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_CertManager.h
19 * @brief This header file contains the declarations of Certificate Manager class.
21 * This header file contains the declarations of Certificate Manager class which manage all SVC calls.
24 #ifndef _FSEC_CERT_INTERNAL_CERT_MANAGER_H_
25 #define _FSEC_CERT_INTERNAL_CERT_MANAGER_H_
27 #include "FSecCert_CertChain.h"
28 #include "FSecCert_CertPrivateKeyInfo.h"
29 #include "FSecCert_Certificate.h"
30 #include "FSecCert_CertTypes.h"
32 namespace Tizen { namespace Security { namespace Cert
35 class _OSP_EXPORT_ _CertManager
38 static result CreateCrtFile(void);
40 static result OpenContext(_CertContextType type, CertChainCtx* pHCertCtx);
42 static result AddCertificate(CertChainCtx certCtx, byte* pCert, int certLen);
44 static result VerifyChain(CertChainCtx certCtx, _CertDomainType* pDomain);
46 static result VerifyCertificate(CertificateHandle certHandle, byte* pPublickey, int keyLen);
48 static result GetPubKeyN(byte* pPublickey, int pubkeyLen, int& keyLen, byte** ppModulus, int& expLen, byte** ppExponent);
50 static _CertFormat GetEncodedCertBuffer(byte* pCertBuffer, int certBufferLen, byte** pDerCertBuffer, int* pDerCertBufferLength, _CertEncodingType* encodingType);
52 static result GetChainDepth(CertChainCtx certCtx, int* pDepth);
54 static result GetNthCertificate(CertChainCtx certCtx, int nth, CertificateHandle* pCertHandle);
56 static result GetCertBuffer(CertificateHandle certHandle, char** ppCertbuffer, int* pCertLen);
58 static result CloseContext(CertChainCtx certCtx);
60 static result GetCertInfo(CertificateHandle certHandle, _CertFieldType field, _CertFieldInfos* pCertInfo);
62 static result GetPublicKey(CertificateHandle certificate, char* pBuffer, int* pBufLen);
64 static result GetSignature(CertificateHandle certificate, char* pBuffer, int* pBufLen);
66 static int GetVersion(CertificateHandle certificate);
68 static result GetValidity(CertificateHandle certificate, _CertValidityType* pValidity);
70 static result GetCertificateType(CertificateHandle certHandle, _CaCertType* pCertType);
72 //User Certificate APIs
74 static result MakeParseAndVerifyCertChainBufferN(byte* pCertChainBuffer, int certChainLength, byte* pUserPrivateKeyBuffer, int userPrivateKeyLength, _CertChain** ppX509CertChain, _CertPrivateKeyInfo** ppX509PrivateKeyInfo);
76 static result CheckRsaPublicPrivateKeyPair(_X509Certificate* pX509Certificate, _CertPrivateKeyInfo* pX509CertificatePrivateKey);
78 static result GetCertificateSubjectNameN(CertificateHandle certificateHandle, byte** ppSubjectName, int* pSubjectNameLength);
80 static result GetCertificateIssuerNameN(CertificateHandle certificateHandle, byte** ppIssuerName, int* pIssuerNameLength);
82 static CertificateStoreCtx OpenUserCertificateStore(int& count);
84 static int GetBlockSize(byte* pBuf);
86 static CertificateStoreCtx OpenRootCaStore(_CaCertType type, int& count);
88 static result CheckRootCaIntegrity(void);
90 static result ParseCertTitle(char subject[_MAX_ISSUER_SUBJECT_NAME_SIZE], char title[_MAX_ISSUER_SUBJECT_NAME_SIZE]);
92 _CertManager(const _CertManager& rhs);
94 _CertManager& operator =(const _CertManager& rhs);
97 } } } //Tizen::Security::Cert
99 #endif // _FSEC_CERT_INTERNAL_CERT_MANAGER_H_