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
24 #include "ocpayload.h"
31 * This function stores CRL in SRM.
33 * @param crl to be stored in SRM.
35 * @return ::OC_STACK_OK for Success, otherwise some error value.
37 OCStackResult UpdateCRLResource(OicSecCrl_t *crl);
40 * This function get encoded with base64 CRL from SRM.
42 * @note Caller responsible for resulting string memory (use OICFree to remove it).
44 * @return NULL if error occured (e.g. CRL did not set).
49 * This function get encoded with DER CRL from SRM.
51 * @return encoded CRL with DER format. array len is 0 if error occured (e.g. CRL did not set).
53 void GetDerCrl(ByteArray_t* crlArray);
56 * This function converts CRL to CBOR
58 * @param crl is a pointer to buffer that contains crl. Shoul be not NULL. Buffer
59 * will be allocated by the function and content of *crl will be ignored.
60 * @param payload is the converted cbor value.
61 * @param size is a pointer to length of the CRL buffer. Should be not NULL.
62 * @param lastUpdate optional field contains CRL last update time
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,
72 * This function converts CBOR to CRL
74 * will be allocated by the function and content of *crl will be ignored.
75 * @param cborPayload is the cbor vlaue
76 * @param size is a pointer to length of the CRL buffer. Should be not NULL.
77 * @param crl is a pointer to buffer that contains crl. Shoul be not NULL. Buffer
79 * @note Caller responsible for crl buffer memory (use OICFree to free it).
81 * @return ::OC_STACK_OK if success, otherwise some error value.
83 OCStackResult CBORPayloadToCrl(const uint8_t *cborPayload, const size_t size,
84 OicSecCrl_t **secCrl);
86 * Initialize CRL resource by loading data from persistent storage.
88 * @return ::OC_STACK_OK for Success, otherwise some error value.
90 OCStackResult InitCRLResource();
93 * Perform cleanup for CRL resources.
95 * @return ::OC_STACK_OK for Success, otherwise some error value.
97 OCStackResult DeInitCRLResource();
100 * Get an instance of CRL resource.
102 * @return reference to the @ref OicSecCrl_t, holding reference to CRL resource.
104 OicSecCrl_t *GetCRLResource();
107 * This function frees resources inside given OicSecCrl_t object
109 * @param crl crl object
111 void DeleteCrl(OicSecCrl_t *crl);
114 * This function gets time when CRL was last updated in database
115 * Function allocates memory for lastUpdate and
116 * Caller is responsible to free that memory
118 * @param lastUpdate pointer to last update string.
119 * @return ::OC_STACK_OK for Success, otherwise some error value.
121 OCStackResult getLastUpdateFromDB(char **lastUpdate);
124 * This function prints OicSecCrl_t object
126 * @param crl crl object
128 void printCrl(const OicSecCrl_t *crl);
134 #endif //IOTVT_SRM_CRLR_H