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