1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
12 @file der_decode_boolean.c
13 ASN.1 DER, decode a BOOLEAN, Tom St Denis
21 @param in The destination for the DER encoded BOOLEAN
22 @param inlen The size of the DER BOOLEAN
23 @param out [out] The boolean to decode
24 @return CRYPT_OK if successful
26 int der_decode_boolean(const unsigned char *in, unsigned long inlen,
29 LTC_ARGCHK(in != NULL);
30 LTC_ARGCHK(out != NULL);
32 if (inlen < 3 || in[0] != 0x01 || in[1] != 0x01 || (in[2] != 0x00 && in[2] != 0xFF)) {
33 return CRYPT_INVALID_ARG;
36 *out = (in[2]==0xFF) ? 1 : 0;
43 /* ref: $Format:%D$ */
44 /* git commit: $Format:%H$ */
45 /* commit time: $Format:%ai$ */