Mercurial > dropbear
comparison pkcs_1_i2osp.c @ 0:d7da3b1e1540 libtomcrypt
put back the 0.95 makefile which was inadvertently merged over
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 31 May 2004 18:21:40 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d7da3b1e1540 |
---|---|
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis | |
2 * | |
3 * LibTomCrypt is a library that provides various cryptographic | |
4 * algorithms in a highly modular and flexible manner. | |
5 * | |
6 * The library is free for all purposes without any express | |
7 * guarantee it works. | |
8 * | |
9 * Tom St Denis, [email protected], http://libtomcrypt.org | |
10 */ | |
11 #include "mycrypt.h" | |
12 | |
13 /* Integer to Octet I2OSP -- Tom St Denis */ | |
14 | |
15 #ifdef PKCS_1 | |
16 | |
17 /* always stores the same # of bytes, pads with leading zero bytes | |
18 as required | |
19 */ | |
20 int pkcs_1_i2osp(mp_int *n, unsigned long modulus_len, unsigned char *out) | |
21 { | |
22 int err; | |
23 unsigned long size; | |
24 | |
25 size = mp_unsigned_bin_size(n); | |
26 | |
27 if (size > modulus_len) { | |
28 return CRYPT_BUFFER_OVERFLOW; | |
29 } | |
30 | |
31 /* store it */ | |
32 zeromem(out, modulus_len); | |
33 if ((err = mp_to_unsigned_bin(n, out+(modulus_len-size))) != MP_OKAY) { | |
34 return mpi_to_ltc_error(err); | |
35 } | |
36 return CRYPT_OK; | |
37 } | |
38 | |
39 #endif /* PKCS_1 */ | |
40 |