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_CertDbStore.h
19 * @brief This header file contains the declarations of X509 Certificate Database.
21 * This header file contains the declarations of X509 Certificate Database.
24 #ifndef _FSEC_CERT_INTERNAL_CERT_DB_STORE_H_
25 #define _FSEC_CERT_INTERNAL_CERT_DB_STORE_H_
27 #include "FSecCert_CertTypes.h"
28 #include "FBaseString.h"
29 #include "FBaseByteBuffer.h"
30 #include "FBaseResult.h"
32 namespace Tizen { namespace Security { namespace Cert
40 char fileName[_MAX_CERTIFICATE_PATH_SIZE];
42 char subjectName[_MAX_ISSUER_SUBJECT_NAME_SIZE];
44 char issuerName[_MAX_ISSUER_SUBJECT_NAME_SIZE];
46 char installed[_MAX_TYPE_RECORD_SIZE];
47 char serialNo[_MAX_SERIAL_NUMBER_SIZE];
54 char certPubKeyHash[_MAX_CERT_PUB_KEY_HASH_SIZE];
56 char fileName[_MAX_CERTIFICATE_PATH_SIZE];
58 char subjectName[_MAX_ISSUER_SUBJECT_NAME_SIZE];
60 char issuerName[_MAX_ISSUER_SUBJECT_NAME_SIZE];
61 char prvKeyPath[_MAX_PRV_KEY_PATH_SIZE_SIZE];
64 char installed[_MAX_TYPE_RECORD_SIZE];
65 char serialNo[_MAX_SERIAL_NUMBER_SIZE];
74 virtual ~_CertDbStore(void);
76 virtual result RemoveCertificateById(int certId);
78 virtual result RemoveAllCertificates(void);
80 virtual result GetNumberOfCertificates(int& count);
82 result IsRootCaCertTableCreated(void);
84 result IsUserCertTableCreated(void);
86 result CreateCertificateTables(void);
88 result DropCertificateTables(void);
90 result DeleteCaCertFiles(void);
92 result DeleteUserCertFiles(void);
95 _CertDbStore(const _CertDbStore& rhs);
97 _CertDbStore& operator =(const _CertDbStore& rhs);
100 bool __rootCaCertTableCreated;
101 bool __userCertTableCreated;
106 : public _CertDbStore
107 , public Tizen::Base::Object
110 _CaCertDbStore(void);
112 virtual ~_CaCertDbStore(void);
114 result RemoveCertificateById(int certId);
116 result RemoveAllCertificates(void);
118 result GetNumberOfCertificates(int& count);
120 result InsertCaCertificate(CaCertRecord* pCertRecord);
122 result UpdateCaCertificate(CaCertRecord* pCertRecord, CaCertRecord* pUpdateCertRecord);
124 result UpdateParentCa(int certId, int parentCa);
126 result RemoveCertificateBySubjectName(_CaCertType certType, byte* pSubjectName, int subjectNameLen);
128 result RemoveCertificateByIssuerNameAndSerialNo(_CaCertType certType, byte* pIssuerName, int issuerNameLen, byte* pSerialNo);
130 result RemoveAllCertificateByCondition(byte* pCondition);
132 result CheckDuplicateCertificate(_CaCertType certType, byte* pSubjectName, int subjectNameLen);
134 result CheckDuplicateCertificate(_CaCertType certType, byte* pIssuerName, int issuerNameLen, byte* pSerialNumber);
136 result GetFirstRecordByConditions(byte* pCondition, CaCertRecord* pCertRecord);
138 result GetNextRecordByCondition(byte* pCondition, CaCertRecord* pCertRecord, int curCertId);
140 result GetCurrentCertId(int& curCertId);
142 result CheckIfSameParent(int certId);
144 result SelectCaCertificateBycertId(int certId, CaCertRecord* pCertRecord);
147 _CaCertDbStore(const _CaCertDbStore& rhs);
149 _CaCertDbStore& operator =(const _CaCertDbStore& rhs);
154 class _UserCertDbStore
155 : public _CertDbStore
156 , public Tizen::Base::Object
160 _UserCertDbStore(void);
162 virtual ~_UserCertDbStore(void);
164 result RemoveCertificateById(int certId);
166 result RemoveAllCertificates(void);
168 result GetNumberOfCertificates(int& count);
170 result InsertUserCertificate(UserCertRecord* pCertRecord);
172 result UpdateParentCa(int certId, int parentCa);
174 result UpdateRecordByCondition(byte* pCondition);
176 result RemoveCertificateByCondition(byte* pCondition);
178 result CheckDuplicateCertificate(byte* pSubjectName, int subjectNameLen);
180 result CheckDuplicateCertificate(byte* pIssuerName, int issuerNameLen, byte* pSerialNumber);
182 result GetFirstRecordByConditions(byte* pCondition, UserCertRecord* pCertRecord);
184 result GetNextRecordByCondition(byte* pCondition, UserCertRecord* pCertRecord, int curCertId);
186 result GetCurrentCertId(int& curCertId);
188 result GetCountByCondition(byte* pCondition, int& count);
190 result GetParentCaByCondition(byte* pCondition, int& parentCa);
192 result SelectUserCertificateBycertId(int certId, UserCertRecord* pCertRecord);
195 _UserCertDbStore(const _UserCertDbStore& rhs);
197 _UserCertDbStore& operator =(const _UserCertDbStore& rhs);
200 }; //_UserCertDbStore
202 } } } //Tizen::Security::Cert
204 #endif // _FSEC_CERT_INTERNAL_CERT_DB_STORE_H_