1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef IOTVT_SRM_CRLR_H
22 #define IOTVT_SRM_CRLR_H
25 #include "securevirtualresourcetypes.h"
32 * This function stores CRL in SRM.
34 * @param crl to be stored in SRM.
36 * @return ::OC_STACK_OK for Success, otherwise some error value.
38 OCStackResult UpdateCRLResource(const OicSecCrl_t *crl);
41 * This function get encoded with base64 CRL from SRM.
43 * @note Caller responsible for resulting string memory (use OICFree to remove it).
45 * @return NULL if error occured (e.g. CRL did not set).
50 * This function get encoded with DER CRL from SRM.
52 * @return encoded CRL with DER format. array len is 0 if error occured (e.g. CRL did not set).
54 void GetDerCrl(ByteArray* crlArray);
57 * This function converts CRL to CBOR
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.
64 * @note Caller responsible for crl buffer memory (use OICFree to free it).
66 * @return ::OC_STACK_OK if success, otherwise some error value.
68 OCStackResult CrlToCBORPayload(const OicSecCrl_t *crl, uint8_t **payload, size_t *size);
71 * This function converts CBOR to CRL
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
78 * @note Caller responsible for crl buffer memory (use OICFree to free it).
80 * @return ::OC_STACK_OK if success, otherwise some error value.
82 OCStackResult CBORPayloadToCrl(const uint8_t *cborPayload, const size_t size,
83 OicSecCrl_t **secCrl);
85 * Initialize CRL resource by loading data from persistent storage.
87 * @return ::OC_STACK_OK for Success, otherwise some error value.
89 OCStackResult InitCRLResource();
92 * Perform cleanup for CRL resources.
94 * @return ::OC_STACK_OK for Success, otherwise some error value.
96 OCStackResult DeInitCRLResource();
99 * Get an instance of CRL resource.
101 * @return reference to the @ref OicSecCrl_t, holding reference to CRL resource.
103 OicSecCrl_t *GetCRLResource();
109 #endif //IOTVT_SRM_CRLR_H