1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 
5 /**
6   @file der_length_utctime.c
7   ASN.1 DER, get length of UTCTIME, Tom St Denis
8 */
9 
10 #ifdef LTC_DER
11 
12 /**
13   Gets length of DER encoding of UTCTIME
14   @param utctime      The UTC time structure to get the size of
15   @param outlen [out] The length of the DER encoding
16   @return CRYPT_OK if successful
17 */
der_length_utctime(const ltc_utctime * utctime,unsigned long * outlen)18 int der_length_utctime(const ltc_utctime *utctime, unsigned long *outlen)
19 {
20    LTC_ARGCHK(outlen  != NULL);
21    LTC_ARGCHK(utctime != NULL);
22 
23    if (utctime->off_hh == 0 && utctime->off_mm == 0) {
24       /* we encode as YYMMDDhhmmssZ */
25       *outlen = 2 + 13;
26    } else {
27       /* we encode as YYMMDDhhmmss{+|-}hh'mm' */
28       *outlen = 2 + 17;
29    }
30 
31    return CRYPT_OK;
32 }
33 
34 #endif
35