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_CertManager.h
20 * @brief This header file contains the declarations of Certificate Manager class.
22 * This header file contains the declarations of Certificate Manager class which manage all SVC calls.
25 #ifndef _FSEC_CERT_INTERNAL_CERT_MANAGER_H_
26 #define _FSEC_CERT_INTERNAL_CERT_MANAGER_H_
28 #include "FSecCert_CertChain.h"
29 #include "FSecCert_CertPrivateKeyInfo.h"
30 #include "FSecCert_Certificate.h"
31 #include "FSecCert_CertTypes.h"
33 namespace Tizen { namespace Security { namespace Cert
36 class _OSP_EXPORT_ _CertManager
39 static result CreateCrtFile(void);
41 static result OpenContext(_CertContextType type, CertChainCtx* pHCertCtx);
43 static result AddCertificate(CertChainCtx certCtx, byte* pCert, int certLen);
45 static result VerifyChain(CertChainCtx certCtx, _CertDomainType* pDomain);
47 static result VerifyCertificate(CertificateHandle certHandle, byte* pPublickey, int keyLen);
49 static result GetPubKeyN(byte* pPublickey, int pubkeyLen, int& keyLen, byte** ppModulus, int& expLen, byte** ppExponent);
51 static _CertFormat GetEncodedCertBuffer(byte* pCertBuffer, int certBufferLen, byte** pDerCertBuffer, int* pDerCertBufferLength, _CertEncodingType* encodingType);
53 static result GetChainDepth(CertChainCtx certCtx, int* pDepth);
55 static result GetNthCertificate(CertChainCtx certCtx, int nth, CertificateHandle* pCertHandle);
57 static result GetCertBuffer(CertificateHandle certHandle, char** ppCertbuffer, int* pCertLen);
59 static result CloseContext(CertChainCtx certCtx);
61 static result GetCertInfo(CertificateHandle certHandle, _CertFieldType field, _CertFieldInfos* pCertInfo);
63 static result GetPublicKey(CertificateHandle certificate, char* pBuffer, int* pBufLen);
65 static result GetSignature(CertificateHandle certificate, char* pBuffer, int* pBufLen);
67 static int GetVersion(CertificateHandle certificate);
69 static result GetValidity(CertificateHandle certificate, _CertValidityType* pValidity);
71 static result GetCertificateType(CertificateHandle certHandle, _CaCertType* pCertType);
73 //User Certificate APIs
75 static result MakeParseAndVerifyCertChainBufferN(byte* pCertChainBuffer, int certChainLength, byte* pUserPrivateKeyBuffer, int userPrivateKeyLength, _CertChain** ppX509CertChain, _CertPrivateKeyInfo** ppX509PrivateKeyInfo);
77 static result CheckRsaPublicPrivateKeyPair(_X509Certificate* pX509Certificate, _CertPrivateKeyInfo* pX509CertificatePrivateKey);
79 static result GetCertificateSubjectNameN(CertificateHandle certificateHandle, byte** ppSubjectName, int* pSubjectNameLength);
81 static result GetCertificateIssuerNameN(CertificateHandle certificateHandle, byte** ppIssuerName, int* pIssuerNameLength);
83 static CertificateStoreCtx OpenUserCertificateStore(int& count);
85 static int GetBlockSize(byte* pBuf);
87 static CertificateStoreCtx OpenRootCaStore(_CaCertType type, int& count);
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_