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