Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions platform/ext/target/arm/drivers/cc3xx/common/cc3xx_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ enum cc3xx_error {
CC3XX_ERR_DRBG_INVALID_ID,
CC3XX_ERR_DCU_LOCKED,
CC3XX_ERR_DCU_MASK_MISMATCH,
CC3XX_ERR_RSA_ENCODE_MSG_TOO_LONG,
CC3XX_ERR_INVALID_ALGORITHM,
CC3XX_ERR_MAX_VALUE = UINT32_MAX
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ endif()

target_sources(${CC3XX_TARGET_NAME}
PRIVATE
src/cc3xx_lcs.c
src/cc3xx_otp.c
# src/cc3xx_lcs.c
# src/cc3xx_otp.c
src/cc3xx_rng.c
src/cc3xx_hash.c
src/cc3xx_aes.c
Expand All @@ -37,18 +37,10 @@ target_sources(${CC3XX_TARGET_NAME}
src/cc3xx_ec_projective_point.c
src/cc3xx_ecdh.c
src/cc3xx_dcu.c
src/cc3xx_rsa.c
../common/cc3xx_stdlib.c
)

# This file is the performance-limit for ECDSA, so should be compiled with the
# highest possible optimizations for speed, even when we are optimizing for
# code size.
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER)
if (${BUILD_TYPE_LOWER} STREQUAL "release" OR ${BUILD_TYPE_LOWER} STREQUAL "minsizerel")
set_source_files_properties(src/cc3xx_pka.c
PROPERTIES COMPILE_FLAGS -Ofast
)
endif()

target_include_directories(${CC3XX_TARGET_NAME}
PUBLIC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void cc3xx_lowlevel_pka_write_reg_swap_endian(cc3xx_pka_reg_id_t reg_id, const u
/**
* @brief Read data from a PKA register.
*
* @param[in] id The register ID to write data into.
* @param[in] id The register ID to write data into. TYPO???? TO READ DATA FROM MAYBE?
* @param[out] data Buffer the data will be written into.
* @param[in] len The size in bytes of the data to be read. Must
* be a multiple of sizeof(uint32_t). The buffer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// #ifdef USE_PSA_CRYPTOCELL
// #include "psa/crypto.h"
// #include "psa_crypto_driver_wrappers.h"
// #endif


#include <stdint.h>
#include <stddef.h>
#include <cc3xx_pka.h>

/*Should I just throw an error or ignore this? If this is not defined
bigger problems probably exists*/
#ifndef PSA_MAX_RSA_KEY_BITS
#define PSA_MAX_RSA_KEY_BITS 2048
#endif

/*There has to exist macro for this "8" --can use "#define PKA_WORD_SIZE 8"
but that's defined in a cc3xx_pka.c file? Should I move it to header file?*/
#define PSA_MAX_RSA_KEY_BYTES PSA_MAX_RSA_KEY_BITS/8
#define PSA_MAX_RSA_KEY_WORDS PSA_MAX_RSA_KEY_BYTES/sizeof(uint32_t)

cc3xx_err_t cc3xx_lowlevel_rsa_pkcs1v15_encode(
const uint8_t *input, /* Message */
size_t input_size, /* Lenght of the message to encode inn octets */
uint32_t encoded_msg_length, /* Intended length of the encoded msg*/
psa_algorithm_t hash_alg, /*The hash alh used*/
uint8_t *output_buf /* Pointer to the output buffer */

);

cc3xx_err_t cc3xx_lowlevel_rsa_sign(
const uint8_t *key, /* Priv key id */
const uint8_t *input, /* DataIn to encrypt */
size_t input_size,
uint32_t *signature /* Buffer for data out */
);
Loading