|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Object encapsulating the OCSP response - uses ASN1 encoding |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 #include "ocsp.h" |
|
20 #include "oids.h" |
|
21 #include "panic.h" |
|
22 #include "certid.h" |
|
23 |
|
24 #include <asn1dec.h> |
|
25 #include <x509cert.h> |
|
26 #include <x500dn.h> |
|
27 #include "ocsprequestandresponse.h" |
|
28 |
|
29 COCSPResponse::COCSPResponse() |
|
30 { |
|
31 } |
|
32 |
|
33 |
|
34 COCSPResponse::~COCSPResponse() |
|
35 { |
|
36 delete iArchiveCutoff; |
|
37 iCertInfos.ResetAndDestroy(); |
|
38 } |
|
39 |
|
40 |
|
41 EXPORT_C TInt COCSPResponse::CertCount() const |
|
42 { |
|
43 return iCertInfos.Count(); |
|
44 } |
|
45 |
|
46 |
|
47 EXPORT_C const COCSPResponseCertInfo& COCSPResponse::CertInfo(TUint aIndex) const |
|
48 { |
|
49 return *iCertInfos[aIndex]; |
|
50 } |
|
51 |
|
52 |
|
53 const TPtrC8 COCSPResponse::SignedDataL() const |
|
54 { |
|
55 return iSignedData; |
|
56 } |
|
57 |
|
58 |
|
59 const TPtrC8* COCSPResponse::DataElementEncoding(const TUint aIndex) const |
|
60 { |
|
61 const TPtrC8* result = NULL; |
|
62 |
|
63 switch (aIndex) |
|
64 { |
|
65 case ECertificateChain: |
|
66 result = iSigningCerts.Length() ? &iSigningCerts : NULL; |
|
67 break; |
|
68 case ENonce: |
|
69 result = iNonce.Length() ? &iNonce : NULL; |
|
70 break; |
|
71 case EResponderIDName: |
|
72 result = iResponderIDName.Length() ? &iResponderIDName : NULL; |
|
73 break; |
|
74 case EResponderIDKeyHash: |
|
75 result = iResponderIDKeyHash.Length() ? &iResponderIDKeyHash : NULL; |
|
76 break; |
|
77 default: |
|
78 Panic(KErrArgument); |
|
79 } |
|
80 |
|
81 return result; |
|
82 } |
|
83 |
|
84 |
|
85 void COCSPResponse::InternalizeL(RReadStream& /* aStream */) |
|
86 { |
|
87 Panic(KErrNotSupported); |
|
88 } |
|
89 |
|
90 |
|
91 EXPORT_C TTime COCSPResponse::ProducedAt() const |
|
92 { |
|
93 return iProducedAt; |
|
94 } |
|
95 |
|
96 |
|
97 EXPORT_C const TTime* COCSPResponse::ArchiveCutoff() const |
|
98 { |
|
99 return iArchiveCutoff; |
|
100 } |
|
101 |
|
102 |
|
103 TInt COCSPResponse::Find(const COCSPCertID& aCertID) const |
|
104 { |
|
105 TInt count = CertCount(); |
|
106 for (TInt index = 0; index < count; ++index) |
|
107 { |
|
108 const COCSPCertID& responseCertID = CertInfo(index).CertID(); |
|
109 if (responseCertID == aCertID) |
|
110 { |
|
111 return index; |
|
112 } |
|
113 } |
|
114 |
|
115 return KErrNotFound; |
|
116 } |