Mercurial > dropbear
comparison libtomcrypt/src/pk/asn1/der/object_identifier/der_decode_object_identifier.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 | 12 |
13 /** | 13 /** |
14 @file der_decode_object_identifier.c | 14 @file der_decode_object_identifier.c |
65 | 65 |
66 if (len < 1 || (len + x) > inlen) { | 66 if (len < 1 || (len + x) > inlen) { |
67 return CRYPT_INVALID_PACKET; | 67 return CRYPT_INVALID_PACKET; |
68 } | 68 } |
69 | 69 |
70 /* decode word1 and word2 */ | 70 /* decode words */ |
71 --len; | 71 y = 0; |
72 t = in[x++]; | |
73 words[0] = t/40; | |
74 words[1] = t%40; | |
75 | |
76 /* decode rest */ | |
77 y = 2; | |
78 t = 0; | 72 t = 0; |
79 while (len--) { | 73 while (len--) { |
80 t = (t << 7) | (in[x] & 0x7F); | 74 t = (t << 7) | (in[x] & 0x7F); |
81 if (!(in[x++] & 0x80)) { | 75 if (!(in[x++] & 0x80)) { |
82 /* store t */ | 76 /* store t */ |
83 if (y >= *outlen) { | 77 if (y >= *outlen) { |
84 return CRYPT_BUFFER_OVERFLOW; | 78 return CRYPT_BUFFER_OVERFLOW; |
85 } | 79 } |
86 words[y++] = t; | 80 if (y == 0) { |
81 words[0] = t / 40; | |
82 words[1] = t % 40; | |
83 y = 2; | |
84 } else { | |
85 words[y++] = t; | |
86 } | |
87 t = 0; | 87 t = 0; |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 *outlen = y; | 91 *outlen = y; |
93 } | 93 } |
94 | 94 |
95 #endif | 95 #endif |
96 | 96 |
97 /* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/object_identifier/der_decode_object_identifier.c,v $ */ | 97 /* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/object_identifier/der_decode_object_identifier.c,v $ */ |
98 /* $Revision: 1.1 $ */ | 98 /* $Revision: 1.5 $ */ |
99 /* $Date: 2005/05/16 15:08:11 $ */ | 99 /* $Date: 2006/11/21 00:18:23 $ */ |