diff options
| author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-07 10:40:37 +0200 |
|---|---|---|
| committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-07 10:41:04 +0200 |
| commit | 115f165b6e3bb74f45e13a65c5f4f82f28664a2c (patch) | |
| tree | ec55b63c736b5bef6061202c8bd31b08796fa2dc /libtomcrypt/pk/asn1/der/integer | |
| parent | 58a20b797e5a987fc8f7c5bea3be24d754908bf5 (diff) | |
| download | cryptodev-linux-115f165b6e3bb74f45e13a65c5f4f82f28664a2c.tar.gz cryptodev-linux-115f165b6e3bb74f45e13a65c5f4f82f28664a2c.tar.xz cryptodev-linux-115f165b6e3bb74f45e13a65c5f4f82f28664a2c.zip | |
Added a modified libtomcrypt with DSA and RSA algorithms.
Diffstat (limited to 'libtomcrypt/pk/asn1/der/integer')
| -rw-r--r-- | libtomcrypt/pk/asn1/der/integer/der_decode_integer.c | 10 | ||||
| -rw-r--r-- | libtomcrypt/pk/asn1/der/integer/der_encode_integer.c | 14 | ||||
| -rw-r--r-- | libtomcrypt/pk/asn1/der/integer/der_length_integer.c | 2 |
3 files changed, 13 insertions, 13 deletions
diff --git a/libtomcrypt/pk/asn1/der/integer/der_decode_integer.c b/libtomcrypt/pk/asn1/der/integer/der_decode_integer.c index 328280d..d7b13cf 100644 --- a/libtomcrypt/pk/asn1/der/integer/der_decode_integer.c +++ b/libtomcrypt/pk/asn1/der/integer/der_decode_integer.c @@ -25,7 +25,7 @@ @param num The first mp_int to decode @return CRYPT_OK if successful */ -int der_decode_integer(const unsigned char *in, unsigned long inlen, void *num) +int der_decode_integer(const unsigned char *in, unsigned long inlen, mp_int_t num) { unsigned long x, y, z; int err; @@ -87,16 +87,16 @@ int der_decode_integer(const unsigned char *in, unsigned long inlen, void *num) /* see if it's negative */ if (in[x] & 0x80) { - void *tmp; + mp_int tmp; if (mp_init(&tmp) != CRYPT_OK) { return CRYPT_MEM; } - if (mp_2expt(tmp, mp_count_bits(num)) != CRYPT_OK || mp_sub(num, tmp, num) != CRYPT_OK) { - mp_clear(tmp); + if (mp_2expt(&tmp, mp_count_bits(num)) != CRYPT_OK || mp_sub(num, &tmp, num) != CRYPT_OK) { + mp_clear(&tmp); return CRYPT_MEM; } - mp_clear(tmp); + mp_clear(&tmp); } return CRYPT_OK; diff --git a/libtomcrypt/pk/asn1/der/integer/der_encode_integer.c b/libtomcrypt/pk/asn1/der/integer/der_encode_integer.c index c1d0612..830446a 100644 --- a/libtomcrypt/pk/asn1/der/integer/der_encode_integer.c +++ b/libtomcrypt/pk/asn1/der/integer/der_encode_integer.c @@ -26,7 +26,7 @@ @param outlen [in/out] The max size and resulting size of the DER encoded integers @return CRYPT_OK if successful */ -int der_encode_integer(void *num, unsigned char *out, unsigned long *outlen) +int der_encode_integer(mp_int_t num, unsigned char *out, unsigned long *outlen) { unsigned long tmplen, y; int err, leading_zero; @@ -96,7 +96,7 @@ int der_encode_integer(void *num, unsigned char *out, unsigned long *outlen) return err; } } else if (mp_iszero(num) != LTC_MP_YES) { - void *tmp; + mp_int tmp; /* negative */ if (mp_init(&tmp) != CRYPT_OK) { @@ -107,15 +107,15 @@ int der_encode_integer(void *num, unsigned char *out, unsigned long *outlen) y = mp_count_bits(num); y = y + (8 - (y & 7)); if (((mp_cnt_lsb(num)+1)==mp_count_bits(num)) && ((mp_count_bits(num)&7)==0)) y -= 8; - if (mp_2expt(tmp, y) != CRYPT_OK || mp_add(tmp, num, tmp) != CRYPT_OK) { - mp_clear(tmp); + if (mp_2expt(&tmp, y) != CRYPT_OK || mp_add(&tmp, num, &tmp) != CRYPT_OK) { + mp_clear(&tmp); return CRYPT_MEM; } - if ((err = mp_to_unsigned_bin(tmp, out)) != CRYPT_OK) { - mp_clear(tmp); + if ((err = mp_to_unsigned_bin(&tmp, out)) != CRYPT_OK) { + mp_clear(&tmp); return err; } - mp_clear(tmp); + mp_clear(&tmp); } /* we good */ diff --git a/libtomcrypt/pk/asn1/der/integer/der_length_integer.c b/libtomcrypt/pk/asn1/der/integer/der_length_integer.c index 9320b03..40addd5 100644 --- a/libtomcrypt/pk/asn1/der/integer/der_length_integer.c +++ b/libtomcrypt/pk/asn1/der/integer/der_length_integer.c @@ -23,7 +23,7 @@ @param outlen [out] The length of the DER encoding for the given integer @return CRYPT_OK if successful */ -int der_length_integer(void *num, unsigned long *outlen) +int der_length_integer(mp_int_t num, unsigned long *outlen) { unsigned long z, len; int leading_zero; |
