1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef _COMMON_CRYPTO_ENCODE_H 8 #define _COMMON_CRYPTO_ENCODE_H 9 10 #include <stdint.h> 11 12 #define CC_COMMON_CALC_BASE64_ENCODE_SIZE(origSize) ((((origSize+2)/3)*4)+1) 13 #define CC_COMMON_CALC_BASE64_MAX_DECODE_SIZE(encodedSize) ((encodedSize*3)/4) /* max size in case no padding to encoded buffer */ 14 15 /** 16 * @brief performs base64-encode 17 * 18 * @param[in] pBuff - the buffer to encode 19 * @param[in] buffLen - input buffer length 20 * @param[in/out] pEncBuffLen - encoded buffer length 21 * @param[out] pEncBuff - encoded buffer 22 */ 23 /*********************************************************/ 24 int32_t CC_CommonBase64Encode(uint8_t *pBuff, 25 uint32_t buffLen, 26 uint8_t *pEncBuff, 27 uint32_t *pEecBuffLen); 28 29 30 /** 31 * @brief performs base64-decode 32 * 33 * @param[in] pEncBuff - base64-encoded buffer 34 * @param[in] encBuffLen - input buffer length 35 * @param[in/out] pDecBuffLen - decoded buffer length 36 * @param[out] pDecBuff - decoded buffer 37 */ 38 /*********************************************************/ 39 int32_t CC_CommonBase64Decode(uint8_t *pEncBuff, 40 uint32_t encBuffLen, 41 uint8_t *pDecBuff, 42 uint32_t *pDecBuffLen); 43 44 45 46 #endif 47