Merge "Beautified source code of appfw/src/base/utility" into tizen_2.2
[platform/framework/native/appfw.git] / src / security / cert / FSecCert_CertList.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        FSecCert_CertList.h
19  * @brief       This header file contains the declarations of Certificate List.
20  *
21  * This header file contains the declarations of Certificate List.
22  */
23
24 #ifndef _FSEC_CERT_INTERNAL_CERT_LIST_H_
25 #define _FSEC_CERT_INTERNAL_CERT_LIST_H_
26
27 #include "unique_ptr.h"
28 #include "FBaseColArrayList.h"
29 #include "FSecCert_CertSignature.h"
30 #include "FSecCert_CertTime.h"
31 #include "FSecCert_CertExtension.h"
32 #include "FSecCert_Asn1Parser.h"
33
34 namespace Tizen { namespace Security { namespace Cert
35 {
36
37 class _X509RevokedCert
38         : public Tizen::Base::Object
39 {
40 public:
41         _X509RevokedCert(void);
42
43         virtual ~_X509RevokedCert(void);
44
45         void SetSerialNumber(byte* pSerial, int len);
46
47         byte* GetSerialNumber(void);
48
49         void SetTime(byte* pRevocationDate);
50
51         byte* GetTime(void);
52
53         void AddExt(byte* pOid, bool critical, byte* pValue, int len);
54
55         _CertExtensionInfo* GetExt(byte* pOid);
56
57         _CertExtensionInfo* GetExt(_CertExt type);
58
59         short GetExtNum(void);
60
61         _CertExtensionInfo* GetExtEntry(short getId);
62
63 private:
64         _X509RevokedCert(const _X509RevokedCert& rhs);
65
66         _X509RevokedCert& operator =(const _X509RevokedCert& rhs);
67
68 private:
69         byte __serialNumber[_MAX_SERIAL_NUMBER_SIZE];
70         int __serialNumberLen;
71         _CertTime __revokedTime;
72         std::unique_ptr< _CertExtension > __pExtension;
73         _X509RevokedCert* __pNextRevokedCert;
74
75 }; //_X509RevokedCert
76
77 class _X509TbsCertList
78 {
79 public:
80         _X509TbsCertList(void);
81
82         virtual ~_X509TbsCertList(void);
83
84         void SetVersion(byte* pVersion, int len);
85
86         int GetVersion(void);
87
88         void SetSignature(const char* pAlgo);
89
90         char* GetSigature(void);
91
92         result SetIssuerName(byte* pName);
93
94         byte* GetIssuerName(void);
95
96         result SetTimes(byte* pThisUpdate, byte* pNextUpdate);
97
98         byte* GetNextUpdate(void);
99
100         void AddCrlEntry(_X509RevokedCert* pCrlEntry);
101
102         int GetEntryNumber(void);
103
104         _X509RevokedCert* GetEntry(int getId);
105
106         void AddExtension(byte* pOid, bool critical, byte* pValue, int len);
107
108 private:
109         _X509TbsCertList(const _X509TbsCertList& rhs);
110
111         _X509TbsCertList& operator =(const _X509TbsCertList& rhs);
112
113 private:
114         int __version;
115         std::unique_ptr< char[] > __pSignatureAlgoId;
116         std::unique_ptr< byte[] > __pIssuer;
117         Tizen::Base::Collection::ArrayList __revokedCerts;
118         _CertExtension __extension;
119         _CertTime __thisUpdate;
120         _CertTime __nextUpdate;
121
122 }; //_X509TBSCertList
123
124 class _CertList
125         : public _Asn1Parser
126 {
127 public:
128         _CertList(void);
129
130         virtual ~_CertList(void);
131
132         result ParseObject(void);
133
134         _X509TbsCertList* GetTbsCertListInstance(void);
135
136         _CertSignature* GetSignInstance(void);
137
138         result GetCrlBuffer(byte*& pBuf, int& bufSize);
139
140 private:
141         _CertList(const _CertList& rhs);
142
143         _CertList& operator =(const _CertList& rhs);
144
145         result ParseVersion();
146
147         result ParseAlgorithmIdentifier();
148
149         result ParseIssuerName();
150
151         result ParseUpdateTimes();
152
153         result ParseRevokedCerts();
154
155         result ParseExtensions();
156
157         result ParseSignature();
158
159 private:
160         void* __pX509Crl;
161         _X509TbsCertList __tbsCertList;
162         _CertSignature __signatureInfo;
163
164 }; //_CertList
165
166 } } } //Tizen::Security::Cert
167
168 #endif // _FSEC_CERT_INTERNAL_CERT_LIST_H_