2 * Copyright (c) 2009 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 @header SecOCSPResponse
26 The functions and data types in SecOCSPResponse implement ocsp response
27 decoding and verification.
30 #ifndef _SECURITY_SECOCSPRESPONSE_H_
31 #define _SECURITY_SECOCSPRESPONSE_H_
33 #include <Security/SecAsn1Coder.h>
34 #include <CoreFoundation/CFArray.h>
35 #include <CoreFoundation/CFData.h>
36 #include <CoreFoundation/CFDate.h>
37 #include <securityd/SecOCSPRequest.h>
38 #include <security_asn1/ocspTemplates.h>
39 #include <Security/SecCertificatePath.h>
41 #if defined(__cplusplus)
49 kSecOCSPMalformedRequest
= 1,
50 kSecOCSPInternalError
= 2,
53 kSecOCSPSigRequired
= 5,
54 kSecOCSPUnauthorized
= 6
55 } SecOCSPResponseStatus
;
58 kSecRevocationReasonUnrevoked
= -2,
59 kSecRevocationReasonUndetermined
= -1,
60 kSecRevocationReasonUnspecified
= 0,
61 kSecRevocationReasonKeyCompromise
= 1,
62 kSecRevocationReasonCACompromise
= 2,
63 kSecRevocationReasonAffiliationChanged
= 3,
64 kSecRevocationReasonSuperseded
= 4,
65 kSecRevocationReasonCessationOfOperation
= 5,
66 kSecRevocationReasonCertificateHold
= 6,
67 /* -- value 7 is not used */
68 kSecRevocationReasonRemoveFromCRL
= 8,
69 kSecRevocationReasonPrivilegeWithdrawn
= 9,
70 kSecRevocationReasonAACompromise
= 10
72 typedef int32_t SecRevocationReason
;
76 @typedef SecOCSPResponseRef
77 @abstract Object used for ocsp response decoding.
79 typedef struct __SecOCSPResponse
*SecOCSPResponseRef
;
81 struct __SecOCSPResponse
{
83 SecAsn1CoderRef coder
;
84 SecOCSPResponseStatus responseStatus
;
86 CFAbsoluteTime producedAt
;
87 CFAbsoluteTime latestNextUpdate
;
88 CFAbsoluteTime expireTime
;
89 CFAbsoluteTime verifyTime
;
90 SecAsn1OCSPBasicResponse basicResponse
;
91 SecAsn1OCSPResponseData responseData
;
92 SecAsn1OCSPResponderIDTag responderIdTag
;
93 SecAsn1OCSPResponderID responderID
;
96 typedef struct __SecOCSPSingleResponse
*SecOCSPSingleResponseRef
;
98 struct __SecOCSPSingleResponse
{
99 SecAsn1OCSPCertStatusTag certStatus
;
100 CFAbsoluteTime thisUpdate
;
101 CFAbsoluteTime nextUpdate
; /* may be NULL_TIME */
102 CFAbsoluteTime revokedTime
; /* != NULL_TIME for certStatus == CS_Revoked */
103 SecRevocationReason crlReason
;
104 //OCSPExtensions *extensions;
108 @function SecOCSPResponseCreate
109 @abstract Returns a SecOCSPResponseRef from a BER encoded ocsp response.
110 @param berResponse The BER encoded ocsp response.
111 @result A SecOCSPResponseRef.
113 SecOCSPResponseRef
SecOCSPResponseCreate(CFDataRef ocspResponse
,
114 CFTimeInterval maxAge
);
116 CFDataRef
SecOCSPResponseGetData(SecOCSPResponseRef
this);
118 SecOCSPResponseStatus
SecOCSPGetResponseStatus(SecOCSPResponseRef ocspResponse
);
120 CFAbsoluteTime
SecOCSPResponseGetExpirationTime(SecOCSPResponseRef ocspResponse
);
122 CFDataRef
SecOCSPResponseGetNonce(SecOCSPResponseRef ocspResponse
);
124 CFAbsoluteTime
SecOCSPResponseProducedAt(SecOCSPResponseRef ocspResponse
);
126 CFAbsoluteTime
SecOCSPResponseVerifyTime(SecOCSPResponseRef ocspResponse
);
129 @function SecOCSPResponseCopySigners
130 @abstract Returns an array of signers.
131 @param ocspResponse A SecOCSPResponseRef.
132 @result The passed in SecOCSPResponseRef is deallocated
134 CFArrayRef
SecOCSPResponseCopySigners(SecOCSPResponseRef ocspResponse
);
137 @function SecOCSPResponseFinalize
138 @abstract Frees a SecOCSPResponseRef.
139 @param ocspResponse The BER encoded ocsp response.
140 @result A SecOCSPResponseRef.
142 void SecOCSPResponseFinalize(SecOCSPResponseRef ocspResponse
);
144 SecOCSPSingleResponseRef
SecOCSPResponseCopySingleResponse(
145 SecOCSPResponseRef ocspResponse
, SecOCSPRequestRef request
);
147 void SecOCSPSingleResponseDestroy(SecOCSPSingleResponseRef
this);
149 /* Returns the SecCertificatePathRef who's leaf signed this ocspResponse if
150 we can find one and NULL if we can't find a valid signer. The issuerPath
151 contains the cert chain from the anchor to the certificate that issued the
152 leaf certificate for which this ocspResponse is supposed to be valid. */
153 SecCertificatePathRef
SecOCSPResponseCopySigner(SecOCSPResponseRef
this,
154 SecCertificatePathRef issuerPath
);
156 #if defined(__cplusplus)
160 #endif /* !_SECURITY_SECOCSPRESPONSE_H_ */