1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef CF_BLOB_H 17 #define CF_BLOB_H 18 19 #include <stddef.h> 20 #include <stdint.h> 21 22 typedef struct CfBlob CfBlob; 23 struct CfBlob { 24 uint32_t size; 25 uint8_t *data; 26 }; 27 28 enum CfEncodingFormat { 29 CF_FORMAT_DER = 0, 30 CF_FORMAT_PEM = 1, 31 }; 32 33 typedef struct { 34 uint8_t *data; 35 size_t len; 36 enum CfEncodingFormat encodingFormat; 37 } CfEncodingBlob; 38 39 typedef struct { 40 CfBlob *data; 41 enum CfEncodingFormat format; 42 uint32_t count; 43 } CfArray; 44 45 typedef struct { 46 CfBlob *data; 47 uint32_t count; 48 } CfBlobArray; 49 50 #ifdef __cplusplus 51 extern "C" { 52 #endif 53 54 void CfBlobDataFree(CfBlob *blob); 55 void CfBlobDataClearAndFree(CfBlob *blob); 56 void CfEncodingBlobDataFree(CfEncodingBlob *encodingBlob); 57 void CfArrayDataClearAndFree(CfArray *array); 58 void FreeCfBlobArray(CfBlob *array, uint32_t arrayLen); 59 60 #ifdef __cplusplus 61 } 62 #endif 63 64 #endif 65