1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 
5 /**
6   @file der_length_octet_string.c
7   ASN.1 DER, get length of OCTET STRING, Tom St Denis
8 */
9 
10 #ifdef LTC_DER
11 /**
12   Gets length of DER encoding of OCTET STRING
13   @param noctets  The number of octets in the string to encode
14   @param outlen   [out] The length of the DER encoding for the given string
15   @return CRYPT_OK if successful
16 */
der_length_octet_string(unsigned long noctets,unsigned long * outlen)17 int der_length_octet_string(unsigned long noctets, unsigned long *outlen)
18 {
19    unsigned long x;
20    int err;
21 
22    LTC_ARGCHK(outlen != NULL);
23 
24    if ((err = der_length_asn1_length(noctets, &x)) != CRYPT_OK) {
25       return err;
26    }
27    *outlen = 1 + x + noctets;
28 
29    return CRYPT_OK;
30 }
31 
32 #endif
33 
34