-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PICO_PLATFORM=host does not allow pico_mbedtls #2427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Do you have a host example that could be used to test this? |
This is the project I am using and the unit testing is done on the host side: Here is the code that uses pico_mbedtls_crypto: Unit tests are run in Github Actions. An example of execution is here: Need a smaller, more focused test code? |
Probably. I could write a sha256 test fairly quickly. The request seems reasonable if @kilograham agrees. |
This is a sample code to test a single SHA256 test vector. main.c #include <stdio.h>
#include <string.h>
#include "pico/stdlib.h"
#include "pico/stdio.h"
#include "mbedtls/sha256.h"
#define IS_SHA256 0
static void test_sha256(void) {
mbedtls_sha256_context ctx;
// https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/secure-hashing#Testing
const unsigned char test_vector_msg[4] = {0x74, 0xba, 0x25, 0x21};
const unsigned char test_vector_md[32] = {0xb1, 0x6a, 0xa5, 0x6b, 0xe3, 0x88, 0x0d, 0x18, 0xcd, 0x41, 0xe6, 0x83, 0x84, 0xcf, 0x1e, 0xc8, 0xc1, 0x76, 0x80, 0xc4, 0x5a, 0x02, 0xb1, 0x57, 0x5d, 0xc1, 0x51, 0x89, 0x23, 0xae, 0x8b, 0x0e};
unsigned char hash[32];
mbedtls_sha256_init(&ctx);
mbedtls_sha256_starts(&ctx, IS_SHA256);
mbedtls_sha256_update(&ctx, test_vector_msg, sizeof(test_vector_msg));
mbedtls_sha256_finish(&ctx, hash);
if (memcmp(test_vector_md, hash, sizeof(hash)) == 0)
printf("SHA256 ok\n");
else
printf("SHA256 ng\n");
}
int main (void) {
stdio_init_all();
test_sha256();
return 0;
} CMakeLists.txt
mbedtls_config.h: #pragma once
#define MBEDTLS_SHA256_C |
Uh oh!
There was an error while loading. Please reload this page.
I'd like to use pico_mbedtls_crypto for using on a development host.
Running tests on the host is often more convenient than on the device, especially when verifying complex behavior. However, it seems that
rp2_common/pico_mbedtls
is not available when building for the host, as it's not included in pico-sdk/src/host.cmake.As a workaround, I’m currently using the following in my CMakeLists.txt to manually bring in mbedtls:
This works, but it would be simpler if pico_mbedtls were included in host.cmake.
The following patch would make it available:
Would it be possible to support this, or is there a recommended alternative approach?
The text was updated successfully, but these errors were encountered: