Select one of the symbols to view example projects that use it.
 
Outline
#include <string.h>
#include "pico.h"
#include "pico/rand.h"
#include "mbedtls/sha256.h"
#include "common.h"
mbedtls_hardware_poll(void *, unsigned char *, size_t, size_t *)
#define PICO_MBEDTLS_SHA256_ALT_USE_DMA
Files
loading...
SourceVuRaspberry Pi Pico SDK and ExamplesPicoSDKsrc/rp2_common/pico_mbedtls/pico_mbedtls.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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause *//* ... */ #include <string.h> #include "pico.h" #include "pico/rand.h" #include "mbedtls/sha256.h" #include "common.h" 5 includes /* Function to feed mbedtls entropy. */ int mbedtls_hardware_poll(void *data __unused, unsigned char *output, size_t len, size_t *olen) { *olen = 0; while(*olen < len) { uint64_t rand_data = get_rand_64(); size_t to_copy = MIN(len, sizeof(rand_data)); memcpy(output + *olen, &rand_data, to_copy); *olen += to_copy; }while (*olen < len) { ... } return 0; }{ ... } #ifdef MBEDTLS_SHA256_ALT #if !LIB_PICO_SHA256 #error SHA256 hardware acceleration not supported #endif // PICO_CONFIG: PICO_MBEDTLS_SHA256_ALT_USE_DMA, Whether to use DMA for writing to hardware for the mbedtls SHA-256 hardware acceleration, type=int, default=1, group=pico_stdlib #ifndef PICO_MBEDTLS_SHA256_ALT_USE_DMA #define PICO_MBEDTLS_SHA256_ALT_USE_DMA 1 #endif void mbedtls_sha256_init(__unused mbedtls_sha256_context *ctx) { }mbedtls_sha256_init (__unused mbedtls_sha256_context *ctx) { ... } void mbedtls_sha256_free(__unused mbedtls_sha256_context *ctx) { }mbedtls_sha256_free (__unused mbedtls_sha256_context *ctx) { ... } int mbedtls_sha256_starts_ret(mbedtls_sha256_context *ctx, int is224) { hard_assert(!is224); // that's annoying return pico_sha256_start_blocking(ctx, SHA256_BIG_ENDIAN, PICO_MBEDTLS_SHA256_ALT_USE_DMA); }mbedtls_sha256_starts_ret (mbedtls_sha256_context *ctx, int is224) { ... } int mbedtls_sha256_update_ret(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen) { pico_sha256_update_blocking(ctx, input, ilen); return 0; }mbedtls_sha256_update_ret (mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen) { ... } int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, unsigned char output[32]) { sha256_result_t result; pico_sha256_finish(ctx, &result); memcpy(output, result.bytes, 32); return 0; }mbedtls_sha256_finish_ret (mbedtls_sha256_context *ctx, unsigned char output[32]) { ... } /* ... */#endif // MBEDTLS_SHA256_ALT
Details
Show:
from
Types: Columns: