3e98f8cc13de311b680a9cc6b7250bf427edc4e2
[platform/upstream/iotivity.git] / resource / csdk / security / include / internal / crlresource.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef IOTVT_SRM_CRLR_H
22 #define IOTVT_SRM_CRLR_H
23
24 #include "octypes.h"
25 #include "securevirtualresourcetypes.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /**
32  * This function stores CRL in SRM.
33  *
34  * @param crl to be stored in SRM.
35  *
36  * @return ::OC_STACK_OK for Success, otherwise some error value.
37  */
38 OCStackResult UpdateCRLResource(const OicSecCrl_t *crl);
39
40 /**
41  * This function get encoded with base64 CRL from SRM.
42  *
43  * @note Caller responsible for resulting string memory (use OICFree to remove it).
44  *
45  * @return NULL if error occured (e.g. CRL did not set).
46  */
47 uint8_t* GetCrl();
48
49 /**
50  * This function get encoded with DER CRL from SRM.
51  *
52  * @return encoded CRL with DER format. array len is 0 if error occured (e.g. CRL did not set).
53  */
54 void  GetDerCrl(ByteArray* crlArray);
55
56 /**
57  * This function converts CRL to CBOR
58  *
59  * @param crl is a pointer to buffer that contains crl. Shoul be not NULL. Buffer
60  * will be allocated by the function and content of *crl will be ignored.
61  * @param payload is the converted cbor value.
62  * @param size is a pointer to length of the CRL buffer. Should be not NULL.
63  *
64  * @note Caller responsible for crl buffer memory (use OICFree to free it).
65  *
66  * @return ::OC_STACK_OK if success, otherwise some error value.
67  */
68 OCStackResult CrlToCBORPayload(const OicSecCrl_t *crl, uint8_t **payload, size_t *size);
69
70 /**
71  * This function converts CBOR to CRL
72  *
73  * will be allocated by the function and content of *crl will be ignored.
74  * @param cborPayload is the cbor vlaue
75  * @param size is a pointer to length of the CRL buffer. Should be not NULL.
76  * @param crl is a pointer to buffer that contains crl. Shoul be not NULL. Buffer
77  *
78  * @note Caller responsible for crl buffer memory (use OICFree to free it).
79  *
80  * @return ::OC_STACK_OK if success, otherwise some error value.
81  */
82 OCStackResult CBORPayloadToCrl(const uint8_t *cborPayload, const size_t size,
83                                OicSecCrl_t **secCrl);
84 /**
85  * Initialize CRL resource by loading data from persistent storage.
86  *
87  * @return ::OC_STACK_OK for Success, otherwise some error value.
88  */
89 OCStackResult InitCRLResource();
90
91 /**
92  * Perform cleanup for CRL resources.
93  *
94  * @return ::OC_STACK_OK for Success, otherwise some error value.
95  */
96 OCStackResult DeInitCRLResource();
97
98 /**
99  * Get an instance of CRL resource.
100  *
101  * @return reference to the @ref OicSecCrl_t, holding reference to CRL resource.
102  */
103 OicSecCrl_t *GetCRLResource();
104
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif //IOTVT_SRM_CRLR_H