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/rsa | |
| 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/rsa')
| -rw-r--r-- | libtomcrypt/pk/rsa/rsa_export.c | 8 | ||||
| -rw-r--r-- | libtomcrypt/pk/rsa/rsa_import.c | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/libtomcrypt/pk/rsa/rsa_export.c b/libtomcrypt/pk/rsa/rsa_export.c index 483af19..cb667a4 100644 --- a/libtomcrypt/pk/rsa/rsa_export.c +++ b/libtomcrypt/pk/rsa/rsa_export.c @@ -31,6 +31,8 @@ int rsa_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_RSA); + LTC_ARGCHK(out != NULL); LTC_ARGCHK(outlen != NULL); LTC_ARGCHK(key != NULL); @@ -40,6 +42,10 @@ int rsa_export(unsigned char *out, unsigned long *outlen, int type, return CRYPT_PK_INVALID_TYPE; } + if (algo == NULL) { + return CRYPT_INVALID_ARG; + } + if (type == PK_PRIVATE) { /* private key */ /* output is @@ -75,7 +81,7 @@ int rsa_export(unsigned char *out, unsigned long *outlen, int type, } err = der_encode_subject_public_key_info(out, outlen, - PKA_RSA, tmp, tmplen, + algo, tmp, tmplen, LTC_ASN1_NULL, NULL, 0); diff --git a/libtomcrypt/pk/rsa/rsa_import.c b/libtomcrypt/pk/rsa/rsa_import.c index de8a103..6a42b07 100644 --- a/libtomcrypt/pk/rsa/rsa_import.c +++ b/libtomcrypt/pk/rsa/rsa_import.c @@ -9,6 +9,7 @@ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" +#include <ncr-int.h> /** @file rsa_import.c @@ -30,10 +31,15 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key * key) mp_int zero; unsigned char *tmpbuf = NULL; unsigned long tmpbuf_len; + const struct algo_properties_st *algo = _ncr_algo_to_properties(NCR_ALG_RSA); LTC_ARGCHK(in != NULL); LTC_ARGCHK(key != NULL); + if (algo == NULL) { + return CRYPT_INVALID_ARG; + } + /* init key */ if ((err = mp_init_multi(&key->e, &key->d, &key->N, &key->dQ, &key->dP, &key->qP, &key->p, &key->q, @@ -50,7 +56,7 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key * key) } err = der_decode_subject_public_key_info(in, inlen, - PKA_RSA, tmpbuf, &tmpbuf_len, + algo, tmpbuf, &tmpbuf_len, LTC_ASN1_NULL, NULL, 0); if (err == CRYPT_OK) { /* SubjectPublicKeyInfo format */ |
