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