139b1f11299da5272de74b6b4913369da385167b
[platform/framework/native/appfw.git] / src / security / cert / FSecCert_CertChain.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_CertChain.h
19  * @brief               This header file contains the declarations of Certificate Chain and its operations.
20  *
21  * This header file contains the declarations of Certificate Chain and its operations.
22  */
23
24 #ifndef _FSEC_CERT_INTERNAL_CERT_CHAIN_H_
25 #define _FSEC_CERT_INTERNAL_CERT_CHAIN_H_
26
27 #include "unique_ptr.h"
28 #include "FSecCert_Certificate.h"
29 #include "FSecCert_CertPrivateKeyInfo.h"
30
31 namespace Tizen { namespace Security { namespace Cert
32 {
33
34 class _CertChain
35 {
36 public:
37         _CertChain(void);
38
39         virtual ~_CertChain(void);
40
41         void Clear(void);
42
43         result AddCertificate(_CertFormat certFormat, char* pFileName);
44
45         result AddCertificate(_CertFormat certFormat, byte* pBuf, int bufSize);
46
47         result AddCertificate(_X509Certificate* pCert);
48
49         result AddPrivateKey(char* pPKeyPath);
50
51         result AddPrivateKey(byte* pBuf, int bufSize);
52
53         result MoveNext(void);
54
55         result MovePrev(void);
56
57         result MoveHead(void);
58
59         result MoveTail(void);
60
61         void RemoveHead(bool freeFlag);
62
63         void RemoveTail(bool freeFlag);
64
65         void SetContextType(_CertContextType type);
66
67         result Verify(void);
68
69         result VerifyUsingOpenSsl(void);
70
71         result VerifyCertChainWithDb(void);
72
73         _CertPrivateKeyInfo* GetPrivateKey(void);
74
75         _X509Certificate* GetCurrentCertificate(void);
76
77         _CertFormat GetCertFormat(void);
78
79         _CertDomainType GetCertTypeByDomain(void);
80
81         _CertContextType GetContextType(void);
82
83         int GetCount(void);
84
85 private:
86         _CertChain(const _CertChain& rhs);
87
88         _CertChain& operator =(const _CertChain& rhs);
89
90         static void DelFunc4CmCertificate(void* pValue);
91
92         int CheckBitInBitString(_CertExtensionInfo* pExtension, int bitNo);
93
94 private:
95         int __pos;
96         std::unique_ptr< _CertPrivateKeyInfo > __pPrivateKey;
97         _CertFormat __certFormat;
98         _CaCertType __rootCertType;
99         _CertContextType __contextType;
100         bool __checkValidity;
101         Tizen::Base::Collection::ArrayList __certChain;
102
103 }; //_CertChain
104
105 } } } //Tizen::Security::Cert
106
107 #endif // _FSEC_CERT_INTERNAL_CERT_CHAIN_H_