Mercurial > dropbear
comparison libtomcrypt/src/pk/asn1/der/utctime/der_encode_utctime.c @ 478:d4f32c3443ac dbclient-netcat-alike
propagate from branch 'au.asn.ucc.matt.dropbear' (head f21045c791002d81fc6b8dde6537ea481e513eb2)
to branch 'au.asn.ucc.matt.dropbear.dbclient-netcat-alike' (head d1f69334581dc4c35f9ca16aa5355074c9dd315d)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 14 Sep 2008 06:47:51 +0000 |
parents | 0cbe8f6dbf9e |
children | f849a5ca2efc |
comparison
equal
deleted
inserted
replaced
296:6b41e2cbf071 | 478:d4f32c3443ac |
---|---|
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 der_encode_utctime.c | 14 @file der_encode_utctime.c |
22 #define STORE_V(y) \ | 22 #define STORE_V(y) \ |
23 out[x++] = der_ia5_char_encode(baseten[(y/10) % 10]); \ | 23 out[x++] = der_ia5_char_encode(baseten[(y/10) % 10]); \ |
24 out[x++] = der_ia5_char_encode(baseten[y % 10]); | 24 out[x++] = der_ia5_char_encode(baseten[y % 10]); |
25 | 25 |
26 /** | 26 /** |
27 Gets length of DER encoding of UTCTIME | 27 Encodes a UTC time structure in DER format |
28 @param outlen [out] The length of the DER encoding | 28 @param utctime The UTC time structure to encode |
29 @param out The destination of the DER encoding of the UTC time structure | |
30 @param outlen [in/out] The length of the DER encoding | |
29 @return CRYPT_OK if successful | 31 @return CRYPT_OK if successful |
30 */ | 32 */ |
31 int der_encode_utctime(ltc_utctime *utctime, | 33 int der_encode_utctime(ltc_utctime *utctime, |
32 unsigned char *out, unsigned long *outlen) | 34 unsigned char *out, unsigned long *outlen) |
33 { | 35 { |
40 | 42 |
41 if ((err = der_length_utctime(utctime, &tmplen)) != CRYPT_OK) { | 43 if ((err = der_length_utctime(utctime, &tmplen)) != CRYPT_OK) { |
42 return err; | 44 return err; |
43 } | 45 } |
44 if (tmplen > *outlen) { | 46 if (tmplen > *outlen) { |
47 *outlen = tmplen; | |
45 return CRYPT_BUFFER_OVERFLOW; | 48 return CRYPT_BUFFER_OVERFLOW; |
46 } | 49 } |
47 | 50 |
48 /* store header */ | 51 /* store header */ |
49 out[0] = 0x17; | 52 out[0] = 0x17; |
64 } else { | 67 } else { |
65 out[x++] = der_ia5_char_encode('Z'); | 68 out[x++] = der_ia5_char_encode('Z'); |
66 } | 69 } |
67 | 70 |
68 /* store length */ | 71 /* store length */ |
69 out[1] = x - 2; | 72 out[1] = (unsigned char)(x - 2); |
70 | 73 |
71 /* all good let's return */ | 74 /* all good let's return */ |
72 *outlen = x; | 75 *outlen = x; |
73 return CRYPT_OK; | 76 return CRYPT_OK; |
74 } | 77 } |
75 | 78 |
76 #endif | 79 #endif |
77 | 80 |
78 /* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utctime/der_encode_utctime.c,v $ */ | 81 /* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utctime/der_encode_utctime.c,v $ */ |
79 /* $Revision: 1.5 $ */ | 82 /* $Revision: 1.9 $ */ |
80 /* $Date: 2005/06/19 12:07:00 $ */ | 83 /* $Date: 2006/12/04 21:34:03 $ */ |