Debian Codegraph @

src/ltc/pk/asn1/der/sequence/der_flexi_sequence_cmp.c

raw
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4
5 /**
6 @file der_length_sequence.c
7 ASN.1 DER, length a SEQUENCE, Tom St Denis
8 */
9
10 #ifdef LTC_DER
11
12 /**
13 Get the length of a DER sequence
14 @param list The sequences of items in the SEQUENCE
15 @param inlen The number of items
16 @param outlen [out] The length required in octets to store it
17 @return CRYPT_OK on success
18 */
19
20 int der_flexi_sequence_cmp(const ltc_asn1_list *flexi, der_flexi_check *check)
21 {
22 ltc_asn1_list *cur;
23 if (flexi->type != LTC_ASN1_SEQUENCE) {
24 return CRYPT_INVALID_PACKET;
25 }
26 cur = flexi->child;
27 while(check->t != LTC_ASN1_EOL && cur) {
28 if (!LTC_ASN1_IS_TYPE(cur, check->t)) {
29 if (check->optional) {
30 check++;
31 continue;
32 }
33 return CRYPT_INVALID_PACKET;
34 }
35 if (check->pp != NULL) *check->pp = cur;
36 else if (check->handler) {
37 int err = check->handler(cur, check->userdata);
38 if (err != CRYPT_OK)
39 return err;
40 }
41 cur = cur->next;
42 check++;
43 }
44 return CRYPT_OK;
45 }
46
47 #endif