diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-09-06 22:02:15 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-09-06 22:02:38 +0200 |
commit | a92443718f19ffc36fbe55d85a4785130a4b33c7 (patch) | |
tree | 79850bdf3cd559d389b2908d17e0e21bdb893b20 /libtomcrypt/pk/dsa | |
parent | e6177630198eb1eea2def0374fae1196da0e40ec (diff) | |
download | cryptodev-linux-a92443718f19ffc36fbe55d85a4785130a4b33c7.tar.gz cryptodev-linux-a92443718f19ffc36fbe55d85a4785130a4b33c7.tar.xz cryptodev-linux-a92443718f19ffc36fbe55d85a4785130a4b33c7.zip |
Algorithm to OID discovery moved to a single place.
Diffstat (limited to 'libtomcrypt/pk/dsa')
-rw-r--r-- | libtomcrypt/pk/dsa/dsa_export.c | 8 | ||||
-rw-r--r-- | libtomcrypt/pk/dsa/dsa_import.c | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/libtomcrypt/pk/dsa/dsa_export.c b/libtomcrypt/pk/dsa/dsa_export.c index 01569e7..ad2991f 100644 --- a/libtomcrypt/pk/dsa/dsa_export.c +++ b/libtomcrypt/pk/dsa/dsa_export.c @@ -9,6 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" +#include <ncr-int.h> /** @file dsa_export.c @@ -30,11 +31,16 @@ int dsa_export(unsigned char *out, unsigned long *outlen, int type, { unsigned long zero = 0; int err; + const struct algo_properties_st *algo = _ncr_algo_to_properties(NCR_ALG_DSA); LTC_ARGCHK(out != NULL); LTC_ARGCHK(outlen != NULL); LTC_ARGCHK(key != NULL); + if (algo == NULL) { + return CRYPT_INVALID_ARG; + } + /* can we store the static header? */ if (type == PK_PRIVATE && key->type != PK_PRIVATE) { return CRYPT_PK_TYPE_MISMATCH; @@ -83,7 +89,7 @@ int dsa_export(unsigned char *out, unsigned long *outlen, int type, int_list[2].type = LTC_ASN1_INTEGER; err = der_encode_subject_public_key_info(out, outlen, - PKA_DSA, tmp, tmplen, + algo, tmp, tmplen, LTC_ASN1_SEQUENCE, int_list, sizeof(int_list) / diff --git a/libtomcrypt/pk/dsa/dsa_import.c b/libtomcrypt/pk/dsa/dsa_import.c index cf21e3b..5a60937 100644 --- a/libtomcrypt/pk/dsa/dsa_import.c +++ b/libtomcrypt/pk/dsa/dsa_import.c @@ -9,6 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" +#include <ncr-int.h> /** @file dsa_import.c @@ -29,10 +30,15 @@ int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key * key) int err; unsigned long zero = 0; unsigned char *tmpbuf = NULL; + const struct algo_properties_st *algo = _ncr_algo_to_properties(NCR_ALG_DSA); LTC_ARGCHK(in != NULL); LTC_ARGCHK(key != NULL); + if (algo == NULL) { + return CRYPT_INVALID_ARG; + } + /* init key */ if (mp_init_multi(&key->p, &key->g, &key->q, &key->x, &key->y, NULL) != CRYPT_OK) { @@ -65,7 +71,7 @@ int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key * key) } err = der_decode_subject_public_key_info(in, inlen, - PKA_DSA, tmpbuf, + algo, tmpbuf, &tmpbuf_len, LTC_ASN1_SEQUENCE, params, 3); |