annotate src/pk/asn1/der/utctime/der_length_utctime.c @ 209:39d5d58461d6 libtomcrypt-orig LTC_1.05

Import of libtomcrypt 1.05
author Matt Johnston <matt@ucc.asn.au>
date Wed, 06 Jul 2005 03:53:40 +0000
parents
children d5faf4814ddb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
209
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 *
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 * LibTomCrypt is a library that provides various cryptographic
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 * algorithms in a highly modular and flexible manner.
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 *
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 * The library is free for all purposes without any express
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 * guarantee it works.
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 *
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 * Tom St Denis, [email protected], http://libtomcrypt.org
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 */
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 #include "tomcrypt.h"
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 /**
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 @file der_length_utctime.c
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 ASN.1 DER, get length of UTCTIME, Tom St Denis
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 */
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 #ifdef LTC_DER
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 /**
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 Gets length of DER encoding of UTCTIME
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 @param outlen [out] The length of the DER encoding
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 @return CRYPT_OK if successful
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24 */
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 int der_length_utctime(ltc_utctime *utctime, unsigned long *outlen)
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26 {
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 LTC_ARGCHK(outlen != NULL);
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
28 LTC_ARGCHK(utctime != NULL);
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
30 if (utctime->off_hh == 0 && utctime->off_mm == 0) {
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
31 /* we encode as YYMMDDhhmmssZ */
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
32 *outlen = 2 + 13;
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
33 } else {
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 /* we encode as YYMMDDhhmmss{+|-}hh'mm' */
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 *outlen = 2 + 17;
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36 }
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
37
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
38 return CRYPT_OK;
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
39 }
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
40
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41 #endif
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
42
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
43 /* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utctime/der_length_utctime.c,v $ */
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44 /* $Revision: 1.2 $ */
39d5d58461d6 Import of libtomcrypt 1.05
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
45 /* $Date: 2005/06/19 11:23:04 $ */