Mercurial > dropbear
comparison libtomcrypt/src/pk/asn1/der/bit/der_decode_bit_string.c @ 1471:6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 09 Feb 2018 21:44:05 +0800 |
parents | f849a5ca2efc |
children |
comparison
equal
deleted
inserted
replaced
1470:8bba51a55704 | 1471:6dba84798cd5 |
---|---|
3 * LibTomCrypt is a library that provides various cryptographic | 3 * LibTomCrypt is a library that provides various cryptographic |
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 * | |
9 * Tom St Denis, [email protected], http://libtom.org | |
10 */ | 8 */ |
11 #include "tomcrypt.h" | 9 #include "tomcrypt.h" |
12 | 10 |
13 /** | 11 /** |
14 @file der_decode_bit_string.c | 12 @file der_decode_bit_string.c |
43 /* check for 0x03 */ | 41 /* check for 0x03 */ |
44 if ((in[0]&0x1F) != 0x03) { | 42 if ((in[0]&0x1F) != 0x03) { |
45 return CRYPT_INVALID_PACKET; | 43 return CRYPT_INVALID_PACKET; |
46 } | 44 } |
47 | 45 |
48 /* offset in the data */ | 46 /* offset in the data */ |
49 x = 1; | 47 x = 1; |
50 | 48 |
51 /* get the length of the data */ | 49 /* get the length of the data */ |
52 if (in[x] & 0x80) { | 50 if (in[x] & 0x80) { |
53 /* long format get number of length bytes */ | 51 /* long format get number of length bytes */ |
54 y = in[x++] & 0x7F; | 52 y = in[x++] & 0x7F; |
65 } | 63 } |
66 } else { | 64 } else { |
67 /* short format */ | 65 /* short format */ |
68 dlen = in[x++] & 0x7F; | 66 dlen = in[x++] & 0x7F; |
69 } | 67 } |
70 | 68 |
71 /* is the data len too long or too short? */ | 69 /* is the data len too long or too short? */ |
72 if ((dlen == 0) || (dlen + x > inlen)) { | 70 if ((dlen == 0) || (dlen + x > inlen)) { |
73 return CRYPT_INVALID_PACKET; | 71 return CRYPT_INVALID_PACKET; |
74 } | 72 } |
75 | 73 |
95 return CRYPT_OK; | 93 return CRYPT_OK; |
96 } | 94 } |
97 | 95 |
98 #endif | 96 #endif |
99 | 97 |
100 /* $Source$ */ | 98 /* ref: $Format:%D$ */ |
101 /* $Revision$ */ | 99 /* git commit: $Format:%H$ */ |
102 /* $Date$ */ | 100 /* commit time: $Format:%ai$ */ |