Chaum-style Blind signatures based on RSA. More...
Go to the source code of this file.
Data Structures | |
struct | GNUNET_CRYPTO_RsaPrivateKey |
The private information of an RSA key pair. More... | |
struct | GNUNET_CRYPTO_RsaPublicKey |
The public information of an RSA key pair. More... | |
struct | GNUNET_CRYPTO_RsaSignature |
an RSA signature More... | |
struct | RsaBlindingKey |
RSA blinding key. More... | |
struct | GNUNET_CRYPTO_RsaPublicKeyHeaderP |
Format of the header of a serialized RSA public key. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-rsa", __VA_ARGS__) |
Functions | |
static int | key_from_sexp (gcry_mpi_t *array, gcry_sexp_t sexp, const char *topname, const char *elems) |
Extract values from an S-expression. More... | |
struct GNUNET_CRYPTO_RsaPrivateKey * | GNUNET_CRYPTO_rsa_private_key_create (unsigned int len) |
Create a new private key. More... | |
void | GNUNET_CRYPTO_rsa_private_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *key) |
Free memory occupied by the private key. More... | |
size_t | GNUNET_CRYPTO_rsa_private_key_encode (const struct GNUNET_CRYPTO_RsaPrivateKey *key, void **buffer) |
Encode the private key in a format suitable for storing it into a file. More... | |
struct GNUNET_CRYPTO_RsaPrivateKey * | GNUNET_CRYPTO_rsa_private_key_decode (const void *buf, size_t buf_size) |
Decode the private key from the data-format back to the "normal", internal format. More... | |
struct GNUNET_CRYPTO_RsaPublicKey * | GNUNET_CRYPTO_rsa_private_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey *priv) |
Extract the public key of the given private key. More... | |
void | GNUNET_CRYPTO_rsa_public_key_free (struct GNUNET_CRYPTO_RsaPublicKey *key) |
Free memory occupied by the public key. More... | |
GNUNET_NETWORK_STRUCT_END bool | GNUNET_CRYPTO_rsa_public_key_check (const struct GNUNET_CRYPTO_RsaPublicKey *key) |
Check if key is well-formed. More... | |
size_t | GNUNET_CRYPTO_rsa_public_key_encode (const struct GNUNET_CRYPTO_RsaPublicKey *key, void **buffer) |
Encode the public key in a format suitable for storing it into a file. More... | |
void | GNUNET_CRYPTO_rsa_public_key_hash (const struct GNUNET_CRYPTO_RsaPublicKey *key, struct GNUNET_HashCode *hc) |
Compute hash over the public key. More... | |
struct GNUNET_CRYPTO_RsaPublicKey * | GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len) |
Decode the public key from the data-format back to the "normal", internal format. More... | |
static int | rsa_gcd_validate (gcry_mpi_t r, gcry_mpi_t n) |
Test for malicious RSA key. More... | |
static struct RsaBlindingKey * | rsa_blinding_key_derive (const struct GNUNET_CRYPTO_RsaPublicKey *pkey, const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks) |
Create a blinding key. More... | |
int | GNUNET_CRYPTO_rsa_signature_cmp (const struct GNUNET_CRYPTO_RsaSignature *s1, const struct GNUNET_CRYPTO_RsaSignature *s2) |
Compare the values of two signatures. More... | |
int | GNUNET_CRYPTO_rsa_public_key_cmp (const struct GNUNET_CRYPTO_RsaPublicKey *p1, const struct GNUNET_CRYPTO_RsaPublicKey *p2) |
Compare the values of two public keys. More... | |
int | GNUNET_CRYPTO_rsa_private_key_cmp (const struct GNUNET_CRYPTO_RsaPrivateKey *p1, const struct GNUNET_CRYPTO_RsaPrivateKey *p2) |
Compare the values of two private keys. More... | |
unsigned int | GNUNET_CRYPTO_rsa_public_key_len (const struct GNUNET_CRYPTO_RsaPublicKey *key) |
Obtain the length of the RSA key in bits. More... | |
static void | rsa_blinding_key_free (struct RsaBlindingKey *bkey) |
Destroy a blinding key. More... | |
static size_t | numeric_mpi_alloc_n_print (gcry_mpi_t v, char **buffer) |
Print an MPI to a newly created buffer. More... | |
static gcry_mpi_t | rsa_full_domain_hash (const struct GNUNET_CRYPTO_RsaPublicKey *pkey, const void *message, size_t message_size) |
Computes a full domain hash seeded by the given public key. More... | |
void | GNUNET_CRYPTO_rsa_blinded_message_free (struct GNUNET_CRYPTO_RsaBlindedMessage *bm) |
Free memory occupied by blinded message. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CRYPTO_rsa_blind (const void *message, size_t message_size, const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, struct GNUNET_CRYPTO_RsaPublicKey *pkey, struct GNUNET_CRYPTO_RsaBlindedMessage *bm) |
Blinds the given message with the given blinding key. More... | |
static gcry_sexp_t | mpi_to_sexp (gcry_mpi_t value) |
Convert an MPI to an S-expression suitable for signature operations. More... | |
static struct GNUNET_CRYPTO_RsaSignature * | rsa_sign_mpi (const struct GNUNET_CRYPTO_RsaPrivateKey *key, gcry_mpi_t value) |
Sign the given MPI. More... | |
struct GNUNET_CRYPTO_RsaSignature * | GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, const struct GNUNET_CRYPTO_RsaBlindedMessage *bm) |
Sign a blinded value, which must be a full domain hash of a message. More... | |
struct GNUNET_CRYPTO_RsaSignature * | GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, const void *message, size_t message_size) |
Create and sign a full domain hash of a message. More... | |
void | GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig) |
Free memory occupied by signature. More... | |
size_t | GNUNET_CRYPTO_rsa_signature_encode (const struct GNUNET_CRYPTO_RsaSignature *sig, void **buffer) |
Encode the given signature in a format suitable for storing it into a file. More... | |
struct GNUNET_CRYPTO_RsaSignature * | GNUNET_CRYPTO_rsa_signature_decode (const void *buf, size_t buf_size) |
Decode the signature from the data-format back to the "normal", internal format. More... | |
struct GNUNET_CRYPTO_RsaPublicKey * | GNUNET_CRYPTO_rsa_public_key_dup (const struct GNUNET_CRYPTO_RsaPublicKey *key) |
Duplicate the given public key. More... | |
struct GNUNET_CRYPTO_RsaSignature * | GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, struct GNUNET_CRYPTO_RsaPublicKey *pkey) |
Unblind a blind-signed signature. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CRYPTO_rsa_verify (const void *message, size_t message_size, const struct GNUNET_CRYPTO_RsaSignature *sig, const struct GNUNET_CRYPTO_RsaPublicKey *pkey) |
Verify whether the given hash corresponds to the given signature and the signature is valid with respect to the given public key. More... | |
struct GNUNET_CRYPTO_RsaPrivateKey * | GNUNET_CRYPTO_rsa_private_key_dup (const struct GNUNET_CRYPTO_RsaPrivateKey *key) |
Duplicate the given private key. More... | |
struct GNUNET_CRYPTO_RsaSignature * | GNUNET_CRYPTO_rsa_signature_dup (const struct GNUNET_CRYPTO_RsaSignature *sig) |
Duplicate the given rsa signature. More... | |
Chaum-style Blind signatures based on RSA.
Definition in file crypto_rsa.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "util-crypto-rsa", __VA_ARGS__) |
Definition at line 34 of file crypto_rsa.c.
|
static |
Extract values from an S-expression.
array | where to store the result(s) |
sexp | S-expression to parse |
topname | top-level name in the S-expression that is of interest |
elems | names of the elements to extract |
Definition at line 95 of file crypto_rsa.c.
References list.
Referenced by GNUNET_CRYPTO_rsa_blind(), GNUNET_CRYPTO_rsa_private_key_get_public(), GNUNET_CRYPTO_rsa_public_key_check(), GNUNET_CRYPTO_rsa_public_key_encode(), GNUNET_CRYPTO_rsa_public_key_len(), GNUNET_CRYPTO_rsa_signature_dup(), GNUNET_CRYPTO_rsa_signature_encode(), GNUNET_CRYPTO_rsa_unblind(), rsa_blinding_key_derive(), and rsa_full_domain_hash().
|
static |
Test for malicious RSA key.
Assuming n is an RSA modulous and r is generated using a call to GNUNET_CRYPTO_kdf_mod_mpi, if gcd(r,n) != 1 then n must be a malicious RSA key designed to deanomize the user.
r | KDF result |
n | RSA modulus |
Definition at line 501 of file crypto_rsa.c.
References t.
Referenced by rsa_blinding_key_derive(), and rsa_full_domain_hash().
|
static |
Create a blinding key.
len | length of the key in bits (e.g. 2048) |
bks | pre-secret to use to derive the blinding key |
Definition at line 522 of file crypto_rsa.c.
References GNUNET_assert, GNUNET_CRYPTO_kdf_mod_mpi(), GNUNET_free, GNUNET_new, key_from_sexp(), pkey, RsaBlindingKey::r, and rsa_gcd_validate().
Referenced by GNUNET_CRYPTO_rsa_blind(), and GNUNET_CRYPTO_rsa_unblind().
|
static |
Destroy a blinding key.
bkey | the blinding key to destroy |
Definition at line 702 of file crypto_rsa.c.
References GNUNET_free, and RsaBlindingKey::r.
Referenced by GNUNET_CRYPTO_rsa_blind(), and GNUNET_CRYPTO_rsa_unblind().
|
static |
Print an MPI to a newly created buffer.
v | MPI to print. | |
[out] | buffer | newly allocated buffer containing the result |
Definition at line 717 of file crypto_rsa.c.
References GNUNET_assert, and GNUNET_malloc.
Referenced by GNUNET_CRYPTO_rsa_blind().
|
static |
Computes a full domain hash seeded by the given public key.
This gives a measure of provable security to the Taler exchange against one-more forgery attacks. See: https://eprint.iacr.org/2001/002.pdf http://www.di.ens.fr/~pointche/Documents/Papers/2001_fcA.pdf
message | the message to sign |
message_size | number of bytes in message |
pkey | the public key of the signer |
rsize | If not NULL, the number of bytes actually stored in buffer |
Definition at line 755 of file crypto_rsa.c.
References GNUNET_assert, GNUNET_CRYPTO_kdf_mod_mpi(), GNUNET_CRYPTO_rsa_public_key_encode(), GNUNET_free, key_from_sexp(), pkey, RsaBlindingKey::r, and rsa_gcd_validate().
Referenced by GNUNET_CRYPTO_rsa_blind(), GNUNET_CRYPTO_rsa_sign_fdh(), and GNUNET_CRYPTO_rsa_verify().
|
static |
Convert an MPI to an S-expression suitable for signature operations.
value | pointer to the data to convert |
Definition at line 894 of file crypto_rsa.c.
References data, GNUNET_assert, and value.
Referenced by GNUNET_CRYPTO_rsa_verify(), and rsa_sign_mpi().
|
static |
Sign the given MPI.
key | private key to use for the signing |
value | the MPI to sign |
Definition at line 915 of file crypto_rsa.c.
References _, data, GNUNET_break, GNUNET_CRYPTO_rsa_private_key_get_public(), GNUNET_CRYPTO_rsa_public_key_free(), GNUNET_ERROR_TYPE_WARNING, GNUNET_new, key, LOG, mpi_to_sexp(), result, GNUNET_CRYPTO_RsaPublicKey::sexp, GNUNET_CRYPTO_RsaSignature::sexp, and value.
Referenced by GNUNET_CRYPTO_rsa_sign_blinded(), and GNUNET_CRYPTO_rsa_sign_fdh().