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
9
* Tom St Denis, tomstdenis@iahu.ca, http://libtomcrypt.org
14
/* Gets length of DER encoding of num */
16
int der_length_integer(mp_int *num, unsigned long *outlen)
22
_ARGCHK(outlen != NULL);
24
/* we only need a leading zero if the msb of the first byte is one */
25
if ((mp_count_bits(num) & 7) == 7 || mp_iszero(num) == MP_YES) {
32
z = len = leading_zero + mp_unsigned_bin_size(num);
37
/* now we need a length */
42
/* long form (relies on z != 0) */