Select one of the symbols to view example projects that use it.
 
Outline
#include "esp_tls_crypto.h"
#include "esp_log.h"
#include "esp_err.h"
TAG
#include "mbedtls/sha1.h"
#include "mbedtls/base64.h"
#define _esp_crypto_sha1
#define _esp_crypto_base64_encode
#include "wolfssl/ssl.h"
#include "wolfssl/wolfcrypt/coding.h"
#define _esp_crypto_sha1
#define _esp_crypto_base64_encode
esp_crypto_sha1_mbedtls(const unsigned char *, size_t, unsigned char *)
esp_crypto_bas64_encode_mbedtls(unsigned char *, size_t, size_t *, const unsigned char *, size_t)
esp_crypto_sha1(const unsigned char *, size_t, unsigned char *)
esp_crypto_base64_encode(unsigned char *, size_t, size_t *, const unsigned char *, size_t)
Files
loading...
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/esp-tls/esp-tls-crypto/esp_tls_crypto.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #include "esp_tls_crypto.h" #include "esp_log.h" #include "esp_err.h" static const char *TAG = "esp_crypto"; #ifdef CONFIG_ESP_TLS_USING_MBEDTLS #include "mbedtls/sha1.h" #include "mbedtls/base64.h" #define _esp_crypto_sha1 esp_crypto_sha1_mbedtls #define _esp_crypto_base64_encode esp_crypto_bas64_encode_mbedtls/* ... */ #elif CONFIG_ESP_TLS_USING_WOLFSSL #include "wolfssl/ssl.h" /* SHA functions are listed in wolfssl/ssl.h */ #include "wolfssl/wolfcrypt/coding.h" #define _esp_crypto_sha1 esp_crypto_sha1_wolfSSL #define _esp_crypto_base64_encode esp_crypto_base64_encode_woflSSL/* ... */ #endif #ifdef CONFIG_ESP_TLS_USING_MBEDTLS static int esp_crypto_sha1_mbedtls( const unsigned char *input, size_t ilen, unsigned char output[20]) { int ret = mbedtls_sha1(input, ilen, output); if (ret != 0) { ESP_LOGE(TAG, "Error in calculating sha1 sum , Returned 0x%02X", ret); }{...} return ret; }{ ... } static int esp_crypto_bas64_encode_mbedtls( unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen) { return mbedtls_base64_encode(dst, dlen, olen, src, slen); }{ ... } /* ... */#elif CONFIG_ESP_TLS_USING_WOLFSSL static int esp_crypto_sha1_wolfSSL( const unsigned char *input, size_t ilen, unsigned char output[20]) { unsigned char *ret = wolfSSL_SHA1(input, ilen, output); if (ret == NULL) { ESP_LOGE(TAG, "Error in calculating sha1 sum"); return -1; }{...} return 0; }{...} static int esp_crypto_base64_encode_woflSSL(unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen) { *olen = dlen; return Base64_Encode_NoNl((const byte *) src, (word32) slen, (byte *) dst, (word32 *) olen); }{...} /* ... */ #else #error "No TLS/SSL Stack selected" #endif int esp_crypto_sha1( const unsigned char *input, size_t ilen, unsigned char output[20]) { return _esp_crypto_sha1(input, ilen, output); }{ ... } int esp_crypto_base64_encode(unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen ) { return _esp_crypto_base64_encode(dst, dlen, olen, src, slen); }{ ... }
Details