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_CertDbManager.h
20 * @brief This header file contains the declarations of X509 Certificate interface layer.
22 * This header file contains the declarations of X509 Certificate interface layer.
25 #ifndef _FSEC_CERT_INTERNAL_CERT_DB_MANAGER_H_
26 #define _FSEC_CERT_INTERNAL_CERT_DB_MANAGER_H_
28 #include "FSecCert_CertTypes.h"
29 #include "FSecCert_CertDbStore.h"
30 #include "FSecCert_CertChain.h"
31 #include "FSecCert_CertPrivateKeyInfo.h"
33 namespace Tizen { namespace Security { namespace Cert
36 class _OSP_EXPORT_ _CertDbManager
39 static _CertDbManager* GetInstance(void);
41 bool IsCertificateTablesCreated(void);
43 result RemoveCaCertificateByType(_CaCertType certType);
45 result RemoveUserCaCertificateByCertId(int certId);
47 result RemoveAllUserCertificate(void);
49 result CreateCertificateTables(void);
51 result ResetCertificateTables(void);
53 result RemoveCertificateTables(void);
55 result RemoveCertificateChainByCertId(int certId);
57 result InsertDefaultCaCertificateFromBuffer(_CaCertType certType, _CertFormat certFormat, byte* pCertBuf, int certLen);
59 result InsertCaCertificateFromBuffer(_CaCertType certType, _CertFormat certFormat, byte* pCertBuf, int certLen, bool checkValidity = true);
61 result UpdateCaCertificateFromBuffer(_CaCertType certType, _CertFormat certFormat, byte* pCurCertBuf, int curCertLen, byte* pNewCertBuf, int newCertLen);
63 result RemoveCaCertificateFromBuffer(_CaCertType certType, _CertFormat certFormat, byte* pCertBuf, int certLen);
65 result GetCaCertificateId(byte* pSubjectName, int subjectNameSize, byte* pIssuerName, int issuerNameSize, int& certId, _CaCertType certType = _CERT_TYPE_NOT_BOUNDED);
67 result GetUserCertificateId(byte* pSubjectName, int subjectNameSize, byte* pIssuerName, int issuerNameSize, int& certId);
69 result GetCertificateListByFormat(_CertFormat certFormat, _CertificateListInfo** ppCertList, int& count);
71 result GetUserCertificateListByFormat(_CertFormat certFormat, _CertificateListInfo** ppCertList, int& count);
73 result GetCaCertificateListByCertId(int certId, _CertificateListInfo** ppCertList);
75 result FindIssuerCertificateAndTypeN(_CertFormat certFormat, char* pIssuerName, byte** ppCert, int& certLen, _CaCertType& certType);
77 result FindIssuerCertificateByTypeN(_CertFormat certFormat, _CaCertType certType, char* pIssuerName, byte** ppCert, int& certLen);
79 result FindCertType(_CertFormat certFormat, char* pIssuerName, char* pSubjectName, _CaCertType* pCertType);
81 result GetUserCertificateListByCertId(int certId, _CertificateListInfo** ppCertList);
83 result GetHashOfCertFile(byte* pFilePath, int* pLen, char* pBuf);
85 result InsertCertChain(_CertFormat certFormat, _CertChain* pCertChain);
87 result InsertCertificateChain(_CertFormat certFormat, _CertChain* pCertChain, _CertPrivateKeyInfo* pPrivateKeyInfo = null);
89 result InsertUserCertificateFromBuffer(_CertFormat certFormat, byte* pCertBuffer, int certLength, byte* pPrivateKey, int privateKeyLen, int parentCa = 0);
91 result GetUserCertificateChain(char* pIssuerName, int issuerNameLen, char* pSubjectName, int subjectNameLen, _CertEncodingType encodingType, _CertificateListInfo** ppCertListInfoTypes);
93 result GetUserCertificateChain(_CertFormat certFormat, _CertChain* pCertChain, _CertPrivateKeyInfo* pPrivateKeyInfo, char* pSubjectName = null);
95 result GetUserCertificateInfoByCertId(int pCertId, int* pSubjectLength, byte* pSubjectName, int* pIssuerLength, byte* pIssuerName);
97 result GetUserCertificateInfoByCertId(int certId, _CertEncodingType encodingType, _CertInfo** ppUserCertInfo);
100 result DeleteCertificateChain(int devCertId, int devParentCa);
102 result DeleteCertificateByIdNTableName(int certId, Tizen::Base::String tableName);
104 _CertDbManager(void);
106 virtual ~_CertDbManager(void);
108 _CertDbManager(const _CertDbManager& rhs);
110 _CertDbManager& operator =(const _CertDbManager& rhs);
112 static void Construct(void);
116 _CaCertDbStore __caCertDbStore;
117 _UserCertDbStore __userCertDbStore;
119 static _CertDbManager* __pCertDb;
123 } } } //Tizen::Security::Cert
125 #endif // _FSEC_CERT_INTERNAL_CERT_DB_MANAGER_H_