comparison libtomcrypt/src/pk/asn1/der/utctime/der_encode_utctime.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 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 $ */