diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-05-24 18:14:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-05-24 18:14:04 +0000 |
commit | 425065e903d0eb1a4a1faeaf183401fa49e9560b (patch) | |
tree | a64ed547fb3154917743692a65c4bdf38e330c6a /src/include/gnunet_crypto_lib.h | |
parent | b2bbad6a70f3d7e089b14f282dd8e6a4dfe6ce46 (diff) | |
download | gnunet-425065e903d0eb1a4a1faeaf183401fa49e9560b.tar.gz gnunet-425065e903d0eb1a4a1faeaf183401fa49e9560b.zip |
fixing #4483: optimize blinding key storage/transmission
Diffstat (limited to 'src/include/gnunet_crypto_lib.h')
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 76 |
1 files changed, 13 insertions, 63 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 63978617c..bd95ad3c3 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -1787,9 +1787,16 @@ struct GNUNET_CRYPTO_RsaPrivateKey; | |||
1787 | struct GNUNET_CRYPTO_RsaPublicKey; | 1787 | struct GNUNET_CRYPTO_RsaPublicKey; |
1788 | 1788 | ||
1789 | /** | 1789 | /** |
1790 | * Key used to blind a message | 1790 | * Constant-size pre-secret for blinding key generation. |
1791 | */ | 1791 | */ |
1792 | struct GNUNET_CRYPTO_RsaBlindingKey; | 1792 | struct GNUNET_CRYPTO_RsaBlindingKeySecret |
1793 | { | ||
1794 | /** | ||
1795 | * Bits used to generate the blinding key. 256 bits | ||
1796 | * of entropy is enough. | ||
1797 | */ | ||
1798 | uint32_t pre_secret[8] GNUNET_PACKED; | ||
1799 | }; | ||
1793 | 1800 | ||
1794 | /** | 1801 | /** |
1795 | * @brief an RSA signature | 1802 | * @brief an RSA signature |
@@ -1929,28 +1936,6 @@ GNUNET_CRYPTO_rsa_public_key_dup (const struct GNUNET_CRYPTO_RsaPublicKey *key); | |||
1929 | 1936 | ||
1930 | 1937 | ||
1931 | /** | 1938 | /** |
1932 | * Create a blinding key | ||
1933 | * | ||
1934 | * @param len length of the key in bits (i.e. 2048) | ||
1935 | * @return the newly created blinding key | ||
1936 | */ | ||
1937 | struct GNUNET_CRYPTO_RsaBlindingKey * | ||
1938 | GNUNET_CRYPTO_rsa_blinding_key_create (unsigned int len); | ||
1939 | |||
1940 | |||
1941 | /** | ||
1942 | * Compare the values of two blinding keys. | ||
1943 | * | ||
1944 | * @param b1 one key | ||
1945 | * @param b2 the other key | ||
1946 | * @return 0 if the two are equal | ||
1947 | */ | ||
1948 | int | ||
1949 | GNUNET_CRYPTO_rsa_blinding_key_cmp (struct GNUNET_CRYPTO_RsaBlindingKey *b1, | ||
1950 | struct GNUNET_CRYPTO_RsaBlindingKey *b2); | ||
1951 | |||
1952 | |||
1953 | /** | ||
1954 | * Compare the values of two signatures. | 1939 | * Compare the values of two signatures. |
1955 | * | 1940 | * |
1956 | * @param s1 one signature | 1941 | * @param s1 one signature |
@@ -1986,52 +1971,17 @@ GNUNET_CRYPTO_rsa_public_key_cmp (struct GNUNET_CRYPTO_RsaPublicKey *p1, | |||
1986 | 1971 | ||
1987 | 1972 | ||
1988 | /** | 1973 | /** |
1989 | * Destroy a blinding key | ||
1990 | * | ||
1991 | * @param bkey the blinding key to destroy | ||
1992 | */ | ||
1993 | void | ||
1994 | GNUNET_CRYPTO_rsa_blinding_key_free (struct GNUNET_CRYPTO_RsaBlindingKey *bkey); | ||
1995 | |||
1996 | |||
1997 | /** | ||
1998 | * Encode the blinding key in a format suitable for | ||
1999 | * storing it into a file. | ||
2000 | * | ||
2001 | * @param bkey the blinding key | ||
2002 | * @param[out] buffer set to a buffer with the encoded key | ||
2003 | * @return size of memory allocated in @a buffer | ||
2004 | */ | ||
2005 | size_t | ||
2006 | GNUNET_CRYPTO_rsa_blinding_key_encode (const struct GNUNET_CRYPTO_RsaBlindingKey *bkey, | ||
2007 | char **buffer); | ||
2008 | |||
2009 | |||
2010 | /** | ||
2011 | * Decode the blinding key from the data-format back | ||
2012 | * to the "normal", internal format. | ||
2013 | * | ||
2014 | * @param buf the buffer where the public key data is stored | ||
2015 | * @param len the length of the data in @a buf | ||
2016 | * @return NULL on error | ||
2017 | */ | ||
2018 | struct GNUNET_CRYPTO_RsaBlindingKey * | ||
2019 | GNUNET_CRYPTO_rsa_blinding_key_decode (const char *buf, | ||
2020 | size_t len); | ||
2021 | |||
2022 | |||
2023 | /** | ||
2024 | * Blinds the given message with the given blinding key | 1974 | * Blinds the given message with the given blinding key |
2025 | * | 1975 | * |
2026 | * @param hash hash of the message to sign | 1976 | * @param hash hash of the message to sign |
2027 | * @param bkey the blinding key | 1977 | * @param bks the blinding key secret |
2028 | * @param pkey the public key of the signer | 1978 | * @param pkey the public key of the signer |
2029 | * @param[out] buffer set to a buffer with the blinded message to be signed | 1979 | * @param[out] buffer set to a buffer with the blinded message to be signed |
2030 | * @return number of bytes stored in @a buffer | 1980 | * @return number of bytes stored in @a buffer |
2031 | */ | 1981 | */ |
2032 | size_t | 1982 | size_t |
2033 | GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, | 1983 | GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, |
2034 | struct GNUNET_CRYPTO_RsaBlindingKey *bkey, | 1984 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, |
2035 | struct GNUNET_CRYPTO_RsaPublicKey *pkey, | 1985 | struct GNUNET_CRYPTO_RsaPublicKey *pkey, |
2036 | char **buffer); | 1986 | char **buffer); |
2037 | 1987 | ||
@@ -2112,13 +2062,13 @@ GNUNET_CRYPTO_rsa_signature_dup (const struct GNUNET_CRYPTO_RsaSignature *sig); | |||
2112 | * #GNUNET_CRYPTO_rsa_blind(). | 2062 | * #GNUNET_CRYPTO_rsa_blind(). |
2113 | * | 2063 | * |
2114 | * @param sig the signature made on the blinded signature purpose | 2064 | * @param sig the signature made on the blinded signature purpose |
2115 | * @param bkey the blinding key used to blind the signature purpose | 2065 | * @param bks the blinding key secret used to blind the signature purpose |
2116 | * @param pkey the public key of the signer | 2066 | * @param pkey the public key of the signer |
2117 | * @return unblinded signature on success, NULL on error | 2067 | * @return unblinded signature on success, NULL on error |
2118 | */ | 2068 | */ |
2119 | struct GNUNET_CRYPTO_RsaSignature * | 2069 | struct GNUNET_CRYPTO_RsaSignature * |
2120 | GNUNET_CRYPTO_rsa_unblind (struct GNUNET_CRYPTO_RsaSignature *sig, | 2070 | GNUNET_CRYPTO_rsa_unblind (struct GNUNET_CRYPTO_RsaSignature *sig, |
2121 | struct GNUNET_CRYPTO_RsaBlindingKey *bkey, | 2071 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, |
2122 | struct GNUNET_CRYPTO_RsaPublicKey *pkey); | 2072 | struct GNUNET_CRYPTO_RsaPublicKey *pkey); |
2123 | 2073 | ||
2124 | 2074 | ||