diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-08-08 08:25:31 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-08-08 08:25:31 +0200 |
commit | b0d560bfcdb2d868a65666e88ba72b7cbd88415e (patch) | |
tree | 86cbb0c71fdd3eef35c9ef3c4c596a6d6eac9a89 /lib/nettle | |
parent | 183ddf5b0a5a483c4c5890cf8a5cbe07e5008554 (diff) | |
download | gnutls-b0d560bfcdb2d868a65666e88ba72b7cbd88415e.tar.gz |
Revert "nettle: use rsa_*_key_prepare"
This reverts commit c801a15bca9ea8f3f7abd4be48bebd36c54eeba2.
Diffstat (limited to 'lib/nettle')
-rw-r--r-- | lib/nettle/pk.c | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/lib/nettle/pk.c b/lib/nettle/pk.c index ca15d847a8..2fab308112 100644 --- a/lib/nettle/pk.c +++ b/lib/nettle/pk.c @@ -88,8 +88,7 @@ _dsa_params_get(const gnutls_pk_params_st * pk_params, memcpy(pub->g, pk_params->params[DSA_G], SIZEOF_MPZT); } -/* returns 0 on invalid privkey */ -static unsigned +static void _rsa_params_to_privkey(const gnutls_pk_params_st * pk_params, struct rsa_private_key *priv) { @@ -99,18 +98,18 @@ _rsa_params_to_privkey(const gnutls_pk_params_st * pk_params, memcpy(priv->c, pk_params->params[5], SIZEOF_MPZT); memcpy(priv->a, pk_params->params[6], SIZEOF_MPZT); memcpy(priv->b, pk_params->params[7], SIZEOF_MPZT); - return (unsigned)rsa_private_key_prepare(priv); + priv->size = + nettle_mpz_sizeinbase_256_u(TOMPZ + (pk_params->params[RSA_MODULUS])); } -/* returns 0 on invalid pubkey */ -static unsigned +static void _rsa_params_to_pubkey(const gnutls_pk_params_st * pk_params, struct rsa_public_key *pub) { memcpy(pub->n, pk_params->params[RSA_MODULUS], SIZEOF_MPZT); memcpy(pub->e, pk_params->params[RSA_PUB], SIZEOF_MPZT); - - return (unsigned)rsa_public_key_prepare(pub); + pub->size = nettle_mpz_sizeinbase_256_u(pub->n); } static int @@ -341,13 +340,7 @@ _wrap_nettle_pk_encrypt(gnutls_pk_algorithm_t algo, { struct rsa_public_key pub; - ret = _rsa_params_to_pubkey(pk_params, &pub); - if (ret == 0) { - ret = - gnutls_assert_val - (GNUTLS_E_ENCRYPTION_FAILED); - goto cleanup; - } + _rsa_params_to_pubkey(pk_params, &pub); ret = rsa_encrypt(&pub, NULL, rnd_func, @@ -404,13 +397,8 @@ _wrap_nettle_pk_decrypt(gnutls_pk_algorithm_t algo, size_t length; bigint_t c; - ret = _rsa_params_to_privkey(pk_params, &priv); - if (ret == 0) - return gnutls_assert_val(GNUTLS_E_DECRYPTION_FAILED); - - ret = _rsa_params_to_pubkey(pk_params, &pub); - if (ret == 0) - return gnutls_assert_val(GNUTLS_E_DECRYPTION_FAILED); + _rsa_params_to_privkey(pk_params, &priv); + _rsa_params_to_pubkey(pk_params, &pub); if (ciphertext->size != pub.size) return @@ -581,13 +569,8 @@ _wrap_nettle_pk_sign(gnutls_pk_algorithm_t algo, struct rsa_public_key pub; mpz_t s; - ret = _rsa_params_to_privkey(pk_params, &priv); - if (ret == 0) - return gnutls_assert_val(GNUTLS_E_PK_SIGN_FAILED); - - ret = _rsa_params_to_pubkey(pk_params, &pub); - if (ret == 0) - return gnutls_assert_val(GNUTLS_E_PK_SIGN_FAILED); + _rsa_params_to_privkey(pk_params, &priv); + _rsa_params_to_pubkey(pk_params, &pub); mpz_init(s); @@ -724,10 +707,7 @@ _wrap_nettle_pk_verify(gnutls_pk_algorithm_t algo, { struct rsa_public_key pub; - ret = _rsa_params_to_pubkey(pk_params, &pub); - if (ret == 0) { - return gnutls_assert_val(GNUTLS_E_PK_SIG_VERIFY_FAILED); - } + _rsa_params_to_pubkey(pk_params, &pub); if (signature->size != pub.size) return |