]> git.saurik.com Git - apple/security.git/blob - libsecurity_keychain/libDER/Tests/DER_Ticket.h
Security-55163.44.tar.gz
[apple/security.git] / libsecurity_keychain / libDER / Tests / DER_Ticket.h
1 /*
2 * DER_Ticket.h
3 * libDER
4 *
5 * Created by Michael Brouwer on 10/13/09.
6 * Copyright 2009 Apple Inc. All rights reserved.
7 *
8 */
9
10 #include <libDER/libDER.h>
11
12
13 #define FAST_SET_LOOKUP 1
14
15 #ifdef FAST_SET_LOOKUP
16 /* state representing a fast by tag set accessor, the caller needs to provide
17 a set large enough to hold all */
18 typedef struct {
19 DERTag capacity; /* should be large enough to hold all encountered tags.
20 otherwise DR_UnexpectedTag will be returned, note
21 that only one tag per tag number can exist. */
22 DERByte *end;
23 DERByte *byTag[]; /* maxTag element array of pointers to tag + length
24 of items in set indexed by tagNumber. */
25 } DERSet;
26
27 /* Iterates over all the tags in the set to build an index returned in
28 derSet. */
29 DERReturn DERDecodeSetContentInit(
30 const DERItem *der, /* data to decode */
31 DERSet *derSet); /* IN/OUT, to use in DERDecodeSetTag */
32
33 /* Returns DR_UnexpectedTag if the requested tag is not in derSet, returns
34 the content of the decoded item in content otherwise. */
35 DERReturn DERDecodeSetTag(
36 DERSet *derSeq, /* data to decode */
37 DERTag tag, /* tag in sequence/set we are looking for. */
38 DERItem *content); /* RETURNED */
39 #endif /* FAST_SET_LOOKUP */
40
41
42 DERReturn DERSetDecodeItemWithTag(
43 const DERItem *der, /* data to decode */
44 DERTag tag, /* tag in sequence/set we are looking for. */
45 DERItem *content); /* RETURNED */
46
47
48 /* Application Processor Ticket */
49 typedef struct {
50 DERItem signatureAlgorithm; /* AlgorithmId */
51 DERItem body; /* SET OF OCTECT STRING, DER_DEC_SAVE_DER */
52 DERItem signature; /* OCTET STRING */
53 DERItem certificates; /* SEQUENCE of CERTIFICATE */
54 } DERApTicket;
55
56 /* DERItemSpecs to decode into a DERApTicket */
57 extern const DERItemSpec DERApTicketItemSpecs[];
58 extern const DERSize DERNumApTicketItemSpecs;
59
60 DERReturn DERDecodeApTicket(
61 const DERItem *contents,
62 DERApTicket *ticket, /* RETURNED */
63 DERSize *numUsedBytes); /* RETURNED */
64
65
66 /* Baseband Ticket */
67 typedef struct {
68 DERItem signatureAlgorithm; /* AlgorithmId */
69 DERItem body; /* SET OF OCTECT STRING, DER_DEC_SAVE_DER */
70 DERItem signature; /* OCTET STRING */
71 DERItem gpuk; /* OCTET STRING */
72 } DERBbTicket;
73
74 /* DERItemSpecs to decode into a DERBbTicket */
75 extern const DERItemSpec DERBbTicketItemSpecs[];
76 extern const DERSize DERNumBbTicketItemSpecs;
77
78 DERReturn DERDecodeBbTicket(
79 const DERItem *contents,
80 DERBbTicket *ticket, /* RETURNED */
81 DERSize *numUsedBytes); /* RETURNED */