|
1 /* |
|
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @publishedPartner |
|
22 @released |
|
23 */ |
|
24 |
|
25 #ifndef __SISCERTIFICATECHAIN_H__ |
|
26 #define __SISCERTIFICATECHAIN_H__ |
|
27 |
|
28 |
|
29 #include "sisblob.h" |
|
30 |
|
31 #include <vector> |
|
32 |
|
33 using std::vector; |
|
34 |
|
35 // Forward declarations |
|
36 class CCertChainData; |
|
37 class CCertificateInfo; |
|
38 |
|
39 class CSisCertificateChain |
|
40 { |
|
41 public: |
|
42 /** |
|
43 * Wrapper class which represents SISCertificateChain. |
|
44 * Actual certificate data is contained in SISX library. |
|
45 * CCertChainData represent the cert chain data (SISX). |
|
46 * @param aSisCertChain reference to CCertChainData |
|
47 */ |
|
48 explicit CSisCertificateChain (CCertChainData& aSisCertChain); |
|
49 /** |
|
50 * Free up owned resources |
|
51 */ |
|
52 ~CSisCertificateChain(); |
|
53 /** |
|
54 * Class Name |
|
55 */ |
|
56 virtual std::string Name () const; |
|
57 |
|
58 public: |
|
59 /** |
|
60 * Function will load the certificate into memory. |
|
61 * @param aName certificate file name. |
|
62 */ |
|
63 void Load (const std::wstring& aName); |
|
64 |
|
65 /** |
|
66 * This function will extract the signing chain certificates (1 pem file per chain). |
|
67 * The files will me named as cert1.pem, cert2.pem etc. All the certificates |
|
68 * represented by this chain will be appended in the same pem file. File name of |
|
69 * the certificate chain is based on the certificate chain index passed to it. |
|
70 * |
|
71 * @param aChainIndex Certificate Chain index. |
|
72 * @return void |
|
73 */ |
|
74 void ExtractCertificateChain (std::string& aCertFileName); |
|
75 /** |
|
76 * Function will retrieve a certificate from the chain. |
|
77 * |
|
78 * @param aOffset offset of certificate within the chain. It will be updated |
|
79 * after the function call to point to the next certificate in the |
|
80 * chain. |
|
81 * @return return X509 certificate instance. Caller is responsible for |
|
82 * calling X509_free on the returned data. |
|
83 */ |
|
84 X509* GetX509 (CSISFieldRoot::TFieldSize& aOffset) const; |
|
85 /** |
|
86 * Function will retrieve the bottom most certificate from the chain. |
|
87 * |
|
88 * @return return X509 certificate instance. Caller is responsible for |
|
89 * calling X509_free on the returned data. |
|
90 */ |
|
91 X509* GetBottomX509 () const; // calling code responsible for calling X509_free |
|
92 |
|
93 /** |
|
94 * Extract the complete certificate chain. Where each certificate is |
|
95 * represented by CCertificateInfo class. |
|
96 */ |
|
97 inline const std::vector<CCertificateInfo*>& CertChain() const; |
|
98 |
|
99 private: |
|
100 CSisCertificateChain (const CSisCertificateChain& aInitialiser):iSisCertChain(aInitialiser.iSisCertChain){} |
|
101 void ConstructL(); |
|
102 |
|
103 void LoadText (const std::wstring& aName); |
|
104 void LoadBinary (const std::wstring& aName); |
|
105 |
|
106 private: |
|
107 CCertChainData& iSisCertChain; |
|
108 std::vector<CCertificateInfo*> iCertificateList; |
|
109 }; |
|
110 |
|
111 |
|
112 inline std::string CSisCertificateChain::Name () const |
|
113 { |
|
114 return "Certificate Chain"; |
|
115 } |
|
116 |
|
117 inline const std::vector<CCertificateInfo*>& CSisCertificateChain::CertChain() const |
|
118 { |
|
119 return iCertificateList; |
|
120 } |
|
121 |
|
122 #endif // __SISCERTIFICATECHAIN_H__ |
|
123 |