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