bignum: harmonize gcrypt, libcrypto and libmcrypt bignum

Ensure most of the abstraction around the 3 libs are consistent.

Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Aris Adamantiadis
2015-12-31 10:48:34 +01:00
committed by Andreas Schneider
parent 43a4f86b6e
commit afe2673cfa
11 changed files with 178 additions and 219 deletions

View File

@@ -128,12 +128,6 @@ int ecdh_build_k(ssh_session session) {
return -1;
}
session->next_crypto->k = bignum_new();
if (session->next_crypto->k == NULL) {
bignum_ctx_free(ctx);
return -1;
}
pubkey = EC_POINT_new(group);
if (pubkey == NULL) {
bignum_ctx_free(ctx);
@@ -176,9 +170,13 @@ int ecdh_build_k(ssh_session session) {
return -1;
}
bignum_bin2bn(buffer, len, session->next_crypto->k);
bignum_bin2bn(buffer, len, &session->next_crypto->k);
free(buffer);
if (session->next_crypto->k == NULL) {
EC_KEY_free(session->next_crypto->ecdh_privkey);
session->next_crypto->ecdh_privkey = NULL;
return -1;
}
EC_KEY_free(session->next_crypto->ecdh_privkey);
session->next_crypto->ecdh_privkey = NULL;