Implemented client-server model and changed code for thread safety
[platform/framework/native/appfw.git] / src / security / cert / FSecCert_CertManager.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file        FSecCert_CertManager.h
20  * @brief       This header file contains the declarations of Certificate Manager class.
21  *
22  * This header file contains the declarations of Certificate Manager class which manage all SVC calls.
23  */
24
25 #ifndef _FSEC_CERT_INTERNAL_CERT_MANAGER_H_
26 #define _FSEC_CERT_INTERNAL_CERT_MANAGER_H_
27
28 #include "FSecCert_CertChain.h"
29 #include "FSecCert_CertPrivateKeyInfo.h"
30 #include "FSecCert_Certificate.h"
31 #include "FSecCert_CertTypes.h"
32
33 namespace Tizen { namespace Security { namespace Cert
34 {
35
36 class _OSP_EXPORT_ _CertManager
37 {
38 public:
39         static result CreateCrtFile(void);
40
41         static result OpenContext(_CertContextType type, CertChainCtx* pHCertCtx);
42
43         static result AddCertificate(CertChainCtx certCtx, byte* pCert, int certLen);
44
45         static result VerifyChain(CertChainCtx certCtx, _CertDomainType* pDomain);
46
47         static result VerifyCertificate(CertificateHandle certHandle, byte* pPublickey, int keyLen);
48
49         static result GetPubKeyN(byte* pPublickey, int pubkeyLen, int& keyLen, byte** ppModulus, int& expLen, byte** ppExponent);
50
51         static _CertFormat GetEncodedCertBuffer(byte* pCertBuffer, int certBufferLen, byte** pDerCertBuffer, int* pDerCertBufferLength, _CertEncodingType* encodingType);
52
53         static result GetChainDepth(CertChainCtx certCtx, int* pDepth);
54
55         static result GetNthCertificate(CertChainCtx certCtx, int nth, CertificateHandle* pCertHandle);
56
57         static result GetCertBuffer(CertificateHandle certHandle, char** ppCertbuffer, int* pCertLen);
58
59         static result CloseContext(CertChainCtx certCtx);
60
61         static result GetCertInfo(CertificateHandle certHandle, _CertFieldType field, _CertFieldInfos* pCertInfo);
62
63         static result GetPublicKey(CertificateHandle certificate, char* pBuffer, int* pBufLen);
64
65         static result GetSignature(CertificateHandle certificate, char* pBuffer, int* pBufLen);
66
67         static int GetVersion(CertificateHandle certificate);
68
69         static result GetValidity(CertificateHandle certificate, _CertValidityType* pValidity);
70
71         static result GetCertificateType(CertificateHandle certHandle, _CaCertType* pCertType);
72
73         //User Certificate APIs
74
75         static result MakeParseAndVerifyCertChainBufferN(byte* pCertChainBuffer, int certChainLength, byte* pUserPrivateKeyBuffer, int userPrivateKeyLength, _CertChain** ppX509CertChain, _CertPrivateKeyInfo** ppX509PrivateKeyInfo);
76
77         static result CheckRsaPublicPrivateKeyPair(_X509Certificate* pX509Certificate, _CertPrivateKeyInfo* pX509CertificatePrivateKey);
78
79         static result GetCertificateSubjectNameN(CertificateHandle certificateHandle, byte** ppSubjectName, int* pSubjectNameLength);
80
81         static result GetCertificateIssuerNameN(CertificateHandle certificateHandle, byte** ppIssuerName, int* pIssuerNameLength);
82
83         static CertificateStoreCtx OpenUserCertificateStore(int& count);
84
85         static int GetBlockSize(byte* pBuf);
86
87         static CertificateStoreCtx OpenRootCaStore(_CaCertType type, int& count);
88
89 private:
90         static result ParseCertTitle(char subject[_MAX_ISSUER_SUBJECT_NAME_SIZE], char title[_MAX_ISSUER_SUBJECT_NAME_SIZE]);
91
92         _CertManager(const _CertManager& rhs);
93
94         _CertManager& operator =(const _CertManager& rhs);
95 }; //_CertManager
96
97 } } } //Tizen::Security::Cert
98
99 #endif // _FSEC_CERT_INTERNAL_CERT_MANAGER_H_