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