Mercurial > dropbear
comparison libtomcrypt/src/pk/asn1/der/sequence/der_encode_sequence_multi.c @ 435:337c45621e81
merge of 'a9b0496634cdd25647b65e585cc3240f3fa699ee'
and 'c22be8b8f570b48e9662dac32c7b3e7148a42206'
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 22 Feb 2007 14:53:49 +0000 |
parents | 0cbe8f6dbf9e |
children | f849a5ca2efc |
comparison
equal
deleted
inserted
replaced
434:0aaaf68e97dc | 435:337c45621e81 |
---|---|
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 #include <stdarg.h> | 12 #include <stdarg.h> |
13 | 13 |
14 | 14 |
17 ASN.1 DER, encode a SEQUENCE, Tom St Denis | 17 ASN.1 DER, encode a SEQUENCE, Tom St Denis |
18 */ | 18 */ |
19 | 19 |
20 #ifdef LTC_DER | 20 #ifdef LTC_DER |
21 | 21 |
22 /** | |
23 Encode a SEQUENCE type using a VA list | |
24 @param out [out] Destination for data | |
25 @param outlen [in/out] Length of buffer and resulting length of output | |
26 @remark <...> is of the form <type, size, data> (int, unsigned long, void*) | |
27 @return CRYPT_OK on success | |
28 */ | |
22 int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...) | 29 int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...) |
23 { | 30 { |
24 int err, type; | 31 int err, type; |
25 unsigned long size, x; | 32 unsigned long size, x; |
26 void *data; | 33 void *data; |
41 if (type == LTC_ASN1_EOL) { | 48 if (type == LTC_ASN1_EOL) { |
42 break; | 49 break; |
43 } | 50 } |
44 | 51 |
45 switch (type) { | 52 switch (type) { |
53 case LTC_ASN1_BOOLEAN: | |
46 case LTC_ASN1_INTEGER: | 54 case LTC_ASN1_INTEGER: |
47 case LTC_ASN1_SHORT_INTEGER: | 55 case LTC_ASN1_SHORT_INTEGER: |
48 case LTC_ASN1_BIT_STRING: | 56 case LTC_ASN1_BIT_STRING: |
49 case LTC_ASN1_OCTET_STRING: | 57 case LTC_ASN1_OCTET_STRING: |
50 case LTC_ASN1_NULL: | 58 case LTC_ASN1_NULL: |
51 case LTC_ASN1_OBJECT_IDENTIFIER: | 59 case LTC_ASN1_OBJECT_IDENTIFIER: |
52 case LTC_ASN1_IA5_STRING: | 60 case LTC_ASN1_IA5_STRING: |
53 case LTC_ASN1_PRINTABLE_STRING: | 61 case LTC_ASN1_PRINTABLE_STRING: |
62 case LTC_ASN1_UTF8_STRING: | |
54 case LTC_ASN1_UTCTIME: | 63 case LTC_ASN1_UTCTIME: |
55 case LTC_ASN1_SEQUENCE: | 64 case LTC_ASN1_SEQUENCE: |
65 case LTC_ASN1_SET: | |
66 case LTC_ASN1_SETOF: | |
56 ++x; | 67 ++x; |
57 break; | 68 break; |
58 | 69 |
59 default: | 70 default: |
60 va_end(args); | 71 va_end(args); |
84 if (type == LTC_ASN1_EOL) { | 95 if (type == LTC_ASN1_EOL) { |
85 break; | 96 break; |
86 } | 97 } |
87 | 98 |
88 switch (type) { | 99 switch (type) { |
100 case LTC_ASN1_BOOLEAN: | |
89 case LTC_ASN1_INTEGER: | 101 case LTC_ASN1_INTEGER: |
90 case LTC_ASN1_SHORT_INTEGER: | 102 case LTC_ASN1_SHORT_INTEGER: |
91 case LTC_ASN1_BIT_STRING: | 103 case LTC_ASN1_BIT_STRING: |
92 case LTC_ASN1_OCTET_STRING: | 104 case LTC_ASN1_OCTET_STRING: |
93 case LTC_ASN1_NULL: | 105 case LTC_ASN1_NULL: |
94 case LTC_ASN1_OBJECT_IDENTIFIER: | 106 case LTC_ASN1_OBJECT_IDENTIFIER: |
95 case LTC_ASN1_IA5_STRING: | 107 case LTC_ASN1_IA5_STRING: |
96 case LTC_ASN1_PRINTABLE_STRING: | 108 case LTC_ASN1_PRINTABLE_STRING: |
109 case LTC_ASN1_UTF8_STRING: | |
97 case LTC_ASN1_UTCTIME: | 110 case LTC_ASN1_UTCTIME: |
98 case LTC_ASN1_SEQUENCE: | 111 case LTC_ASN1_SEQUENCE: |
112 case LTC_ASN1_SET: | |
113 case LTC_ASN1_SETOF: | |
99 list[x].type = type; | 114 list[x].type = type; |
100 list[x].size = size; | 115 list[x].size = size; |
101 list[x++].data = data; | 116 list[x++].data = data; |
102 break; | 117 break; |
103 | 118 |
117 | 132 |
118 #endif | 133 #endif |
119 | 134 |
120 | 135 |
121 /* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_encode_sequence_multi.c,v $ */ | 136 /* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_encode_sequence_multi.c,v $ */ |
122 /* $Revision: 1.6 $ */ | 137 /* $Revision: 1.11 $ */ |
123 /* $Date: 2005/06/18 19:20:23 $ */ | 138 /* $Date: 2006/11/26 02:25:18 $ */ |