2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FSecCert_Certificate.h
20 * @brief This header file contains the declarations of parsing class.
22 * This header file contains the declarations of parsing class.
25 #ifndef _FSEC_CERT_INTERNAL_CERTIFICATE_H_
26 #define _FSEC_CERT_INTERNAL_CERTIFICATE_H_
28 #include <unique_ptr.h>
29 #include <FBaseDateTime.h>
30 #include "FSecCert_CertExtension.h"
31 #include "FSecCert_CertSignature.h"
32 #include "FSecCert_CertTime.h"
33 #include "FSecCert_Asn1Parser.h"
34 #include "FSecCert_CertTypes.h"
37 namespace Tizen { namespace Security { namespace Cert
40 class _OSP_EXPORT_ _X509CertValidity
43 _X509CertValidity(void);
45 _X509CertValidity(byte* pNotBefore, byte* pNotAfter);
47 virtual ~_X509CertValidity(void);
49 result GetValidity(Tizen::Base::DateTime& drmTime);
51 result SetTimes(byte* pNotBefore, byte* pNotAfter);
53 result GetBeforeTimes(Tizen::Base::DateTime& notBefore);
55 result GetAfterTimes(Tizen::Base::DateTime& notAfter);
58 _X509CertValidity(const _X509CertValidity& rhs);
60 _X509CertValidity& operator =(const _X509CertValidity& rhs);
63 _CertTime __notBefore;
66 }; //_X509CertValidity
68 class _OSP_EXPORT_ _X509CertSubPublicKeyInfo
71 _X509CertSubPublicKeyInfo(void);
73 _X509CertSubPublicKeyInfo(const char* pAlg, int keyLen, byte* pPubKey);
75 virtual ~_X509CertSubPublicKeyInfo(void);
77 result GetPubKeyN(int& keyLen, byte** ppPubKey);
79 result SetPubKey(int keyLen, byte* pPubKey);
81 char* GetPubKeyAlgoId(void);
83 result SetPubKeyAlgoId(const char* pPubKeyAlgoId);
86 _X509CertSubPublicKeyInfo(const _X509CertSubPublicKeyInfo& rhs);
88 _X509CertSubPublicKeyInfo& operator =(const _X509CertSubPublicKeyInfo& rhs);
91 std::unique_ptr<char[]> __pPubKeyAlg;
92 std::unique_ptr<byte[]> __publicKey;
95 }; //_X509CertSubPublicKeyInfo
97 class _OSP_EXPORT_ _X509TbsCert
102 virtual ~_X509TbsCert(void);
104 void SetVersion(byte* pVersion, int len);
106 void SetVersion(int version);
108 int GetVersion(void);
110 void SetSerialNumber(byte* pSerial, int len);
112 result GetSerialNumber(byte*& pSerial, int& len);
114 result SetSignatureAlgoId(const char* pAlgoId);
116 char* GetSignatureAlgoId(void);
118 result SetIssuerName(byte* pName);
120 byte* GetIssuerName(void);
122 result SetValidity(byte* pNotBefore, byte* pNotAfter);
124 result GetValidity(void);
126 result GetBeforeTimes(Tizen::Base::DateTime& notBefore);
128 result GetAfterTimes(Tizen::Base::DateTime& notAfter);
130 result SetSubjectName(byte* pName);
132 byte* GetSubjectName(void);
134 result SetPublicKeyInfo(int keyLen, byte* pPubKey);
136 result GetPublicKeyInfoN(int& keyLen, byte** ppPubKey);
138 char* GetPublicKeyAlgoIdInfo(void);
140 result SetPublicKeyAlgoIdInfo(const char* pPubKeyAlgoId);
142 result AddExtension(byte* pOid, bool critical, byte* pValue, int len);
144 _CertExtension* GetCertExtension(void);
147 _X509TbsCert(const _X509TbsCert& rhs);
149 _X509TbsCert& operator =(const _X509TbsCert& rhs);
153 int __serialNumberLen;
154 byte __serialNumber[_MAX_SERIAL_NUMBER_SIZE];
155 std::unique_ptr<byte[]> __pIssuer;
156 std::unique_ptr<byte[]> __pSubject;
157 std::unique_ptr<char[]> __pSignatureAlgoId;
158 _CertExtension __extension;
159 _X509CertSubPublicKeyInfo __subPubKeyInfo;
160 _X509CertValidity __validity;
164 class _OSP_EXPORT_ _Certificate
170 virtual ~_Certificate(void);
172 result ParseObject(void);
174 virtual result GetKeyIdN(byte** ppKeyid);
176 virtual bool IsSelfSigned(void);
178 _Certificate* GetNextEntry(void);
180 void SetCertFormat(_CertFormat certFormat);
182 _CertFormat GetCertFormat(void);
185 _Certificate(const _Certificate& rhs);
187 _Certificate& operator =(const _Certificate& rhs);
190 _CertFormat __certFormat;
194 class _OSP_EXPORT_ _X509Certificate
195 : public _Certificate
198 _X509Certificate(void);
200 virtual ~_X509Certificate(void);
202 result ParseObject(void);
204 _X509TbsCert* GetTbsCertInstance(void);
206 _CertSignature* GetSignInstance(void);
208 result GetKeyIdN(byte** ppKeyid);
210 bool IsSelfSigned(void);
212 bool IsContextCertificate(void);
214 void SetContextCertificate(bool contextCert);
216 result GetCertBuffer(byte*& pBuf, int& bufSize);
218 result GetIssuerBuffer(byte*& pBuf, int& bufSize);
220 result GetSubjectNameBuffer(byte*& pBuf, int& bufSize);
222 result VerifySignature(byte* pPublicKey, int keySize);
224 bool IsCaCertificate();
226 _X509Certificate* GetNextEntry(void);
228 bool IsIssuer(_X509Certificate* pCertIssuer);
230 void* GetX509CertObject();
233 _X509Certificate(const _X509Certificate& rhs);
235 _X509Certificate& operator =(const _X509Certificate& rhs);
237 result ParseRun(void);
239 result ParseTbsCertHeader(void);
241 result ParseVersion(void);
243 result ParseSerialNumber(void);
245 result ParseAlgorithmIdentifier(void);
247 result ParseIssuerName(void);
249 result ParseValidity(void);
251 result ParseSubjectName(void);
253 result ParseSubjectPublicKeyInfo(void);
255 result ParseExtensions(void);
257 result ParseSignature(void);
262 bool __x509IsSelfSign;
263 void* __pX509Certificate;
264 _X509TbsCert __tbsCert;
265 _CertSignature __signautreInfo;
267 }; //_X509Certificate
269 } } } //Tizen::Security::Cert
271 #endif // _FSEC_CERT_INTERNAL_CERTIFICATE_H_