mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-26 16:15:11 +02:00
@@ -71,12 +71,7 @@ void generic_hash(mbedtls_md_type_t md, const uint8_t *input, size_t len, uint8_
|
||||
mbedtls_md(mbedtls_md_info_from_type(md), input, len, output);
|
||||
}
|
||||
|
||||
int aes_encrypt(const uint8_t *key,
|
||||
const uint8_t *iv,
|
||||
int key_size,
|
||||
int mode,
|
||||
uint8_t *data,
|
||||
int len) {
|
||||
int aes_encrypt(const uint8_t *key, const uint8_t *iv, uint16_t key_size, int mode, uint8_t *data, uint16_t len) {
|
||||
mbedtls_aes_context aes;
|
||||
mbedtls_aes_init(&aes);
|
||||
uint8_t tmp_iv[IV_SIZE];
|
||||
@@ -95,12 +90,7 @@ int aes_encrypt(const uint8_t *key,
|
||||
return mbedtls_aes_crypt_cfb128(&aes, MBEDTLS_AES_ENCRYPT, len, &iv_offset, tmp_iv, data, data);
|
||||
}
|
||||
|
||||
int aes_decrypt(const uint8_t *key,
|
||||
const uint8_t *iv,
|
||||
int key_size,
|
||||
int mode,
|
||||
uint8_t *data,
|
||||
int len) {
|
||||
int aes_decrypt(const uint8_t *key, const uint8_t *iv, uint16_t key_size, int mode, uint8_t *data, uint16_t len) {
|
||||
mbedtls_aes_context aes;
|
||||
mbedtls_aes_init(&aes);
|
||||
uint8_t tmp_iv[IV_SIZE];
|
||||
@@ -120,10 +110,10 @@ int aes_decrypt(const uint8_t *key,
|
||||
return mbedtls_aes_crypt_cfb128(&aes, MBEDTLS_AES_DECRYPT, len, &iv_offset, tmp_iv, data, data);
|
||||
}
|
||||
|
||||
int aes_encrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, int len) {
|
||||
int aes_encrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, uint16_t 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) {
|
||||
int aes_decrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, uint16_t len) {
|
||||
return aes_decrypt(key, iv, 256, PICO_KEYS_AES_MODE_CFB, data, len);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user