Remove TALER_RSA_hash_sign() and TALER_RSA_hash_verify().
This commit is contained in:
parent
ce9da7f183
commit
b119131873
@ -229,7 +229,8 @@ TALER_RSA_public_key_from_string (const char *enc,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign a given block.h
|
* Sign a given data block. The size of the message should be less than
|
||||||
|
* TALER_RSA_DATA_ENCODING_LENGTH (256) bytes.
|
||||||
*
|
*
|
||||||
* @param key private key to use for the signing
|
* @param key private key to use for the signing
|
||||||
* @param msg the message
|
* @param msg the message
|
||||||
@ -245,21 +246,8 @@ TALER_RSA_sign (const struct TALER_RSA_PrivateKey *key,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify signature with the given hash.
|
* Verify signature on the given message. The size of the message should be
|
||||||
*
|
* less than TALER_RSA_DATA_ENCODING_LENGTH (256) bytes.
|
||||||
* @param hash the hash code to verify against the signature
|
|
||||||
* @param sig signature that is being validated
|
|
||||||
* @param publicKey public key of the signer
|
|
||||||
* @returns GNUNET_OK if ok, GNUNET_SYSERR if invalid
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
TALER_RSA_hash_verify (const struct GNUNET_HashCode *hash,
|
|
||||||
const struct TALER_RSA_Signature *sig,
|
|
||||||
const struct TALER_RSA_PublicKeyBinaryEncoded *publicKey);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify signature on the given message
|
|
||||||
*
|
*
|
||||||
* @param msg the message
|
* @param msg the message
|
||||||
* @param size the size of the message
|
* @param size the size of the message
|
||||||
|
@ -578,18 +578,19 @@ data_to_sexp (const void *ptr, size_t size)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign the given hash block.
|
* Sign the given message. The size of the message should be less than
|
||||||
|
* TALER_RSA_DATA_ENCODING_LENGTH (256) bytes.
|
||||||
*
|
*
|
||||||
* @param key private key to use for the signing
|
* @param key private key to use for the signing
|
||||||
* @param hash the block containing the hash of the message to sign
|
* @param msg the message
|
||||||
* @param hash_size the size of the hash block
|
* @param size the size of the message
|
||||||
* @param sig where to write the signature
|
* @param sig where to write the signature
|
||||||
* @return GNUNET_SYSERR on error, GNUNET_OK on success
|
* @return GNUNET_SYSERR on error, GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_RSA_sign (const struct TALER_RSA_PrivateKey *key,
|
TALER_RSA_sign (const struct TALER_RSA_PrivateKey *key,
|
||||||
const void *hash,
|
const void *msg,
|
||||||
size_t hash_size,
|
size_t size,
|
||||||
struct TALER_RSA_Signature *sig)
|
struct TALER_RSA_Signature *sig)
|
||||||
{
|
{
|
||||||
gcry_sexp_t result;
|
gcry_sexp_t result;
|
||||||
@ -597,7 +598,10 @@ TALER_RSA_sign (const struct TALER_RSA_PrivateKey *key,
|
|||||||
size_t ssize;
|
size_t ssize;
|
||||||
gcry_mpi_t rval;
|
gcry_mpi_t rval;
|
||||||
|
|
||||||
data = data_to_sexp (hash, hash_size);
|
GNUNET_assert (size <= TALER_RSA_DATA_ENCODING_LENGTH);
|
||||||
|
if (size > TALER_RSA_DATA_ENCODING_LENGTH)
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
data = data_to_sexp (msg, size);
|
||||||
GNUNET_assert (0 == gcry_pk_sign (&result, data, key->sexp));
|
GNUNET_assert (0 == gcry_pk_sign (&result, data, key->sexp));
|
||||||
gcry_sexp_release (data);
|
gcry_sexp_release (data);
|
||||||
GNUNET_assert (0 == key_from_sexp (&rval, result, "rsa", "s"));
|
GNUNET_assert (0 == key_from_sexp (&rval, result, "rsa", "s"));
|
||||||
@ -666,35 +670,42 @@ decode_public_key (const struct TALER_RSA_PublicKeyBinaryEncoded *publicKey)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify signature with the given hash.
|
* Verify signature on the given message. The size of the message should be less than
|
||||||
|
* TALER_RSA_DATA_ENCODING_LENGTH (256) bytes.
|
||||||
*
|
*
|
||||||
* @param hash the hash code to verify against the signature
|
* @param msg the message
|
||||||
|
* @param size the size of the message
|
||||||
* @param sig signature that is being validated
|
* @param sig signature that is being validated
|
||||||
* @param publicKey public key of the signer
|
* @param publicKey public key of the signer
|
||||||
* @returns GNUNET_OK if ok, GNUNET_SYSERR if invalid
|
* @returns GNUNET_OK if ok, GNUNET_SYSERR if invalid
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_RSA_hash_verify (const struct GNUNET_HashCode *hash,
|
TALER_RSA_verify (const void *msg, size_t size,
|
||||||
const struct TALER_RSA_Signature *sig,
|
const struct TALER_RSA_Signature *sig,
|
||||||
const struct TALER_RSA_PublicKeyBinaryEncoded *publicKey)
|
const struct TALER_RSA_PublicKeyBinaryEncoded *publicKey)
|
||||||
{
|
{
|
||||||
gcry_sexp_t data;
|
gcry_sexp_t data;
|
||||||
gcry_sexp_t sigdata;
|
gcry_sexp_t sigdata;
|
||||||
size_t size;
|
size_t sig_size;
|
||||||
gcry_mpi_t val;
|
gcry_mpi_t val;
|
||||||
gcry_sexp_t psexp;
|
gcry_sexp_t psexp;
|
||||||
size_t erroff;
|
size_t erroff;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
size = sizeof (struct TALER_RSA_Signature);
|
GNUNET_assert (size <= TALER_RSA_DATA_ENCODING_LENGTH);
|
||||||
|
if (size > TALER_RSA_DATA_ENCODING_LENGTH)
|
||||||
|
return GNUNET_SYSERR;
|
||||||
GNUNET_assert (0 ==
|
GNUNET_assert (0 ==
|
||||||
gcry_mpi_scan (&val, GCRYMPI_FMT_USG,
|
gcry_mpi_scan (&val, GCRYMPI_FMT_USG,
|
||||||
(const unsigned char *) sig, size, &size));
|
(const unsigned char *) sig,
|
||||||
|
sizeof (struct TALER_RSA_Signature),
|
||||||
|
&sig_size));
|
||||||
|
GNUNET_assert (sizeof (struct TALER_RSA_Signature) == sig_size);
|
||||||
GNUNET_assert (0 ==
|
GNUNET_assert (0 ==
|
||||||
gcry_sexp_build (&sigdata, &erroff, "(sig-val(rsa(s %m)))",
|
gcry_sexp_build (&sigdata, &erroff, "(sig-val(rsa(s %m)))",
|
||||||
val));
|
val));
|
||||||
gcry_mpi_release (val);
|
gcry_mpi_release (val);
|
||||||
data = data_to_sexp (hash, sizeof (struct GNUNET_HashCode));
|
data = data_to_sexp (msg, size);
|
||||||
if (! (psexp = decode_public_key (publicKey)))
|
if (! (psexp = decode_public_key (publicKey)))
|
||||||
{
|
{
|
||||||
gcry_sexp_release (data);
|
gcry_sexp_release (data);
|
||||||
@ -715,27 +726,6 @@ TALER_RSA_hash_verify (const struct GNUNET_HashCode *hash,
|
|||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify signature on the given message
|
|
||||||
*
|
|
||||||
* @param msg the message
|
|
||||||
* @param size the size of the message
|
|
||||||
* @param sig signature that is being validated
|
|
||||||
* @param publicKey public key of the signer
|
|
||||||
* @returns GNUNET_OK if ok, GNUNET_SYSERR if invalid
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
TALER_RSA_verify (const void *msg, size_t size,
|
|
||||||
const struct TALER_RSA_Signature *sig,
|
|
||||||
const struct TALER_RSA_PublicKeyBinaryEncoded *publicKey)
|
|
||||||
{
|
|
||||||
struct GNUNET_HashCode hash;
|
|
||||||
|
|
||||||
GNUNET_CRYPTO_hash (msg, size, &hash);
|
|
||||||
return TALER_RSA_hash_verify (&hash, sig, publicKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The blinding key is equal in length to the RSA modulus
|
* The blinding key is equal in length to the RSA modulus
|
||||||
*/
|
*/
|
||||||
|
@ -69,11 +69,7 @@ main (int argc, char *argv[])
|
|||||||
ntohs (priv_enc->len))));
|
ntohs (priv_enc->len))));
|
||||||
GNUNET_free (priv_enc);
|
GNUNET_free (priv_enc);
|
||||||
priv_enc = NULL;
|
priv_enc = NULL;
|
||||||
EXITIF (GNUNET_OK != TALER_RSA_hash_verify (&hash,
|
EXITIF (GNUNET_OK != TALER_RSA_verify (&hash, sizeof (hash),
|
||||||
&sig,
|
|
||||||
&pubkey));
|
|
||||||
EXITIF (GNUNET_OK != TALER_RSA_verify (rnd_blk,
|
|
||||||
RND_BLK_SIZE,
|
|
||||||
&sig,
|
&sig,
|
||||||
&pubkey));
|
&pubkey));
|
||||||
|
|
||||||
@ -93,9 +89,9 @@ main (int argc, char *argv[])
|
|||||||
EXITIF (GNUNET_OK != TALER_RSA_unblind (&sig,
|
EXITIF (GNUNET_OK != TALER_RSA_unblind (&sig,
|
||||||
bkey,
|
bkey,
|
||||||
&pubkey));
|
&pubkey));
|
||||||
EXITIF (GNUNET_OK != TALER_RSA_hash_verify (&hash,
|
EXITIF (GNUNET_OK != TALER_RSA_verify (&hash, sizeof (hash),
|
||||||
&sig,
|
&sig,
|
||||||
&pubkey));
|
&pubkey));
|
||||||
ret = 0; /* all OK */
|
ret = 0; /* all OK */
|
||||||
|
|
||||||
EXITIF_exit:
|
EXITIF_exit:
|
||||||
|
Loading…
Reference in New Issue
Block a user