aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_pq_lib.h4
-rw-r--r--src/lib/pq/pq_result_helper.c72
2 files changed, 41 insertions, 35 deletions
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h
index 8b4077d0e..7501bee12 100644
--- a/src/include/gnunet_pq_lib.h
+++ b/src/include/gnunet_pq_lib.h
@@ -1136,7 +1136,7 @@ GNUNET_PQ_result_spec_array_string (
1136struct GNUNET_PQ_ResultSpec 1136struct GNUNET_PQ_ResultSpec
1137GNUNET_PQ_result_spec_blind_sign_pub ( 1137GNUNET_PQ_result_spec_blind_sign_pub (
1138 const char *name, 1138 const char *name,
1139 struct GNUNET_CRYPTO_BlindSignPublicKey *public_key); 1139 struct GNUNET_CRYPTO_BlindSignPublicKey **public_key);
1140 1140
1141 1141
1142/** 1142/**
@@ -1149,7 +1149,7 @@ GNUNET_PQ_result_spec_blind_sign_pub (
1149struct GNUNET_PQ_ResultSpec 1149struct GNUNET_PQ_ResultSpec
1150GNUNET_PQ_result_spec_blind_sign_priv ( 1150GNUNET_PQ_result_spec_blind_sign_priv (
1151 const char *name, 1151 const char *name,
1152 struct GNUNET_CRYPTO_BlindSignPrivateKey *private_key); 1152 struct GNUNET_CRYPTO_BlindSignPrivateKey **private_key);
1153 1153
1154/* ************************* pq.c functions ************************ */ 1154/* ************************* pq.c functions ************************ */
1155 1155
diff --git a/src/lib/pq/pq_result_helper.c b/src/lib/pq/pq_result_helper.c
index f8759eba1..cbb1e8e8e 100644
--- a/src/lib/pq/pq_result_helper.c
+++ b/src/lib/pq/pq_result_helper.c
@@ -1816,7 +1816,8 @@ extract_blind_sign_pub (void *cls,
1816 size_t *dst_size, 1816 size_t *dst_size,
1817 void *dst) 1817 void *dst)
1818{ 1818{
1819 struct GNUNET_CRYPTO_BlindSignPublicKey *bpk = dst; 1819 struct GNUNET_CRYPTO_BlindSignPublicKey **bpk = dst;
1820 struct GNUNET_CRYPTO_BlindSignPublicKey *tmp;
1820 size_t len; 1821 size_t len;
1821 const char *res; 1822 const char *res;
1822 int fnum; 1823 int fnum;
@@ -1854,44 +1855,46 @@ extract_blind_sign_pub (void *cls,
1854 sizeof (be)); 1855 sizeof (be));
1855 res += sizeof (be); 1856 res += sizeof (be);
1856 len -= sizeof (be); 1857 len -= sizeof (be);
1857 bpk = GNUNET_new (struct GNUNET_CRYPTO_BlindSignPublicKey); 1858 tmp = GNUNET_new (struct GNUNET_CRYPTO_BlindSignPublicKey);
1858 bpk->cipher = ntohl (be); 1859 tmp->cipher = ntohl (be);
1859 bpk->rc = 1; 1860 tmp->rc = 1;
1860 switch (bpk->cipher) 1861 switch (tmp->cipher)
1861 { 1862 {
1862 case GNUNET_CRYPTO_BSA_INVALID: 1863 case GNUNET_CRYPTO_BSA_INVALID:
1863 break; 1864 break;
1864 case GNUNET_CRYPTO_BSA_RSA: 1865 case GNUNET_CRYPTO_BSA_RSA:
1865 bpk->details.rsa_public_key 1866 tmp->details.rsa_public_key
1866 = GNUNET_CRYPTO_rsa_public_key_decode (res, 1867 = GNUNET_CRYPTO_rsa_public_key_decode (res,
1867 len); 1868 len);
1868 if (NULL == bpk->details.rsa_public_key) 1869 if (NULL == tmp->details.rsa_public_key)
1869 { 1870 {
1870 GNUNET_break (0); 1871 GNUNET_break (0);
1871 GNUNET_free (bpk); 1872 GNUNET_free (tmp);
1872 return GNUNET_SYSERR; 1873 return GNUNET_SYSERR;
1873 } 1874 }
1874 GNUNET_CRYPTO_hash (res, 1875 GNUNET_CRYPTO_hash (res,
1875 len, 1876 len,
1876 &bpk->pub_key_hash); 1877 &tmp->pub_key_hash);
1878 *bpk = tmp;
1877 return GNUNET_OK; 1879 return GNUNET_OK;
1878 case GNUNET_CRYPTO_BSA_CS: 1880 case GNUNET_CRYPTO_BSA_CS:
1879 if (sizeof (bpk->details.cs_public_key) != len) 1881 if (sizeof (tmp->details.cs_public_key) != len)
1880 { 1882 {
1881 GNUNET_break (0); 1883 GNUNET_break (0);
1882 GNUNET_free (bpk); 1884 GNUNET_free (tmp);
1883 return GNUNET_SYSERR; 1885 return GNUNET_SYSERR;
1884 } 1886 }
1885 GNUNET_memcpy (&bpk->details.cs_public_key, 1887 GNUNET_memcpy (&tmp->details.cs_public_key,
1886 res, 1888 res,
1887 len); 1889 len);
1888 GNUNET_CRYPTO_hash (res, 1890 GNUNET_CRYPTO_hash (res,
1889 len, 1891 len,
1890 &bpk->pub_key_hash); 1892 &tmp->pub_key_hash);
1893 *bpk = tmp;
1891 return GNUNET_OK; 1894 return GNUNET_OK;
1892 } 1895 }
1893 GNUNET_break (0); 1896 GNUNET_break (0);
1894 GNUNET_free (bpk); 1897 GNUNET_free (tmp);
1895 return GNUNET_SYSERR; 1898 return GNUNET_SYSERR;
1896} 1899}
1897 1900
@@ -1907,17 +1910,17 @@ static void
1907clean_blind_sign_pub (void *cls, 1910clean_blind_sign_pub (void *cls,
1908 void *rd) 1911 void *rd)
1909{ 1912{
1910 struct GNUNET_CRYPTO_BlindSignPublicKey *pub = rd; 1913 struct GNUNET_CRYPTO_BlindSignPublicKey **pub = rd;
1911 1914
1912 (void) cls; 1915 (void) cls;
1913 GNUNET_CRYPTO_blind_sign_pub_decref (pub); 1916 GNUNET_CRYPTO_blind_sign_pub_decref (*pub);
1914 pub = NULL; 1917 *pub = NULL;
1915} 1918}
1916 1919
1917 1920
1918struct GNUNET_PQ_ResultSpec 1921struct GNUNET_PQ_ResultSpec
1919GNUNET_PQ_result_spec_blind_sign_pub (const char *name, 1922GNUNET_PQ_result_spec_blind_sign_pub (const char *name,
1920 struct GNUNET_CRYPTO_BlindSignPublicKey *pub) 1923 struct GNUNET_CRYPTO_BlindSignPublicKey **pub)
1921{ 1924{
1922 struct GNUNET_PQ_ResultSpec res = { 1925 struct GNUNET_PQ_ResultSpec res = {
1923 .conv = &extract_blind_sign_pub, 1926 .conv = &extract_blind_sign_pub,
@@ -1951,7 +1954,8 @@ extract_blind_sign_priv (void *cls,
1951 size_t *dst_size, 1954 size_t *dst_size,
1952 void *dst) 1955 void *dst)
1953{ 1956{
1954 struct GNUNET_CRYPTO_BlindSignPrivateKey *bpk = dst; 1957 struct GNUNET_CRYPTO_BlindSignPrivateKey **bpk = dst;
1958 struct GNUNET_CRYPTO_BlindSignPrivateKey *tmp;
1955 size_t len; 1959 size_t len;
1956 const char *res; 1960 const char *res;
1957 int fnum; 1961 int fnum;
@@ -1989,38 +1993,40 @@ extract_blind_sign_priv (void *cls,
1989 sizeof (be)); 1993 sizeof (be));
1990 res += sizeof (be); 1994 res += sizeof (be);
1991 len -= sizeof (be); 1995 len -= sizeof (be);
1992 bpk = GNUNET_new (struct GNUNET_CRYPTO_BlindSignPrivateKey); 1996 tmp = GNUNET_new (struct GNUNET_CRYPTO_BlindSignPrivateKey);
1993 bpk->cipher = ntohl (be); 1997 tmp->cipher = ntohl (be);
1994 bpk->rc = 1; 1998 tmp->rc = 1;
1995 switch (bpk->cipher) 1999 switch (tmp->cipher)
1996 { 2000 {
1997 case GNUNET_CRYPTO_BSA_INVALID: 2001 case GNUNET_CRYPTO_BSA_INVALID:
1998 break; 2002 break;
1999 case GNUNET_CRYPTO_BSA_RSA: 2003 case GNUNET_CRYPTO_BSA_RSA:
2000 bpk->details.rsa_private_key 2004 tmp->details.rsa_private_key
2001 = GNUNET_CRYPTO_rsa_private_key_decode (res, 2005 = GNUNET_CRYPTO_rsa_private_key_decode (res,
2002 len); 2006 len);
2003 if (NULL == bpk->details.rsa_private_key) 2007 if (NULL == tmp->details.rsa_private_key)
2004 { 2008 {
2005 GNUNET_break (0); 2009 GNUNET_break (0);
2006 GNUNET_free (bpk); 2010 GNUNET_free (bpk);
2007 return GNUNET_SYSERR; 2011 return GNUNET_SYSERR;
2008 } 2012 }
2013 *bpk = tmp;
2009 return GNUNET_OK; 2014 return GNUNET_OK;
2010 case GNUNET_CRYPTO_BSA_CS: 2015 case GNUNET_CRYPTO_BSA_CS:
2011 if (sizeof (bpk->details.cs_private_key) != len) 2016 if (sizeof (tmp->details.cs_private_key) != len)
2012 { 2017 {
2013 GNUNET_break (0); 2018 GNUNET_break (0);
2014 GNUNET_free (bpk); 2019 GNUNET_free (tmp);
2015 return GNUNET_SYSERR; 2020 return GNUNET_SYSERR;
2016 } 2021 }
2017 GNUNET_memcpy (&bpk->details.cs_private_key, 2022 GNUNET_memcpy (&tmp->details.cs_private_key,
2018 res, 2023 res,
2019 len); 2024 len);
2025 *bpk = tmp;
2020 return GNUNET_OK; 2026 return GNUNET_OK;
2021 } 2027 }
2022 GNUNET_break (0); 2028 GNUNET_break (0);
2023 GNUNET_free (bpk); 2029 GNUNET_free (tmp);
2024 return GNUNET_SYSERR; 2030 return GNUNET_SYSERR;
2025} 2031}
2026 2032
@@ -2036,17 +2042,17 @@ static void
2036clean_blind_sign_priv (void *cls, 2042clean_blind_sign_priv (void *cls,
2037 void *rd) 2043 void *rd)
2038{ 2044{
2039 struct GNUNET_CRYPTO_BlindSignPublicKey *pub = rd; 2045 struct GNUNET_CRYPTO_BlindSignPrivateKey **priv = rd;
2040 2046
2041 (void) cls; 2047 (void) cls;
2042 GNUNET_CRYPTO_blind_sign_pub_decref (pub); 2048 GNUNET_CRYPTO_blind_sign_priv_decref (*priv);
2043 pub = NULL; 2049 *priv = NULL;
2044} 2050}
2045 2051
2046 2052
2047struct GNUNET_PQ_ResultSpec 2053struct GNUNET_PQ_ResultSpec
2048GNUNET_PQ_result_spec_blind_sign_priv (const char *name, 2054GNUNET_PQ_result_spec_blind_sign_priv (const char *name,
2049 struct GNUNET_CRYPTO_BlindSignPrivateKey *priv) 2055 struct GNUNET_CRYPTO_BlindSignPrivateKey **priv)
2050{ 2056{
2051 struct GNUNET_PQ_ResultSpec res = { 2057 struct GNUNET_PQ_ResultSpec res = {
2052 .conv = &extract_blind_sign_priv, 2058 .conv = &extract_blind_sign_priv,