2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FSecCert_Certificate.h
19 * @brief This header file contains the declarations of parsing class.
21 * This header file contains the declarations of parsing class.
24 #ifndef _FSEC_CERT_INTERNAL_CERTIFICATE_H_
25 #define _FSEC_CERT_INTERNAL_CERTIFICATE_H_
27 #include <unique_ptr.h>
28 #include <FBaseDateTime.h>
29 #include "FSecCert_CertExtension.h"
30 #include "FSecCert_CertSignature.h"
31 #include "FSecCert_CertTime.h"
32 #include "FSecCert_Asn1Parser.h"
33 #include "FSecCert_CertTypes.h"
36 namespace Tizen { namespace Security { namespace Cert
39 class _OSP_EXPORT_ _X509CertValidity
42 _X509CertValidity(void);
44 _X509CertValidity(byte* pNotBefore, byte* pNotAfter);
46 virtual ~_X509CertValidity(void);
48 result GetValidity(Tizen::Base::DateTime& drmTime);
50 result SetTimes(byte* pNotBefore, byte* pNotAfter);
52 result GetBeforeTimes(Tizen::Base::DateTime& notBefore);
54 result GetAfterTimes(Tizen::Base::DateTime& notAfter);
57 _X509CertValidity(const _X509CertValidity& rhs);
59 _X509CertValidity& operator =(const _X509CertValidity& rhs);
62 _CertTime __notBefore;
65 }; //_X509CertValidity
67 class _OSP_EXPORT_ _X509CertSubPublicKeyInfo
70 _X509CertSubPublicKeyInfo(void);
72 _X509CertSubPublicKeyInfo(const char* pAlg, int keyLen, byte* pPubKey);
74 virtual ~_X509CertSubPublicKeyInfo(void);
76 result GetPubKeyN(int& keyLen, byte** ppPubKey);
78 result SetPubKey(int keyLen, byte* pPubKey);
80 char* GetPubKeyAlgoId(void);
82 result SetPubKeyAlgoId(const char* pPubKeyAlgoId);
85 _X509CertSubPublicKeyInfo(const _X509CertSubPublicKeyInfo& rhs);
87 _X509CertSubPublicKeyInfo& operator =(const _X509CertSubPublicKeyInfo& rhs);
90 std::unique_ptr< char[] > __pPubKeyAlg;
91 std::unique_ptr< byte[] > __publicKey;
94 }; //_X509CertSubPublicKeyInfo
96 class _OSP_EXPORT_ _X509TbsCert
101 virtual ~_X509TbsCert(void);
103 void SetVersion(byte* pVersion, int len);
105 void SetVersion(int version);
107 int GetVersion(void);
109 void SetSerialNumber(byte* pSerial, int len);
111 result GetSerialNumber(byte*& pSerial, int& len);
113 result SetSignatureAlgoId(const char* pAlgoId);
115 char* GetSignatureAlgoId(void);
117 result SetIssuerName(byte* pName);
119 byte* GetIssuerName(void);
121 result SetValidity(byte* pNotBefore, byte* pNotAfter);
123 result GetValidity(void);
125 result GetBeforeTimes(Tizen::Base::DateTime& notBefore);
127 result GetAfterTimes(Tizen::Base::DateTime& notAfter);
129 result SetSubjectName(byte* pName);
131 byte* GetSubjectName(void);
133 result SetPublicKeyInfo(int keyLen, byte* pPubKey);
135 result GetPublicKeyInfoN(int& keyLen, byte** ppPubKey);
137 char* GetPublicKeyAlgoIdInfo(void);
139 result SetPublicKeyAlgoIdInfo(const char* pPubKeyAlgoId);
141 result AddExtension(byte* pOid, bool critical, byte* pValue, int len);
143 _CertExtension* GetCertExtension(void);
146 _X509TbsCert(const _X509TbsCert& rhs);
148 _X509TbsCert& operator =(const _X509TbsCert& rhs);
152 int __serialNumberLen;
153 byte __serialNumber[_MAX_SERIAL_NUMBER_SIZE];
154 std::unique_ptr< byte[] > __pIssuer;
155 std::unique_ptr< byte[] > __pSubject;
156 std::unique_ptr< char[] > __pSignatureAlgoId;
157 _CertExtension __extension;
158 _X509CertSubPublicKeyInfo __subPubKeyInfo;
159 _X509CertValidity __validity;
163 class _OSP_EXPORT_ _Certificate
169 virtual ~_Certificate(void);
171 result ParseObject(void);
173 virtual result GetKeyIdN(byte** ppKeyid);
175 virtual bool IsSelfSigned(void);
177 _Certificate* GetNextEntry(void);
179 void SetCertFormat(_CertFormat certFormat);
181 _CertFormat GetCertFormat(void);
184 _Certificate(const _Certificate& rhs);
186 _Certificate& operator =(const _Certificate& rhs);
189 _CertFormat __certFormat;
193 class _OSP_EXPORT_ _X509Certificate
194 : public _Certificate
197 _X509Certificate(void);
199 virtual ~_X509Certificate(void);
201 result ParseObject(void);
203 _X509TbsCert* GetTbsCertInstance(void);
205 _CertSignature* GetSignInstance(void);
207 result GetKeyIdN(byte** ppKeyid);
209 bool IsSelfSigned(void);
211 bool IsContextCertificate(void);
213 void SetContextCertificate(bool contextCert);
215 result GetCertBuffer(byte*& pBuf, int& bufSize);
217 result GetIssuerBuffer(byte*& pBuf, int& bufSize);
219 result GetSubjectNameBuffer(byte*& pBuf, int& bufSize);
221 result VerifySignature(byte* pPublicKey, int keySize);
223 bool IsCaCertificate();
225 _X509Certificate* GetNextEntry(void);
227 bool IsIssuer(_X509Certificate* pCertIssuer);
229 void* GetX509CertObject();
232 _X509Certificate(const _X509Certificate& rhs);
234 _X509Certificate& operator =(const _X509Certificate& rhs);
236 result ParseRun(void);
238 result ParseTbsCertHeader(void);
240 result ParseVersion(void);
242 result ParseSerialNumber(void);
244 result ParseAlgorithmIdentifier(void);
246 result ParseIssuerName(void);
248 result ParseValidity(void);
250 result ParseSubjectName(void);
252 result ParseSubjectPublicKeyInfo(void);
254 result ParseExtensions(void);
256 result ParseSignature(void);
261 bool __x509IsSelfSign;
262 void* __pX509Certificate;
263 _X509TbsCert __tbsCert;
264 _CertSignature __signautreInfo;
266 }; //_X509Certificate
268 } } } //Tizen::Security::Cert
270 #endif // _FSEC_CERT_INTERNAL_CERTIFICATE_H_