Mercurial > dropbear
comparison libtomcrypt/src/pk/pkcs1/pkcs_1_i2osp.c @ 382:0cbe8f6dbf9e
propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 2af22fb4e878750b88f80f90d439b316d229796f)
to branch 'au.asn.ucc.matt.dropbear' (head 02c413252c90e9de8e03d91e9939dde3029f5c0a)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 11 Jan 2007 02:41:05 +0000 |
parents | 1b9e69c058d2 |
children | f849a5ca2efc |
comparison
equal
deleted
inserted
replaced
379:b66a00272a90 | 382:0cbe8f6dbf9e |
---|---|
4 * algorithms in a highly modular and flexible manner. | 4 * algorithms in a highly modular and flexible manner. |
5 * | 5 * |
6 * The library is free for all purposes without any express | 6 * The library is free for all purposes without any express |
7 * guarantee it works. | 7 * guarantee it works. |
8 * | 8 * |
9 * Tom St Denis, [email protected], http://libtomcrypt.org | 9 * Tom St Denis, [email protected], http://libtomcrypt.com |
10 */ | 10 */ |
11 #include "tomcrypt.h" | 11 #include "tomcrypt.h" |
12 | 12 |
13 /** | 13 /** |
14 @file pkcs_1_i2osp.c | 14 @file pkcs_1_i2osp.c |
26 @param n The integer to store | 26 @param n The integer to store |
27 @param modulus_len The length of the RSA modulus | 27 @param modulus_len The length of the RSA modulus |
28 @param out [out] The destination for the integer | 28 @param out [out] The destination for the integer |
29 @return CRYPT_OK if successful | 29 @return CRYPT_OK if successful |
30 */ | 30 */ |
31 int pkcs_1_i2osp(mp_int *n, unsigned long modulus_len, unsigned char *out) | 31 int pkcs_1_i2osp(void *n, unsigned long modulus_len, unsigned char *out) |
32 { | 32 { |
33 int err; | |
34 unsigned long size; | 33 unsigned long size; |
35 | 34 |
36 size = mp_unsigned_bin_size(n); | 35 size = mp_unsigned_bin_size(n); |
37 | 36 |
38 if (size > modulus_len) { | 37 if (size > modulus_len) { |
39 return CRYPT_BUFFER_OVERFLOW; | 38 return CRYPT_BUFFER_OVERFLOW; |
40 } | 39 } |
41 | 40 |
42 /* store it */ | 41 /* store it */ |
43 zeromem(out, modulus_len); | 42 zeromem(out, modulus_len); |
44 if ((err = mp_to_unsigned_bin(n, out+(modulus_len-size))) != MP_OKAY) { | 43 return mp_to_unsigned_bin(n, out+(modulus_len-size)); |
45 return mpi_to_ltc_error(err); | |
46 } | |
47 return CRYPT_OK; | |
48 } | 44 } |
49 | 45 |
50 #endif /* PKCS_1 */ | 46 #endif /* PKCS_1 */ |
51 | 47 |
52 | 48 |
53 /* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_i2osp.c,v $ */ | 49 /* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_i2osp.c,v $ */ |
54 /* $Revision: 1.3 $ */ | 50 /* $Revision: 1.5 $ */ |
55 /* $Date: 2005/05/05 14:35:59 $ */ | 51 /* $Date: 2006/03/31 14:15:35 $ */ |