Imported Upstream version 1.0.0
[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  * @param crl - CRL
34  *
35  * @returns OC_STACK_OK for Success, otherwise some error value
36  */
37 OCStackResult UpdateCRLResource(const OicSecCrl_t *crl);
38
39 /**
40  * This function get encoded with base64 CRL from SRM
41  *
42  * @returns encoded CRL with base64 format. NULL if error occured (e.g. CRL did not set)
43  * @note Caller responsible for resulting string memory (use OICFree to remove it)
44  */
45 char* GetBase64CRL();
46 /**
47  * This function get encoded with DER CRL from SRM
48  *
49  * @returns encoded CRL with DER format. array len is 0 if error occured (e.g. CRL did not set)
50  */
51 void  GetDerCrl(ByteArray crlArray);
52
53 /**
54  * This function get CRL from SRM
55  *
56  * @param crl [out] - pointer to buffer that contains crl. Shoul be not NULL. Buffer
57  * will be allocated by the function and content of *crl will be ignored.
58  * @param outlen [out] - pointer to length of the CRL buffer. Shoul be not NULL.
59  *
60  * @returns OC_STACK_OK if success and errorcode otherwise.
61  * @note Caller responsible for crl buffer memory (use OICFree to free it)
62  */
63 OicSecCrl_t * JSONToCrlBin(const char * jsonStr);
64
65 /**
66  * Initialize CLR resource by loading data from persistent storage.
67  *
68  * @returns OC_STACK_OK for Success, otherwise some error value
69  */
70 OCStackResult InitCRLResource();
71
72 /**
73  * Perform cleanup for CRL resources.
74  */
75 void DeInitCRLResource();
76
77 OicSecCrl_t *GetCRLResource();
78
79 OCEntityHandlerResult CRLEntityHandler(OCEntityHandlerFlag flag,
80                                         OCEntityHandlerRequest * ehRequest,
81                                         void* callbackParameter);
82 #ifdef __cplusplus
83 }
84 #endif
85
86 #endif //IOTVT_SRM_CRLR_H
87
88