comparison libtomcrypt/src/pk/asn1/der/boolean/der_decode_boolean.c @ 1511:5916af64acd4 fuzz

merge from main
author Matt Johnston <matt@ucc.asn.au>
date Sat, 17 Feb 2018 19:29:51 +0800
parents 6dba84798cd5
children
comparison
equal deleted inserted replaced
1457:32f990cc96b1 1511:5916af64acd4
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_boolean.c 12 @file der_decode_boolean.c
28 int der_decode_boolean(const unsigned char *in, unsigned long inlen, 26 int der_decode_boolean(const unsigned char *in, unsigned long inlen,
29 int *out) 27 int *out)
30 { 28 {
31 LTC_ARGCHK(in != NULL); 29 LTC_ARGCHK(in != NULL);
32 LTC_ARGCHK(out != NULL); 30 LTC_ARGCHK(out != NULL);
33 31
34 if (inlen != 3 || in[0] != 0x01 || in[1] != 0x01 || (in[2] != 0x00 && in[2] != 0xFF)) { 32 if (inlen < 3 || in[0] != 0x01 || in[1] != 0x01 || (in[2] != 0x00 && in[2] != 0xFF)) {
35 return CRYPT_INVALID_ARG; 33 return CRYPT_INVALID_ARG;
36 } 34 }
37 35
38 *out = (in[2]==0xFF) ? 1 : 0; 36 *out = (in[2]==0xFF) ? 1 : 0;
39 37
40 return CRYPT_OK; 38 return CRYPT_OK;
41 } 39 }
42 40
43 #endif 41 #endif
44 42
45 /* $Source$ */ 43 /* ref: $Format:%D$ */
46 /* $Revision$ */ 44 /* git commit: $Format:%H$ */
47 /* $Date$ */ 45 /* commit time: $Format:%ai$ */