comparison libtomcrypt/src/pk/asn1/der/boolean/der_encode_boolean.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_encode_boolean.c 12 @file der_encode_boolean.c
23 @param in The boolean to encode 21 @param in The boolean to encode
24 @param out [out] The destination for the DER encoded BOOLEAN 22 @param out [out] The destination for the DER encoded BOOLEAN
25 @param outlen [in/out] The max size and resulting size of the DER BOOLEAN 23 @param outlen [in/out] The max size and resulting size of the DER BOOLEAN
26 @return CRYPT_OK if successful 24 @return CRYPT_OK if successful
27 */ 25 */
28 int der_encode_boolean(int in, 26 int der_encode_boolean(int in,
29 unsigned char *out, unsigned long *outlen) 27 unsigned char *out, unsigned long *outlen)
30 { 28 {
31 LTC_ARGCHK(outlen != NULL); 29 LTC_ARGCHK(outlen != NULL);
32 LTC_ARGCHK(out != NULL); 30 LTC_ARGCHK(out != NULL);
33 31
34 if (*outlen < 3) { 32 if (*outlen < 3) {
35 *outlen = 3; 33 *outlen = 3;
36 return CRYPT_BUFFER_OVERFLOW; 34 return CRYPT_BUFFER_OVERFLOW;
37 } 35 }
38 36
39 *outlen = 3; 37 *outlen = 3;
40 out[0] = 0x01; 38 out[0] = 0x01;
41 out[1] = 0x01; 39 out[1] = 0x01;
42 out[2] = in ? 0xFF : 0x00; 40 out[2] = in ? 0xFF : 0x00;
43 41
44 return CRYPT_OK; 42 return CRYPT_OK;
45 } 43 }
46 44
47 #endif 45 #endif
48 46
49 /* $Source$ */ 47 /* ref: $Format:%D$ */
50 /* $Revision$ */ 48 /* git commit: $Format:%H$ */
51 /* $Date$ */ 49 /* commit time: $Format:%ai$ */