comparison libtomcrypt/src/pk/asn1/der/short_integer/der_encode_short_integer.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_short_integer.c 12 @file der_encode_short_integer.c
24 @param out [out] The destination for the DER encoded integers 22 @param out [out] The destination for the DER encoded integers
25 @param outlen [in/out] The max size and resulting size of the DER encoded integers 23 @param outlen [in/out] The max size and resulting size of the DER encoded integers
26 @return CRYPT_OK if successful 24 @return CRYPT_OK if successful
27 */ 25 */
28 int der_encode_short_integer(unsigned long num, unsigned char *out, unsigned long *outlen) 26 int der_encode_short_integer(unsigned long num, unsigned char *out, unsigned long *outlen)
29 { 27 {
30 unsigned long len, x, y, z; 28 unsigned long len, x, y, z;
31 int err; 29 int err;
32 30
33 LTC_ARGCHK(out != NULL); 31 LTC_ARGCHK(out != NULL);
34 LTC_ARGCHK(outlen != NULL); 32 LTC_ARGCHK(outlen != NULL);
35 33
36 /* force to 32 bits */ 34 /* force to 32 bits */
37 num &= 0xFFFFFFFFUL; 35 num &= 0xFFFFFFFFUL;
84 num <<= 8; 82 num <<= 8;
85 } 83 }
86 84
87 /* we good */ 85 /* we good */
88 *outlen = x; 86 *outlen = x;
89 87
90 return CRYPT_OK; 88 return CRYPT_OK;
91 } 89 }
92 90
93 #endif 91 #endif
94 92
95 /* $Source$ */ 93 /* ref: $Format:%D$ */
96 /* $Revision$ */ 94 /* git commit: $Format:%H$ */
97 /* $Date$ */ 95 /* commit time: $Format:%ai$ */