1 // SPDX-License-Identifier: BSD-2-Clause 2 /* LibTomCrypt, modular cryptographic library -- Tom St Denis 3 * 4 * LibTomCrypt is a library that provides various cryptographic 5 * algorithms in a highly modular and flexible manner. 6 * 7 * The library is free for all purposes without any express 8 * guarantee it works. 9 */ 10 #include "tomcrypt_private.h" 11 12 /** 13 @file der_length_utctime.c 14 ASN.1 DER, get length of UTCTIME, Tom St Denis 15 */ 16 17 #ifdef LTC_DER 18 19 /** 20 Gets length of DER encoding of UTCTIME 21 @param utctime The UTC time structure to get the size of 22 @param outlen [out] The length of the DER encoding 23 @return CRYPT_OK if successful 24 */ der_length_utctime(const ltc_utctime * utctime,unsigned long * outlen)25int der_length_utctime(const ltc_utctime *utctime, unsigned long *outlen) 26 { 27 LTC_ARGCHK(outlen != NULL); 28 LTC_ARGCHK(utctime != NULL); 29 30 if (utctime->off_hh == 0 && utctime->off_mm == 0) { 31 /* we encode as YYMMDDhhmmssZ */ 32 *outlen = 2 + 13; 33 } else { 34 /* we encode as YYMMDDhhmmss{+|-}hh'mm' */ 35 *outlen = 2 + 17; 36 } 37 38 return CRYPT_OK; 39 } 40 41 #endif 42 43 /* ref: $Format:%D$ */ 44 /* git commit: $Format:%H$ */ 45 /* commit time: $Format:%ai$ */ 46