f76b9797d4b5eed927bfca0870032f126a04107d
[platform/core/security/key-manager.git] / src / include / ckm / ckm-certificate.h
1 /*
2  *  Copyright (c) 2014 Samsung Electronics Co.
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  * @file        ckm-certificate.h
18  * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
19  * @version     1.0
20  * @brief       Main header file for client library.
21  */
22 #pragma once
23
24 #include <vector>
25 #include <memory>
26
27 #include <ckm/ckm-type.h>
28
29 extern "C" {
30 struct x509_st;
31 typedef struct x509_st X509;
32 }
33
34 // Central Key Manager namespace
35 namespace CKM {
36
37 class Certificate;
38 typedef std::shared_ptr<Certificate> CertificateShPtr;
39
40 class Certificate {
41 public:
42
43     virtual bool empty() const = 0;
44
45     // This function  will return openssl struct X509*.
46     // You should not free the memory.
47     // Memory will be freed in ~Certificate.
48     virtual X509 *getX509() const = 0;
49     virtual RawBuffer getDER() const = 0;
50     virtual ~Certificate(){}
51
52     static CertificateShPtr create(const RawBuffer &rawBuffer, DataFormat format);
53 };
54
55 typedef std::vector<CertificateShPtr> CertificateShPtrVector;
56
57 } // namespace CKM
58