]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_keychain/libDER/Tests/DER_Ticket.h
Security-57740.51.3.tar.gz
[apple/security.git] / OSX / libsecurity_keychain / libDER / Tests / DER_Ticket.h
1 /*
2 * Copyright (c) 2009,2012,2014 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25 #include <libDER/libDER.h>
26
27
28 #define FAST_SET_LOOKUP 1
29
30 #ifdef FAST_SET_LOOKUP
31 /* state representing a fast by tag set accessor, the caller needs to provide
32 a set large enough to hold all */
33 typedef struct {
34 DERTag capacity; /* should be large enough to hold all encountered tags.
35 otherwise DR_UnexpectedTag will be returned, note
36 that only one tag per tag number can exist. */
37 DERByte *end;
38 DERByte *byTag[]; /* maxTag element array of pointers to tag + length
39 of items in set indexed by tagNumber. */
40 } DERSet;
41
42 /* Iterates over all the tags in the set to build an index returned in
43 derSet. */
44 DERReturn DERDecodeSetContentInit(
45 const DERItem *der, /* data to decode */
46 DERSet *derSet); /* IN/OUT, to use in DERDecodeSetTag */
47
48 /* Returns DR_UnexpectedTag if the requested tag is not in derSet, returns
49 the content of the decoded item in content otherwise. */
50 DERReturn DERDecodeSetTag(
51 DERSet *derSeq, /* data to decode */
52 DERTag tag, /* tag in sequence/set we are looking for. */
53 DERItem *content); /* RETURNED */
54 #endif /* FAST_SET_LOOKUP */
55
56
57 DERReturn DERSetDecodeItemWithTag(
58 const DERItem *der, /* data to decode */
59 DERTag tag, /* tag in sequence/set we are looking for. */
60 DERItem *content); /* RETURNED */
61
62
63 /* Application Processor Ticket */
64 typedef struct {
65 DERItem signatureAlgorithm; /* AlgorithmId */
66 DERItem body; /* SET OF OCTECT STRING, DER_DEC_SAVE_DER */
67 DERItem signature; /* OCTET STRING */
68 DERItem certificates; /* SEQUENCE of CERTIFICATE */
69 } DERApTicket;
70
71 /* DERItemSpecs to decode into a DERApTicket */
72 extern const DERItemSpec DERApTicketItemSpecs[];
73 extern const DERSize DERNumApTicketItemSpecs;
74
75 DERReturn DERDecodeApTicket(
76 const DERItem *contents,
77 DERApTicket *ticket, /* RETURNED */
78 DERSize *numUsedBytes); /* RETURNED */
79
80
81 /* Baseband Ticket */
82 typedef struct {
83 DERItem signatureAlgorithm; /* AlgorithmId */
84 DERItem body; /* SET OF OCTECT STRING, DER_DEC_SAVE_DER */
85 DERItem signature; /* OCTET STRING */
86 DERItem gpuk; /* OCTET STRING */
87 } DERBbTicket;
88
89 /* DERItemSpecs to decode into a DERBbTicket */
90 extern const DERItemSpec DERBbTicketItemSpecs[];
91 extern const DERSize DERNumBbTicketItemSpecs;
92
93 DERReturn DERDecodeBbTicket(
94 const DERItem *contents,
95 DERBbTicket *ticket, /* RETURNED */
96 DERSize *numUsedBytes); /* RETURNED */