1 /* 2 * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #ifndef _ESP_TLS_CRYPTO_H 7 #define _ESP_TLS_CRYPTO_H 8 9 #include <stddef.h> 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 /** 16 * @brief Calculate sha1 sum 17 * esp-tls abstraction for crypto sha1 API, calculates the sha1 sum(digest) of 18 * the data provided in input which is of ilen size and returns 19 * a 20 char sha1 sum 20 * @param[in] input Input array 21 * @param[in] ilen Length of Input array 22 * @param[out] output calculated sha1 sum 23 * 24 * @return 25 * mbedtls stack:- 26 * - MBEDTLS_ERR_SHA1_BAD_INPUT_DATA on BAD INPUT. 27 * - 0 on success. 28 * wolfssl stack:- 29 * - -1 on failure. 30 * - 0 on success. 31 */ 32 int esp_crypto_sha1(const unsigned char *input, 33 size_t ilen, 34 unsigned char output[20]); 35 36 /** 37 * @brief Do Base64 encode of the src data 38 * 39 * @param[in] dst destination buffer 40 * @param[in] dlen length of destination buffer 41 * @param[out] olen number of bytes written 42 * @param[in] src src buffer to be encoded 43 * @param[in] slen src buffer len 44 * 45 * @return 46 * mbedtls stack:- 47 * - MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL if buffer is of insufficient size. 48 * - 0 if successful. 49 * wolfssl stack:- 50 * - <0 on failure. 51 * - 0 if succcessful. 52 */ 53 int esp_crypto_base64_encode(unsigned char *dst, size_t dlen, 54 size_t *olen, const unsigned char *src, 55 size_t slen); 56 57 #ifdef __cplusplus 58 } 59 #endif 60 #endif /* _ESP_TLS_CRYPTO_H */ 61