Rename project to Pico Keys SDK to avoid confusions with Pico Fido and Pico OpenPGP.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2023-11-06 13:32:28 +01:00
parent de3f5f0bce
commit d0dc786f74
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3
28 changed files with 75 additions and 75 deletions

View file

@ -1,5 +1,5 @@
#
# This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
# This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
# Copyright (c) 2022 Pol Henarejos.
#
# This program is free software: you can redistribute it and/or modify
@ -22,7 +22,7 @@
include(pico_sdk_import.cmake)
endif()
project(pico_hsm C CXX ASM)
project(pico_keys C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
@ -41,32 +41,32 @@
set(USB_ITF_CCID 1)
set(USB_ITF_HID 1)
include(pico_hsm_sdk_import.cmake)
include(pico_keys_sdk_import.cmake)
add_executable(pico_hsm_sdk_exe)
add_executable(pico_keys_sdk_exe)
target_compile_options(pico_hsm_sdk_exe PUBLIC
target_compile_options(pico_keys_sdk_exe PUBLIC
-Wall
-Werror
)
if(ENABLE_EMULATION)
target_compile_options(pico_hsm_sdk_exe PUBLIC
target_compile_options(pico_keys_sdk_exe PUBLIC
-fdata-sections
-ffunction-sections
)
if(APPLE)
target_link_options(pico_hsm_sdk_exe PUBLIC
target_link_options(pico_keys_sdk_exe PUBLIC
-Wl,-dead_strip
)
else()
target_link_options(pico_hsm_sdk_exe PUBLIC
target_link_options(pico_keys_sdk_exe PUBLIC
-Wl,--gc-sections
)
endif (APPLE)
else()
pico_add_extra_outputs(pico_hsm_sdk_exe)
pico_add_extra_outputs(pico_keys_sdk_exe)
target_link_libraries(pico_hsm_sdk_exe PRIVATE pico_hsm_sdk pico_stdlib pico_multicore hardware_flash hardware_sync hardware_adc pico_unique_id hardware_rtc tinyusb_device tinyusb_board)
target_link_libraries(pico_keys_sdk_exe PRIVATE pico_keys_sdk pico_stdlib pico_multicore hardware_flash hardware_sync hardware_adc pico_unique_id hardware_rtc tinyusb_device tinyusb_board)
endif()

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -16,7 +16,7 @@
*/
#include "apdu.h"
#include "hsm.h"
#include "pico_keys.h"
#include "usb.h"
#include <stdio.h>

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -22,7 +22,7 @@
#include "mbedtls/sha256.h"
#include "mbedtls/aes.h"
#include "crypto_utils.h"
#include "hsm.h"
#include "pico_keys.h"
void double_hash_pin(const uint8_t *pin, size_t len, uint8_t output[32]) {
uint8_t o1[32];
@ -91,7 +91,7 @@ int aes_encrypt(const uint8_t *key,
if (r != 0) {
return CCID_EXEC_ERROR;
}
if (mode == HSM_AES_MODE_CBC) {
if (mode == PICO_KEYS_AES_MODE_CBC) {
return mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_ENCRYPT, len, tmp_iv, data, data);
}
return mbedtls_aes_crypt_cfb128(&aes, MBEDTLS_AES_ENCRYPT, len, &iv_offset, tmp_iv, data, data);
@ -115,7 +115,7 @@ int aes_decrypt(const uint8_t *key,
if (r != 0) {
return CCID_EXEC_ERROR;
}
if (mode == HSM_AES_MODE_CBC) {
if (mode == PICO_KEYS_AES_MODE_CBC) {
return mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_DECRYPT, len, tmp_iv, data, data);
}
r = mbedtls_aes_setkey_enc(&aes, key, key_size); //CFB requires set_enc instead set_dec
@ -123,10 +123,10 @@ int aes_decrypt(const uint8_t *key,
}
int aes_encrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, int len) {
return aes_encrypt(key, iv, 256, HSM_AES_MODE_CFB, data, len);
return aes_encrypt(key, iv, 256, PICO_KEYS_AES_MODE_CFB, data, len);
}
int aes_decrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, int len) {
return aes_decrypt(key, iv, 256, HSM_AES_MODE_CFB, data, len);
return aes_decrypt(key, iv, 256, PICO_KEYS_AES_MODE_CFB, data, len);
}
struct lv_data {

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -25,20 +25,20 @@
#include "mbedtls/ecp.h"
#include "mbedtls/md.h"
#define HSM_KEY_RSA 0x000f // It is a mask
#define HSM_KEY_RSA_1K 0x0001
#define HSM_KEY_RSA_2K 0x0002
#define HSM_KEY_RSA_3K 0x0004
#define HSM_KEY_RSA_4k 0x0008
#define HSM_KEY_EC 0x0010
#define HSM_KEY_AES 0x0f00 // It is a mask
#define HSM_KEY_AES_128 0x0100
#define HSM_KEY_AES_192 0x0200
#define HSM_KEY_AES_256 0x0400
#define HSM_KEY_AES_512 0x0800 /* For AES XTS */
#define PICO_KEYS_KEY_RSA 0x000f // It is a mask
#define PICO_KEYS_KEY_RSA_1K 0x0001
#define PICO_KEYS_KEY_RSA_2K 0x0002
#define PICO_KEYS_KEY_RSA_3K 0x0004
#define PICO_KEYS_KEY_RSA_4k 0x0008
#define PICO_KEYS_KEY_EC 0x0010
#define PICO_KEYS_KEY_AES 0x0f00 // It is a mask
#define PICO_KEYS_KEY_AES_128 0x0100
#define PICO_KEYS_KEY_AES_192 0x0200
#define PICO_KEYS_KEY_AES_256 0x0400
#define PICO_KEYS_KEY_AES_512 0x0800 /* For AES XTS */
#define HSM_AES_MODE_CBC 1
#define HSM_AES_MODE_CFB 2
#define PICO_KEYS_AES_MODE_CBC 1
#define PICO_KEYS_AES_MODE_CFB 2
#define IV_SIZE 16

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -131,7 +131,7 @@ int sm_unwrap() {
return CCID_WRONG_PADDING;
}
sm_update_iv();
aes_decrypt(sm_kenc, sm_iv, 128, HSM_AES_MODE_CBC, body, body_size);
aes_decrypt(sm_kenc, sm_iv, 128, PICO_KEYS_AES_MODE_CBC, body, body_size);
memmove(apdu.data, body, body_size);
apdu.nc = sm_remove_padding(apdu.data, body_size);
DEBUG_PAYLOAD(apdu.data, (int) apdu.nc);
@ -162,7 +162,7 @@ int sm_wrap() {
res_APDU_size += (sm_blocksize - (res_APDU_size % sm_blocksize));
DEBUG_PAYLOAD(res_APDU, res_APDU_size);
sm_update_iv();
aes_encrypt(sm_kenc, sm_iv, 128, HSM_AES_MODE_CBC, res_APDU, res_APDU_size);
aes_encrypt(sm_kenc, sm_iv, 128, PICO_KEYS_AES_MODE_CBC, res_APDU, res_APDU_size);
memmove(res_APDU + 1, res_APDU, res_APDU_size);
res_APDU[0] = 0x1;
res_APDU_size++;
@ -224,7 +224,7 @@ void sm_update_iv() {
uint8_t tmp_iv[16], sc_counter[16];
memset(tmp_iv, 0, sizeof(tmp_iv)); //IV is always 0 for encryption of IV based on counter
mbedtls_mpi_write_binary(&sm_mSSC, sc_counter, sizeof(sc_counter));
aes_encrypt(sm_kenc, tmp_iv, 128, HSM_AES_MODE_CBC, sc_counter, sizeof(sc_counter));
aes_encrypt(sm_kenc, tmp_iv, 128, PICO_KEYS_AES_MODE_CBC, sc_counter, sizeof(sc_counter));
memcpy(sm_iv, sc_counter, sizeof(sc_counter));
}

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -22,7 +22,7 @@
#ifndef ENABLE_EMULATION
#include "pico/stdlib.h"
#endif
#include "hsm.h"
#include "pico_keys.h"
typedef enum MSE_protocol {
MSE_AES = 0,

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -16,7 +16,7 @@
*/
#include "file.h"
#include "hsm.h"
#include "pico_keys.h"
#include <string.h>
#include <stdio.h>
#include "asn1.h"

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -27,7 +27,7 @@
#define FLASH_SECTOR_SIZE 4096
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
#include "hsm.h"
#include "pico_keys.h"
#include "file.h"
#include <stdio.h>

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -36,7 +36,7 @@
int fd_map = 0;
uint8_t *map = NULL;
#endif
#include "hsm.h"
#include "pico_keys.h"
#include <string.h>
#define TOTAL_FLASH_PAGES 4

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -44,7 +44,7 @@
#endif
#include "random.h"
#include "hsm.h"
#include "pico_keys.h"
#include "apdu.h"
#ifdef CYW43_WL_GPIO_LED_PIN
#include "pico/cyw43_arch.h"

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -35,7 +35,7 @@
#include "hardware/resets.h"
#include "random.h"
#include "hsm.h"
#include "pico_keys.h"
#include "hardware/rtc.h"
#include "tusb.h"
#include "ccid.h"

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -27,7 +27,7 @@
#include <time.h>
#include <poll.h>
#include "hsm.h"
#include "pico_keys.h"
#include "apdu.h"
#include "usb.h"
#include "ccid/ccid.h"

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -20,8 +20,8 @@
#include "bsp/board.h"
#endif
#include "ctap_hid.h"
#include "hsm.h"
#include "hsm_version.h"
#include "pico_keys.h"
#include "pico_keys_version.h"
#include "apdu.h"
#include "usb.h"
@ -362,8 +362,8 @@ int driver_process_usb_packet_hid(uint16_t read) {
memcpy(resp->nonce, req->nonce, sizeof(resp->nonce));
resp->cid = 0x01000000;
resp->versionInterface = CTAPHID_IF_VERSION;
resp->versionMajor = get_version_major ? get_version_major() : HSM_SDK_VERSION_MAJOR;
resp->versionMinor = get_version_minor ? get_version_minor() : HSM_SDK_VERSION_MINOR;
resp->versionMajor = get_version_major ? get_version_major() : PICO_KEYS_SDK_VERSION_MAJOR;
resp->versionMinor = get_version_minor ? get_version_minor() : PICO_KEYS_SDK_VERSION_MINOR;
resp->capFlags = CAPFLAG_WINK | CAPFLAG_CBOR;
ctap_resp->cid = ctap_req->cid;
@ -446,8 +446,8 @@ int driver_process_usb_packet_hid(uint16_t read) {
memset(ctap_resp, 0, 64);
ctap_resp->cid = ctap_req->cid;
ctap_resp->init.cmd = ctap_req->init.cmd;
ctap_resp->init.data[0] = HSM_SDK_VERSION_MAJOR;
ctap_resp->init.data[1] = HSM_SDK_VERSION_MINOR;
ctap_resp->init.data[0] = PICO_KEYS_SDK_VERSION_MAJOR;
ctap_resp->init.data[1] = PICO_KEYS_SDK_VERSION_MINOR;
ctap_resp->init.bcntl = 4;
hid_write(64);
msg_packet.len = msg_packet.current_len = 0;

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -24,7 +24,7 @@
#include "tusb.h"
#include "bsp/board.h"
#endif
#include "hsm.h"
#include "pico_keys.h"
#include "usb.h"
#include "apdu.h"

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM distribution (https://github.com/polhenarejos/pico-hsm).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify
@ -18,7 +18,7 @@
#include "tusb.h"
#include "usb_descriptors.h"
#include "pico/unique_id.h"
#include "hsm_version.h"
#include "pico_keys_version.h"
#include "usb.h"
#ifndef USB_VID
@ -50,7 +50,7 @@ tusb_desc_device_t const desc_device = {
.idVendor = (USB_VID),
.idProduct = (USB_PID),
.bcdDevice = HSM_SDK_VERSION,
.bcdDevice = PICO_KEYS_SDK_VERSION,
.iManufacturer = 1,
.iProduct = 2,

View file

@ -1,5 +1,5 @@
/*
* This file is part of the Pico HSM SDK distribution (https://github.com/polhenarejos/pico-hsm-sdk).
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
* Copyright (c) 2022 Pol Henarejos.
*
* This program is free software: you can redistribute it and/or modify