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_CertDbManager.h
19 * @brief This header file contains the declarations of X509 Certificate interface layer.
21 * This header file contains the declarations of X509 Certificate interface layer.
24 #ifndef _FSEC_CERT_INTERNAL_CERT_DB_MANAGER_H_
25 #define _FSEC_CERT_INTERNAL_CERT_DB_MANAGER_H_
27 #include "FSecCert_CertTypes.h"
28 #include "FSecCert_CertDbStore.h"
29 #include "FSecCert_CertChain.h"
30 #include "FSecCert_CertPrivateKeyInfo.h"
32 namespace Tizen { namespace Security { namespace Cert
35 class _OSP_EXPORT_ _CertDbManager
38 static _CertDbManager* GetInstance(void);
40 bool IsCertificateTablesCreated(void);
42 result RemoveCaCertificateByType(_CaCertType certType);
44 result RemoveUserCaCertificateByCertId(int certId);
46 result RemoveAllUserCertificate(void);
48 result CreateCertificateTables(void);
50 result ResetCertificateTables(void);
52 result RemoveCertificateTables(void);
54 result RemoveCertificateChainByCertId(int certId);
56 result InsertDefaultCaCertificateFromBuffer(_CaCertType certType, _CertFormat certFormat, byte* pCertBuf, int certLen);
58 result InsertCaCertificateFromBuffer(_CaCertType certType, _CertFormat certFormat, byte* pCertBuf, int certLen, bool checkValidity = true);
60 result UpdateCaCertificateFromBuffer(_CaCertType certType, _CertFormat certFormat, byte* pCurCertBuf, int curCertLen, byte* pNewCertBuf, int newCertLen);
62 result RemoveCaCertificateFromBuffer(_CaCertType certType, _CertFormat certFormat, byte* pCertBuf, int certLen);
64 result GetCaCertificateId(byte* pSubjectName, int subjectNameSize, byte* pIssuerName, int issuerNameSize, int& certId, _CaCertType certType = _CERT_TYPE_NOT_BOUNDED);
66 result GetUserCertificateId(byte* pSubjectName, int subjectNameSize, byte* pIssuerName, int issuerNameSize, int& certId);
68 result GetCertificateListByFormat(_CertFormat certFormat, _CertificateListInfo** ppCertList, int& count);
70 result GetUserCertificateListByFormat(_CertFormat certFormat, _CertificateListInfo** ppCertList, int& count);
72 result GetCaCertificateListByCertId(int certId, _CertificateListInfo** ppCertList);
74 result FindIssuerCertificateAndTypeN(_CertFormat certFormat, char* pIssuerName, byte** ppCert, int& certLen, _CaCertType& certType);
76 result FindIssuerCertificateByTypeN(_CertFormat certFormat, _CaCertType certType, char* pIssuerName, byte** ppCert, int& certLen);
78 result FindCertType(_CertFormat certFormat, char* pIssuerName, char* pSubjectName, _CaCertType* pCertType);
80 result GetUserCertificateListByCertId(int certId, _CertificateListInfo** ppCertList);
82 result GetHashOfCertFile(byte* pFilePath, int* pLen, char* pBuf);
84 result InsertCertChain(_CertFormat certFormat, _CertChain* pCertChain);
86 result InsertCertificateChain(_CertFormat certFormat, _CertChain* pCertChain, _CertPrivateKeyInfo* pPrivateKeyInfo = null);
88 result InsertUserCertificateFromBuffer(_CertFormat certFormat, byte* pCertBuffer, int certLength, byte* pPrivateKey, int privateKeyLen, int parentCa = 0);
90 result GetUserCertificateChain(char* pIssuerName, int issuerNameLen, char* pSubjectName, int subjectNameLen, _CertEncodingType encodingType, _CertificateListInfo** ppCertListInfoTypes);
92 result GetUserCertificateChain(_CertFormat certFormat, _CertChain* pCertChain, _CertPrivateKeyInfo* pPrivateKeyInfo, char* pSubjectName = null);
94 result GetUserCertificateInfoByCertId(int pCertId, int* pSubjectLength, byte* pSubjectName, int* pIssuerLength, byte* pIssuerName);
96 result GetUserCertificateInfoByCertId(int certId, _CertEncodingType encodingType, _CertInfo** ppUserCertInfo);
99 result DeleteCertificateChain(int devCertId, int devParentCa);
101 result DeleteCertificateByIdNTableName(int certId, Tizen::Base::String tableName);
103 _CertDbManager(void);
105 virtual ~_CertDbManager(void);
107 _CertDbManager(const _CertDbManager& rhs);
109 _CertDbManager& operator =(const _CertDbManager& rhs);
111 static void Construct(void);
115 _CaCertDbStore __caCertDbStore;
116 _UserCertDbStore __userCertDbStore;
118 static _CertDbManager* __pCertDb;
122 } } } //Tizen::Security::Cert
124 #endif // _FSEC_CERT_INTERNAL_CERT_DB_MANAGER_H_