2 * Copyright (c) 2009,2012,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
25 #include <libDER/libDER.h>
28 #define FAST_SET_LOOKUP 1
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 */
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. */
38 DERByte
*byTag
[]; /* maxTag element array of pointers to tag + length
39 of items in set indexed by tagNumber. */
42 /* Iterates over all the tags in the set to build an index returned in
44 DERReturn
DERDecodeSetContentInit(
45 const DERItem
*der
, /* data to decode */
46 DERSet
*derSet
); /* IN/OUT, to use in DERDecodeSetTag */
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 */
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 */
63 /* Application Processor Ticket */
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 */
71 /* DERItemSpecs to decode into a DERApTicket */
72 extern const DERItemSpec DERApTicketItemSpecs
[];
73 extern const DERSize DERNumApTicketItemSpecs
;
75 DERReturn
DERDecodeApTicket(
76 const DERItem
*contents
,
77 DERApTicket
*ticket
, /* RETURNED */
78 DERSize
*numUsedBytes
); /* RETURNED */
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 */
89 /* DERItemSpecs to decode into a DERBbTicket */
90 extern const DERItemSpec DERBbTicketItemSpecs
[];
91 extern const DERSize DERNumBbTicketItemSpecs
;
93 DERReturn
DERDecodeBbTicket(
94 const DERItem
*contents
,
95 DERBbTicket
*ticket
, /* RETURNED */
96 DERSize
*numUsedBytes
); /* RETURNED */