From cc60c137c1f5e8ff9dc01f44e2fe44f2036765db Mon Sep 17 00:00:00 2001 From: kaiki osakaki Date: Tue, 28 May 2024 09:26:38 +0900 Subject: [PATCH 1/7] plat-rz: Initial support for Renesas RZ/V2H. Signed-off-by: kaiki osakaki --- core/arch/arm/plat-rz/common/drivers/hw_rng.c | 59 + .../plat-rz/common/drivers/r_sce/README.md | 46 + .../drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst | 4980 +++++++++++++++++ .../common/drivers/r_sce/inc/api/r_sce_api.h | 1501 +++++ .../drivers/r_sce/private/inc/r_sce_private.h | 376 ++ .../drivers/r_sce/private/r_sce_private.c | 1346 +++++ .../common/drivers/r_sce/public/r_sce.c | 1447 +++++ .../common/drivers/r_sce/public/r_sce_aes.c | 2174 +++++++ .../common/drivers/r_sce/public/r_sce_ecc.c | 685 +++ .../common/drivers/r_sce/public/r_sce_rsa.c | 1162 ++++ .../common/drivers/r_sce/public/r_sce_sha.c | 447 ++ .../arm/plat-rz/common/drivers/r_sce/sub.mk | 8 + core/arch/arm/plat-rz/common/drivers/sce.c | 50 + core/arch/arm/plat-rz/common/drivers/sub.mk | 5 +- .../plat-rz/common/pta/include/pta_flash.h | 14 +- core/arch/arm/plat-rz/conf.mk | 3 + core/arch/arm/plat-rz/platform_config.h | 4 +- core/arch/arm/plat-rz/sub.mk | 1 + core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.c | 190 + core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.h | 12 + .../arm/plat-rz/v2h/drivers/cpg/cpg_regs.h | 22 + core/arch/arm/plat-rz/v2h/drivers/cpg/sub.mk | 3 + .../v2h/drivers/sce_lib/inc/instances/r_sce.h | 424 ++ .../arm/plat-rz/v2h/drivers/sce_lib/sub.mk | 4 + core/arch/arm/plat-rz/v2h/drivers/sflash.c | 97 + core/arch/arm/plat-rz/v2h/drivers/sflash.h | 14 + core/arch/arm/plat-rz/v2h/drivers/sub.mk | 7 + core/arch/arm/plat-rz/v2h/main.c | 34 + .../arm/plat-rz/v2h/pta/include/pta_sce.h | 179 + .../arm/plat-rz/v2h/pta/include/pta_sce_aes.h | 279 + .../arm/plat-rz/v2h/pta/include/pta_sce_ecc.h | 70 + .../arm/plat-rz/v2h/pta/include/pta_sce_rsa.h | 84 + .../arm/plat-rz/v2h/pta/include/pta_sce_sha.h | 48 + core/arch/arm/plat-rz/v2h/pta/pta_sce.c | 1170 ++++ core/arch/arm/plat-rz/v2h/pta/pta_sce_aes.c | 2257 ++++++++ core/arch/arm/plat-rz/v2h/pta/pta_sce_ecc.c | 483 ++ core/arch/arm/plat-rz/v2h/pta/pta_sce_rsa.c | 576 ++ core/arch/arm/plat-rz/v2h/pta/pta_sce_sha.c | 269 + core/arch/arm/plat-rz/v2h/pta/sub.mk | 3 + core/arch/arm/plat-rz/v2h/rzv2h_conf.mk | 31 + core/arch/arm/plat-rz/v2h/rzv2h_config.h | 48 + core/arch/arm/plat-rz/v2h/sub.mk | 5 + 42 files changed, 20608 insertions(+), 9 deletions(-) create mode 100644 core/arch/arm/plat-rz/common/drivers/hw_rng.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_sce/README.md create mode 100644 core/arch/arm/plat-rz/common/drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst create mode 100644 core/arch/arm/plat-rz/common/drivers/r_sce/inc/api/r_sce_api.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_sce/private/inc/r_sce_private.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_sce/private/r_sce_private.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_aes.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_ecc.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_rsa.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_sha.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_sce/sub.mk create mode 100644 core/arch/arm/plat-rz/common/drivers/sce.c create mode 100644 core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.c create mode 100644 core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.h create mode 100644 core/arch/arm/plat-rz/v2h/drivers/cpg/cpg_regs.h create mode 100644 core/arch/arm/plat-rz/v2h/drivers/cpg/sub.mk create mode 100644 core/arch/arm/plat-rz/v2h/drivers/sce_lib/inc/instances/r_sce.h create mode 100644 core/arch/arm/plat-rz/v2h/drivers/sce_lib/sub.mk create mode 100644 core/arch/arm/plat-rz/v2h/drivers/sflash.c create mode 100644 core/arch/arm/plat-rz/v2h/drivers/sflash.h create mode 100644 core/arch/arm/plat-rz/v2h/drivers/sub.mk create mode 100644 core/arch/arm/plat-rz/v2h/main.c create mode 100644 core/arch/arm/plat-rz/v2h/pta/include/pta_sce.h create mode 100644 core/arch/arm/plat-rz/v2h/pta/include/pta_sce_aes.h create mode 100644 core/arch/arm/plat-rz/v2h/pta/include/pta_sce_ecc.h create mode 100644 core/arch/arm/plat-rz/v2h/pta/include/pta_sce_rsa.h create mode 100644 core/arch/arm/plat-rz/v2h/pta/include/pta_sce_sha.h create mode 100644 core/arch/arm/plat-rz/v2h/pta/pta_sce.c create mode 100644 core/arch/arm/plat-rz/v2h/pta/pta_sce_aes.c create mode 100644 core/arch/arm/plat-rz/v2h/pta/pta_sce_ecc.c create mode 100644 core/arch/arm/plat-rz/v2h/pta/pta_sce_rsa.c create mode 100644 core/arch/arm/plat-rz/v2h/pta/pta_sce_sha.c create mode 100644 core/arch/arm/plat-rz/v2h/pta/sub.mk create mode 100644 core/arch/arm/plat-rz/v2h/rzv2h_conf.mk create mode 100644 core/arch/arm/plat-rz/v2h/rzv2h_config.h create mode 100644 core/arch/arm/plat-rz/v2h/sub.mk diff --git a/core/arch/arm/plat-rz/common/drivers/hw_rng.c b/core/arch/arm/plat-rz/common/drivers/hw_rng.c new file mode 100644 index 000000000..1efb6ffd4 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/hw_rng.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2021, Renesas Electronics + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define LOCAL_BUFFER_SIZE (16) + +static uint32_t buffer[LOCAL_BUFFER_SIZE / sizeof(uint32_t)]; + +static TEE_Result random_number_generator(uint32_t *rand, size_t size) +{ + fsp_err_t err; + + size_t n; + const size_t rand_sz = 4; + + assert(0 == (size % rand_sz)); + + for (n = 0; n < size; n += rand_sz) + { + err = g_sce_protected_on_sce.randomNumberGenerate(&rand[n]); + switch (err) + { + case FSP_SUCCESS: + break; + default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ + return TEE_ERROR_BUSY; + } + } + + return TEE_SUCCESS; +} + +TEE_Result hw_get_random_bytes(void *buf, size_t len) +{ + TEE_Result ret = TEE_SUCCESS; + + for(size_t i = 0; i < len; i += sizeof(buffer)) + { + if (TEE_SUCCESS != (ret = random_number_generator(buffer, ARRAY_SIZE(buffer)))) + { + return ret; + } + memcpy(buf + i, buffer, MIN(sizeof(buffer), len - i)); + } + + return ret; +} diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/README.md b/core/arch/arm/plat-rz/common/drivers/r_sce/README.md new file mode 100644 index 000000000..1c64d1caa --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/README.md @@ -0,0 +1,46 @@ +RZ MPU SCE Driver +========================================== + +
+Renesas Electronics Corporation + +March-31-2022 +
+ +## 1. Overview + +The SCE Driver is software for controlling SCE, which is the security IP of RZ MPU. + +### 1.1. Requirements + + - RZ Secure Crypto Engine library 1.0.0 (libr_secure_ip_1_0.a.1.0.0) + +### 1.2. Notice + +RZ MPU SCE Driver is distributed as a sample software from Renesas without any warranty or support. + +## 1.3. Contributing + +To contribute to this software, you should email patches to renesas-rz@renesas.com. Please send .patch files as email attachments, not embedded in the email body. + +## 1.4. References + +The following table shows the document related to this function. + +| Number | Issuer | Title | Edition | +|--------|---------|----------------------------------------------------------------|-------------------| +| 1 | Renesas | RZ/G2L Security Manual | Rev.1.00 or later | + + +## 2. Driver Specifications + +See /doc/*.rst + +## 3. Revision history + +Describe the revision history of RZ MPU SCE Driver. + +### 3.1. v1.00 + +- First release. + diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst b/core/arch/arm/plat-rz/common/drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst new file mode 100644 index 000000000..a23742e8a --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst @@ -0,0 +1,4980 @@ +################################################################################### +1.About +################################################################################### + +************************************************************************* +1.1.Overview +************************************************************************* + +This document describes the architecture of the driver for the Secure Crypto Engine (SCE) on RZ MPUs. + +************************************************************************* +1.2.Features +************************************************************************* +The SCE module supports for the following features. + + - Cryptography + - Symmetric Encryption/Decryption + - AES + - ECB 128/256bit + - CBC 128/256bit + - CTR 128/256bit + - Asymmetric Encryption/Decryption + - RSA + - RSAES-PKCS1-V1_5 1024/2048bit + - RSAES-PKCS1-V1_5 4096bit (Encryption only) + - RSASSA-PKCS1-V1_5 1024/2048bit + - RSASSA-PKCS1-V1_5 4096bit (Verification only) + - ECC + - ECDSA secp192r1/secp224r1/secp256r1/BrainpoolP512r1 + - Hash Functions + - SHA-2 + - SHA-256/224 + - Message Authentication Code + - AES-CMAC 128/256bit + - Key Support + - AES 128/256bit + - RSA 1024/2048bit + - RSA 4096bit (public key only) + - ECC secp192r1/secp224r1/secp256r1/BrainpoolP512r1 + - TRNG + +************************************************************************* +1.3.Terminology +************************************************************************* + +************************************************************************* +1.4.Operating Environment +************************************************************************* +------------------------------------------------------- +1.4.1.Hardware Environment +------------------------------------------------------- +The following table lists the hardware needed to use this utility. + +.. csv-table:: Hardware environment + :header: "Name", "Note" + + Target board,"RZ/G2L Device" + +------------------------------------------------------- +1.4.1.Software Environment +------------------------------------------------------- +This driver are designed for use with generic (or no specific) operating systems. + +************************************************************************* +1.5.Requirement +************************************************************************* + + - RZ Secure Crypto Engine library 1.0.0 + +************************************************************************* +1.6.Notice +************************************************************************* + +This driver is distributed as a sample software from Renesas without any warranty or support. + +For inquiries regarding the provision of the RZ Secure Crypto Engine library, please contact Renesas Electronics distributor or contact us. + +################################################################################### +2.SCE Driver API Specifications +################################################################################### + +This chapter presents the API specifications for the RZ SCE driver. + +************************************************************************* +2.1.File Structure +************************************************************************* + +This SCE driver file structure is shown below. + ++------------------------+-------------------+---------------------------------------------------+ +|Folder Name |File Name |Description | ++=====+==================+===================+===================================================+ +|sce |doc |sce_usage_notes.rst|This document. | +| +---------+--------+-------------------+---------------------------------------------------+ +| |inc |api |r_sce_api.h |sce API interface header file | +| | +--------+-------------------+---------------------------------------------------+ +| | |instance|r_sce.h |cryptographic function API header file | +| +---------+--------+-------------------+---------------------------------------------------+ +| |private | |r_sce_private.c |private function API header file | +| | +--------+-------------------+---------------------------------------------------+ +| | |inc |r_sce_private.h |private function API module | +| +---------+--------+-------------------+---------------------------------------------------+ +| |public |r_sce_aes.c |Public AES function API module | +| | +-------------------+---------------------------------------------------+ +| | |r_sce_ecc.c |Public ECC function API module | +| | +-------------------+---------------------------------------------------+ +| | |r_sce_rsa.c |Public RSA function API module | +| | +-------------------+---------------------------------------------------+ +| | |r_sce_sha.c |Public SHA function API module | +| | +-------------------+---------------------------------------------------+ +| | |r_sce.c |Common API module | ++-----+------------------+-------------------+---------------------------------------------------+ + +************************************************************************* +2.2.Functions +************************************************************************* + ++----------------------------------------------------------------------+---------------------------------+ +|Functions |Description | ++=======+==============================================================+=================================+ +|Common |`R_SCE_Open <2.6.1.R_SCE_Open_>`_ |Enables use of SCE functionality.| +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_Close |Stops supply of power to the SCE.| +| |<2.6.2.R_SCE_Close_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_SoftwareReset |Software reset to SCE. | +| |<2.6.3.R_SCE_SoftwareReset_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128_WrappedKeyGenerate |Random AES 128bit wrapped | +| |<2.6.4.R_SCE_AES128_WrappedKeyGenerate_>`_ |Key generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256_WrappedKeyGenerate |Random AES 256bit wrapped | +| |<2.6.5.R_SCE_AES256_WrappedKeyGenerate_>`_ |Key generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA1024_WrappedKeyPairGenerate |Random RSA 1024bit wrapped | +| |<2.6.6.R_SCE_RSA1024_WrappedKeyPairGenerate_>`_ |Key Pair generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA2048_WrappedKeyPairGenerate |Random RSA 2048bit wrapped | +| |<2.6.7.R_SCE_RSA2048_WrappedKeyPairGenerate_>`_ |Key Pair generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp192r1_WrappedKeyPairGenerate |Random ECC 192bit wrapped | +| |<2.6.8.R_SCE_ECC_secp192r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp224r1_WrappedKeyPairGenerate |Random ECC 224bit wrapped | +| |<2.6.9.R_SCE_ECC_secp224r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp256r1_WrappedKeyPairGenerate |Random ECC 256bit wrapped | +| |<2.6.10.R_SCE_ECC_secp256r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate |Random ECC 512bit wrapped | +| |<2.6.11.R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RandomNumberGenerate |Generate 4 words random number | +| |<2.6.12.R_SCE_RandomNumberGenerate_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128_EncryptedKeyWrap |Update AES 128bit installed Key | +| |<2.6.13.R_SCE_AES128_EncryptedKeyWrap_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256_EncryptedKeyWrap |Update AES 256bit installed Key | +| |<2.6.14.R_SCE_AES256_EncryptedKeyWrap_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA1024_EncryptedPublicKeyWrap |Update installed RSA 1024bit | +| |<2.6.15.R_SCE_RSA1024_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA1024_EncryptedPrivateKeyWrap |Update installed RSA 1024bit | +| |<2.6.16.R_SCE_RSA1024_EncryptedPrivateKeyWrap_>`_ |PrivateKey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA2048_EncryptedPublicKeyWrap |Update installed RSA 2048bit | +| |<2.6.17.R_SCE_RSA2048_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA2048_EncryptedPrivateKeyWrap |Update installed RSA 2048bit | +| |<2.6.18.R_SCE_RSA2048_EncryptedPrivateKeyWrap_>`_ |PrivateKey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA4096_EncryptedPublicKeyWrap |Update installed RSA 4096bit | +| |<2.6.19.R_SCE_RSA4096_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap |Update installed ECC 192bit | +| |<2.6.20.R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap |Update installed ECC 224bit | +| |<2.6.21.R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap |Update installed ECC 256bit | +| |<2.6.22.R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap |Update installed ECC 512bit | +| |<2.6.23.R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap |Update installed ECC 192bit | +| |<2.6.24.R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap |Update installed ECC 224bit | +| |<2.6.25.R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap |Update installed ECC 256bit | +| |<2.6.26.R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap |Update installed ECC 512bit | +| |<2.6.27.R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | ++-------+--------------------------------------------------------------+---------------------------------+ +|AES |`R_SCE_AES128ECB_EncryptInit |Initialization function | +| |<2.6.28.R_SCE_AES128ECB_EncryptInit_>`_ |(AES-128 ECB encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128ECB_EncryptUpdate |Update function | +| |<2.6.29.R_SCE_AES128ECB_EncryptUpdate_>`_ |(AES-128 ECB encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128ECB_EncryptFinal |Termination function | +| |<2.6.30.R_SCE_AES128ECB_EncryptFinal_>`_ |(AES-128 ECB encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128ECB_DecryptInit |Initialization function | +| |<2.6.31.R_SCE_AES128ECB_DecryptInit_>`_ |(AES-128 ECB decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128ECB_DecryptUpdate |Update function | +| |<2.6.32.R_SCE_AES128ECB_DecryptUpdate_>`_ |(AES-128 ECB decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128ECB_DecryptFinal |Termination function | +| |<2.6.33.R_SCE_AES128ECB_DecryptFinal_>`_ |(AES-256 ECB decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256ECB_EncryptInit |Initialization function | +| |<2.6.34.R_SCE_AES256ECB_EncryptInit_>`_ |(AES-256 ECB encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256ECB_EncryptUpdate |Update function | +| |<2.6.35.R_SCE_AES256ECB_EncryptUpdate_>`_ |(AES-256 ECB encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256ECB_EncryptFinal |Termination function | +| |<2.6.36.R_SCE_AES256ECB_EncryptFinal_>`_ |(AES-256 ECB encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256ECB_DecryptInit |Initialization function | +| |<2.6.37.R_SCE_AES256ECB_DecryptInit_>`_ |(AES-256 ECB decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256ECB_DecryptUpdate |Update function | +| |<2.6.38.R_SCE_AES256ECB_DecryptUpdate_>`_ |(AES-256 ECB decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256ECB_DecryptFinal |Termination function | +| |<2.6.39.R_SCE_AES256ECB_DecryptFinal_>`_ |(AES-256 ECB decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CBC_EncryptInit |Initialization function | +| |<2.6.40.R_SCE_AES128CBC_EncryptInit_>`_ |(AES-128 CBC encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CBC_EncryptUpdate |Update function | +| |<2.6.41.R_SCE_AES128CBC_EncryptUpdate_>`_ |(AES-128 CBC encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CBC_EncryptFinal |Termination function | +| |<2.6.42.R_SCE_AES128CBC_EncryptFinal_>`_ |(AES-128 CBC encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CBC_DecryptInit |Initialization function | +| |<2.6.43.R_SCE_AES128CBC_DecryptInit_>`_ |(AES-128 CBC decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CBC_DecryptUpdate |Update function | +| |<2.6.44.R_SCE_AES128CBC_DecryptUpdate_>`_ |(AES-128 CBC decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CBC_DecryptFinal |Termination function | +| |<2.6.45.R_SCE_AES128CBC_DecryptFinal_>`_ |(AES-128 CBC decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CBC_EncryptInit |Initialization function | +| |<2.6.46.R_SCE_AES256CBC_EncryptInit_>`_ |(AES-256 CBC encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CBC_EncryptUpdate |Update function | +| |<2.6.47.R_SCE_AES256CBC_EncryptUpdate_>`_ |(AES-256 CBC encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CBC_EncryptFinal |Termination function | +| |<2.6.48.R_SCE_AES256CBC_EncryptFinal_>`_ |(AES-256 CBC encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CBC_DecryptInit |Initialization function | +| |<2.6.49.R_SCE_AES256CBC_DecryptInit_>`_ |(AES-256 CBC decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CBC_DecryptUpdate |Update function | +| |<2.6.50.R_SCE_AES256CBC_DecryptUpdate_>`_ |(AES-256 CBC decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CBC_DecryptFinal |Termination function | +| |<2.6.51.R_SCE_AES256CBC_DecryptFinal_>`_ |(AES-256 CBC decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CTR_EncryptInit |Initialization function | +| |<2.6.52.R_SCE_AES128CTR_EncryptInit_>`_ |(AES-128 CTR encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CTR_EncryptUpdate |Update function | +| |<2.6.53.R_SCE_AES128CTR_EncryptUpdate_>`_ |(AES-128 CTR encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CTR_EncryptFinal |Termination function | +| |<2.6.54.R_SCE_AES128CTR_EncryptFinal_>`_ |(AES-128 CTR encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CTR_DecryptInit |Initialization function | +| |<2.6.55.R_SCE_AES128CTR_DecryptInit_>`_ |(AES-128 CTR decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CTR_DecryptUpdate |Update function | +| |<2.6.56.R_SCE_AES128CTR_DecryptUpdate_>`_ |(AES-128 CTR decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CTR_DecryptFinal |Termination function | +| |<2.6.57.R_SCE_AES128CTR_DecryptFinal_>`_ |(AES-128 CTR decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CTR_EncryptInit |Initialization function | +| |<2.6.58.R_SCE_AES256CTR_EncryptInit_>`_ |(AES-256 CTR encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CTR_EncryptUpdate |Update function | +| |<2.6.59.R_SCE_AES256CTR_EncryptUpdate_>`_ |(AES-256 CTR encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CTR_EncryptFinal |Termination function | +| |<2.6.60.R_SCE_AES256CTR_EncryptFinal_>`_ |(AES-256 CTR encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CTR_DecryptInit |Initialization function | +| |<2.6.61.R_SCE_AES256CTR_DecryptInit_>`_ |(AES-256 CTR decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CTR_DecryptUpdate |Update function | +| |<2.6.62.R_SCE_AES256CTR_DecryptUpdate_>`_ |(AES-256 CTR decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CTR_DecryptFinal |Termination function | +| |<2.6.63.R_SCE_AES256CTR_DecryptFinal_>`_ |(AES-256 CTR decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CMAC_GenerateInit |Initialization function | +| |<2.6.64.R_SCE_AES128CMAC_GenerateInit_>`_ |(AES-128 CMAC generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CMAC_GenerateUpdate |Update function | +| |<2.6.65.R_SCE_AES128CMAC_GenerateUpdate_>`_ |(AES-128 CMAC generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CMAC_GenerateFinal |Termination function | +| |<2.6.66.R_SCE_AES128CMAC_GenerateFinal_>`_ |(AES-128 CMAC generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CMAC_VerifyInit |Initialization function | +| |<2.6.67.R_SCE_AES128CMAC_VerifyInit_>`_ |(AES-128 CMAC verification) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CMAC_VerifyUpdate |Update function | +| |<2.6.68.R_SCE_AES128CMAC_VerifyUpdate_>`_ |(AES-128 CMAC verification) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CMAC_VerifyFinal |Termination function | +| |<2.6.69.R_SCE_AES128CMAC_VerifyFinal_>`_ |(AES-128 CMAC verification) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CMAC_GenerateInit |Initialization function | +| |<2.6.70.R_SCE_AES256CMAC_GenerateInit_>`_ |(AES-256 CMAC generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CMAC_GenerateUpdate |Update function | +| |<2.6.71.R_SCE_AES256CMAC_GenerateUpdate_>`_ |(AES-256 CMAC generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CMAC_GenerateFinal |Termination function | +| |<2.6.72.R_SCE_AES256CMAC_GenerateFinal_>`_ |(AES-256 CMAC generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CMAC_VerifyInit |Initialization function | +| |<2.6.73.R_SCE_AES256CMAC_VerifyInit_>`_ |(AES-256 CMAC verification) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CMAC_VerifyUpdate |Update function | +| |<2.6.74.R_SCE_AES256CMAC_VerifyUpdate_>`_ |(AES-256 CMAC verification) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CMAC_VerifyFinal |Termination function | +| |<2.6.75.R_SCE_AES256CMAC_VerifyFinal_>`_ |(AES-256 CMAC verification) | ++-------+--------------------------------------------------------------+---------------------------------+ +|SHA |`R_SCE_SHA256_Init |Initialization function | +| |<2.6.76.R_SCE_SHA256_Init_>`_ |(SHA-256 hash value generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_SHA256_Update |Update function | +| |<2.6.77.R_SCE_SHA256_Update_>`_ |(SHA-256 hash value generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_SHA256_Final |Termination function | +| |<2.6.78.R_SCE_SHA256_Final_>`_ |(SHA-256 hash value generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_SHA224_Init |Initialization function | +| |<2.6.79.R_SCE_SHA224_Init_>`_ |(SHA-224 hash value generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_SHA224_Update |Update function | +| |<2.6.80.R_SCE_SHA224_Update_>`_ |(SHA-224 hash value generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_SHA224_Final |Termination function | +| |<2.6.81.R_SCE_SHA224_Final_>`_ |(SHA-224 hash value generation) | ++-------+--------------------------------------------------------------+---------------------------------+ +|RSA |`R_SCE_RSASSA_PKCS1024_SignatureGenerate |RSA Signature Generation | +| |<2.6.82.R_SCE_RSASSA_PKCS1024_SignatureGenerate_>`_ |with 1024bit key | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSASSA_PKCS1024_SignatureVerify |RSA Signature verification | +| |<2.6.83.R_SCE_RSASSA_PKCS1024_SignatureVerify_>`_ |with 1024bit key | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSASSA_PKCS2048_SignatureGenerate |RSA Signature Generation | +| |<2.6.84.R_SCE_RSASSA_PKCS2048_SignatureGenerate_>`_ |with 2048bit key | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSASSA_PKCS2048_SignatureVerify |RSA Signature verification | +| |<2.6.85.R_SCE_RSASSA_PKCS2048_SignatureVerify_>`_ |with 2048bit key | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSASSA_PKCS4096_SignatureVerify |RSA Signature verification | +| |<2.6.86.R_SCE_RSASSA_PKCS4096_SignatureVerify_>`_ |with 4096bit key | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSAES_PKCS1024_Encrypt |RSA 1024bit encryption function | +| |<2.6.87.R_SCE_RSAES_PKCS1024_Encrypt_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSAES_PKCS1024_Decrypt |RSA 1024bit decryption function | +| |<2.6.88.R_SCE_RSAES_PKCS1024_Decrypt_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSAES_PKCS2048_Encrypt |RSA 2048bit encryption function | +| |<2.6.89.R_SCE_RSAES_PKCS2048_Encrypt_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSAES_PKCS2048_Decrypt |RSA 1024bit decryption function | +| |<2.6.90.R_SCE_RSAES_PKCS2048_Decrypt_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSAES_PKCS4096_Encrypt |RSA 4096bit encryption function | +| |<2.6.91.R_SCE_RSAES_PKCS4096_Encrypt_>`_ | | ++-------+--------------------------------------------------------------+---------------------------------+ +|ECC |`R_SCE_ECDSA_secp192r1_SignatureGenerate |192bit ECC Signature Generation | +| |<2.6.92.R_SCE_ECDSA_secp192r1_SignatureGenerate_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_secp224r1_SignatureGenerate |224bit ECC Signature Generation | +| |<2.6.93.R_SCE_ECDSA_secp224r1_SignatureGenerate_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_secp256r1_SignatureGenerate |256bit ECC Signature Generation | +| |<2.6.94.R_SCE_ECDSA_secp256r1_SignatureGenerate_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate |512bit ECC Signature verification| +| |<2.6.95.R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_secp192r1_SignatureVerify |192bit ECC Signature verification| +| |<2.6.96.R_SCE_ECDSA_secp192r1_SignatureVerify_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_secp224r1_SignatureVerify |224bit ECC Signature verification| +| |<2.6.97.R_SCE_ECDSA_secp224r1_SignatureVerify_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_secp256r1_SignatureVerify |256bit ECC Signature verification| +| |<2.6.98.R_SCE_ECDSA_secp256r1_SignatureVerify_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify |512bit ECC Signature verification| +| |<2.6.99.R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify_>`_ | | ++-------+--------------------------------------------------------------+---------------------------------+ + + +************************************************************************* +2.3.Return Values and Constants +************************************************************************* +The return values for the SCE driver API functions is shown below. + +.. csv-table:: Return values for the SCE driver API functions + :header: "Return Code", "Value", "Description" + + FSP_SUCCESS,0,"Normal termination" + FSP_ERR_CRYPTO_CONTINUE,0x10000,"Continue executing function" + FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT,0x10001,"Hardware resource busy" + FSP_ERR_CRYPTO_SCE_FAIL,0x10002,"Internal I/O buffer is not empty" + FSP_ERR_CRYPTO_SCE_HRK_INVALID_INDEX,0x10003,"Invalid index" + FSP_ERR_CRYPTO_SCE_RETRY,0x10004,"Retry" + FSP_ERR_CRYPTO_SCE_VERIFY_FAIL,0x10005,"Verify is failed" + FSP_ERR_CRYPTO_SCE_ALREADY_OPEN,0x10006,"HW SCE module is already opened" + FSP_ERR_CRYPTO_NOT_OPEN,0x10007,"Hardware module is not initialized" + FSP_ERR_CRYPTO_UNKNOWN,0x10008,"Some unknown error occurred" + FSP_ERR_CRYPTO_NULL_POINTER,0x10009,"Null pointer input as a parameter" + FSP_ERR_CRYPTO_NOT_IMPLEMENTED,0x1000a,"Algorithm/size not implemented" + FSP_ERR_CRYPTO_RNG_INVALID_PARAM,0x1000b,"An invalid parameter is specified" + FSP_ERR_CRYPTO_RNG_FATAL_ERROR,0x1000c,"A fatal error occurred" + FSP_ERR_CRYPTO_INVALID_SIZE,0x1000d,"Size specified is invalid" + FSP_ERR_CRYPTO_INVALID_STATE,0x1000e,"Function used in an valid state" + FSP_ERR_CRYPTO_ALREADY_OPEN,0x1000f,"control block is already opened" + FSP_ERR_CRYPTO_INSTALL_KEY_FAILED,0x10010,"Specified input key is invalid." + FSP_ERR_CRYPTO_AUTHENTICATION_FAILED,0x10011,"Authentication failed" + FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL,0x10012,"Failure to Init Cipher" + FSP_ERR_CRYPTO_SCE_AUTHENTICATION,0x10013,"Authentication failed" + FSP_ERR_CRYPTO_SCE_PARAMETER,0x10014,"Input date is illegal." + FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION,0x10015,"An invalid function call occurred." + FSP_ERR_CRYPTO_COMMON_NOT_OPENED,0x20000,"Crypto Framework Common is not opened" + FSP_ERR_CRYPTO_HAL_ERROR,0x20001,"Cryoto HAL module returned an error" + FSP_ERR_CRYPTO_KEY_BUF_NOT_ENOUGH,0x20002,"Key buffer size is not enough to generate a key" + FSP_ERR_CRYPTO_BUF_OVERFLOW,0x20003,"Attempt to write data larger than what the buffer can hold" + FSP_ERR_CRYPTO_INVALID_OPERATION_MODE,0x20004,"Invalid operation mode." + FSP_ERR_MESSAGE_TOO_LONG,0x20005,"Message for RSA encryption is too long." + FSP_ERR_RSA_DECRYPTION_ERROR,0x20006,"RSA Decryption error." + +The macro constants defined by the SCE driver is shown below. + +.. csv-table:: Macro define for Common operation + :header: "Macro Code", "Value" + + HW_SCE_SRAM_WORD_SIZE,32U + HW_SCE_SINST_WORD_SIZE,140U + HW_SCE_SINST2_WORD_SIZE,16U + HW_SCE_SHEAP_WORD_SIZE,1504U + HW_SCE_MAC_SIZE,16U + +.. csv-table:: Macro define for AES operation + :header: "Macro Code", "Value" + + HW_SCE_AES128_KEY_INDEX_WORD_SIZE,12U + HW_SCE_AES256_KEY_INDEX_WORD_SIZE,16U + HW_SCE_AES128_KEY_WORD_SIZE,4U + HW_SCE_AES256_KEY_WORD_SIZE,8U + HW_SCE_AES128_KEY_BYTE_SIZE,16U + HW_SCE_AES256_KEY_BYTE_SIZE,32U + HW_SCE_AES_BLOCK_BYTE_SIZE,16U + HW_SCE_AES_BLOCK_BIT_SIZE,128U + HW_SCE_AES_CBC_IV_BYTE_SIZE,16U + HW_SCE_AES_CTR_IV_BYTE_SIZE,16U + +.. csv-table:: Macro define for SHA operation + :header: "Macro Code", "Value" + + HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE,28U + HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE,32U + HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE,64U + +.. csv-table:: Macro define for RSA operation + :header: "Macro Code", "Value" + + HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE,128U + HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE,4U + HW_SCE_RSA_1024_KEY_D_LENGTH_BYTE_SIZE,128U + HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE,256U + HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE,4U + HW_SCE_RSA_2048_KEY_D_LENGTH_BYTE_SIZE,256U + HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE,128*4U + HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE,4U + HW_SCE_RSA_4096_KEY_D_LENGTH_BYTE_SIZE,128*4U + HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U + HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE,36U + HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U + HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE,68U + HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U + HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE,68U + HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U + HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE,132U + HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U + HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE,4U + HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE,12U + HW_SCE_RSA1024_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE,76U + HW_SCE_RSA1024_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE,104U + HW_SCE_RSA2048_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE,140U + HW_SCE_RSA2048_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE,200U + HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE,11U + HW_SCE_RSA_1024_DATA_BYTE_SIZE,128U + HW_SCE_RSA_2048_DATA_BYTE_SIZE,256U + HW_SCE_RSA_4096_DATA_BYTE_SIZE,128*4U + HW_SCE_SHARED_SECRET_KEY_INDEX_WORD_SIZE,13U + +.. csv-table:: Macro define for ECC operation + :header: "Macro Code", "Value" + + HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE,144U + HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE,4U + HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE,24U + HW_SCE_ECDSA_DATA_BYTE_SIZE,64U + HW_SCE_ECDSA_P512_DATA_BYTE_SIZE,128U + SCE_ECC_CURVE_TYPE_NIST,0 + SCE_ECC_CURVE_TYPE_BRAINPOOL,1 + SCE_ECC_CURVE_TYPE_KOBLITZ,2 + SCE_ECC_KEY_LENGTH_256,0 + SCE_ECC_KEY_LENGTH_224,1 + SCE_ECC_KEY_LENGTH_192,2 + +.. csv-table:: Macro define for HASH type + :header: "Macro Code", "Value" + + HW_SCE_RSA_HASH_SHA256,0x03 + +.. csv-table:: Macro define for Key update + :header: "Macro Code", "Value" + + HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE,16U + SCE_OEM_KEY_SIZE_DUMMY_INST_DATA_WORD,0 + SCE_OEM_KEY_SIZE_AES128_INST_DATA_WORD,8 + SCE_OEM_KEY_SIZE_AES256_INST_DATA_WORD,12 + SCE_OEM_KEY_SIZE_RSA1024_PUBLIC_KEY_INST_DATA_WORD,40 + SCE_OEM_KEY_SIZE_RSA1024_PRIVATE_KEY_INST_DATA_WORD,68 + SCE_OEM_KEY_SIZE_RSA2048_PUBLIC_KEY_INST_DATA_WORD,72 + SCE_OEM_KEY_SIZE_RSA2048_PRIVATE_KEY_INST_DATA_WORD,132 + SCE_OEM_KEY_SIZE_RSA4096_PUBLIC_KEY_INST_DATA_WORD,136 + SCE_OEM_KEY_SIZE_RSA4096_PRIVATE_KEY_INST_DATA_WORD,260 + SCE_OEM_KEY_SIZE_ECCP192_PUBLIC_KEY_INST_DATA_WORD,20 + SCE_OEM_KEY_SIZE_ECCP192_PRIVATE_KEY_INST_DATA_WORD,12 + SCE_OEM_KEY_SIZE_ECCP224_PUBLIC_KEY_INST_DATA_WORD,20 + SCE_OEM_KEY_SIZE_ECCP224_PRIVATE_KEY_INST_DATA_WORD,12 + SCE_OEM_KEY_SIZE_ECCP256_PUBLIC_KEY_INST_DATA_WORD,20 + SCE_OEM_KEY_SIZE_ECCP256_PRIVATE_KEY_INST_DATA_WORD,12 + SCE_INSTALL_KEY_RING_INDEX,0 + + +************************************************************************* +2.4.Structure and Enumerations +************************************************************************* + +------------------------------------------------------- +SCE_KEY_INDEX_TYPE +------------------------------------------------------- + +.. code:: c + + typedef enum + { + SCE_KEY_INDEX_TYPE_INVALID = 0U, + SCE_KEY_INDEX_TYPE_AES128, + SCE_KEY_INDEX_TYPE_AES256, + SCE_KEY_INDEX_TYPE_TDES, + SCE_KEY_INDEX_TYPE_HMAC_SHA1, + SCE_KEY_INDEX_TYPE_HMAC_SHA256, + SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE, + SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE, + SCE_KEY_INDEX_TYPE_RSA3072_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA3072_PRIVATE, + SCE_KEY_INDEX_TYPE_RSA4096_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA4096_PRIVATE, + SCE_KEY_INDEX_TYPE_AES128_FOR_TLS, + SCE_KEY_INDEX_TYPE_AES192_FOR_TLS, + SCE_KEY_INDEX_TYPE_AES256_FOR_TLS, + SCE_KEY_INDEX_TYPE_HMAC_SHA1_FOR_TLS, + SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_TLS, + SCE_KEY_INDEX_TYPE_UPDATE_KEY_RING, + SCE_KEY_INDEX_TYPE_TLS_CA_CERTIFICATION_PUBLIC_KEY, + SCE_KEY_INDEX_TYPE_TLS_P256_ECC_KEY, + SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P256R1_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P512R1_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P256R1_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P512R1_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PRIVATE, + SCE_KEY_INDEX_TYPE_ECDH_SHARED_SECRET, + SCE_KEY_INDEX_TYPE_AES128_FOR_ECDH, + SCE_KEY_INDEX_TYPE_AES256_FOR_ECDH, + SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_ECDH, + SCE_KEY_INDEX_TYPE_AES128_GCM_FOR_DLMS_COSEM, + SCE_KEY_INDEX_TYPE_AES256_GCM_FOR_DLMS_COSEM, + SCE_KEY_INDEX_TYPE_AES128_KEY_WRAP_FOR_DLMS_COSEM, + SCE_KEY_INDEX_TYPE_AES128_GCM_WITH_IV, + } SCE_KEY_INDEX_TYPE; + +------------------------------------------------------- +sce_oem_cmd +------------------------------------------------------- + +.. code:: c + + typedef enum e_sce_oem_cmd + { + SCE_OEM_CMD_AES128 = 5, + SCE_OEM_CMD_AES256 = 7, + SCE_OEM_CMD_RSA1024_PUBLIC = 10, + SCE_OEM_CMD_RSA1024_PRIVATE, + SCE_OEM_CMD_RSA2048_PUBLIC, + SCE_OEM_CMD_RSA2048_PRIVATE, + SCE_OEM_CMD_RSA3072_PUBLIC, + SCE_OEM_CMD_RSA3072_PRIVATE, + SCE_OEM_CMD_RSA4096_PUBLIC, + SCE_OEM_CMD_RSA4096_PRIVATE, + SCE_OEM_CMD_ECC_P192_PUBLIC, + SCE_OEM_CMD_ECC_P192_PRIVATE, + SCE_OEM_CMD_ECC_P224_PUBLIC, + SCE_OEM_CMD_ECC_P224_PRIVATE, + SCE_OEM_CMD_ECC_P256_PUBLIC, + SCE_OEM_CMD_ECC_P256_PRIVATE, + SCE_OEM_CMD_ECC_P384_PUBLIC, + SCE_OEM_CMD_ECC_P384_PRIVATE, + SCE_OEM_CMD_ECC_P512_PUBLIC, + SCE_OEM_CMD_ECC_P512_PRIVATE, + SCE_OEM_CMD_HMAC_SHA256 = 28, + SCE_OEM_CMD_NUM + } sce_oem_cmd_t; + +------------------------------------------------------- +sce_byte_data +------------------------------------------------------- +Byte data structure + +.. code:: c + + typedef struct sce_byte_data + { + uint8_t * pdata; ///< pointer + uint32_t data_length; ///< data_length + uint32_t data_type; ///< data type + } sce_byte_data_t; + +------------------------------------------------------- +sce_rsa_byte_data_t +------------------------------------------------------- +RSA byte data structure + +.. code:: c + + typedef sce_byte_data_t sce_rsa_byte_data_t; ///< byte data + +------------------------------------------------------- +sce_ecdsa_byte_data_t +------------------------------------------------------- +ECDSA byte data structure + +.. code:: c + + typedef sce_byte_data_t sce_ecdsa_byte_data_t; ///< byte data + +------------------------------------------------------- +sce_aes_wrapped_key_t +------------------------------------------------------- +AES wrapped key data structure. DO NOT MODIFY. + +.. code:: c + + typedef struct sce_aes_wrapped_key + { + uint32_t type; ///< key type + + /* AES128, AES256 are supported */ + uint32_t value[SCE_TLS_AES256_KEY_INDEX_WORD_SIZE]; ///< wrapped key value + } sce_aes_wrapped_key_t; + +------------------------------------------------------- +sce_rsa1024_public_wrapped_key_t +------------------------------------------------------- +RSA 1024bit public wrapped key data structure. DO NOT MODIFY. + +.. code:: c + + typedef struct sce_rsa1024_public_wrapped_key + { + uint32_t type; ///< key type + struct + { + uint32_t key_management_info1[HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information + uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 1024-bit public key n (plaintext) + uint8_t key_e[HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE]; ///< RSA 1024-bit public key e (plaintext) + uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; ///< dummy + uint32_t key_management_info2[HW_SCE_AES256_KEY_INDEX_WORD_SIZE]; ///< key management information + } value; + } sce_rsa1024_public_wrapped_key_t; + +------------------------------------------------------- +sce_rsa1024_private_wrapped_key_t +------------------------------------------------------- +RSA 1024bit private wrapped key data structure. DO NOT MODIFY. + +.. code:: c + + typedef struct sce_rsa1024_private_wrapped_key + { + uint32_t type; ///< key type + struct + { + uint32_t key_management_info1[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information + uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 1024-bit private key n (plaintext) + uint32_t key_management_info2[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information + } value; + } sce_rsa1024_private_wrapped_key_t; + +------------------------------------------------------- +sce_rsa2048_public_wrapped_key_t +------------------------------------------------------- +RSA 2048bit public wrapped key data structure. DO NOT MODIFY. + +.. code:: c + + typedef struct sce_rsa2048_public_wrapped_key + { + uint32_t type; ///< Key type + struct + { + uint32_t key_management_info1[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information + uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 2048-bit public key n (plaintext) + uint8_t key_e[HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE]; ///< RSA 2048-bit public key e (plaintext) + uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; ///< dummy + uint32_t key_management_info2[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information + } value; + } sce_rsa2048_public_wrapped_key_t; + +------------------------------------------------------- +sce_rsa2048_private_wrapped_key_t +------------------------------------------------------- +RSA 2048bit private wrapped key data structure. DO NOT MODIFY. + +.. code:: c + + typedef struct sce_rsa2048_private_wrapped_key + { + uint32_t type; ///< key type + struct + { + uint32_t key_management_info1[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information + uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 2048-bit private key n (plaintext) + uint32_t key_management_info2[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information + } value; + } sce_rsa2048_private_wrapped_key_t; + +------------------------------------------------------- +sce_rsa4096_public_wrapped_key_t +------------------------------------------------------- +RSA 4096bit public wrapped key data structure. DO NOT MODIFY. + +.. code:: c + + typedef struct sce_rsa4096_public_wrapped_key + { + uint32_t type; ///< Key type + struct + { + uint32_t key_management_info1[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information + uint8_t key_n[HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 4096-bit public key n (plaintext) + uint8_t key_e[HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE]; ///< RSA 4096-bit public key e (plaintext) + uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; ///< dummy + uint32_t key_management_info2[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information + } value; + } sce_rsa4096_public_wrapped_key_t; + +------------------------------------------------------- +sce_rsa1024_wrapped_pair_key_t +------------------------------------------------------- +RSA 1024bit wrapped key pair structure. DO NOT MODIFY. + +.. code:: c + + typedef struct sce_rsa1024_wrapped_pair_key + { + sce_rsa1024_private_wrapped_key_t priv_key; ///< RSA 1024-bit private wrapped key + sce_rsa1024_public_wrapped_key_t pub_key; ///< RSA 1024-bit public wrapped key + } sce_rsa1024_wrapped_pair_key_t; + +------------------------------------------------------- +sce_rsa2048_wrapped_pair_key_t +------------------------------------------------------- +RSA 2048bit wrapped key pair structure. DO NOT MODIFY. + +.. code:: c + + typedef struct sce_rsa2048_wrapped_pair_key + { + sce_rsa2048_private_wrapped_key_t priv_key; ///< RSA 2048-bit private wrapped key + sce_rsa2048_public_wrapped_key_t pub_key; ///< RSA 2048-bit public wrapped key + } sce_rsa2048_wrapped_pair_key_t; + +------------------------------------------------------- +sce_ecc_private_wrapped_key_t +------------------------------------------------------- +ECC P-192/224/256/512 private wrapped key data structure. + +.. code:: c + + typedef struct sce_ecc_private_wrapped_key + { + uint32_t type; ///< key type + uint32_t value[HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE]; ///< wrapped key value + } sce_ecc_private_wrapped_key_t; + + +------------------------------------------------------- +sce_ecc_public_wrapped_key_t +------------------------------------------------------- +ECC P-192/224/256/512 public wrapped key data structure. + +.. code:: c + + typedef struct sce_ecc_public_wrapped_key + { + uint32_t type; ///< key type + struct + { + uint32_t key_management_info[HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE]; ///< key management information + uint8_t key_q[HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE]; ///< ECC public key Q (plaintext) + } value; + } sce_ecc_public_wrapped_key_t; + +------------------------------------------------------- +sce_ecc_wrapped_pair_key_t +------------------------------------------------------- +ECC P-192/224/256/512 wrapped key pair structure. + +.. code:: c + + typedef struct sce_ecc_wrapped_pair_key + { + sce_ecc_private_wrapped_key_t priv_key; ///< ECC private wrapped key + sce_ecc_public_wrapped_key_t pub_key; ///< ECC public wrapped key + } sce_ecc_wrapped_pair_key_t; + +------------------------------------------------------- +sce_key_update_key_t +------------------------------------------------------- +Update key ring index data structure. DO NOT MODIFY. + +.. code:: c + + typedef struct sce_key_update_key + { + uint32_t type; ///< key type + uint32_t value[HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE]; ///< wrapped key value + } sce_key_update_key_t; + +------------------------------------------------------- +sce_aes_handle_t +------------------------------------------------------- +The work area for AES. DO NOT MODIFY. + +.. code:: c + + typedef struct sce_aes_handle + { + uint32_t id; ///< serial number of this handle + sce_aes_wrapped_key_t wrapped_key; ///< wrapped key + uint32_t current_input_data_size; ///< text size under encryption / decryption + uint8_t last_1_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE]; ///< text array less than the block long + uint8_t last_2_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE * 2]; ///< reserved + uint8_t current_initial_vector[HW_SCE_AES_CBC_IV_BYTE_SIZE]; ///< current initialization vector used in CBC mode + uint8_t flag_call_init; ///< control flag of calling function + } sce_aes_handle_t; + +------------------------------------------------------- +sce_cmac_handle_t +------------------------------------------------------- +The work area for CMAC. DO NOT MODIFY. + +.. code:: c + + typedef struct sce_cmac_handle + { + uint32_t id; ///< serial number of this handle + sce_aes_wrapped_key_t wrapped_key; ///< wrapped key + uint8_t cmac_buffer[HW_SCE_AES_BLOCK_BYTE_SIZE]; ///< message array less than the block long + uint32_t all_received_length; ///< entire length of message + uint32_t buffering_length; ///< message array length less than the block long + uint8_t flag_call_init; ///< control flag of calling function + } sce_cmac_handle_t; + +------------------------------------------------------- +sce_sha_md5_handle_t +------------------------------------------------------- +The work area for SHA. DO NOT MODIFY. + +.. code:: c + + typedef struct sce_sha_md5_handle + { + uint32_t id; ///< serial number of this handle + uint8_t sha_buffer[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE * 4]; ///< message array length less than the block long + uint32_t all_received_length; ///< entire length of message + uint32_t buffering_length; ///< message array length less than the block long + + /* SHA1(20byte), SHA256(32byte), MD5(16byte) are supported */ + uint8_t current_hash[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE]; ///< last hash value + uint8_t flag_call_init; ///< control flag of calling function + } sce_sha_md5_handle_t; + +------------------------------------------------------- +sce_ctrl_t +------------------------------------------------------- + +.. code:: c + + typedef void sce_ctrl_t; + +------------------------------------------------------- +sce_cfg_t +------------------------------------------------------- + +.. code:: c + + typedef void sce_cfg_t; + + +------------------------------------------------------- +sce_api_t +------------------------------------------------------- +Functions implemented in sce driver. + +.. code:: c + + typedef struct st_sce_api + { + + fsp_err_t (* open)(sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg); + + fsp_err_t (* close)(sce_ctrl_t * const p_ctrl); + + fsp_err_t (* softwareReset)(void); + + fsp_err_t (* randomNumberGenerate)(uint32_t * random); + + fsp_err_t (* AES128_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES256_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES128_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES256_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES128ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES128ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + fsp_err_t (* AES128ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + fsp_err_t (* AES128ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES128ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + fsp_err_t (* AES128ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + fsp_err_t (* AES256ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES256ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + fsp_err_t (* AES256ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + fsp_err_t (* AES256ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES256ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + fsp_err_t (* AES256ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + fsp_err_t (* AES128CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES128CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + fsp_err_t (* AES128CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + fsp_err_t (* AES128CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES128CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + fsp_err_t (* AES128CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + fsp_err_t (* AES256CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES256CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + fsp_err_t (* AES256CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + fsp_err_t (* AES256CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES256CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + fsp_err_t (* AES256CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + fsp_err_t (* AES128CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES128CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + fsp_err_t (* AES128CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + fsp_err_t (* AES128CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES128CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + fsp_err_t (* AES128CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + fsp_err_t (* AES256CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES256CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + fsp_err_t (* AES256CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + fsp_err_t (* AES256CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES256CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + fsp_err_t (* AES256CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + fsp_err_t (* AES128CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES128CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + fsp_err_t (* AES128CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); + + fsp_err_t (* AES128CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES128CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + fsp_err_t (* AES128CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); + + fsp_err_t (* AES256CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES256CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + fsp_err_t (* AES256CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); + + fsp_err_t (* AES256CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES256CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + fsp_err_t (* AES256CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); + + fsp_err_t (* SHA256_Init)(sce_sha_md5_handle_t * handle); + + fsp_err_t (* SHA256_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); + + fsp_err_t (* SHA256_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); + + fsp_err_t (* SHA224_Init)(sce_sha_md5_handle_t * handle); + + fsp_err_t (* SHA224_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); + + fsp_err_t (* SHA224_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); + + fsp_err_t (* RSA1024_WrappedKeyPairGenerate)(sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key); + + fsp_err_t (* RSA2048_WrappedKeyPairGenerate)(sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key); + + fsp_err_t (* RSA1024_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSA1024_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSA2048_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSA2048_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSA4096_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa4096_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSASSA_PKCS1024_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, sce_rsa_byte_data_t * signature, + sce_rsa1024_private_wrapped_key_t * wrapped_key, uint8_t hash_type); + + fsp_err_t (* RSASSA_PKCS2048_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, sce_rsa_byte_data_t * signature, + sce_rsa2048_private_wrapped_key_t * wrapped_key, uint8_t hash_type); + + fsp_err_t (* RSASSA_PKCS1024_SignatureVerify)(sce_rsa_byte_data_t * signature, sce_rsa_byte_data_t * message_hash, + sce_rsa1024_public_wrapped_key_t * wrapped_key, uint8_t hash_type); + + fsp_err_t (* RSASSA_PKCS2048_SignatureVerify)(sce_rsa_byte_data_t * signature, sce_rsa_byte_data_t * message_hash, + sce_rsa2048_public_wrapped_key_t * wrapped_key, uint8_t hash_type); + + fsp_err_t (* RSASSA_PKCS4096_SignatureVerify)(sce_rsa_byte_data_t * signature, sce_rsa_byte_data_t * message_hash, + sce_rsa4096_public_wrapped_key_t * wrapped_key, uint8_t hash_type); + + fsp_err_t (* RSAES_PKCS1024_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, + sce_rsa1024_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSAES_PKCS2048_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, + sce_rsa2048_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSAES_PKCS4096_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, + sce_rsa4096_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSAES_PKCS1024_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, + sce_rsa1024_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSAES_PKCS2048_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, + sce_rsa2048_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_secp192r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + fsp_err_t (* ECC_secp224r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + fsp_err_t (* ECC_secp256r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + fsp_err_t (* ECC_secp192r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_secp224r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_secp256r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_secp192r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_secp224r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_secp256r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_secp192r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_secp224r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_secp256r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_secp192r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_secp224r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_secp256r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + } sce_api_t; + +------------------------------------------------------- +sce_instance_t +------------------------------------------------------- +This structure encompasses everything that is needed to use an instance of this interface. + +.. code:: c + + typedef struct st_sce_instance + { + sce_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance + sce_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance + sce_api_t const * p_api; ///< Pointer to the API structure for this instance + } sce_instance_t; + +************************************************************************* +2.5.Global Variables +************************************************************************* +There are no global variables that can be used by users. + + +************************************************************************* +2.6.Function Specifications +************************************************************************* + +------------------------------------------------------- +2.6.1.R_SCE_Open +------------------------------------------------------- ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_Open ( sce_ctrl_t const \*\p_ctrl, sce_cfg_t const \*\const p_cfg ) | ++--------------+---------------------------------------------------------------------------------+ +| Description | Enables use of SCE functionality. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |p_ctrl |Pointer to control structure. | +| +---------+--------------------------+--------------------------------------------+ +| |IN |p_cfg |Pointer to pin configuration structure. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |The error-detection self-test failed to | +| | ||br| terminate normally. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RETRY |Indicates that an entropy evaluation failure| +| | ||br| occurred. Run the function again. | ++--------------+------------------------------------+--------------------------------------------+ +| Note | | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.2.R_SCE_Close +------------------------------------------------------- ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_Close ( sce_ctrl_t \*\const p_ctrl) | ++--------------+---------------------------------------------------------------------------------+ +| Description | Stops supply of power to the SCE. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |p_ctrl |Pointer to control structure. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | ++--------------+------------------------------------+--------------------------------------------+ +| Note | | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.3.R_SCE_SoftwareReset +------------------------------------------------------- ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_SoftwareReset ( void ) | ++--------------+---------------------------------------------------------------------------------+ +| Description | Software reset to SCE. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |none |none |none | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | ++--------------+------------------------------------+--------------------------------------------+ +| Note | | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.4.R_SCE_AES128_WrappedKeyGenerate +------------------------------------------------------- ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128_WrappedKeyGenerate ( sce_aes_wrapped_key_t \*\ wrapped_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API outputs 128-bit AES wrapped key from a random number. | +| ||br| This API generates a wrapped key from a random number in the SCE. | +| ||br| Accordingly, user key input is unnecessary. | +| ||br| By encrypting data using the wrapped key is output by this API, | +| ||br| dead copying of data can be prevented. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_key |128-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | ++--------------+------------------------------------+--------------------------------------------+ +| Note | | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.5.R_SCE_AES256_WrappedKeyGenerate +------------------------------------------------------- ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256_WrappedKeyGenerate ( sce_aes_wrapped_key_t \*\ wrapped_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API outputs 256-bit AES wrapped key from a random number. | +| ||br| This API generates a wrapped key from a random number in the SCE. | +| ||br| Accordingly, user key input is unnecessary. | +| ||br| By encrypting data using the wrapped key is output by this API, | +| ||br| dead copying of data can be prevented. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_key |256-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | ++--------------+------------------------------------+--------------------------------------------+ +| Note | | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.6.R_SCE_RSA1024_WrappedKeyPairGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t | +|R_SCE_RSA1024_WrappedKeyPairGenerate ( sce_rsa1024_wrapped_pair_key_t \*\wrapped_pair_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API outputs a wrapped key pair | +| ||br| for a 1024-bit RSA public key and private key pair.These keys are generated | +| ||br| from a random value produced internally by the SCE. | +| ||br| Consequently, there is no need to input a user key. | +| ||br| Dead copying of data can be prevented by encrypting the data using the | +| ||br| wrapped key output by this API. A public wrapped key is generated by | +| ||br| wrapped_pair_key->pub_key, and a private wrapped key is generated by | +| ||br| wrapped_pair_key->priv_key. | +| ||br| As the public key exponent, only 0x00010001 is generated. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_pair_key |User key index for RSA 1024-bit public key | +| | | ||br| and private key pair | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| Key generation failed. | ++--------------+------------------------------------+--------------------------------------------+ +| Note | | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.7.R_SCE_RSA2048_WrappedKeyPairGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t | +|R_SCE_RSA2048_WrappedKeyPairGenerate ( sce_rsa2048_wrapped_pair_key_t \*\wrapped_pair_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API outputs a wrapped key pair | +| ||br| for a 2048-bit RSA public key and private key pair.These keys are generated | +| ||br| from a random value produced internally by the SCE. | +| ||br| Consequently, there is no need to input a user key. | +| ||br| Dead copying of data can be prevented by encrypting the data using the | +| ||br| wrapped key output by this API. A public wrapped key is generated by | +| ||br| wrapped_pair_key->pub_key, and a private wrapped key is generated by | +| ||br| wrapped_pair_key->priv_key. | +| ||br| As the public key exponent, only 0x00010001 is generated. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_pair_key |User key index for RSA 2048-bit public key | +| | | ||br| and private key pair | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| Key generation failed. | ++--------------+------------------------------------+--------------------------------------------+ +| Note | | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.8.R_SCE_ECC_secp192r1_WrappedKeyPairGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t | +|R_SCE_ECC_secp192r1_WrappedKeyPairGenerate ( sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This is an API for outputting a wrapped key pair for secp192r1 public key | +| ||br| and private key pair. These keys are generated from a random number value | +| ||br| internally within the SCE. There is therefore no need to input user keys. | +| ||br| Consequently, there is no need to input a user key. | +| ||br| It is possible to prevent dead copying of data by using | +| ||br| wrapped key output by this API. A public wrapped key is generated by | +| ||br| the wrapped key output by this API to encrypt the data. | +| ||br| The public key index is generated in wrapped_pair_key->pub_key, | +| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_pair_key |Wrapped pair key forsecp192r1 public key | +| | | ||br| and private key pair | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| Key generation failed. | ++--------------+------------------------------------+--------------------------------------------+ +| Note | | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.9.R_SCE_ECC_secp224r1_WrappedKeyPairGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t | +| R_SCE_ECC_secp224r1_WrappedKeyPairGenerate ( sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This is an API for outputting a wrapped key pair for secp224r1 public key | +| ||br| and private key pair. These keys are generated from a random number value | +| ||br| internally within the SCE. There is therefore no need to input user keys. | +| ||br| Consequently, there is no need to input a user key. | +| ||br| It is possible to prevent dead copying of data by using | +| ||br| wrapped key output by this API. A public wrapped key is generated by | +| ||br| the wrapped key output by this API to encrypt the data. | +| ||br| The public key index is generated in wrapped_pair_key->pub_key, | +| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_pair_key |Wrapped pair key forsecp224r1 public key | +| | | ||br| and private key pair | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| Key generation failed. | ++--------------+------------------------------------+--------------------------------------------+ +| Note | | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.10.R_SCE_ECC_secp256r1_WrappedKeyPairGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t | +|R_SCE_ECC_secp256r1_WrappedKeyPairGenerate ( sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This is an API for outputting a wrapped key pair for secp256r1 public key | +| ||br| and private key pair. These keys are generated from a random number value | +| ||br| internally within the SCE. There is therefore no need to input user keys. | +| ||br| Consequently, there is no need to input a user key. | +| ||br| It is possible to prevent dead copying of data by using | +| ||br| wrapped key output by this API. A public wrapped key is generated by | +| ||br| the wrapped key output by this API to encrypt the data. | +| ||br| The public key index is generated in wrapped_pair_key->pub_key, | +| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_pair_key |Wrapped pair key forsecp256r1 public key | +| | | ||br| and private key pair | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| Key generation failed. | ++--------------+------------------------------------+--------------------------------------------+ +| Note | | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.11.R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t | +|R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key)| ++--------------+---------------------------------------------------------------------------------+ +| Description |This is an API for outputting a wrapped key pair for BrainpoolP512r1 public key | +| ||br| and private key pair. These keys are generated from a random number value | +| ||br| internally within the SCE. There is therefore no need to input user keys. | +| ||br| Consequently, there is no need to input a user key. | +| ||br| It is possible to prevent dead copying of data by using | +| ||br| wrapped key output by this API. A public wrapped key is generated by | +| ||br| the wrapped key output by this API to encrypt the data. | +| ||br| The public key index is generated in wrapped_pair_key->pub_key, | +| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_pair_key |Wrapped pair key for BrainpoolP512r1 | +| | | ||br| key pair | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| Key generation failed. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.12.R_SCE_RandomNumberGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RandomNumberGenerate ( uint32_t \*\random) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API can generate 4 words random number. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |random |Stores 4words (16 bytes) random data. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.13.R_SCE_AES128_EncryptedKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128_EncryptedKeyWrap ( uint8_t \*\ initial_vector, uint8_t \*\ encrypted_key,| +||br| sce_key_update_key_t \*\ key_update_key, sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 128-bit AES key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encryptedand MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |128-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.14.R_SCE_AES256_EncryptedKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256_EncryptedKeyWrap ( uint8_t \*\ initial_vector, uint8_t \*\ encrypted_key,| +||br| sce_key_update_key_t \*\ key_update_key, sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 256-bit AES key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |256-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.15.R_SCE_RSA1024_EncryptedPublicKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrap ( uint8_t \*\initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_rsa1024_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 1024-bit RSA public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |1024-bit RSA public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.16.R_SCE_RSA1024_EncryptedPrivateKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_rsa1024_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 1024-bit RSA private key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |1024-bit RSA private wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.17.R_SCE_RSA2048_EncryptedPublicKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_rsa2048_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 2048-bit RSA public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |2048-bit RSA public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.18.R_SCE_RSA2048_EncryptedPrivateKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_rsa2048_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 2048-bit RSA private key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |2048-bit RSA private wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.19.R_SCE_RSA4096_EncryptedPublicKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_rsa4096_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 4096-bit RSA public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |4096-bit RSA public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.20.R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps secp192r1 public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |secp192r1 public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.21.R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps secp224r1 public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |secp224r1 public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.22.R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps secp256r1 public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |secp256r1 public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processingroutine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.23.R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps BrainpoolP512r1 public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |BrainpoolP512r1 public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.24.R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps secp192r1 private key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |secp192r1 private wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.25.R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps secp224r1 private key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |secp224r1 private wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.26.R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps secp256r1 private key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |secp256r1 private wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processingroutine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +---------------------------------------------------------- +2.6.27.R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap +---------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps BrainpoolP512r1 private key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |BrainpoolP512r1 private wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +---------------------------------------------------------- +2.6.27.R_SCE_SelfCheck2Private +---------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_SelfCheck2Private (void) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Self check No2. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |none |none |none | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RETRY |self-test2 fail | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|resource conflict | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For information on how to create and update keys, refer to Security Manual | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.28.R_SCE_AES128ECB_EncryptInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128ECB_EncryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128ECB_EncryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128ECB_EncryptUpdate() function and | +| ||br| R_SCE_AES128ECB_EncryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_SUCCESS |Normal termination | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.29.R_SCE_AES128ECB_EncryptUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128ECB_EncryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128ECB_EncryptUpdate function encrypts the second argument, plain, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, cipher. After plaintext input is completed, | +| ||br| call R_SCE_AES128ECB_EncryptFinal(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.30.R_SCE_AES128ECB_EncryptFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128ECB_EncryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES128ECB_EncryptFinal() function writes the calculation result | +| ||br| to the second argument, cipher, and writes the length of the | +| ||br| calculation result to the third argument, cipher_length. | +| ||br| The original intent was for a portion of the encryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to cipher, | +| ||br| and 0 is always written to cipher_length. The arguments cipher | +| ||br| and cipher_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.31.R_SCE_AES128ECB_DecryptInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128ECB_DecryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128ECB_DecryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128ECB_DecryptUpdate() function and | +| ||br| R_SCE_AES128ECB_DecryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_SUCCESS |Normal termination | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.32.R_SCE_AES128ECB_DecryptUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128ECB_DecryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128ECB_DecryptUpdate function encrypts the second argument, cipher, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, plain. After ciphertext input is completed, | +| ||br| call R_SCE_AES128ECB_DecryptFinal. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.33.R_SCE_AES128ECB_DecryptFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128ECB_DecryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES128ECB_DecryptFinal() function writes the calculation result | +| ||br| to the second argument, plain, and writes the length of the | +| ||br| calculation result to the third argument, plain_length. | +| ||br| The original intent was for a portion of the Decryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to plain, | +| ||br| and 0 is always written to plain_length. The arguments plain | +| ||br| and plain_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.34.R_SCE_AES256ECB_EncryptInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256ECB_EncryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256ECB_EncryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256ECB_EncryptUpdate() function and | +| ||br| R_SCE_AES256ECB_EncryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.35.R_SCE_AES256ECB_EncryptUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256ECB_EncryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256ECB_EncryptUpdate function encrypts the second argument, plain, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, cipher. After plaintext input is completed, | +| ||br| call R_SCE_AES256ECB_EncryptFinal(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.36.R_SCE_AES256ECB_EncryptFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256ECB_EncryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES256ECB_EncryptFinal() function writes the calculation result | +| ||br| to the second argument, cipher, and writes the length of the | +| ||br| calculation result to the third argument, cipher_length. | +| ||br| The original intent was for a portion of the encryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to cipher, | +| ||br| and 0 is always written to cipher_length. The arguments cipher | +| ||br| and cipher_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.37.R_SCE_AES256ECB_DecryptInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256ECB_DecryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256ECB_DecryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256ECB_DecryptUpdate() function and | +| ||br| R_SCE_AES256ECB_DecryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.38.R_SCE_AES256ECB_DecryptUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256ECB_DecryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256ECB_DecryptUpdate function encrypts the second argument, cipher, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, plain. After ciphertext input is completed, | +| ||br| call R_SCE_AES256ECB_DecryptFinal. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.39.R_SCE_AES256ECB_DecryptFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256ECB_DecryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES256ECB_DecryptFinal() function writes the calculation result | +| ||br| to the second argument, plain, and writes the length of the | +| ||br| calculation result to the third argument, plain_length. | +| ||br| The original intent was for a portion of the Decryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to plain, | +| ||br| and 0 is always written to plain_length. The arguments plain | +| ||br| and plain_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + + +------------------------------------------------------- +2.6.40.R_SCE_AES128CBC_EncryptInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CBC_EncryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CBC_EncryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128CBC_EncryptUpdate() function and | +| ||br| R_SCE_AES128CBC_EncryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.41.R_SCE_AES128CBC_EncryptUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CBC_EncryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CBC_EncryptUpdate function encrypts the second argument, plain, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, cipher. After plaintext input is completed, | +| ||br| call R_SCE_AES128CBC_EncryptFinal(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.42.R_SCE_AES128CBC_EncryptFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CBC_EncryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES128CBC_EncryptFinal() function writes the calculation result | +| ||br| to the second argument, cipher, and writes the length of the | +| ||br| calculation result to the third argument, cipher_length. | +| ||br| The original intent was for a portion of the encryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to cipher, | +| ||br| and 0 is always written to cipher_length. The arguments cipher | +| ||br| and cipher_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.43.R_SCE_AES128CBC_DecryptInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CBC_DecryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CBC_DecryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128CBC_DecryptUpdate() function and | +| ||br| R_SCE_AES128CBC_DecryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.44.R_SCE_AES128CBC_DecryptUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CBC_DecryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CBC_DecryptUpdate function encrypts the second argument, cipher, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, plain. After ciphertext input is completed, | +| ||br| call R_SCE_AES128CBC_DecryptFinal. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.45.R_SCE_AES128CBC_DecryptFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CBC_DecryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES128CBC_DecryptFinal() function writes the calculation result | +| ||br| to the second argument, plain, and writes the length of the | +| ||br| calculation result to the third argument, plain_length. | +| ||br| The original intent was for a portion of the Decryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to plain, | +| ||br| and 0 is always written to plain_length. The arguments plain | +| ||br| and plain_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.46.R_SCE_AES256CBC_EncryptInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CBC_EncryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CBC_EncryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256CBC_EncryptUpdate() function and | +| ||br| R_SCE_AES256CBC_EncryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.47.R_SCE_AES256CBC_EncryptUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CBC_EncryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CBC_EncryptUpdate function encrypts the second argument, plain, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, cipher. After plaintext input is completed, | +| ||br| call R_SCE_AES256CBC_EncryptFinal(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.48.R_SCE_AES256CBC_EncryptFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CBC_EncryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES256CBC_EncryptFinal() function writes the calculation result | +| ||br| to the second argument, cipher, and writes the length of the | +| ||br| calculation result to the third argument, cipher_length. | +| ||br| The original intent was for a portion of the encryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to cipher, | +| ||br| and 0 is always written to cipher_length. The arguments cipher | +| ||br| and cipher_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.49.R_SCE_AES256CBC_DecryptInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CBC_DecryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CBC_DecryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256CBC_DecryptUpdate() function and | +| ||br| R_SCE_AES256CBC_DecryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.50.R_SCE_AES256CBC_DecryptUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CBC_DecryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CBC_DecryptUpdate function encrypts the second argument, cipher, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, plain. After ciphertext input is completed, | +| ||br| call R_SCE_AES256CBC_DecryptFinal. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.51.R_SCE_AES256CBC_DecryptFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CBC_DecryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES256CBC_DecryptFinal() function writes the calculation result | +| ||br| to the second argument, plain, and writes the length of the | +| ||br| calculation result to the third argument, plain_length. | +| ||br| The original intent was for a portion of the Decryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to plain, | +| ||br| and 0 is always written to plain_length. The arguments plain | +| ||br| and plain_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.52.R_SCE_AES128CTR_EncryptInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CTR_EncryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CTR_EncryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128CTR_EncryptUpdate() function and | +| ||br| R_SCE_AES128CTR_EncryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.53.R_SCE_AES128CTR_EncryptUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CTR_EncryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CTR_EncryptUpdate function encrypts the second argument, plain, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, cipher. After plaintext input is completed, | +| ||br| call R_SCE_AES128CTR_EncryptFinal(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.54.R_SCE_AES128CTR_EncryptFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CTR_EncryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES128CTR_EncryptFinal() function writes the calculation result | +| ||br| to the second argument, cipher, and writes the length of the | +| ||br| calculation result to the third argument, cipher_length. | +| ||br| The original intent was for a portion of the encryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to cipher, | +| ||br| and 0 is always written to cipher_length. The arguments cipher | +| ||br| and cipher_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.55.R_SCE_AES128CTR_DecryptInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CTR_DecryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CTR_DecryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128CTR_DecryptUpdate() function and | +| ||br| R_SCE_AES128CTR_DecryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.56.R_SCE_AES128CTR_DecryptUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CTR_DecryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CTR_DecryptUpdate function encrypts the second argument, cipher, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, plain. After ciphertext input is completed, | +| ||br| call R_SCE_AES128CTR_DecryptFinal. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.57.R_SCE_AES128CTR_DecryptFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CTR_DecryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES128CTR_DecryptFinal() function writes the calculation result | +| ||br| to the second argument, plain, and writes the length of the | +| ||br| calculation result to the third argument, plain_length. | +| ||br| The original intent was for a portion of the Decryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to plain, | +| ||br| and 0 is always written to plain_length. The arguments plain | +| ||br| and plain_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.58.R_SCE_AES256CTR_EncryptInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CTR_EncryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CTR_EncryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256CTR_EncryptUpdate() function and | +| ||br| R_SCE_AES256CTR_EncryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.59.R_SCE_AES256CTR_EncryptUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CTR_EncryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CTR_EncryptUpdate function encrypts the second argument, plain, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, cipher. After plaintext input is completed, | +| ||br| call R_SCE_AES256CTR_EncryptFinal(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.60.R_SCE_AES256CTR_EncryptFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CTR_EncryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES256CTR_EncryptFinal() function writes the calculation result | +| ||br| to the second argument, cipher, and writes the length of the | +| ||br| calculation result to the third argument, cipher_length. | +| ||br| The original intent was for a portion of the encryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to cipher, | +| ||br| and 0 is always written to cipher_length. The arguments cipher | +| ||br| and cipher_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.61.R_SCE_AES256CTR_DecryptInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CTR_DecryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CTR_DecryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256CTR_DecryptUpdate() function and | +| ||br| R_SCE_AES256CTR_DecryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.62.R_SCE_AES256CTR_DecryptUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CTR_DecryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CTR_DecryptUpdate function encrypts the second argument, cipher, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, plain. After ciphertext input is completed, | +| ||br| call R_SCE_AES256CTR_DecryptFinal. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.63.R_SCE_AES256CTR_DecryptFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CTR_DecryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES256CTR_DecryptFinal() function writes the calculation result | +| ||br| to the second argument, plain, and writes the length of the | +| ||br| calculation result to the third argument, plain_length. | +| ||br| The original intent was for a portion of the Decryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to plain, | +| ||br| and 0 is always written to plain_length. The arguments plain | +| ||br| and plain_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.64.R_SCE_AES128CMAC_GenerateInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CMAC_GenerateInit ( sce_cmac_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CMAC_GenerateInit function performs preparations for the | +| ||br| execution of an CMAC calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128CMAC_GenerateUpdate function and | +| ||br| R_SCE_AES128CMAC_GenerateFinal function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.65.R_SCE_AES128CMAC_GenerateUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CMAC_GenerateUpdate ( sce_cmac_handle_t \*\ handle, | +||br| uint8_t \*\ message, uint32_t message_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CMAC_GenerateUpdate() function performs MAC value generation | +| ||br| based on the message specified in the second argument, message, | +| ||br| using the value specified for wrapped_key in R_SCE_AES128CMAC_GenerateInit. | +| ||br| Inside this function, the data that is input by the user is buffered | +| ||br| until the input value of message exceeds 16 bytes. | +| ||br| The length of the message data to input is specified in the third argument, | +| ||br| message_len. For these, input not the total byte count | +| ||br| for message input data, but rather the message data length to input | +| ||br| when the user calls this function. If the input value, message, | +| ||br| is not a multiple of 16 bytes, it will be padded within the function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message |plaintext data area | +| | | ||br| (message_length byte) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_length |message data length | +| | | ||br| (0 or more bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For message, specify a RAM address that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.66.R_SCE_AES128CMAC_GenerateFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CMAC_GenerateFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CMAC_GenerateFinal() function outputs the MAC value in | +| ||br| the MAC data area specified in the second argument, mac, and ends CMAC mode.| ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |mac |MAC data area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Not used. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.67.R_SCE_AES128CMAC_VerifyInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CMAC_VerifyInit ( sce_cmac_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CMAC_VerifyInit function performs preparations for the | +| ||br| execution of an CMAC calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128CMAC_VerifyUpdate function and | +| ||br| R_SCE_AES128CMAC_VerifyFinal function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.68.R_SCE_AES128CMAC_VerifyUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CMAC_VerifyUpdate ( sce_cmac_handle_t \*\ handle, | +||br| uint8_t \*\ message, uint32_t message_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CMAC_VerifyUpdate function performs MAC value generation | +| ||br| based on the message specified in the second argument, message, | +| ||br| using the value specified for wrapped_key in R_SCE_AES128CMAC_VerifyInit. | +| ||br| Inside this function, the data that is input by the user is buffered | +| ||br| until the input value of message exceeds 16 bytes. | +| ||br| The length of the message data to input is specified in the third argument, | +| ||br| message_len. For these, input not the total byte count | +| ||br| for message input data, but rather the message data length to input | +| ||br| when the user calls this function. If the input value, message, | +| ||br| is not a multiple of 16 bytes, it will be padded within the function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message |plaintext data area | +| | | ||br| (message_length byte) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_length |message data length | +| | | ||br| (0 or more bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For message, specify a RAM address that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.69.R_SCE_AES128CMAC_VerifyFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES128CMAC_VerifyFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac, | +||br| uint32_t mac_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CMAC_VerifyFinal() function inputs the MAC value in the MAC | +| ||br| data area specified in the second argument, mac, and verifies the MAC value.| +| ||br| If authentication fails, the return value will be TSIP_ERR_AUTHENTICATION. | +| ||br| If the MAC value is less than 16 bytes, | +| ||br| it will be padded with zeros inside the function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |mac |MAC data area (mac_length byte) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |mac_length |MAC data length (2 to 16 bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.70.R_SCE_AES256CMAC_GenerateInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CMAC_GenerateInit ( sce_cmac_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CMAC_GenerateInit function performs preparations for the | +| ||br| execution of an CMAC calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256CMAC_GenerateUpdate function and | +| ||br| R_SCE_AES256CMAC_GenerateFinal function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.71.R_SCE_AES256CMAC_GenerateUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CMAC_GenerateUpdate ( sce_cmac_handle_t \*\ handle, | +||br| uint8_t \*\ message, uint32_t message_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CMAC_GenerateUpdate() function performs MAC value generation | +| ||br| based on the message specified in the second argument, message, | +| ||br| using the value specified for wrapped_key in R_SCE_AES256CMAC_GenerateInit. | +| ||br| Inside this function, the data that is input by the user is buffered | +| ||br| until the input value of message exceeds 16 bytes. | +| ||br| The length of the message data to input is specified in the third argument, | +| ||br| message_len. For these, input not the total byte count | +| ||br| for message input data, but rather the message data length to input | +| ||br| when the user calls this function. If the input value, message, | +| ||br| is not a multiple of 16 bytes, it will be padded within the function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message |plaintext data area | +| | | ||br| (message_length byte) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_length |message data length | +| | | ||br| (0 or more bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For message, specify a RAM address that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.72.R_SCE_AES256CMAC_GenerateFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CMAC_GenerateFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CMAC_GenerateFinal() function outputs the MAC value in | +| ||br| the MAC data area specified in the second argument, mac, and ends CMAC mode.| ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |mac |MAC data area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Not used. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.73.R_SCE_AES256CMAC_VerifyInit +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CMAC_VerifyInit ( sce_cmac_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CMAC_VerifyInit function performs preparations for the | +| ||br| execution of an CMAC calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256CMAC_VerifyUpdate function and | +| ||br| R_SCE_AES256CMAC_VerifyFinal function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.74.R_SCE_AES256CMAC_VerifyUpdate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CMAC_VerifyUpdate ( sce_cmac_handle_t \*\ handle, | +||br| uint8_t \*\ message, uint32_t message_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CMAC_VerifyUpdate function performs MAC value generation | +| ||br| based on the message specified in the second argument, message, | +| ||br| using the value specified for wrapped_key in R_SCE_AES256CMAC_VerifyInit. | +| ||br| Inside this function, the data that is input by the user is buffered | +| ||br| until the input value of message exceeds 16 bytes. | +| ||br| The length of the message data to input is specified in the third argument, | +| ||br| message_len. For these, input not the total byte count | +| ||br| for message input data, but rather the message data length to input | +| ||br| when the user calls this function. If the input value, message, | +| ||br| is not a multiple of 16 bytes, it will be padded within the function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message |plaintext data area | +| | | ||br| (message_length byte) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_length |message data length | +| | | ||br| (0 or more bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |For message, specify a RAM address that are multiples of 4. | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.75.R_SCE_AES256CMAC_VerifyFinal +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_AES256CMAC_VerifyFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac, | +||br| uint32_t mac_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CMAC_VerifyFinal() function inputs the MAC value in the MAC | +| ||br| data area specified in the second argument, mac, and verifies the MAC value.| +| ||br| If authentication fails, the return value will be TSIP_ERR_AUTHENTICATION. | +| ||br| If the MAC value is less than 16 bytes, | +| ||br| it will be padded with zeros inside the function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |mac |MAC data area (mac_length byte) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |mac_length |MAC data length (2 to 16 bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.76.R_SCE_SHA256_Init +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_SHA256_Init ( sce_sha_md5_handle_t \*\ handle) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_SHA256_Init() function performs preparations for the execution | +| ||br| of an SHA-256 hash calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_SHA256_Update() function | +| ||br| and R_SCE_SHA256_Final() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |SHA handler (work area) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.77.R_SCE_SHA256_Update +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_SHA256_Update ( sce_sha_md5_handle_t \*\ handle, | +||br| uint8_t \*\ message, uint32_t message_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_SHA256_Update() function calculates a hash value based on | +| ||br| the second argument, message, and the third argument, message_length, | +| ||br| and writes the ongoing status to the first argument, handle. | +| ||br| After message input is completed, call R_SCE_SHA256_Final(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |SHA handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message |message data area | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_length |message data length | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.78.R_SCE_SHA256_Final +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_SHA256_Final ( sce_sha_md5_handle_t \*\ handle, | +||br| uint8_t \*\ digest, uint32_t \*\ digest_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, the R_SCE_SHA256_Final | +| ||br| function writes the calculation result to the second argument, digest, | +| ||br| and writes the length of the calculation result | +| ||br| to the third argument, digest_length. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |SHA handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |digest |hash data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |digest_length |hash data length (32bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.79.R_SCE_SHA224_Init +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_SHA224_Init ( sce_sha_md5_handle_t \*\ handle) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_SHA224_Init() function performs preparations for the execution | +| ||br| of an SHA-224 hash calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_SHA224_Update() function | +| ||br| and R_SCE_SHA224_Final() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |SHA handler (work area) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.80.R_SCE_SHA224_Update +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_SHA224_Update ( sce_sha_md5_handle_t \*\ handle, | +||br| uint8_t \*\ message, uint32_t message_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_SHA224_Update() function calculates a hash value based on | +| ||br| the second argument, message, and the third argument, message_length, | +| ||br| and writes the ongoing status to the first argument, handle. | +| ||br| After message input is completed, call R_SCE_SHA224_Final(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |SHA handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message |message data area | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_length |message data length | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.81.R_SCE_SHA224_Final +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_SHA224_Final ( sce_sha_md5_handle_t \*\ handle, | +||br| uint8_t \*\ digest, uint32_t \*\ digest_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, the R_SCE_SHA224_Final | +| ||br| function writes the calculation result to the second argument, digest, | +| ||br| and writes the length of the calculation result | +| ||br| to the third argument, digest_length. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |SHA handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |digest |hash data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |digest_length |hash data length (32bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.82.R_SCE_RSASSA_PKCS1024_SignatureGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate ( sce_rsa_byte_data_t \*\ message_hash, | +||br| sce_rsa_byte_data_t \*\ signature, sce_rsa1024_private_wrapped_key_t \*\ wrapped_key, | +||br| uint8_t hash_type ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSASSA_PKCS1024_SignatureGenerate function generates, in accordance | +| ||br| with RSASSA-PKCS1-V1_5, a signature from the message text or hash value | +| ||br| that is input in the first argument, message_hash, using the | +| ||br| private wrapped key input to the third argument, wrapped_key, | +| ||br| and writes the signature text to the second argument, signature. | +| ||br| When a message is specified in the first argument, message_hash->data_type, | +| ||br| a hash value is calculated for the message as specified by | +| ||br| the fourth argument, hash_type. When specifying a hash value, | +| ||br| a hash value calculated with a hash algorithm as specified by | +| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |signature |Signature text storage | +| | | ||br| destination information | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | - signature->data_length : data length | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 1024-bit RSA private wrapped key.| +| +---------+--------------------------+--------------------------------------------+ +| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.83.R_SCE_RSASSA_PKCS1024_SignatureVerify +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureVerify ( sce_rsa_byte_data_t \*\ signature, | +||br| sce_rsa_byte_data_t \*\ message_hash, sce_rsa1024_public_wrapped_key_t \*\ wrapped_key, | +||br| uint8_t hash_type ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSASSA_PKCS1024_SignatureVerify() function verifies, in accordance | +| ||br| with RSASSA-PKCS1-V1_5, the signature text input to the | +| ||br| the first argument signature, and the message text or hash value input | +| ||br| to the second argument, message_hash, using the public wrapped key input | +| ||br| to the third argument, wrapped_key. When a message is specified | +| ||br| in the second argument, message_hash->data_type, a hash value is calculated | +| ||br| using the public wrapped key input to the third argument, wrapped_key, | +| ||br| and as specified by the fourth argument, hash_type. When specifying | +| ||br| a hash value in the second argument, message_hash->data_type, | +| ||br| a hash value calculated with a hash algorithm as specified | +| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to verify | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | - signature->data_length : Specifies | +| | | | |br| effective data length of the array | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_hash |Message text or hash value to verify | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 1024-bit RSA private wrapped key.| +| +---------+--------------------------+--------------------------------------------+ +| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.84.R_SCE_RSASSA_PKCS2048_SignatureGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate ( sce_rsa_byte_data_t \*\ message_hash, | +||br| sce_rsa_byte_data_t \*\ signature, sce_rsa2048_private_wrapped_key_t \*\ wrapped_key, | +||br| uint8_t hash_type ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSASSA_PKCS2048_SignatureGenerate function generates, in accordance | +| ||br| with RSASSA-PKCS1-V1_5, a signature from the message text or hash value | +| ||br| that is input in the first argument, message_hash, using the | +| ||br| private wrapped key input to the third argument, wrapped_key, | +| ||br| and writes the signature text to the second argument, signature. | +| ||br| When a message is specified in the first argument, message_hash->data_type, | +| ||br| a hash value is calculated for the message as specified by | +| ||br| the fourth argument, hash_type. When specifying a hash value, | +| ||br| a hash value calculated with a hash algorithm as specified by | +| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |signature |Signature text storage | +| | | ||br| destination information | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | - signature->data_length : data length | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 2048-bit RSA private wrapped key.| +| +---------+--------------------------+--------------------------------------------+ +| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.85.R_SCE_RSASSA_PKCS2048_SignatureVerify +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify ( sce_rsa_byte_data_t \*\ signature, | +||br| sce_rsa_byte_data_t \*\ message_hash, sce_rsa2048_public_wrapped_key_t \*\ wrapped_key, | +||br| uint8_t hash_type ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSASSA_PKCS2048_SignatureVerify() function verifies, in accordance | +| ||br| with RSASSA-PKCS1-V1_5, the signature text input to the | +| ||br| the first argument signature, and the message text or hash value input | +| ||br| to the second argument, message_hash, using the public wrapped key input | +| ||br| to the third argument, wrapped_key. When a message is specified | +| ||br| in the second argument, message_hash->data_type, a hash value is calculated | +| ||br| using the public wrapped key input to the third argument, wrapped_key, | +| ||br| and as specified by the fourth argument, hash_type. When specifying | +| ||br| a hash value in the second argument, message_hash->data_type, | +| ||br| a hash value calculated with a hash algorithm as specified | +| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to verify | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | - signature->data_length : Specifies | +| | | | |br| effective data length of the array | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_hash |Message text or hash value to verify | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 2048-bit RSA private wrapped key.| +| +---------+--------------------------+--------------------------------------------+ +| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.86.R_SCE_RSASSA_PKCS4096_SignatureVerify +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSASSA_PKCS4096_SignatureVerify ( sce_rsa_byte_data_t \*\ signature, | +||br| sce_rsa_byte_data_t \*\ message_hash, sce_rsa4096_public_wrapped_key_t \*\ wrapped_key, | +||br| uint8_t hash_type ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSASSA_PKCS4096_SignatureVerify() function verifies, in accordance | +| ||br| with RSASSA-PKCS1-V1_5, the signature text input to the | +| ||br| the first argument signature, and the message text or hash value input | +| ||br| to the second argument, message_hash, using the public wrapped key input | +| ||br| to the third argument, wrapped_key. When a message is specified | +| ||br| in the second argument, message_hash->data_type, a hash value is calculated | +| ||br| using the public wrapped key input to the third argument, wrapped_key, | +| ||br| and as specified by the fourth argument, hash_type. When specifying | +| ||br| a hash value in the second argument, message_hash->data_type, | +| ||br| a hash value calculated with a hash algorithm as specified | +| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to verify | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | - signature->data_length : Specifies | +| | | | |br| effective data length of the array | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_hash |Message text or hash value to verify | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 4096-bit RSA private wrapped key.| +| +---------+--------------------------+--------------------------------------------+ +| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.87.R_SCE_RSAES_PKCS1024_Encrypt +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSAES_PKCS1024_Encrypt ( sce_rsa_byte_data_t \*\ plain, | +||br| sce_rsa_byte_data_t \*\ cipher, sce_rsa1024_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSAES_PKCS1024_Encrypt() function RSA-encrypts the plaintext | +| ||br| input to the first argument, plain, according to RSAES-PKCS1-V1_5. | +| ||br| It writes the encryption result to the second argument, cipher. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |plain |plaintext | +| | | | | +| | | | - plain->pdata : Specifies pointer to | +| | | | |br| array containing plaintext. | +| | | | - plain->data_length : Specifies valid data| +| | | | |br| length of plaintext array. | +| | | | |br| data size <= public key n size - 11 | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext | +| | | | | +| | | | - cipher->pdata : Specifies pointer to | +| | | | |br| array containing ciphertext. | +| | | | - cipher->data_length : Inputs ciphertext | +| | | | |br| buffer size. Outputs valid data | +| | | | |br| length after encryption | +| | | | |br| (public key n size). | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 1024-bit RSA public wrapped key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.88.R_SCE_RSAES_PKCS1024_Decrypt +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt ( sce_rsa_byte_data_t \*\ cipher, | +||br| sce_rsa_byte_data_t \*\ plain, sce_rsa1024_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSAES_PKCS1024_Decrypt() function RSA-decrypts the ciphertext | +| ||br| input to the first argument, cipher, according to RSAES-PKCS1-V1_5. | +| ||br| It writes the encryption result to the second argument, plain. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |cipher |ciphertext | +| | | | | +| | | | - cipher->pdata : Specifies pointer to | +| | | | |br| array containing ciphertext. | +| | | | - cipher->data_length : Inputs ciphertext | +| | | | |br| buffer size. Outputs valid data | +| | | | |br| length after encryption | +| | | | |br| (public key n size). | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext | +| | | | | +| | | | - plain->pdata : Specifies pointer to | +| | | | |br| array containing plaintext. | +| | | | - plain->data_length : Inputs plaintext | +| | | | |br| buffer size. The following size | +| | | | |br| is required. | +| | | | |br| Plaintext buffer size >= | +| | | | |br| publickey n size - 11. | +| | | | |br| Outputs valid data length after | +| | | | |br| decryption (publickey n size). | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 1024-bit RSA private wrapped key.| ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.89.R_SCE_RSAES_PKCS2048_Encrypt +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSAES_PKCS2048_Encrypt ( sce_rsa_byte_data_t \*\ plain, | +||br| sce_rsa_byte_data_t \*\ cipher, sce_rsa2048_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSAES_PKCS2048_Encrypt() function RSA-encrypts the plaintext | +| ||br| input to the first argument, plain, according to RSAES-PKCS1-V1_5. | +| ||br| It writes the encryption result to the second argument, cipher. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |plain |plaintext | +| | | | | +| | | | - plain->pdata : Specifies pointer to | +| | | | |br| array containing plaintext. | +| | | | - plain->data_length : Specifies valid data| +| | | | |br| length of plaintext array. | +| | | | |br| data size <= public key n size - 11 | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext | +| | | | | +| | | | - cipher->pdata : Specifies pointer to | +| | | | |br| array containing ciphertext. | +| | | | - cipher->data_length : Inputs ciphertext | +| | | | |br| buffer size. Outputs valid data | +| | | | |br| length after encryption | +| | | | |br| (public key n size). | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 2048-bit RSA public wrapped key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.90.R_SCE_RSAES_PKCS2048_Decrypt +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSAES_PKCS2048_Decrypt ( sce_rsa_byte_data_t \*\ cipher, | +||br| sce_rsa_byte_data_t \*\ plain, sce_rsa2048_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSAES_PKCS2048_Decrypt() function RSA-decrypts the ciphertext | +| ||br| input to the first argument, cipher, according to RSAES-PKCS1-V1_5. | +| ||br| It writes the encryption result to the second argument, plain. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |cipher |ciphertext | +| | | | | +| | | | - cipher->pdata : Specifies pointer to | +| | | | |br| array containing ciphertext. | +| | | | - cipher->data_length : Inputs ciphertext | +| | | | |br| buffer size. Outputs valid data | +| | | | |br| length after encryption | +| | | | |br| (public key n size). | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext | +| | | | | +| | | | - plain->pdata : Specifies pointer to | +| | | | |br| array containing plaintext. | +| | | | - plain->data_length : Inputs plaintext | +| | | | |br| buffer size. The following size | +| | | | |br| is required. | +| | | | |br| Plaintext buffer size >= | +| | | | |br| publickey n size - 11. | +| | | | |br| Outputs valid data length after | +| | | | |br| decryption (publickey n size). | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 2048-bit RSA private wrapped key.| ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.91.R_SCE_RSAES_PKCS4096_Encrypt +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt ( sce_rsa_byte_data_t \*\ plain, | +||br| sce_rsa_byte_data_t \*\ cipher, sce_rsa4096_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSAES_PKCS4096_Encrypt() function RSA-encrypts the plaintext | +| ||br| input to the first argument, plain, according to RSAES-PKCS1-V1_5. | +| ||br| It writes the encryption result to the second argument, cipher. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |plain |plaintext | +| | | | | +| | | | - plain->pdata : Specifies pointer to | +| | | | |br| array containing plaintext. | +| | | | - plain->data_length : Specifies valid data| +| | | | |br| length of plaintext array. | +| | | | |br| data size <= public key n size - 11 | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext | +| | | | | +| | | | - cipher->pdata : Specifies pointer to | +| | | | |br| array containing ciphertext. | +| | | | - cipher->data_length : Inputs ciphertext | +| | | | |br| buffer size. Outputs valid data | +| | | | |br| length after encryption | +| | | | |br| (public key n size). | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 4096-bit RSA public wrapped key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.92.R_SCE_ECDSA_secp192r1_SignatureGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate ( sce_ecdsa_byte_data_t \*\ message_hash, | +||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a message is specified in the first argument, message_hash->data_type, | +| ||br| a SHA-256 hash of the message text input as the first argument, | +| ||br| message_hash->pdata, is calculated, and the signature text is written to | +| ||br| the second argument, signature, in accordance with secp192r1 using | +| ||br| the private wrapped key input as the third argument, wrapped_key. | +| ||br| When a hash value is specified in the first argument, | +| ||br| message_hash->data_type, the signature text for the first 24 bytes | +| ||br| of the SHA-256 hash value input to the first argument, message_hash->pdata, | +| ||br| is written to the second argument, signature, in accordance with secp192r1 | +| ||br| using the private wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |signature |Signature text storage | +| | | ||br| destination information | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "0 padding (64 bits) | +| | | | |br| || signature r (192bits) | +| | | | |br| || 0 padding (64 bits) | +| | | | |br| || signature s (192 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Input wrapped key of secp192r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.93.R_SCE_ECDSA_secp224r1_SignatureGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate ( sce_ecdsa_byte_data_t \*\ message_hash, | +||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a message is specified in the first argument, message_hash->data_type, | +| ||br| a SHA-256 hash of the message text input as the first argument, | +| ||br| message_hash->pdata, is calculated, and the signature text is written to | +| ||br| the second argument, signature, in accordance with secp224r1 using | +| ||br| the private wrapped key input as the third argument, wrapped_key. | +| ||br| When a hash value is specified in the first argument, | +| ||br| message_hash->data_type, the signature text for the first 28 bytes | +| ||br| of the SHA-256 hash value input to the first argument, message_hash->pdata, | +| ||br| is written to the second argument, signature, in accordance with secp224r1 | +| ||br| using the private wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |signature |Signature text storage | +| | | ||br| destination information | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "0 padding (32 bits) | +| | | | |br| || signature r (224bits) | +| | | | |br| || 0 padding (32 bits) | +| | | | |br| || signature s (224 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Input wrapped key of secp224r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.94.R_SCE_ECDSA_secp256r1_SignatureGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate ( sce_ecdsa_byte_data_t \*\ message_hash, | +||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a message is specified in the first argument, message_hash->data_type, | +| ||br| a SHA-256 hash of the message text input as the first argument, | +| ||br| message_hash->pdata, is calculated, and the signature text is written to | +| ||br| the second argument, signature, in accordance with secp256r1 using | +| ||br| the private wrapped key input as the third argument, wrapped_key. | +| ||br| When a hash value is specified in the first argument, | +| ||br| message_hash->data_type, the signature text for the first 32 bytes | +| ||br| of the SHA-256 hash value input to the first argument, message_hash->pdata, | +| ||br| is written to the second argument, signature, in accordance with secp256r1 | +| ||br| using the private wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |signature |Signature text storage | +| | | ||br| destination information | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "signature r (256bits) | +| | | | |br| || signature s (256 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Input wrapped key of secp256r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.95.R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate( sce_ecdsa_byte_data_t \*\ message_hash,| +||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a hash value is specified in the first argument, | +| ||br| message_hash->data_type, the signature text for the first 64 bytes | +| ||br| of the SHA-512 hash value input to the first argument, message_hash->pdata, | +| ||br| is written to the second argument, in accordance with BrainpoolP512r1 | +| ||br| using the private wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (only Hash value(1) is support) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |signature |Signature text storage | +| | | ||br| destination information | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "signature r (512bits) | +| | | | |br| || signature s (512 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |wrapped key of BrainpoolP512r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.96.R_SCE_ECDSA_secp192r1_SignatureVerify +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | +||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a message is specified in the second argument, message_hash->data_type, | +| ||br| a SHA-256 hash of the message text input as the second argument, | +| ||br| message_hash->pdata, is calculated, and the signature text input to the | +| ||br| first argument, signature, is validated in accordance with secp192r1 using | +| ||br| the public wrapped key input as the third argument, wrapped_key. | +| ||br| When a hash value is specified in the second argument, | +| ||br| message_hash->data_type, the signature text for the first 24 bytes | +| ||br| of the SHA-256 hash value input to the second argument, message_hash->pdata,| +| ||br| is written to the first argument, signature, | +| ||br| is validated in accordance with secp192r1 | +| ||br| using the public wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to be verified | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "0 padding (64 bits) | +| | | | |br| || signature r (192bits) | +| | | | |br| || 0 padding (64 bits) | +| | | | |br| || signature s (192 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) (nonuse) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Input wrapped key of secp192r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| or signature verification failed. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.97.R_SCE_ECDSA_secp224r1_SignatureVerify +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | +||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a message is specified in the second argument, message_hash->data_type, | +| ||br| a SHA-224 hash of the message text input as the second argument, | +| ||br| message_hash->pdata, is calculated, and the signature text input to the | +| ||br| first argument, signature, is validated in accordance with secp224r1 using | +| ||br| the public wrapped key input as the third argument, wrapped_key. | +| ||br| When a hash value is specified in the second argument, | +| ||br| message_hash->data_type, the signature text for the first 28 bytes | +| ||br| of the SHA-224 hash value input to the second argument, message_hash->pdata,| +| ||br| is written to the first argument, signature, | +| ||br| is validated in accordance with secp224r1 | +| ||br| using the public wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to be verified | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "0 padding (32 bits) | +| | | | |br| || signature r (224bits) | +| | | | |br| || 0 padding (32 bits) | +| | | | |br| || signature s (224 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) (nonuse) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Input wrapped key of secp224r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| or signature verification failed. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.98.R_SCE_ECDSA_secp256r1_SignatureVerify +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | +||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a message is specified in the second argument, message_hash->data_type, | +| ||br| a SHA-256 hash of the message text input as the second argument, | +| ||br| message_hash->pdata, is calculated, and the signature text input to the | +| ||br| first argument, signature, is validated in accordance with secp256r1 using | +| ||br| the public wrapped key input as the third argument, wrapped_key. | +| ||br| When a hash value is specified in the second argument, | +| ||br| message_hash->data_type, the signature text for the first 32 bytes | +| ||br| of the SHA-256 hash value input to the second argument, message_hash->pdata,| +| ||br| is written to the first argument, signature, | +| ||br| is validated in accordance with secp256r1 | +| ||br| using the public wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to be verified | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "signature r (256bits) | +| | | | |br| || signature s (256 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) (nonuse) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Input wrapped key of secp256r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| or signature verification failed. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + +------------------------------------------------------- +2.6.99.R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify +------------------------------------------------------- + ++------------------------------------------------------------------------------------------------+ +|fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | +||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a hash value is specified in the second argument, | +| ||br| message_hash->data_type, the signature text for the first 64 bytes | +| ||br| of the SHA-512 hash value input to the second argument, message_hash->pdata,| +| ||br| is written to the first argument, signature, | +| ||br| is validated in accordance with BrainpoolP512r1 | +| ||br| using the public wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to be verified | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "signature r (512bits) | +| | | | |br| || signature s (512 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) (nonuse) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (only Hash value(1) is support) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |wrapped key of BrainpoolP512r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| or signature verification failed. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | ++--------------+------------------------------------+--------------------------------------------+ +| Note |none | ++--------------+---------------------------------------------------------------------------------+ + + + +.. |br| raw:: html + +
\ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/inc/api/r_sce_api.h b/core/arch/arm/plat-rz/common/drivers/r_sce/inc/api/r_sce_api.h new file mode 100644 index 000000000..9381c0b86 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/inc/api/r_sce_api.h @@ -0,0 +1,1501 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : r_sce_api.h + * Version : 1.0 + * Description : SCE API header file + *********************************************************************************************************************/ +/********************************************************************************************************************** + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release + *********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @ingroup RENESAS_INTERFACES + * @defgroup SCE_PROTECTED_API SCE Interface + * @brief Interface for Secure Crypto Engine (SCE) functions. + * + * @section SCE_PROTECTED_API_Summary Summary + * The SCE interface provides SCE functionality. + * + * The SCE interface can be implemented by: + * - @ref SCE_PROTECTED + * + * @{ + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include + +#ifndef R_SCE_API_H +#define R_SCE_API_H + + + +/********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ +#define FSP_PARAMETER_NOT_USED(p) ((void) ((p))) + +/* For AES operation. */ +#define HW_SCE_AES128_KEY_INDEX_WORD_SIZE (12U) +#define HW_SCE_AES256_KEY_INDEX_WORD_SIZE (16U) +#define HW_SCE_AES128_KEY_WORD_SIZE (4U) +#define HW_SCE_AES256_KEY_WORD_SIZE (8U) +#define HW_SCE_AES128_KEY_BYTE_SIZE (16U) +#define HW_SCE_AES256_KEY_BYTE_SIZE (32U) +#define HW_SCE_AES_BLOCK_BYTE_SIZE (16U) +#define HW_SCE_AES_BLOCK_BIT_SIZE (128U) +#define HW_SCE_AES_CBC_IV_BYTE_SIZE (16U) + +/* For SHA operation. */ +#define HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE (28U) +#define HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE (32U) +#define HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE (64U) + +/* For RSA operation. */ +#define HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE (128U) +#define HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE (4U) +#define HW_SCE_RSA_1024_KEY_D_LENGTH_BYTE_SIZE (128U) +#define HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE (256U) +#define HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE (4U) +#define HW_SCE_RSA_2048_KEY_D_LENGTH_BYTE_SIZE (256U) +#define HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE (128 * 4U) +#define HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE (4U) +#define HW_SCE_RSA_4096_KEY_D_LENGTH_BYTE_SIZE (128 * 4U) +#define HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) +#define HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE (36U) +#define HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) +#define HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE (68U) +#define HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) +#define HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE (68U) +#define HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) +#define HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE (132U) +#define HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) +#define HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE (4U) +#define HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE (12U) +#define HW_SCE_RSA1024_NE_KEY_BYTE_SIZE (144U) +#define HW_SCE_RSA1024_ND_KEY_BYTE_SIZE (256U) +#define HW_SCE_RSA2048_NE_KEY_BYTE_SIZE (272U) +#define HW_SCE_RSA2048_ND_KEY_BYTE_SIZE (512U) +#define HW_SCE_RSA4096_NE_KEY_BYTE_SIZE (128 * 4 + 16U) +#define HW_SCE_RSA4096_ND_KEY_BYTE_SIZE (256 * 4U) +#define HW_SCE_RSA1024_NE_KEY_INDEX_WORD_SIZE (76U) +#define HW_SCE_RSA1024_ND_KEY_INDEX_WORD_SIZE (104U) +#define HW_SCE_RSA2048_NE_KEY_INDEX_WORD_SIZE (140U) +#define HW_SCE_RSA2048_ND_KEY_INDEX_WORD_SIZE (200U) +#define HW_SCE_RSA4096_NE_KEY_INDEX_WORD_SIZE (140U) +#define HW_SCE_RSA4096_ND_KEY_INDEX_WORD_SIZE (261U) +#define HW_SCE_RSA1024_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE (76U) +#define HW_SCE_RSA1024_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE (104U) +#define HW_SCE_RSA2048_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE (140U) +#define HW_SCE_RSA2048_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE (200U) + +#define HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE (11U) +#define HW_SCE_RSA_1024_DATA_BYTE_SIZE (128U) +#define HW_SCE_RSA_2048_DATA_BYTE_SIZE (256U) +#define HW_SCE_RSA_4096_DATA_BYTE_SIZE (128 * 4U) + +/* RSA HASH type. */ +#define HW_SCE_RSA_HASH_SHA256 (0x03) /* SHA-256 */ + +/* For ECC operation. */ +#define HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE (144U) +#define HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE (4U) +#define HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE (24U) +#define HW_SCE_ECC_PUBLIC_KEY_BYTE_SIZE (64U) +#define HW_SCE_ECC_PRIVATE_KEY_BYTE_SIZE (32U) +#define HW_SCE_ECDSA_DATA_BYTE_SIZE (64U) +#define HW_SCE_ECDSA_P512_DATA_BYTE_SIZE (128U) +#define HW_SCE_SHARED_SECRET_KEY_INDEX_WORD_SIZE (13U) + +/* Key update. */ +#define HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE (16U) + +#define SCE_OEM_KEY_SIZE_DUMMY_INST_DATA_WORD (0) +#define SCE_OEM_KEY_SIZE_AES128_INST_DATA_WORD (8) +#define SCE_OEM_KEY_SIZE_AES256_INST_DATA_WORD (12) + +#define SCE_OEM_KEY_SIZE_RSA1024_PUBLIC_KEY_INST_DATA_WORD (40) +#define SCE_OEM_KEY_SIZE_RSA1024_PRIVATE_KEY_INST_DATA_WORD (68) +#define SCE_OEM_KEY_SIZE_RSA2048_PUBLIC_KEY_INST_DATA_WORD (72) +#define SCE_OEM_KEY_SIZE_RSA2048_PRIVATE_KEY_INST_DATA_WORD (132) +#define SCE_OEM_KEY_SIZE_RSA4096_PUBLIC_KEY_INST_DATA_WORD (136) +#define SCE_OEM_KEY_SIZE_RSA4096_PRIVATE_KEY_INST_DATA_WORD (260) + +#define SCE_OEM_KEY_SIZE_ECCP192_PUBLIC_KEY_INST_DATA_WORD (20) +#define SCE_OEM_KEY_SIZE_ECCP192_PRIVATE_KEY_INST_DATA_WORD (12) +#define SCE_OEM_KEY_SIZE_ECCP224_PUBLIC_KEY_INST_DATA_WORD (20) +#define SCE_OEM_KEY_SIZE_ECCP224_PRIVATE_KEY_INST_DATA_WORD (12) +#define SCE_OEM_KEY_SIZE_ECCP256_PUBLIC_KEY_INST_DATA_WORD (20) +#define SCE_OEM_KEY_SIZE_ECCP256_PRIVATE_KEY_INST_DATA_WORD (12) +#define SCE_OEM_KEY_SIZE_ECCP512_PUBLIC_KEY_INST_DATA_WORD (36) +#define SCE_OEM_KEY_SIZE_ECCP512_PRIVATE_KEY_INST_DATA_WORD (20) + +#define SCE_INSTALL_KEY_RING_INDEX (0) /* 0-15 */ + +/********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ +/* Return error codes fsp */ +typedef enum e_fsp_err +{ + FSP_SUCCESS = 0, + + /* Start of Crypto specific (0x10000) @note Refer to sf_cryoto_err.h for Crypto error code. */ + FSP_ERR_CRYPTO_CONTINUE = 0x10000, ///< Continue executing function + FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT = 0x10001, ///< Hardware resource busy + FSP_ERR_CRYPTO_SCE_FAIL = 0x10002, ///< Internal I/O buffer is not empty + FSP_ERR_CRYPTO_SCE_HRK_INVALID_INDEX = 0x10003, ///< Invalid index + FSP_ERR_CRYPTO_SCE_RETRY = 0x10004, ///< Retry + FSP_ERR_CRYPTO_SCE_VERIFY_FAIL = 0x10005, ///< Verify is failed + FSP_ERR_CRYPTO_SCE_ALREADY_OPEN = 0x10006, ///< HW SCE module is already opened + FSP_ERR_CRYPTO_NOT_OPEN = 0x10007, ///< Hardware module is not initialized + FSP_ERR_CRYPTO_UNKNOWN = 0x10008, ///< Some unknown error occurred + FSP_ERR_CRYPTO_NULL_POINTER = 0x10009, ///< Null pointer input as a parameter + FSP_ERR_CRYPTO_NOT_IMPLEMENTED = 0x1000a, ///< Algorithm/size not implemented + FSP_ERR_CRYPTO_RNG_INVALID_PARAM = 0x1000b, ///< An invalid parameter is specified + FSP_ERR_CRYPTO_RNG_FATAL_ERROR = 0x1000c, ///< A fatal error occurred + FSP_ERR_CRYPTO_INVALID_SIZE = 0x1000d, ///< Size specified is invalid + FSP_ERR_CRYPTO_INVALID_STATE = 0x1000e, ///< Function used in an valid state + FSP_ERR_CRYPTO_ALREADY_OPEN = 0x1000f, ///< control block is already opened + FSP_ERR_CRYPTO_INSTALL_KEY_FAILED = 0x10010, ///< Specified input key is invalid. + FSP_ERR_CRYPTO_AUTHENTICATION_FAILED = 0x10011, ///< Authentication failed + FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL = 0x10012, ///< Failure to Init Cipher + FSP_ERR_CRYPTO_SCE_AUTHENTICATION = 0x10013, ///< Authentication failed + FSP_ERR_CRYPTO_SCE_PARAMETER = 0x10014, ///< Input date is illegal. + FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION = 0x10015, ///< An invalid function call occurred. + + /* Start of SF_CRYPTO specific */ + FSP_ERR_CRYPTO_COMMON_NOT_OPENED = 0x20000, ///< Crypto Framework Common is not opened + FSP_ERR_CRYPTO_HAL_ERROR = 0x20001, ///< Cryoto HAL module returned an error + FSP_ERR_CRYPTO_KEY_BUF_NOT_ENOUGH = 0x20002, ///< Key buffer size is not enough to generate a key + FSP_ERR_CRYPTO_BUF_OVERFLOW = 0x20003, ///< Attempt to write data larger than what the buffer can hold + FSP_ERR_CRYPTO_INVALID_OPERATION_MODE = 0x20004, ///< Invalid operation mode. + FSP_ERR_MESSAGE_TOO_LONG = 0x20005, ///< Message for RSA encryption is too long. + FSP_ERR_RSA_DECRYPTION_ERROR = 0x20006, ///< RSA Decryption error. +} fsp_err_t; + +/** Data lifecycle */ +typedef enum +{ + SCE_CM = 1, + SCE_SSD, + SCE_NSECSD, + SCE_DPL, + SCE_LCK_DBG, + SCE_LCK_BOOT, + SCE_RMA_REQ, + SCE_RMA_ACK, +} lifecycle_t; + +/** Byte data structure */ +typedef struct sce_byte_data +{ + uint8_t * pdata; ///< pointer + uint32_t data_length; ///< data_length + uint32_t data_type; ///< data type +} sce_byte_data_t; + +/** RSA byte data structure */ +typedef sce_byte_data_t sce_rsa_byte_data_t; ///< byte data + +/** ECDSA byte data structure */ +typedef sce_byte_data_t sce_ecdsa_byte_data_t; ///< byte data + +/** AES wrapped key data structure. DO NOT MODIFY. */ +typedef struct sce_aes_wrapped_key +{ + uint32_t type; ///< key type + + /* AES128, AES256 are supported */ + uint32_t value[HW_SCE_AES256_KEY_INDEX_WORD_SIZE]; ///< wrapped key value +} sce_aes_wrapped_key_t; + +/** RSA 1024bit public wrapped key data structure. DO NOT MODIFY. */ +typedef struct sce_rsa1024_public_wrapped_key +{ + uint32_t type; ///< key type + struct + { + /* key management information */ + uint32_t key_management_info1[HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; + /* RSA 1024-bit public key n (plaintext) */ + uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; + /* RSA 1024-bit public key e (plaintext) */ + uint8_t key_e[HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE]; + /* dummy */ + uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; + /* key management information */ + uint32_t key_management_info2[HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; + } value; +} sce_rsa1024_public_wrapped_key_t; + +/** RSA 1024bit private wrapped key data structure. DO NOT MODIFY. */ +typedef struct sce_rsa1024_private_wrapped_key +{ + uint32_t type; ///< key type + struct + { + /* key management information */ + uint32_t key_management_info1[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; + /* RSA 1024-bit private key n (plaintext) */ + uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; + /* key management information */ + uint32_t key_management_info2[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; + } value; +} sce_rsa1024_private_wrapped_key_t; + +/** RSA 2048bit public wrapped key data structure. DO NOT MODIFY. */ +typedef struct sce_rsa2048_public_wrapped_key +{ + uint32_t type; ///< Key type + struct + { + /* key management information */ + uint32_t key_management_info1[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; + /* RSA 2048-bit public key n (plaintext) */ + uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; + /* RSA 2048-bit public key e (plaintext) */ + uint8_t key_e[HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE]; + /* dummy */ + uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; + /* key management information */ + uint32_t key_management_info2[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; + } value; +} sce_rsa2048_public_wrapped_key_t; + +/** RSA 2048bit private wrapped key data structure. DO NOT MODIFY. */ +typedef struct sce_rsa2048_private_wrapped_key +{ + uint32_t type; ///< key type + struct + { + /* key management information */ + uint32_t key_management_info1[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; + /* RSA 2048-bit private key n (plaintext) */ + uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; + /* key management information */ + uint32_t key_management_info2[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; + } value; +} sce_rsa2048_private_wrapped_key_t; + +/** RSA 4096bit public wrapped key data structure. DO NOT MODIFY. */ +typedef struct sce_rsa4096_public_wrapped_key +{ + uint32_t type; ///< Key type + struct + { + /* key management information */ + uint32_t key_management_info1[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; + /* RSA 4096-bit public key n (plaintext) */ + uint8_t key_n[HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE]; + /* RSA 4096-bit public key e (plaintext) */ + uint8_t key_e[HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE]; + /* dummy */ + uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; + /* key management information */ + uint32_t key_management_info2[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; + } value; +} sce_rsa4096_public_wrapped_key_t; + +/** RSA 1024bit wrapped key pair structure. DO NOT MODIFY. */ +typedef struct sce_rsa1024_wrapped_pair_key +{ + sce_rsa1024_private_wrapped_key_t priv_key; ///< RSA 1024-bit private wrapped key + sce_rsa1024_public_wrapped_key_t pub_key; ///< RSA 1024-bit public wrapped key +} sce_rsa1024_wrapped_pair_key_t; + +/** RSA 2048bit wrapped key pair structure. DO NOT MODIFY. */ +typedef struct sce_rsa2048_wrapped_pair_key +{ + sce_rsa2048_private_wrapped_key_t priv_key; ///< RSA 2048-bit private wrapped key + sce_rsa2048_public_wrapped_key_t pub_key; ///< RSA 2048-bit public wrapped key +} sce_rsa2048_wrapped_pair_key_t; + +/** ECC P-192/224/256/512 public wrapped key data structure */ +typedef struct sce_ecc_public_wrapped_key +{ + uint32_t type; ///< key type + struct + { + /* key management information */ + uint32_t key_management_info[HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE]; + /* ECC public key Q (plaintext) */ + uint8_t key_q[HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE]; + } value; +} sce_ecc_public_wrapped_key_t; + +/** ECC P-192/224/256/512 private wrapped key data structure */ +typedef struct sce_ecc_private_wrapped_key +{ + uint32_t type; ///< key type + uint32_t value[HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE]; ///< wrapped key value +} sce_ecc_private_wrapped_key_t; + +/** ECC P-192/224/256 wrapped key pair structure */ +typedef struct sce_ecc_wrapped_pair_key +{ + sce_ecc_private_wrapped_key_t priv_key; ///< ECC private wrapped key + sce_ecc_public_wrapped_key_t pub_key; ///< ECC public wrapped key +} sce_ecc_wrapped_pair_key_t; + +/** Update key ring index data structure. DO NOT MODIFY. */ +typedef struct sce_key_update_key +{ + uint32_t type; ///< key type + uint32_t value[HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE]; ///< wrapped key value +} sce_key_update_key_t; + +/** The work area for AES. DO NOT MODIFY. */ +typedef struct sce_aes_handle +{ + /* serial number of this handle */ + uint32_t id; + /* wrapped key */ + sce_aes_wrapped_key_t wrapped_key; + /* text size under encryption / decryption */ + uint32_t current_input_data_size; + /* text array less than the block long */ + uint8_t last_1_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE]; + /* reserved */ + uint8_t last_2_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE * 2]; + /* current initialization vector used in CBC/CTR mode */ + uint8_t current_initial_vector[HW_SCE_AES_CBC_IV_BYTE_SIZE]; + /* control flag of calling function */ + uint8_t flag_call_init; +} sce_aes_handle_t; + +/** The work area for CMAC. DO NOT MODIFY. */ +typedef struct sce_cmac_handle +{ + uint32_t id; ///< serial number of this handle + sce_aes_wrapped_key_t wrapped_key; ///< wrapped key + uint8_t cmac_buffer[HW_SCE_AES_BLOCK_BYTE_SIZE]; ///< message array less than the block long + uint32_t all_received_length; ///< entire length of message + /* message array length less than the block long */ + uint32_t buffering_length; + uint8_t flag_call_init; ///< control flag of calling function +} sce_cmac_handle_t; + +/** The work area for SHA. DO NOT MODIFY. */ +typedef struct sce_sha_md5_handle +{ + uint32_t id; ///< serial number of this handle + uint8_t sha_buffer[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE * 4];///< message array length less than the block long + uint32_t all_received_length; ///< entire length of message + uint32_t buffering_length; ///< message array length less than the block long + + /* SHA1(20byte), SHA256(32byte), MD5(16byte) are supported */ + uint8_t current_hash[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE]; ///< last hash value + uint8_t flag_call_init; ///< control flag of calling function +} sce_sha_md5_handle_t; + +/** SCE Control block. Allocate an instance specific control block to pass into the API calls. + * @par Implemented as + * - sce_instance_ctrl_t + */ +typedef void sce_ctrl_t; + +/** User configuration structure, used in open function */ +typedef struct st_sce_cfg +{ + lifecycle_t lifecycle; ///< Data lifecycle +} sce_cfg_t; + +/** Functions implemented at the HAL layer will follow this API. */ +typedef struct st_sce_api +{ + /** Enables use of SCE functionality. + * @par Implemented as + * - @ref R_SCE_Open() + * + * @param[in] p_ctrl Pointer to control structure. + * @param[in] p_cfg Pointer to pin configuration structure. + */ + + /***** TODO: Replace "struct st_sce_ctrl" to "void" *****/ + fsp_err_t (* open)(sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg); + + /** Stops supply of power to the SCE. + * @par Implemented as + * - @ref R_SCE_Close() + * + * @param[in] p_ctrl Pointer to control structure. + */ + fsp_err_t (* close)(sce_ctrl_t * const p_ctrl); + + /** Software reset to SCE. + * @par Implemented as + * - @ref R_SCE_SoftwareReset() + * + */ + fsp_err_t (* softwareReset)(void); + + /** Generates 4 words random number. + * @par Implemented as + * - @ref R_SCE_RandomNumberGenerate() + * + * @param[in,out] random Stores 4words (16 bytes) random data. + */ + fsp_err_t (* randomNumberGenerate)(uint32_t * random); + + /** This API outputs 128-bit AES wrapped key. + * @par Implemented as + * - @ref R_SCE_AES128_WrappedKeyGenerate() + * + * @param[in,out] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* AES128_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); + + /** This API outputs 256-bit AES wrapped key. + * @par Implemented as + * - @ref R_SCE_AES256_WrappedKeyGenerate() + * + * @param[in,out] wrapped_key 256-bit AES wrapped key + */ + fsp_err_t (* AES256_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); + + /** This API outputs 128-bit AES wrapped key. + * @par Implemented as + * - @ref R_SCE_AES128_EncryptedKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* AES128_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); + + /** This API outputs 256-bit AES wrapped key. + * @par Implemented as + * - @ref R_SCE_AES256_EncryptedKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 256-bit AES wrapped key + */ + fsp_err_t (* AES256_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); + + /** Initialize AES128ECB encryption. + * @par Implemented as + * - @ref R_SCE_AES128ECB_EncryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* AES128ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES128ECB encryption. + * @par Implemented as + * - @ref R_SCE_AES128ECB_EncryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + */ + fsp_err_t (* AES128ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + /** Finalize AES128ECB encryption. + * @par Implemented as + * - @ref R_SCE_AES128ECB_EncryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + */ + fsp_err_t (* AES128ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + /** Initialize AES128ECB decryption. + * @par Implemented as + * - @ref R_SCE_AES128ECB_DecryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* AES128ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES128ECB decryption. + * @par Implemented as + * - @ref R_SCE_AES128ECB_DecryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + */ + fsp_err_t (* AES128ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + /** Finalize AES128ECB decryption. + * @par Implemented as + * - @ref R_SCE_AES128ECB_DecryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + */ + fsp_err_t (* AES128ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + /** Initialize AES256ECB encryption. + * @par Implemented as + * - @ref R_SCE_AES256ECB_EncryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + */ + fsp_err_t (* AES256ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES256ECB encryption. + * @par Implemented as + * - @ref R_SCE_AES256ECB_EncryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + */ + fsp_err_t (* AES256ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + /** Finalize AES256ECB encryption. + * @par Implemented as + * - @ref R_SCE_AES256ECB_EncryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + */ + fsp_err_t (* AES256ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + /** Initialize AES256ECB decryption. + * @par Implemented as + * - @ref R_SCE_AES256ECB_DecryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + */ + fsp_err_t (* AES256ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES256ECB decryption. + * @par Implemented as + * - @ref R_SCE_AES256ECB_DecryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + */ + fsp_err_t (* AES256ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + /** Finalize AES256ECB decryption. + * @par Implemented as + * - @ref R_SCE_AES256ECB_DecryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + */ + fsp_err_t (* AES256ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + /** Initialize AES128CBC encryption. + * @par Implemented as + * - @ref R_SCE_AES128CBC_EncryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES128CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES128CBC encryption. + * @par Implemented as + * - @ref R_SCE_AES128CBC_EncryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + */ + fsp_err_t (* AES128CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + /** Finalize AES128CBC encryption. + * @par Implemented as + * - @ref R_SCE_AES128CBC_EncryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + */ + fsp_err_t (* AES128CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + /** Initialize AES128CBC decryption. + * @par Implemented as + * - @ref R_SCE_AES128CBC_DecryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES128CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES128CBC decryption. + * @par Implemented as + * - @ref R_SCE_AES128CBC_DecryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + */ + fsp_err_t (* AES128CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + /** Finalize AES128CBC decryption. + * @par Implemented as + * - @ref R_SCE_AES128CBC_DecryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + */ + fsp_err_t (* AES128CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + /** Initialize AES256CBC encryption. + * @par Implemented as + * - @ref R_SCE_AES256CBC_EncryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES256CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES256CBC encryption. + * @par Implemented as + * - @ref R_SCE_AES256CBC_EncryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + */ + fsp_err_t (* AES256CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + /** Finalize AES256CBC encryption. + * @par Implemented as + * - @ref R_SCE_AES256CBC_EncryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + */ + fsp_err_t (* AES256CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + /** Initialize AES256CBC decryption. + * @par Implemented as + * - @ref R_SCE_AES256CBC_DecryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES256CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES256CBC decryption. + * @par Implemented as + * - @ref R_SCE_AES256CBC_DecryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + */ + fsp_err_t (* AES256CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + /** Finalize AES256CBC decryption. + * @par Implemented as + * - @ref R_SCE_AES256CBC_DecryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + */ + fsp_err_t (* AES256CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + /** Initialize AES128CTR encryption. + * @par Implemented as + * - @ref R_SCE_AES128CTR_EncryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES128CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES128CTR encryption. + * @par Implemented as + * - @ref R_SCE_AES128CTR_EncryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + */ + fsp_err_t (* AES128CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + /** Finalize AES128CTR encryption. + * @par Implemented as + * - @ref R_SCE_AES128CTR_EncryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + */ + fsp_err_t (* AES128CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + /** Initialize AES128CTR decryption. + * @par Implemented as + * - @ref R_SCE_AES128CTR_DecryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES128CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES128CTR decryption. + * @par Implemented as + * - @ref R_SCE_AES128CTR_DecryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + */ + fsp_err_t (* AES128CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + /** Finalize AES128CTR decryption. + * @par Implemented as + * - @ref R_SCE_AES128CTR_DecryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + */ + fsp_err_t (* AES128CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + /** Initialize AES256CTR encryption. + * @par Implemented as + * - @ref R_SCE_AES256CTR_EncryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES256CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES256CTR encryption. + * @par Implemented as + * - @ref R_SCE_AES256CTR_EncryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + */ + fsp_err_t (* AES256CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + /** Finalize AES256CTR encryption. + * @par Implemented as + * - @ref R_SCE_AES256CTR_EncryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + */ + fsp_err_t (* AES256CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + /** Initialize AES256CTR decryption. + * @par Implemented as + * - @ref R_SCE_AES256CTR_DecryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES256CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES256CTR decryption. + * @par Implemented as + * - @ref R_SCE_AES256CTR_DecryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + */ + fsp_err_t (* AES256CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + /** Finalize AES256CTR decryption. + * @par Implemented as + * - @ref R_SCE_AES256CTR_DecryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + */ + fsp_err_t (* AES256CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + /** Initialize AES128CMAC generation. + * @par Implemented as + * - @ref R_SCE_AES128CMAC_GenerateInit() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* AES128CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES128CMAC generation. + * @par Implemented as + * - @ref R_SCE_AES128CMAC_GenerateUpdate() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) + */ + fsp_err_t (* AES128CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + /** Finalize AES128CMAC generation. + * @par Implemented as + * - @ref R_SCE_AES128CMAC_GenerateFinal() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (16byte) + */ + fsp_err_t (* AES128CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); + + /** Initialize AES128CMAC verification. + * @par Implemented as + * - @ref R_SCE_AES128CMAC_VerifyInit() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* AES128CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES128CMAC verification. + * @par Implemented as + * - @ref R_SCE_AES128CMAC_VerifyUpdate() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) + */ + fsp_err_t (* AES128CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + /** Finalize AES128CMAC verification. + * @par Implemented as + * - @ref R_SCE_AES128CMAC_VerifyFinal() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (mac_length byte) + * @param[in,out] mac_length MAC data length (2 to 16 bytes) + */ + fsp_err_t (* AES128CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); + + /** Initialize AES256CMAC generation. + * @par Implemented as + * - @ref R_SCE_AES256CMAC_GenerateInit() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + */ + fsp_err_t (* AES256CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES256CMAC generation. + * @par Implemented as + * - @ref R_SCE_AES256CMAC_GenerateUpdate() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) + */ + fsp_err_t (* AES256CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + /** Finalize AES256CMAC generation. + * @par Implemented as + * - @ref R_SCE_AES256CMAC_GenerateFinal() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (16byte) + */ + fsp_err_t (* AES256CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); + + /** Initialize AES256CMAC verification. + * @par Implemented as + * - @ref R_SCE_AES256CMAC_VerifyInit() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + */ + fsp_err_t (* AES256CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES256CMAC verification. + * @par Implemented as + * - @ref R_SCE_AES256CMAC_VerifyUpdate() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) + */ + fsp_err_t (* AES256CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + /** Finalize AES256CMAC verification. + * @par Implemented as + * - @ref R_SCE_AES256CMAC_VerifyFinal() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (mac_length byte) + * @param[in,out] mac_length MAC data length (2 to 16 bytes) + */ + fsp_err_t (* AES256CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); + + /** Initialize SHA-256 Calculation. + * @par Implemented as + * - @ref R_SCE_SHA256_Init() + * + * @param[in,out] handle SHA handler (work area) + */ + fsp_err_t (* SHA256_Init)(sce_sha_md5_handle_t * handle); + + /** Update SHA-256 Calculation. + * @par Implemented as + * - @ref R_SCE_SHA256_Update() + * + * @param[in,out] handle SHA handler (work area) + * @param[in] message message data area + * @param[in] message_length message data length + */ + fsp_err_t (* SHA256_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); + + /** Finalize SHA-256 Calculation. + * @par Implemented as + * - @ref R_SCE_SHA256_Final() + * + * @param[in,out] handle SHA handler (work area) + * @param[in,out] digest hasha data area + * @param[in,out] digest_length hash data length (32bytes) + */ + fsp_err_t (* SHA256_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); + + /** Initialize SHA-224 Calculation. + * @par Implemented as + * - @ref R_SCE_SHA224_Init() + * + * @param[in,out] handle SHA handler (work area) + */ + fsp_err_t (* SHA224_Init)(sce_sha_md5_handle_t * handle); + + /** Update SHA-224 Calculation. + * @par Implemented as + * - @ref R_SCE_SHA224_Update() + * + * @param[in,out] handle SHA handler (work area) + * @param[in] message message data area + * @param[in] message_length message data length + */ + fsp_err_t (* SHA224_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); + + /** Finalize SHA-224 Calculation. + * @par Implemented as + * - @ref R_SCE_SHA224_Final() + * + * @param[in,out] handle SHA handler (work area) + * @param[in,out] digest hasha data area + * @param[in,out] digest_length hash data length (32bytes) + */ + fsp_err_t (* SHA224_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); + + /** This API outputs 1024-bit RSA wrapped pair key. + * @par Implemented as + * - @ref R_SCE_RSA1024_WrappedKeyPairGenerate() + * + * @param[in,out] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* RSA1024_WrappedKeyPairGenerate)(sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key); + + /** This API outputs 2048-bit RSA wrapped pair key. + * @par Implemented as + * - @ref R_SCE_RSA2048_WrappedKeyPairGenerate() + * + * @param[in,out] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* RSA2048_WrappedKeyPairGenerate)(sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key); + + /** This API outputs 1024-bit RSA public wrapped key. + * @par Implemented as + * - @ref R_SCE_RSA1024_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 1024-bit RSA public wrapped key + */ + fsp_err_t (* RSA1024_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_public_wrapped_key_t * wrapped_key); + + /** This API outputs 1024-bit RSA private wrapped key. + * @par Implemented as + * - @ref R_SCE_RSA1024_EncryptedPrivateKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 1024-bit RSA private wrapped key + */ + fsp_err_t (* RSA1024_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_private_wrapped_key_t * wrapped_key); + + /** This API outputs 2048-bit RSA public wrapped key. + * @par Implemented as + * - @ref R_SCE_RSA2048_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 2048-bit RSA public wrapped key + */ + fsp_err_t (* RSA2048_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_public_wrapped_key_t * wrapped_key); + + /** This API outputs 2048-bit RSA private wrapped key. + * @par Implemented as + * - @ref R_SCE_RSA2048_EncryptedPrivateKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 2048-bit RSA private wrapped key + */ + fsp_err_t (* RSA2048_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_private_wrapped_key_t * wrapped_key); + + /** This API outputs 4096-bit RSA public wrapped key. + * @par Implemented as + * - @ref R_SCE_RSA4096_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 4096-bit RSA public wrapped key + */ + fsp_err_t (* RSA4096_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa4096_public_wrapped_key_t * wrapped_key); + + /** RSASSA-PKCS1-V1_5 signature generation. + * @par Implemented as + * - @ref R_SCE_RSASSA_PKCS1024_SignatureGenerate() + * + * @param[in] message_hash Message or hash value to which to attach signature + * @param[in,out] signature Signature text storage destination information + * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + */ + fsp_err_t (* RSASSA_PKCS1024_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, + sce_rsa_byte_data_t * signature, sce_rsa1024_private_wrapped_key_t * wrapped_key, uint8_t hash_type); + + /** RSASSA-PKCS1-V1_5 signature generation. + * @par Implemented as + * - @ref R_SCE_RSASSA_PKCS2048_SignatureGenerate() + * + * @param[in] message_hash Message or hash value to which to attach signature + * @param[in,out] signature Signature text storage destination information + * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + */ + fsp_err_t (* RSASSA_PKCS2048_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, + sce_rsa_byte_data_t * signature, sce_rsa2048_private_wrapped_key_t * wrapped_key, uint8_t hash_type); + + /** RSASSA-PKCS1-V1_5 signature verification. + * @par Implemented as + * - @ref R_SCE_RSASSA_PKCS1024_SignatureVerify() + * + * @param[in] signature Signature text information to verify + * @param[in] message_hash Message text or hash value to verify + * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + */ + fsp_err_t (* RSASSA_PKCS1024_SignatureVerify)(sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, sce_rsa1024_public_wrapped_key_t * wrapped_key, uint8_t hash_type); + + /** RSASSA-PKCS1-V1_5 signature verification. + * @par Implemented as + * - @ref R_SCE_RSASSA_PKCS2048_SignatureVerify() + * + * @param[in] signature Signature text information to verify + * @param[in] message_hash Message text or hash value to verify + * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + */ + fsp_err_t (* RSASSA_PKCS2048_SignatureVerify)(sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, sce_rsa2048_public_wrapped_key_t * wrapped_key, uint8_t hash_type); + + /** RSASSA-PKCS1-V1_5 signature verification. + * @par Implemented as + * - @ref R_SCE_RSASSA_PKCS4096_SignatureVerify() + * + * @param[in] signature Signature text information to verify + * @param[in] message_hash Message text or hash value to verify + * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + */ + fsp_err_t (* RSASSA_PKCS4096_SignatureVerify)(sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, sce_rsa4096_public_wrapped_key_t * wrapped_key, uint8_t hash_type); + + /** RSAES-PKCS1-V1_5 encryption. + * @par Implemented as + * - @ref R_SCE_RSAES_PKCS1024_Encrypt() + * + * @param[in] plain plaintext + * @param[in,out] cipher ciphertext + * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. + */ + fsp_err_t (* RSAES_PKCS1024_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, + sce_rsa1024_public_wrapped_key_t * wrapped_key); + + /** RSAES-PKCS1-V1_5 encryption. + * @par Implemented as + * - @ref R_SCE_RSAES_PKCS2048_Encrypt() + * + * @param[in] plain plaintext + * @param[in,out] cipher ciphertext + * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. + */ + fsp_err_t (* RSAES_PKCS2048_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, + sce_rsa2048_public_wrapped_key_t * wrapped_key); + + /** RSAES-PKCS1-V1_5 encryption. + * @par Implemented as + * - @ref R_SCE_RSAES_PKCS4096_Encrypt() + * + * @param[in] plain plaintext + * @param[in,out] cipher ciphertext + * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. + */ + fsp_err_t (* RSAES_PKCS4096_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, + sce_rsa4096_public_wrapped_key_t * wrapped_key); + + /** RSAES-PKCS1-V1_5 decryption. + * @par Implemented as + * - @ref R_SCE_RSAES_PKCS1024_Decrypt() + * + * @param[in] cipher ciphertext + * @param[in,out] plain plaintext + * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. + */ + fsp_err_t (* RSAES_PKCS1024_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, + sce_rsa1024_private_wrapped_key_t * wrapped_key); + + /** RSAES-PKCS1-V1_5 decryption. + * @par Implemented as + * - @ref R_SCE_RSAES_PKCS2048_Decrypt() + * + * @param[in] cipher ciphertext + * @param[in,out] plain plaintext + * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. + */ + fsp_err_t (* RSAES_PKCS2048_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, + sce_rsa2048_private_wrapped_key_t * wrapped_key); + + /** This API outputs secp192r1 wrapped pair key. + * @par Implemented as + * - @ref R_SCE_ECC_secp192r1_WrappedKeyPairGenerate() + * + * @param[in,out] wrapped_pair_key Wrapped pair key for secp192r1 public key and private key pair + */ + fsp_err_t (* ECC_secp192r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + /** This API outputs secp224r1 wrapped pair key. + * @par Implemented as + * - @ref R_SCE_ECC_secp224r1_WrappedKeyPairGenerate() + * + * @param[in,out] wrapped_pair_key Wrapped pair key for secp224r1 public key and private key pair + */ + fsp_err_t (* ECC_secp224r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + /** This API outputs secp256r1 wrapped pair key. + * @par Implemented as + * - @ref R_SCE_ECC_secp256r1_WrappedKeyPairGenerate() + * + * @param[in,out] wrapped_pair_key Wrapped pair key for secp256r1 public key and private key pair + */ + fsp_err_t (* ECC_secp256r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + /** This API outputs BrainpoolP512r1 wrapped pair key. + * @par Implemented as + * - @ref R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate() + * + * @param[in,out] wrapped_pair_key Wrapped pair key for BrainpoolP512r1 public key and private key pair + */ + fsp_err_t (* ECC_BrainpoolP512r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + /** This API outputs secp192r1 public wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp192r1 public wrapped key + */ + fsp_err_t (* ECC_secp192r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** This API outputs secp224r1 public wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp224r1 public wrapped key + */ + fsp_err_t (* ECC_secp224r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** This API outputs secp256r1 public wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp256r1 public wrapped key + */ + fsp_err_t (* ECC_secp256r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** This API outputs BrainpoolP512r1 public wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key BrainpoolP512r1 public wrapped key + */ + fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** This API outputs secp192r1 private wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp192r1 private wrapped key + */ + fsp_err_t (* ECC_secp192r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** This API outputs secp224r1 private wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp224r1 private wrapped key + */ + fsp_err_t (* ECC_secp224r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** This API outputs secp256r1 private wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp256r1 private wrapped key + */ + fsp_err_t (* ECC_secp256r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** This API outputs BrainpoolP512r1 private wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key BrainpoolP512r1 private wrapped key + */ + fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** ECDSA signature generation. + * @par Implemented as + * - @ref R_SCE_ECDSA_secp192r1_SignatureGenerate() + * + * @param[in] message_hash Message or hash value to which to attach signature + * @param[in,out] signature Signature text storage destination information + * @param[in] wrapped_key Input wrapped key of secp192r1 private key. + */ + fsp_err_t (* ECDSA_secp192r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** ECDSA signature generation. + * @par Implemented as + * - @ref R_SCE_ECDSA_secp224r1_SignatureGenerate() + * + * @param[in] message_hash Message or hash value to which to attach signature + * @param[in,out] signature Signature text storage destination information + * @param[in] wrapped_key Input wrapped key of secp224r1 private key. + */ + fsp_err_t (* ECDSA_secp224r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** ECDSA signature generation. + * @par Implemented as + * - @ref R_SCE_ECDSA_secp256r1_SignatureGenerate() + * + * @param[in] message_hash Message or hash value to which to attach signature + * @param[in,out] signature Signature text storage destination information + * @param[in] wrapped_key Input wrapped key of secp256r1 private key. + */ + fsp_err_t (* ECDSA_secp256r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** ECDSA signature generation. + * @par Implemented as + * - @ref R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate() + * + * @param[in] message_hash Message or hash value to which to attach signature + * @param[in,out] signature Signature text storage destination information + * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 private key. + */ + fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** ECDSA signature verification. + * @par Implemented as + * - @ref R_SCE_ECDSA_secp192r1_SignatureVerify() + * + * @param[in] signature Signature text information to be verified + * @param[in,out] message_hash Message or hash value to be verified + * @param[in] wrapped_key Input wrapped key of secp192r1 public key. + */ + fsp_err_t (* ECDSA_secp192r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** ECDSA signature verification. + * @par Implemented as + * - @ref R_SCE_ECDSA_secp224r1_SignatureVerify() + * + * @param[in] signature Signature text information to be verified + * @param[in,out] message_hash Message or hash value to be verified + * @param[in] wrapped_key Input wrapped key of secp224r1 public key. + */ + fsp_err_t (* ECDSA_secp224r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** ECDSA signature verification. + * @par Implemented as + * - @ref R_SCE_ECDSA_secp256r1_SignatureVerify() + * + * @param[in] signature Signature text information to be verified + * @param[in,out] message_hash Message or hash value to be verified + * @param[in] wrapped_key Input wrapped key of secp256r1 public key. + */ + fsp_err_t (* ECDSA_secp256r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** ECDSA signature verification. + * @par Implemented as + * - @ref R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify() + * + * @param[in] signature Signature text information to be verified + * @param[in,out] message_hash Message or hash value to be verified + * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 public key. + */ + fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + +} sce_api_t; + +/** This structure encompasses everything that is needed to use an instance of this interface. */ +typedef struct st_sce_instance +{ + sce_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance + sce_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance + sce_api_t const * p_api; ///< Pointer to the API structure for this instance +} sce_instance_t; + +#endif /* R_SCE_API_H */ + +/*******************************************************************************************************************//** + * @} (end addtogroup SCE_PROTECTED_API) + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/private/inc/r_sce_private.h b/core/arch/arm/plat-rz/common/drivers/r_sce/private/inc/r_sce_private.h new file mode 100644 index 000000000..f331cef42 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/private/inc/r_sce_private.h @@ -0,0 +1,376 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : r_sce_private.h + * Version : 1.0 + * Description : SCE Private API header file + *********************************************************************************************************************/ +/********************************************************************************************************************** + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release + *********************************************************************************************************************/ +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "r_sce.h" + +#ifndef R_SCE_PRIVATE_HEADER_FILE +#define R_SCE_PRIVATE_HEADER_FILE + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ +extern uint32_t const S_FLASH2[]; +extern uint32_t S_RAM[HW_SCE_SRAM_WORD_SIZE]; +extern uint32_t S_HEAP[HW_SCE_SHEAP_WORD_SIZE]; +extern uint32_t S_INST2[HW_SCE_SINST2_WORD_SIZE]; + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/* --------------------- SCE driver wrapper layer ---------------------- */ + +fsp_err_t R_SCE_SelfCheck1Private(void); +fsp_err_t R_SCE_SelfCheck2Private(void); +fsp_err_t R_SCE_SelfCheck3Private(void); +fsp_err_t R_SCE_LoadHukPrivate(lifecycle_t lifecycle); +fsp_err_t R_SCE_FwIntegrityCheckPrivate(void); + +fsp_err_t R_SCE_UpdateOemKeyIndexPrivate(lifecycle_t lifecycle, + sce_oem_cmd_t key_type, + uint8_t * iv, + uint8_t * encrypted_oem_key, + uint32_t * key_index); + +fsp_err_t R_SCE_Aes128EcbEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); +fsp_err_t R_SCE_Aes128EcbEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes128EcbEncryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); +fsp_err_t R_SCE_Aes128EcbDecryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); +fsp_err_t R_SCE_Aes128EcbDecryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes128EcbDecryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); +fsp_err_t R_SCE_Aes128CbcEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); +fsp_err_t R_SCE_Aes128CbcEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes128CbcEncryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); +fsp_err_t R_SCE_Aes128CbcDecryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); +fsp_err_t R_SCE_Aes128CbcDecryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes128CbcDecryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); +fsp_err_t R_SCE_Aes128CtrEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); +fsp_err_t R_SCE_Aes128CtrEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes128CtrEncryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); +fsp_err_t R_SCE_Aes128CtrDecryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); +fsp_err_t R_SCE_Aes128CtrDecryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes128CtrDecryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); + +fsp_err_t R_SCE_Aes256EcbEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); +fsp_err_t R_SCE_Aes256EcbEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes256EcbEncryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); +fsp_err_t R_SCE_Aes256EcbDecryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); +fsp_err_t R_SCE_Aes256EcbDecryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes256EcbDecryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); +fsp_err_t R_SCE_Aes256CbcEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); +fsp_err_t R_SCE_Aes256CbcEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes256CbcEncryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); +fsp_err_t R_SCE_Aes256CbcDecryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); +fsp_err_t R_SCE_Aes256CbcDecryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes256CbcDecryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); +fsp_err_t R_SCE_Aes256CtrEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); +fsp_err_t R_SCE_Aes256CtrEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes256CtrEncryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); +fsp_err_t R_SCE_Aes256CtrDecryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); +fsp_err_t R_SCE_Aes256CtrDecryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes256CtrDecryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); + +fsp_err_t R_SCE_Aes128CmacGenerateInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); +fsp_err_t R_SCE_Aes128CmacGenerateUpdatePrivate(uint32_t * InData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes128CmacGenerateFinalPrivate(uint32_t All_Msg_Len, uint32_t * InData_Text, uint32_t * OutData_DataT); +fsp_err_t R_SCE_Aes128CmacVerifyInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); +fsp_err_t R_SCE_Aes128CmacVerifyUpdatePrivate(uint32_t * InData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes128CmacVerifyFinalPrivate(uint32_t All_Msg_Len, + uint32_t * InData_Text, + uint32_t * InData_DataT, + uint32_t * InData_DataTLen); + +fsp_err_t R_SCE_Aes256CmacGenerateInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); +fsp_err_t R_SCE_Aes256CmacGenerateUpdatePrivate(uint32_t * InData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes256CmacGenerateFinalPrivate(uint32_t All_Msg_Len, uint32_t * InData_Text, uint32_t * OutData_DataT); +fsp_err_t R_SCE_Aes256CmacVerifyInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); +fsp_err_t R_SCE_Aes256CmacVerifyUpdatePrivate(uint32_t * InData_Text, uint32_t MAX_CNT); +fsp_err_t R_SCE_Aes256CmacVerifyFinalPrivate(uint32_t All_Msg_Len, + uint32_t * InData_Text, + uint32_t * InData_DataT, + uint32_t * InData_DataTLen); + +fsp_err_t R_SCE_Sha224InitPrivate(sce_sha_md5_handle_t * handle); +fsp_err_t R_SCE_Sha224UpdatePrivate(sce_sha_md5_handle_t * handle, uint32_t * InData_PaddedMsg, uint32_t MAX_CNT); +fsp_err_t R_SCE_Sha224FinalPrivate(sce_sha_md5_handle_t * handle, + uint32_t * InData_PaddedMsg, + uint32_t MAX_CNT, + uint32_t * OutData_MsgDigest, + uint32_t * OutData_Length); +fsp_err_t R_SCE_Sha256InitPrivate(sce_sha_md5_handle_t * handle); +fsp_err_t R_SCE_Sha256UpdatePrivate(sce_sha_md5_handle_t * handle, uint32_t * InData_PaddedMsg, uint32_t MAX_CNT); +fsp_err_t R_SCE_Sha256FinalPrivate(sce_sha_md5_handle_t * handle, + uint32_t * InData_PaddedMsg, + uint32_t MAX_CNT, + uint32_t * OutData_MsgDigest, + uint32_t * OutData_Length); + +fsp_err_t R_SCE_Rsa1024ModularExponentEncryptPrivate(uint32_t * InData_KeyIndex, + uint32_t * InData_Text, + uint32_t * OutData_Text); +fsp_err_t R_SCE_Rsa1024ModularExponentDecryptPrivate(uint32_t * InData_KeyIndex, + uint32_t * InData_Text, + uint32_t * OutData_Text); +fsp_err_t R_SCE_Rsa2048ModularExponentEncryptPrivate(uint32_t * InData_KeyIndex, + uint32_t * InData_Text, + uint32_t * OutData_Text); +fsp_err_t R_SCE_Rsa2048ModularExponentDecryptPrivate(uint32_t * InData_KeyIndex, + uint32_t * InData_Text, + uint32_t * OutData_Text); +fsp_err_t R_SCE_Rsa4096ModularExponentEncryptPrivate(uint32_t * InData_KeyIndex, + uint32_t * InData_Text, + uint32_t * OutData_Text); + +/* --------------------- SCE control procedure related ---------------------- */ + +void R_SCE_SoftwareResetSub(void); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_RETRY **/ +fsp_err_t R_SCE_SelfCheck2Sub(void); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_StateCheckSub(uint32_t *fsm2_number); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_AES128_EncryptedKeyWrapSub(uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_AES256_EncryptedKeyWrapSub(uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrapSub(uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrapSub(uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrapSub(uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrapSub(uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(uint32_t *InData_CurveType, + uint32_t *InData_Cmd, + uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(uint32_t *InData_CurveType, + uint32_t *InData_Cmd, + uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrapSub(uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrapSub(uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrapSub(uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT **/ +fsp_err_t R_SCE_GenerateAes128RandomKeyIndexSub(uint32_t * OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT **/ +fsp_err_t R_SCE_GenerateAes256RandomKeyIndexSub(uint32_t * OutData_KeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_GenerateRsa1024RandomKeyIndexSub(uint32_t MAX_CNT, + uint32_t * OutData_PubKeyIndex, + uint32_t * OutData_PrivKeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_GenerateRsa2048RandomKeyIndexSub(uint32_t MAX_CNT, + uint32_t * OutData_PubKeyIndex, + uint32_t * OutData_PrivKeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_GenerateEccRandomKeyIndexSub(uint32_t * InData_CurveType, + uint32_t * InData_Cmd, + uint32_t * OutData_PubKeyIndex, + uint32_t * OutData_PrivKeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_GenerateEccP512RandomKeyIndexSub (uint32_t *OutData_PubKeyIndex, + uint32_t *OutData_PrivKeyIndex); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT **/ +fsp_err_t R_SCE_GenerateRandomNumberSub(uint32_t * OutData_Text); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL + * @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_Aes128EncryptDecryptInitSub(const uint32_t * InData_Cmd, + const uint32_t * InData_KeyIndex, + const uint32_t * InData_IV); +void R_SCE_Aes128EncryptDecryptUpdateSub(const uint32_t * InData_Text, + uint32_t * OutData_Text, + const uint32_t MAX_CNT); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_Aes128EncryptDecryptFinalSub(void); + + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL + * @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_Aes256EncryptDecryptInitSub(const uint32_t * InData_Cmd, + const uint32_t * InData_KeyIndex, + const uint32_t * InData_IV); +void R_SCE_Aes256EncryptDecryptUpdateSub(const uint32_t * InData_Text, + uint32_t * OutData_Text, + const uint32_t MAX_CNT); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_Aes256EncryptDecryptFinalSub(void); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL + * @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_Aes128CmacInitSub(uint32_t * InData_KeyIndex); +void R_SCE_Aes128CmacUpdateSub(uint32_t * InData_Text, uint32_t MAX_CNT); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION **/ +fsp_err_t R_SCE_Aes128CmacFinalSub(uint32_t * InData_Cmd, + uint32_t * InData_Text, + uint32_t * InData_DataT, + uint32_t * InData_DataTLen, + uint32_t * OutData_DataT); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL + * @retval FSP_ERR_CRYPTO_SCE_FAIL **/ +fsp_err_t R_SCE_Aes256CmacInitSub(uint32_t * InData_KeyIndex); +void R_SCE_Aes256CmacUpdateSub(uint32_t * InData_Text, uint32_t MAX_CNT); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION **/ +fsp_err_t R_SCE_Aes256CmacFinalSub(uint32_t * InData_Cmd, + uint32_t * InData_Text, + uint32_t * InData_DataT, + uint32_t * InData_DataTLen, + uint32_t * OutData_DataT); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT **/ +fsp_err_t R_SCE_Sha224256GenerateMessageDigestSub(const uint32_t * InData_InitVal, + const uint32_t * InData_PaddedMsg, + const uint32_t MAX_CNT, + uint32_t * OutData_MsgDigest); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ +fsp_err_t R_SCE_Rsa1024ModularExponentEncryptSub(const uint32_t * InData_KeyIndex, + const uint32_t * InData_Text, + uint32_t * OutData_Text); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ +fsp_err_t R_SCE_Rsa1024ModularExponentDecryptSub(uint32_t * InData_KeyIndex, + const uint32_t * InData_Text, + uint32_t * OutData_Text); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ +fsp_err_t R_SCE_Rsa2048ModularExponentEncryptSub(const uint32_t * InData_KeyIndex, + const uint32_t * InData_Text, + uint32_t * OutData_Text); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ +fsp_err_t R_SCE_Rsa2048ModularExponentDecryptSub(uint32_t * InData_KeyIndex, + const uint32_t * InData_Text, + uint32_t * OutData_Text); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ +fsp_err_t R_SCE_Rsa4096ModularExponentEncryptSub(const uint32_t * InData_KeyIndex, + uint32_t * InData_Text, + uint32_t * OutData_Text); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ +fsp_err_t R_SCE_EcdsaSignatureGenerateSub(uint32_t * InData_CurveType, + uint32_t * InData_Cmd, + uint32_t * InData_KeyIndex, + uint32_t * InData_MsgDgst, + uint32_t * OutData_Signature); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ +fsp_err_t R_SCE_EcdsaSignatureVerificationSub(uint32_t * InData_CurveType, + uint32_t * InData_Cmd, + uint32_t * InData_KeyIndex, + uint32_t * InData_MsgDgst, + uint32_t * InData_Signature); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ +fsp_err_t R_SCE_EcdsaP512SignatureVerificationSub (uint32_t *InData_KeyIndex, + uint32_t *InData_MsgDgst, + uint32_t *InData_Signature); + +/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ +fsp_err_t R_SCE_EcdsaP512SignatureGenerateSub (uint32_t *InData_KeyIndex, + uint32_t *InData_MsgDgst, + uint32_t *OutData_Signature); + +uint32_t change_endian_long (volatile uint32_t value); + +#endif /* R_SCE_PRIVATE_HEADER_FILE */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/private/r_sce_private.c b/core/arch/arm/plat-rz/common/drivers/r_sce/private/r_sce_private.c new file mode 100644 index 000000000..49f815882 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/private/r_sce_private.c @@ -0,0 +1,1346 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : r_sce_private.c + * Version : 1.0 + * Description : SCE Private API source file + *********************************************************************************************************************/ +/********************************************************************************************************************** + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include "r_sce_private.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ +#ifndef SCE_HEX_6A09E667 +#define SCE_HEX_6A09E667 (0x6a09e667UL) +#endif +#ifndef SCE_HEX_BB67AE85 +#define SCE_HEX_BB67AE85 (0xbb67ae85UL) +#endif +#ifndef SCE_HEX_3C6EF372 +#define SCE_HEX_3C6EF372 (0x3c6ef372UL) +#endif +#ifndef SCE_HEX_A54FF53A +#define SCE_HEX_A54FF53A (0xa54ff53aUL) +#endif +#ifndef SCE_HEX_510E527F +#define SCE_HEX_510E527F (0x510e527fUL) +#endif +#ifndef SCE_HEX_9B05688C +#define SCE_HEX_9B05688C (0x9b05688cUL) +#endif +#ifndef SCE_HEX_1F83D9AB +#define SCE_HEX_1F83D9AB (0x1f83d9abUL) +#endif +#ifndef SCE_HEX_5BE0CD19 +#define SCE_HEX_5BE0CD19 (0x5be0cd19UL) +#endif +#ifndef SCE_HEX_C1059ED8 +#define SCE_HEX_C1059ED8 (0xc1059ed8UL) +#endif +#ifndef SCE_HEX_367CD507 +#define SCE_HEX_367CD507 (0x367cd507UL) +#endif +#ifndef SCE_HEX_3070DD17 +#define SCE_HEX_3070DD17 (0x3070dd17UL) +#endif +#ifndef SCE_HEX_F70E5939 +#define SCE_HEX_F70E5939 (0xf70e5939UL) +#endif +#ifndef SCE_HEX_FFC00B31 +#define SCE_HEX_FFC00B31 (0xffc00b31UL) +#endif +#ifndef SCE_HEX_68581511 +#define SCE_HEX_68581511 (0x68581511UL) +#endif +#ifndef SCE_HEX_64F98FA7 +#define SCE_HEX_64F98FA7 (0x64f98fa7UL) +#endif +#ifndef SCE_HEX_BEFA4FA4 +#define SCE_HEX_BEFA4FA4 (0xbefa4fa4UL) +#endif + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES ECB mode algorithm with AES 128 key. + * + * @param InData_KeyIndex User key generation information area. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128EcbEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) +{ + uint32_t indata_cmd = 0; + uint32_t indata_iv[4] = /* dummy */ + { + 0 + }; + + if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(0); /* ECB-Encrypt command */ + + return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES ECB mode algorithm with AES 128 key. + * + * @param InData_Text Input plain text. + * @param OutData_Text Output cipher text. + * @param MAX_CNT Input byte size of plain. + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128EcbEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES ECB mode algorithm with AES 128 key. + * + * @param OutData_Text Output cipher text. + * @param OutData_length Output byte size of cipher. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128EcbEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) +{ + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); + + return R_SCE_Aes128EncryptDecryptFinalSub(); +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES ECB mode algorithm with AES 128 key. + * + * @param InData_KeyIndex User key generation information area. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128EcbDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) +{ + uint32_t indata_cmd = 0; + uint32_t indata_iv[4] = /* dummy */ + { + 0 + }; + + if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(1); /* ECB-Decrypt command */ + + return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES ECB mode algorithm with AES 128 key. + * + * @param InData_Text Input cipher text. + * @param OutData_Text Output plain text. + * @param MAX_CNT Input byte size of cipher. + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128EcbDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES ECB mode algorithm with AES 128 key. + * + * @param OutData_Text Output plain text. + * @param OutData_length Output byte size of plain. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128EcbDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) +{ + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); + + return R_SCE_Aes128EncryptDecryptFinalSub(); +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES ECB mode algorithm with AES 256 key. + * + * @param InData_KeyIndex User key generation information area. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256EcbEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) +{ + uint32_t indata_cmd = 0; + uint32_t indata_iv[4] = /* dummy */ + { + 0 + }; + + if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(0); /* ECB-Encrypt command */ + + return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES ECB mode algorithm with AES 256 key. + * + * @param InData_Text Input plain text. + * @param OutData_Text Output cipher text. + * @param MAX_CNT Input byte size of plain. + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256EcbEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES ECB mode algorithm with AES 256 key. + * + * @param OutData_Text Output cipher text. + * @param OutData_length Output byte size of cipher. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256EcbEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) +{ + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); + + return R_SCE_Aes256EncryptDecryptFinalSub(); +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES ECB mode algorithm with AES 256 key. + * + * @param InData_KeyIndex User key generation information area. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256EcbDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) +{ + uint32_t indata_cmd = 0; + uint32_t indata_iv[4] = /* dummy */ + { + 0 + }; + + if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(1); /* ECB-Decrypt command */ + + return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES ECB mode algorithm with AES 256 key. + * + * @param InData_Text Input cipher text. + * @param OutData_Text Output plain text. + * @param MAX_CNT Input byte size of cipher. + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256EcbDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES ECB mode algorithm with AES 256 key. + * + * @param OutData_Text Output plain text. + * @param OutData_length Output byte size of plain. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256EcbDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) +{ + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); + + return R_SCE_Aes256EncryptDecryptFinalSub(); +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES CBC mode algorithm with AES 128 key. + * + * @param InData_KeyIndex User key generation information area. + * @param InData_IV Input initial vector. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CbcEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) +{ + uint32_t indata_cmd = 0; + + if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(2); /* CBC-Encrypt command */ + + return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES CBC mode algorithm with AES 128 key. + * + * @param InData_Text Input plain text. + * @param OutData_Text Output cipher text. + * @param MAX_CNT Input byte size of plain. + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CbcEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES CBC mode algorithm with AES 128 key. + * + * @param OutData_Text Output cipher text. + * @param OutData_length Output byte size of cipher. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CbcEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) +{ + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); + + return R_SCE_Aes128EncryptDecryptFinalSub(); +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES CBC mode algorithm with AES 128 key. + * + * @param InData_KeyIndex User key generation information area. + * @param InData_IV Input initial vector. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CbcDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) +{ + uint32_t indata_cmd = 0; + + if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(3); /* CBC-Decrypt command */ + + return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES CBC mode algorithm with AES 128 key. + * + * @param InData_Text Input cipher text. + * @param OutData_Text Output plain text. + * @param MAX_CNT Input byte size of cipher. + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CbcDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES CBC mode algorithm with AES 128 key. + * + * @param OutData_Text Output plain text. + * @param OutData_length Output byte size of plain. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CbcDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) +{ + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); + + return R_SCE_Aes128EncryptDecryptFinalSub(); +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES CBC mode algorithm with AES 256 key. + * + * @param InData_KeyIndex User key generation information area. + * @param InData_IV Input initial vector. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CbcEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) +{ + uint32_t indata_cmd = 0; + + if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(2); /* CBC-Encrypt command */ + + return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES CBC mode algorithm with AES 256 key. + * + * @param InData_Text Input plain text. + * @param OutData_Text Output cipher text. + * @param MAX_CNT Input byte size of plain. + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CbcEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES CBC mode algorithm with AES 256 key. + * + * @param OutData_Text Output cipher text. + * @param OutData_length Output byte size of cipher. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CbcEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) +{ + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); + + return R_SCE_Aes256EncryptDecryptFinalSub(); +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES CBC mode algorithm with AES 256 key. + * + * @param InData_KeyIndex User key generation information area. + * @param InData_IV Input initial vector. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CbcDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) +{ + uint32_t indata_cmd = 0; + + if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(3); /* CBC-Decrypt command */ + + return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES CBC mode algorithm with AES 256 key. + * + * @param InData_Text Input cipher text. + * @param OutData_Text Output plain text. + * @param MAX_CNT Input byte size of cipher. + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CbcDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES CBC mode algorithm with AES 256 key. + * + * @param OutData_Text Output plain text. + * @param OutData_length Output byte size of plain. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CbcDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) +{ + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); + + return R_SCE_Aes256EncryptDecryptFinalSub(); +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES CTR mode algorithm with AES 128 key. + * + * @param InData_KeyIndex User key generation information area. + * @param InData_IV Input initial vector. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CtrEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) +{ + uint32_t indata_cmd = 0; + + if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(4); /* CTR-Encrypt command */ + + return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES CTR mode algorithm with AES 128 key. + * + * @param InData_Text Input plain text. + * @param OutData_Text Output cipher text. + * @param MAX_CNT Input byte size of plain. + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CtrEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES CTR mode algorithm with AES 128 key. + * + * @param OutData_Text Output cipher text. + * @param OutData_length Output byte size of cipher. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CtrEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) +{ + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); + + return R_SCE_Aes128EncryptDecryptFinalSub(); +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES CTR mode algorithm with AES 128 key. + * + * @param InData_KeyIndex User key generation information area. + * @param InData_IV Input initial vector. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CtrDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) +{ + uint32_t indata_cmd = 0; + + if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(4); /* CTR-Decrypt command */ + + return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES CTR mode algorithm with AES 128 key. + * + * @param InData_Text Input cipher text. + * @param OutData_Text Output plain text. + * @param MAX_CNT Input byte size of cipher. + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CtrDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES CTR mode algorithm with AES 128 key. + * + * @param OutData_Text Output plain text. + * @param OutData_length Output byte size of plain. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CtrDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) +{ + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); + + return R_SCE_Aes128EncryptDecryptFinalSub(); +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES CTR mode algorithm with AES 256 key. + * + * @param InData_KeyIndex User key generation information area. + * @param InData_IV Input initial vector. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CtrEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) +{ + uint32_t indata_cmd = 0; + + if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(4); /* CTR-Encrypt command */ + + return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES CTR mode algorithm with AES 256 key. + * + * @param InData_Text Input plain text. + * @param OutData_Text Output cipher text. + * @param MAX_CNT Input byte size of plain. + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CtrEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Encrypt data to cipher using AES CTR mode algorithm with AES 256 key. + * + * @param OutData_Text Output cipher text. + * @param OutData_length Output byte size of cipher. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CtrEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) +{ + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); + + return R_SCE_Aes256EncryptDecryptFinalSub(); +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES CTR mode algorithm with AES 256 key. + * + * @param InData_KeyIndex User key generation information area. + * @param InData_IV Input initial vector. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CtrDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) +{ + uint32_t indata_cmd = 0; + + if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(4); /* CTR-Decrypt command */ + + return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES CTR mode algorithm with AES 256 key. + * + * @param InData_Text Input cipher text. + * @param OutData_Text Output plain text. + * @param MAX_CNT Input byte size of cipher. + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CtrDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Decrypt data to plain using AES CTR mode algorithm with AES 256 key. + * + * @param OutData_Text Output plain text. + * @param OutData_length Output byte size of plain. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CtrDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) +{ + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); + + return R_SCE_Aes256EncryptDecryptFinalSub(); +} + +/*******************************************************************************************************************//** + * Prepare to execute AES calculation. + * + * @param InData_KeyIndex User key generation information area + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CmacGenerateInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) +{ + return R_SCE_Aes128CmacInitSub(InData_KeyIndex->value); +} + +/*******************************************************************************************************************//** + * Generates a MAC value from the message specified. + * + * @param InData_Text Message data area (data_len byte) + * @param MAX_CNT Message data length (0 to arbitrary byte) + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CmacGenerateUpdatePrivate (uint32_t * InData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes128CmacUpdateSub(InData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Outputs the Mac value. + * + * @param All_Msg_Len Input byte size of message data. + * @param InData_Text Input message data. + * @param OutData_DataT MAC data area (data_len byte) + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Reserved. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CmacGenerateFinalPrivate (uint32_t All_Msg_Len, uint32_t * InData_Text, uint32_t * OutData_DataT) +{ + uint32_t indata_cmd = 0; + uint32_t indata_datat[4] = /* dummy */ + { + 0 + }; + uint32_t indata_datat_len = 0; /* dummy */ + + if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) + { + indata_cmd = 0; + } + else + { + indata_cmd = 1; + } + + return R_SCE_Aes128CmacFinalSub(&indata_cmd, InData_Text, indata_datat, &indata_datat_len, OutData_DataT); +} + +/*******************************************************************************************************************//** + * Prepare to execute CMAC calculation. + * + * @param InData_KeyIndex User key generation information area + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CmacVerifyInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) +{ + return R_SCE_Aes128CmacInitSub(InData_KeyIndex->value); +} + +/*******************************************************************************************************************//** + * Verifies the MAC value. + * + * @param InData_Text Message data area (data_len byte) + * @param MAX_CNT Message data length (0 to arbitrary byte) + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CmacVerifyUpdatePrivate (uint32_t * InData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes128CmacUpdateSub(InData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Validates the Mac value. + * + * @param All_Msg_Len Input byte size of message data. + * @param InData_Text Input message data. + * @param InData_DataT MAC data area (data_len byte) + * @param InData_DataTLen MAC data length + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication NG + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes128CmacVerifyFinalPrivate (uint32_t All_Msg_Len, + uint32_t * InData_Text, + uint32_t * InData_DataT, + uint32_t * InData_DataTLen) +{ + uint32_t indata_cmd = 0; + uint32_t out_data[4] = + { + 0 + }; + + if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) + { + indata_cmd = 2; + } + else + { + indata_cmd = 3; + } + + return R_SCE_Aes128CmacFinalSub(&indata_cmd, InData_Text, InData_DataT, InData_DataTLen, out_data); +} + +/*******************************************************************************************************************//** + * Prepare to execute AES calculation. + * + * @param InData_KeyIndex User key generation information area + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CmacGenerateInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) +{ + return R_SCE_Aes256CmacInitSub(InData_KeyIndex->value); +} + +/*******************************************************************************************************************//** + * Generates a MAC value from the message specified. + * + * @param InData_Text Message data area (data_len byte) + * @param MAX_CNT Message data length (0 to arbitrary byte) + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CmacGenerateUpdatePrivate (uint32_t * InData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes256CmacUpdateSub(InData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Outputs the Mac value. + * + * @param All_Msg_Len Input byte size of message data. + * @param InData_Text Input message data. + * @param OutData_DataT MAC data area (data_len byte) + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Reserved. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CmacGenerateFinalPrivate (uint32_t All_Msg_Len, uint32_t * InData_Text, uint32_t * OutData_DataT) +{ + uint32_t indata_cmd = 0; + uint32_t indata_datat[4] = /* dummy */ + { + 0 + }; + uint32_t indata_datat_len = 0; /* dummy */ + + if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) + { + indata_cmd = 0; + } + else + { + indata_cmd = 1; + } + + return R_SCE_Aes256CmacFinalSub(&indata_cmd, InData_Text, indata_datat, &indata_datat_len, OutData_DataT); +} + +/*******************************************************************************************************************//** + * Prepare to execute CMAC calculation. + * + * @param InData_KeyIndex User key generation information area + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CmacVerifyInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) +{ + return R_SCE_Aes256CmacInitSub(InData_KeyIndex->value); +} + +/*******************************************************************************************************************//** + * Verifies the MAC value. + * + * @param InData_Text Message data area (data_len byte) + * @param MAX_CNT Message data length (0 to arbitrary byte) + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CmacVerifyUpdatePrivate (uint32_t * InData_Text, uint32_t MAX_CNT) +{ + R_SCE_Aes256CmacUpdateSub(InData_Text, MAX_CNT); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Validates the Mac value. + * + * @param All_Msg_Len Input byte size of message data. + * @param InData_Text Input message data. + * @param InData_DataT MAC data area (data_len byte) + * @param InData_DataTLen MAC data length + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication NG + **********************************************************************************************************************/ +fsp_err_t R_SCE_Aes256CmacVerifyFinalPrivate (uint32_t All_Msg_Len, + uint32_t * InData_Text, + uint32_t * InData_DataT, + uint32_t * InData_DataTLen) +{ + uint32_t indata_cmd = 0; + uint32_t out_data[4] = + { + 0 + }; + + if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) + { + indata_cmd = 2; + } + else + { + indata_cmd = 3; + } + + return R_SCE_Aes256CmacFinalSub(&indata_cmd, InData_Text, InData_DataT, InData_DataTLen, out_data); +} + +/*******************************************************************************************************************//** + * prepares to execute the SHA256 hash operation + * + * @param handle SHA256 handler (work area) + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Sha256InitPrivate (sce_sha_md5_handle_t * handle) +{ + uint32_t indata_sha256initval[8] = + { + 0 + }; + + FSP_PARAMETER_NOT_USED(handle); + + indata_sha256initval[0] = change_endian_long(SCE_HEX_6A09E667); + indata_sha256initval[1] = change_endian_long(SCE_HEX_BB67AE85); + indata_sha256initval[2] = change_endian_long(SCE_HEX_3C6EF372); + indata_sha256initval[3] = change_endian_long(SCE_HEX_A54FF53A); + indata_sha256initval[4] = change_endian_long(SCE_HEX_510E527F); + indata_sha256initval[5] = change_endian_long(SCE_HEX_9B05688C); + indata_sha256initval[6] = change_endian_long(SCE_HEX_1F83D9AB); + indata_sha256initval[7] = change_endian_long(SCE_HEX_5BE0CD19); + + memcpy(handle->current_hash, indata_sha256initval, HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * calculate a hash value + * + * @param handle SHA256 handler (work area) + * @param InData_PaddedMsg Input message. + * @param MAX_CNT Input message length + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + **********************************************************************************************************************/ +fsp_err_t R_SCE_Sha256UpdatePrivate (sce_sha_md5_handle_t * handle, uint32_t * InData_PaddedMsg, uint32_t MAX_CNT) +{ + uint32_t out_data[8] = + { + 0 + }; + fsp_err_t ercd = FSP_SUCCESS; + + FSP_PARAMETER_NOT_USED(handle); + + /*Casting uint32_t pointer is used for address.*/ + ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, + InData_PaddedMsg, + MAX_CNT, + out_data); + memcpy(handle->current_hash, out_data, HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE); + + return ercd; +} + +/*******************************************************************************************************************//** + * calculate a hash value + * + * @param handle SHA256 handler (work area). + * @param InData_PaddedMsg Input Message data + * @param MAX_CNT Input message length + * @param OutData_MsgDigest Output Hash data + * @param OutData_Length Output Hash length + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + **********************************************************************************************************************/ +fsp_err_t R_SCE_Sha256FinalPrivate (sce_sha_md5_handle_t * handle, + uint32_t * InData_PaddedMsg, + uint32_t MAX_CNT, + uint32_t * OutData_MsgDigest, + uint32_t * OutData_Length) +{ + fsp_err_t ercd = FSP_SUCCESS; + + FSP_PARAMETER_NOT_USED(handle); + + /*Casting uint32_t pointer is used for address.*/ + ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, + InData_PaddedMsg, + MAX_CNT, + OutData_MsgDigest); + memcpy(handle->current_hash, OutData_MsgDigest, HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE); + *OutData_Length = HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE; + + return ercd; +} + +/*******************************************************************************************************************//** + * prepares to execute the SHA224 hash operation + * + * @param handle SHA224 handler (work area) + * + * @retval FSP_SUCCESS Normal termination. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Sha224InitPrivate (sce_sha_md5_handle_t * handle) +{ + uint32_t indata_sha224initval[8] = + { + 0 + }; + + FSP_PARAMETER_NOT_USED(handle); + + indata_sha224initval[0] = change_endian_long(SCE_HEX_C1059ED8); + indata_sha224initval[1] = change_endian_long(SCE_HEX_367CD507); + indata_sha224initval[2] = change_endian_long(SCE_HEX_3070DD17); + indata_sha224initval[3] = change_endian_long(SCE_HEX_F70E5939); + indata_sha224initval[4] = change_endian_long(SCE_HEX_FFC00B31); + indata_sha224initval[5] = change_endian_long(SCE_HEX_68581511); + indata_sha224initval[6] = change_endian_long(SCE_HEX_64F98FA7); + indata_sha224initval[7] = change_endian_long(SCE_HEX_BEFA4FA4); + + memcpy(handle->current_hash, indata_sha224initval, HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE + 4); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * calculate a hash value + * + * @param handle SHA224 handler (work area) + * @param InData_PaddedMsg Input message. + * @param MAX_CNT Input message length + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + **********************************************************************************************************************/ +fsp_err_t R_SCE_Sha224UpdatePrivate (sce_sha_md5_handle_t * handle, uint32_t * InData_PaddedMsg, uint32_t MAX_CNT) +{ + uint32_t out_data[8] = + { + 0 + }; + fsp_err_t ercd = FSP_SUCCESS; + + FSP_PARAMETER_NOT_USED(handle); + + /*Casting uint32_t pointer is used for address.*/ + ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, + InData_PaddedMsg, + MAX_CNT, + out_data); + memcpy(handle->current_hash, out_data, HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE + 4); + + return ercd; +} + +/*******************************************************************************************************************//** + * calculate a hash value + * + * @param handle SHA224 handler (work area). + * @param InData_PaddedMsg Input Message data + * @param MAX_CNT Input message length + * @param OutData_MsgDigest Output Hash data + * @param OutData_Length Output Hash length + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + **********************************************************************************************************************/ +fsp_err_t R_SCE_Sha224FinalPrivate (sce_sha_md5_handle_t * handle, + uint32_t * InData_PaddedMsg, + uint32_t MAX_CNT, + uint32_t * OutData_MsgDigest, + uint32_t * OutData_Length) +{ + fsp_err_t ercd = FSP_SUCCESS; + + FSP_PARAMETER_NOT_USED(handle); + + /*Casting uint32_t pointer is used for address.*/ + ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, + InData_PaddedMsg, + MAX_CNT, + (uint32_t *) handle->current_hash); + memcpy(OutData_MsgDigest, handle->current_hash, HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE); + *OutData_Length = HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE; + + return ercd; +} + +/*******************************************************************************************************************//** + * Modular exponentiation operation with RSA 1024bit public key + * + * @param InData_KeyIndex the public key index information + * @param InData_Text input data + * @param OutData_Text output data + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + **********************************************************************************************************************/ +fsp_err_t R_SCE_Rsa1024ModularExponentEncryptPrivate (uint32_t * InData_KeyIndex, + uint32_t * InData_Text, + uint32_t * OutData_Text) +{ + return R_SCE_Rsa1024ModularExponentEncryptSub(InData_KeyIndex, InData_Text, OutData_Text); +} + +/*******************************************************************************************************************//** + * Modular exponentiation operation with RSA 1024bit private key + * + * @param InData_KeyIndex the private key index information + * @param InData_Text input data + * @param OutData_Text output data + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + **********************************************************************************************************************/ +fsp_err_t R_SCE_Rsa1024ModularExponentDecryptPrivate (uint32_t * InData_KeyIndex, + uint32_t * InData_Text, + uint32_t * OutData_Text) +{ + return R_SCE_Rsa1024ModularExponentDecryptSub(InData_KeyIndex, InData_Text, OutData_Text); +} + +/*******************************************************************************************************************//** + * Modular exponentiation operation with RSA 2048bit public key + * + * @param InData_KeyIndex the public key index information + * @param InData_Text input data + * @param OutData_Text output data + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + **********************************************************************************************************************/ +fsp_err_t R_SCE_Rsa2048ModularExponentEncryptPrivate (uint32_t * InData_KeyIndex, + uint32_t * InData_Text, + uint32_t * OutData_Text) +{ + return R_SCE_Rsa2048ModularExponentEncryptSub(InData_KeyIndex, InData_Text, OutData_Text); +} + +/*******************************************************************************************************************//** + * Modular exponentiation operation with RSA 2048bit private key + * + * @param InData_KeyIndex the private key index information + * @param InData_Text input data + * @param OutData_Text output data + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + **********************************************************************************************************************/ +fsp_err_t R_SCE_Rsa2048ModularExponentDecryptPrivate (uint32_t * InData_KeyIndex, + uint32_t * InData_Text, + uint32_t * OutData_Text) +{ + return R_SCE_Rsa2048ModularExponentDecryptSub(InData_KeyIndex, InData_Text, OutData_Text); +} + +/*******************************************************************************************************************//** + * Modular exponentiation operation with RSA 4096bit public key + * + * @param InData_KeyIndex the public key index information + * @param InData_Text input data + * @param OutData_Text output data + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + **********************************************************************************************************************/ +fsp_err_t R_SCE_Rsa4096ModularExponentEncryptPrivate (uint32_t * InData_KeyIndex, + uint32_t * InData_Text, + uint32_t * OutData_Text) +{ + return R_SCE_Rsa4096ModularExponentEncryptSub(InData_KeyIndex, InData_Text, OutData_Text); +} + +/*******************************************************************************************************************//** + * change endian + * + * @param data input data + * + * @return the data changing endian + **********************************************************************************************************************/ + +uint32_t change_endian_long (volatile uint32_t data) +{ + return ((((data) & 0xFF000000) >> 24) | (((data) & 0x00FF0000) >> 8) | (((data) & 0x0000FF00) << 8) | + (((data) & 0x000000FF) << 24)); +} \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce.c b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce.c new file mode 100644 index 000000000..931ba0ef1 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce.c @@ -0,0 +1,1447 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : r_sce.c + * Version : 1.0 + * Description : SCE Common Public API source file + *********************************************************************************************************************/ +/********************************************************************************************************************** + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release + *********************************************************************************************************************/ + + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include "r_sce_private.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ +#define HW_STATE_UNAVAILABLE (1) +#define HW_STATE_AVAILABLE (2) + +/* 5*(key_length/2)*2 is recommended by NIST FIPS186-4 */ +#define SCE_RSA_RETRY_COUNT_FOR_RSA1024_KEY_GENERATION (5*(1024/2)*2) +#define SCE_RSA_RETRY_COUNT_FOR_RSA2048_KEY_GENERATION (5*(2048/2)*2) + + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ +static lifecycle_t gs_lifecycle; + +/********************************************************************************************************************** + Global variables + *********************************************************************************************************************/ +uint32_t S_RAM[HW_SCE_SRAM_WORD_SIZE]; +uint32_t S_HEAP[HW_SCE_SHEAP_WORD_SIZE]; +uint32_t S_INST2[HW_SCE_SINST2_WORD_SIZE]; + +uint32_t g_private_id_counter; +extern uint32_t g_aes128ecbenc_private_id; +extern uint32_t g_aes128ecbdec_private_id; +extern uint32_t g_aes256ecbenc_private_id; +extern uint32_t g_aes256ecbdec_private_id; +extern uint32_t g_aes128cbcenc_private_id; +extern uint32_t g_aes128cbcdec_private_id; +extern uint32_t g_aes256cbcenc_private_id; +extern uint32_t g_aes256cbcdec_private_id; +extern uint32_t g_aes128ctrenc_private_id; +extern uint32_t g_aes128ctrdec_private_id; +extern uint32_t g_aes256ctrenc_private_id; +extern uint32_t g_aes256ctrdec_private_id; +extern uint32_t g_aes128cmacgen_private_id; +extern uint32_t g_aes128cmacver_private_id; +extern uint32_t g_aes256cmacgen_private_id; +extern uint32_t g_aes256cmacver_private_id; +extern uint32_t g_sha224_private_id; +extern uint32_t g_sha256_private_id; + +const sce_api_t g_sce_protected_on_sce = +{ + .open = R_SCE_Open, + .close = R_SCE_Close, + .softwareReset = R_SCE_SoftwareReset, + .randomNumberGenerate = R_SCE_RandomNumberGenerate, + .AES128_WrappedKeyGenerate = R_SCE_AES128_WrappedKeyGenerate, + .AES256_WrappedKeyGenerate = R_SCE_AES256_WrappedKeyGenerate, + .AES128_EncryptedKeyWrap = R_SCE_AES128_EncryptedKeyWrap, + .AES256_EncryptedKeyWrap = R_SCE_AES256_EncryptedKeyWrap, + .AES128ECB_EncryptInit = R_SCE_AES128ECB_EncryptInit, + .AES128ECB_EncryptUpdate = R_SCE_AES128ECB_EncryptUpdate, + .AES128ECB_EncryptFinal = R_SCE_AES128ECB_EncryptFinal, + .AES128ECB_DecryptInit = R_SCE_AES128ECB_DecryptInit, + .AES128ECB_DecryptUpdate = R_SCE_AES128ECB_DecryptUpdate, + .AES128ECB_DecryptFinal = R_SCE_AES128ECB_DecryptFinal, + .AES256ECB_EncryptInit = R_SCE_AES256ECB_EncryptInit, + .AES256ECB_EncryptUpdate = R_SCE_AES256ECB_EncryptUpdate, + .AES256ECB_EncryptFinal = R_SCE_AES256ECB_EncryptFinal, + .AES256ECB_DecryptInit = R_SCE_AES256ECB_DecryptInit, + .AES256ECB_DecryptUpdate = R_SCE_AES256ECB_DecryptUpdate, + .AES256ECB_DecryptFinal = R_SCE_AES256ECB_DecryptFinal, + .AES128CBC_EncryptInit = R_SCE_AES128CBC_EncryptInit, + .AES128CBC_EncryptUpdate = R_SCE_AES128CBC_EncryptUpdate, + .AES128CBC_EncryptFinal = R_SCE_AES128CBC_EncryptFinal, + .AES128CBC_DecryptInit = R_SCE_AES128CBC_DecryptInit, + .AES128CBC_DecryptUpdate = R_SCE_AES128CBC_DecryptUpdate, + .AES128CBC_DecryptFinal = R_SCE_AES128CBC_DecryptFinal, + .AES256CBC_EncryptInit = R_SCE_AES256CBC_EncryptInit, + .AES256CBC_EncryptUpdate = R_SCE_AES256CBC_EncryptUpdate, + .AES256CBC_EncryptFinal = R_SCE_AES256CBC_EncryptFinal, + .AES256CBC_DecryptInit = R_SCE_AES256CBC_DecryptInit, + .AES256CBC_DecryptUpdate = R_SCE_AES256CBC_DecryptUpdate, + .AES256CBC_DecryptFinal = R_SCE_AES256CBC_DecryptFinal, + .AES128CTR_EncryptInit = R_SCE_AES128CTR_EncryptInit, + .AES128CTR_EncryptUpdate = R_SCE_AES128CTR_EncryptUpdate, + .AES128CTR_EncryptFinal = R_SCE_AES128CTR_EncryptFinal, + .AES128CTR_DecryptInit = R_SCE_AES128CTR_DecryptInit, + .AES128CTR_DecryptUpdate = R_SCE_AES128CTR_DecryptUpdate, + .AES128CTR_DecryptFinal = R_SCE_AES128CTR_DecryptFinal, + .AES256CTR_EncryptInit = R_SCE_AES256CTR_EncryptInit, + .AES256CTR_EncryptUpdate = R_SCE_AES256CTR_EncryptUpdate, + .AES256CTR_EncryptFinal = R_SCE_AES256CTR_EncryptFinal, + .AES256CTR_DecryptInit = R_SCE_AES256CTR_DecryptInit, + .AES256CTR_DecryptUpdate = R_SCE_AES256CTR_DecryptUpdate, + .AES256CTR_DecryptFinal = R_SCE_AES256CTR_DecryptFinal, + .AES128CMAC_GenerateInit = R_SCE_AES128CMAC_GenerateInit, + .AES128CMAC_GenerateUpdate = R_SCE_AES128CMAC_GenerateUpdate, + .AES128CMAC_GenerateFinal = R_SCE_AES128CMAC_GenerateFinal, + .AES128CMAC_VerifyInit = R_SCE_AES128CMAC_VerifyInit, + .AES128CMAC_VerifyUpdate = R_SCE_AES128CMAC_VerifyUpdate, + .AES128CMAC_VerifyFinal = R_SCE_AES128CMAC_VerifyFinal, + .AES256CMAC_GenerateInit = R_SCE_AES256CMAC_GenerateInit, + .AES256CMAC_GenerateUpdate = R_SCE_AES256CMAC_GenerateUpdate, + .AES256CMAC_GenerateFinal = R_SCE_AES256CMAC_GenerateFinal, + .AES256CMAC_VerifyInit = R_SCE_AES256CMAC_VerifyInit, + .AES256CMAC_VerifyUpdate = R_SCE_AES256CMAC_VerifyUpdate, + .AES256CMAC_VerifyFinal = R_SCE_AES256CMAC_VerifyFinal, + .SHA224_Init = R_SCE_SHA224_Init, + .SHA224_Update = R_SCE_SHA224_Update, + .SHA224_Final = R_SCE_SHA224_Final, + .SHA256_Init = R_SCE_SHA256_Init, + .SHA256_Update = R_SCE_SHA256_Update, + .SHA256_Final = R_SCE_SHA256_Final, + .RSA1024_WrappedKeyPairGenerate = R_SCE_RSA1024_WrappedKeyPairGenerate, + .RSA2048_WrappedKeyPairGenerate = R_SCE_RSA2048_WrappedKeyPairGenerate, + .RSA1024_EncryptedPublicKeyWrap = R_SCE_RSA1024_EncryptedPublicKeyWrap, + .RSA1024_EncryptedPrivateKeyWrap = R_SCE_RSA1024_EncryptedPrivateKeyWrap, + .RSA2048_EncryptedPublicKeyWrap = R_SCE_RSA2048_EncryptedPublicKeyWrap, + .RSA2048_EncryptedPrivateKeyWrap = R_SCE_RSA2048_EncryptedPrivateKeyWrap, + .RSA4096_EncryptedPublicKeyWrap = R_SCE_RSA4096_EncryptedPublicKeyWrap, + .RSASSA_PKCS1024_SignatureGenerate = R_SCE_RSASSA_PKCS1024_SignatureGenerate, + .RSASSA_PKCS2048_SignatureGenerate = R_SCE_RSASSA_PKCS2048_SignatureGenerate, + .RSASSA_PKCS1024_SignatureVerify = R_SCE_RSASSA_PKCS1024_SignatureVerify, + .RSASSA_PKCS2048_SignatureVerify = R_SCE_RSASSA_PKCS2048_SignatureVerify, + .RSASSA_PKCS4096_SignatureVerify = R_SCE_RSASSA_PKCS4096_SignatureVerify, + .RSAES_PKCS1024_Encrypt = R_SCE_RSAES_PKCS1024_Encrypt, + .RSAES_PKCS2048_Encrypt = R_SCE_RSAES_PKCS2048_Encrypt, + .RSAES_PKCS4096_Encrypt = R_SCE_RSAES_PKCS4096_Encrypt, + .RSAES_PKCS1024_Decrypt = R_SCE_RSAES_PKCS1024_Decrypt, + .RSAES_PKCS2048_Decrypt = R_SCE_RSAES_PKCS2048_Decrypt, + .ECC_secp192r1_WrappedKeyPairGenerate = R_SCE_ECC_secp192r1_WrappedKeyPairGenerate, + .ECC_secp224r1_WrappedKeyPairGenerate = R_SCE_ECC_secp224r1_WrappedKeyPairGenerate, + .ECC_secp256r1_WrappedKeyPairGenerate = R_SCE_ECC_secp256r1_WrappedKeyPairGenerate, + .ECC_BrainpoolP512r1_WrappedKeyPairGenerate = R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate, + .ECC_secp192r1_EncryptedPublicKeyWrap = R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap, + .ECC_secp224r1_EncryptedPublicKeyWrap = R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap, + .ECC_secp256r1_EncryptedPublicKeyWrap = R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap, + .ECC_BrainpoolP512r1_EncryptedPublicKeyWrap = R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap, + .ECC_secp192r1_EncryptedPrivateKeyWrap = R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap, + .ECC_secp224r1_EncryptedPrivateKeyWrap = R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap, + .ECC_secp256r1_EncryptedPrivateKeyWrap = R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap, + .ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap = R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap, + .ECDSA_secp192r1_SignatureGenerate = R_SCE_ECDSA_secp192r1_SignatureGenerate, + .ECDSA_secp224r1_SignatureGenerate = R_SCE_ECDSA_secp224r1_SignatureGenerate, + .ECDSA_secp256r1_SignatureGenerate = R_SCE_ECDSA_secp256r1_SignatureGenerate, + .ECDSA_BrainpoolP512r1_SignatureGenerate = R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate, + .ECDSA_secp192r1_SignatureVerify = R_SCE_ECDSA_secp192r1_SignatureVerify, + .ECDSA_secp224r1_SignatureVerify = R_SCE_ECDSA_secp224r1_SignatureVerify, + .ECDSA_secp256r1_SignatureVerify = R_SCE_ECDSA_secp256r1_SignatureVerify, + .ECDSA_BrainpoolP512r1_SignatureVerify = R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify, +}; + +/*******************************************************************************************************************//** + * @addtogroup SCE_PROTECTED + * @{ + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Enables use of SCE functionality. + * + * @param[in] p_ctrl Pointer to control structure. + * @param[in] p_cfg Pointer to pin configuration structure. + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL The error-detection self-test failed to terminate normally. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_RETRY Indicates that an entropy evaluation failure occurred. + * Run the function again. + * + * @return See @ref RENESAS_ERROR_CODES or functions called by this function for other possible return codes. + * + * @note The valid pre-run state is SCE disabled. + * The pre-run state is SCE Disabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Open (sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg) +{ + fsp_err_t error_code = FSP_SUCCESS; + uint32_t state; + + sce_instance_ctrl_t * p_instance_ctrl = (sce_instance_ctrl_t *) p_ctrl; + p_instance_ctrl->open = 1; + gs_lifecycle = p_cfg->lifecycle; + + /* Check for need to do self-test */ + error_code = R_SCE_StateCheckSub(&state); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + if (HW_STATE_UNAVAILABLE == state) + { + error_code = R_SCE_SelfCheck2Private(); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + } + + g_private_id_counter = 0; + g_aes128ecbenc_private_id = 0; + g_aes128ecbdec_private_id = 0; + g_aes256ecbenc_private_id = 0; + g_aes256ecbdec_private_id = 0; + g_aes128cbcenc_private_id = 0; + g_aes128cbcdec_private_id = 0; + g_aes256cbcenc_private_id = 0; + g_aes256cbcdec_private_id = 0; + g_aes128ctrenc_private_id = 0; + g_aes128ctrdec_private_id = 0; + g_aes256ctrenc_private_id = 0; + g_aes256ctrdec_private_id = 0; + g_aes128cmacgen_private_id = 0; + g_aes128cmacver_private_id = 0; + g_aes256cmacgen_private_id = 0; + g_aes256cmacver_private_id = 0; + g_sha224_private_id = 0; + g_sha256_private_id = 0; + + return error_code; +} + +/*******************************************************************************************************************//** + * Stops supply of power to the SCE. + * + * @param[in] p_ctrl Pointer to control structure. + * + * @retval FSP_SUCCESS Normal termination + * + * @note The pre-run state is any state. + * After the function runs the state transitions to SCE Disabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_Close (sce_ctrl_t * const p_ctrl) +{ + sce_instance_ctrl_t * p_instance_ctrl = (sce_instance_ctrl_t *) p_ctrl; + p_instance_ctrl->open = 0; + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Software reset to SCE. + * + * Reverts the state to the SCE initial state. + * + * @retval FSP_SUCCESS Normal termination + * + * @note The pre-run state is any state. + * After the function runs the state transitions to SCE Disabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_SoftwareReset (void) +{ + R_SCE_SoftwareResetSub(); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * This API can generate 4 words random number. + * + * @param[in,out] random Stores 4words (16 bytes) random data. + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RandomNumberGenerate (uint32_t * random) +{ + return R_SCE_GenerateRandomNumberSub(random); +} + +/*******************************************************************************************************************//** + * This API outputs 128-bit AES wrapped key from a random number. + * + * This API generates a wrapped key from a random number in the SCE. Accordingly, user key input is unnecessary. + * By encrypting data using the wrapped key is output by this API, dead copying of data can be prevented. + * + * @param[in,out] wrapped_key 128-bit AES wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Disabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128_WrappedKeyGenerate (sce_aes_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + error_code = R_SCE_GenerateAes128RandomKeyIndexSub(wrapped_key->value); + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_AES128; + } + else if (FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + else + { + /* not used */ + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API outputs 256-bit AES wrapped key from a random number. + * + * This API generates a wrapped key from a random number in the SCE. Accordingly, user key input is unnecessary. + * By encrypting data using the wrapped key is output by this API, dead copying of data can be prevented. + * + * @param[in,out] wrapped_key 256-bit AES wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Disabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256_WrappedKeyGenerate (sce_aes_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + error_code = R_SCE_GenerateAes256RandomKeyIndexSub(wrapped_key->value); + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_AES256; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps 128-bit AES key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 128-bit AES wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128_EncryptedKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_aes_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_AES128; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_AES128; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps 256-bit AES key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 256-bit AES wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256_EncryptedKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_aes_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_AES256; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_AES256; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API outputs a wrapped key pair for a 1024-bit RSA public key and private key pair. These keys are generated + * from a random value produced internally by the SCE. Consequently, there is no need to input a user key. + * Dead copying of data can be prevented by encrypting the data using the wrapped key output by this API. + * A public wrapped key is generated by wrapped_pair_key->pub_key, and a private wrapped key is generated by + * wrapped_pair_key->priv_key. As the public key exponent, only 0x00010001 is generated. + * + * @param [in,out] wrapped_pair_key User key index for RSA 1024-bit public key and private key pair + * + * @retval FSP_SUCCESS Normal end + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. Key generation failed. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSA1024_WrappedKeyPairGenerate (sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + error_code = R_SCE_GenerateRsa1024RandomKeyIndexSub(SCE_RSA_RETRY_COUNT_FOR_RSA1024_KEY_GENERATION, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_pair_key->pub_key.value, + (uint32_t *) &wrapped_pair_key->priv_key.value); + if (FSP_SUCCESS == error_code) + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE; + } + else + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API outputs a wrapped key pair for a 2048-bit RSA public key and private key pair. These keys are generated + * from a random value produced internally by the SCE. Consequently, there is no need to input a user key. + * Dead copying of data can be prevented by encrypting the data using the wrapped key output by this API. + * A public wrapped key is generated by wrapped_pair_key->pub_key, and a private wrapped key is generated by + * wrapped_pair_key->priv_key. As the public key exponent, only 0x00010001 is generated. + * + * @param [in,out] wrapped_pair_key User key index for RSA 2048-bit public key and private key pair + * + * @retval FSP_SUCCESS Normal end + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. Key generation failed. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSA2048_WrappedKeyPairGenerate (sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + error_code = R_SCE_GenerateRsa2048RandomKeyIndexSub(SCE_RSA_RETRY_COUNT_FOR_RSA2048_KEY_GENERATION, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_pair_key->pub_key.value, + (uint32_t *) &wrapped_pair_key->priv_key.value); + if (FSP_SUCCESS == error_code) + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE; + } + else + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps 1024-bit RSA public key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 1024-bit RSA public wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_public_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA1024_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps 1024-bit RSA private key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 1024-bit RSA private wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_private_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA1024_PRIVATE; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps 2048-bit RSA public key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 1024-bit RSA public wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_public_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA2048_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps 2048-bit RSA private key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 2048-bit RSA private wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_private_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA2048_PRIVATE; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps 4096-bit RSA public key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 1024-bit RSA public wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa4096_public_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA4096_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA4096_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This is an API for outputting a wrapped key pair for secp192r1 public key and private key pair. + * These keys are generated from a random number value internally within the SCE. + * There is therefore no need to input user keys. It is possible to prevent dead copying of data by using the + * wrapped key output by this API to encrypt the data. The public key index is generated in wrapped_pair_key->pub_key, + * and the private key index is generated in wrapped_pair_key->priv_key. + * + * @param[in,out] wrapped_pair_key Wrapped pair key for secp192r1 public key and private key pair + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECC_secp192r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * wrapped_pair_key) +{ + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_GenerateEccRandomKeyIndexSub(&curvetype, + /* Casting uint32_t pointer is used for address. */ + &indata_cmd, + (uint32_t *) &wrapped_pair_key->pub_key.value, + (uint32_t *) &wrapped_pair_key->priv_key.value); + if (FSP_SUCCESS == error_code) + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE; + } + else + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This is an API for outputting a wrapped key pair for secp224r1 public key and private key pair. + * These keys are generated from a random number value internally within the SCE. + * There is therefore no need to input user keys. It is possible to prevent dead copying of data by using the + * wrapped key output by this API to encrypt the data. The public key index is generated in wrapped_pair_key->pub_key, + * and the private key index is generated in wrapped_pair_key->priv_key. + * + * @param[in,out] wrapped_pair_key Wrapped pair key for secp224r1 public key and private key pair + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECC_secp224r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * wrapped_pair_key) +{ + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_GenerateEccRandomKeyIndexSub(&curvetype, + /* Casting uint32_t pointer is used for address. */ + &indata_cmd, + (uint32_t *) &wrapped_pair_key->pub_key.value, + (uint32_t *) &wrapped_pair_key->priv_key.value); + if (FSP_SUCCESS == error_code) + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE; + } + else + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This is an API for outputting a wrapped key pair for secp256r1 public key and private key pair. + * These keys are generated from a random number value internally within the SCE. + * There is therefore no need to input user keys. It is possible to prevent dead copying of data by using the + * wrapped key output by this API to encrypt the data. The public key index is generated in wrapped_pair_key->pub_key, + * and the private key index is generated in wrapped_pair_key->priv_key. + * + * @param[in,out] wrapped_pair_key Wrapped pair key for secp256r1 public key and private key pair + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECC_secp256r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * wrapped_pair_key) +{ + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_GenerateEccRandomKeyIndexSub(&curvetype, + /* Casting uint32_t pointer is used for address. */ + &indata_cmd, + (uint32_t *) &wrapped_pair_key->pub_key.value, + (uint32_t *) &wrapped_pair_key->priv_key.value); + if (FSP_SUCCESS == error_code) + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE; + } + else + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This is an API for outputting a wrapped key pair for BrainpoolP512r1 public key and private key pair. + * These keys are generated from a random number value internally within the SCE. + * There is therefore no need to input user keys. It is possible to prevent dead copying of data by using the + * wrapped key output by this API to encrypt the data. The public key index is generated in wrapped_pair_key->pub_key, + * and the private key index is generated in wrapped_pair_key->priv_key. + * + * @param[in,out] wrapped_pair_key Wrapped pair key for BrainpoolP512r1 public key and private key pair + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * wrapped_pair_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + + error_code = R_SCE_GenerateEccP512RandomKeyIndexSub( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_pair_key->pub_key.value, + (uint32_t *) &wrapped_pair_key->priv_key.value); + if (FSP_SUCCESS == error_code) + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE; + } + else + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps secp192r1 public key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp192r1 public wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P192_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps secp224r1 public key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp224r1 public wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P224_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps secp256r1 public key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp256r1 public wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P256_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps BrainpoolP512r1 public key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key BrainpoolP512r1 public wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P512_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps secp192r1 private key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp192r1 private wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P192_PRIVATE; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps secp224r1 private key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp224r1 private wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P224_PRIVATE; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps secp256r1 private key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp256r1 private wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P256_PRIVATE; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * This API wraps BrainpoolP512r1 private key within the user routine. + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key BrainpoolP512r1 private wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P512_PRIVATE; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; +} + +/*******************************************************************************************************************//** + * @} (end addtogroup SCE_PROTECTED) + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Self check No2 + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RETRY self-test2 fail + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + **********************************************************************************************************************/ +fsp_err_t R_SCE_SelfCheck2Private (void) +{ + return R_SCE_SelfCheck2Sub(); +} + +/*******************************************************************************************************************//** + * This API Updates OEM key index (wrapped key). + * + * @param[in] lifecycle (no use) + * @param[in] key_type User key type define in sce_oem_cmd_t + * @param[in] encrypted_oem_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key wrapped key + * + * @retval FSP_SUCCESS + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT + * @retval FSP_ERR_CRYPTO_SCE_FAIL + **********************************************************************************************************************/ +fsp_err_t R_SCE_UpdateOemKeyIndexPrivate (lifecycle_t lifecycle, + sce_oem_cmd_t key_type, + uint8_t * iv, + uint8_t * encrypted_oem_key, + uint32_t * key_index) +{ + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + + FSP_PARAMETER_NOT_USED(lifecycle); + + switch (key_type) + { + case SCE_OEM_CMD_AES128: + error_code = R_SCE_AES128_EncryptedKeyWrapSub((uint32_t *) iv, (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_AES256: + error_code = R_SCE_AES256_EncryptedKeyWrapSub((uint32_t *) iv, (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_RSA1024_PUBLIC: + error_code = R_SCE_RSA1024_EncryptedPublicKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_RSA1024_PRIVATE: + error_code = R_SCE_RSA1024_EncryptedPrivateKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_RSA2048_PUBLIC: + error_code = R_SCE_RSA2048_EncryptedPublicKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_RSA2048_PRIVATE: + error_code = R_SCE_RSA2048_EncryptedPrivateKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_RSA4096_PUBLIC: + error_code = R_SCE_RSA4096_EncryptedPublicKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_ECC_P192_PUBLIC: + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(&curvetype, + &indata_cmd, + (uint32_t *) iv, + (uint32_t *) encrypted_oem_key, + key_index); + break; + case SCE_OEM_CMD_ECC_P224_PUBLIC: + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(&curvetype, + &indata_cmd, + (uint32_t *) iv, + (uint32_t *) encrypted_oem_key, + key_index); + break; + case SCE_OEM_CMD_ECC_P256_PUBLIC: + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(&curvetype, + &indata_cmd, + (uint32_t *) iv, + (uint32_t *) encrypted_oem_key, + key_index); + break; + case SCE_OEM_CMD_ECC_P512_PUBLIC: + error_code = R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_ECC_P192_PRIVATE: + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(&curvetype, + &indata_cmd, + (uint32_t *) iv, + (uint32_t *) encrypted_oem_key, + key_index); + break; + case SCE_OEM_CMD_ECC_P224_PRIVATE: + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(&curvetype, + &indata_cmd, + (uint32_t *) iv, + (uint32_t *) encrypted_oem_key, + key_index); + break; + case SCE_OEM_CMD_ECC_P256_PRIVATE: + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(&curvetype, + &indata_cmd, + (uint32_t *) iv, + (uint32_t *) encrypted_oem_key, + key_index); + break; + case SCE_OEM_CMD_ECC_P512_PRIVATE: + error_code = R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + default: + error_code = FSP_ERR_CRYPTO_SCE_FAIL; /* Not support Key type */ + break; + } + + return error_code; +} diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_aes.c b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_aes.c new file mode 100644 index 000000000..a630e513c --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_aes.c @@ -0,0 +1,2174 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : r_sce_aes.c + * Version : 1.0 + * Description : SCE AES Public API source file + *********************************************************************************************************************/ +/********************************************************************************************************************** + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include "r_sce_private.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* Initialization function call state */ +#define CALL_ONLY_INIT (0) +#define CALL_ONLY_UPDATE_FINAL (1) + +/* Magic numbers */ +#ifndef SCE_HEX_E000000 +#define SCE_HEX_E000000 (0xe000000U) +#endif +#ifndef SCE_DEC_110 +#define SCE_DEC_110 (110) +#endif + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ +static void cal_current_ivec_ctrmode(sce_aes_handle_t *handle , uint32_t block_num); + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ +extern uint32_t g_private_id_counter; +uint32_t g_aes128ecbenc_private_id; +uint32_t g_aes128ecbdec_private_id; +uint32_t g_aes256ecbenc_private_id; +uint32_t g_aes256ecbdec_private_id; +uint32_t g_aes128cbcenc_private_id; +uint32_t g_aes128cbcdec_private_id; +uint32_t g_aes256cbcenc_private_id; +uint32_t g_aes256cbcdec_private_id; +uint32_t g_aes128ctrenc_private_id; +uint32_t g_aes128ctrdec_private_id; +uint32_t g_aes256ctrenc_private_id; +uint32_t g_aes256ctrdec_private_id; +uint32_t g_aes128cmacgen_private_id; +uint32_t g_aes128cmacver_private_id; +uint32_t g_aes256cmacgen_private_id; +uint32_t g_aes256cmacver_private_id; + +/*******************************************************************************************************************//** + * @addtogroup SCE_PROTECTED + * @{ + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * The R_SCE_AES128ECB_EncryptInit() function performs preparations for the execution of an AES calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument + * in the subsequent R_SCE_AES128ECB_EncryptUpdate() function and R_SCE_AES128ECB_EncryptFinal() function. + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128ECB_EncryptInit (sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) +{ + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128ecbenc_private_id = g_private_id_counter; + handle->id = g_aes128ecbenc_private_id; + + return R_SCE_Aes128EcbEncryptInitPrivate(wrapped_key); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128ECB_EncryptUpdate() function encrypts the second argument, plain, utilizing the key index stored + * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. + * In addition, it writes the encryption result to the third argument, cipher. After plaintext input is completed, + * call R_SCE_AES128ECB_EncryptFinal(). + * + * Specify areas for plain and cipher that do not overlap. For plain and cipher, + * specify RAM addresses that are multiples of 4. + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128ECB_EncryptUpdate (sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128ecbenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + memcpy(handle->last_1_block_as_fraction, + (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + handle->current_input_data_size = plain_length; + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128EcbEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_AES128ECB_EncryptFinal() function writes + * the calculation result to the second argument, cipher, and writes the length of the calculation result + * to the third argument, cipher_length. The original intent was for a portion of the encryption + * result that was not a multiple of 16 bytes to be written to the second argument. + * However, as a result of the restriction that only multiples of 16 can be input to the Update function, + * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length + * are provided for compatibility in anticipation of the time when this restriction is lifted. + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128ECB_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128ecbenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *cipher_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128EcbEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128ECB_DecryptInit() function performs preparations for the execution of an AES calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument + * in the subsequent R_SCE_AES128ECB_DecryptUpdate() function and R_SCE_AES128ECB_DecryptFinal() function. + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128ECB_DecryptInit (sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) +{ + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128ecbdec_private_id = g_private_id_counter; + handle->id = g_aes128ecbdec_private_id; + + return R_SCE_Aes128EcbDecryptInitPrivate(wrapped_key); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128ECB_DecryptUpdate() function decrypts the second argument, cipher, utilizing the key index stored + * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. + * In addition, it writes the decryption result to the third argument, plain. After plaintext input is completed, + * call R_SCE_AES128ECB_DecryptFinal(). + * + * Specify areas for plain and cipher that do not overlap. For plain and cipher, + * specify RAM addresses that are multiples of 4. + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128ECB_DecryptUpdate (sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128ecbdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = cipher_length; + memcpy(handle->last_1_block_as_fraction, + (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128EcbDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_AES128ECB_DecryptFinal() function writes + * the calculation result to the second argument, plain, and writes the length of the calculation result + * to the third argument, plain_length. The original intent was for a portion of the decryption + * result that was not a multiple of 16 bytes to be written to the second argument. + * However, as a result of the restriction that only multiples of 16 can be input to the Update function, + * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length + * are provided for compatibility in anticipation of the time when this restriction is lifted. + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128ECB_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128ecbdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *plain_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128EcbDecryptFinalPrivate((uint32_t *) (plain), plain_length); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256ECB_EncryptInit() function performs preparations for the execution of an AES calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument + * in the subsequent R_SCE_AES256ECB_EncryptUpdate() function and R_SCE_AES256ECB_EncryptFinal() function. + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256ECB_EncryptInit (sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) +{ + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256ecbenc_private_id = g_private_id_counter; + handle->id = g_aes256ecbenc_private_id; + + return R_SCE_Aes256EcbEncryptInitPrivate(wrapped_key); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256ECB_EncryptUpdate() function encrypts the second argument, plain, utilizing the key index stored + * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. + * In addition, it writes the encryption result to the third argument, cipher. After plaintext input is completed, + * call R_SCE_AES256ECB_EncryptFinal(). + * + * Specify areas for plain and cipher that do not overlap. For plain and cipher, + * specify RAM addresses that are multiples of 4. + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256ECB_EncryptUpdate (sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256ecbenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = plain_length; + memcpy(handle->last_1_block_as_fraction, + (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256EcbEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_AES256ECB_EncryptFinal() function writes + * the calculation result to the second argument, cipher, and writes the length of the calculation result + * to the third argument, cipher_length. The original intent was for a portion of the encryption + * result that was not a multiple of 16 bytes to be written to the second argument. + * However, as a result of the restriction that only multiples of 16 can be input to the Update function, + * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length + * are provided for compatibility in anticipation of the time when this restriction is lifted. + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256ECB_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256ecbenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *cipher_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256EcbEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256ECB_DecryptInit() function performs preparations for the execution of an AES calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument + * in the subsequent R_SCE_AES128ECB_DecryptUpdate() function and R_SCE_AES128ECB_DecryptFinal() function. + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256ECB_DecryptInit (sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) +{ + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256ecbdec_private_id = g_private_id_counter; + handle->id = g_aes256ecbdec_private_id; + return R_SCE_Aes256EcbDecryptInitPrivate(wrapped_key); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256ECB_DecryptUpdate() function decrypts the second argument, cipher, utilizing the key index stored + * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. + * In addition, it writes the decryption result to the third argument, plain. After plaintext input is completed, + * call R_SCE_AES256ECB_DecryptFinal(). + * + * Specify areas for plain and cipher that do not overlap. For plain and cipher, + * specify RAM addresses that are multiples of 4. + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256ECB_DecryptUpdate (sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256ecbdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = cipher_length; + memcpy(handle->last_1_block_as_fraction, + (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256EcbDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_AES256ECB_DecryptFinal() function writes + * the calculation result to the second argument, plain, and writes the length of the calculation result + * to the third argument, plain_length. The original intent was for a portion of the decryption + * result that was not a multiple of 16 bytes to be written to the second argument. + * However, as a result of the restriction that only multiples of 16 can be input to the Update function, + * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length + * are provided for compatibility in anticipation of the time when this restriction is lifted. + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256ECB_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256ecbdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *plain_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256EcbDecryptFinalPrivate((uint32_t *) (plain), plain_length); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CBC_EncryptInit() function performs preparations for the execution of an AES calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument + * in the subsequent R_SCE_AES128CBC_EncryptUpdate() function and R_SCE_AES128CBC_EncryptFinal() function. + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initialization vector area (16byte) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CBC_EncryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) +{ + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128cbcenc_private_id = g_private_id_counter; + handle->id = g_aes128cbcenc_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CbcEncryptInitPrivate(wrapped_key, (uint32_t *) (initial_vector)); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CBC_EncryptUpdate() function encrypts the second argument, plain, utilizing the key index stored + * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. + * In addition, it writes the encryption result to the third argument, cipher. After plaintext input is completed, + * call R_SCE_AES128CBC_EncryptFinal(). + * + * Specify areas for plain and cipher that do not overlap. For plain and cipher, + * specify RAM addresses that are multiples of 4. + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CBC_EncryptUpdate (sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128cbcenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = plain_length; + memcpy(handle->last_1_block_as_fraction, + (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes128CbcEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); + memcpy(handle->current_initial_vector, + (cipher + (plain_length - HW_SCE_AES_BLOCK_BYTE_SIZE)), + HW_SCE_AES_CBC_IV_BYTE_SIZE); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_AES128CBC_EncryptFinal() function writes + * the calculation result to the second argument, cipher, and writes the length of the calculation result + * to the third argument, cipher_length. The original intent was for a portion of the encryption + * result that was not a multiple of 16 bytes to be written to the second argument. + * However, as a result of the restriction that only multiples of 16 can be input to the Update function, + * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length + * are provided for compatibility in anticipation of the time when this restriction is lifted. + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CBC_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128cbcenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *cipher_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CbcEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CBC_DecryptInit() function performs preparations for the execution of an AES calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument + * in the subsequent R_SCE_AES128CBC_DecryptUpdate() function and R_SCE_AES128CBC_DecryptFinal() function. + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initialization vector area (16byte) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CBC_DecryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) +{ + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128cbcdec_private_id = g_private_id_counter; + handle->id = g_aes128cbcdec_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CbcDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CBC_DecryptUpdate() function decrypts the second argument, cipher, utilizing the key index stored + * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. + * In addition, it writes the decryption result to the third argument, plain. After plaintext input is completed, + * call R_SCE_AES128CBC_DecryptFinal(). + * + * Specify areas for plain and cipher that do not overlap. For plain and cipher, + * specify RAM addresses that are multiples of 4. + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CBC_DecryptUpdate (sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128cbcdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = cipher_length; + memcpy(handle->last_1_block_as_fraction, + (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes128CbcDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); + memcpy(handle->current_initial_vector, + (plain + (cipher_length - HW_SCE_AES_BLOCK_BYTE_SIZE)), + HW_SCE_AES_CBC_IV_BYTE_SIZE); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_AES128CBC_DecryptFinal() function writes + * the calculation result to the second argument, plain, and writes the length of the calculation result + * to the third argument, plain_length. The original intent was for a portion of the decryption + * result that was not a multiple of 16 bytes to be written to the second argument. + * However, as a result of the restriction that only multiples of 16 can be input to the Update function, + * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length + * are provided for compatibility in anticipation of the time when this restriction is lifted. + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CBC_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128cbcdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *plain_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CbcDecryptFinalPrivate((uint32_t *) (plain), plain_length); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CBC_EncryptInit() function performs preparations for the execution of an AES calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument + * in the subsequent R_SCE_AES256CBC_EncryptUpdate() function and R_SCE_AES256CBC_EncryptFinal() function. + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CBC_EncryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) +{ + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256cbcenc_private_id = g_private_id_counter; + handle->id = g_aes256cbcenc_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CbcEncryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CBC_EncryptUpdate() function encrypts the second argument, plain, utilizing the key index stored + * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. + * In addition, it writes the encryption result to the third argument, cipher. After plaintext input is completed, + * call R_SCE_AES256CBC_EncryptFinal(). + * + * Specify areas for plain and cipher that do not overlap. For plain and cipher, + * specify RAM addresses that are multiples of 4. + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CBC_EncryptUpdate (sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256cbcenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = plain_length; + memcpy(handle->last_1_block_as_fraction, + (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes256CbcEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); + memcpy(handle->current_initial_vector, + cipher + (plain_length - HW_SCE_AES_BLOCK_BYTE_SIZE), + HW_SCE_AES_CBC_IV_BYTE_SIZE); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_AES256CBC_EncryptFinal() function writes + * the calculation result to the second argument, cipher, and writes the length of the calculation result + * to the third argument, cipher_length. The original intent was for a portion of the encryption + * result that was not a multiple of 16 bytes to be written to the second argument. + * However, as a result of the restriction that only multiples of 16 can be input to the Update function, + * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length + * are provided for compatibility in anticipation of the time when this restriction is lifted. + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CBC_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256cbcenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *cipher_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CbcEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CBC_DecryptInit() function performs preparations for the execution of an AES calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument + * in the subsequent R_SCE_AES256CBC_DecryptUpdate() function and R_SCE_AES256CBC_DecryptFinal() function. + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initialization vector area (16byte) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CBC_DecryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) +{ + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256cbcdec_private_id = g_private_id_counter; + handle->id = g_aes256cbcdec_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CbcDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CBC_DecryptUpdate() function decrypts the second argument, cipher, utilizing the key index stored + * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. + * In addition, it writes the decryption result to the third argument, plain. After plaintext input is completed, + * call R_SCE_AES256CBC_DecryptFinal(). + * + * Specify areas for plain and cipher that do not overlap. For plain and cipher, + * specify RAM addresses that are multiples of 4. + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CBC_DecryptUpdate (sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256cbcdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = cipher_length; + memcpy(handle->last_1_block_as_fraction, + (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes256CbcDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); + memcpy(handle->current_initial_vector, + plain + (cipher_length - HW_SCE_AES_BLOCK_BYTE_SIZE), + HW_SCE_AES_CBC_IV_BYTE_SIZE); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_AES256CBC_DecryptFinal() function writes + * the calculation result to the second argument, plain, and writes the length of the calculation result + * to the third argument, plain_length. The original intent was for a portion of the decryption + * result that was not a multiple of 16 bytes to be written to the second argument. + * However, as a result of the restriction that only multiples of 16 can be input to the Update function, + * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length + * are provided for compatibility in anticipation of the time when this restriction is lifted. + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CBC_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256cbcdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *plain_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CbcDecryptFinalPrivate((uint32_t *) (plain), plain_length); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CTR_EncryptInit() function performs preparations for the execution of an AES calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument + * in the subsequent R_SCE_AES128CTR_EncryptUpdate() function and R_SCE_AES128CTR_EncryptFinal() function. + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initialization vector area (16byte) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CTR_EncryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) +{ + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128ctrenc_private_id = g_private_id_counter; + handle->id = g_aes128ctrenc_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CtrEncryptInitPrivate(wrapped_key, (uint32_t *) (initial_vector)); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CTR_EncryptUpdate() function encrypts the second argument, plain, utilizing the key index stored + * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. + * In addition, it writes the encryption result to the third argument, cipher. After plaintext input is completed, + * call R_SCE_AES128CTR_EncryptFinal(). + * + * Specify areas for plain and cipher that do not overlap. For plain and cipher, + * specify RAM addresses that are multiples of 4. + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CTR_EncryptUpdate (sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length) +{ + uint32_t block_num = (plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128ctrenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = plain_length; + memcpy(handle->last_1_block_as_fraction, + (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes128CtrEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); + cal_current_ivec_ctrmode(handle, block_num); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_AES128CTR_EncryptFinal() function writes + * the calculation result to the second argument, cipher, and writes the length of the calculation result + * to the third argument, cipher_length. The original intent was for a portion of the encryption + * result that was not a multiple of 16 bytes to be written to the second argument. + * However, as a result of the restriction that only multiples of 16 can be input to the Update function, + * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length + * are provided for compatibility in anticipation of the time when this restriction is lifted. + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CTR_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128ctrenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *cipher_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CtrEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CTR_DecryptInit() function performs preparations for the execution of an AES calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument + * in the subsequent R_SCE_AES128CTR_DecryptUpdate() function and R_SCE_AES128CTR_DecryptFinal() function. + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initialization vector area (16byte) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CTR_DecryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) +{ + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128ctrdec_private_id = g_private_id_counter; + handle->id = g_aes128ctrdec_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CtrDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CTR_DecryptUpdate() function decrypts the second argument, cipher, utilizing the key index stored + * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. + * In addition, it writes the decryption result to the third argument, plain. After plaintext input is completed, + * call R_SCE_AES128CTR_DecryptFinal(). + * + * Specify areas for plain and cipher that do not overlap. For plain and cipher, + * specify RAM addresses that are multiples of 4. + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CTR_DecryptUpdate (sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length) +{ + uint32_t block_num = (cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128ctrdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = cipher_length; + memcpy(handle->last_1_block_as_fraction, + (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes128CtrDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); + cal_current_ivec_ctrmode(handle, block_num); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_AES128CTR_DecryptFinal() function writes + * the calculation result to the second argument, plain, and writes the length of the calculation result + * to the third argument, plain_length. The original intent was for a portion of the decryption + * result that was not a multiple of 16 bytes to be written to the second argument. + * However, as a result of the restriction that only multiples of 16 can be input to the Update function, + * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length + * are provided for compatibility in anticipation of the time when this restriction is lifted. + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CTR_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128ctrdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *plain_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CtrDecryptFinalPrivate((uint32_t *) (plain), plain_length); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CTR_EncryptInit() function performs preparations for the execution of an AES calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument + * in the subsequent R_SCE_AES256CTR_EncryptUpdate() function and R_SCE_AES256CTR_EncryptFinal() function. + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CTR_EncryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) +{ + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256ctrenc_private_id = g_private_id_counter; + handle->id = g_aes256ctrenc_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CtrEncryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CTR_EncryptUpdate() function encrypts the second argument, plain, utilizing the key index stored + * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. + * In addition, it writes the encryption result to the third argument, cipher. After plaintext input is completed, + * call R_SCE_AES256CTR_EncryptFinal(). + * + * Specify areas for plain and cipher that do not overlap. For plain and cipher, + * specify RAM addresses that are multiples of 4. + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CTR_EncryptUpdate (sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length) +{ + uint32_t block_num = (plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256ctrenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = plain_length; + memcpy(handle->last_1_block_as_fraction, + (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes256CtrEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); + cal_current_ivec_ctrmode(handle, block_num); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_AES256CTR_EncryptFinal() function writes + * the calculation result to the second argument, cipher, and writes the length of the calculation result + * to the third argument, cipher_length. The original intent was for a portion of the encryption + * result that was not a multiple of 16 bytes to be written to the second argument. + * However, as a result of the restriction that only multiples of 16 can be input to the Update function, + * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length + * are provided for compatibility in anticipation of the time when this restriction is lifted. + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CTR_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256ctrenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *cipher_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CtrEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CTR_DecryptInit() function performs preparations for the execution of an AES calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument + * in the subsequent R_SCE_AES256CTR_DecryptUpdate() function and R_SCE_AES256CTR_DecryptFinal() function. + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initialization vector area (16byte) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CTR_DecryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) +{ + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256ctrdec_private_id = g_private_id_counter; + handle->id = g_aes256ctrdec_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CtrDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CTR_DecryptUpdate() function decrypts the second argument, cipher, utilizing the key index stored + * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. + * In addition, it writes the decryption result to the third argument, plain. After plaintext input is completed, + * call R_SCE_AES256CTR_DecryptFinal(). + * + * Specify areas for plain and cipher that do not overlap. For plain and cipher, + * specify RAM addresses that are multiples of 4. + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CTR_DecryptUpdate (sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length) +{ + uint32_t block_num = (cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256ctrdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = cipher_length; + memcpy(handle->last_1_block_as_fraction, + (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes256CtrDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); + cal_current_ivec_ctrmode(handle, block_num); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_AES256CTR_DecryptFinal() function writes + * the calculation result to the second argument, plain, and writes the length of the calculation result + * to the third argument, plain_length. The original intent was for a portion of the decryption + * result that was not a multiple of 16 bytes to be written to the second argument. + * However, as a result of the restriction that only multiples of 16 can be input to the Update function, + * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length + * are provided for compatibility in anticipation of the time when this restriction is lifted. + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CTR_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) +{ + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256ctrdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *plain_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CtrDecryptFinalPrivate((uint32_t *) (plain), plain_length); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CMAC_GenerateInit() function performs preparations for the execution of an CMAC calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument in the subsequent + * R_SCE_AES128CMAC_GenerateUpdate() function and R_SCE_AES128CMAC_GenerateFinal() function. + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CMAC_GenerateInit (sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) +{ + memset(handle, 0, sizeof(sce_cmac_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128cmacgen_private_id = g_private_id_counter; + handle->id = g_aes128cmacgen_private_id; + memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES128_KEY_INDEX_WORD_SIZE * 4); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + + return R_SCE_Aes128CmacGenerateInitPrivate(wrapped_key); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CMAC_GenerateUpdate() function performs MAC value generation based on the message specified + * in the second argument, message, using the value specified for wrapped_key in R_SCE_AES128CMAC_GenerateInit(). + * Inside this function, the data that is input by the user is buffered until the input value of message + * exceeds 16 bytes. The length of the message data to input is specified in the third argument, message_len. + * For these, input not the total byte count for message input data, but rather the message data length + * to input when the user calls this function. If the input value, message, is not a multiple of 16 bytes, + * it will be padded within the function. For message, specify a RAM address that are multiples of 4. + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CMAC_GenerateUpdate (sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length) +{ + uint32_t length_rest = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128cmacgen_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->all_received_length += message_length; + if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), + message, + HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes128CmacGenerateUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); + length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + R_SCE_Aes128CmacGenerateUpdatePrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), + (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); + length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); + } + + handle->buffering_length = 0; + memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); + handle->buffering_length = length_rest; + } + else + { + memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); + handle->buffering_length += message_length; + } + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CMAC_GenerateFinal() function outputs the MAC value to the MAC data area specified + * in the second argument, mac, and ends CMAC mode. + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (16byte) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Not used. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CMAC_GenerateFinal (sce_cmac_handle_t * handle, uint8_t * mac) +{ + fsp_err_t ercd = FSP_SUCCESS; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128cmacgen_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) + { + handle->cmac_buffer[handle->buffering_length] = 1 << 7; + memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, + HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); + } + + ercd = R_SCE_Aes128CmacGenerateFinalPrivate(handle->all_received_length, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (handle->cmac_buffer), + (uint32_t *) (mac)); + memset(handle, 0, sizeof(sce_cmac_handle_t)); + + return ercd; +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CMAC_VerifyInit() function performs preparations for the execution of a CMAC calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argumentin the subsequent + * R_SCE_AES128CMAC_VerifyUpdate() function and R_SCE_AES128CMAC_VerifyFinal() function. + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CMAC_VerifyInit (sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) +{ + memset(handle, 0, sizeof(sce_cmac_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128cmacver_private_id = g_private_id_counter; + handle->id = g_aes128cmacver_private_id; + memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES128_KEY_INDEX_WORD_SIZE * 4); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + + return R_SCE_Aes128CmacVerifyInitPrivate(wrapped_key); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CMAC_VerifyUpdate() function performs MAC value generation based on the message specified + * in the second argument, message, using the value specified for wrapped_key in R_SCE_AES128CMAC_VerifyInit(). + * Inside this function, the data that is input by the user is buffered until the input value of message + * exceeds 16 bytes. The length of the message data to input is specified in the third argument, message_len. + * For these, input not the total byte count for message input data, but rather the message data length to input + * when the user calls this function. If the input value, message, is not a multiple of 16 bytes, + * it will be padded within the function. For message, specify a RAM address that are multiples of 4. + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CMAC_VerifyUpdate (sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length) +{ + uint32_t length_rest = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128cmacver_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->all_received_length += message_length; + if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), + message, + HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes128CmacVerifyUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); + length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + R_SCE_Aes128CmacVerifyUpdatePrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), + (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); + length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); + } + + handle->buffering_length = 0; + memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); + handle->buffering_length = length_rest; + } + else + { + memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); + handle->buffering_length += message_length; + } + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * The R_SCE_AES128CMAC_VerifyFinal() function inputs the MAC value in the MAC data area specified + * in the second argument, mac, and verifies the MAC value. If authentication fails, the return value will be + * TSIP_ERR_AUTHENTICATION. If the MAC value is less than 16 bytes, it will be padded with zeros inside the function. + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (mac_length byte) + * @param[in,out] mac_length MAC data length (2 to 16 bytes) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES128CMAC_VerifyFinal (sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length) +{ + fsp_err_t ercd = FSP_SUCCESS; + uint32_t mac_tmp[16 / sizeof(uint32_t)] = + { + 0 /* mac_tmp is initialized with 0. */ + }; + uint32_t mac_length_bit = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128cmacver_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((2 > mac_length) || (mac_length > HW_SCE_AES_BLOCK_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) + { + handle->cmac_buffer[handle->buffering_length] = 1 << 7; + memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, + HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); + } + + memcpy(mac_tmp, mac, mac_length); + mac_length_bit = change_endian_long(mac_length * 8); + + ercd = R_SCE_Aes128CmacVerifyFinalPrivate(handle->all_received_length, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) handle->cmac_buffer, + (uint32_t *) mac_tmp, + &mac_length_bit); + memset(handle, 0, sizeof(sce_cmac_handle_t)); + + return ercd; +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CMAC_GenerateInit() function performs preparations for the execution of an CMAC calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument in the subsequent + * R_SCE_AES256CMAC_GenerateUpdate() function and R_SCE_AES256CMAC_GenerateFinal() function. + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CMAC_GenerateInit (sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) +{ + memset(handle, 0, sizeof(sce_cmac_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256cmacgen_private_id = g_private_id_counter; + handle->id = g_aes256cmacgen_private_id; + memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES256_KEY_INDEX_WORD_SIZE * 4); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + + return R_SCE_Aes256CmacGenerateInitPrivate(wrapped_key); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CMAC_GenerateUpdate() function performs MAC value generation based on the message specified + * in the second argument, message, using the value specified for wrapped_key in R_SCE_AES256CMAC_GenerateInit(). + * Inside this function, the data that is input by the user is buffered until the input value of message + * exceeds 16 bytes. The length of the message data to input is specified in the third argument, message_len. + * For these, input not the total byte count for message input data, but rather the message data length + * to input when the user calls this function. If the input value, message, is not a multiple of 16 bytes, + * it will be padded within the function. For message, specify a RAM address that are multiples of 4. + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CMAC_GenerateUpdate (sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length) +{ + uint32_t length_rest = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256cmacgen_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->all_received_length += message_length; + if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), + message, + HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes256CmacGenerateUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); + length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + R_SCE_Aes256CmacGenerateUpdatePrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), + (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); + length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); + } + + handle->buffering_length = 0; + memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); + handle->buffering_length = length_rest; + } + else + { + memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); + handle->buffering_length += message_length; + } + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CMAC_GenerateFinal() function outputs the MAC value to the MAC data area specified + * in the second argument, mac, and ends CMAC mode. + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (16byte) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Not used. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CMAC_GenerateFinal (sce_cmac_handle_t * handle, uint8_t * mac) +{ + fsp_err_t ercd = FSP_SUCCESS; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256cmacgen_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) + { + handle->cmac_buffer[handle->buffering_length] = 1 << 7; + memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, + HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); + } + + ercd = R_SCE_Aes256CmacGenerateFinalPrivate(handle->all_received_length, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (handle->cmac_buffer), + (uint32_t *) (mac)); + memset(handle, 0, sizeof(sce_cmac_handle_t)); + + return ercd; +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CMAC_VerifyInit() function performs preparations for the execution of a CMAC calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argumentin the subsequent + * R_SCE_AES256CMAC_VerifyUpdate() function and R_SCE_AES256CMAC_VerifyFinal() function. + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CMAC_VerifyInit (sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) +{ + memset(handle, 0, sizeof(sce_cmac_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256cmacver_private_id = g_private_id_counter; + handle->id = g_aes256cmacver_private_id; + memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES256_KEY_INDEX_WORD_SIZE * 4); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + + return R_SCE_Aes256CmacVerifyInitPrivate(wrapped_key); +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CMAC_VerifyUpdate() function performs MAC value generation based on the message specified + * in the second argument, message, using the value specified for wrapped_key in R_SCE_AES256CMAC_VerifyInit(). + * Inside this function, the data that is input by the user is buffered until the input value of message + * exceeds 16 bytes. The length of the message data to input is specified in the third argument, message_len. + * For these, input not the total byte count for message input data, but rather the message data length to input + * when the user calls this function. If the input value, message, is not a multiple of 16 bytes, + * it will be padded within the function. For message, specify a RAM address that are multiples of 4. + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CMAC_VerifyUpdate (sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length) +{ + uint32_t length_rest = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256cmacver_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->all_received_length += message_length; + if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), + message, + HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes256CmacVerifyUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); + length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + R_SCE_Aes256CmacVerifyUpdatePrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), + (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); + length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); + } + + handle->buffering_length = 0; + memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); + handle->buffering_length = length_rest; + } + else + { + memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); + handle->buffering_length += message_length; + } + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * The R_SCE_AES256CMAC_VerifyFinal() function inputs the MAC value in the MAC data area specified + * in the second argument, mac, and verifies the MAC value. If authentication fails, the return value will be + * TSIP_ERR_AUTHENTICATION. If the MAC value is less than 16 bytes, it will be padded with zeros inside the function. + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (mac_length byte) + * @param[in,out] mac_length MAC data length (2 to 16 bytes) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_AES256CMAC_VerifyFinal (sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length) +{ + fsp_err_t ercd = FSP_SUCCESS; + uint32_t mac_tmp[16 / sizeof(uint32_t)] = + { + 0 /* mac_tmp is initialized with 0. */ + }; + uint32_t mac_length_bit = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256cmacver_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((2 > mac_length) || (mac_length > HW_SCE_AES_BLOCK_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) + { + handle->cmac_buffer[handle->buffering_length] = 1 << 7; + memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, + HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); + } + + memcpy(mac_tmp, mac, mac_length); + mac_length_bit = change_endian_long(mac_length * 8); + + ercd = R_SCE_Aes256CmacVerifyFinalPrivate(handle->all_received_length, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) handle->cmac_buffer, + (uint32_t *) mac_tmp, + &mac_length_bit); + memset(handle, 0, sizeof(sce_cmac_handle_t)); + + return ercd; +} + +/*******************************************************************************************************************//** + * @} (end addtogroup SCE_PROTECTED) + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ + +/****************************************************************************** + * calculate curent ivec after update process on AES COUNTER mode + * + * @param[in] block_num encrypted block number. + * @param[in,out] handle Handler for AES(work area). + * + * Return Value :none + *****************************************************************************/ +static void cal_current_ivec_ctrmode(sce_aes_handle_t *handle , uint32_t block_num) +{ + uint8_t carry_num = 0; + for (uint8_t i = 0; i < 16; i++) + { + uint16_t current_byte_sum = (uint16_t)(carry_num + handle->current_initial_vector[15 - i]); + if (i < (sizeof(block_num))) + { + current_byte_sum = (uint16_t)((uint32_t)current_byte_sum + ((block_num >> (i * 8)) & 0xFF)); + } + handle->current_initial_vector[15 - i] = (uint8_t)(current_byte_sum & 0xFF); + carry_num = (uint8_t)(current_byte_sum >> 8) & 0xFF; + } +} diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_ecc.c b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_ecc.c new file mode 100644 index 000000000..103a17c0d --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_ecc.c @@ -0,0 +1,685 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : r_sce_ecc.c + * Version : 1.0 + * Description : SCE ECC Public API source file + *********************************************************************************************************************/ +/********************************************************************************************************************** + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include "r_sce_private.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ +/* Hash data output position for ECDSA P-192. : (256 - 192) / 32 */ +#define SCE_PRV_HASH_WORD_POS_ECDSA_P192 (2) +/* Hash data output position for ECDSA P-224. : (256 - 224) / 32 */ +#define SCE_PRV_HASH_WORD_POS_ECDSA_P224 (1) +/* Hash data output position for ECDSA P-256. : (256 - 256) / 32 */ +#define SCE_PRV_HASH_WORD_POS_ECDSA_P256 (0) +/* For ECDSA P-512 : (256 - 512) / 32 */ +#define SCE_PRV_HASH_WORD_POS_ECDSA_P512 (0xFFFFFFF8UL) + +#ifndef SCE_HEX_FF +#define SCE_HEX_FF (0xFF) +#endif +#ifndef SCE_HEX_80 +#define SCE_HEX_80 (0x80) +#endif +#ifndef SCE_DEC_64 +#define SCE_DEC_64 (64) +#endif + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ +static fsp_err_t set_ecdsa_hash_data(sce_ecdsa_byte_data_t * p_message_hash, + uint32_t * data_buff, + uint32_t hash_word_pos); + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @addtogroup SCE_PROTECTED + * @{ + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * When a message is specified in the first argument, message_hash->data_type, a SHA-256 hash of the message text + * input as the first argument, message_hash->pdata, is calculated, and the signature text is written to the second + * argument, signature, in accordance with secp192r1 using the private wrapped key input as the third argument, + * wrapped_key. + * + * When a hash value is specified in the first argument, message_hash->data_type, the signature text for the first + * 24 bytes of the SHA-256 hash value input to the first argument, message_hash->pdata, is written to the second + * argument, signature, in accordance with secp192r1 using the private wrapped key input as the third argument, + * wrapped_key. + * + * @param[in] message_hash Message or hash value to which to attach signature + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in,out] signature Signature text storage destination information + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "0 padding (64 bits) || + * signature r (192 bits) || 0 padding (64 bits) || + * signature s (192 bits)". + * @arg signature->data_length : Data length (byte units) + * @param[in] wrapped_key Input wrapped key of secp192r1 private key. + * + * @retval FSP_SUCCESS Normal end + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key) +{ + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P192 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P192); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_EcdsaSignatureGenerateSub( + /* Casting uint32_t pointer is used for address. */ + &curvetype, + &indata_cmd, + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + signature->data_length = HW_SCE_ECDSA_DATA_BYTE_SIZE; + + return error_code; +} + +/*******************************************************************************************************************//** + * When a message is specified in the first argument, message_hash->data_type, a SHA-256 hash of the message text + * input as the first argument, message_hash->pdata, is calculated, and the signature text is written to the second + * argument, signature, in accordance with secp224r1 using the private wrapped key input as the third argument, + * wrapped_key. + * + * When a hash value is specified in the first argument, message_hash->data_type, the signature text for the first + * 28 bytes of the SHA-256 hash value input to the first argument, message_hash->pdata, is written to the second + * argument, signature, in accordance with secp224r1 using the private wrapped key input as the third argument, + * wrapped_key. + * + * @param[in] message_hash Message or hash value to which to attach signature + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in,out] signature Signature text storage destination information + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "0 padding (32 bits) || + * signature r (224 bits) || 0 padding (32 bits) || + * signature s (224 bits)". + * @arg signature->data_length : Data length (byte units) + * @param[in] wrapped_key Input wrapped key of secp224r1 private key. + * + * @retval FSP_SUCCESS Normal end + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key) +{ + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P224 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P224); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_EcdsaSignatureGenerateSub( + /* Casting uint32_t pointer is used for address. */ + &curvetype, + &indata_cmd, + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + signature->data_length = HW_SCE_ECDSA_DATA_BYTE_SIZE; + + return error_code; +} + +/*******************************************************************************************************************//** + * When a message is specified in the first argument, message_hash->data_type, a SHA-256 hash of the message text + * input as the first argument, message_hash->pdata, is calculated, and the signature text is written to the second + * argument, signature, in accordance with secp256r1 using the private wrapped key input as the third argument, + * wrapped_key. + * + * When a hash value is specified in the first argument, message_hash->data_type, the signature text for the first + * 32 bytes of the SHA-256 hash value input to the first argument, message_hash->pdata, is written to the second + * argument, signature, in accordance with secp256r1 using the private wrapped key input as the third argument, + * wrapped_key. + * + * @param[in] message_hash Message or hash value to which to attach signature + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in,out] signature Signature text storage destination information + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "signature r (256 bits) || + * signature s (256 bits)". + * @arg signature->data_length : Data length (byte units) + * @param[in] wrapped_key Input wrapped key of secp256r1 private key. + * + * @retval FSP_SUCCESS Normal end + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key) +{ + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P256 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P256); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_EcdsaSignatureGenerateSub( + /* Casting uint32_t pointer is used for address. */ + &curvetype, + &indata_cmd, + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + signature->data_length = HW_SCE_ECDSA_DATA_BYTE_SIZE; + + return error_code; +} + +/*******************************************************************************************************************//** + * When a hash value is specified in the first argument, message_hash->data_type, the signature text for the first + * 64 bytes of the SHA-512 hash value input to the first argument, message_hash->pdata, is written to the second + * argument, signature, in accordance with BrainpoolP512r1 using the private wrapped key input as the third argument, + * wrapped_key. + * + * @param[in] message_hash Message or hash value to which to attach signature + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (only Hash value(1) is support) + * @param[in,out] signature Signature text storage destination information + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "signature r (512 bits) || + * signature s (512 bits)". + * @arg signature->data_length : Data length (byte units) + * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 private key. + * + * @retval FSP_SUCCESS Normal end + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[(HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + if (1 != message_hash->data_type) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P512); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = R_SCE_EcdsaP512SignatureGenerateSub( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + signature->data_length = HW_SCE_ECDSA_P512_DATA_BYTE_SIZE; + + return error_code; +} + +/*******************************************************************************************************************//** + * When a message is specified in the second argument, message_hash->data_type, a SHA-256 hash of the message text + * input as the second argument, message_hash->pdata, is calculated, and the signature text input to the first argument, + * signature, is validated in accordance with secp192r1 using the public wrapped key input as the third argument, + * wrapped_key. + * + * When a hash value is specified in the second argument, message_hash->data_type, the signature text for the first + * 24 bytes of the SHA-256 hash value input to the second argument, message_hash->pdata, input to the first argument, + * signature, is validated in accordance with secp192r1 using the public wrapped key input as the third argument, + * wrapped_key. + * + * @param[in] signature Signature text information to be verified + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "0 padding (64 bits) || + * signature r (192 bits) || 0 padding (64 bits) || + * signature s (192 bits)". + * @arg signature->data_length : Specifies the data length (byte units) (nonuse) + * @param[in,out] message_hash Message or hash value to be verified + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in] wrapped_key Input wrapped key of secp192r1 public key. + * + * @retval FSP_SUCCESS Normal end + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key) +{ + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P192 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P192); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_EcdsaSignatureVerificationSub( + /* Casting uint32_t pointer is used for address. */ + &curvetype, + &indata_cmd, + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + + return error_code; +} + +/*******************************************************************************************************************//** + * When a message is specified in the second argument, message_hash->data_type, a SHA-256 hash of the message text + * input as the second argument, message_hash->pdata, is calculated, and the signature text input to the first argument, + * signature, is validated in accordance with secp224r1 using the public wrapped key input as the third argument, + * wrapped_key. + * + * When a hash value is specified in the second argument, message_hash->data_type, the signature text for the first + * 28 bytes of the SHA-256 hash value input to the second argument, message_hash->pdata, input to the first argument, + * signature, is validated in accordance with secp224r1 using the public wrapped key input as the third argument, + * wrapped_key. + * + * @param[in] signature Signature text information to be verified + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "0 padding (32 bits) || + * signature r (224 bits) || 0 padding (32 bits) || + * signature s (224 bits)". + * @arg signature->data_length : Specifies the data length (byte units) (nonuse) + * @param[in,out] message_hash Message or hash value to be verified + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in] wrapped_key Input wrapped key of secp224r1 public key. + * + * @retval FSP_SUCCESS Normal end + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key) +{ + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P224 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P224); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_EcdsaSignatureVerificationSub( + /* Casting uint32_t pointer is used for address. */ + &curvetype, + &indata_cmd, + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + + return error_code; +} + +/*******************************************************************************************************************//** + * When a message is specified in the second argument, message_hash->data_type, a SHA-256 hash of the message text + * input as the second argument, message_hash->pdata, is calculated, and the signature text input to the first argument, + * signature, is validated in accordance with secp256r1 using the public wrapped key input as the third argument, + * wrapped_key. + * + * When a hash value is specified in the second argument, message_hash->data_type, the signature text for the first + * 32 bytes of the SHA-256 hash value input to the second argument, message_hash->pdata, input to the first argument, + * signature, is validated in accordance with secp256r1 using the public wrapped key input as the third argument, + * wrapped_key. + * + * @param[in] signature Signature text information to be verified + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "signature r (256 bits) || + * signature s (256 bits)". + * @arg signature->data_length : Specifies the data length (byte units) (nonuse) + * @param[in,out] message_hash Message or hash value to be verified + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in] wrapped_key Input wrapped key of secp256r1 public key. + * + * @retval FSP_SUCCESS Normal end + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key) +{ + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P256 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P256); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_EcdsaSignatureVerificationSub( + /* Casting uint32_t pointer is used for address. */ + &curvetype, + &indata_cmd, + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + + return error_code; +} + +/*******************************************************************************************************************//** + * When a hash value is specified in the second argument, message_hash->data_type, the signature text for the first + * 32 bytes of the SHA-256 hash value input to the second argument, message_hash->pdata, input to the first argument, + * signature, is validated in accordance with BrainpoolP512r1 using the public wrapped key input as the third argument, + * wrapped_key. + * + * @param[in] signature Signature text information to be verified + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "signature r (512 bits) || + * signature s (512 bits)". + * @arg signature->data_length : Specifies the data length (byte units) (nonuse) + * @param[in,out] message_hash Message or hash value to be verified + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (only Hash value(1) is support) + * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 public key. + * + * @retval FSP_SUCCESS Normal end + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key) +{ + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[(HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + if (1 != message_hash->data_type) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P512); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = R_SCE_EcdsaP512SignatureVerificationSub( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + + return error_code; +} + +/*******************************************************************************************************************//** + * @} (end addtogroup SCE_PROTECTED) + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * For messages, SHA hash operation is performed and the hash value is set according to ECDSA. + * + * @param p_message_hash message or hash value information + * @param data_buff pointer to the hash value area, including 0 padding + * @param hash_word_pos hash value output word position from the beginning of the data_buff + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input parameter illegal + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + **********************************************************************************************************************/ +static fsp_err_t set_ecdsa_hash_data (sce_ecdsa_byte_data_t * p_message_hash, + uint32_t * data_buff, + uint32_t hash_word_pos) +{ + fsp_err_t error_code = FSP_SUCCESS; + sce_sha_md5_handle_t ex_sha_handle = + { + 0 + }; + uint32_t hash_length = 0; + + if (0 == p_message_hash->data_type) + { + if (SCE_PRV_HASH_WORD_POS_ECDSA_P512 != hash_word_pos) + { + R_SCE_SHA256_Init(&ex_sha_handle); + error_code = R_SCE_SHA256_Update(&ex_sha_handle, p_message_hash->pdata, p_message_hash->data_length); + if (FSP_SUCCESS == error_code) + { + /* Casting uint8_t pointer is used for address. */ + error_code = R_SCE_SHA256_Final(&ex_sha_handle, (uint8_t *) &data_buff[hash_word_pos], &hash_length); + } + } + else + { + error_code = FSP_ERR_CRYPTO_SCE_FAIL; + } + } + else if (1 == p_message_hash->data_type) + { + if (SCE_PRV_HASH_WORD_POS_ECDSA_P512 != hash_word_pos) + { + memcpy(&data_buff[hash_word_pos], + p_message_hash->pdata, + HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE - (hash_word_pos * sizeof(uint32_t))); + } + else + { + memcpy(data_buff, p_message_hash->pdata, HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE); + } + } + else + { + error_code = FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + return error_code; +} diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_rsa.c b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_rsa.c new file mode 100644 index 000000000..a4e2a9920 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_rsa.c @@ -0,0 +1,1162 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : r_sce_rsa.c + * Version : 1.0 + * Description : SCE RSA Public API source file + *********************************************************************************************************************/ +/********************************************************************************************************************** + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include +#include "r_sce_private.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ +#define SCE_RSA_SIG_SHA256_PREFIX_00 (0x30) +#define SCE_RSA_SIG_SHA256_PREFIX_01 (0x31) +#define SCE_RSA_SIG_SHA256_PREFIX_02 (0x30) +#define SCE_RSA_SIG_SHA256_PREFIX_03 (0x0d) +#define SCE_RSA_SIG_SHA256_PREFIX_04 (0x06) +#define SCE_RSA_SIG_SHA256_PREFIX_05 (0x09) +#define SCE_RSA_SIG_SHA256_PREFIX_06 (0x60) +#define SCE_RSA_SIG_SHA256_PREFIX_07 (0x86) +#define SCE_RSA_SIG_SHA256_PREFIX_08 (0x48) +#define SCE_RSA_SIG_SHA256_PREFIX_09 (0x01) +#define SCE_RSA_SIG_SHA256_PREFIX_10 (0x65) +#define SCE_RSA_SIG_SHA256_PREFIX_11 (0x03) +#define SCE_RSA_SIG_SHA256_PREFIX_12 (0x04) +#define SCE_RSA_SIG_SHA256_PREFIX_13 (0x02) +#define SCE_RSA_SIG_SHA256_PREFIX_14 (0x01) +#define SCE_RSA_SIG_SHA256_PREFIX_15 (0x05) +#define SCE_RSA_SIG_SHA256_PREFIX_16 (0x00) +#define SCE_RSA_SIG_SHA256_PREFIX_17 (0x04) +#define SCE_RSA_SIG_SHA256_PREFIX_18 (0x20) + +#ifndef SCE_HEX_FF +#define SCE_HEX_FF (0xff) +#endif + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ +static fsp_err_t calc_hash_data(uint8_t * p_mes, uint8_t * p_hash, uint32_t mes_len, uint8_t hash_type); +static fsp_err_t set_rsassapkcs_hash_data(sce_rsa_byte_data_t * p_message_hash, + uint8_t hash_type, + uint32_t rsa_key_byte_size, + uint8_t * data_buff); +static uint32_t get_keyn_size(uint32_t * prsa_key_index, uint32_t key_max_size); +static fsp_err_t get_rand_rsaes_pkcs(uint32_t rand_size, uint8_t * prand_data); + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ +static uint8_t gs_rsa_sig_sha256_prefix[] = +{ + SCE_RSA_SIG_SHA256_PREFIX_00, + SCE_RSA_SIG_SHA256_PREFIX_01, + SCE_RSA_SIG_SHA256_PREFIX_02, + SCE_RSA_SIG_SHA256_PREFIX_03, + SCE_RSA_SIG_SHA256_PREFIX_04, + SCE_RSA_SIG_SHA256_PREFIX_05, + SCE_RSA_SIG_SHA256_PREFIX_06, + SCE_RSA_SIG_SHA256_PREFIX_07, + SCE_RSA_SIG_SHA256_PREFIX_08, + SCE_RSA_SIG_SHA256_PREFIX_09, + SCE_RSA_SIG_SHA256_PREFIX_10, + SCE_RSA_SIG_SHA256_PREFIX_11, + SCE_RSA_SIG_SHA256_PREFIX_12, + SCE_RSA_SIG_SHA256_PREFIX_13, + SCE_RSA_SIG_SHA256_PREFIX_14, + SCE_RSA_SIG_SHA256_PREFIX_15, + SCE_RSA_SIG_SHA256_PREFIX_16, + SCE_RSA_SIG_SHA256_PREFIX_17, + SCE_RSA_SIG_SHA256_PREFIX_18 +}; + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @addtogroup SCE_PROTECTED + * @{ + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * The R_SCE_RSASSA_PKCS1024_SignatureGenerate() function generates, in accordance with RSASSA-PKCS1-V1_5, a signature + * from the message text or hash value that is input in the first argument, message_hash, using the private wrapped + * key input to the third argument, wrapped_key, and writes the signature text to the second argument, signature. + * When a message is specified in the first argument, message_hash->data_type, a hash value is calculated for + * the message as specified by the fourth argument, hash_type. When specifying a hash value in the first argument, + * message_hash->data_type, a hash value calculated with a hash algorithm as specified by the fourth argument, + * hash_type, must be input to message_hash->pdata. + * + * @param[in] message_hash Message or hash value to which to attach signature + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in,out] signature Signature text storage destination information + * @arg signature->pdata : Specifies pointer to array storing the signature text + * @arg signature->data_length : data length + * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate (sce_rsa_byte_data_t * message_hash, + sce_rsa_byte_data_t * signature, + sce_rsa1024_private_wrapped_key_t * wrapped_key, + uint8_t hash_type) +{ + fsp_err_t error_code = FSP_SUCCESS; + uint8_t data_buff[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + + error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_1024_DATA_BYTE_SIZE, data_buff); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = R_SCE_Rsa1024ModularExponentDecryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (data_buff), + (uint32_t *) (signature->pdata)); + + signature->data_length = HW_SCE_RSA_1024_DATA_BYTE_SIZE; + + return error_code; +} + +/*******************************************************************************************************************//** + * The R_SCE_RSASSA_PKCS1024_SignatureVerify() function verifies, in accordance with RSASSA-PKCS1-V1_5, + * the signature text input to the first argument signature, + * and the message text or hash value input to the second argument, + * message_hash, using the public wrapped key input to the third argument, wrapped_key. When a message is specified + * in the second argument, message_hash->data_type, a hash value is calculated using the public wrapped key input to + * the third argument, wrapped_key, and as specified by the fourth argument, hash_type. When specifying a hash value + * in the second argument, message_hash->data_type, a hash value calculated with a hash algorithm as specified by the + * fourth argument, hash_type, must be input to message_hash->pdata. + * + * @param[in] signature Signature text information to verify + * @arg signature->pdata : Specifies pointer to array storing the signature text + * @arg signature->data_length : Specifies effective data length of the array + * @param[in] message_hash Message text or hash value to verify + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureVerify (sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, + sce_rsa1024_public_wrapped_key_t * wrapped_key, + uint8_t hash_type) +{ + fsp_err_t error_code = FSP_SUCCESS; + uint8_t data_buff[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t decrypt_data[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t data_ptr = 0; + + data_ptr = HW_SCE_RSA_1024_DATA_BYTE_SIZE - signature->data_length; + memcpy(data_buff + data_ptr, signature->pdata, signature->data_length); + + error_code = R_SCE_Rsa1024ModularExponentEncryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (data_buff), + (uint32_t *) (decrypt_data)); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_1024_DATA_BYTE_SIZE, data_buff); + if (FSP_SUCCESS == error_code) + { + if (memcmp(data_buff, decrypt_data, HW_SCE_RSA_1024_DATA_BYTE_SIZE)) + { + error_code = FSP_ERR_CRYPTO_SCE_AUTHENTICATION; + } + } + + return error_code; +} + +/*******************************************************************************************************************//** + * The R_SCE_RSAES_PKCS1024_Encrypt() function RSA-encrypts the plaintext input to the first argument, plain, + * according to RSAES-PKCS1-V1_5. It writes the encryption result to the second argument, cipher. + * + * @param[in] plain plaintext + * @arg plain->pdata : Specifies pointer to array containing plaintext. + * @arg plain->data_length : Specifies valid data length of plaintext array. + * data size <= public key n size - 11 + * @param[in,out] cipher ciphertext + * @arg cipher->pdata : Specifies pointer to array containing ciphertext. + * @arg cipher->data_length : Inputs ciphertext buffer size. + * Outputs valid data length after encryption + * (public key n size). + * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSAES_PKCS1024_Encrypt (sce_rsa_byte_data_t * plain, + sce_rsa_byte_data_t * cipher, + sce_rsa1024_public_wrapped_key_t * wrapped_key) +{ + fsp_err_t ercd = FSP_SUCCESS; + uint8_t input_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t output_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t key_size = 0; + uint32_t ptr = 0; + + /* Casting uint32_t pointer is used for address. */ + key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_1024_DATA_BYTE_SIZE); + if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((plain->data_length) > (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (cipher->data_length < key_size) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + cipher->data_length = key_size; + + /*** RSAES-PKCS#1_V1.5 format ***/ + /* (1) | (2) | (3) | (4) | (5) */ + /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ + ptr = HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size; + input_data_arry[ptr] = 0x00; + ptr++; + input_data_arry[ptr] = 0x02; + ptr++; + + get_rand_rsaes_pkcs(((key_size - plain->data_length) - 3), &input_data_arry[ptr]); + ptr += ((key_size - plain->data_length) - 3); + input_data_arry[ptr] = 0x00; + ptr++; + + memcpy(&input_data_arry[ptr], plain->pdata, plain->data_length); + + ercd = R_SCE_Rsa1024ModularExponentEncryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (input_data_arry), + (uint32_t *) (output_data_arry)); + memcpy(cipher->pdata, &output_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size], cipher->data_length); + + return ercd; +} + +/*******************************************************************************************************************//** + * The R_SCE_RSAES_PKCS1024_Decrypt() function RSA-decrypts the ciphertext input to the first argument, cipher, + * according to RSAES-PKCS1-V1_5. It writes the decryption result to the second argument, plain. + * + * @param[in] cipher ciphertext + * @arg cipher->pdata : Specifies pointer to array containing ciphertext. + * @arg cipher->data_length : Inputs ciphertext buffer size. + * Outputs valid data length after encryption + * (public key n size). + * @param[in,out] plain plaintext + * @arg plain->pdata : Specifies pointer to array containing plaintext. + * @arg plain->data_length : Inputs plaintext buffer size. + * The following size is required. + * Plaintext buffer size >= public key n size -11. + * Outputs valid data length after decryption + * (public key n size). + * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt (sce_rsa_byte_data_t * cipher, + sce_rsa_byte_data_t * plain, + sce_rsa1024_private_wrapped_key_t * wrapped_key) +{ + fsp_err_t ercd = FSP_SUCCESS; + uint8_t input_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t output_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t key_size = 0; + uint32_t ptr = 0; + uint32_t ptr_start = 0; + uint8_t * p_start = 0; + uint8_t * p_zero_ptr = 0; + + /* Casting uint32_t pointer is used for address. */ + key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_1024_DATA_BYTE_SIZE); + if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (cipher->data_length != key_size) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (plain->data_length < (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + memcpy(&input_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size], cipher->pdata, cipher->data_length); + ercd = R_SCE_Rsa1024ModularExponentDecryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (input_data_arry), + (uint32_t *) (output_data_arry)); + if (FSP_SUCCESS != ercd) + { + return ercd; + } + + /*** RSAES-PKCS#1_V1.5 format ***/ + /* (1) | (2) | (3) | (4) | (5) */ + /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ + ptr = HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size; + ptr_start = ptr; + + /* (1) */ + if (0x00 != output_data_arry[ptr]) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + ptr++; + + /* (2) */ + if (0x02 != output_data_arry[ptr]) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + ptr++; + + /* (3) and (4) */ + p_start = &output_data_arry[ptr]; + + /* Casting uint8_t pointer is used for address. */ + p_zero_ptr = (uint8_t *) memchr(p_start, 0x00, key_size - 2); /* "2" is (1)+(2) */ + if (NULL == p_zero_ptr) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + if ((HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE - 3) > (uint32_t) (p_zero_ptr - p_start)) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + ptr += (uint32_t) ((p_zero_ptr - p_start) + 1); + + plain->data_length = key_size - (ptr - ptr_start); + memcpy(plain->pdata, &output_data_arry[ptr], plain->data_length); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * The R_SCE_RSASSA_PKCS2048_SignatureGenerate() function generates, in accordance with RSASSA-PKCS1-V1_5, a signature + * from the message text or hash value that is input in the first argument, message_hash, using the private wrapped + * key input to the third argument, wrapped_key, and writes the signature text to the second argument, signature. + * When a message is specified in the first argument, message_hash->data_type, a hash value is calculated for + * the message as specified by the fourth argument, hash_type. When specifying a hash value in the first argument, + * message_hash->data_type, a hash value calculated with a hash algorithm as specified by the fourth argument, + * hash_type, must be input to message_hash->pdata. + * + * @param[in] message_hash Message or hash value to which to attach signature + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in,out] signature Signature text storage destination information + * @arg signature->pdata : Specifies pointer to array storing the signature text + * @arg signature->data_length : data length + * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate (sce_rsa_byte_data_t * message_hash, + sce_rsa_byte_data_t * signature, + sce_rsa2048_private_wrapped_key_t * wrapped_key, + uint8_t hash_type) +{ + fsp_err_t error_code = FSP_SUCCESS; + uint8_t data_buff[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + + error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_2048_DATA_BYTE_SIZE, data_buff); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = R_SCE_Rsa2048ModularExponentDecryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (data_buff), + (uint32_t *) (signature->pdata)); + + signature->data_length = HW_SCE_RSA_2048_DATA_BYTE_SIZE; + + return error_code; +} + +/*******************************************************************************************************************//** + * The R_SCE_RSASSA_PKCS2048_SignatureVerify() function verifies, in accordance with RSASSA-PKCS1-V1_5, + * the signature text input to the first argument signature, + * and the message text or hash value input to the second argument, + * message_hash, using the public wrapped key input to the third argument, wrapped_key. When a message is specified + * in the second argument, message_hash->data_type, a hash value is calculated using the public wrapped key input to + * the third argument, wrapped_key, and as specified by the fourth argument, hash_type. When specifying a hash value + * in the second argument, message_hash->data_type, a hash value calculated with a hash algorithm as specified by the + * fourth argument, hash_type, must be input to message_hash->pdata. + * + * @param[in] signature Signature text information to verify + * @arg signature->pdata : Specifies pointer to array storing the signature text + * @arg signature->data_length : Specifies effective data length of the array + * @param[in] message_hash Message text or hash value to verify + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify (sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, + sce_rsa2048_public_wrapped_key_t * wrapped_key, + uint8_t hash_type) +{ + fsp_err_t error_code = FSP_SUCCESS; + uint8_t data_buff[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t decrypt_data[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t data_ptr = 0; + + data_ptr = HW_SCE_RSA_2048_DATA_BYTE_SIZE - signature->data_length; + memcpy(data_buff + data_ptr, signature->pdata, signature->data_length); + + error_code = R_SCE_Rsa2048ModularExponentEncryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (data_buff), + (uint32_t *) (decrypt_data)); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_2048_DATA_BYTE_SIZE, data_buff); + if (FSP_SUCCESS == error_code) + { + if (memcmp(data_buff, decrypt_data, HW_SCE_RSA_2048_DATA_BYTE_SIZE)) + { + error_code = FSP_ERR_CRYPTO_SCE_AUTHENTICATION; + } + } + + return error_code; +} + +/*******************************************************************************************************************//** + * The R_SCE_RSASSA_PKCS4096_SignatureVerify() function verifies, in accordance with RSASSA-PKCS1-V1_5, + * the signature text input to the first argument signature, + * and the message text or hash value input to the second argument, + * message_hash, using the public wrapped key input to the third argument, wrapped_key. When a message is specified + * in the second argument, message_hash->data_type, a hash value is calculated using the public wrapped key input to + * the third argument, wrapped_key, and as specified by the fourth argument, hash_type. When specifying a hash value + * in the second argument, message_hash->data_type, a hash value calculated with a hash algorithm as specified by the + * fourth argument, hash_type, must be input to message_hash->pdata. + * + * @param[in] signature Signature text information to verify + * @arg signature->pdata : Specifies pointer to array storing the signature text + * @arg signature->data_length : Specifies effective data length of the array + * @param[in] message_hash Message text or hash value to verify + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSASSA_PKCS4096_SignatureVerify (sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, + sce_rsa4096_public_wrapped_key_t * wrapped_key, + uint8_t hash_type) +{ + fsp_err_t error_code = FSP_SUCCESS; + uint8_t data_buff[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t decrypt_data[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t data_ptr = 0; + + data_ptr = HW_SCE_RSA_4096_DATA_BYTE_SIZE - signature->data_length; + memcpy(data_buff + data_ptr, signature->pdata, signature->data_length); + + error_code = R_SCE_Rsa4096ModularExponentEncryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (data_buff), + (uint32_t *) (decrypt_data)); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_4096_DATA_BYTE_SIZE, data_buff); + if (FSP_SUCCESS == error_code) + { + if (memcmp(data_buff, decrypt_data, HW_SCE_RSA_4096_DATA_BYTE_SIZE)) + { + error_code = FSP_ERR_CRYPTO_SCE_AUTHENTICATION; + } + } + + return error_code; +} + +/*******************************************************************************************************************//** + * The R_SCE_RSAES_PKCS2048_Encrypt() function RSA-encrypts the plaintext input to the first argument, plain, + * according to RSAES-PKCS1-V1_5. It writes the encryption result to the second argument, cipher. + * + * @param[in] plain plaintext + * @arg plain->pdata : Specifies pointer to array containing plaintext. + * @arg plain->data_length : Specifies valid data length of plaintext array. + * data size <= public key n size - 11 + * @param[in,out] cipher ciphertext + * @arg cipher->pdata : Specifies pointer to array containing ciphertext. + * @arg cipher->data_length : Inputs ciphertext buffer size. + * Outputs valid data length after encryption + * (public key n size). + * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSAES_PKCS2048_Encrypt (sce_rsa_byte_data_t * plain, + sce_rsa_byte_data_t * cipher, + sce_rsa2048_public_wrapped_key_t * wrapped_key) +{ + fsp_err_t ercd = FSP_SUCCESS; + uint8_t input_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t output_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t key_size = 0; + uint32_t ptr = 0; + + /* Casting uint32_t pointer is used for address. */ + key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_2048_DATA_BYTE_SIZE); + if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((plain->data_length) > (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (cipher->data_length < key_size) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + cipher->data_length = key_size; + + /*** RSAES-PKCS#1_V1.5 format ***/ + /* (1) | (2) | (3) | (4) | (5) */ + /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ + ptr = HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size; + input_data_arry[ptr] = 0x00; + ptr++; + input_data_arry[ptr] = 0x02; + ptr++; + + get_rand_rsaes_pkcs(((key_size - plain->data_length) - 3), &input_data_arry[ptr]); + ptr += ((key_size - plain->data_length) - 3); + input_data_arry[ptr] = 0x00; + ptr++; + + memcpy(&input_data_arry[ptr], plain->pdata, plain->data_length); + + ercd = R_SCE_Rsa2048ModularExponentEncryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (input_data_arry), + (uint32_t *) (output_data_arry)); + memcpy(cipher->pdata, &output_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size], cipher->data_length); + + return ercd; +} + +/*******************************************************************************************************************//** + * The R_SCE_RSAES_PKCS2048_Decrypt() function RSA-decrypts the ciphertext input to the first argument, cipher, + * according to RSAES-PKCS1-V1_5. It writes the decryption result to the second argument, plain. + * + * @param[in] cipher ciphertext + * @arg cipher->pdata : Specifies pointer to array containing ciphertext. + * @arg cipher->data_length : Inputs ciphertext buffer size. + * Outputs valid data length after encryption + * (public key n size). + * @param[in,out] plain plaintext + * @arg plain->pdata : Specifies pointer to array containing plaintext. + * @arg plain->data_length : Inputs plaintext buffer size. + * The following size is required. + * Plaintext buffer size >= public key n size -11. + * Outputs valid data length after decryption + * (public key n size). + * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSAES_PKCS2048_Decrypt (sce_rsa_byte_data_t * cipher, + sce_rsa_byte_data_t * plain, + sce_rsa2048_private_wrapped_key_t * wrapped_key) +{ + fsp_err_t ercd = FSP_SUCCESS; + uint8_t input_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t output_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t key_size = 0; + uint32_t ptr = 0; + uint32_t ptr_start = 0; + uint8_t * p_start = 0; + uint8_t * p_zero_ptr = 0; + + /* Casting uint32_t pointer is used for address. */ + key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_2048_DATA_BYTE_SIZE); + if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (cipher->data_length != key_size) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (plain->data_length < (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + memcpy(&input_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size], cipher->pdata, cipher->data_length); + ercd = R_SCE_Rsa2048ModularExponentDecryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (input_data_arry), + (uint32_t *) (output_data_arry)); + if (FSP_SUCCESS != ercd) + { + return ercd; + } + + /*** RSAES-PKCS#1_V1.5 format ***/ + /* (1) | (2) | (3) | (4) | (5) */ + /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ + ptr = HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size; + ptr_start = ptr; + + /* (1) */ + if (0x00 != output_data_arry[ptr]) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + ptr++; + + /* (2) */ + if (0x02 != output_data_arry[ptr]) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + ptr++; + + /* (3) and (4) */ + p_start = &output_data_arry[ptr]; + + /* Casting uint8_t pointer is used for address. */ + p_zero_ptr = (uint8_t *) memchr(p_start, 0x00, key_size - 2); /* "2" is (1)+(2) */ + if (NULL == p_zero_ptr) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + if ((HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE - 3) > (uint32_t) (p_zero_ptr - p_start)) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + ptr += (uint32_t) ((p_zero_ptr - p_start) + 1); + + plain->data_length = key_size - (ptr - ptr_start); + memcpy(plain->pdata, &output_data_arry[ptr], plain->data_length); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * The R_SCE_RSAES_PKCS4096_Encrypt() function RSA-encrypts the plaintext input to the first argument, plain, + * according to RSAES-PKCS1-V1_5. It writes the encryption result to the second argument, cipher. + * + * @param[in] plain plaintext + * @arg plain->pdata : Specifies pointer to array containing plaintext. + * @arg plain->data_length : Specifies valid data length of plaintext array. + * data size <= public key n size - 11 + * @param[in,out] cipher ciphertext + * @arg cipher->pdata : Specifies pointer to array containing ciphertext. + * @arg cipher->data_length : Inputs ciphertext buffer size. + * Outputs valid data length after encryption + * (public key n size). + * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt (sce_rsa_byte_data_t * plain, + sce_rsa_byte_data_t * cipher, + sce_rsa4096_public_wrapped_key_t * wrapped_key) +{ + fsp_err_t ercd = FSP_SUCCESS; + uint8_t input_data_arry[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t output_data_arry[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t key_size = 0; + uint32_t ptr = 0; + + /* Casting uint32_t pointer is used for address. */ + key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_4096_DATA_BYTE_SIZE); + if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((plain->data_length) > (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (cipher->data_length < key_size) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + cipher->data_length = key_size; + + /*** RSAES-PKCS#1_V1.5 format ***/ + /* (1) | (2) | (3) | (4) | (5) */ + /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ + ptr = HW_SCE_RSA_4096_DATA_BYTE_SIZE - key_size; + input_data_arry[ptr] = 0x00; + ptr++; + input_data_arry[ptr] = 0x02; + ptr++; + + get_rand_rsaes_pkcs(((key_size - plain->data_length) - 3), &input_data_arry[ptr]); + ptr += ((key_size - plain->data_length) - 3); + input_data_arry[ptr] = 0x00; + ptr++; + + memcpy(&input_data_arry[ptr], plain->pdata, plain->data_length); + + ercd = R_SCE_Rsa4096ModularExponentEncryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (input_data_arry), + (uint32_t *) (output_data_arry)); + memcpy(cipher->pdata, &output_data_arry[HW_SCE_RSA_4096_DATA_BYTE_SIZE - key_size], cipher->data_length); + + return ercd; +} + +/*******************************************************************************************************************//** + * @} (end addtogroup SCE_PROTECTED) + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Hash message text according to the hash type. + * + * @param p_mes message text + * @param p_hash pointer of hash data + * @param mes_len message size(byte) + * @param hash_type hash type + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input parameter illegal + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + **********************************************************************************************************************/ +static fsp_err_t calc_hash_data (uint8_t * p_mes, uint8_t * p_hash, uint32_t mes_len, uint8_t hash_type) +{ + fsp_err_t error_code = FSP_SUCCESS; + sce_sha_md5_handle_t ex_sha_handle = + { + 0 + }; + uint32_t hash_length = 0; + + if (HW_SCE_RSA_HASH_SHA256 == hash_type) + { + R_SCE_SHA256_Init(&ex_sha_handle); + error_code = R_SCE_SHA256_Update(&ex_sha_handle, p_mes, mes_len); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = R_SCE_SHA256_Final(&ex_sha_handle, p_hash, &hash_length); + } + + return error_code; +} + +/*******************************************************************************************************************//** + * Prefix the hash of the message according to RSASSA-PKCS1-V1_5. + * + * @param p_message_hash message text or hash value + * @param hash_type hash type + * @param rsa_key_byte_size RSA data size + * @param data_buff pointer of Sig data + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input parameter illegal + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + **********************************************************************************************************************/ +static fsp_err_t set_rsassapkcs_hash_data (sce_rsa_byte_data_t * p_message_hash, + uint8_t hash_type, + uint32_t rsa_key_byte_size, + uint8_t * data_buff) +{ + fsp_err_t error_code = FSP_SUCCESS; + sce_rsa_byte_data_t prefix = + { + 0 + }; + uint32_t hash_data_buff[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t)] = + { + 0 + }; + uint32_t hash_length = 0; + uint32_t data_ptr = 0; + + if ((HW_SCE_RSA_HASH_SHA256 < hash_type) || (1 < p_message_hash->data_type)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (0 == p_message_hash->data_type) + { + /* Casting uint8_t pointer is used for address. */ + error_code = calc_hash_data(p_message_hash->pdata, + (uint8_t *) hash_data_buff, + p_message_hash->data_length, + hash_type); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + } + + if (HW_SCE_RSA_HASH_SHA256 == hash_type) + { + prefix.pdata = gs_rsa_sig_sha256_prefix; + prefix.data_length = sizeof(gs_rsa_sig_sha256_prefix); + hash_length = HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE; + } + + data_buff[0] = 0x00; + data_buff[1] = 0x01; + data_ptr = ((rsa_key_byte_size - prefix.data_length) - hash_length) - 1; + memset(data_buff + 2, SCE_HEX_FF, data_ptr); + data_buff[data_ptr] = 0x0; + data_ptr++; + memcpy(data_buff + data_ptr, prefix.pdata, prefix.data_length); + data_ptr += prefix.data_length; + if (0 == p_message_hash->data_type) + { + memcpy(data_buff + data_ptr, hash_data_buff, hash_length); + } + else /* if (1 == p_message_hash->data_type) */ + { + memcpy(data_buff + data_ptr, p_message_hash->pdata, hash_length); + } + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Get key n size from RSA key index + * + * @param prsa_key_index RSA key index + * @param key_max_size key data max byte size + * + * @return key_size + **********************************************************************************************************************/ +static uint32_t get_keyn_size (uint32_t * prsa_key_index, uint32_t key_max_size) +{ + bool get_output_data_length = false; + + /* Casting uint8_t pointer is used for address. */ + uint8_t * p_rsa_key_n_data = (uint8_t *) prsa_key_index; + uint32_t key_size_tmp = 0; + + key_size_tmp = key_max_size; + for (uint32_t i = 0; i < (key_max_size); i++) + { + if (!get_output_data_length) + { + if (0 == p_rsa_key_n_data[i]) + { + key_size_tmp--; + } + else + { + get_output_data_length = true; + } + } + } + + return key_size_tmp; +} + +/*******************************************************************************************************************//** + * In accordance with RSAES-PKCS1-V1_5 to obtain random number data of rand_size that does not contain 0. + * + * @param rand_size random data size + * @param prand_data random data area pointer + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict + **********************************************************************************************************************/ +static fsp_err_t get_rand_rsaes_pkcs (uint32_t rand_size, uint8_t * prand_data) +{ + fsp_err_t ercd = FSP_SUCCESS; + uint8_t rand_tmp[16] = + { + 0 + }; + uint32_t rest_size = rand_size; + uint32_t rand_ptr = 0; + uint32_t i = 0; + + while (rest_size) + { +#if defined RSA_ENC_TEST_MODE + memset(rand_tmp, SCE_HEX_FF, sizeof(rand_tmp)); +#else + + /* Casting uint32_t pointer is used for address. */ + ercd = R_SCE_RandomNumberGenerate((uint32_t *) rand_tmp); + if (FSP_SUCCESS != ercd) + { + break; + } +#endif /* defined RSA_ENC_TEST_MODE */ + for (i = 0; i < 16; i++) + { + if (0 != rand_tmp[i]) + { + prand_data[rand_ptr] = rand_tmp[i]; + rand_ptr++; + rest_size--; + } + + if (0 == rest_size) + { + break; + } + } + } + + return ercd; +} diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_sha.c b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_sha.c new file mode 100644 index 000000000..3294d898d --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_sha.c @@ -0,0 +1,447 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : r_sce_sha.c + * Version : 1.0 + * Description : SCE Hash Public API source file + *********************************************************************************************************************/ +/********************************************************************************************************************** + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "r_sce_private.h" +#include + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* Block length (in bytes) of SHA */ +#define SHA_BLOCK8_LEN (64U) + +/* Initialization function call state */ +#define CALL_ONLY_INIT (0) +#define CALL_ONLY_UPDATE_FINAL (1) + +#ifndef SCE_HEX_FF +#define SCE_HEX_FF (0xff) +#endif +#ifndef SCE_HEX_80 +#define SCE_HEX_80 (0x80) +#endif +#ifndef SCE_DEC_32 +#define SCE_DEC_32 (32) +#endif +#ifndef SCE_DEC_64 +#define SCE_DEC_64 (64) +#endif + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ +extern uint32_t g_private_id_counter; +uint32_t g_sha224_private_id; +uint32_t g_sha256_private_id; + +/*******************************************************************************************************************//** + * @addtogroup SCE_PROTECTED + * @{ + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * The R_SCE_SHA224_Init() function performs preparations for the execution of an SHA-224 hash calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument in the subsequent + * R_SCE_SHA224_Update() function and R_SCE_SHA224_Final() function. + * + * @param[in,out] handle SHA handler (work area) + * + * @retval FSP_SUCCESS Normal termination + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_SHA224_Init (sce_sha_md5_handle_t * handle) +{ + memset(handle, 0, sizeof(sce_sha_md5_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_sha224_private_id = g_private_id_counter; + handle->id = g_sha224_private_id; + memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); + + return R_SCE_Sha224InitPrivate(handle); +} + +/*******************************************************************************************************************//** + * The R_SCE_SHA224_Update() function calculates a hash value based on the second argument, message, + * and the third argument, message_length, and writes the ongoing status to the first argument, handle. + * After message input is completed, call R_SCE_SHA224_Final(). + * + * @param[in,out] handle SHA handler (work area) + * @param[in] message message data area + * @param[in] message_length message data length + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_SHA224_Update (sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length) +{ + fsp_err_t ercd = FSP_SUCCESS; + uint32_t length_rest = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_sha224_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->all_received_length += message_length; + if ((handle->buffering_length + message_length) >= SHA_BLOCK8_LEN) + { + memcpy(handle->sha_buffer + handle->buffering_length, message, SHA_BLOCK8_LEN - handle->buffering_length); + + /*Casting uint32_t pointer is used for address.*/ + ercd = R_SCE_Sha224UpdatePrivate(handle, (uint32_t *) (handle->sha_buffer), SHA_BLOCK8_LEN >> 2); + length_rest = message_length - (SHA_BLOCK8_LEN - handle->buffering_length); + memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); + if (length_rest >= SHA_BLOCK8_LEN) + { + ercd = R_SCE_Sha224UpdatePrivate(handle, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (message + (SHA_BLOCK8_LEN - handle->buffering_length)), + ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN) >> 2); + length_rest -= ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN); + } + + handle->buffering_length = 0; + memcpy(handle->sha_buffer, message + (message_length - length_rest), length_rest); + handle->buffering_length = length_rest; + } + else + { + memcpy(handle->sha_buffer + handle->buffering_length, message, message_length); + handle->buffering_length += message_length; + } + + return ercd; +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_SHA224_Final() function writes the calculation + * result to the second argument, digest, and writes the length of the calculation result to the third argument, + * digest_length. + * + * @param[in,out] handle SHA handler (work area) + * @param[in,out] digest hasha data area + * @param[in,out] digest_length hash data length (32bytes) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_SHA224_Final (sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length) +{ + uint32_t max_cnt_byte = 0; + fsp_err_t ercd = FSP_SUCCESS; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_sha224_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->sha_buffer[handle->buffering_length] = SCE_HEX_80; + if ((SHA_BLOCK8_LEN - handle->buffering_length) >= 9) /* another block unnecessary */ + { + memset(handle->sha_buffer + (handle->buffering_length + 1), 0, + (SHA_BLOCK8_LEN - 4) - (handle->buffering_length + 1)); + + /* According c., but support only l < 2**32 case */ + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 3] = (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 2] = (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); + max_cnt_byte = SHA_BLOCK8_LEN; + } + else + { + /* another block necessary */ + memset(handle->sha_buffer + (handle->buffering_length + 1), 0, + ((2 * SHA_BLOCK8_LEN) - 4) - (handle->buffering_length + 1)); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 3] = + (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 2] = + (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); + max_cnt_byte = 2 * SHA_BLOCK8_LEN; + } + + ercd = R_SCE_Sha224FinalPrivate(handle, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (handle->sha_buffer), + max_cnt_byte >> 2, + (uint32_t *) (digest), + digest_length); + handle->all_received_length = 0; + handle->buffering_length = 0; + memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); + + return ercd; +} + +/*******************************************************************************************************************//** + * The R_SCE_SHA256_Init() function performs preparations for the execution of an SHA-256 hash calculation, + * and writes the result to the first argument, handle. The value of handle is used as an argument in the subsequent + * R_SCE_SHA256_Update() function and R_SCE_SHA256_Final() function. + * + * @param[in,out] handle SHA handler (work area) + * + * @retval FSP_SUCCESS Normal termination + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_SHA256_Init (sce_sha_md5_handle_t * handle) +{ + memset(handle, 0, sizeof(sce_sha_md5_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_sha256_private_id = g_private_id_counter; + handle->id = g_sha256_private_id; + memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); + + return R_SCE_Sha256InitPrivate(handle); +} + +/*******************************************************************************************************************//** + * The R_SCE_SHA256_Update() function calculates a hash value based on the second argument, message, + * and the third argument, message_length, and writes the ongoing status to the first argument, handle. + * After message input is completed, call R_SCE_SHA256_Final(). + * + * @param[in,out] handle SHA handler (work area) + * @param[in] message message data area + * @param[in] message_length message data length + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_SHA256_Update (sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length) +{ + fsp_err_t ercd = FSP_SUCCESS; + uint32_t length_rest = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_sha256_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->all_received_length += message_length; + if ((handle->buffering_length + message_length) >= SHA_BLOCK8_LEN) + { + memcpy(handle->sha_buffer + handle->buffering_length, message, SHA_BLOCK8_LEN - handle->buffering_length); + + /*Casting uint32_t pointer is used for address.*/ + ercd = R_SCE_Sha256UpdatePrivate(handle, (uint32_t *) (handle->sha_buffer), SHA_BLOCK8_LEN >> 2); + length_rest = message_length - (SHA_BLOCK8_LEN - handle->buffering_length); + memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); + if (length_rest >= SHA_BLOCK8_LEN) + { + ercd = R_SCE_Sha256UpdatePrivate(handle, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (message + (SHA_BLOCK8_LEN - handle->buffering_length)), + ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN) >> 2); + length_rest -= ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN); + } + + handle->buffering_length = 0; + memcpy(handle->sha_buffer, message + (message_length - length_rest), length_rest); + handle->buffering_length = length_rest; + } + else + { + memcpy(handle->sha_buffer + handle->buffering_length, message, message_length); + handle->buffering_length += message_length; + } + + return ercd; +} + +/*******************************************************************************************************************//** + * Using the handle specified in the first argument, handle, the R_SCE_SHA256_Final() function writes the calculation + * result to the second argument, digest, and writes the length of the calculation result to the third argument, + * digest_length. + * + * @param[in,out] handle SHA handler (work area) + * @param[in,out] digest hasha data area + * @param[in,out] digest_length hash data length (32bytes) + * + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. + * + * @note The pre-run state is SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. + **********************************************************************************************************************/ +fsp_err_t R_SCE_SHA256_Final (sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length) +{ + uint32_t max_cnt_byte = 0; + fsp_err_t ercd = FSP_SUCCESS; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_sha256_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->sha_buffer[handle->buffering_length] = SCE_HEX_80; + if ((SHA_BLOCK8_LEN - handle->buffering_length) >= 9) /* another block unnecessary */ + { + memset(handle->sha_buffer + (handle->buffering_length + 1), 0, + (SHA_BLOCK8_LEN - 4) - (handle->buffering_length + 1)); + + /* According c., but support only l < 2**32 case */ + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 3] = (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 2] = (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); + max_cnt_byte = SHA_BLOCK8_LEN; + } + else + { + /* another block necessary */ + memset(handle->sha_buffer + (handle->buffering_length + 1), 0, + ((2 * SHA_BLOCK8_LEN) - 4) - (handle->buffering_length + 1)); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 3] = + (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 2] = + (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); + max_cnt_byte = 2 * SHA_BLOCK8_LEN; + } + + ercd = R_SCE_Sha256FinalPrivate(handle, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (handle->sha_buffer), + max_cnt_byte >> 2, + (uint32_t *) (digest), + digest_length); + handle->all_received_length = 0; + handle->buffering_length = 0; + memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); + + return ercd; +} + +/*******************************************************************************************************************//** + * @} (end addtogroup SCE_PROTECTED) + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/sub.mk b/core/arch/arm/plat-rz/common/drivers/r_sce/sub.mk new file mode 100644 index 000000000..89e5ed0eb --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/sub.mk @@ -0,0 +1,8 @@ +srcs-y += public/r_sce_aes.c +srcs-y += public/r_sce_ecc.c +srcs-y += public/r_sce_rsa.c +srcs-y += public/r_sce_sha.c +srcs-y += public/r_sce.c +srcs-y += private/r_sce_private.c +global-incdirs-y += private/inc +global-incdirs-y += inc/api diff --git a/core/arch/arm/plat-rz/common/drivers/sce.c b/core/arch/arm/plat-rz/common/drivers/sce.c new file mode 100644 index 000000000..412861910 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/sce.c @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2021, Renesas Electronics + */ +#include +#include +#include +#include +#include +#include + +#include + +register_phys_mem_pgdir(MEM_AREA_IO_SEC, HW_SCE_BASE, HW_SCE_SIZE); + +static sce_cfg_t sce_cfg; +static sce_instance_ctrl_t sce_instance_ctrl; + +static TEE_Result SCE_Init(void) +{ + fsp_err_t err; + + int32_t retry_cnt = 3; + + gp_sce = (uint32_t *) phys_to_virt_io(HW_SCE_BASE, HW_SCE_SIZE); + + while (0 < retry_cnt) + { + err = g_sce_protected_on_sce.open(&sce_instance_ctrl, &sce_cfg); + switch (err) + { + case FSP_ERR_CRYPTO_SCE_RETRY: + retry_cnt--; + break; + default: + retry_cnt = 0; + break; + } + } + + if (FSP_SUCCESS != err) + { + EMSG("Failed to initialize SCE (0x%08x).", err); + panic(); + } + + return TEE_SUCCESS; +} + +driver_init(SCE_Init); diff --git a/core/arch/arm/plat-rz/common/drivers/sub.mk b/core/arch/arm/plat-rz/common/drivers/sub.mk index 361bf32e0..406309146 100644 --- a/core/arch/arm/plat-rz/common/drivers/sub.mk +++ b/core/arch/arm/plat-rz/common/drivers/sub.mk @@ -2,4 +2,7 @@ global-incdirs-y += . srcs-$(CFG_RZ_SCIF) += scif.c -subdirs-$(CFG_RZ_XSPI) += xspi \ No newline at end of file +subdirs-$(CFG_RZ_XSPI) += xspi + +srcs-$(CFG_RZ_SCE) += sce.c hw_rng.c +subdirs-$(CFG_RZ_SCE) += r_sce \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/pta/include/pta_flash.h b/core/arch/arm/plat-rz/common/pta/include/pta_flash.h index 7cc975e96..0d02e2ad1 100644 --- a/core/arch/arm/plat-rz/common/pta/include/pta_flash.h +++ b/core/arch/arm/plat-rz/common/pta/include/pta_flash.h @@ -7,13 +7,13 @@ #ifndef PTA_FLASH_H_ #define PTA_FLASH_H_ -#define FLASH_UUID \ - { \ - 0x2c0fca92, 0x5ab1, 0x11eb, \ - { \ - 0x81, 0x53, 0xc7, 0xd7, 0x50, 0xe0, 0xae, 0x47 \ - } \ - } +#define FLASH_UUID \ + { \ + 0x2c0fca92, 0x5ab1, 0x11eb, \ + { \ + 0x81, 0x53, 0xc7, 0xd7, 0x50, 0xe0, 0xae, 0x47 \ + } \ + } /* * FLASH_CMD_WRITE_SPI - Write data to SPI Flash diff --git a/core/arch/arm/plat-rz/conf.mk b/core/arch/arm/plat-rz/conf.mk index 408b61612..22c872236 100644 --- a/core/arch/arm/plat-rz/conf.mk +++ b/core/arch/arm/plat-rz/conf.mk @@ -27,6 +27,9 @@ include core/arch/arm/plat-rz/g3s/rzg3s_conf.mk else ifeq ($(PLATFORM_FLAVOR),g3s_dev14_1) $(call force,CFG_PLATFORM_GROUP_g3s,y) include core/arch/arm/plat-rz/g3s/rzg3s_conf.mk +else ifeq ($(PLATFORM_FLAVOR),v2h_evk_1) +$(call force,CFG_PLATFORM_GROUP_v2h,y) +include core/arch/arm/plat-rz/v2h/rzv2h_conf.mk else $(error Unsupported PLATFORM_FLAVOR "$(PLATFORM_FLAVOR)") endif diff --git a/core/arch/arm/plat-rz/platform_config.h b/core/arch/arm/plat-rz/platform_config.h index c7fcf8064..b72533105 100644 --- a/core/arch/arm/plat-rz/platform_config.h +++ b/core/arch/arm/plat-rz/platform_config.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (c) 2021, Renesas Electronics + * Copyright (c) 2021-2024, Renesas Electronics */ #ifndef PLATFORM_CONFIG_H @@ -10,6 +10,8 @@ #include "g2l/rzg2l_config.h" #elif defined(CFG_PLATFORM_GROUP_g3s) #include "g3s/rzg3s_config.h" +#elif defined(CFG_PLATFORM_GROUP_v2h) +#include "v2h/rzv2h_config.h" #endif #endif /*PLATFORM_CONFIG_H*/ diff --git a/core/arch/arm/plat-rz/sub.mk b/core/arch/arm/plat-rz/sub.mk index 54454dbf2..b2b5216d3 100644 --- a/core/arch/arm/plat-rz/sub.mk +++ b/core/arch/arm/plat-rz/sub.mk @@ -2,5 +2,6 @@ global-incdirs-y += . subdirs-$(CFG_PLATFORM_GROUP_g2l) += g2l subdirs-$(CFG_PLATFORM_GROUP_g3s) += g3s +subdirs-$(CFG_PLATFORM_GROUP_v2h) += v2h subdirs-y += common diff --git a/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.c b/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.c new file mode 100644 index 000000000..743b93415 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.c @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2024, Renesas Electronics Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CPG_T_CLK (0) +#define CPG_T_RST (1) + +typedef struct { + uintptr_t addr; + uint32_t val; +} CPG_REG_SETTING; + +typedef struct { + CPG_REG_SETTING reg; + CPG_REG_SETTING mon; + uint32_t type; +} CPG_SETUP_DATA; + + +register_phys_mem_pgdir(MEM_AREA_IO_NSEC, CPG_REG_BASE, CPG_REG_SIZE); + +static vaddr_t cpg_base; + +inline static void cpg_io_write(uint32_t reg, uint32_t data) +{ + DMSG("cpg_io_write: Addr:0x%x, Val:0x%x ", reg, data); + io_write32(cpg_base + reg, data); +} + +inline static uint32_t cpg_io_read(uint32_t reg) +{ + uint32_t ret; + ret = io_read32(cpg_base + reg); + DMSG("cpg_io_read: Addr:0x%x, Val:0x%x ", reg, ret); + return ret; +} + +static CPG_SETUP_DATA cpg_clk_on_tbl[] = { + + { /* xSPI */ + .reg = { + .addr = (uintptr_t)CPG_CLKON_9, + .val = 0x00008000, + }, + + .mon = { + .addr = (uintptr_t)CPG_CLKMON_4, + .val = 0x80000000, + }, + + .type = CPG_T_CLK + }, + + { /* xSPI */ + .reg = { + .addr = (uintptr_t)CPG_CLKON_10, + .val = 0x00000003, + }, + + .mon = { + .addr = (uintptr_t)CPG_CLKMON_5, + .val = 0x00000007, + }, + + .type = CPG_T_CLK + }, +}; + + +static CPG_SETUP_DATA cpg_reset_tbl[] = { + { /* xSPI */ + .reg = { + .addr = (uintptr_t)CPG_RST_10, + .val = 0x00000018, + }, + + .mon = { + .addr = (uintptr_t)CPG_RSTMON_4, + .val = 0x00300000, + }, + + .type = CPG_T_RST + } +}; + +static void cpg_clkon_rst(CPG_SETUP_DATA const *array, uint32_t num) +{ + int i; + uint32_t mask; + uint32_t cmp; + + for (i = 0; i < num; i++, array++) { + /* + * Upper 16bits are enables for lower 16bits so write the upper 16bits with same value as lower value + */ + uint32_t val = (array->reg.val & 0xFFFF) | ((array->reg.val & 0xFFFF) << 16); + + cpg_io_write(array->reg.addr, val); + + /* + * This generic function needs to handle case where Montitor for clock + * is looking for a HIGH as clock active whereas Montitoring a reset + * it is looking for a LOW to indicate reset release. + */ + mask = array->mon.val; + cmp = mask; + + if (array->type == CPG_T_RST) + cmp = ~cmp; + + while ((cpg_io_read(array->mon.addr) & mask) != (cmp & mask)) + ; + } +} + +static void cpg_clkoff_rst(CPG_SETUP_DATA const *array, uint32_t num) +{ + int i; + uint32_t mask; + uint32_t cmp; + + for (i = 0; i < num; i++, array++) { + /* + * Upper 16bits are enables for lower 16bits so write the upper 16bits with same value as lower value + */ + uint32_t val = (array->reg.val & 0xFFFF) | ((array->reg.val & 0xFFFF) << 16); + + + if (array->type == CPG_T_CLK) + val = val & 0xffff0000; + + cpg_io_write(array->reg.addr, val); + + /* + * This generic function needs to handle case where Montitor for clock + * is looking for a HIGH as clock active whereas Montitoring a reset + * it is looking for a LOW to indicate reset release. + */ + mask = array->mon.val; + cmp = mask; + + if ((array->type == CPG_T_CLK) || (array->type == CPG_T_RST)) + cmp = ~cmp; + + while ((cpg_io_read(array->mon.addr) & mask) != (cmp & mask)) + ; + } +} + + + +void cpg_xspi_start(void) +{ + DMSG("cpg_xspi_start is called."); + cpg_io_write(CPG_BUS_4_MSTOP, 0x00200000); + cpg_io_write(CPG_BUS_5_MSTOP, 0x00200000); + + cpg_clkon_rst(&cpg_clk_on_tbl[0], ARRAY_SIZE(cpg_clk_on_tbl)); + cpg_clkon_rst(&cpg_reset_tbl[0], ARRAY_SIZE(cpg_reset_tbl)); + +} + +void cpg_xspi_stop(void) +{ + DMSG("cpg_xspi_stop is called."); + cpg_io_write(CPG_BUS_4_MSTOP, 0x00200020); + cpg_io_write(CPG_BUS_5_MSTOP, 0x00200020); + cpg_clkoff_rst(&cpg_clk_on_tbl[0], ARRAY_SIZE(cpg_clk_on_tbl)); + cpg_clkoff_rst(&cpg_reset_tbl[0], ARRAY_SIZE(cpg_reset_tbl)); +} + +static TEE_Result cpg_init(void) +{ + cpg_base = (vaddr_t)phys_to_virt_io(CPG_REG_BASE, CPG_REG_SIZE); + + return TEE_SUCCESS; +} + +driver_init(cpg_init); diff --git a/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.h b/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.h new file mode 100644 index 000000000..aa4d8b03d --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2024, Renesas Electronics Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#ifndef _CPG_H_ +#define _CPG_H_ + +extern void cpg_xspi_start(void); +extern void cpg_xspi_stop(void); + +#endif /* _CPG_H_ */ diff --git a/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg_regs.h b/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg_regs.h new file mode 100644 index 000000000..2d13f4a1f --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg_regs.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024, Renesas Electronics Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef __CPG_REGS_H__ +#define __CPG_REGS_H__ + +#define CPG_CLKON_9 (0x0624) /* CGC Control Register xSPI */ +#define CPG_CLKON_10 (0x0628) /* CGC Control Register xSPI */ + +#define CPG_CLKMON_4 (0x0810) /* CGC Monitor Register xSPI */ +#define CPG_CLKMON_5 (0x0814) /* CGC Monitor Register xSPI */ + + +#define CPG_BUS_4_MSTOP (0x0D0C) /* MSTOP register 4 */ +#define CPG_BUS_5_MSTOP (0x0D10) /* MSTOP register 5 */ +#define CPG_RST_10 (0x0928) /* Reset Control Register xSPI */ +#define CPG_RSTMON_4 (0x0A10) /* Reset Monitor Registers xSPI */ + +#endif /* __CPG_REGS_H__ */ \ No newline at end of file diff --git a/core/arch/arm/plat-rz/v2h/drivers/cpg/sub.mk b/core/arch/arm/plat-rz/v2h/drivers/cpg/sub.mk new file mode 100644 index 000000000..c993d31e5 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/drivers/cpg/sub.mk @@ -0,0 +1,3 @@ +global-incdirs-y += . + +srcs-y += cpg.c \ No newline at end of file diff --git a/core/arch/arm/plat-rz/v2h/drivers/sce_lib/inc/instances/r_sce.h b/core/arch/arm/plat-rz/v2h/drivers/sce_lib/inc/instances/r_sce.h new file mode 100644 index 000000000..e143df4be --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/drivers/sce_lib/inc/instances/r_sce.h @@ -0,0 +1,424 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022-2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : r_sce.h + * Version : 1.0 + * Description : SCE API header file + *********************************************************************************************************************/ +/********************************************************************************************************************** + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release + *********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @addtogroup SCE_PROTECTED + * @{ + **********************************************************************************************************************/ + +#include +#include "r_sce_api.h" + +#ifndef R_SCE_H +#define R_SCE_H + + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* Various information. */ +#define HW_SCE_BASE (0x10440000) +#define HW_SCE_SIZE (0x10000) +#define HW_SCE_SRAM_WORD_SIZE (20U) +#define HW_SCE_SINST_WORD_SIZE (140U) +#define HW_SCE_SINST2_WORD_SIZE (16U) +#define HW_SCE_SHEAP_WORD_SIZE (1496U) +#define HW_SCE_MAC_SIZE (16U) + +/* ECC curve types. */ +#define SCE_ECC_CURVE_TYPE_NIST (0) +#define SCE_ECC_CURVE_TYPE_BRAINPOOL (1) +#define SCE_ECC_CURVE_TYPE_KOBLITZ (2) + +/* ECC curve size */ +#define SCE_ECC_KEY_LENGTH_256 (0) +#define SCE_ECC_KEY_LENGTH_224 (1) +#define SCE_ECC_KEY_LENGTH_192 (2) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/* key index type */ +typedef enum +{ + SCE_KEY_INDEX_TYPE_INVALID = 0U, + SCE_KEY_INDEX_TYPE_AES128, + SCE_KEY_INDEX_TYPE_AES256, + SCE_KEY_INDEX_TYPE_TDES, + SCE_KEY_INDEX_TYPE_HMAC_SHA1, + SCE_KEY_INDEX_TYPE_HMAC_SHA256, + SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE, + SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE, + SCE_KEY_INDEX_TYPE_RSA3072_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA3072_PRIVATE, + SCE_KEY_INDEX_TYPE_RSA4096_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA4096_PRIVATE, + SCE_KEY_INDEX_TYPE_AES128_FOR_TLS, + SCE_KEY_INDEX_TYPE_AES192_FOR_TLS, + SCE_KEY_INDEX_TYPE_AES256_FOR_TLS, + SCE_KEY_INDEX_TYPE_HMAC_SHA1_FOR_TLS, + SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_TLS, + SCE_KEY_INDEX_TYPE_UPDATE_KEY_RING, + SCE_KEY_INDEX_TYPE_TLS_CA_CERTIFICATION_PUBLIC_KEY, + SCE_KEY_INDEX_TYPE_TLS_P256_ECC_KEY, + SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P384_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P384_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P256R1_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P384R1_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P256R1_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P384R1_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PRIVATE, + SCE_KEY_INDEX_TYPE_ECDH_SHARED_SECRET, + SCE_KEY_INDEX_TYPE_AES128_FOR_ECDH, + SCE_KEY_INDEX_TYPE_AES256_FOR_ECDH, + SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_ECDH, + SCE_KEY_INDEX_TYPE_AES128_GCM_FOR_DLMS_COSEM, + SCE_KEY_INDEX_TYPE_AES256_GCM_FOR_DLMS_COSEM, + SCE_KEY_INDEX_TYPE_AES128_KEY_WRAP_FOR_DLMS_COSEM, + SCE_KEY_INDEX_TYPE_AES128_GCM_WITH_IV, +} SCE_KEY_INDEX_TYPE; + +/* OEM Command */ +typedef enum e_sce_oem_cmd +{ + SCE_OEM_CMD_AES128 = 5, + SCE_OEM_CMD_AES256 = 7, + SCE_OEM_CMD_RSA1024_PUBLIC = 10, + SCE_OEM_CMD_RSA1024_PRIVATE, + SCE_OEM_CMD_RSA2048_PUBLIC, + SCE_OEM_CMD_RSA2048_PRIVATE, + SCE_OEM_CMD_RSA3072_PUBLIC, + SCE_OEM_CMD_RSA3072_PRIVATE, + SCE_OEM_CMD_RSA4096_PUBLIC, + SCE_OEM_CMD_RSA4096_PRIVATE, + SCE_OEM_CMD_ECC_P192_PUBLIC, + SCE_OEM_CMD_ECC_P192_PRIVATE, + SCE_OEM_CMD_ECC_P224_PUBLIC, + SCE_OEM_CMD_ECC_P224_PRIVATE, + SCE_OEM_CMD_ECC_P256_PUBLIC, + SCE_OEM_CMD_ECC_P256_PRIVATE, + SCE_OEM_CMD_ECC_P384_PUBLIC, + SCE_OEM_CMD_ECC_P384_PRIVATE, + SCE_OEM_CMD_ECC_P512_PUBLIC, + SCE_OEM_CMD_ECC_P512_PRIVATE, + SCE_OEM_CMD_HMAC_SHA256 = 28, + SCE_OEM_CMD_NUM +} sce_oem_cmd_t; + +/** SCE private control block. DO NOT MODIFY. Initialization occurs when R_SCE_Open() is called. */ +typedef struct st_sce_instance_ctrl +{ + uint32_t open; // Indicates whether the open() API has been successfully +} sce_instance_ctrl_t; + +/********************************************************************************************************************** + * Exported global variables + **********************************************************************************************************************/ +/********************************************************************************************************************** + External global variables + *********************************************************************************************************************/ +/* memory area for SCE procedure */ +extern volatile uint32_t * gp_sce; + +/** @cond INC_HEADER_DEFS_SEC */ +/** Filled in Interface API structure for this Instance. */ +extern const sce_api_t g_sce_protected_on_sce; + +/** @endcond */ + +/********************************************************************************************************************** + * Public Function Prototypes + **********************************************************************************************************************/ +fsp_err_t R_SCE_Open(sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg); +fsp_err_t R_SCE_Close(sce_ctrl_t * const p_ctrl); +fsp_err_t R_SCE_SoftwareReset(void); + +fsp_err_t R_SCE_AES128_WrappedKeyGenerate(sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES256_WrappedKeyGenerate(sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSA1024_WrappedKeyPairGenerate(sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key); +fsp_err_t R_SCE_RSA2048_WrappedKeyPairGenerate(sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key); +fsp_err_t R_SCE_ECC_secp192r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); +fsp_err_t R_SCE_ECC_secp224r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); +fsp_err_t R_SCE_ECC_secp256r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); +fsp_err_t R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); +fsp_err_t R_SCE_RandomNumberGenerate(uint32_t * random); + +fsp_err_t R_SCE_AES128_EncryptedKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES256_EncryptedKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_aes_wrapped_key_t * wrapped_key); + +fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa4096_public_wrapped_key_t * wrapped_key); + +fsp_err_t R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + +fsp_err_t R_SCE_AES128ECB_EncryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES128ECB_EncryptUpdate(sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length); +fsp_err_t R_SCE_AES128ECB_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); +fsp_err_t R_SCE_AES128ECB_DecryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES128ECB_DecryptUpdate(sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length); +fsp_err_t R_SCE_AES128ECB_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); +fsp_err_t R_SCE_AES256ECB_EncryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES256ECB_EncryptUpdate(sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length); +fsp_err_t R_SCE_AES256ECB_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); +fsp_err_t R_SCE_AES256ECB_DecryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES256ECB_DecryptUpdate(sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length); +fsp_err_t R_SCE_AES256ECB_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + +fsp_err_t R_SCE_AES128CBC_EncryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES128CBC_EncryptUpdate(sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length); +fsp_err_t R_SCE_AES128CBC_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); +fsp_err_t R_SCE_AES128CBC_DecryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES128CBC_DecryptUpdate(sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length); +fsp_err_t R_SCE_AES128CBC_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); +fsp_err_t R_SCE_AES256CBC_EncryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES256CBC_EncryptUpdate(sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length); +fsp_err_t R_SCE_AES256CBC_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); +fsp_err_t R_SCE_AES256CBC_DecryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES256CBC_DecryptUpdate(sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length); +fsp_err_t R_SCE_AES256CBC_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + +fsp_err_t R_SCE_AES128CTR_EncryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES128CTR_EncryptUpdate(sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length); +fsp_err_t R_SCE_AES128CTR_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); +fsp_err_t R_SCE_AES128CTR_DecryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES128CTR_DecryptUpdate(sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length); +fsp_err_t R_SCE_AES128CTR_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); +fsp_err_t R_SCE_AES256CTR_EncryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES256CTR_EncryptUpdate(sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length); +fsp_err_t R_SCE_AES256CTR_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); +fsp_err_t R_SCE_AES256CTR_DecryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES256CTR_DecryptUpdate(sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length); +fsp_err_t R_SCE_AES256CTR_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + +fsp_err_t R_SCE_AES128CMAC_GenerateInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES128CMAC_GenerateUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); +fsp_err_t R_SCE_AES128CMAC_GenerateFinal(sce_cmac_handle_t * handle, uint8_t * mac); +fsp_err_t R_SCE_AES128CMAC_VerifyInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES128CMAC_VerifyUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); +fsp_err_t R_SCE_AES128CMAC_VerifyFinal(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); +fsp_err_t R_SCE_AES256CMAC_GenerateInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES256CMAC_GenerateUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); +fsp_err_t R_SCE_AES256CMAC_GenerateFinal(sce_cmac_handle_t * handle, uint8_t * mac); +fsp_err_t R_SCE_AES256CMAC_VerifyInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES256CMAC_VerifyUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); +fsp_err_t R_SCE_AES256CMAC_VerifyFinal(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); + +fsp_err_t R_SCE_SHA224_Init(sce_sha_md5_handle_t * handle); +fsp_err_t R_SCE_SHA224_Update(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); +fsp_err_t R_SCE_SHA224_Final(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); +fsp_err_t R_SCE_SHA256_Init(sce_sha_md5_handle_t * handle); +fsp_err_t R_SCE_SHA256_Update(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); +fsp_err_t R_SCE_SHA256_Final(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); + +fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate(sce_rsa_byte_data_t * message_hash, + sce_rsa_byte_data_t * signature, + sce_rsa1024_private_wrapped_key_t * wrapped_key, + uint8_t hash_type); +fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureVerify(sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, + sce_rsa1024_public_wrapped_key_t * wrapped_key, + uint8_t hash_type); +fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate(sce_rsa_byte_data_t * message_hash, + sce_rsa_byte_data_t * signature, + sce_rsa2048_private_wrapped_key_t * wrapped_key, + uint8_t hash_type); +fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify(sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, + sce_rsa2048_public_wrapped_key_t * wrapped_key, + uint8_t hash_type); +fsp_err_t R_SCE_RSASSA_PKCS4096_SignatureVerify(sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, + sce_rsa4096_public_wrapped_key_t * wrapped_key, + uint8_t hash_type); + +fsp_err_t R_SCE_RSAES_PKCS1024_Encrypt(sce_rsa_byte_data_t * plain, + sce_rsa_byte_data_t * cipher, + sce_rsa1024_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt(sce_rsa_byte_data_t * cipher, + sce_rsa_byte_data_t * plain, + sce_rsa1024_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSAES_PKCS2048_Encrypt(sce_rsa_byte_data_t * plain, + sce_rsa_byte_data_t * cipher, + sce_rsa2048_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSAES_PKCS2048_Decrypt(sce_rsa_byte_data_t * cipher, + sce_rsa_byte_data_t * plain, + sce_rsa2048_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt(sce_rsa_byte_data_t * plain, + sce_rsa_byte_data_t * cipher, + sce_rsa4096_public_wrapped_key_t * wrapped_key); + +fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + +#endif /* R_SCE_H */ + +/*******************************************************************************************************************//** + * @} (end addtogroup SCE_PROTECTED) + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/v2h/drivers/sce_lib/sub.mk b/core/arch/arm/plat-rz/v2h/drivers/sce_lib/sub.mk new file mode 100644 index 000000000..82da2488a --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/drivers/sce_lib/sub.mk @@ -0,0 +1,4 @@ + +global-incdirs-y += inc/instances + +ldflags-external += $(CFG_RZ_SCE_LIB_DIR)/libr_secure_ip_2_0.a.1.0.0 diff --git a/core/arch/arm/plat-rz/v2h/drivers/sflash.c b/core/arch/arm/plat-rz/v2h/drivers/sflash.c new file mode 100644 index 000000000..603c7d76f --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/drivers/sflash.c @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2023-2024, Renesas Electronics Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +register_phys_mem_pgdir(MEM_AREA_IO_NSEC, SPI_FLASH_BASE, SPI_FLASH_SIZE); + +static vaddr_t sflash_base; +static uint32_t sflash_work[SPI_SECTOR_SIZE / sizeof(uint32_t)]; + +static vaddr_t sflash_phys_to_virt(uint32_t addr) +{ + return (vaddr_t)(sflash_base + (addr & 0x00FFFFFF)); +} + +void sflash_write_buffer(uint32_t addr, uintptr_t buff, size_t len) +{ + uintptr_t sflash_work_base = (uintptr_t)&sflash_work[0]; + uintptr_t base_sector_addr = ROUNDDOWN(addr, SPI_SECTOR_SIZE); + uintptr_t last_sector_addr = ROUNDDOWN(addr + len - 1, SPI_SECTOR_SIZE); + uint32_t write_offset; + uint32_t write_length; + int32_t secotr_count; + + secotr_count = ((last_sector_addr - base_sector_addr) / SPI_SECTOR_SIZE) + 1; + write_offset = addr - base_sector_addr; + write_length = MIN(len, SPI_SECTOR_SIZE - write_offset); + + if (write_offset != 0) { + + vaddr_t virt_addr = sflash_phys_to_virt(base_sector_addr); + + memcpy((void *)sflash_work_base, (void *)virt_addr, SPI_SECTOR_SIZE); + + memcpy((void *)(sflash_work_base + write_offset), (void *)buff, write_length); + + xspi_write(base_sector_addr, sflash_work_base, SPI_SECTOR_SIZE); + + base_sector_addr += SPI_SECTOR_SIZE; + + secotr_count--; + } + + write_length = (addr + len) - last_sector_addr; + + if ((secotr_count > 0) && ((write_length % SPI_SECTOR_SIZE) > 0)) { + + vaddr_t virt_addr = sflash_phys_to_virt(last_sector_addr); + + memcpy((void *)sflash_work_base, (void *)virt_addr, SPI_SECTOR_SIZE); + + memcpy((void *)sflash_work_base, (void *)((buff + len) - write_length), write_length); + + xspi_write(last_sector_addr, sflash_work_base, SPI_SECTOR_SIZE); + + secotr_count--; + } + + write_length = secotr_count * SPI_SECTOR_SIZE; + + if(secotr_count > 0) { + + xspi_write(base_sector_addr, buff + (base_sector_addr - addr), write_length); + } +} + +void sflash_open(void) +{ + cpg_xspi_start(); + xspi_setup(); +} + +void sflash_close(void) +{ + cpg_xspi_stop(); +} + +static TEE_Result sflash_init(void) +{ + sflash_base = (vaddr_t)phys_to_virt_io(SPI_FLASH_BASE, SPI_FLASH_SIZE); + + return TEE_SUCCESS; +} + +driver_init(sflash_init); \ No newline at end of file diff --git a/core/arch/arm/plat-rz/v2h/drivers/sflash.h b/core/arch/arm/plat-rz/v2h/drivers/sflash.h new file mode 100644 index 000000000..266017e53 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/drivers/sflash.h @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2023-2024, Renesas Electronics Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _SFLASH_H_ +#define _SFLASH_H_ + +extern void sflash_open(void); +extern void sflash_close(void); +extern void sflash_write_buffer(uint32_t addr, uintptr_t buff, size_t len); + +#endif /* _SFLASH_H_ */ diff --git a/core/arch/arm/plat-rz/v2h/drivers/sub.mk b/core/arch/arm/plat-rz/v2h/drivers/sub.mk new file mode 100644 index 000000000..2680d487b --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/drivers/sub.mk @@ -0,0 +1,7 @@ +global-incdirs-y += . + +srcs-y += sflash.c + +subdirs-$(CFG_RZ_SCE) += sce_lib + +subdirs-y += cpg \ No newline at end of file diff --git a/core/arch/arm/plat-rz/v2h/main.c b/core/arch/arm/plat-rz/v2h/main.c new file mode 100644 index 000000000..74cfba29b --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/main.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2016, GlobalLogic + * Copyright (c) 2021-2024, Renesas Electronics + */ + +#include +#include +#include +#include +#include +#include + +register_phys_mem_pgdir(MEM_AREA_IO_SEC, CONSOLE_UART_BASE, SCIF_REG_SIZE); +register_phys_mem_pgdir(MEM_AREA_IO_SEC, GICD_BASE, GIC_DIST_REG_SIZE); + +register_dynamic_shm(NSEC_DDR_0_BASE, NSEC_DDR_0_SIZE); +#ifdef NSEC_DDR_1_BASE +register_dynamic_shm(NSEC_DDR_1_BASE, NSEC_DDR_1_SIZE); +#endif +#ifdef NSEC_DDR_2_BASE +register_dynamic_shm(NSEC_DDR_2_BASE, NSEC_DDR_2_SIZE); +#endif +#ifdef NSEC_DDR_3_BASE +register_dynamic_shm(NSEC_DDR_3_BASE, NSEC_DDR_3_SIZE); +#endif + +static struct scif_uart_data console_data __nex_bss; + +void console_init(void) +{ + scif_uart_init(&console_data, CONSOLE_UART_BASE); + register_serial_console(&console_data.chip); +} diff --git a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce.h b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce.h new file mode 100644 index 000000000..7d2f2364e --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce.h @@ -0,0 +1,179 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ +#ifndef __PTA_SCE_H +#define __PTA_SCE_H + +#include + +#define PTA_SCE_UUID \ + { 0x3b221d77, 0xe679, 0x4ca5, \ + { 0xa4, 0x48, 0x1f, 0x9f, 0x16, 0x02, 0x15, 0xc5 } } + +/* + * [in/out] memref[0] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES128_WrappedKeyGenerate (0x00010000) + +/* + * [in/out] memref[0] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES256_WrappedKeyGenerate (0x00010100) + +/* + * [in/out] memref[0] : Wrapped key (sce_rsa1024_wrapped_pair_key_t) + */ +#define PTA_CMD_RSA1024_WrappedKeyPairGenerate (0x00011000) + +/* + * [in/out] memref[0] : Wrapped key (sce_rsa2048_wrapped_pair_key_t) + */ +#define PTA_CMD_RSA2048_WrappedKeyPairGenerate (0x00011100) + +/* + * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) + */ +#define PTA_CMD_ECC_secp192r1_WrappedKeyPairGenerate (0x00012000) + +/* + * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) + */ +#define PTA_CMD_ECC_secp224r1_WrappedKeyPairGenerate (0x00012100) + +/* + * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) + */ +#define PTA_CMD_ECC_secp256r1_WrappedKeyPairGenerate (0x00012200) + +/* + * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) + */ +#define PTA_CMD_ECC_BrainpoolP512r1_WrappedKeyPairGenerate (0x00013000) + +/* + * [in/out] memref[0] : random data (16byte) + */ +#define PTA_CMD_RandomNumberGenerate (0x00014000) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (32byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES128_EncryptedKeyWrap (0x00015000) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (64byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES256_EncryptedKeyWrap (0x00015100) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (160byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_rsa1024_public_wrapped_key_t) + */ +#define PTA_CMD_RSA1024_EncryptedPublicKeyWrap (0x00016000) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (272byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_rsa1024_private_wrapped_key_t) + */ +#define PTA_CMD_RSA1024_EncryptedPrivateKeyWrap (0x00016010) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (288byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_rsa2048_public_wrapped_key_t) + */ +#define PTA_CMD_RSA2048_EncryptedPublicKeyWrap (0x00016100) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (528byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_rsa2048_private_wrapped_key_t) + */ +#define PTA_CMD_RSA2048_EncryptedPrivateKeyWrap (0x00016110) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (544byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_rsa4096_public_wrapped_key_t) + */ +#define PTA_CMD_RSA4096_EncryptedPublicKeyWrap (0x00016200) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECC_secp192r1_EncryptedPublicKeyWrap (0x00017000) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECC_secp192r1_EncryptedPrivateKeyWrap (0x00017010) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECC_secp224r1_EncryptedPublicKeyWrap (0x00017100) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECC_secp224r1_EncryptedPrivateKeyWrap (0x00017110) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECC_secp256r1_EncryptedPublicKeyWrap (0x00017200) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECC_secp256r1_EncryptedPrivateKeyWrap (0x00017210) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (144byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap (0x00018000) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap (0x00018010) + +#endif /* __PTA_SCE_H */ diff --git a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_aes.h b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_aes.h new file mode 100644 index 000000000..101b869f2 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_aes.h @@ -0,0 +1,279 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ +#ifndef __PTA_SCE_AES_H +#define __PTA_SCE_AES_H + +#include + +#define PTA_SCE_AES_UUID \ + { 0x4be7b9c4, 0x4951, 0x4105, \ + { 0xa3, 0xd3, 0x08, 0x1b, 0x50, 0x98, 0x10, 0xef } } + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES128ECB_EncryptInit (0x00020001) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : plain (length must be a multiple of 16) + * [in/out] memref[2] : cipher + */ +#define PTA_CMD_AES128ECB_EncryptUpdate (0x00020002) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES128ECB_EncryptFinal (0x00020003) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES128ECB_DecryptInit (0x00020011) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : cipher (length must be a multiple of 16) + * [in/out] memref[2] : plain + */ +#define PTA_CMD_AES128ECB_DecryptUpdate (0x00020012) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES128ECB_DecryptFinal (0x00020013) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES256ECB_EncryptInit (0x00020101) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : plain (length must be a multiple of 16) + * [in/out] memref[2] : cipher + */ +#define PTA_CMD_AES256ECB_EncryptUpdate (0x00020102) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES256ECB_EncryptFinal (0x00020103) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES256ECB_DecryptInit (0x00020111) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : cipher (length must be a multiple of 16) + * [in/out] memref[2] : plain + */ +#define PTA_CMD_AES256ECB_DecryptUpdate (0x00020112) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES256ECB_DecryptFinal (0x00020113) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES128CBC_EncryptInit (0x00021001) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : plain (length must be a multiple of 16) + * [in/out] memref[2] : cipher + */ +#define PTA_CMD_AES128CBC_EncryptUpdate (0x00021002) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES128CBC_EncryptFinal (0x00021003) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES128CBC_DecryptInit (0x00021011) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : cipher (length must be a multiple of 16) + * [in/out] memref[2] : plain + */ +#define PTA_CMD_AES128CBC_DecryptUpdate (0x00021012) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES128CBC_DecryptFinal (0x00021013) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES256CBC_EncryptInit (0x00021101) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : plain (length must be a multiple of 16) + * [in/out] memref[2] : cipher + */ +#define PTA_CMD_AES256CBC_EncryptUpdate (0x00021102) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES256CBC_EncryptFinal (0x00021103) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES256CBC_DecryptInit (0x00021111) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : cipher (length must be a multiple of 16) + * [in/out] memref[2] : plain + */ +#define PTA_CMD_AES256CBC_DecryptUpdate (0x00021112) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES256CBC_DecryptFinal (0x00021113) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES128CTR_EncryptInit (0x00022001) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : plain (length must be a multiple of 16) + * [in/out] memref[2] : cipher + */ +#define PTA_CMD_AES128CTR_EncryptUpdate (0x00022002) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES128CTR_EncryptFinal (0x00022003) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES128CTR_DecryptInit (0x00022011) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : cipher (length must be a multiple of 16) + * [in/out] memref[2] : plain + */ +#define PTA_CMD_AES128CTR_DecryptUpdate (0x00022012) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES128CTR_DecryptFinal (0x00022013) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES256CTR_EncryptInit (0x00022101) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : plain (length must be a multiple of 16) + * [in/out] memref[2] : cipher + */ +#define PTA_CMD_AES256CTR_EncryptUpdate (0x00022102) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES256CTR_EncryptFinal (0x00022103) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES256CTR_DecryptInit (0x00022111) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : cipher (length must be a multiple of 16) + * [in/out] memref[2] : plain + */ +#define PTA_CMD_AES256CTR_DecryptUpdate (0x00022112) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES256CTR_DecryptFinal (0x00022113) + +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES128CMAC_GenerateInit (0x00023001) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : message + */ +#define PTA_CMD_AES128CMAC_GenerateUpdate (0x00023002) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in/out] memref[1] : mac (16byte) + */ +#define PTA_CMD_AES128CMAC_GenerateFinal (0x00023003) + +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES128CMAC_VerifyInit (0x00023011) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : message + */ +#define PTA_CMD_AES128CMAC_VerifyUpdate (0x00023012) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : mac (2 to 16bytes) + */ +#define PTA_CMD_AES128CMAC_VerifyFinal (0x00023013) + +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES256CMAC_GenerateInit (0x00023101) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : message + */ +#define PTA_CMD_AES256CMAC_GenerateUpdate (0x00023102) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in/out] memref[1] : mac (16byte) + */ +#define PTA_CMD_AES256CMAC_GenerateFinal (0x00023103) + +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES256CMAC_VerifyInit (0x00023111) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : message + */ +#define PTA_CMD_AES256CMAC_VerifyUpdate (0x00023112) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : mac (2 to 16bytes) + */ +#define PTA_CMD_AES256CMAC_VerifyFinal (0x00023113) + + +#endif /* __PTA_SCE_AES_H */ diff --git a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_ecc.h b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_ecc.h new file mode 100644 index 000000000..6845d0df9 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_ecc.h @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ +#ifndef __PTA_SCE_ECC_H +#define __PTA_SCE_ECC_H + +#include + +#define PTA_SCE_ECC_UUID \ + { 0xa0c74f91, 0xbaac, 0x4ba3, \ + { 0x96, 0xbe, 0x58, 0xe5, 0x1f, 0xb1, 0xd1, 0xba } } + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (64byte) + * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_secp192r1_SignatureGenerate (0x00050000) + +/* + * [in] memref[0] : Signature (64byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_secp192r1_SignatureVerify (0x00050010) + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (64byte) + * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_secp224r1_SignatureGenerate (0x00050100) + +/* + * [in] memref[0] : Signature (64byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_secp224r1_SignatureVerify (0x00050110) + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (64byte) + * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_secp256r1_SignatureGenerate (0x00050200) + +/* + * [in] memref[0] : Signature (64byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_secp256r1_SignatureVerify (0x00050210) + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (64byte) + * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_BrainpoolP512r1_SignatureGenerate (0x00051000) + +/* + * [in] memref[0] : Signature (64byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_BrainpoolP512r1_SignatureVerify (0x00051010) + +#endif /* __PTA_SCE_ECC_H */ diff --git a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_rsa.h b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_rsa.h new file mode 100644 index 000000000..3be51d0d4 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_rsa.h @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ +#ifndef __PTA_SCE_RSA_H +#define __PTA_SCE_RSA_H + +#include + +#define PTA_SCE_RSA_UUID \ + { 0x5ad57120, 0xc447, 0x4b17, \ + { 0x90, 0x7b, 0x03, 0x1a, 0xd8, 0xd9, 0xb1, 0x7c } } + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (128byte) + * [in] memref[2] : Wrapped key (sce_rsa1024_private_wrapped_key_t) + */ +#define PTA_CMD_RSASSA_PKCS1024_SignatureGenerate (0x00040000) + +/* + * [in] memref[0] : Signature (128byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_rsa1024_public_wrapped_key_t) + */ +#define PTA_CMD_RSASSA_PKCS1024_SignatureVerify (0x00040010) + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (256byte) + * [in] memref[2] : Wrapped key (sce_rsa2048_private_wrapped_key_t) + */ +#define PTA_CMD_RSASSA_PKCS2048_SignatureGenerate (0x00040100) + +/* + * [in] memref[0] : Signature (256byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_rsa2048_public_wrapped_key_t) + */ +#define PTA_CMD_RSASSA_PKCS2048_SignatureVerify (0x00040110) + +/* + * [in] memref[0] : Signature (512byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_rsa4096_public_wrapped_key_t) + */ +#define PTA_CMD_RSASSA_PKCS4096_SignatureVerify (0x00040210) + +/* + * [in] memref[0] : plain (size <= public key n size - 11 byte) + * [in/out] memref[1] : cipher (size >= public key n byte) + * [in] memref[2] : Wrapped key (sce_rsa1024_public_wrapped_key_t) + */ +#define PTA_CMD_RSAES_PKCS1024_Encrypt (0x00041000) + +/* + * [in] memref[0] : cipher (size == public key n byte) + * [in/out] memref[1] : plain (size >= public key n - 11 byte) + * [in] memref[2] : Wrapped key (sce_rsa1024_private_wrapped_key_t) + */ +#define PTA_CMD_RSAES_PKCS1024_Decrypt (0x00041010) + +/* + * [in] memref[0] : plain (size <= public key n - 11 byte) + * [in/out] memref[1] : cipher (size >= public key n byte) + * [in] memref[2] : Wrapped key (sce_rsa2048_public_wrapped_key_t) + */ +#define PTA_CMD_RSAES_PKCS2048_Encrypt (0x00041100) + +/* + * [in] memref[0] : cipher (size == public key n byte) + * [in/out] memref[1] : plain (size >= public key n - 11 byte) + * [in] memref[2] : Wrapped key (sce_rsa2048_private_wrapped_key_t) + */ +#define PTA_CMD_RSAES_PKCS2048_Decrypt (0x00041110) + +/* + * [in] memref[0] : plain (size <= public key n - 11 byte) + * [in/out] memref[1] : cipher (size >= public key n byte) + * [in] memref[2] : Wrapped key (sce_rsa4096_public_wrapped_key_t) + */ +#define PTA_CMD_RSAES_PKCS4096_Encrypt (0x00041200) + +#endif /* __PTA_SCE_RSA_H */ diff --git a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_sha.h b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_sha.h new file mode 100644 index 000000000..c112ce0f7 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_sha.h @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ +#ifndef __PTA_SCE_SHA_H +#define __PTA_SCE_SHA_H + +#include + +#define PTA_SCE_SHA_UUID \ + { 0x5b6cecf4, 0x12ae, 0x4c0f, \ + { 0x94, 0xb5, 0xce, 0xcc, 0x5f, 0x48, 0x62, 0xe4 } } + +/* + * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) + */ +#define PTA_CMD_SHA224_Init (0x00030000) + +/* + * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_SHA224_Update (0x00030001) + +/* + * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) + * [in/out] memref[1] : Digest (28byte) + */ +#define PTA_CMD_SHA224_Final (0x00030002) + +/* + * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) + */ +#define PTA_CMD_SHA256_Init (0x00030100) + +/* + * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_SHA256_Update (0x00030101) + +/* + * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) + * [in/out] memref[1] : Digest (32byte) + */ +#define PTA_CMD_SHA256_Final (0x00030102) + +#endif /* __PTA_SCE_SHA_H */ diff --git a/core/arch/arm/plat-rz/v2h/pta/pta_sce.c b/core/arch/arm/plat-rz/v2h/pta/pta_sce.c new file mode 100644 index 000000000..88606bfe0 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/pta/pta_sce.c @@ -0,0 +1,1170 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ + +#include + +#include +#include + +#define PTA_NAME "sce.pta" + +static TEE_Result aes128_wrappedkeygenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128_WrappedKeyGenerate(wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ + return TEE_ERROR_ACCESS_CONFLICT; + } + + params[0].memref.size = sizeof(sce_aes_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256_wrappedkeygenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256_WrappedKeyGenerate(wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ + return TEE_ERROR_ACCESS_CONFLICT; + } + + params[0].memref.size = sizeof(sce_aes_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa1024_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pair_key = (sce_rsa1024_wrapped_pair_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_pair_key) || (sizeof(sce_rsa1024_wrapped_pair_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA1024_WrappedKeyPairGenerate(wrapped_pair_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_rsa1024_wrapped_pair_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa2048_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pair_key = (sce_rsa2048_wrapped_pair_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_pair_key) || (sizeof(sce_rsa2048_wrapped_pair_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA2048_WrappedKeyPairGenerate(wrapped_pair_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_rsa2048_wrapped_pair_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp192r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecc_wrapped_pair_key_t * wrapped_pair_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp192r1_WrappedKeyPairGenerate(wrapped_pair_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp224r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecc_wrapped_pair_key_t * wrapped_pair_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp224r1_WrappedKeyPairGenerate(wrapped_pair_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp256r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecc_wrapped_pair_key_t * wrapped_pair_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp256r1_WrappedKeyPairGenerate(wrapped_pair_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_brainpoolp512r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecc_wrapped_pair_key_t * wrapped_pair_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_BrainpoolP512r1_WrappedKeyPairGenerate(wrapped_pair_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result randomnumbergenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint32_t * random; + + const uint32_t random_length = 16; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + random = (uint32_t *)params[0].memref.buffer; + if ((NULL == random) || (random_length > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.randomNumberGenerate(random); + switch (err) + { + case FSP_SUCCESS: + break; + default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ + return TEE_ERROR_ACCESS_CONFLICT; + } + + params[0].memref.size = random_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128_encryptedkeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || ((SCE_OEM_KEY_SIZE_AES128_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128_EncryptedKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_aes_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256_encryptedkeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || ((SCE_OEM_KEY_SIZE_AES256_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256_EncryptedKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_aes_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa1024_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_rsa1024_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_RSA1024_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa1024_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA1024_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_rsa1024_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa1024_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_rsa1024_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_RSA1024_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa1024_private_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_private_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA1024_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_rsa1024_private_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa2048_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_rsa2048_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_RSA2048_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa2048_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA2048_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_rsa2048_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa2048_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_rsa2048_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_RSA2048_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa2048_private_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_private_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA2048_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_rsa2048_private_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa4096_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_rsa4096_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_RSA4096_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa4096_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa4096_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA4096_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_rsa4096_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp192r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP192_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp192r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp192r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP192_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp192r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp224r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP224_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp224r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp224r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP224_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp224r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp256r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP256_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp256r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp256r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP256_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp256r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_brainpoolp512r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP512_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_BrainpoolP512r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_brainpoolp512r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP512_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_AES128_WrappedKeyGenerate : + return aes128_wrappedkeygenerate(ptypes, params); + case PTA_CMD_AES256_WrappedKeyGenerate : + return aes256_wrappedkeygenerate(ptypes, params); + case PTA_CMD_RSA1024_WrappedKeyPairGenerate : + return rsa1024_wrappedkeypairgenerate(ptypes, params); + case PTA_CMD_RSA2048_WrappedKeyPairGenerate : + return rsa2048_wrappedkeypairgenerate(ptypes, params); + case PTA_CMD_ECC_secp192r1_WrappedKeyPairGenerate : + return ecc_secp192r1_wrappedkeypairgenerate(ptypes, params); + case PTA_CMD_ECC_secp224r1_WrappedKeyPairGenerate : + return ecc_secp224r1_wrappedkeypairgenerate(ptypes, params); + case PTA_CMD_ECC_secp256r1_WrappedKeyPairGenerate : + return ecc_secp256r1_wrappedkeypairgenerate(ptypes, params); + case PTA_CMD_ECC_BrainpoolP512r1_WrappedKeyPairGenerate : + return ecc_brainpoolp512r1_wrappedkeypairgenerate(ptypes, params); + case PTA_CMD_RandomNumberGenerate : + return randomnumbergenerate(ptypes, params); + case PTA_CMD_AES128_EncryptedKeyWrap : + return aes128_encryptedkeywrap(ptypes, params); + case PTA_CMD_AES256_EncryptedKeyWrap : + return aes256_encryptedkeywrap(ptypes, params); + case PTA_CMD_RSA1024_EncryptedPublicKeyWrap : + return rsa1024_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_RSA1024_EncryptedPrivateKeyWrap : + return rsa1024_encryptedprivatekeywrap(ptypes, params); + case PTA_CMD_RSA2048_EncryptedPublicKeyWrap : + return rsa2048_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_RSA2048_EncryptedPrivateKeyWrap : + return rsa2048_encryptedprivatekeywrap(ptypes, params); + case PTA_CMD_RSA4096_EncryptedPublicKeyWrap : + return rsa4096_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_ECC_secp192r1_EncryptedPublicKeyWrap : + return ecc_secp192r1_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_ECC_secp224r1_EncryptedPublicKeyWrap : + return ecc_secp224r1_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_ECC_secp256r1_EncryptedPublicKeyWrap : + return ecc_secp256r1_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap : + return ecc_brainpoolp512r1_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_ECC_secp192r1_EncryptedPrivateKeyWrap : + return ecc_secp192r1_encryptedprivatekeywrap(ptypes, params); + case PTA_CMD_ECC_secp224r1_EncryptedPrivateKeyWrap : + return ecc_secp224r1_encryptedprivatekeywrap(ptypes, params); + case PTA_CMD_ECC_secp256r1_EncryptedPrivateKeyWrap : + return ecc_secp256r1_encryptedprivatekeywrap(ptypes, params); + case PTA_CMD_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap : + return ecc_brainpoolp512r1_encryptedprivatekeywrap(ptypes, params); + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_SCE_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/v2h/pta/pta_sce_aes.c b/core/arch/arm/plat-rz/v2h/pta/pta_sce_aes.c new file mode 100644 index 000000000..7a53c976a --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/pta/pta_sce_aes.c @@ -0,0 +1,2257 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ + +#include + +#include +#include + +#define PTA_NAME "sce_aes.pta" + +static TEE_Result aes128ecb_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128ECB_EncryptInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128ecb_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[2].memref.buffer; + cipher_length = (uint32_t)params[2].memref.size; + if ((NULL == cipher) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128ECB_EncryptUpdate(handle, plain, cipher, plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128ecb_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = NULL; // nothing ever written here + cipher_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES128ECB_EncryptFinal(handle, cipher, &cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128ecb_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128ECB_DecryptInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128ecb_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[2].memref.buffer; + plain_length = (uint32_t)params[2].memref.size; + if ((NULL == plain) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128ECB_DecryptUpdate(handle, cipher, plain, cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128ecb_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = NULL; // nothing ever written here + plain_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES128ECB_DecryptFinal(handle, plain, &plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256ecb_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256ECB_EncryptInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256ecb_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[2].memref.buffer; + cipher_length = (uint32_t)params[2].memref.size; + if ((NULL == cipher) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256ECB_EncryptUpdate(handle, plain, cipher, plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes256ecb_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = NULL; // nothing ever written here + cipher_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES256ECB_EncryptFinal(handle, cipher, &cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256ecb_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256ECB_DecryptInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256ecb_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[2].memref.buffer; + plain_length = (uint32_t)params[2].memref.size; + if ((NULL == plain) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256ECB_DecryptUpdate(handle, cipher, plain, cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes256ecb_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = NULL; // nothing ever written here + plain_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES256ECB_DecryptFinal(handle, plain, &plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128cbc_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CBC_EncryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128cbc_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[2].memref.buffer; + cipher_length = (uint32_t)params[2].memref.size; + if ((NULL == cipher) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CBC_EncryptUpdate(handle, plain, cipher, plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128cbc_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = NULL; // nothing ever written here + cipher_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES128CBC_EncryptFinal(handle, cipher, &cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128cbc_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CBC_DecryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128cbc_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[2].memref.buffer; + plain_length = (uint32_t)params[2].memref.size; + if ((NULL == plain) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CBC_DecryptUpdate(handle, cipher, plain, cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128cbc_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = NULL; // nothing ever written here + plain_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES128CBC_DecryptFinal(handle, plain, &plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256cbc_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CBC_EncryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256cbc_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[2].memref.buffer; + cipher_length = (uint32_t)params[2].memref.size; + if ((NULL == cipher) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CBC_EncryptUpdate(handle, plain, cipher, plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes256cbc_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = NULL; // nothing ever written here + cipher_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES256CBC_EncryptFinal(handle, cipher, &cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256cbc_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CBC_DecryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256cbc_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[2].memref.buffer; + plain_length = (uint32_t)params[2].memref.size; + if ((NULL == plain) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CBC_DecryptUpdate(handle, cipher, plain, cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes256cbc_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = NULL; // nothing ever written here + plain_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES256CBC_DecryptFinal(handle, plain, &plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128ctr_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CTR_EncryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128ctr_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[2].memref.buffer; + cipher_length = (uint32_t)params[2].memref.size; + if ((NULL == cipher) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CTR_EncryptUpdate(handle, plain, cipher, plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128ctr_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = NULL; // nothing ever written here + cipher_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES128CTR_EncryptFinal(handle, cipher, &cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128ctr_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CTR_DecryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128ctr_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[2].memref.buffer; + plain_length = (uint32_t)params[2].memref.size; + if ((NULL == plain) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CTR_DecryptUpdate(handle, cipher, plain, cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128ctr_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = NULL; // nothing ever written here + plain_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES128CTR_DecryptFinal(handle, plain, &plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256ctr_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CTR_EncryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256ctr_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[2].memref.buffer; + cipher_length = (uint32_t)params[2].memref.size; + if ((NULL == cipher) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CTR_EncryptUpdate(handle, plain, cipher, plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes256ctr_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = NULL; // nothing ever written here + cipher_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES256CTR_EncryptFinal(handle, cipher, &cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256ctr_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CTR_DecryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256ctr_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[2].memref.buffer; + plain_length = (uint32_t)params[2].memref.size; + if ((NULL == plain) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CTR_DecryptUpdate(handle, cipher, plain, cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes256ctr_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = NULL; // nothing ever written here + plain_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES256CTR_DecryptFinal(handle, plain, &plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128cmac_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CMAC_GenerateInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_cmac_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128cmac_generateupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (NULL == message) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CMAC_GenerateUpdate(handle, message, message_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128cmac_generatefinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * mac; + uint32_t mac_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + mac = (uint8_t *)params[1].memref.buffer; + mac_length = params[1].memref.size; + if ((NULL == mac) || (HW_SCE_AES_BLOCK_BYTE_SIZE > mac_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CMAC_GenerateFinal(handle, mac); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION: + return TEE_ERROR_BAD_STATE; + default: /* FSP_ERR_CRYPTO_SCE_AUTHENTICATION */ + return TEE_ERROR_MAC_INVALID; + } + + params[1].memref.size = HW_SCE_AES_BLOCK_BYTE_SIZE; + + return TEE_SUCCESS; +} + +static TEE_Result aes128cmac_verifyinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CMAC_VerifyInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_cmac_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128cmac_verifyupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (NULL == message) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CMAC_VerifyUpdate(handle, message, message_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128cmac_verifyfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * mac; + uint32_t mac_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + mac = (uint8_t *)params[1].memref.buffer; + mac_length = params[1].memref.size; + if ((NULL == mac) || (2 > mac_length) || (HW_SCE_AES_BLOCK_BYTE_SIZE < mac_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CMAC_VerifyFinal(handle, mac, mac_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: + return TEE_ERROR_MAC_INVALID; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256cmac_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CMAC_GenerateInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_cmac_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256cmac_generateupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (NULL == message) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CMAC_GenerateUpdate(handle, message, message_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256cmac_generatefinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * mac; + uint32_t mac_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + mac = (uint8_t *)params[1].memref.buffer; + mac_length = params[1].memref.size; + if ((NULL == mac) || (HW_SCE_AES_BLOCK_BYTE_SIZE > mac_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CMAC_GenerateFinal(handle, mac); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION: + return TEE_ERROR_BAD_STATE; + default: /* FSP_ERR_CRYPTO_SCE_AUTHENTICATION */ + return TEE_ERROR_MAC_INVALID; + } + + params[1].memref.size = HW_SCE_AES_BLOCK_BYTE_SIZE; + + return TEE_SUCCESS; +} + +static TEE_Result aes256cmac_verifyinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CMAC_VerifyInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_cmac_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256cmac_verifyupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (NULL == message) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CMAC_VerifyUpdate(handle, message, message_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256cmac_verifyfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * mac; + uint32_t mac_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + mac = (uint8_t *)params[1].memref.buffer; + mac_length = params[1].memref.size; + if ((NULL == mac) || (2 > mac_length) || (HW_SCE_AES_BLOCK_BYTE_SIZE < mac_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CMAC_VerifyFinal(handle, mac, mac_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: + return TEE_ERROR_MAC_INVALID; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result invoke_command( + void *session __unused, + uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS] + ) +{ + DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_AES128ECB_EncryptInit : + return aes128ecb_encryptinit(ptypes, params); + case PTA_CMD_AES128ECB_EncryptUpdate : + return aes128ecb_encryptupdate(ptypes, params); + case PTA_CMD_AES128ECB_EncryptFinal : + return aes128ecb_encryptfinal(ptypes, params); + case PTA_CMD_AES128ECB_DecryptInit : + return aes128ecb_decryptinit(ptypes, params); + case PTA_CMD_AES128ECB_DecryptUpdate : + return aes128ecb_decryptupdate(ptypes, params); + case PTA_CMD_AES128ECB_DecryptFinal : + return aes128ecb_decryptfinal(ptypes, params); + case PTA_CMD_AES256ECB_EncryptInit : + return aes256ecb_encryptinit(ptypes, params); + case PTA_CMD_AES256ECB_EncryptUpdate : + return aes256ecb_encryptupdate(ptypes, params); + case PTA_CMD_AES256ECB_EncryptFinal : + return aes256ecb_encryptfinal(ptypes, params); + case PTA_CMD_AES256ECB_DecryptInit : + return aes256ecb_decryptinit(ptypes, params); + case PTA_CMD_AES256ECB_DecryptUpdate : + return aes256ecb_decryptupdate(ptypes, params); + case PTA_CMD_AES256ECB_DecryptFinal : + return aes256ecb_decryptfinal(ptypes, params); + case PTA_CMD_AES128CBC_EncryptInit : + return aes128cbc_encryptinit(ptypes, params); + case PTA_CMD_AES128CBC_EncryptUpdate : + return aes128cbc_encryptupdate(ptypes, params); + case PTA_CMD_AES128CBC_EncryptFinal : + return aes128cbc_encryptfinal(ptypes, params); + case PTA_CMD_AES128CBC_DecryptInit : + return aes128cbc_decryptinit(ptypes, params); + case PTA_CMD_AES128CBC_DecryptUpdate : + return aes128cbc_decryptupdate(ptypes, params); + case PTA_CMD_AES128CBC_DecryptFinal : + return aes128cbc_decryptfinal(ptypes, params); + case PTA_CMD_AES256CBC_EncryptInit : + return aes256cbc_encryptinit(ptypes, params); + case PTA_CMD_AES256CBC_EncryptUpdate : + return aes256cbc_encryptupdate(ptypes, params); + case PTA_CMD_AES256CBC_EncryptFinal : + return aes256cbc_encryptfinal(ptypes, params); + case PTA_CMD_AES256CBC_DecryptInit : + return aes256cbc_decryptinit(ptypes, params); + case PTA_CMD_AES256CBC_DecryptUpdate : + return aes256cbc_decryptupdate(ptypes, params); + case PTA_CMD_AES256CBC_DecryptFinal : + return aes256cbc_decryptfinal(ptypes, params); + case PTA_CMD_AES128CTR_EncryptInit : + return aes128ctr_encryptinit(ptypes, params); + case PTA_CMD_AES128CTR_EncryptUpdate : + return aes128ctr_encryptupdate(ptypes, params); + case PTA_CMD_AES128CTR_EncryptFinal : + return aes128ctr_encryptfinal(ptypes, params); + case PTA_CMD_AES128CTR_DecryptInit : + return aes128ctr_decryptinit(ptypes, params); + case PTA_CMD_AES128CTR_DecryptUpdate : + return aes128ctr_decryptupdate(ptypes, params); + case PTA_CMD_AES128CTR_DecryptFinal : + return aes128ctr_decryptfinal(ptypes, params); + case PTA_CMD_AES256CTR_EncryptInit : + return aes256ctr_encryptinit(ptypes, params); + case PTA_CMD_AES256CTR_EncryptUpdate : + return aes256ctr_encryptupdate(ptypes, params); + case PTA_CMD_AES256CTR_EncryptFinal : + return aes256ctr_encryptfinal(ptypes, params); + case PTA_CMD_AES256CTR_DecryptInit : + return aes256ctr_decryptinit(ptypes, params); + case PTA_CMD_AES256CTR_DecryptUpdate : + return aes256ctr_decryptupdate(ptypes, params); + case PTA_CMD_AES256CTR_DecryptFinal : + return aes256ctr_decryptfinal(ptypes, params); + case PTA_CMD_AES128CMAC_GenerateInit : + return aes128cmac_generateinit(ptypes, params); + case PTA_CMD_AES128CMAC_GenerateUpdate : + return aes128cmac_generateupdate(ptypes, params); + case PTA_CMD_AES128CMAC_GenerateFinal : + return aes128cmac_generatefinal(ptypes, params); + case PTA_CMD_AES128CMAC_VerifyInit : + return aes128cmac_verifyinit(ptypes, params); + case PTA_CMD_AES128CMAC_VerifyUpdate : + return aes128cmac_verifyupdate(ptypes, params); + case PTA_CMD_AES128CMAC_VerifyFinal : + return aes128cmac_verifyfinal(ptypes, params); + case PTA_CMD_AES256CMAC_GenerateInit : + return aes256cmac_generateinit(ptypes, params); + case PTA_CMD_AES256CMAC_GenerateUpdate : + return aes256cmac_generateupdate(ptypes, params); + case PTA_CMD_AES256CMAC_GenerateFinal : + return aes256cmac_generatefinal(ptypes, params); + case PTA_CMD_AES256CMAC_VerifyInit : + return aes256cmac_verifyinit(ptypes, params); + case PTA_CMD_AES256CMAC_VerifyUpdate : + return aes256cmac_verifyupdate(ptypes, params); + case PTA_CMD_AES256CMAC_VerifyFinal : + return aes256cmac_verifyfinal(ptypes, params); + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register( + .uuid = PTA_SCE_AES_UUID, + .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS | TA_FLAG_DEVICE_ENUM, + .invoke_command_entry_point = invoke_command +); diff --git a/core/arch/arm/plat-rz/v2h/pta/pta_sce_ecc.c b/core/arch/arm/plat-rz/v2h/pta/pta_sce_ecc.c new file mode 100644 index 000000000..f431ede56 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/pta/pta_sce_ecc.c @@ -0,0 +1,483 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ + +#include +#include + +#include +#include + +#define PTA_NAME "sce_ecc.pta" + +static uint32_t sha512_hash[HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t)]; + +static TEE_Result ecdsa_secp192r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t message_hash; + sce_ecdsa_byte_data_t signature; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[0].memref.buffer; + message_hash.data_length = params[0].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[1].memref.buffer; + signature.data_length = params[1].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE > signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_secp192r1_SignatureGenerate(&message_hash, &signature, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = signature.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp192r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t signature; + sce_ecdsa_byte_data_t message_hash; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[1].memref.buffer; + message_hash.data_length = params[1].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_secp192r1_SignatureVerify(&signature, &message_hash, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp224r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t message_hash; + sce_ecdsa_byte_data_t signature; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[0].memref.buffer; + message_hash.data_length = params[0].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[1].memref.buffer; + signature.data_length = params[1].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE > signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_secp224r1_SignatureGenerate(&message_hash, &signature, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = signature.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp224r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t signature; + sce_ecdsa_byte_data_t message_hash; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[1].memref.buffer; + message_hash.data_length = params[1].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_secp224r1_SignatureVerify(&signature, &message_hash, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp256r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t message_hash; + sce_ecdsa_byte_data_t signature; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[0].memref.buffer; + message_hash.data_length = params[0].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[1].memref.buffer; + signature.data_length = params[1].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE > signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_secp256r1_SignatureGenerate(&message_hash, &signature, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = signature.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp256r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t signature; + sce_ecdsa_byte_data_t message_hash; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[1].memref.buffer; + message_hash.data_length = params[1].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_secp256r1_SignatureVerify(&signature, &message_hash, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_brainpoolp512r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t message_hash; + sce_ecdsa_byte_data_t signature; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)sha512_hash; + message_hash.data_length = HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE; + message_hash.data_type = 1; + err = tee_hash_createdigest(TEE_ALG_SHA512, params[0].memref.buffer, params[0].memref.size, + message_hash.pdata, message_hash.data_length); + if (err) { + return err; + } + + signature.pdata = (uint8_t *)params[1].memref.buffer; + signature.data_length = params[1].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_P512_DATA_BYTE_SIZE > signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_BrainpoolP512r1_SignatureGenerate(&message_hash, &signature, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = signature.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_brainpoolp512r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t signature; + sce_ecdsa_byte_data_t message_hash; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_P512_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)sha512_hash; + message_hash.data_length = HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE; + message_hash.data_type = 1; + err = tee_hash_createdigest(TEE_ALG_SHA512, params[1].memref.buffer, params[1].memref.size, + message_hash.pdata, message_hash.data_length); + if (err) { + return err; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_BrainpoolP512r1_SignatureVerify(&signature, &message_hash, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) + { + case PTA_CMD_ECDSA_secp192r1_SignatureGenerate : + return ecdsa_secp192r1_signaturegenerate(ptypes, params); + case PTA_CMD_ECDSA_secp192r1_SignatureVerify : + return ecdsa_secp192r1_signatureverify(ptypes, params); + case PTA_CMD_ECDSA_secp224r1_SignatureGenerate : + return ecdsa_secp224r1_signaturegenerate(ptypes, params); + case PTA_CMD_ECDSA_secp224r1_SignatureVerify : + return ecdsa_secp224r1_signatureverify(ptypes, params); + case PTA_CMD_ECDSA_secp256r1_SignatureGenerate : + return ecdsa_secp256r1_signaturegenerate(ptypes, params); + case PTA_CMD_ECDSA_secp256r1_SignatureVerify : + return ecdsa_secp256r1_signatureverify(ptypes, params); + case PTA_CMD_ECDSA_BrainpoolP512r1_SignatureGenerate : + return ecdsa_brainpoolp512r1_signaturegenerate(ptypes, params); + case PTA_CMD_ECDSA_BrainpoolP512r1_SignatureVerify : + return ecdsa_brainpoolp512r1_signatureverify(ptypes, params); + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_SCE_ECC_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/v2h/pta/pta_sce_rsa.c b/core/arch/arm/plat-rz/v2h/pta/pta_sce_rsa.c new file mode 100644 index 000000000..5c6694f62 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/pta/pta_sce_rsa.c @@ -0,0 +1,576 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ + +#include + +#include +#include + +#define PTA_NAME "sce_rsa.pta" + +static TEE_Result rsassa_pkcs1024_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t message_hash; + sce_rsa_byte_data_t signature; + sce_rsa1024_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[0].memref.buffer; + message_hash.data_length = params[0].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[1].memref.buffer; + signature.data_length = params[1].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_RSA_1024_DATA_BYTE_SIZE > signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa1024_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSASSA_PKCS1024_SignatureGenerate(&message_hash, &signature, wrapped_key, HW_SCE_RSA_HASH_SHA256); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = signature.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result rsassa_pkcs1024_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t signature; + sce_rsa_byte_data_t message_hash; + sce_rsa1024_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_RSA_1024_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[1].memref.buffer; + message_hash.data_length = params[1].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa1024_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSASSA_PKCS1024_SignatureVerify(&signature, &message_hash, wrapped_key, HW_SCE_RSA_HASH_SHA256); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: + return TEE_ERROR_SIGNATURE_INVALID; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result rsassa_pkcs2048_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t message_hash; + sce_rsa_byte_data_t signature; + sce_rsa2048_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[0].memref.buffer; + message_hash.data_length = params[0].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[1].memref.buffer; + signature.data_length = params[1].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_RSA_2048_DATA_BYTE_SIZE > signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa2048_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSASSA_PKCS2048_SignatureGenerate(&message_hash, &signature, wrapped_key, HW_SCE_RSA_HASH_SHA256); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = signature.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result rsassa_pkcs2048_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t signature; + sce_rsa_byte_data_t message_hash; + sce_rsa2048_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_RSA_2048_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[1].memref.buffer; + message_hash.data_length = params[1].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa2048_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSASSA_PKCS2048_SignatureVerify(&signature, &message_hash, wrapped_key, HW_SCE_RSA_HASH_SHA256); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: + return TEE_ERROR_SIGNATURE_INVALID; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result rsassa_pkcs4096_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t signature; + sce_rsa_byte_data_t message_hash; + sce_rsa4096_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_RSA_4096_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[1].memref.buffer; + message_hash.data_length = params[1].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa4096_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa4096_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSASSA_PKCS4096_SignatureVerify(&signature, &message_hash, wrapped_key, HW_SCE_RSA_HASH_SHA256); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: + return TEE_ERROR_SIGNATURE_INVALID; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result rsaes_pkcs1024_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t plain; + sce_rsa_byte_data_t cipher; + sce_rsa1024_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain.pdata = (uint8_t *)params[0].memref.buffer; + plain.data_length = params[0].memref.size; + plain.data_type = 0; + if (NULL == plain.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher.pdata = (uint8_t *)params[1].memref.buffer; + cipher.data_length = params[1].memref.size; + cipher.data_type = 0; + if (NULL == cipher.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa1024_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSAES_PKCS1024_Encrypt(&plain, &cipher, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PARAMETER */ + return TEE_ERROR_BAD_PARAMETERS; + } + + params[1].memref.size = cipher.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result rsaes_pkcs1024_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t plain; + sce_rsa_byte_data_t cipher; + sce_rsa1024_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher.pdata = (uint8_t *)params[0].memref.buffer; + cipher.data_length = params[0].memref.size; + cipher.data_type = 0; + if (NULL == cipher.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain.pdata = (uint8_t *)params[1].memref.buffer; + plain.data_length = params[1].memref.size; + plain.data_type = 0; + if (NULL == plain.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa1024_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSAES_PKCS1024_Decrypt(&cipher, &plain, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} +static TEE_Result rsaes_pkcs2048_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t plain; + sce_rsa_byte_data_t cipher; + sce_rsa2048_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain.pdata = (uint8_t *)params[0].memref.buffer; + plain.data_length = params[0].memref.size; + plain.data_type = 0; + if (NULL == plain.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher.pdata = (uint8_t *)params[1].memref.buffer; + cipher.data_length = params[1].memref.size; + cipher.data_type = 0; + if (NULL == cipher.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa2048_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSAES_PKCS2048_Encrypt(&plain, &cipher, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PARAMETER */ + return TEE_ERROR_BAD_PARAMETERS; + } + + params[1].memref.size = cipher.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result rsaes_pkcs2048_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t plain; + sce_rsa_byte_data_t cipher; + sce_rsa2048_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher.pdata = (uint8_t *)params[0].memref.buffer; + cipher.data_length = params[0].memref.size; + cipher.data_type = 0; + if (NULL == cipher.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain.pdata = (uint8_t *)params[1].memref.buffer; + plain.data_length = params[1].memref.size; + plain.data_type = 0; + if (NULL == plain.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa2048_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSAES_PKCS2048_Decrypt(&cipher, &plain, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +static TEE_Result rsaes_pkcs4096_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t plain; + sce_rsa_byte_data_t cipher; + sce_rsa4096_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain.pdata = (uint8_t *)params[0].memref.buffer; + plain.data_length = params[0].memref.size; + plain.data_type = 0; + if (NULL == plain.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher.pdata = (uint8_t *)params[1].memref.buffer; + cipher.data_length = params[1].memref.size; + cipher.data_type = 0; + if (NULL == cipher.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa4096_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa4096_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSAES_PKCS4096_Encrypt(&plain, &cipher, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PARAMETER */ + return TEE_ERROR_BAD_PARAMETERS; + } + + params[1].memref.size = cipher.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_RSASSA_PKCS1024_SignatureGenerate : + return rsassa_pkcs1024_signaturegenerate(ptypes, params); + case PTA_CMD_RSASSA_PKCS1024_SignatureVerify : + return rsassa_pkcs1024_signatureverify(ptypes, params); + case PTA_CMD_RSASSA_PKCS2048_SignatureGenerate : + return rsassa_pkcs2048_signaturegenerate(ptypes, params); + case PTA_CMD_RSASSA_PKCS2048_SignatureVerify : + return rsassa_pkcs2048_signatureverify(ptypes, params); + case PTA_CMD_RSASSA_PKCS4096_SignatureVerify : + return rsassa_pkcs4096_signatureverify(ptypes, params); + case PTA_CMD_RSAES_PKCS1024_Encrypt : + return rsaes_pkcs1024_encrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS1024_Decrypt : + return rsaes_pkcs1024_decrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS2048_Encrypt : + return rsaes_pkcs2048_encrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS2048_Decrypt : + return rsaes_pkcs2048_decrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS4096_Encrypt : + return rsaes_pkcs4096_encrypt(ptypes, params); + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_SCE_RSA_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/v2h/pta/pta_sce_sha.c b/core/arch/arm/plat-rz/v2h/pta/pta_sce_sha.c new file mode 100644 index 000000000..d54a75c06 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/pta/pta_sce_sha.c @@ -0,0 +1,269 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ + +#include + +#include +#include + +#define PTA_NAME "sce_sha.pta" + +static TEE_Result sha224_init(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_sha_md5_handle_t * handle; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.SHA224_Init(handle); + switch (err) + { + case FSP_SUCCESS: + break; + default: + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_sha_md5_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result sha224_update(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_sha_md5_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + + err = g_sce_protected_on_sce.SHA224_Update(handle, message, message_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result sha224_final(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_sha_md5_handle_t * handle; + uint8_t * digest; + uint32_t digest_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + digest = (uint8_t *)params[1].memref.buffer; + digest_length = (uint32_t)params[1].memref.size; + if ((NULL == digest) || (HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE > digest_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.SHA224_Final(handle, digest, &digest_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = digest_length; + + return TEE_SUCCESS; +} + +static TEE_Result sha256_init(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_sha_md5_handle_t * handle; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.SHA256_Init(handle); + switch (err) + { + case FSP_SUCCESS: + break; + default: + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_sha_md5_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result sha256_update(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_sha_md5_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + + err = g_sce_protected_on_sce.SHA256_Update(handle, message, message_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result sha256_final(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_sha_md5_handle_t * handle; + uint8_t * digest; + uint32_t digest_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + digest = (uint8_t *)params[1].memref.buffer; + digest_length = (uint32_t)params[1].memref.size; + if ((NULL == digest) || (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE > digest_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.SHA256_Final(handle, digest, &digest_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = digest_length; + + return TEE_SUCCESS; +} + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_SHA224_Init : + return sha224_init(ptypes, params); + case PTA_CMD_SHA224_Update : + return sha224_update(ptypes, params); + case PTA_CMD_SHA224_Final : + return sha224_final(ptypes, params); + case PTA_CMD_SHA256_Init : + return sha256_init(ptypes, params); + case PTA_CMD_SHA256_Update : + return sha256_update(ptypes, params); + case PTA_CMD_SHA256_Final : + return sha256_final(ptypes, params); + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_SCE_SHA_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/v2h/pta/sub.mk b/core/arch/arm/plat-rz/v2h/pta/sub.mk new file mode 100644 index 000000000..e51074b6d --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/pta/sub.mk @@ -0,0 +1,3 @@ +global-incdirs-y += include + +srcs-$(CFG_RZ_SCE) += pta_sce.c pta_sce_ecc.c pta_sce_rsa.c pta_sce_sha.c pta_sce_aes.c diff --git a/core/arch/arm/plat-rz/v2h/rzv2h_conf.mk b/core/arch/arm/plat-rz/v2h/rzv2h_conf.mk new file mode 100644 index 000000000..eb5052449 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/rzv2h_conf.mk @@ -0,0 +1,31 @@ + +include core/arch/arm/cpu/cortex-armv8-0.mk +include core/arch/arm/plat-rz/link.mk + +$(call force,CFG_SECURE_TIME_SOURCE_CNTPCT,y) +$(call force,CFG_WITH_ARM_TRUSTED_FW,y) +$(call force,CFG_SCIF,n) +$(call force,CFG_RZ_SCIF,y) +$(call force,CFG_CORE_LARGE_PHYS_ADDR,y) +$(call force,CFG_CORE_ARM64_PA_BITS,36) +$(call force,CFG_GIC,y) +$(call force,CFG_ARM_GICV3,y) +$(call force,CFG_RZ_HUK,y) +$(call force,CFG_RZ_XSPI,y) + +CFG_TEE_CORE_NB_CORE ?= 4 + +CFG_TZDRAM_START ?= 0x44100000 +CFG_TZDRAM_SIZE ?= 0x03D00000 +CFG_TEE_RAM_VA_SIZE ?= 0x100000 +ifeq ($(CFG_ARM64_core),y) +$(call force,CFG_WITH_LPAE,y) +supported-ta-targets = ta_arm64 +else +$(call force,CFG_ARM32_core,y) +endif + +CFG_RZ_SCE ?= n +ifeq ($(CFG_RZ_SCE),y) +CFG_WITH_SOFTWARE_PRNG ?= n +endif diff --git a/core/arch/arm/plat-rz/v2h/rzv2h_config.h b/core/arch/arm/plat-rz/v2h/rzv2h_config.h new file mode 100644 index 000000000..f507b54e8 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/rzv2h_config.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (c) 2016, GlobalLogic + * Copyright (c) 2021-2024, Renesas Electronics + */ + +#ifndef RZV2H_CONFIG_H +#define RZV2H_CONFIG_H + +#include + +/* Make stacks aligned to data cache line length */ +#define STACK_ALIGNMENT 64 + +#define GICD_BASE 0x14900000U + +#define CONSOLE_UART_BASE 0x11C01400U + +#define CHIPID_BASE 0x1045114CU +#define CHIPID_SIZE 16 + +#define CPG_REG_BASE 0x10420000U +#define CPG_REG_SIZE 0x00010000 + +#define SPI_FLASH_BASE 0x20000000U +#define SPI_FLASH_SIZE 0x10000000 +#define SPI_SECTOR_SIZE 0x10000 + +#define XSPI_BASE 0x11030000U +#define XSPI_REG_SIZE 0x10000 + +#if defined(PLATFORM_FLAVOR_v2h_evk_1) +/* DDR 8Gbyte x1 */ +#define NSEC_DDR_0_BASE 0x47E00000U +#define NSEC_DDR_0_SIZE 0x1F8000000U + +/* DDR 8Gbyte x1 */ +#define NSEC_DDR_1_BASE 0x240000000U +#define NSEC_DDR_1_SIZE 0x200000000U + +#else +#error "Unknown platform flavor" +#endif + +#define TEE_SHMEM_START (TZDRAM_BASE + TZDRAM_SIZE) +#define TEE_SHMEM_SIZE 0x100000 + +#endif /*RZV2H_CONFIG_H*/ diff --git a/core/arch/arm/plat-rz/v2h/sub.mk b/core/arch/arm/plat-rz/v2h/sub.mk new file mode 100644 index 000000000..86535d4a9 --- /dev/null +++ b/core/arch/arm/plat-rz/v2h/sub.mk @@ -0,0 +1,5 @@ +global-incdirs-y += . +srcs-y += main.c + + +subdirs-y += drivers pta \ No newline at end of file From 9647dfc1deb276d7c2c994f8b544c8592bd49c55 Mon Sep 17 00:00:00 2001 From: kaiki osakaki Date: Thu, 6 Jun 2024 09:53:46 +0900 Subject: [PATCH 2/7] plat-rz: Fixed common files and v2h files. Signed-off-by: kaiki osakaki --- .../plat-rz/common/drivers/r_sce/README.md | 11 +- .../drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst | 7654 ++++++++--------- .../common/drivers/r_sce/inc/api/r_sce_api.h | 2620 +++--- .../drivers/r_sce/inc/instances/r_sce.h | 423 + .../drivers/r_sce/private/inc/r_sce_private.h | 234 +- .../drivers/r_sce/private/r_sce_private.c | 1066 +-- .../common/drivers/r_sce/public/r_sce.c | 1886 ++-- .../common/drivers/r_sce/public/r_sce_aes.c | 2544 +++--- .../common/drivers/r_sce/public/r_sce_ecc.c | 900 +- .../common/drivers/r_sce/public/r_sce_rsa.c | 1758 ++-- .../common/drivers/r_sce/public/r_sce_sha.c | 552 +- .../arm/plat-rz/common/drivers/r_sce/sub.mk | 1 + core/arch/arm/plat-rz/common/drivers/sce.c | 55 +- core/arch/arm/plat-rz/common/drivers/sub.mk | 6 +- .../plat-rz/common/pta/include/pta_flash.h | 14 +- .../arm/plat-rz/common/pta/include/pta_sce.h | 179 + .../plat-rz/common/pta/include/pta_sce_aes.h | 279 + .../plat-rz/common/pta/include/pta_sce_ecc.h | 70 + .../plat-rz/common/pta/include/pta_sce_rsa.h | 84 + .../{v2h => common}/pta/include/pta_sce_sha.h | 20 +- core/arch/arm/plat-rz/common/pta/pta_sce.c | 1170 +++ .../arch/arm/plat-rz/common/pta/pta_sce_aes.c | 2257 +++++ .../arch/arm/plat-rz/common/pta/pta_sce_ecc.c | 483 ++ .../arch/arm/plat-rz/common/pta/pta_sce_rsa.c | 576 ++ .../arch/arm/plat-rz/common/pta/pta_sce_sha.c | 269 + core/arch/arm/plat-rz/common/pta/sub.mk | 3 +- core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.c | 26 +- .../arm/plat-rz/v2h/drivers/cpg/cpg_regs.h | 4 +- .../v2h/drivers/sce_lib/inc/instances/r_sce.h | 424 - .../arm/plat-rz/v2h/drivers/sce_lib/sub.mk | 4 - core/arch/arm/plat-rz/v2h/drivers/sub.mk | 2 - core/arch/arm/plat-rz/v2h/main.c | 2 +- .../arm/plat-rz/v2h/pta/include/pta_sce.h | 179 - .../arm/plat-rz/v2h/pta/include/pta_sce_aes.h | 279 - .../arm/plat-rz/v2h/pta/include/pta_sce_ecc.h | 70 - .../arm/plat-rz/v2h/pta/include/pta_sce_rsa.h | 84 - core/arch/arm/plat-rz/v2h/pta/pta_sce.c | 1170 --- core/arch/arm/plat-rz/v2h/pta/pta_sce_aes.c | 2257 ----- core/arch/arm/plat-rz/v2h/pta/pta_sce_ecc.c | 483 -- core/arch/arm/plat-rz/v2h/pta/pta_sce_rsa.c | 576 -- core/arch/arm/plat-rz/v2h/pta/pta_sce_sha.c | 269 - core/arch/arm/plat-rz/v2h/pta/sub.mk | 3 - core/arch/arm/plat-rz/v2h/rzv2h_config.h | 2 + core/arch/arm/plat-rz/v2h/sub.mk | 2 +- 44 files changed, 15474 insertions(+), 15476 deletions(-) create mode 100644 core/arch/arm/plat-rz/common/drivers/r_sce/inc/instances/r_sce.h create mode 100644 core/arch/arm/plat-rz/common/pta/include/pta_sce.h create mode 100644 core/arch/arm/plat-rz/common/pta/include/pta_sce_aes.h create mode 100644 core/arch/arm/plat-rz/common/pta/include/pta_sce_ecc.h create mode 100644 core/arch/arm/plat-rz/common/pta/include/pta_sce_rsa.h rename core/arch/arm/plat-rz/{v2h => common}/pta/include/pta_sce_sha.h (58%) create mode 100644 core/arch/arm/plat-rz/common/pta/pta_sce.c create mode 100644 core/arch/arm/plat-rz/common/pta/pta_sce_aes.c create mode 100644 core/arch/arm/plat-rz/common/pta/pta_sce_ecc.c create mode 100644 core/arch/arm/plat-rz/common/pta/pta_sce_rsa.c create mode 100644 core/arch/arm/plat-rz/common/pta/pta_sce_sha.c delete mode 100644 core/arch/arm/plat-rz/v2h/drivers/sce_lib/inc/instances/r_sce.h delete mode 100644 core/arch/arm/plat-rz/v2h/drivers/sce_lib/sub.mk delete mode 100644 core/arch/arm/plat-rz/v2h/pta/include/pta_sce.h delete mode 100644 core/arch/arm/plat-rz/v2h/pta/include/pta_sce_aes.h delete mode 100644 core/arch/arm/plat-rz/v2h/pta/include/pta_sce_ecc.h delete mode 100644 core/arch/arm/plat-rz/v2h/pta/include/pta_sce_rsa.h delete mode 100644 core/arch/arm/plat-rz/v2h/pta/pta_sce.c delete mode 100644 core/arch/arm/plat-rz/v2h/pta/pta_sce_aes.c delete mode 100644 core/arch/arm/plat-rz/v2h/pta/pta_sce_ecc.c delete mode 100644 core/arch/arm/plat-rz/v2h/pta/pta_sce_rsa.c delete mode 100644 core/arch/arm/plat-rz/v2h/pta/pta_sce_sha.c delete mode 100644 core/arch/arm/plat-rz/v2h/pta/sub.mk diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/README.md b/core/arch/arm/plat-rz/common/drivers/r_sce/README.md index 1c64d1caa..eddad92b7 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/README.md +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/README.md @@ -13,7 +13,8 @@ The SCE Driver is software for controlling SCE, which is the security IP of RZ M ### 1.1. Requirements - - RZ Secure Crypto Engine library 1.0.0 (libr_secure_ip_1_0.a.1.0.0) + - RZ/G2L Secure Crypto Engine library 1.0.0 (libr_secure_ip_1_0.a.1.0.0) + - RZ/V2H Secure Crypto Engine library 1.0.0 (libr_secure_ip_2_0.a.1.0.0) ### 1.2. Notice @@ -27,9 +28,10 @@ To contribute to this software, you should email patches to renesas-rz@renesas.c The following table shows the document related to this function. -| Number | Issuer | Title | Edition | +| Number | Issuer | Title | Edition | |--------|---------|----------------------------------------------------------------|-------------------| -| 1 | Renesas | RZ/G2L Security Manual | Rev.1.00 or later | +| 1 | Renesas | RZ/G2L Security Manual | Rev.1.00 or later | +| 2 | Renesas | RZ/V2H Security Manual | Rev.1.00 or later | ## 2. Driver Specifications @@ -44,3 +46,6 @@ Describe the revision history of RZ MPU SCE Driver. - First release. +### 3.2. v1.01 + +- Support RZ/V2H EVK Board. \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst b/core/arch/arm/plat-rz/common/drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst index a23742e8a..ca9d14f0f 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst @@ -14,29 +14,29 @@ This document describes the architecture of the driver for the Secure Crypto Eng The SCE module supports for the following features. - Cryptography - - Symmetric Encryption/Decryption - - AES - - ECB 128/256bit - - CBC 128/256bit - - CTR 128/256bit - - Asymmetric Encryption/Decryption - - RSA - - RSAES-PKCS1-V1_5 1024/2048bit - - RSAES-PKCS1-V1_5 4096bit (Encryption only) - - RSASSA-PKCS1-V1_5 1024/2048bit - - RSASSA-PKCS1-V1_5 4096bit (Verification only) - - ECC - - ECDSA secp192r1/secp224r1/secp256r1/BrainpoolP512r1 - - Hash Functions - - SHA-2 - - SHA-256/224 + - Symmetric Encryption/Decryption + - AES + - ECB 128/256bit + - CBC 128/256bit + - CTR 128/256bit + - Asymmetric Encryption/Decryption + - RSA + - RSAES-PKCS1-V1_5 1024/2048bit + - RSAES-PKCS1-V1_5 4096bit (Encryption only) + - RSASSA-PKCS1-V1_5 1024/2048bit + - RSASSA-PKCS1-V1_5 4096bit (Verification only) + - ECC + - ECDSA secp192r1/secp224r1/secp256r1/BrainpoolP512r1 + - Hash Functions + - SHA-2 + - SHA-256/224 - Message Authentication Code - - AES-CMAC 128/256bit + - AES-CMAC 128/256bit - Key Support - - AES 128/256bit - - RSA 1024/2048bit - - RSA 4096bit (public key only) - - ECC secp192r1/secp224r1/secp256r1/BrainpoolP512r1 + - AES 128/256bit + - RSA 1024/2048bit + - RSA 4096bit (public key only) + - ECC secp192r1/secp224r1/secp256r1/BrainpoolP512r1 - TRNG ************************************************************************* @@ -52,9 +52,9 @@ The SCE module supports for the following features. The following table lists the hardware needed to use this utility. .. csv-table:: Hardware environment - :header: "Name", "Note" + :header: "Name", "Note" - Target board,"RZ/G2L Device" + Target board,"RZ/G2L Device" and "RZ/V2H Device" ------------------------------------------------------- 1.4.1.Software Environment @@ -65,7 +65,7 @@ This driver are designed for use with generic (or no specific) operating systems 1.5.Requirement ************************************************************************* - - RZ Secure Crypto Engine library 1.0.0 + - RZ Secure Crypto Engine library ************************************************************************* 1.6.Notice @@ -88,27 +88,27 @@ This chapter presents the API specifications for the RZ SCE driver. This SCE driver file structure is shown below. +------------------------+-------------------+---------------------------------------------------+ -|Folder Name |File Name |Description | +|Folder Name |File Name |Description | +=====+==================+===================+===================================================+ -|sce |doc |sce_usage_notes.rst|This document. | -| +---------+--------+-------------------+---------------------------------------------------+ -| |inc |api |r_sce_api.h |sce API interface header file | -| | +--------+-------------------+---------------------------------------------------+ -| | |instance|r_sce.h |cryptographic function API header file | -| +---------+--------+-------------------+---------------------------------------------------+ -| |private | |r_sce_private.c |private function API header file | -| | +--------+-------------------+---------------------------------------------------+ -| | |inc |r_sce_private.h |private function API module | -| +---------+--------+-------------------+---------------------------------------------------+ -| |public |r_sce_aes.c |Public AES function API module | -| | +-------------------+---------------------------------------------------+ -| | |r_sce_ecc.c |Public ECC function API module | -| | +-------------------+---------------------------------------------------+ -| | |r_sce_rsa.c |Public RSA function API module | -| | +-------------------+---------------------------------------------------+ -| | |r_sce_sha.c |Public SHA function API module | -| | +-------------------+---------------------------------------------------+ -| | |r_sce.c |Common API module | +|sce |doc |sce_usage_notes.rst|This document. | +| +---------+--------+-------------------+---------------------------------------------------+ +| |inc |api |r_sce_api.h |sce API interface header file | +| | +--------+-------------------+---------------------------------------------------+ +| | |instance|r_sce.h |cryptographic function API header file | +| +---------+--------+-------------------+---------------------------------------------------+ +| |private | |r_sce_private.c |private function API header file | +| | +--------+-------------------+---------------------------------------------------+ +| | |inc |r_sce_private.h |private function API module | +| +---------+--------+-------------------+---------------------------------------------------+ +| |public |r_sce_aes.c |Public AES function API module | +| | +-------------------+---------------------------------------------------+ +| | |r_sce_ecc.c |Public ECC function API module | +| | +-------------------+---------------------------------------------------+ +| | |r_sce_rsa.c |Public RSA function API module | +| | +-------------------+---------------------------------------------------+ +| | |r_sce_sha.c |Public SHA function API module | +| | +-------------------+---------------------------------------------------+ +| | |r_sce.c |Common API module | +-----+------------------+-------------------+---------------------------------------------------+ ************************************************************************* @@ -116,303 +116,303 @@ This SCE driver file structure is shown below. ************************************************************************* +----------------------------------------------------------------------+---------------------------------+ -|Functions |Description | +|Functions |Description | +=======+==============================================================+=================================+ -|Common |`R_SCE_Open <2.6.1.R_SCE_Open_>`_ |Enables use of SCE functionality.| -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_Close |Stops supply of power to the SCE.| -| |<2.6.2.R_SCE_Close_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_SoftwareReset |Software reset to SCE. | -| |<2.6.3.R_SCE_SoftwareReset_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128_WrappedKeyGenerate |Random AES 128bit wrapped | -| |<2.6.4.R_SCE_AES128_WrappedKeyGenerate_>`_ |Key generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256_WrappedKeyGenerate |Random AES 256bit wrapped | -| |<2.6.5.R_SCE_AES256_WrappedKeyGenerate_>`_ |Key generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA1024_WrappedKeyPairGenerate |Random RSA 1024bit wrapped | -| |<2.6.6.R_SCE_RSA1024_WrappedKeyPairGenerate_>`_ |Key Pair generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA2048_WrappedKeyPairGenerate |Random RSA 2048bit wrapped | -| |<2.6.7.R_SCE_RSA2048_WrappedKeyPairGenerate_>`_ |Key Pair generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp192r1_WrappedKeyPairGenerate |Random ECC 192bit wrapped | -| |<2.6.8.R_SCE_ECC_secp192r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp224r1_WrappedKeyPairGenerate |Random ECC 224bit wrapped | -| |<2.6.9.R_SCE_ECC_secp224r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp256r1_WrappedKeyPairGenerate |Random ECC 256bit wrapped | -| |<2.6.10.R_SCE_ECC_secp256r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate |Random ECC 512bit wrapped | -| |<2.6.11.R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RandomNumberGenerate |Generate 4 words random number | -| |<2.6.12.R_SCE_RandomNumberGenerate_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128_EncryptedKeyWrap |Update AES 128bit installed Key | -| |<2.6.13.R_SCE_AES128_EncryptedKeyWrap_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256_EncryptedKeyWrap |Update AES 256bit installed Key | -| |<2.6.14.R_SCE_AES256_EncryptedKeyWrap_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA1024_EncryptedPublicKeyWrap |Update installed RSA 1024bit | -| |<2.6.15.R_SCE_RSA1024_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA1024_EncryptedPrivateKeyWrap |Update installed RSA 1024bit | -| |<2.6.16.R_SCE_RSA1024_EncryptedPrivateKeyWrap_>`_ |PrivateKey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA2048_EncryptedPublicKeyWrap |Update installed RSA 2048bit | -| |<2.6.17.R_SCE_RSA2048_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA2048_EncryptedPrivateKeyWrap |Update installed RSA 2048bit | -| |<2.6.18.R_SCE_RSA2048_EncryptedPrivateKeyWrap_>`_ |PrivateKey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA4096_EncryptedPublicKeyWrap |Update installed RSA 4096bit | -| |<2.6.19.R_SCE_RSA4096_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap |Update installed ECC 192bit | -| |<2.6.20.R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap |Update installed ECC 224bit | -| |<2.6.21.R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap |Update installed ECC 256bit | -| |<2.6.22.R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap |Update installed ECC 512bit | -| |<2.6.23.R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap |Update installed ECC 192bit | -| |<2.6.24.R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap |Update installed ECC 224bit | -| |<2.6.25.R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap |Update installed ECC 256bit | -| |<2.6.26.R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap |Update installed ECC 512bit | -| |<2.6.27.R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | +|Common |`R_SCE_Open <2.6.1.R_SCE_Open_>`_ |Enables use of SCE functionality.| +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_Close |Stops supply of power to the SCE.| +| |<2.6.2.R_SCE_Close_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_SoftwareReset |Software reset to SCE. | +| |<2.6.3.R_SCE_SoftwareReset_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128_WrappedKeyGenerate |Random AES 128bit wrapped | +| |<2.6.4.R_SCE_AES128_WrappedKeyGenerate_>`_ |Key generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256_WrappedKeyGenerate |Random AES 256bit wrapped | +| |<2.6.5.R_SCE_AES256_WrappedKeyGenerate_>`_ |Key generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA1024_WrappedKeyPairGenerate |Random RSA 1024bit wrapped | +| |<2.6.6.R_SCE_RSA1024_WrappedKeyPairGenerate_>`_ |Key Pair generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA2048_WrappedKeyPairGenerate |Random RSA 2048bit wrapped | +| |<2.6.7.R_SCE_RSA2048_WrappedKeyPairGenerate_>`_ |Key Pair generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp192r1_WrappedKeyPairGenerate |Random ECC 192bit wrapped | +| |<2.6.8.R_SCE_ECC_secp192r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp224r1_WrappedKeyPairGenerate |Random ECC 224bit wrapped | +| |<2.6.9.R_SCE_ECC_secp224r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp256r1_WrappedKeyPairGenerate |Random ECC 256bit wrapped | +| |<2.6.10.R_SCE_ECC_secp256r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate |Random ECC 512bit wrapped | +| |<2.6.11.R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RandomNumberGenerate |Generate 4 words random number | +| |<2.6.12.R_SCE_RandomNumberGenerate_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128_EncryptedKeyWrap |Update AES 128bit installed Key | +| |<2.6.13.R_SCE_AES128_EncryptedKeyWrap_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256_EncryptedKeyWrap |Update AES 256bit installed Key | +| |<2.6.14.R_SCE_AES256_EncryptedKeyWrap_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA1024_EncryptedPublicKeyWrap |Update installed RSA 1024bit | +| |<2.6.15.R_SCE_RSA1024_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA1024_EncryptedPrivateKeyWrap |Update installed RSA 1024bit | +| |<2.6.16.R_SCE_RSA1024_EncryptedPrivateKeyWrap_>`_ |PrivateKey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA2048_EncryptedPublicKeyWrap |Update installed RSA 2048bit | +| |<2.6.17.R_SCE_RSA2048_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA2048_EncryptedPrivateKeyWrap |Update installed RSA 2048bit | +| |<2.6.18.R_SCE_RSA2048_EncryptedPrivateKeyWrap_>`_ |PrivateKey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSA4096_EncryptedPublicKeyWrap |Update installed RSA 4096bit | +| |<2.6.19.R_SCE_RSA4096_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap |Update installed ECC 192bit | +| |<2.6.20.R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap |Update installed ECC 224bit | +| |<2.6.21.R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap |Update installed ECC 256bit | +| |<2.6.22.R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap |Update installed ECC 512bit | +| |<2.6.23.R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap_>`_ |publickey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap |Update installed ECC 192bit | +| |<2.6.24.R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap |Update installed ECC 224bit | +| |<2.6.25.R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap |Update installed ECC 256bit | +| |<2.6.26.R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap |Update installed ECC 512bit | +| |<2.6.27.R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | +-------+--------------------------------------------------------------+---------------------------------+ -|AES |`R_SCE_AES128ECB_EncryptInit |Initialization function | -| |<2.6.28.R_SCE_AES128ECB_EncryptInit_>`_ |(AES-128 ECB encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128ECB_EncryptUpdate |Update function | -| |<2.6.29.R_SCE_AES128ECB_EncryptUpdate_>`_ |(AES-128 ECB encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128ECB_EncryptFinal |Termination function | -| |<2.6.30.R_SCE_AES128ECB_EncryptFinal_>`_ |(AES-128 ECB encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128ECB_DecryptInit |Initialization function | -| |<2.6.31.R_SCE_AES128ECB_DecryptInit_>`_ |(AES-128 ECB decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128ECB_DecryptUpdate |Update function | -| |<2.6.32.R_SCE_AES128ECB_DecryptUpdate_>`_ |(AES-128 ECB decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128ECB_DecryptFinal |Termination function | -| |<2.6.33.R_SCE_AES128ECB_DecryptFinal_>`_ |(AES-256 ECB decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256ECB_EncryptInit |Initialization function | -| |<2.6.34.R_SCE_AES256ECB_EncryptInit_>`_ |(AES-256 ECB encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256ECB_EncryptUpdate |Update function | -| |<2.6.35.R_SCE_AES256ECB_EncryptUpdate_>`_ |(AES-256 ECB encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256ECB_EncryptFinal |Termination function | -| |<2.6.36.R_SCE_AES256ECB_EncryptFinal_>`_ |(AES-256 ECB encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256ECB_DecryptInit |Initialization function | -| |<2.6.37.R_SCE_AES256ECB_DecryptInit_>`_ |(AES-256 ECB decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256ECB_DecryptUpdate |Update function | -| |<2.6.38.R_SCE_AES256ECB_DecryptUpdate_>`_ |(AES-256 ECB decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256ECB_DecryptFinal |Termination function | -| |<2.6.39.R_SCE_AES256ECB_DecryptFinal_>`_ |(AES-256 ECB decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CBC_EncryptInit |Initialization function | -| |<2.6.40.R_SCE_AES128CBC_EncryptInit_>`_ |(AES-128 CBC encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CBC_EncryptUpdate |Update function | -| |<2.6.41.R_SCE_AES128CBC_EncryptUpdate_>`_ |(AES-128 CBC encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CBC_EncryptFinal |Termination function | -| |<2.6.42.R_SCE_AES128CBC_EncryptFinal_>`_ |(AES-128 CBC encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CBC_DecryptInit |Initialization function | -| |<2.6.43.R_SCE_AES128CBC_DecryptInit_>`_ |(AES-128 CBC decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CBC_DecryptUpdate |Update function | -| |<2.6.44.R_SCE_AES128CBC_DecryptUpdate_>`_ |(AES-128 CBC decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CBC_DecryptFinal |Termination function | -| |<2.6.45.R_SCE_AES128CBC_DecryptFinal_>`_ |(AES-128 CBC decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CBC_EncryptInit |Initialization function | -| |<2.6.46.R_SCE_AES256CBC_EncryptInit_>`_ |(AES-256 CBC encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CBC_EncryptUpdate |Update function | -| |<2.6.47.R_SCE_AES256CBC_EncryptUpdate_>`_ |(AES-256 CBC encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CBC_EncryptFinal |Termination function | -| |<2.6.48.R_SCE_AES256CBC_EncryptFinal_>`_ |(AES-256 CBC encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CBC_DecryptInit |Initialization function | -| |<2.6.49.R_SCE_AES256CBC_DecryptInit_>`_ |(AES-256 CBC decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CBC_DecryptUpdate |Update function | -| |<2.6.50.R_SCE_AES256CBC_DecryptUpdate_>`_ |(AES-256 CBC decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CBC_DecryptFinal |Termination function | -| |<2.6.51.R_SCE_AES256CBC_DecryptFinal_>`_ |(AES-256 CBC decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CTR_EncryptInit |Initialization function | -| |<2.6.52.R_SCE_AES128CTR_EncryptInit_>`_ |(AES-128 CTR encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CTR_EncryptUpdate |Update function | -| |<2.6.53.R_SCE_AES128CTR_EncryptUpdate_>`_ |(AES-128 CTR encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CTR_EncryptFinal |Termination function | -| |<2.6.54.R_SCE_AES128CTR_EncryptFinal_>`_ |(AES-128 CTR encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CTR_DecryptInit |Initialization function | -| |<2.6.55.R_SCE_AES128CTR_DecryptInit_>`_ |(AES-128 CTR decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CTR_DecryptUpdate |Update function | -| |<2.6.56.R_SCE_AES128CTR_DecryptUpdate_>`_ |(AES-128 CTR decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CTR_DecryptFinal |Termination function | -| |<2.6.57.R_SCE_AES128CTR_DecryptFinal_>`_ |(AES-128 CTR decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CTR_EncryptInit |Initialization function | -| |<2.6.58.R_SCE_AES256CTR_EncryptInit_>`_ |(AES-256 CTR encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CTR_EncryptUpdate |Update function | -| |<2.6.59.R_SCE_AES256CTR_EncryptUpdate_>`_ |(AES-256 CTR encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CTR_EncryptFinal |Termination function | -| |<2.6.60.R_SCE_AES256CTR_EncryptFinal_>`_ |(AES-256 CTR encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CTR_DecryptInit |Initialization function | -| |<2.6.61.R_SCE_AES256CTR_DecryptInit_>`_ |(AES-256 CTR decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CTR_DecryptUpdate |Update function | -| |<2.6.62.R_SCE_AES256CTR_DecryptUpdate_>`_ |(AES-256 CTR decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CTR_DecryptFinal |Termination function | -| |<2.6.63.R_SCE_AES256CTR_DecryptFinal_>`_ |(AES-256 CTR decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CMAC_GenerateInit |Initialization function | -| |<2.6.64.R_SCE_AES128CMAC_GenerateInit_>`_ |(AES-128 CMAC generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CMAC_GenerateUpdate |Update function | -| |<2.6.65.R_SCE_AES128CMAC_GenerateUpdate_>`_ |(AES-128 CMAC generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CMAC_GenerateFinal |Termination function | -| |<2.6.66.R_SCE_AES128CMAC_GenerateFinal_>`_ |(AES-128 CMAC generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CMAC_VerifyInit |Initialization function | -| |<2.6.67.R_SCE_AES128CMAC_VerifyInit_>`_ |(AES-128 CMAC verification) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CMAC_VerifyUpdate |Update function | -| |<2.6.68.R_SCE_AES128CMAC_VerifyUpdate_>`_ |(AES-128 CMAC verification) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CMAC_VerifyFinal |Termination function | -| |<2.6.69.R_SCE_AES128CMAC_VerifyFinal_>`_ |(AES-128 CMAC verification) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CMAC_GenerateInit |Initialization function | -| |<2.6.70.R_SCE_AES256CMAC_GenerateInit_>`_ |(AES-256 CMAC generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CMAC_GenerateUpdate |Update function | -| |<2.6.71.R_SCE_AES256CMAC_GenerateUpdate_>`_ |(AES-256 CMAC generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CMAC_GenerateFinal |Termination function | -| |<2.6.72.R_SCE_AES256CMAC_GenerateFinal_>`_ |(AES-256 CMAC generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CMAC_VerifyInit |Initialization function | -| |<2.6.73.R_SCE_AES256CMAC_VerifyInit_>`_ |(AES-256 CMAC verification) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CMAC_VerifyUpdate |Update function | -| |<2.6.74.R_SCE_AES256CMAC_VerifyUpdate_>`_ |(AES-256 CMAC verification) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CMAC_VerifyFinal |Termination function | -| |<2.6.75.R_SCE_AES256CMAC_VerifyFinal_>`_ |(AES-256 CMAC verification) | +|AES |`R_SCE_AES128ECB_EncryptInit |Initialization function | +| |<2.6.28.R_SCE_AES128ECB_EncryptInit_>`_ |(AES-128 ECB encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128ECB_EncryptUpdate |Update function | +| |<2.6.29.R_SCE_AES128ECB_EncryptUpdate_>`_ |(AES-128 ECB encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128ECB_EncryptFinal |Termination function | +| |<2.6.30.R_SCE_AES128ECB_EncryptFinal_>`_ |(AES-128 ECB encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128ECB_DecryptInit |Initialization function | +| |<2.6.31.R_SCE_AES128ECB_DecryptInit_>`_ |(AES-128 ECB decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128ECB_DecryptUpdate |Update function | +| |<2.6.32.R_SCE_AES128ECB_DecryptUpdate_>`_ |(AES-128 ECB decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128ECB_DecryptFinal |Termination function | +| |<2.6.33.R_SCE_AES128ECB_DecryptFinal_>`_ |(AES-256 ECB decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256ECB_EncryptInit |Initialization function | +| |<2.6.34.R_SCE_AES256ECB_EncryptInit_>`_ |(AES-256 ECB encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256ECB_EncryptUpdate |Update function | +| |<2.6.35.R_SCE_AES256ECB_EncryptUpdate_>`_ |(AES-256 ECB encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256ECB_EncryptFinal |Termination function | +| |<2.6.36.R_SCE_AES256ECB_EncryptFinal_>`_ |(AES-256 ECB encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256ECB_DecryptInit |Initialization function | +| |<2.6.37.R_SCE_AES256ECB_DecryptInit_>`_ |(AES-256 ECB decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256ECB_DecryptUpdate |Update function | +| |<2.6.38.R_SCE_AES256ECB_DecryptUpdate_>`_ |(AES-256 ECB decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256ECB_DecryptFinal |Termination function | +| |<2.6.39.R_SCE_AES256ECB_DecryptFinal_>`_ |(AES-256 ECB decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CBC_EncryptInit |Initialization function | +| |<2.6.40.R_SCE_AES128CBC_EncryptInit_>`_ |(AES-128 CBC encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CBC_EncryptUpdate |Update function | +| |<2.6.41.R_SCE_AES128CBC_EncryptUpdate_>`_ |(AES-128 CBC encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CBC_EncryptFinal |Termination function | +| |<2.6.42.R_SCE_AES128CBC_EncryptFinal_>`_ |(AES-128 CBC encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CBC_DecryptInit |Initialization function | +| |<2.6.43.R_SCE_AES128CBC_DecryptInit_>`_ |(AES-128 CBC decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CBC_DecryptUpdate |Update function | +| |<2.6.44.R_SCE_AES128CBC_DecryptUpdate_>`_ |(AES-128 CBC decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CBC_DecryptFinal |Termination function | +| |<2.6.45.R_SCE_AES128CBC_DecryptFinal_>`_ |(AES-128 CBC decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CBC_EncryptInit |Initialization function | +| |<2.6.46.R_SCE_AES256CBC_EncryptInit_>`_ |(AES-256 CBC encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CBC_EncryptUpdate |Update function | +| |<2.6.47.R_SCE_AES256CBC_EncryptUpdate_>`_ |(AES-256 CBC encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CBC_EncryptFinal |Termination function | +| |<2.6.48.R_SCE_AES256CBC_EncryptFinal_>`_ |(AES-256 CBC encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CBC_DecryptInit |Initialization function | +| |<2.6.49.R_SCE_AES256CBC_DecryptInit_>`_ |(AES-256 CBC decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CBC_DecryptUpdate |Update function | +| |<2.6.50.R_SCE_AES256CBC_DecryptUpdate_>`_ |(AES-256 CBC decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CBC_DecryptFinal |Termination function | +| |<2.6.51.R_SCE_AES256CBC_DecryptFinal_>`_ |(AES-256 CBC decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CTR_EncryptInit |Initialization function | +| |<2.6.52.R_SCE_AES128CTR_EncryptInit_>`_ |(AES-128 CTR encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CTR_EncryptUpdate |Update function | +| |<2.6.53.R_SCE_AES128CTR_EncryptUpdate_>`_ |(AES-128 CTR encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CTR_EncryptFinal |Termination function | +| |<2.6.54.R_SCE_AES128CTR_EncryptFinal_>`_ |(AES-128 CTR encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CTR_DecryptInit |Initialization function | +| |<2.6.55.R_SCE_AES128CTR_DecryptInit_>`_ |(AES-128 CTR decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CTR_DecryptUpdate |Update function | +| |<2.6.56.R_SCE_AES128CTR_DecryptUpdate_>`_ |(AES-128 CTR decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CTR_DecryptFinal |Termination function | +| |<2.6.57.R_SCE_AES128CTR_DecryptFinal_>`_ |(AES-128 CTR decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CTR_EncryptInit |Initialization function | +| |<2.6.58.R_SCE_AES256CTR_EncryptInit_>`_ |(AES-256 CTR encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CTR_EncryptUpdate |Update function | +| |<2.6.59.R_SCE_AES256CTR_EncryptUpdate_>`_ |(AES-256 CTR encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CTR_EncryptFinal |Termination function | +| |<2.6.60.R_SCE_AES256CTR_EncryptFinal_>`_ |(AES-256 CTR encryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CTR_DecryptInit |Initialization function | +| |<2.6.61.R_SCE_AES256CTR_DecryptInit_>`_ |(AES-256 CTR decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CTR_DecryptUpdate |Update function | +| |<2.6.62.R_SCE_AES256CTR_DecryptUpdate_>`_ |(AES-256 CTR decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CTR_DecryptFinal |Termination function | +| |<2.6.63.R_SCE_AES256CTR_DecryptFinal_>`_ |(AES-256 CTR decryption) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CMAC_GenerateInit |Initialization function | +| |<2.6.64.R_SCE_AES128CMAC_GenerateInit_>`_ |(AES-128 CMAC generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CMAC_GenerateUpdate |Update function | +| |<2.6.65.R_SCE_AES128CMAC_GenerateUpdate_>`_ |(AES-128 CMAC generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CMAC_GenerateFinal |Termination function | +| |<2.6.66.R_SCE_AES128CMAC_GenerateFinal_>`_ |(AES-128 CMAC generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CMAC_VerifyInit |Initialization function | +| |<2.6.67.R_SCE_AES128CMAC_VerifyInit_>`_ |(AES-128 CMAC verification) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CMAC_VerifyUpdate |Update function | +| |<2.6.68.R_SCE_AES128CMAC_VerifyUpdate_>`_ |(AES-128 CMAC verification) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES128CMAC_VerifyFinal |Termination function | +| |<2.6.69.R_SCE_AES128CMAC_VerifyFinal_>`_ |(AES-128 CMAC verification) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CMAC_GenerateInit |Initialization function | +| |<2.6.70.R_SCE_AES256CMAC_GenerateInit_>`_ |(AES-256 CMAC generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CMAC_GenerateUpdate |Update function | +| |<2.6.71.R_SCE_AES256CMAC_GenerateUpdate_>`_ |(AES-256 CMAC generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CMAC_GenerateFinal |Termination function | +| |<2.6.72.R_SCE_AES256CMAC_GenerateFinal_>`_ |(AES-256 CMAC generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CMAC_VerifyInit |Initialization function | +| |<2.6.73.R_SCE_AES256CMAC_VerifyInit_>`_ |(AES-256 CMAC verification) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CMAC_VerifyUpdate |Update function | +| |<2.6.74.R_SCE_AES256CMAC_VerifyUpdate_>`_ |(AES-256 CMAC verification) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_AES256CMAC_VerifyFinal |Termination function | +| |<2.6.75.R_SCE_AES256CMAC_VerifyFinal_>`_ |(AES-256 CMAC verification) | +-------+--------------------------------------------------------------+---------------------------------+ -|SHA |`R_SCE_SHA256_Init |Initialization function | -| |<2.6.76.R_SCE_SHA256_Init_>`_ |(SHA-256 hash value generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_SHA256_Update |Update function | -| |<2.6.77.R_SCE_SHA256_Update_>`_ |(SHA-256 hash value generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_SHA256_Final |Termination function | -| |<2.6.78.R_SCE_SHA256_Final_>`_ |(SHA-256 hash value generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_SHA224_Init |Initialization function | -| |<2.6.79.R_SCE_SHA224_Init_>`_ |(SHA-224 hash value generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_SHA224_Update |Update function | -| |<2.6.80.R_SCE_SHA224_Update_>`_ |(SHA-224 hash value generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_SHA224_Final |Termination function | -| |<2.6.81.R_SCE_SHA224_Final_>`_ |(SHA-224 hash value generation) | +|SHA |`R_SCE_SHA256_Init |Initialization function | +| |<2.6.76.R_SCE_SHA256_Init_>`_ |(SHA-256 hash value generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_SHA256_Update |Update function | +| |<2.6.77.R_SCE_SHA256_Update_>`_ |(SHA-256 hash value generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_SHA256_Final |Termination function | +| |<2.6.78.R_SCE_SHA256_Final_>`_ |(SHA-256 hash value generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_SHA224_Init |Initialization function | +| |<2.6.79.R_SCE_SHA224_Init_>`_ |(SHA-224 hash value generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_SHA224_Update |Update function | +| |<2.6.80.R_SCE_SHA224_Update_>`_ |(SHA-224 hash value generation) | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_SHA224_Final |Termination function | +| |<2.6.81.R_SCE_SHA224_Final_>`_ |(SHA-224 hash value generation) | +-------+--------------------------------------------------------------+---------------------------------+ -|RSA |`R_SCE_RSASSA_PKCS1024_SignatureGenerate |RSA Signature Generation | -| |<2.6.82.R_SCE_RSASSA_PKCS1024_SignatureGenerate_>`_ |with 1024bit key | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSASSA_PKCS1024_SignatureVerify |RSA Signature verification | -| |<2.6.83.R_SCE_RSASSA_PKCS1024_SignatureVerify_>`_ |with 1024bit key | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSASSA_PKCS2048_SignatureGenerate |RSA Signature Generation | -| |<2.6.84.R_SCE_RSASSA_PKCS2048_SignatureGenerate_>`_ |with 2048bit key | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSASSA_PKCS2048_SignatureVerify |RSA Signature verification | -| |<2.6.85.R_SCE_RSASSA_PKCS2048_SignatureVerify_>`_ |with 2048bit key | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSASSA_PKCS4096_SignatureVerify |RSA Signature verification | -| |<2.6.86.R_SCE_RSASSA_PKCS4096_SignatureVerify_>`_ |with 4096bit key | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSAES_PKCS1024_Encrypt |RSA 1024bit encryption function | -| |<2.6.87.R_SCE_RSAES_PKCS1024_Encrypt_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSAES_PKCS1024_Decrypt |RSA 1024bit decryption function | -| |<2.6.88.R_SCE_RSAES_PKCS1024_Decrypt_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSAES_PKCS2048_Encrypt |RSA 2048bit encryption function | -| |<2.6.89.R_SCE_RSAES_PKCS2048_Encrypt_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSAES_PKCS2048_Decrypt |RSA 1024bit decryption function | -| |<2.6.90.R_SCE_RSAES_PKCS2048_Decrypt_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSAES_PKCS4096_Encrypt |RSA 4096bit encryption function | -| |<2.6.91.R_SCE_RSAES_PKCS4096_Encrypt_>`_ | | +|RSA |`R_SCE_RSASSA_PKCS1024_SignatureGenerate |RSA Signature Generation | +| |<2.6.82.R_SCE_RSASSA_PKCS1024_SignatureGenerate_>`_ |with 1024bit key | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSASSA_PKCS1024_SignatureVerify |RSA Signature verification | +| |<2.6.83.R_SCE_RSASSA_PKCS1024_SignatureVerify_>`_ |with 1024bit key | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSASSA_PKCS2048_SignatureGenerate |RSA Signature Generation | +| |<2.6.84.R_SCE_RSASSA_PKCS2048_SignatureGenerate_>`_ |with 2048bit key | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSASSA_PKCS2048_SignatureVerify |RSA Signature verification | +| |<2.6.85.R_SCE_RSASSA_PKCS2048_SignatureVerify_>`_ |with 2048bit key | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSASSA_PKCS4096_SignatureVerify |RSA Signature verification | +| |<2.6.86.R_SCE_RSASSA_PKCS4096_SignatureVerify_>`_ |with 4096bit key | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSAES_PKCS1024_Encrypt |RSA 1024bit encryption function | +| |<2.6.87.R_SCE_RSAES_PKCS1024_Encrypt_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSAES_PKCS1024_Decrypt |RSA 1024bit decryption function | +| |<2.6.88.R_SCE_RSAES_PKCS1024_Decrypt_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSAES_PKCS2048_Encrypt |RSA 2048bit encryption function | +| |<2.6.89.R_SCE_RSAES_PKCS2048_Encrypt_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSAES_PKCS2048_Decrypt |RSA 1024bit decryption function | +| |<2.6.90.R_SCE_RSAES_PKCS2048_Decrypt_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_RSAES_PKCS4096_Encrypt |RSA 4096bit encryption function | +| |<2.6.91.R_SCE_RSAES_PKCS4096_Encrypt_>`_ | | +-------+--------------------------------------------------------------+---------------------------------+ -|ECC |`R_SCE_ECDSA_secp192r1_SignatureGenerate |192bit ECC Signature Generation | -| |<2.6.92.R_SCE_ECDSA_secp192r1_SignatureGenerate_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_secp224r1_SignatureGenerate |224bit ECC Signature Generation | -| |<2.6.93.R_SCE_ECDSA_secp224r1_SignatureGenerate_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_secp256r1_SignatureGenerate |256bit ECC Signature Generation | -| |<2.6.94.R_SCE_ECDSA_secp256r1_SignatureGenerate_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate |512bit ECC Signature verification| -| |<2.6.95.R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_secp192r1_SignatureVerify |192bit ECC Signature verification| -| |<2.6.96.R_SCE_ECDSA_secp192r1_SignatureVerify_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_secp224r1_SignatureVerify |224bit ECC Signature verification| -| |<2.6.97.R_SCE_ECDSA_secp224r1_SignatureVerify_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_secp256r1_SignatureVerify |256bit ECC Signature verification| -| |<2.6.98.R_SCE_ECDSA_secp256r1_SignatureVerify_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify |512bit ECC Signature verification| -| |<2.6.99.R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify_>`_ | | +|ECC |`R_SCE_ECDSA_secp192r1_SignatureGenerate |192bit ECC Signature Generation | +| |<2.6.92.R_SCE_ECDSA_secp192r1_SignatureGenerate_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_secp224r1_SignatureGenerate |224bit ECC Signature Generation | +| |<2.6.93.R_SCE_ECDSA_secp224r1_SignatureGenerate_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_secp256r1_SignatureGenerate |256bit ECC Signature Generation | +| |<2.6.94.R_SCE_ECDSA_secp256r1_SignatureGenerate_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate |512bit ECC Signature verification| +| |<2.6.95.R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_secp192r1_SignatureVerify |192bit ECC Signature verification| +| |<2.6.96.R_SCE_ECDSA_secp192r1_SignatureVerify_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_secp224r1_SignatureVerify |224bit ECC Signature verification| +| |<2.6.97.R_SCE_ECDSA_secp224r1_SignatureVerify_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_secp256r1_SignatureVerify |256bit ECC Signature verification| +| |<2.6.98.R_SCE_ECDSA_secp256r1_SignatureVerify_>`_ | | +| +--------------------------------------------------------------+---------------------------------+ +| |`R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify |512bit ECC Signature verification| +| |<2.6.99.R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify_>`_ | | +-------+--------------------------------------------------------------+---------------------------------+ @@ -422,144 +422,144 @@ This SCE driver file structure is shown below. The return values for the SCE driver API functions is shown below. .. csv-table:: Return values for the SCE driver API functions - :header: "Return Code", "Value", "Description" - - FSP_SUCCESS,0,"Normal termination" - FSP_ERR_CRYPTO_CONTINUE,0x10000,"Continue executing function" - FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT,0x10001,"Hardware resource busy" - FSP_ERR_CRYPTO_SCE_FAIL,0x10002,"Internal I/O buffer is not empty" - FSP_ERR_CRYPTO_SCE_HRK_INVALID_INDEX,0x10003,"Invalid index" - FSP_ERR_CRYPTO_SCE_RETRY,0x10004,"Retry" - FSP_ERR_CRYPTO_SCE_VERIFY_FAIL,0x10005,"Verify is failed" - FSP_ERR_CRYPTO_SCE_ALREADY_OPEN,0x10006,"HW SCE module is already opened" - FSP_ERR_CRYPTO_NOT_OPEN,0x10007,"Hardware module is not initialized" - FSP_ERR_CRYPTO_UNKNOWN,0x10008,"Some unknown error occurred" - FSP_ERR_CRYPTO_NULL_POINTER,0x10009,"Null pointer input as a parameter" - FSP_ERR_CRYPTO_NOT_IMPLEMENTED,0x1000a,"Algorithm/size not implemented" - FSP_ERR_CRYPTO_RNG_INVALID_PARAM,0x1000b,"An invalid parameter is specified" - FSP_ERR_CRYPTO_RNG_FATAL_ERROR,0x1000c,"A fatal error occurred" - FSP_ERR_CRYPTO_INVALID_SIZE,0x1000d,"Size specified is invalid" - FSP_ERR_CRYPTO_INVALID_STATE,0x1000e,"Function used in an valid state" - FSP_ERR_CRYPTO_ALREADY_OPEN,0x1000f,"control block is already opened" - FSP_ERR_CRYPTO_INSTALL_KEY_FAILED,0x10010,"Specified input key is invalid." - FSP_ERR_CRYPTO_AUTHENTICATION_FAILED,0x10011,"Authentication failed" - FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL,0x10012,"Failure to Init Cipher" - FSP_ERR_CRYPTO_SCE_AUTHENTICATION,0x10013,"Authentication failed" - FSP_ERR_CRYPTO_SCE_PARAMETER,0x10014,"Input date is illegal." - FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION,0x10015,"An invalid function call occurred." - FSP_ERR_CRYPTO_COMMON_NOT_OPENED,0x20000,"Crypto Framework Common is not opened" - FSP_ERR_CRYPTO_HAL_ERROR,0x20001,"Cryoto HAL module returned an error" - FSP_ERR_CRYPTO_KEY_BUF_NOT_ENOUGH,0x20002,"Key buffer size is not enough to generate a key" - FSP_ERR_CRYPTO_BUF_OVERFLOW,0x20003,"Attempt to write data larger than what the buffer can hold" - FSP_ERR_CRYPTO_INVALID_OPERATION_MODE,0x20004,"Invalid operation mode." - FSP_ERR_MESSAGE_TOO_LONG,0x20005,"Message for RSA encryption is too long." - FSP_ERR_RSA_DECRYPTION_ERROR,0x20006,"RSA Decryption error." + :header: "Return Code", "Value", "Description" + + FSP_SUCCESS,0,"Normal termination" + FSP_ERR_CRYPTO_CONTINUE,0x10000,"Continue executing function" + FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT,0x10001,"Hardware resource busy" + FSP_ERR_CRYPTO_SCE_FAIL,0x10002,"Internal I/O buffer is not empty" + FSP_ERR_CRYPTO_SCE_HRK_INVALID_INDEX,0x10003,"Invalid index" + FSP_ERR_CRYPTO_SCE_RETRY,0x10004,"Retry" + FSP_ERR_CRYPTO_SCE_VERIFY_FAIL,0x10005,"Verify is failed" + FSP_ERR_CRYPTO_SCE_ALREADY_OPEN,0x10006,"HW SCE module is already opened" + FSP_ERR_CRYPTO_NOT_OPEN,0x10007,"Hardware module is not initialized" + FSP_ERR_CRYPTO_UNKNOWN,0x10008,"Some unknown error occurred" + FSP_ERR_CRYPTO_NULL_POINTER,0x10009,"Null pointer input as a parameter" + FSP_ERR_CRYPTO_NOT_IMPLEMENTED,0x1000a,"Algorithm/size not implemented" + FSP_ERR_CRYPTO_RNG_INVALID_PARAM,0x1000b,"An invalid parameter is specified" + FSP_ERR_CRYPTO_RNG_FATAL_ERROR,0x1000c,"A fatal error occurred" + FSP_ERR_CRYPTO_INVALID_SIZE,0x1000d,"Size specified is invalid" + FSP_ERR_CRYPTO_INVALID_STATE,0x1000e,"Function used in an valid state" + FSP_ERR_CRYPTO_ALREADY_OPEN,0x1000f,"control block is already opened" + FSP_ERR_CRYPTO_INSTALL_KEY_FAILED,0x10010,"Specified input key is invalid." + FSP_ERR_CRYPTO_AUTHENTICATION_FAILED,0x10011,"Authentication failed" + FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL,0x10012,"Failure to Init Cipher" + FSP_ERR_CRYPTO_SCE_AUTHENTICATION,0x10013,"Authentication failed" + FSP_ERR_CRYPTO_SCE_PARAMETER,0x10014,"Input date is illegal." + FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION,0x10015,"An invalid function call occurred." + FSP_ERR_CRYPTO_COMMON_NOT_OPENED,0x20000,"Crypto Framework Common is not opened" + FSP_ERR_CRYPTO_HAL_ERROR,0x20001,"Cryoto HAL module returned an error" + FSP_ERR_CRYPTO_KEY_BUF_NOT_ENOUGH,0x20002,"Key buffer size is not enough to generate a key" + FSP_ERR_CRYPTO_BUF_OVERFLOW,0x20003,"Attempt to write data larger than what the buffer can hold" + FSP_ERR_CRYPTO_INVALID_OPERATION_MODE,0x20004,"Invalid operation mode." + FSP_ERR_MESSAGE_TOO_LONG,0x20005,"Message for RSA encryption is too long." + FSP_ERR_RSA_DECRYPTION_ERROR,0x20006,"RSA Decryption error." The macro constants defined by the SCE driver is shown below. .. csv-table:: Macro define for Common operation - :header: "Macro Code", "Value" + :header: "Macro Code", "Value" - HW_SCE_SRAM_WORD_SIZE,32U - HW_SCE_SINST_WORD_SIZE,140U - HW_SCE_SINST2_WORD_SIZE,16U - HW_SCE_SHEAP_WORD_SIZE,1504U - HW_SCE_MAC_SIZE,16U + HW_SCE_SRAM_WORD_SIZE,32U + HW_SCE_SINST_WORD_SIZE,140U + HW_SCE_SINST2_WORD_SIZE,16U + HW_SCE_SHEAP_WORD_SIZE,1504U + HW_SCE_MAC_SIZE,16U .. csv-table:: Macro define for AES operation - :header: "Macro Code", "Value" - - HW_SCE_AES128_KEY_INDEX_WORD_SIZE,12U - HW_SCE_AES256_KEY_INDEX_WORD_SIZE,16U - HW_SCE_AES128_KEY_WORD_SIZE,4U - HW_SCE_AES256_KEY_WORD_SIZE,8U - HW_SCE_AES128_KEY_BYTE_SIZE,16U - HW_SCE_AES256_KEY_BYTE_SIZE,32U - HW_SCE_AES_BLOCK_BYTE_SIZE,16U - HW_SCE_AES_BLOCK_BIT_SIZE,128U - HW_SCE_AES_CBC_IV_BYTE_SIZE,16U - HW_SCE_AES_CTR_IV_BYTE_SIZE,16U + :header: "Macro Code", "Value" + + HW_SCE_AES128_KEY_INDEX_WORD_SIZE,12U + HW_SCE_AES256_KEY_INDEX_WORD_SIZE,16U + HW_SCE_AES128_KEY_WORD_SIZE,4U + HW_SCE_AES256_KEY_WORD_SIZE,8U + HW_SCE_AES128_KEY_BYTE_SIZE,16U + HW_SCE_AES256_KEY_BYTE_SIZE,32U + HW_SCE_AES_BLOCK_BYTE_SIZE,16U + HW_SCE_AES_BLOCK_BIT_SIZE,128U + HW_SCE_AES_CBC_IV_BYTE_SIZE,16U + HW_SCE_AES_CTR_IV_BYTE_SIZE,16U .. csv-table:: Macro define for SHA operation - :header: "Macro Code", "Value" + :header: "Macro Code", "Value" - HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE,28U - HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE,32U - HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE,64U + HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE,28U + HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE,32U + HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE,64U .. csv-table:: Macro define for RSA operation - :header: "Macro Code", "Value" - - HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE,128U - HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE,4U - HW_SCE_RSA_1024_KEY_D_LENGTH_BYTE_SIZE,128U - HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE,256U - HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE,4U - HW_SCE_RSA_2048_KEY_D_LENGTH_BYTE_SIZE,256U - HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE,128*4U - HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE,4U - HW_SCE_RSA_4096_KEY_D_LENGTH_BYTE_SIZE,128*4U - HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U - HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE,36U - HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U - HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE,68U - HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U - HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE,68U - HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U - HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE,132U - HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U - HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE,4U - HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE,12U - HW_SCE_RSA1024_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE,76U - HW_SCE_RSA1024_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE,104U - HW_SCE_RSA2048_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE,140U - HW_SCE_RSA2048_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE,200U - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE,11U - HW_SCE_RSA_1024_DATA_BYTE_SIZE,128U - HW_SCE_RSA_2048_DATA_BYTE_SIZE,256U - HW_SCE_RSA_4096_DATA_BYTE_SIZE,128*4U - HW_SCE_SHARED_SECRET_KEY_INDEX_WORD_SIZE,13U + :header: "Macro Code", "Value" + + HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE,128U + HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE,4U + HW_SCE_RSA_1024_KEY_D_LENGTH_BYTE_SIZE,128U + HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE,256U + HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE,4U + HW_SCE_RSA_2048_KEY_D_LENGTH_BYTE_SIZE,256U + HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE,128*4U + HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE,4U + HW_SCE_RSA_4096_KEY_D_LENGTH_BYTE_SIZE,128*4U + HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U + HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE,36U + HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U + HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE,68U + HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U + HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE,68U + HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U + HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE,132U + HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U + HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE,4U + HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE,12U + HW_SCE_RSA1024_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE,76U + HW_SCE_RSA1024_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE,104U + HW_SCE_RSA2048_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE,140U + HW_SCE_RSA2048_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE,200U + HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE,11U + HW_SCE_RSA_1024_DATA_BYTE_SIZE,128U + HW_SCE_RSA_2048_DATA_BYTE_SIZE,256U + HW_SCE_RSA_4096_DATA_BYTE_SIZE,128*4U + HW_SCE_SHARED_SECRET_KEY_INDEX_WORD_SIZE,13U .. csv-table:: Macro define for ECC operation - :header: "Macro Code", "Value" - - HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE,144U - HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE,4U - HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE,24U - HW_SCE_ECDSA_DATA_BYTE_SIZE,64U - HW_SCE_ECDSA_P512_DATA_BYTE_SIZE,128U - SCE_ECC_CURVE_TYPE_NIST,0 - SCE_ECC_CURVE_TYPE_BRAINPOOL,1 - SCE_ECC_CURVE_TYPE_KOBLITZ,2 - SCE_ECC_KEY_LENGTH_256,0 - SCE_ECC_KEY_LENGTH_224,1 - SCE_ECC_KEY_LENGTH_192,2 + :header: "Macro Code", "Value" + + HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE,144U + HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE,4U + HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE,24U + HW_SCE_ECDSA_DATA_BYTE_SIZE,64U + HW_SCE_ECDSA_P512_DATA_BYTE_SIZE,128U + SCE_ECC_CURVE_TYPE_NIST,0 + SCE_ECC_CURVE_TYPE_BRAINPOOL,1 + SCE_ECC_CURVE_TYPE_KOBLITZ,2 + SCE_ECC_KEY_LENGTH_256,0 + SCE_ECC_KEY_LENGTH_224,1 + SCE_ECC_KEY_LENGTH_192,2 .. csv-table:: Macro define for HASH type - :header: "Macro Code", "Value" + :header: "Macro Code", "Value" - HW_SCE_RSA_HASH_SHA256,0x03 + HW_SCE_RSA_HASH_SHA256,0x03 .. csv-table:: Macro define for Key update - :header: "Macro Code", "Value" - - HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE,16U - SCE_OEM_KEY_SIZE_DUMMY_INST_DATA_WORD,0 - SCE_OEM_KEY_SIZE_AES128_INST_DATA_WORD,8 - SCE_OEM_KEY_SIZE_AES256_INST_DATA_WORD,12 - SCE_OEM_KEY_SIZE_RSA1024_PUBLIC_KEY_INST_DATA_WORD,40 - SCE_OEM_KEY_SIZE_RSA1024_PRIVATE_KEY_INST_DATA_WORD,68 - SCE_OEM_KEY_SIZE_RSA2048_PUBLIC_KEY_INST_DATA_WORD,72 - SCE_OEM_KEY_SIZE_RSA2048_PRIVATE_KEY_INST_DATA_WORD,132 - SCE_OEM_KEY_SIZE_RSA4096_PUBLIC_KEY_INST_DATA_WORD,136 - SCE_OEM_KEY_SIZE_RSA4096_PRIVATE_KEY_INST_DATA_WORD,260 - SCE_OEM_KEY_SIZE_ECCP192_PUBLIC_KEY_INST_DATA_WORD,20 - SCE_OEM_KEY_SIZE_ECCP192_PRIVATE_KEY_INST_DATA_WORD,12 - SCE_OEM_KEY_SIZE_ECCP224_PUBLIC_KEY_INST_DATA_WORD,20 - SCE_OEM_KEY_SIZE_ECCP224_PRIVATE_KEY_INST_DATA_WORD,12 - SCE_OEM_KEY_SIZE_ECCP256_PUBLIC_KEY_INST_DATA_WORD,20 - SCE_OEM_KEY_SIZE_ECCP256_PRIVATE_KEY_INST_DATA_WORD,12 - SCE_INSTALL_KEY_RING_INDEX,0 + :header: "Macro Code", "Value" + + HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE,16U + SCE_OEM_KEY_SIZE_DUMMY_INST_DATA_WORD,0 + SCE_OEM_KEY_SIZE_AES128_INST_DATA_WORD,8 + SCE_OEM_KEY_SIZE_AES256_INST_DATA_WORD,12 + SCE_OEM_KEY_SIZE_RSA1024_PUBLIC_KEY_INST_DATA_WORD,40 + SCE_OEM_KEY_SIZE_RSA1024_PRIVATE_KEY_INST_DATA_WORD,68 + SCE_OEM_KEY_SIZE_RSA2048_PUBLIC_KEY_INST_DATA_WORD,72 + SCE_OEM_KEY_SIZE_RSA2048_PRIVATE_KEY_INST_DATA_WORD,132 + SCE_OEM_KEY_SIZE_RSA4096_PUBLIC_KEY_INST_DATA_WORD,136 + SCE_OEM_KEY_SIZE_RSA4096_PRIVATE_KEY_INST_DATA_WORD,260 + SCE_OEM_KEY_SIZE_ECCP192_PUBLIC_KEY_INST_DATA_WORD,20 + SCE_OEM_KEY_SIZE_ECCP192_PRIVATE_KEY_INST_DATA_WORD,12 + SCE_OEM_KEY_SIZE_ECCP224_PUBLIC_KEY_INST_DATA_WORD,20 + SCE_OEM_KEY_SIZE_ECCP224_PRIVATE_KEY_INST_DATA_WORD,12 + SCE_OEM_KEY_SIZE_ECCP256_PUBLIC_KEY_INST_DATA_WORD,20 + SCE_OEM_KEY_SIZE_ECCP256_PRIVATE_KEY_INST_DATA_WORD,12 + SCE_INSTALL_KEY_RING_INDEX,0 ************************************************************************* @@ -572,53 +572,53 @@ SCE_KEY_INDEX_TYPE .. code:: c - typedef enum - { - SCE_KEY_INDEX_TYPE_INVALID = 0U, - SCE_KEY_INDEX_TYPE_AES128, - SCE_KEY_INDEX_TYPE_AES256, - SCE_KEY_INDEX_TYPE_TDES, - SCE_KEY_INDEX_TYPE_HMAC_SHA1, - SCE_KEY_INDEX_TYPE_HMAC_SHA256, - SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE, - SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE, - SCE_KEY_INDEX_TYPE_RSA3072_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA3072_PRIVATE, - SCE_KEY_INDEX_TYPE_RSA4096_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA4096_PRIVATE, - SCE_KEY_INDEX_TYPE_AES128_FOR_TLS, - SCE_KEY_INDEX_TYPE_AES192_FOR_TLS, - SCE_KEY_INDEX_TYPE_AES256_FOR_TLS, - SCE_KEY_INDEX_TYPE_HMAC_SHA1_FOR_TLS, - SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_TLS, - SCE_KEY_INDEX_TYPE_UPDATE_KEY_RING, - SCE_KEY_INDEX_TYPE_TLS_CA_CERTIFICATION_PUBLIC_KEY, - SCE_KEY_INDEX_TYPE_TLS_P256_ECC_KEY, - SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P256R1_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P512R1_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P256R1_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P512R1_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PRIVATE, - SCE_KEY_INDEX_TYPE_ECDH_SHARED_SECRET, - SCE_KEY_INDEX_TYPE_AES128_FOR_ECDH, - SCE_KEY_INDEX_TYPE_AES256_FOR_ECDH, - SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_ECDH, - SCE_KEY_INDEX_TYPE_AES128_GCM_FOR_DLMS_COSEM, - SCE_KEY_INDEX_TYPE_AES256_GCM_FOR_DLMS_COSEM, - SCE_KEY_INDEX_TYPE_AES128_KEY_WRAP_FOR_DLMS_COSEM, - SCE_KEY_INDEX_TYPE_AES128_GCM_WITH_IV, - } SCE_KEY_INDEX_TYPE; + typedef enum + { + SCE_KEY_INDEX_TYPE_INVALID = 0U, + SCE_KEY_INDEX_TYPE_AES128, + SCE_KEY_INDEX_TYPE_AES256, + SCE_KEY_INDEX_TYPE_TDES, + SCE_KEY_INDEX_TYPE_HMAC_SHA1, + SCE_KEY_INDEX_TYPE_HMAC_SHA256, + SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE, + SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE, + SCE_KEY_INDEX_TYPE_RSA3072_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA3072_PRIVATE, + SCE_KEY_INDEX_TYPE_RSA4096_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA4096_PRIVATE, + SCE_KEY_INDEX_TYPE_AES128_FOR_TLS, + SCE_KEY_INDEX_TYPE_AES192_FOR_TLS, + SCE_KEY_INDEX_TYPE_AES256_FOR_TLS, + SCE_KEY_INDEX_TYPE_HMAC_SHA1_FOR_TLS, + SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_TLS, + SCE_KEY_INDEX_TYPE_UPDATE_KEY_RING, + SCE_KEY_INDEX_TYPE_TLS_CA_CERTIFICATION_PUBLIC_KEY, + SCE_KEY_INDEX_TYPE_TLS_P256_ECC_KEY, + SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P256R1_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P512R1_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P256R1_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P512R1_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PRIVATE, + SCE_KEY_INDEX_TYPE_ECDH_SHARED_SECRET, + SCE_KEY_INDEX_TYPE_AES128_FOR_ECDH, + SCE_KEY_INDEX_TYPE_AES256_FOR_ECDH, + SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_ECDH, + SCE_KEY_INDEX_TYPE_AES128_GCM_FOR_DLMS_COSEM, + SCE_KEY_INDEX_TYPE_AES256_GCM_FOR_DLMS_COSEM, + SCE_KEY_INDEX_TYPE_AES128_KEY_WRAP_FOR_DLMS_COSEM, + SCE_KEY_INDEX_TYPE_AES128_GCM_WITH_IV, + } SCE_KEY_INDEX_TYPE; ------------------------------------------------------- sce_oem_cmd @@ -626,31 +626,31 @@ sce_oem_cmd .. code:: c - typedef enum e_sce_oem_cmd - { - SCE_OEM_CMD_AES128 = 5, - SCE_OEM_CMD_AES256 = 7, - SCE_OEM_CMD_RSA1024_PUBLIC = 10, - SCE_OEM_CMD_RSA1024_PRIVATE, - SCE_OEM_CMD_RSA2048_PUBLIC, - SCE_OEM_CMD_RSA2048_PRIVATE, - SCE_OEM_CMD_RSA3072_PUBLIC, - SCE_OEM_CMD_RSA3072_PRIVATE, - SCE_OEM_CMD_RSA4096_PUBLIC, - SCE_OEM_CMD_RSA4096_PRIVATE, - SCE_OEM_CMD_ECC_P192_PUBLIC, - SCE_OEM_CMD_ECC_P192_PRIVATE, - SCE_OEM_CMD_ECC_P224_PUBLIC, - SCE_OEM_CMD_ECC_P224_PRIVATE, - SCE_OEM_CMD_ECC_P256_PUBLIC, - SCE_OEM_CMD_ECC_P256_PRIVATE, - SCE_OEM_CMD_ECC_P384_PUBLIC, - SCE_OEM_CMD_ECC_P384_PRIVATE, - SCE_OEM_CMD_ECC_P512_PUBLIC, - SCE_OEM_CMD_ECC_P512_PRIVATE, - SCE_OEM_CMD_HMAC_SHA256 = 28, - SCE_OEM_CMD_NUM - } sce_oem_cmd_t; + typedef enum e_sce_oem_cmd + { + SCE_OEM_CMD_AES128 = 5, + SCE_OEM_CMD_AES256 = 7, + SCE_OEM_CMD_RSA1024_PUBLIC = 10, + SCE_OEM_CMD_RSA1024_PRIVATE, + SCE_OEM_CMD_RSA2048_PUBLIC, + SCE_OEM_CMD_RSA2048_PRIVATE, + SCE_OEM_CMD_RSA3072_PUBLIC, + SCE_OEM_CMD_RSA3072_PRIVATE, + SCE_OEM_CMD_RSA4096_PUBLIC, + SCE_OEM_CMD_RSA4096_PRIVATE, + SCE_OEM_CMD_ECC_P192_PUBLIC, + SCE_OEM_CMD_ECC_P192_PRIVATE, + SCE_OEM_CMD_ECC_P224_PUBLIC, + SCE_OEM_CMD_ECC_P224_PRIVATE, + SCE_OEM_CMD_ECC_P256_PUBLIC, + SCE_OEM_CMD_ECC_P256_PRIVATE, + SCE_OEM_CMD_ECC_P384_PUBLIC, + SCE_OEM_CMD_ECC_P384_PRIVATE, + SCE_OEM_CMD_ECC_P512_PUBLIC, + SCE_OEM_CMD_ECC_P512_PRIVATE, + SCE_OEM_CMD_HMAC_SHA256 = 28, + SCE_OEM_CMD_NUM + } sce_oem_cmd_t; ------------------------------------------------------- sce_byte_data @@ -659,12 +659,12 @@ Byte data structure .. code:: c - typedef struct sce_byte_data - { - uint8_t * pdata; ///< pointer - uint32_t data_length; ///< data_length - uint32_t data_type; ///< data type - } sce_byte_data_t; + typedef struct sce_byte_data + { + uint8_t * pdata; ///< pointer + uint32_t data_length; ///< data_length + uint32_t data_type; ///< data type + } sce_byte_data_t; ------------------------------------------------------- sce_rsa_byte_data_t @@ -673,7 +673,7 @@ RSA byte data structure .. code:: c - typedef sce_byte_data_t sce_rsa_byte_data_t; ///< byte data + typedef sce_byte_data_t sce_rsa_byte_data_t; ///< byte data ------------------------------------------------------- sce_ecdsa_byte_data_t @@ -682,7 +682,7 @@ ECDSA byte data structure .. code:: c - typedef sce_byte_data_t sce_ecdsa_byte_data_t; ///< byte data + typedef sce_byte_data_t sce_ecdsa_byte_data_t; ///< byte data ------------------------------------------------------- sce_aes_wrapped_key_t @@ -691,13 +691,13 @@ AES wrapped key data structure. DO NOT MODIFY. .. code:: c - typedef struct sce_aes_wrapped_key - { - uint32_t type; ///< key type + typedef struct sce_aes_wrapped_key + { + uint32_t type; ///< key type - /* AES128, AES256 are supported */ - uint32_t value[SCE_TLS_AES256_KEY_INDEX_WORD_SIZE]; ///< wrapped key value - } sce_aes_wrapped_key_t; + /* AES128, AES256 are supported */ + uint32_t value[SCE_TLS_AES256_KEY_INDEX_WORD_SIZE]; ///< wrapped key value + } sce_aes_wrapped_key_t; ------------------------------------------------------- sce_rsa1024_public_wrapped_key_t @@ -706,18 +706,18 @@ RSA 1024bit public wrapped key data structure. DO NOT MODIFY. .. code:: c - typedef struct sce_rsa1024_public_wrapped_key - { - uint32_t type; ///< key type - struct - { - uint32_t key_management_info1[HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information - uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 1024-bit public key n (plaintext) - uint8_t key_e[HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE]; ///< RSA 1024-bit public key e (plaintext) - uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; ///< dummy - uint32_t key_management_info2[HW_SCE_AES256_KEY_INDEX_WORD_SIZE]; ///< key management information - } value; - } sce_rsa1024_public_wrapped_key_t; + typedef struct sce_rsa1024_public_wrapped_key + { + uint32_t type; ///< key type + struct + { + uint32_t key_management_info1[HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information + uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 1024-bit public key n (plaintext) + uint8_t key_e[HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE]; ///< RSA 1024-bit public key e (plaintext) + uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; ///< dummy + uint32_t key_management_info2[HW_SCE_AES256_KEY_INDEX_WORD_SIZE]; ///< key management information + } value; + } sce_rsa1024_public_wrapped_key_t; ------------------------------------------------------- sce_rsa1024_private_wrapped_key_t @@ -726,16 +726,16 @@ RSA 1024bit private wrapped key data structure. DO NOT MODIFY. .. code:: c - typedef struct sce_rsa1024_private_wrapped_key - { - uint32_t type; ///< key type - struct - { - uint32_t key_management_info1[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information - uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 1024-bit private key n (plaintext) - uint32_t key_management_info2[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information - } value; - } sce_rsa1024_private_wrapped_key_t; + typedef struct sce_rsa1024_private_wrapped_key + { + uint32_t type; ///< key type + struct + { + uint32_t key_management_info1[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information + uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 1024-bit private key n (plaintext) + uint32_t key_management_info2[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information + } value; + } sce_rsa1024_private_wrapped_key_t; ------------------------------------------------------- sce_rsa2048_public_wrapped_key_t @@ -744,18 +744,18 @@ RSA 2048bit public wrapped key data structure. DO NOT MODIFY. .. code:: c - typedef struct sce_rsa2048_public_wrapped_key - { - uint32_t type; ///< Key type - struct - { - uint32_t key_management_info1[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information - uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 2048-bit public key n (plaintext) - uint8_t key_e[HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE]; ///< RSA 2048-bit public key e (plaintext) - uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; ///< dummy - uint32_t key_management_info2[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information - } value; - } sce_rsa2048_public_wrapped_key_t; + typedef struct sce_rsa2048_public_wrapped_key + { + uint32_t type; ///< Key type + struct + { + uint32_t key_management_info1[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information + uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 2048-bit public key n (plaintext) + uint8_t key_e[HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE]; ///< RSA 2048-bit public key e (plaintext) + uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; ///< dummy + uint32_t key_management_info2[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information + } value; + } sce_rsa2048_public_wrapped_key_t; ------------------------------------------------------- sce_rsa2048_private_wrapped_key_t @@ -764,16 +764,16 @@ RSA 2048bit private wrapped key data structure. DO NOT MODIFY. .. code:: c - typedef struct sce_rsa2048_private_wrapped_key - { - uint32_t type; ///< key type - struct - { - uint32_t key_management_info1[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information - uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 2048-bit private key n (plaintext) - uint32_t key_management_info2[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information - } value; - } sce_rsa2048_private_wrapped_key_t; + typedef struct sce_rsa2048_private_wrapped_key + { + uint32_t type; ///< key type + struct + { + uint32_t key_management_info1[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information + uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 2048-bit private key n (plaintext) + uint32_t key_management_info2[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information + } value; + } sce_rsa2048_private_wrapped_key_t; ------------------------------------------------------- sce_rsa4096_public_wrapped_key_t @@ -782,18 +782,18 @@ RSA 4096bit public wrapped key data structure. DO NOT MODIFY. .. code:: c - typedef struct sce_rsa4096_public_wrapped_key - { - uint32_t type; ///< Key type - struct - { - uint32_t key_management_info1[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information - uint8_t key_n[HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 4096-bit public key n (plaintext) - uint8_t key_e[HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE]; ///< RSA 4096-bit public key e (plaintext) - uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; ///< dummy - uint32_t key_management_info2[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information - } value; - } sce_rsa4096_public_wrapped_key_t; + typedef struct sce_rsa4096_public_wrapped_key + { + uint32_t type; ///< Key type + struct + { + uint32_t key_management_info1[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information + uint8_t key_n[HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 4096-bit public key n (plaintext) + uint8_t key_e[HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE]; ///< RSA 4096-bit public key e (plaintext) + uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; ///< dummy + uint32_t key_management_info2[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information + } value; + } sce_rsa4096_public_wrapped_key_t; ------------------------------------------------------- sce_rsa1024_wrapped_pair_key_t @@ -802,11 +802,11 @@ RSA 1024bit wrapped key pair structure. DO NOT MODIFY. .. code:: c - typedef struct sce_rsa1024_wrapped_pair_key - { - sce_rsa1024_private_wrapped_key_t priv_key; ///< RSA 1024-bit private wrapped key - sce_rsa1024_public_wrapped_key_t pub_key; ///< RSA 1024-bit public wrapped key - } sce_rsa1024_wrapped_pair_key_t; + typedef struct sce_rsa1024_wrapped_pair_key + { + sce_rsa1024_private_wrapped_key_t priv_key; ///< RSA 1024-bit private wrapped key + sce_rsa1024_public_wrapped_key_t pub_key; ///< RSA 1024-bit public wrapped key + } sce_rsa1024_wrapped_pair_key_t; ------------------------------------------------------- sce_rsa2048_wrapped_pair_key_t @@ -815,11 +815,11 @@ RSA 2048bit wrapped key pair structure. DO NOT MODIFY. .. code:: c - typedef struct sce_rsa2048_wrapped_pair_key - { - sce_rsa2048_private_wrapped_key_t priv_key; ///< RSA 2048-bit private wrapped key - sce_rsa2048_public_wrapped_key_t pub_key; ///< RSA 2048-bit public wrapped key - } sce_rsa2048_wrapped_pair_key_t; + typedef struct sce_rsa2048_wrapped_pair_key + { + sce_rsa2048_private_wrapped_key_t priv_key; ///< RSA 2048-bit private wrapped key + sce_rsa2048_public_wrapped_key_t pub_key; ///< RSA 2048-bit public wrapped key + } sce_rsa2048_wrapped_pair_key_t; ------------------------------------------------------- sce_ecc_private_wrapped_key_t @@ -828,11 +828,11 @@ ECC P-192/224/256/512 private wrapped key data structure. .. code:: c - typedef struct sce_ecc_private_wrapped_key - { - uint32_t type; ///< key type - uint32_t value[HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE]; ///< wrapped key value - } sce_ecc_private_wrapped_key_t; + typedef struct sce_ecc_private_wrapped_key + { + uint32_t type; ///< key type + uint32_t value[HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE]; ///< wrapped key value + } sce_ecc_private_wrapped_key_t; ------------------------------------------------------- @@ -842,15 +842,15 @@ ECC P-192/224/256/512 public wrapped key data structure. .. code:: c - typedef struct sce_ecc_public_wrapped_key - { - uint32_t type; ///< key type - struct - { - uint32_t key_management_info[HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE]; ///< key management information - uint8_t key_q[HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE]; ///< ECC public key Q (plaintext) - } value; - } sce_ecc_public_wrapped_key_t; + typedef struct sce_ecc_public_wrapped_key + { + uint32_t type; ///< key type + struct + { + uint32_t key_management_info[HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE]; ///< key management information + uint8_t key_q[HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE]; ///< ECC public key Q (plaintext) + } value; + } sce_ecc_public_wrapped_key_t; ------------------------------------------------------- sce_ecc_wrapped_pair_key_t @@ -859,11 +859,11 @@ ECC P-192/224/256/512 wrapped key pair structure. .. code:: c - typedef struct sce_ecc_wrapped_pair_key - { - sce_ecc_private_wrapped_key_t priv_key; ///< ECC private wrapped key - sce_ecc_public_wrapped_key_t pub_key; ///< ECC public wrapped key - } sce_ecc_wrapped_pair_key_t; + typedef struct sce_ecc_wrapped_pair_key + { + sce_ecc_private_wrapped_key_t priv_key; ///< ECC private wrapped key + sce_ecc_public_wrapped_key_t pub_key; ///< ECC public wrapped key + } sce_ecc_wrapped_pair_key_t; ------------------------------------------------------- sce_key_update_key_t @@ -872,11 +872,11 @@ Update key ring index data structure. DO NOT MODIFY. .. code:: c - typedef struct sce_key_update_key - { - uint32_t type; ///< key type - uint32_t value[HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE]; ///< wrapped key value - } sce_key_update_key_t; + typedef struct sce_key_update_key + { + uint32_t type; ///< key type + uint32_t value[HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE]; ///< wrapped key value + } sce_key_update_key_t; ------------------------------------------------------- sce_aes_handle_t @@ -885,16 +885,16 @@ The work area for AES. DO NOT MODIFY. .. code:: c - typedef struct sce_aes_handle - { - uint32_t id; ///< serial number of this handle - sce_aes_wrapped_key_t wrapped_key; ///< wrapped key - uint32_t current_input_data_size; ///< text size under encryption / decryption - uint8_t last_1_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE]; ///< text array less than the block long - uint8_t last_2_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE * 2]; ///< reserved - uint8_t current_initial_vector[HW_SCE_AES_CBC_IV_BYTE_SIZE]; ///< current initialization vector used in CBC mode - uint8_t flag_call_init; ///< control flag of calling function - } sce_aes_handle_t; + typedef struct sce_aes_handle + { + uint32_t id; ///< serial number of this handle + sce_aes_wrapped_key_t wrapped_key; ///< wrapped key + uint32_t current_input_data_size; ///< text size under encryption / decryption + uint8_t last_1_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE]; ///< text array less than the block long + uint8_t last_2_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE * 2]; ///< reserved + uint8_t current_initial_vector[HW_SCE_AES_CBC_IV_BYTE_SIZE]; ///< current initialization vector used in CBC mode + uint8_t flag_call_init; ///< control flag of calling function + } sce_aes_handle_t; ------------------------------------------------------- sce_cmac_handle_t @@ -903,15 +903,15 @@ The work area for CMAC. DO NOT MODIFY. .. code:: c - typedef struct sce_cmac_handle - { - uint32_t id; ///< serial number of this handle - sce_aes_wrapped_key_t wrapped_key; ///< wrapped key - uint8_t cmac_buffer[HW_SCE_AES_BLOCK_BYTE_SIZE]; ///< message array less than the block long - uint32_t all_received_length; ///< entire length of message - uint32_t buffering_length; ///< message array length less than the block long - uint8_t flag_call_init; ///< control flag of calling function - } sce_cmac_handle_t; + typedef struct sce_cmac_handle + { + uint32_t id; ///< serial number of this handle + sce_aes_wrapped_key_t wrapped_key; ///< wrapped key + uint8_t cmac_buffer[HW_SCE_AES_BLOCK_BYTE_SIZE]; ///< message array less than the block long + uint32_t all_received_length; ///< entire length of message + uint32_t buffering_length; ///< message array length less than the block long + uint8_t flag_call_init; ///< control flag of calling function + } sce_cmac_handle_t; ------------------------------------------------------- sce_sha_md5_handle_t @@ -920,17 +920,17 @@ The work area for SHA. DO NOT MODIFY. .. code:: c - typedef struct sce_sha_md5_handle - { - uint32_t id; ///< serial number of this handle - uint8_t sha_buffer[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE * 4]; ///< message array length less than the block long - uint32_t all_received_length; ///< entire length of message - uint32_t buffering_length; ///< message array length less than the block long + typedef struct sce_sha_md5_handle + { + uint32_t id; ///< serial number of this handle + uint8_t sha_buffer[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE * 4]; ///< message array length less than the block long + uint32_t all_received_length; ///< entire length of message + uint32_t buffering_length; ///< message array length less than the block long - /* SHA1(20byte), SHA256(32byte), MD5(16byte) are supported */ - uint8_t current_hash[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE]; ///< last hash value - uint8_t flag_call_init; ///< control flag of calling function - } sce_sha_md5_handle_t; + /* SHA1(20byte), SHA256(32byte), MD5(16byte) are supported */ + uint8_t current_hash[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE]; ///< last hash value + uint8_t flag_call_init; ///< control flag of calling function + } sce_sha_md5_handle_t; ------------------------------------------------------- sce_ctrl_t @@ -938,7 +938,7 @@ sce_ctrl_t .. code:: c - typedef void sce_ctrl_t; + typedef void sce_ctrl_t; ------------------------------------------------------- sce_cfg_t @@ -946,7 +946,7 @@ sce_cfg_t .. code:: c - typedef void sce_cfg_t; + typedef void sce_cfg_t; ------------------------------------------------------- @@ -956,279 +956,279 @@ Functions implemented in sce driver. .. code:: c - typedef struct st_sce_api - { - - fsp_err_t (* open)(sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg); - - fsp_err_t (* close)(sce_ctrl_t * const p_ctrl); - - fsp_err_t (* softwareReset)(void); - - fsp_err_t (* randomNumberGenerate)(uint32_t * random); - - fsp_err_t (* AES128_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES256_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES128_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES256_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES128ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES128ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - fsp_err_t (* AES128ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - fsp_err_t (* AES128ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES128ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - fsp_err_t (* AES128ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - fsp_err_t (* AES256ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES256ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - fsp_err_t (* AES256ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - fsp_err_t (* AES256ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES256ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - fsp_err_t (* AES256ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - fsp_err_t (* AES128CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES128CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - fsp_err_t (* AES128CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - fsp_err_t (* AES128CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES128CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - fsp_err_t (* AES128CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - fsp_err_t (* AES256CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES256CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - fsp_err_t (* AES256CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - fsp_err_t (* AES256CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES256CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - fsp_err_t (* AES256CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - fsp_err_t (* AES128CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES128CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - fsp_err_t (* AES128CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - fsp_err_t (* AES128CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES128CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - fsp_err_t (* AES128CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - fsp_err_t (* AES256CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES256CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - fsp_err_t (* AES256CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - fsp_err_t (* AES256CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES256CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - fsp_err_t (* AES256CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - fsp_err_t (* AES128CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES128CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - fsp_err_t (* AES128CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); - - fsp_err_t (* AES128CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES128CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - fsp_err_t (* AES128CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); - - fsp_err_t (* AES256CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES256CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - fsp_err_t (* AES256CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); - - fsp_err_t (* AES256CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES256CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - fsp_err_t (* AES256CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); - - fsp_err_t (* SHA256_Init)(sce_sha_md5_handle_t * handle); - - fsp_err_t (* SHA256_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); - - fsp_err_t (* SHA256_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); - - fsp_err_t (* SHA224_Init)(sce_sha_md5_handle_t * handle); - - fsp_err_t (* SHA224_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); - - fsp_err_t (* SHA224_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); - - fsp_err_t (* RSA1024_WrappedKeyPairGenerate)(sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key); - - fsp_err_t (* RSA2048_WrappedKeyPairGenerate)(sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key); - - fsp_err_t (* RSA1024_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSA1024_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSA2048_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSA2048_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSA4096_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa4096_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSASSA_PKCS1024_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, sce_rsa_byte_data_t * signature, - sce_rsa1024_private_wrapped_key_t * wrapped_key, uint8_t hash_type); - - fsp_err_t (* RSASSA_PKCS2048_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, sce_rsa_byte_data_t * signature, - sce_rsa2048_private_wrapped_key_t * wrapped_key, uint8_t hash_type); - - fsp_err_t (* RSASSA_PKCS1024_SignatureVerify)(sce_rsa_byte_data_t * signature, sce_rsa_byte_data_t * message_hash, - sce_rsa1024_public_wrapped_key_t * wrapped_key, uint8_t hash_type); - - fsp_err_t (* RSASSA_PKCS2048_SignatureVerify)(sce_rsa_byte_data_t * signature, sce_rsa_byte_data_t * message_hash, - sce_rsa2048_public_wrapped_key_t * wrapped_key, uint8_t hash_type); - - fsp_err_t (* RSASSA_PKCS4096_SignatureVerify)(sce_rsa_byte_data_t * signature, sce_rsa_byte_data_t * message_hash, - sce_rsa4096_public_wrapped_key_t * wrapped_key, uint8_t hash_type); - - fsp_err_t (* RSAES_PKCS1024_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, - sce_rsa1024_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSAES_PKCS2048_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, - sce_rsa2048_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSAES_PKCS4096_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, - sce_rsa4096_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSAES_PKCS1024_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, - sce_rsa1024_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSAES_PKCS2048_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, - sce_rsa2048_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_secp192r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - fsp_err_t (* ECC_secp224r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - fsp_err_t (* ECC_secp256r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - fsp_err_t (* ECC_secp192r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_secp224r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_secp256r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_secp192r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_secp224r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_secp256r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_secp192r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_secp224r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_secp256r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_secp192r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_secp224r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_secp256r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - } sce_api_t; + typedef struct st_sce_api + { + + fsp_err_t (* open)(sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg); + + fsp_err_t (* close)(sce_ctrl_t * const p_ctrl); + + fsp_err_t (* softwareReset)(void); + + fsp_err_t (* randomNumberGenerate)(uint32_t * random); + + fsp_err_t (* AES128_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES256_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES128_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES256_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES128ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES128ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + fsp_err_t (* AES128ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + fsp_err_t (* AES128ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES128ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + fsp_err_t (* AES128ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + fsp_err_t (* AES256ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES256ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + fsp_err_t (* AES256ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + fsp_err_t (* AES256ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES256ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + fsp_err_t (* AES256ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + fsp_err_t (* AES128CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES128CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + fsp_err_t (* AES128CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + fsp_err_t (* AES128CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES128CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + fsp_err_t (* AES128CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + fsp_err_t (* AES256CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES256CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + fsp_err_t (* AES256CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + fsp_err_t (* AES256CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES256CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + fsp_err_t (* AES256CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + fsp_err_t (* AES128CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES128CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + fsp_err_t (* AES128CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + fsp_err_t (* AES128CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES128CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + fsp_err_t (* AES128CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + fsp_err_t (* AES256CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES256CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + fsp_err_t (* AES256CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + fsp_err_t (* AES256CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + fsp_err_t (* AES256CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + fsp_err_t (* AES256CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + fsp_err_t (* AES128CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES128CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + fsp_err_t (* AES128CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); + + fsp_err_t (* AES128CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES128CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + fsp_err_t (* AES128CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); + + fsp_err_t (* AES256CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES256CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + fsp_err_t (* AES256CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); + + fsp_err_t (* AES256CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + fsp_err_t (* AES256CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + fsp_err_t (* AES256CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); + + fsp_err_t (* SHA256_Init)(sce_sha_md5_handle_t * handle); + + fsp_err_t (* SHA256_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); + + fsp_err_t (* SHA256_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); + + fsp_err_t (* SHA224_Init)(sce_sha_md5_handle_t * handle); + + fsp_err_t (* SHA224_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); + + fsp_err_t (* SHA224_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); + + fsp_err_t (* RSA1024_WrappedKeyPairGenerate)(sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key); + + fsp_err_t (* RSA2048_WrappedKeyPairGenerate)(sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key); + + fsp_err_t (* RSA1024_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSA1024_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSA2048_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSA2048_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSA4096_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa4096_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSASSA_PKCS1024_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, sce_rsa_byte_data_t * signature, + sce_rsa1024_private_wrapped_key_t * wrapped_key, uint8_t hash_type); + + fsp_err_t (* RSASSA_PKCS2048_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, sce_rsa_byte_data_t * signature, + sce_rsa2048_private_wrapped_key_t * wrapped_key, uint8_t hash_type); + + fsp_err_t (* RSASSA_PKCS1024_SignatureVerify)(sce_rsa_byte_data_t * signature, sce_rsa_byte_data_t * message_hash, + sce_rsa1024_public_wrapped_key_t * wrapped_key, uint8_t hash_type); + + fsp_err_t (* RSASSA_PKCS2048_SignatureVerify)(sce_rsa_byte_data_t * signature, sce_rsa_byte_data_t * message_hash, + sce_rsa2048_public_wrapped_key_t * wrapped_key, uint8_t hash_type); + + fsp_err_t (* RSASSA_PKCS4096_SignatureVerify)(sce_rsa_byte_data_t * signature, sce_rsa_byte_data_t * message_hash, + sce_rsa4096_public_wrapped_key_t * wrapped_key, uint8_t hash_type); + + fsp_err_t (* RSAES_PKCS1024_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, + sce_rsa1024_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSAES_PKCS2048_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, + sce_rsa2048_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSAES_PKCS4096_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, + sce_rsa4096_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSAES_PKCS1024_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, + sce_rsa1024_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* RSAES_PKCS2048_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, + sce_rsa2048_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_secp192r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + fsp_err_t (* ECC_secp224r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + fsp_err_t (* ECC_secp256r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + fsp_err_t (* ECC_secp192r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_secp224r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_secp256r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_secp192r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_secp224r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_secp256r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_secp192r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_secp224r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_secp256r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_secp192r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_secp224r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_secp256r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + + fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + } sce_api_t; ------------------------------------------------------- sce_instance_t @@ -1237,12 +1237,12 @@ This structure encompasses everything that is needed to use an instance of this .. code:: c - typedef struct st_sce_instance - { - sce_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance - sce_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance - sce_api_t const * p_api; ///< Pointer to the API structure for this instance - } sce_instance_t; + typedef struct st_sce_instance + { + sce_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance + sce_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance + sce_api_t const * p_api; ///< Pointer to the API structure for this instance + } sce_instance_t; ************************************************************************* 2.5.Global Variables @@ -1258,106 +1258,106 @@ There are no global variables that can be used by users. 2.6.1.R_SCE_Open ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_Open ( sce_ctrl_t const \*\p_ctrl, sce_cfg_t const \*\const p_cfg ) | -+--------------+---------------------------------------------------------------------------------+ -| Description | Enables use of SCE functionality. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |p_ctrl |Pointer to control structure. | -| +---------+--------------------------+--------------------------------------------+ -| |IN |p_cfg |Pointer to pin configuration structure. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |The error-detection self-test failed to | -| | ||br| terminate normally. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RETRY |Indicates that an entropy evaluation failure| -| | ||br| occurred. Run the function again. | +|fsp_err_t R_SCE_Open ( sce_ctrl_t const \*\p_ctrl, sce_cfg_t const \*\const p_cfg ) | ++--------------+---------------------------------------------------------------------------------+ +| Description | Enables use of SCE functionality. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |p_ctrl |Pointer to control structure. | +| +---------+--------------------------+--------------------------------------------+ +| |IN |p_cfg |Pointer to pin configuration structure. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |The error-detection self-test failed to | +| | ||br| terminate normally. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RETRY |Indicates that an entropy evaluation failure| +| | ||br| occurred. Run the function again. | +--------------+------------------------------------+--------------------------------------------+ -| Note | | +| Note | | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- 2.6.2.R_SCE_Close ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_Close ( sce_ctrl_t \*\const p_ctrl) | +|fsp_err_t R_SCE_Close ( sce_ctrl_t \*\const p_ctrl) | +--------------+---------------------------------------------------------------------------------+ -| Description | Stops supply of power to the SCE. | +| Description | Stops supply of power to the SCE. | +--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |p_ctrl |Pointer to control structure. | +| Arguments |IN |p_ctrl |Pointer to control structure. | +--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | +| Return value |FSP_SUCCESS |Normal termination | +--------------+------------------------------------+--------------------------------------------+ -| Note | | +| Note | | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- 2.6.3.R_SCE_SoftwareReset ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SoftwareReset ( void ) | +|fsp_err_t R_SCE_SoftwareReset ( void ) | +--------------+---------------------------------------------------------------------------------+ -| Description | Software reset to SCE. | +| Description | Software reset to SCE. | +--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |none |none |none | +| Arguments |none |none |none | +--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | +| Return value |FSP_SUCCESS |Normal termination | +--------------+------------------------------------+--------------------------------------------+ -| Note | | +| Note | | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- 2.6.4.R_SCE_AES128_WrappedKeyGenerate ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128_WrappedKeyGenerate ( sce_aes_wrapped_key_t \*\ wrapped_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API outputs 128-bit AES wrapped key from a random number. | -| ||br| This API generates a wrapped key from a random number in the SCE. | -| ||br| Accordingly, user key input is unnecessary. | -| ||br| By encrypting data using the wrapped key is output by this API, | -| ||br| dead copying of data can be prevented. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_key |128-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | +|fsp_err_t R_SCE_AES128_WrappedKeyGenerate ( sce_aes_wrapped_key_t \*\ wrapped_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API outputs 128-bit AES wrapped key from a random number. | +| ||br| This API generates a wrapped key from a random number in the SCE. | +| ||br| Accordingly, user key input is unnecessary. | +| ||br| By encrypting data using the wrapped key is output by this API, | +| ||br| dead copying of data can be prevented. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_key |128-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +--------------+------------------------------------+--------------------------------------------+ -| Note | | +| Note | | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- 2.6.5.R_SCE_AES256_WrappedKeyGenerate ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256_WrappedKeyGenerate ( sce_aes_wrapped_key_t \*\ wrapped_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API outputs 256-bit AES wrapped key from a random number. | -| ||br| This API generates a wrapped key from a random number in the SCE. | -| ||br| Accordingly, user key input is unnecessary. | -| ||br| By encrypting data using the wrapped key is output by this API, | -| ||br| dead copying of data can be prevented. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_key |256-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | +|fsp_err_t R_SCE_AES256_WrappedKeyGenerate ( sce_aes_wrapped_key_t \*\ wrapped_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API outputs 256-bit AES wrapped key from a random number. | +| ||br| This API generates a wrapped key from a random number in the SCE. | +| ||br| Accordingly, user key input is unnecessary. | +| ||br| By encrypting data using the wrapped key is output by this API, | +| ||br| dead copying of data can be prevented. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_key |256-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +--------------+------------------------------------+--------------------------------------------+ -| Note | | +| Note | | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1365,33 +1365,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t | -|R_SCE_RSA1024_WrappedKeyPairGenerate ( sce_rsa1024_wrapped_pair_key_t \*\wrapped_pair_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API outputs a wrapped key pair | -| ||br| for a 1024-bit RSA public key and private key pair.These keys are generated | -| ||br| from a random value produced internally by the SCE. | -| ||br| Consequently, there is no need to input a user key. | -| ||br| Dead copying of data can be prevented by encrypting the data using the | -| ||br| wrapped key output by this API. A public wrapped key is generated by | -| ||br| wrapped_pair_key->pub_key, and a private wrapped key is generated by | -| ||br| wrapped_pair_key->priv_key. | -| ||br| As the public key exponent, only 0x00010001 is generated. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_pair_key |User key index for RSA 1024-bit public key | -| | | ||br| and private key pair | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| Key generation failed. | +|fsp_err_t | +|R_SCE_RSA1024_WrappedKeyPairGenerate ( sce_rsa1024_wrapped_pair_key_t \*\wrapped_pair_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API outputs a wrapped key pair | +| ||br| for a 1024-bit RSA public key and private key pair.These keys are generated | +| ||br| from a random value produced internally by the SCE. | +| ||br| Consequently, there is no need to input a user key. | +| ||br| Dead copying of data can be prevented by encrypting the data using the | +| ||br| wrapped key output by this API. A public wrapped key is generated by | +| ||br| wrapped_pair_key->pub_key, and a private wrapped key is generated by | +| ||br| wrapped_pair_key->priv_key. | +| ||br| As the public key exponent, only 0x00010001 is generated. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_pair_key |User key index for RSA 1024-bit public key | +| | | ||br| and private key pair | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| Key generation failed. | +--------------+------------------------------------+--------------------------------------------+ -| Note | | +| Note | | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1399,33 +1399,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t | -|R_SCE_RSA2048_WrappedKeyPairGenerate ( sce_rsa2048_wrapped_pair_key_t \*\wrapped_pair_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API outputs a wrapped key pair | -| ||br| for a 2048-bit RSA public key and private key pair.These keys are generated | -| ||br| from a random value produced internally by the SCE. | -| ||br| Consequently, there is no need to input a user key. | -| ||br| Dead copying of data can be prevented by encrypting the data using the | -| ||br| wrapped key output by this API. A public wrapped key is generated by | -| ||br| wrapped_pair_key->pub_key, and a private wrapped key is generated by | -| ||br| wrapped_pair_key->priv_key. | -| ||br| As the public key exponent, only 0x00010001 is generated. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_pair_key |User key index for RSA 2048-bit public key | -| | | ||br| and private key pair | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| Key generation failed. | +|fsp_err_t | +|R_SCE_RSA2048_WrappedKeyPairGenerate ( sce_rsa2048_wrapped_pair_key_t \*\wrapped_pair_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API outputs a wrapped key pair | +| ||br| for a 2048-bit RSA public key and private key pair.These keys are generated | +| ||br| from a random value produced internally by the SCE. | +| ||br| Consequently, there is no need to input a user key. | +| ||br| Dead copying of data can be prevented by encrypting the data using the | +| ||br| wrapped key output by this API. A public wrapped key is generated by | +| ||br| wrapped_pair_key->pub_key, and a private wrapped key is generated by | +| ||br| wrapped_pair_key->priv_key. | +| ||br| As the public key exponent, only 0x00010001 is generated. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_pair_key |User key index for RSA 2048-bit public key | +| | | ||br| and private key pair | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| Key generation failed. | +--------------+------------------------------------+--------------------------------------------+ -| Note | | +| Note | | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1433,33 +1433,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t | -|R_SCE_ECC_secp192r1_WrappedKeyPairGenerate ( sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This is an API for outputting a wrapped key pair for secp192r1 public key | -| ||br| and private key pair. These keys are generated from a random number value | -| ||br| internally within the SCE. There is therefore no need to input user keys. | -| ||br| Consequently, there is no need to input a user key. | -| ||br| It is possible to prevent dead copying of data by using | -| ||br| wrapped key output by this API. A public wrapped key is generated by | -| ||br| the wrapped key output by this API to encrypt the data. | -| ||br| The public key index is generated in wrapped_pair_key->pub_key, | -| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_pair_key |Wrapped pair key forsecp192r1 public key | -| | | ||br| and private key pair | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| Key generation failed. | +|fsp_err_t | +|R_SCE_ECC_secp192r1_WrappedKeyPairGenerate ( sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This is an API for outputting a wrapped key pair for secp192r1 public key | +| ||br| and private key pair. These keys are generated from a random number value | +| ||br| internally within the SCE. There is therefore no need to input user keys. | +| ||br| Consequently, there is no need to input a user key. | +| ||br| It is possible to prevent dead copying of data by using | +| ||br| wrapped key output by this API. A public wrapped key is generated by | +| ||br| the wrapped key output by this API to encrypt the data. | +| ||br| The public key index is generated in wrapped_pair_key->pub_key, | +| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_pair_key |Wrapped pair key forsecp192r1 public key | +| | | ||br| and private key pair | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| Key generation failed. | +--------------+------------------------------------+--------------------------------------------+ -| Note | | +| Note | | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1467,33 +1467,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t | -| R_SCE_ECC_secp224r1_WrappedKeyPairGenerate ( sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This is an API for outputting a wrapped key pair for secp224r1 public key | -| ||br| and private key pair. These keys are generated from a random number value | -| ||br| internally within the SCE. There is therefore no need to input user keys. | -| ||br| Consequently, there is no need to input a user key. | -| ||br| It is possible to prevent dead copying of data by using | -| ||br| wrapped key output by this API. A public wrapped key is generated by | -| ||br| the wrapped key output by this API to encrypt the data. | -| ||br| The public key index is generated in wrapped_pair_key->pub_key, | -| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_pair_key |Wrapped pair key forsecp224r1 public key | -| | | ||br| and private key pair | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| Key generation failed. | +|fsp_err_t | +| R_SCE_ECC_secp224r1_WrappedKeyPairGenerate ( sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This is an API for outputting a wrapped key pair for secp224r1 public key | +| ||br| and private key pair. These keys are generated from a random number value | +| ||br| internally within the SCE. There is therefore no need to input user keys. | +| ||br| Consequently, there is no need to input a user key. | +| ||br| It is possible to prevent dead copying of data by using | +| ||br| wrapped key output by this API. A public wrapped key is generated by | +| ||br| the wrapped key output by this API to encrypt the data. | +| ||br| The public key index is generated in wrapped_pair_key->pub_key, | +| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_pair_key |Wrapped pair key forsecp224r1 public key | +| | | ||br| and private key pair | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| Key generation failed. | +--------------+------------------------------------+--------------------------------------------+ -| Note | | +| Note | | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1501,33 +1501,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t | -|R_SCE_ECC_secp256r1_WrappedKeyPairGenerate ( sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This is an API for outputting a wrapped key pair for secp256r1 public key | -| ||br| and private key pair. These keys are generated from a random number value | -| ||br| internally within the SCE. There is therefore no need to input user keys. | -| ||br| Consequently, there is no need to input a user key. | -| ||br| It is possible to prevent dead copying of data by using | -| ||br| wrapped key output by this API. A public wrapped key is generated by | -| ||br| the wrapped key output by this API to encrypt the data. | -| ||br| The public key index is generated in wrapped_pair_key->pub_key, | -| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_pair_key |Wrapped pair key forsecp256r1 public key | -| | | ||br| and private key pair | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| Key generation failed. | +|fsp_err_t | +|R_SCE_ECC_secp256r1_WrappedKeyPairGenerate ( sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This is an API for outputting a wrapped key pair for secp256r1 public key | +| ||br| and private key pair. These keys are generated from a random number value | +| ||br| internally within the SCE. There is therefore no need to input user keys. | +| ||br| Consequently, there is no need to input a user key. | +| ||br| It is possible to prevent dead copying of data by using | +| ||br| wrapped key output by this API. A public wrapped key is generated by | +| ||br| the wrapped key output by this API to encrypt the data. | +| ||br| The public key index is generated in wrapped_pair_key->pub_key, | +| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_pair_key |Wrapped pair key forsecp256r1 public key | +| | | ||br| and private key pair | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| Key generation failed. | +--------------+------------------------------------+--------------------------------------------+ -| Note | | +| Note | | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1535,33 +1535,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t | +|fsp_err_t | |R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key)| +--------------+---------------------------------------------------------------------------------+ -| Description |This is an API for outputting a wrapped key pair for BrainpoolP512r1 public key | -| ||br| and private key pair. These keys are generated from a random number value | -| ||br| internally within the SCE. There is therefore no need to input user keys. | -| ||br| Consequently, there is no need to input a user key. | -| ||br| It is possible to prevent dead copying of data by using | -| ||br| wrapped key output by this API. A public wrapped key is generated by | -| ||br| the wrapped key output by this API to encrypt the data. | -| ||br| The public key index is generated in wrapped_pair_key->pub_key, | -| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_pair_key |Wrapped pair key for BrainpoolP512r1 | -| | | ||br| key pair | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| Key generation failed. | +| Description |This is an API for outputting a wrapped key pair for BrainpoolP512r1 public key | +| ||br| and private key pair. These keys are generated from a random number value | +| ||br| internally within the SCE. There is therefore no need to input user keys. | +| ||br| Consequently, there is no need to input a user key. | +| ||br| It is possible to prevent dead copying of data by using | +| ||br| wrapped key output by this API. A public wrapped key is generated by | +| ||br| the wrapped key output by this API to encrypt the data. | +| ||br| The public key index is generated in wrapped_pair_key->pub_key, | +| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |wrapped_pair_key |Wrapped pair key for BrainpoolP512r1 | +| | | ||br| key pair | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| Key generation failed. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1569,20 +1569,20 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RandomNumberGenerate ( uint32_t \*\random) | +|fsp_err_t R_SCE_RandomNumberGenerate ( uint32_t \*\random) | +--------------+---------------------------------------------------------------------------------+ -| Description |This API can generate 4 words random number. | +| Description |This API can generate 4 words random number. | +--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |random |Stores 4words (16 bytes) random data. | +| Arguments |INOUT |random |Stores 4words (16 bytes) random data. | +--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1591,29 +1591,29 @@ There are no global variables that can be used by users. +------------------------------------------------------------------------------------------------+ |fsp_err_t R_SCE_AES128_EncryptedKeyWrap ( uint8_t \*\ initial_vector, uint8_t \*\ encrypted_key,| -||br| sce_key_update_key_t \*\ key_update_key, sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 128-bit AES key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encryptedand MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |128-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +||br| sce_key_update_key_t \*\ key_update_key, sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 128-bit AES key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encryptedand MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |128-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1622,29 +1622,29 @@ There are no global variables that can be used by users. +------------------------------------------------------------------------------------------------+ |fsp_err_t R_SCE_AES256_EncryptedKeyWrap ( uint8_t \*\ initial_vector, uint8_t \*\ encrypted_key,| -||br| sce_key_update_key_t \*\ key_update_key, sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 256-bit AES key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |256-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +||br| sce_key_update_key_t \*\ key_update_key, sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 256-bit AES key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |256-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1652,31 +1652,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrap ( uint8_t \*\initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_rsa1024_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 1024-bit RSA public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |1024-bit RSA public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrap ( uint8_t \*\initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_rsa1024_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 1024-bit RSA public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |1024-bit RSA public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1684,31 +1684,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_rsa1024_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 1024-bit RSA private key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |1024-bit RSA private wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_rsa1024_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 1024-bit RSA private key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |1024-bit RSA private wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1716,31 +1716,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_rsa2048_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 2048-bit RSA public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |2048-bit RSA public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_rsa2048_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 2048-bit RSA public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |2048-bit RSA public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1748,31 +1748,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_rsa2048_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 2048-bit RSA private key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |2048-bit RSA private wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_rsa2048_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 2048-bit RSA private key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |2048-bit RSA private wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1780,31 +1780,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_rsa4096_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 4096-bit RSA public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |4096-bit RSA public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_rsa4096_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps 4096-bit RSA public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |4096-bit RSA public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1812,31 +1812,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps secp192r1 public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |secp192r1 public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps secp192r1 public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |secp192r1 public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1844,31 +1844,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps secp224r1 public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |secp224r1 public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps secp224r1 public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |secp224r1 public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1876,31 +1876,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps secp256r1 public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |secp256r1 public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processingroutine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps secp256r1 public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |secp256r1 public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processingroutine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1908,31 +1908,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps BrainpoolP512r1 public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |BrainpoolP512r1 public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps BrainpoolP512r1 public key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |BrainpoolP512r1 public wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1940,31 +1940,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps secp192r1 private key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |secp192r1 private wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps secp192r1 private key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |secp192r1 private wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -1972,31 +1972,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps secp224r1 private key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |secp224r1 private wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps secp224r1 private key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |secp224r1 private wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2004,31 +2004,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps secp256r1 private key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |secp256r1 private wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processingroutine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps secp256r1 private key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |secp256r1 private wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processingroutine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ---------------------------------------------------------- @@ -2036,31 +2036,31 @@ There are no global variables that can be used by users. ---------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps BrainpoolP512r1 private key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |BrainpoolP512r1 private wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | +||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | +||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |This API wraps BrainpoolP512r1 private key within the user routine. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |initial_vector |Initialization vector when | +| | | ||br| generating encrypted_key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |encrypted_key |User key encrypted and MAC appended | +| +---------+--------------------------+--------------------------------------------+ +| |IN |key_update_key |Key update keyring | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |wrapped_key |BrainpoolP512r1 private wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ---------------------------------------------------------- @@ -2068,19 +2068,19 @@ There are no global variables that can be used by users. ---------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SelfCheck2Private (void) | +|fsp_err_t R_SCE_SelfCheck2Private (void) | +--------------+---------------------------------------------------------------------------------+ -| Description |Self check No2. | +| Description |Self check No2. | +--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |none |none |none | +| Arguments |none |none |none | +--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RETRY |self-test2 fail | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|resource conflict | +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RETRY |self-test2 fail | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|resource conflict | +--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | +| Note |For information on how to create and update keys, refer to Security Manual | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2088,31 +2088,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128ECB_EncryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128ECB_EncryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128ECB_EncryptUpdate() function and | -| ||br| R_SCE_AES128ECB_EncryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_SUCCESS |Normal termination | +|fsp_err_t R_SCE_AES128ECB_EncryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128ECB_EncryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128ECB_EncryptUpdate() function and | +| ||br| R_SCE_AES128ECB_EncryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_SUCCESS |Normal termination | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2120,33 +2120,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128ECB_EncryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128ECB_EncryptUpdate function encrypts the second argument, plain, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, cipher. After plaintext input is completed, | -| ||br| call R_SCE_AES128ECB_EncryptFinal(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES128ECB_EncryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128ECB_EncryptUpdate function encrypts the second argument, plain, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, cipher. After plaintext input is completed, | +| ||br| call R_SCE_AES128ECB_EncryptFinal(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2154,38 +2154,38 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128ECB_EncryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES128ECB_EncryptFinal() function writes the calculation result | -| ||br| to the second argument, cipher, and writes the length of the | -| ||br| calculation result to the third argument, cipher_length. | -| ||br| The original intent was for a portion of the encryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to cipher, | -| ||br| and 0 is always written to cipher_length. The arguments cipher | -| ||br| and cipher_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES128ECB_EncryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES128ECB_EncryptFinal() function writes the calculation result | +| ||br| to the second argument, cipher, and writes the length of the | +| ||br| calculation result to the third argument, cipher_length. | +| ||br| The original intent was for a portion of the encryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to cipher, | +| ||br| and 0 is always written to cipher_length. The arguments cipher | +| ||br| and cipher_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2193,31 +2193,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128ECB_DecryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128ECB_DecryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128ECB_DecryptUpdate() function and | -| ||br| R_SCE_AES128ECB_DecryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_SUCCESS |Normal termination | +|fsp_err_t R_SCE_AES128ECB_DecryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128ECB_DecryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128ECB_DecryptUpdate() function and | +| ||br| R_SCE_AES128ECB_DecryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_SUCCESS |Normal termination | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2225,33 +2225,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128ECB_DecryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | +|fsp_err_t R_SCE_AES128ECB_DecryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | +--------------+---------------------------------------------------------------------------------+ | Description |The R_SCE_AES128ECB_DecryptUpdate function encrypts the second argument, cipher, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, plain. After ciphertext input is completed, | -| ||br| call R_SCE_AES128ECB_DecryptFinal. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, plain. After ciphertext input is completed, | +| ||br| call R_SCE_AES128ECB_DecryptFinal. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2259,38 +2259,38 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128ECB_DecryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES128ECB_DecryptFinal() function writes the calculation result | -| ||br| to the second argument, plain, and writes the length of the | -| ||br| calculation result to the third argument, plain_length. | -| ||br| The original intent was for a portion of the Decryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to plain, | -| ||br| and 0 is always written to plain_length. The arguments plain | -| ||br| and plain_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES128ECB_DecryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES128ECB_DecryptFinal() function writes the calculation result | +| ||br| to the second argument, plain, and writes the length of the | +| ||br| calculation result to the third argument, plain_length. | +| ||br| The original intent was for a portion of the Decryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to plain, | +| ||br| and 0 is always written to plain_length. The arguments plain | +| ||br| and plain_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2298,31 +2298,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256ECB_EncryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256ECB_EncryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256ECB_EncryptUpdate() function and | -| ||br| R_SCE_AES256ECB_EncryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES256ECB_EncryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256ECB_EncryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256ECB_EncryptUpdate() function and | +| ||br| R_SCE_AES256ECB_EncryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2330,33 +2330,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256ECB_EncryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256ECB_EncryptUpdate function encrypts the second argument, plain, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, cipher. After plaintext input is completed, | -| ||br| call R_SCE_AES256ECB_EncryptFinal(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES256ECB_EncryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256ECB_EncryptUpdate function encrypts the second argument, plain, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, cipher. After plaintext input is completed, | +| ||br| call R_SCE_AES256ECB_EncryptFinal(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2364,38 +2364,38 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256ECB_EncryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES256ECB_EncryptFinal() function writes the calculation result | -| ||br| to the second argument, cipher, and writes the length of the | -| ||br| calculation result to the third argument, cipher_length. | -| ||br| The original intent was for a portion of the encryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to cipher, | -| ||br| and 0 is always written to cipher_length. The arguments cipher | -| ||br| and cipher_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES256ECB_EncryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES256ECB_EncryptFinal() function writes the calculation result | +| ||br| to the second argument, cipher, and writes the length of the | +| ||br| calculation result to the third argument, cipher_length. | +| ||br| The original intent was for a portion of the encryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to cipher, | +| ||br| and 0 is always written to cipher_length. The arguments cipher | +| ||br| and cipher_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2403,31 +2403,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256ECB_DecryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256ECB_DecryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256ECB_DecryptUpdate() function and | -| ||br| R_SCE_AES256ECB_DecryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES256ECB_DecryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256ECB_DecryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256ECB_DecryptUpdate() function and | +| ||br| R_SCE_AES256ECB_DecryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2435,33 +2435,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256ECB_DecryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | +|fsp_err_t R_SCE_AES256ECB_DecryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | +--------------+---------------------------------------------------------------------------------+ | Description |The R_SCE_AES256ECB_DecryptUpdate function encrypts the second argument, cipher, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, plain. After ciphertext input is completed, | -| ||br| call R_SCE_AES256ECB_DecryptFinal. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, plain. After ciphertext input is completed, | +| ||br| call R_SCE_AES256ECB_DecryptFinal. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2469,38 +2469,38 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256ECB_DecryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES256ECB_DecryptFinal() function writes the calculation result | -| ||br| to the second argument, plain, and writes the length of the | -| ||br| calculation result to the third argument, plain_length. | -| ||br| The original intent was for a portion of the Decryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to plain, | -| ||br| and 0 is always written to plain_length. The arguments plain | -| ||br| and plain_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES256ECB_DecryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES256ECB_DecryptFinal() function writes the calculation result | +| ||br| to the second argument, plain, and writes the length of the | +| ||br| calculation result to the third argument, plain_length. | +| ||br| The original intent was for a portion of the Decryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to plain, | +| ||br| and 0 is always written to plain_length. The arguments plain | +| ||br| and plain_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ @@ -2509,33 +2509,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CBC_EncryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CBC_EncryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128CBC_EncryptUpdate() function and | -| ||br| R_SCE_AES128CBC_EncryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES128CBC_EncryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CBC_EncryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128CBC_EncryptUpdate() function and | +| ||br| R_SCE_AES128CBC_EncryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2543,33 +2543,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CBC_EncryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CBC_EncryptUpdate function encrypts the second argument, plain, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, cipher. After plaintext input is completed, | -| ||br| call R_SCE_AES128CBC_EncryptFinal(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES128CBC_EncryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CBC_EncryptUpdate function encrypts the second argument, plain, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, cipher. After plaintext input is completed, | +| ||br| call R_SCE_AES128CBC_EncryptFinal(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2577,38 +2577,38 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CBC_EncryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES128CBC_EncryptFinal() function writes the calculation result | -| ||br| to the second argument, cipher, and writes the length of the | -| ||br| calculation result to the third argument, cipher_length. | -| ||br| The original intent was for a portion of the encryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to cipher, | -| ||br| and 0 is always written to cipher_length. The arguments cipher | -| ||br| and cipher_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES128CBC_EncryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES128CBC_EncryptFinal() function writes the calculation result | +| ||br| to the second argument, cipher, and writes the length of the | +| ||br| calculation result to the third argument, cipher_length. | +| ||br| The original intent was for a portion of the encryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to cipher, | +| ||br| and 0 is always written to cipher_length. The arguments cipher | +| ||br| and cipher_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2616,33 +2616,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CBC_DecryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CBC_DecryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128CBC_DecryptUpdate() function and | -| ||br| R_SCE_AES128CBC_DecryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES128CBC_DecryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CBC_DecryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128CBC_DecryptUpdate() function and | +| ||br| R_SCE_AES128CBC_DecryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2650,33 +2650,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CBC_DecryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | +|fsp_err_t R_SCE_AES128CBC_DecryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | +--------------+---------------------------------------------------------------------------------+ | Description |The R_SCE_AES128CBC_DecryptUpdate function encrypts the second argument, cipher, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, plain. After ciphertext input is completed, | -| ||br| call R_SCE_AES128CBC_DecryptFinal. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, plain. After ciphertext input is completed, | +| ||br| call R_SCE_AES128CBC_DecryptFinal. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2684,38 +2684,38 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CBC_DecryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES128CBC_DecryptFinal() function writes the calculation result | -| ||br| to the second argument, plain, and writes the length of the | -| ||br| calculation result to the third argument, plain_length. | -| ||br| The original intent was for a portion of the Decryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to plain, | -| ||br| and 0 is always written to plain_length. The arguments plain | -| ||br| and plain_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES128CBC_DecryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES128CBC_DecryptFinal() function writes the calculation result | +| ||br| to the second argument, plain, and writes the length of the | +| ||br| calculation result to the third argument, plain_length. | +| ||br| The original intent was for a portion of the Decryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to plain, | +| ||br| and 0 is always written to plain_length. The arguments plain | +| ||br| and plain_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2723,33 +2723,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CBC_EncryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CBC_EncryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256CBC_EncryptUpdate() function and | -| ||br| R_SCE_AES256CBC_EncryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES256CBC_EncryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CBC_EncryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256CBC_EncryptUpdate() function and | +| ||br| R_SCE_AES256CBC_EncryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2757,33 +2757,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CBC_EncryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CBC_EncryptUpdate function encrypts the second argument, plain, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, cipher. After plaintext input is completed, | -| ||br| call R_SCE_AES256CBC_EncryptFinal(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES256CBC_EncryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CBC_EncryptUpdate function encrypts the second argument, plain, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, cipher. After plaintext input is completed, | +| ||br| call R_SCE_AES256CBC_EncryptFinal(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2791,38 +2791,38 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CBC_EncryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES256CBC_EncryptFinal() function writes the calculation result | -| ||br| to the second argument, cipher, and writes the length of the | -| ||br| calculation result to the third argument, cipher_length. | -| ||br| The original intent was for a portion of the encryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to cipher, | -| ||br| and 0 is always written to cipher_length. The arguments cipher | -| ||br| and cipher_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES256CBC_EncryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES256CBC_EncryptFinal() function writes the calculation result | +| ||br| to the second argument, cipher, and writes the length of the | +| ||br| calculation result to the third argument, cipher_length. | +| ||br| The original intent was for a portion of the encryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to cipher, | +| ||br| and 0 is always written to cipher_length. The arguments cipher | +| ||br| and cipher_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2830,33 +2830,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CBC_DecryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CBC_DecryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256CBC_DecryptUpdate() function and | -| ||br| R_SCE_AES256CBC_DecryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES256CBC_DecryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CBC_DecryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256CBC_DecryptUpdate() function and | +| ||br| R_SCE_AES256CBC_DecryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2864,33 +2864,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CBC_DecryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | +|fsp_err_t R_SCE_AES256CBC_DecryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | +--------------+---------------------------------------------------------------------------------+ | Description |The R_SCE_AES256CBC_DecryptUpdate function encrypts the second argument, cipher, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, plain. After ciphertext input is completed, | -| ||br| call R_SCE_AES256CBC_DecryptFinal. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, plain. After ciphertext input is completed, | +| ||br| call R_SCE_AES256CBC_DecryptFinal. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2898,38 +2898,38 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CBC_DecryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES256CBC_DecryptFinal() function writes the calculation result | -| ||br| to the second argument, plain, and writes the length of the | -| ||br| calculation result to the third argument, plain_length. | -| ||br| The original intent was for a portion of the Decryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to plain, | -| ||br| and 0 is always written to plain_length. The arguments plain | -| ||br| and plain_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES256CBC_DecryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES256CBC_DecryptFinal() function writes the calculation result | +| ||br| to the second argument, plain, and writes the length of the | +| ||br| calculation result to the third argument, plain_length. | +| ||br| The original intent was for a portion of the Decryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to plain, | +| ||br| and 0 is always written to plain_length. The arguments plain | +| ||br| and plain_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2937,33 +2937,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CTR_EncryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CTR_EncryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128CTR_EncryptUpdate() function and | -| ||br| R_SCE_AES128CTR_EncryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES128CTR_EncryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CTR_EncryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128CTR_EncryptUpdate() function and | +| ||br| R_SCE_AES128CTR_EncryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -2971,33 +2971,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CTR_EncryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CTR_EncryptUpdate function encrypts the second argument, plain, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, cipher. After plaintext input is completed, | -| ||br| call R_SCE_AES128CTR_EncryptFinal(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES128CTR_EncryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CTR_EncryptUpdate function encrypts the second argument, plain, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, cipher. After plaintext input is completed, | +| ||br| call R_SCE_AES128CTR_EncryptFinal(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3005,38 +3005,38 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CTR_EncryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES128CTR_EncryptFinal() function writes the calculation result | -| ||br| to the second argument, cipher, and writes the length of the | -| ||br| calculation result to the third argument, cipher_length. | -| ||br| The original intent was for a portion of the encryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to cipher, | -| ||br| and 0 is always written to cipher_length. The arguments cipher | -| ||br| and cipher_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES128CTR_EncryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES128CTR_EncryptFinal() function writes the calculation result | +| ||br| to the second argument, cipher, and writes the length of the | +| ||br| calculation result to the third argument, cipher_length. | +| ||br| The original intent was for a portion of the encryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to cipher, | +| ||br| and 0 is always written to cipher_length. The arguments cipher | +| ||br| and cipher_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3044,33 +3044,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CTR_DecryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CTR_DecryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128CTR_DecryptUpdate() function and | -| ||br| R_SCE_AES128CTR_DecryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES128CTR_DecryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CTR_DecryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128CTR_DecryptUpdate() function and | +| ||br| R_SCE_AES128CTR_DecryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3078,33 +3078,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CTR_DecryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | +|fsp_err_t R_SCE_AES128CTR_DecryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | +--------------+---------------------------------------------------------------------------------+ | Description |The R_SCE_AES128CTR_DecryptUpdate function encrypts the second argument, cipher, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, plain. After ciphertext input is completed, | -| ||br| call R_SCE_AES128CTR_DecryptFinal. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, plain. After ciphertext input is completed, | +| ||br| call R_SCE_AES128CTR_DecryptFinal. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3112,38 +3112,38 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CTR_DecryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES128CTR_DecryptFinal() function writes the calculation result | -| ||br| to the second argument, plain, and writes the length of the | -| ||br| calculation result to the third argument, plain_length. | -| ||br| The original intent was for a portion of the Decryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to plain, | -| ||br| and 0 is always written to plain_length. The arguments plain | -| ||br| and plain_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES128CTR_DecryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES128CTR_DecryptFinal() function writes the calculation result | +| ||br| to the second argument, plain, and writes the length of the | +| ||br| calculation result to the third argument, plain_length. | +| ||br| The original intent was for a portion of the Decryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to plain, | +| ||br| and 0 is always written to plain_length. The arguments plain | +| ||br| and plain_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3151,33 +3151,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CTR_EncryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CTR_EncryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256CTR_EncryptUpdate() function and | -| ||br| R_SCE_AES256CTR_EncryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES256CTR_EncryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CTR_EncryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256CTR_EncryptUpdate() function and | +| ||br| R_SCE_AES256CTR_EncryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3185,33 +3185,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CTR_EncryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CTR_EncryptUpdate function encrypts the second argument, plain, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, cipher. After plaintext input is completed, | -| ||br| call R_SCE_AES256CTR_EncryptFinal(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES256CTR_EncryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CTR_EncryptUpdate function encrypts the second argument, plain, | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, cipher. After plaintext input is completed, | +| ||br| call R_SCE_AES256CTR_EncryptFinal(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3219,38 +3219,38 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CTR_EncryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES256CTR_EncryptFinal() function writes the calculation result | -| ||br| to the second argument, cipher, and writes the length of the | -| ||br| calculation result to the third argument, cipher_length. | -| ||br| The original intent was for a portion of the encryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to cipher, | -| ||br| and 0 is always written to cipher_length. The arguments cipher | -| ||br| and cipher_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES256CTR_EncryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES256CTR_EncryptFinal() function writes the calculation result | +| ||br| to the second argument, cipher, and writes the length of the | +| ||br| calculation result to the third argument, cipher_length. | +| ||br| The original intent was for a portion of the encryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to cipher, | +| ||br| and 0 is always written to cipher_length. The arguments cipher | +| ||br| and cipher_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3258,33 +3258,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CTR_DecryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CTR_DecryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256CTR_DecryptUpdate() function and | -| ||br| R_SCE_AES256CTR_DecryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES256CTR_DecryptInit ( sce_aes_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CTR_DecryptInit() function performs preparations for the | +| ||br| execution of an AES calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256CTR_DecryptUpdate() function and | +| ||br| R_SCE_AES256CTR_DecryptFinal() function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | +| +---------+--------------------------+--------------------------------------------+ +| |IN |initial_vector |initialization vector area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3292,33 +3292,33 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CTR_DecryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | +|fsp_err_t R_SCE_AES256CTR_DecryptUpdate ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | +--------------+---------------------------------------------------------------------------------+ | Description |The R_SCE_AES256CTR_DecryptUpdate function encrypts the second argument, cipher, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, plain. After ciphertext input is completed, | -| ||br| call R_SCE_AES256CTR_DecryptFinal. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +| ||br| utilizing the key index stored in the handle specified | +| ||br| in the first argument, handle,and writes the ongoing status | +| ||br| to this first argument. In addition, it writes the encryption result | +| ||br| to the third argument, plain. After ciphertext input is completed, | +| ||br| call R_SCE_AES256CTR_DecryptFinal. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |cipher |ciphertext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher_length |ciphertext data length | +| | | ||br| (must be a multiple of 16) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +| Note |Specify areas for plain and cipher that do not overlap. | +| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3326,38 +3326,38 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CTR_DecryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES256CTR_DecryptFinal() function writes the calculation result | -| ||br| to the second argument, plain, and writes the length of the | -| ||br| calculation result to the third argument, plain_length. | -| ||br| The original intent was for a portion of the Decryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to plain, | -| ||br| and 0 is always written to plain_length. The arguments plain | -| ||br| and plain_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES256CTR_DecryptFinal ( sce_aes_handle_t \*\ handle, | +||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |Using the handle specified in the first argument, handle, | +| ||br| the R_SCE_AES256CTR_DecryptFinal() function writes the calculation result | +| ||br| to the second argument, plain, and writes the length of the | +| ||br| calculation result to the third argument, plain_length. | +| ||br| The original intent was for a portion of the Decryption result | +| ||br| that was not a multiple of 16 bytes to be written to the second argument. | +| ||br| However, as a result of the restriction that only multiples of 16 | +| ||br| can be input to the Update function, nothing is ever written to plain, | +| ||br| and 0 is always written to plain_length. The arguments plain | +| ||br| and plain_length are provided for compatibility in anticipation of | +| ||br| the time when this restriction is lifted. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext data area | +| | | ||br| (nothing ever written here) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain_length |plaintext data length | +| | | ||br| (0 always written here) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3365,31 +3365,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CMAC_GenerateInit ( sce_cmac_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CMAC_GenerateInit function performs preparations for the | -| ||br| execution of an CMAC calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128CMAC_GenerateUpdate function and | -| ||br| R_SCE_AES128CMAC_GenerateFinal function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES128CMAC_GenerateInit ( sce_cmac_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CMAC_GenerateInit function performs preparations for the | +| ||br| execution of an CMAC calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128CMAC_GenerateUpdate function and | +| ||br| R_SCE_AES128CMAC_GenerateFinal function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3397,35 +3397,35 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CMAC_GenerateUpdate ( sce_cmac_handle_t \*\ handle, | -||br| uint8_t \*\ message, uint32_t message_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CMAC_GenerateUpdate() function performs MAC value generation | -| ||br| based on the message specified in the second argument, message, | -| ||br| using the value specified for wrapped_key in R_SCE_AES128CMAC_GenerateInit. | -| ||br| Inside this function, the data that is input by the user is buffered | -| ||br| until the input value of message exceeds 16 bytes. | -| ||br| The length of the message data to input is specified in the third argument, | -| ||br| message_len. For these, input not the total byte count | -| ||br| for message input data, but rather the message data length to input | -| ||br| when the user calls this function. If the input value, message, | -| ||br| is not a multiple of 16 bytes, it will be padded within the function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message |plaintext data area | -| | | ||br| (message_length byte) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_length |message data length | -| | | ||br| (0 or more bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES128CMAC_GenerateUpdate ( sce_cmac_handle_t \*\ handle, | +||br| uint8_t \*\ message, uint32_t message_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CMAC_GenerateUpdate() function performs MAC value generation | +| ||br| based on the message specified in the second argument, message, | +| ||br| using the value specified for wrapped_key in R_SCE_AES128CMAC_GenerateInit. | +| ||br| Inside this function, the data that is input by the user is buffered | +| ||br| until the input value of message exceeds 16 bytes. | +| ||br| The length of the message data to input is specified in the third argument, | +| ||br| message_len. For these, input not the total byte count | +| ||br| for message input data, but rather the message data length to input | +| ||br| when the user calls this function. If the input value, message, | +| ||br| is not a multiple of 16 bytes, it will be padded within the function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message |plaintext data area | +| | | ||br| (message_length byte) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_length |message data length | +| | | ||br| (0 or more bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For message, specify a RAM address that are multiples of 4. | +| Note |For message, specify a RAM address that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3433,26 +3433,26 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CMAC_GenerateFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CMAC_GenerateFinal() function outputs the MAC value in | -| ||br| the MAC data area specified in the second argument, mac, and ends CMAC mode.| -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |mac |MAC data area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Not used. | +|fsp_err_t R_SCE_AES128CMAC_GenerateFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CMAC_GenerateFinal() function outputs the MAC value in | +| ||br| the MAC data area specified in the second argument, mac, and ends CMAC mode.| ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |mac |MAC data area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Not used. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3460,31 +3460,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CMAC_VerifyInit ( sce_cmac_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CMAC_VerifyInit function performs preparations for the | -| ||br| execution of an CMAC calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128CMAC_VerifyUpdate function and | -| ||br| R_SCE_AES128CMAC_VerifyFinal function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES128CMAC_VerifyInit ( sce_cmac_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CMAC_VerifyInit function performs preparations for the | +| ||br| execution of an CMAC calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES128CMAC_VerifyUpdate function and | +| ||br| R_SCE_AES128CMAC_VerifyFinal function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |128-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3492,35 +3492,35 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CMAC_VerifyUpdate ( sce_cmac_handle_t \*\ handle, | -||br| uint8_t \*\ message, uint32_t message_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CMAC_VerifyUpdate function performs MAC value generation | -| ||br| based on the message specified in the second argument, message, | -| ||br| using the value specified for wrapped_key in R_SCE_AES128CMAC_VerifyInit. | -| ||br| Inside this function, the data that is input by the user is buffered | -| ||br| until the input value of message exceeds 16 bytes. | -| ||br| The length of the message data to input is specified in the third argument, | -| ||br| message_len. For these, input not the total byte count | -| ||br| for message input data, but rather the message data length to input | -| ||br| when the user calls this function. If the input value, message, | -| ||br| is not a multiple of 16 bytes, it will be padded within the function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message |plaintext data area | -| | | ||br| (message_length byte) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_length |message data length | -| | | ||br| (0 or more bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES128CMAC_VerifyUpdate ( sce_cmac_handle_t \*\ handle, | +||br| uint8_t \*\ message, uint32_t message_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CMAC_VerifyUpdate function performs MAC value generation | +| ||br| based on the message specified in the second argument, message, | +| ||br| using the value specified for wrapped_key in R_SCE_AES128CMAC_VerifyInit. | +| ||br| Inside this function, the data that is input by the user is buffered | +| ||br| until the input value of message exceeds 16 bytes. | +| ||br| The length of the message data to input is specified in the third argument, | +| ||br| message_len. For these, input not the total byte count | +| ||br| for message input data, but rather the message data length to input | +| ||br| when the user calls this function. If the input value, message, | +| ||br| is not a multiple of 16 bytes, it will be padded within the function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message |plaintext data area | +| | | ||br| (message_length byte) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_length |message data length | +| | | ||br| (0 or more bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For message, specify a RAM address that are multiples of 4. | +| Note |For message, specify a RAM address that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3528,32 +3528,32 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CMAC_VerifyFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac, | -||br| uint32_t mac_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CMAC_VerifyFinal() function inputs the MAC value in the MAC | -| ||br| data area specified in the second argument, mac, and verifies the MAC value.| -| ||br| If authentication fails, the return value will be TSIP_ERR_AUTHENTICATION. | -| ||br| If the MAC value is less than 16 bytes, | -| ||br| it will be padded with zeros inside the function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |mac |MAC data area (mac_length byte) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |mac_length |MAC data length (2 to 16 bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES128CMAC_VerifyFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac, | +||br| uint32_t mac_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES128CMAC_VerifyFinal() function inputs the MAC value in the MAC | +| ||br| data area specified in the second argument, mac, and verifies the MAC value.| +| ||br| If authentication fails, the return value will be TSIP_ERR_AUTHENTICATION. | +| ||br| If the MAC value is less than 16 bytes, | +| ||br| it will be padded with zeros inside the function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |mac |MAC data area (mac_length byte) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |mac_length |MAC data length (2 to 16 bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3561,31 +3561,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CMAC_GenerateInit ( sce_cmac_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CMAC_GenerateInit function performs preparations for the | -| ||br| execution of an CMAC calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256CMAC_GenerateUpdate function and | -| ||br| R_SCE_AES256CMAC_GenerateFinal function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES256CMAC_GenerateInit ( sce_cmac_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CMAC_GenerateInit function performs preparations for the | +| ||br| execution of an CMAC calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256CMAC_GenerateUpdate function and | +| ||br| R_SCE_AES256CMAC_GenerateFinal function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3593,35 +3593,35 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CMAC_GenerateUpdate ( sce_cmac_handle_t \*\ handle, | -||br| uint8_t \*\ message, uint32_t message_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CMAC_GenerateUpdate() function performs MAC value generation | -| ||br| based on the message specified in the second argument, message, | -| ||br| using the value specified for wrapped_key in R_SCE_AES256CMAC_GenerateInit. | -| ||br| Inside this function, the data that is input by the user is buffered | -| ||br| until the input value of message exceeds 16 bytes. | -| ||br| The length of the message data to input is specified in the third argument, | -| ||br| message_len. For these, input not the total byte count | -| ||br| for message input data, but rather the message data length to input | -| ||br| when the user calls this function. If the input value, message, | -| ||br| is not a multiple of 16 bytes, it will be padded within the function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message |plaintext data area | -| | | ||br| (message_length byte) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_length |message data length | -| | | ||br| (0 or more bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES256CMAC_GenerateUpdate ( sce_cmac_handle_t \*\ handle, | +||br| uint8_t \*\ message, uint32_t message_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CMAC_GenerateUpdate() function performs MAC value generation | +| ||br| based on the message specified in the second argument, message, | +| ||br| using the value specified for wrapped_key in R_SCE_AES256CMAC_GenerateInit. | +| ||br| Inside this function, the data that is input by the user is buffered | +| ||br| until the input value of message exceeds 16 bytes. | +| ||br| The length of the message data to input is specified in the third argument, | +| ||br| message_len. For these, input not the total byte count | +| ||br| for message input data, but rather the message data length to input | +| ||br| when the user calls this function. If the input value, message, | +| ||br| is not a multiple of 16 bytes, it will be padded within the function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message |plaintext data area | +| | | ||br| (message_length byte) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_length |message data length | +| | | ||br| (0 or more bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For message, specify a RAM address that are multiples of 4. | +| Note |For message, specify a RAM address that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3629,26 +3629,26 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CMAC_GenerateFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CMAC_GenerateFinal() function outputs the MAC value in | -| ||br| the MAC data area specified in the second argument, mac, and ends CMAC mode.| -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |mac |MAC data area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Not used. | +|fsp_err_t R_SCE_AES256CMAC_GenerateFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CMAC_GenerateFinal() function outputs the MAC value in | +| ||br| the MAC data area specified in the second argument, mac, and ends CMAC mode.| ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |mac |MAC data area (16byte) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Not used. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3656,31 +3656,31 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CMAC_VerifyInit ( sce_cmac_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CMAC_VerifyInit function performs preparations for the | -| ||br| execution of an CMAC calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256CMAC_VerifyUpdate function and | -| ||br| R_SCE_AES256CMAC_VerifyFinal function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_AES256CMAC_VerifyInit ( sce_cmac_handle_t \*\ handle, | +||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CMAC_VerifyInit function performs preparations for the | +| ||br| execution of an CMAC calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_AES256CMAC_VerifyUpdate function and | +| ||br| R_SCE_AES256CMAC_VerifyFinal function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |256-bit AES wrapped key | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3688,35 +3688,35 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CMAC_VerifyUpdate ( sce_cmac_handle_t \*\ handle, | -||br| uint8_t \*\ message, uint32_t message_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CMAC_VerifyUpdate function performs MAC value generation | -| ||br| based on the message specified in the second argument, message, | -| ||br| using the value specified for wrapped_key in R_SCE_AES256CMAC_VerifyInit. | -| ||br| Inside this function, the data that is input by the user is buffered | -| ||br| until the input value of message exceeds 16 bytes. | -| ||br| The length of the message data to input is specified in the third argument, | -| ||br| message_len. For these, input not the total byte count | -| ||br| for message input data, but rather the message data length to input | -| ||br| when the user calls this function. If the input value, message, | -| ||br| is not a multiple of 16 bytes, it will be padded within the function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message |plaintext data area | -| | | ||br| (message_length byte) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_length |message data length | -| | | ||br| (0 or more bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES256CMAC_VerifyUpdate ( sce_cmac_handle_t \*\ handle, | +||br| uint8_t \*\ message, uint32_t message_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CMAC_VerifyUpdate function performs MAC value generation | +| ||br| based on the message specified in the second argument, message, | +| ||br| using the value specified for wrapped_key in R_SCE_AES256CMAC_VerifyInit. | +| ||br| Inside this function, the data that is input by the user is buffered | +| ||br| until the input value of message exceeds 16 bytes. | +| ||br| The length of the message data to input is specified in the third argument, | +| ||br| message_len. For these, input not the total byte count | +| ||br| for message input data, but rather the message data length to input | +| ||br| when the user calls this function. If the input value, message, | +| ||br| is not a multiple of 16 bytes, it will be padded within the function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES-CMAC handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message |plaintext data area | +| | | ||br| (message_length byte) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_length |message data length | +| | | ||br| (0 or more bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |For message, specify a RAM address that are multiples of 4. | +| Note |For message, specify a RAM address that are multiples of 4. | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3724,32 +3724,32 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CMAC_VerifyFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac, | -||br| uint32_t mac_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CMAC_VerifyFinal() function inputs the MAC value in the MAC | -| ||br| data area specified in the second argument, mac, and verifies the MAC value.| -| ||br| If authentication fails, the return value will be TSIP_ERR_AUTHENTICATION. | -| ||br| If the MAC value is less than 16 bytes, | -| ||br| it will be padded with zeros inside the function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |mac |MAC data area (mac_length byte) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |mac_length |MAC data length (2 to 16 bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_AES256CMAC_VerifyFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac, | +||br| uint32_t mac_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_AES256CMAC_VerifyFinal() function inputs the MAC value in the MAC | +| ||br| data area specified in the second argument, mac, and verifies the MAC value.| +| ||br| If authentication fails, the return value will be TSIP_ERR_AUTHENTICATION. | +| ||br| If the MAC value is less than 16 bytes, | +| ||br| it will be padded with zeros inside the function. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |AES handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |mac |MAC data area (mac_length byte) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |mac_length |MAC data length (2 to 16 bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3757,19 +3757,19 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SHA256_Init ( sce_sha_md5_handle_t \*\ handle) | +|fsp_err_t R_SCE_SHA256_Init ( sce_sha_md5_handle_t \*\ handle) | +--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_SHA256_Init() function performs preparations for the execution | -| ||br| of an SHA-256 hash calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_SHA256_Update() function | -| ||br| and R_SCE_SHA256_Final() function. | +| Description |The R_SCE_SHA256_Init() function performs preparations for the execution | +| ||br| of an SHA-256 hash calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_SHA256_Update() function | +| ||br| and R_SCE_SHA256_Final() function. | +--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |SHA handler (work area) | +| Arguments |INOUT |handle |SHA handler (work area) | +--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | +| Return value |FSP_SUCCESS |Normal termination | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3777,32 +3777,32 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SHA256_Update ( sce_sha_md5_handle_t \*\ handle, | -||br| uint8_t \*\ message, uint32_t message_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_SHA256_Update() function calculates a hash value based on | -| ||br| the second argument, message, and the third argument, message_length, | -| ||br| and writes the ongoing status to the first argument, handle. | -| ||br| After message input is completed, call R_SCE_SHA256_Final(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |SHA handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message |message data area | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_length |message data length | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_SHA256_Update ( sce_sha_md5_handle_t \*\ handle, | +||br| uint8_t \*\ message, uint32_t message_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_SHA256_Update() function calculates a hash value based on | +| ||br| the second argument, message, and the third argument, message_length, | +| ||br| and writes the ongoing status to the first argument, handle. | +| ||br| After message input is completed, call R_SCE_SHA256_Final(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |SHA handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message |message data area | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_length |message data length | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3810,32 +3810,32 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SHA256_Final ( sce_sha_md5_handle_t \*\ handle, | -||br| uint8_t \*\ digest, uint32_t \*\ digest_length ) | +|fsp_err_t R_SCE_SHA256_Final ( sce_sha_md5_handle_t \*\ handle, | +||br| uint8_t \*\ digest, uint32_t \*\ digest_length ) | +--------------+---------------------------------------------------------------------------------+ | Description |Using the handle specified in the first argument, handle, the R_SCE_SHA256_Final | -| ||br| function writes the calculation result to the second argument, digest, | -| ||br| and writes the length of the calculation result | -| ||br| to the third argument, digest_length. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |SHA handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |digest |hash data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |digest_length |hash data length (32bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +| ||br| function writes the calculation result to the second argument, digest, | +| ||br| and writes the length of the calculation result | +| ||br| to the third argument, digest_length. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |SHA handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |digest |hash data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |digest_length |hash data length (32bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3843,19 +3843,19 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SHA224_Init ( sce_sha_md5_handle_t \*\ handle) | +|fsp_err_t R_SCE_SHA224_Init ( sce_sha_md5_handle_t \*\ handle) | +--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_SHA224_Init() function performs preparations for the execution | -| ||br| of an SHA-224 hash calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_SHA224_Update() function | -| ||br| and R_SCE_SHA224_Final() function. | +| Description |The R_SCE_SHA224_Init() function performs preparations for the execution | +| ||br| of an SHA-224 hash calculation, and writes the result | +| ||br| to the first argument, handle. The value of handle is used as an argument | +| ||br| in the subsequent R_SCE_SHA224_Update() function | +| ||br| and R_SCE_SHA224_Final() function. | +--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |SHA handler (work area) | +| Arguments |INOUT |handle |SHA handler (work area) | +--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | +| Return value |FSP_SUCCESS |Normal termination | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3863,32 +3863,32 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SHA224_Update ( sce_sha_md5_handle_t \*\ handle, | -||br| uint8_t \*\ message, uint32_t message_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_SHA224_Update() function calculates a hash value based on | -| ||br| the second argument, message, and the third argument, message_length, | -| ||br| and writes the ongoing status to the first argument, handle. | -| ||br| After message input is completed, call R_SCE_SHA224_Final(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |SHA handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message |message data area | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_length |message data length | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_SHA224_Update ( sce_sha_md5_handle_t \*\ handle, | +||br| uint8_t \*\ message, uint32_t message_length ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_SHA224_Update() function calculates a hash value based on | +| ||br| the second argument, message, and the third argument, message_length, | +| ||br| and writes the ongoing status to the first argument, handle. | +| ||br| After message input is completed, call R_SCE_SHA224_Final(). | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |SHA handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message |message data area | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_length |message data length | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3896,32 +3896,32 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SHA224_Final ( sce_sha_md5_handle_t \*\ handle, | -||br| uint8_t \*\ digest, uint32_t \*\ digest_length ) | +|fsp_err_t R_SCE_SHA224_Final ( sce_sha_md5_handle_t \*\ handle, | +||br| uint8_t \*\ digest, uint32_t \*\ digest_length ) | +--------------+---------------------------------------------------------------------------------+ | Description |Using the handle specified in the first argument, handle, the R_SCE_SHA224_Final | -| ||br| function writes the calculation result to the second argument, digest, | -| ||br| and writes the length of the calculation result | -| ||br| to the third argument, digest_length. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |SHA handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |digest |hash data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |digest_length |hash data length (32bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +| ||br| function writes the calculation result to the second argument, digest, | +| ||br| and writes the length of the calculation result | +| ||br| to the third argument, digest_length. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |INOUT |handle |SHA handler (work area) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |digest |hash data area | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |digest_length |hash data length (32bytes) | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3929,59 +3929,59 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate ( sce_rsa_byte_data_t \*\ message_hash, | -||br| sce_rsa_byte_data_t \*\ signature, sce_rsa1024_private_wrapped_key_t \*\ wrapped_key, | -||br| uint8_t hash_type ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSASSA_PKCS1024_SignatureGenerate function generates, in accordance | -| ||br| with RSASSA-PKCS1-V1_5, a signature from the message text or hash value | -| ||br| that is input in the first argument, message_hash, using the | -| ||br| private wrapped key input to the third argument, wrapped_key, | -| ||br| and writes the signature text to the second argument, signature. | -| ||br| When a message is specified in the first argument, message_hash->data_type, | -| ||br| a hash value is calculated for the message as specified by | -| ||br| the fourth argument, hash_type. When specifying a hash value, | -| ||br| a hash value calculated with a hash algorithm as specified by | -| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |signature |Signature text storage | -| | | ||br| destination information | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | - signature->data_length : data length | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 1024-bit RSA private wrapped key.| -| +---------+--------------------------+--------------------------------------------+ -| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate ( sce_rsa_byte_data_t \*\ message_hash, | +||br| sce_rsa_byte_data_t \*\ signature, sce_rsa1024_private_wrapped_key_t \*\ wrapped_key, | +||br| uint8_t hash_type ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSASSA_PKCS1024_SignatureGenerate function generates, in accordance | +| ||br| with RSASSA-PKCS1-V1_5, a signature from the message text or hash value | +| ||br| that is input in the first argument, message_hash, using the | +| ||br| private wrapped key input to the third argument, wrapped_key, | +| ||br| and writes the signature text to the second argument, signature. | +| ||br| When a message is specified in the first argument, message_hash->data_type, | +| ||br| a hash value is calculated for the message as specified by | +| ||br| the fourth argument, hash_type. When specifying a hash value, | +| ||br| a hash value calculated with a hash algorithm as specified by | +| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |signature |Signature text storage | +| | | ||br| destination information | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | - signature->data_length : data length | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 1024-bit RSA private wrapped key.| +| +---------+--------------------------+--------------------------------------------+ +| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -3989,61 +3989,61 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureVerify ( sce_rsa_byte_data_t \*\ signature, | -||br| sce_rsa_byte_data_t \*\ message_hash, sce_rsa1024_public_wrapped_key_t \*\ wrapped_key, | -||br| uint8_t hash_type ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSASSA_PKCS1024_SignatureVerify() function verifies, in accordance | -| ||br| with RSASSA-PKCS1-V1_5, the signature text input to the | -| ||br| the first argument signature, and the message text or hash value input | -| ||br| to the second argument, message_hash, using the public wrapped key input | -| ||br| to the third argument, wrapped_key. When a message is specified | -| ||br| in the second argument, message_hash->data_type, a hash value is calculated | -| ||br| using the public wrapped key input to the third argument, wrapped_key, | -| ||br| and as specified by the fourth argument, hash_type. When specifying | -| ||br| a hash value in the second argument, message_hash->data_type, | -| ||br| a hash value calculated with a hash algorithm as specified | -| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to verify | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | - signature->data_length : Specifies | -| | | | |br| effective data length of the array | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_hash |Message text or hash value to verify | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 1024-bit RSA private wrapped key.| -| +---------+--------------------------+--------------------------------------------+ -| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureVerify ( sce_rsa_byte_data_t \*\ signature, | +||br| sce_rsa_byte_data_t \*\ message_hash, sce_rsa1024_public_wrapped_key_t \*\ wrapped_key, | +||br| uint8_t hash_type ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSASSA_PKCS1024_SignatureVerify() function verifies, in accordance | +| ||br| with RSASSA-PKCS1-V1_5, the signature text input to the | +| ||br| the first argument signature, and the message text or hash value input | +| ||br| to the second argument, message_hash, using the public wrapped key input | +| ||br| to the third argument, wrapped_key. When a message is specified | +| ||br| in the second argument, message_hash->data_type, a hash value is calculated | +| ||br| using the public wrapped key input to the third argument, wrapped_key, | +| ||br| and as specified by the fourth argument, hash_type. When specifying | +| ||br| a hash value in the second argument, message_hash->data_type, | +| ||br| a hash value calculated with a hash algorithm as specified | +| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to verify | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | - signature->data_length : Specifies | +| | | | |br| effective data length of the array | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_hash |Message text or hash value to verify | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 1024-bit RSA private wrapped key.| +| +---------+--------------------------+--------------------------------------------+ +| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4051,59 +4051,59 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate ( sce_rsa_byte_data_t \*\ message_hash, | -||br| sce_rsa_byte_data_t \*\ signature, sce_rsa2048_private_wrapped_key_t \*\ wrapped_key, | -||br| uint8_t hash_type ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSASSA_PKCS2048_SignatureGenerate function generates, in accordance | -| ||br| with RSASSA-PKCS1-V1_5, a signature from the message text or hash value | -| ||br| that is input in the first argument, message_hash, using the | -| ||br| private wrapped key input to the third argument, wrapped_key, | -| ||br| and writes the signature text to the second argument, signature. | -| ||br| When a message is specified in the first argument, message_hash->data_type, | -| ||br| a hash value is calculated for the message as specified by | -| ||br| the fourth argument, hash_type. When specifying a hash value, | -| ||br| a hash value calculated with a hash algorithm as specified by | -| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |signature |Signature text storage | -| | | ||br| destination information | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | - signature->data_length : data length | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 2048-bit RSA private wrapped key.| -| +---------+--------------------------+--------------------------------------------+ -| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate ( sce_rsa_byte_data_t \*\ message_hash, | +||br| sce_rsa_byte_data_t \*\ signature, sce_rsa2048_private_wrapped_key_t \*\ wrapped_key, | +||br| uint8_t hash_type ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSASSA_PKCS2048_SignatureGenerate function generates, in accordance | +| ||br| with RSASSA-PKCS1-V1_5, a signature from the message text or hash value | +| ||br| that is input in the first argument, message_hash, using the | +| ||br| private wrapped key input to the third argument, wrapped_key, | +| ||br| and writes the signature text to the second argument, signature. | +| ||br| When a message is specified in the first argument, message_hash->data_type, | +| ||br| a hash value is calculated for the message as specified by | +| ||br| the fourth argument, hash_type. When specifying a hash value, | +| ||br| a hash value calculated with a hash algorithm as specified by | +| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |signature |Signature text storage | +| | | ||br| destination information | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | - signature->data_length : data length | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 2048-bit RSA private wrapped key.| +| +---------+--------------------------+--------------------------------------------+ +| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4111,61 +4111,61 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify ( sce_rsa_byte_data_t \*\ signature, | -||br| sce_rsa_byte_data_t \*\ message_hash, sce_rsa2048_public_wrapped_key_t \*\ wrapped_key, | -||br| uint8_t hash_type ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSASSA_PKCS2048_SignatureVerify() function verifies, in accordance | -| ||br| with RSASSA-PKCS1-V1_5, the signature text input to the | -| ||br| the first argument signature, and the message text or hash value input | -| ||br| to the second argument, message_hash, using the public wrapped key input | -| ||br| to the third argument, wrapped_key. When a message is specified | -| ||br| in the second argument, message_hash->data_type, a hash value is calculated | -| ||br| using the public wrapped key input to the third argument, wrapped_key, | -| ||br| and as specified by the fourth argument, hash_type. When specifying | -| ||br| a hash value in the second argument, message_hash->data_type, | -| ||br| a hash value calculated with a hash algorithm as specified | -| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to verify | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | - signature->data_length : Specifies | -| | | | |br| effective data length of the array | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_hash |Message text or hash value to verify | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 2048-bit RSA private wrapped key.| -| +---------+--------------------------+--------------------------------------------+ -| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify ( sce_rsa_byte_data_t \*\ signature, | +||br| sce_rsa_byte_data_t \*\ message_hash, sce_rsa2048_public_wrapped_key_t \*\ wrapped_key, | +||br| uint8_t hash_type ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSASSA_PKCS2048_SignatureVerify() function verifies, in accordance | +| ||br| with RSASSA-PKCS1-V1_5, the signature text input to the | +| ||br| the first argument signature, and the message text or hash value input | +| ||br| to the second argument, message_hash, using the public wrapped key input | +| ||br| to the third argument, wrapped_key. When a message is specified | +| ||br| in the second argument, message_hash->data_type, a hash value is calculated | +| ||br| using the public wrapped key input to the third argument, wrapped_key, | +| ||br| and as specified by the fourth argument, hash_type. When specifying | +| ||br| a hash value in the second argument, message_hash->data_type, | +| ||br| a hash value calculated with a hash algorithm as specified | +| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to verify | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | - signature->data_length : Specifies | +| | | | |br| effective data length of the array | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_hash |Message text or hash value to verify | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 2048-bit RSA private wrapped key.| +| +---------+--------------------------+--------------------------------------------+ +| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4173,61 +4173,61 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSASSA_PKCS4096_SignatureVerify ( sce_rsa_byte_data_t \*\ signature, | -||br| sce_rsa_byte_data_t \*\ message_hash, sce_rsa4096_public_wrapped_key_t \*\ wrapped_key, | -||br| uint8_t hash_type ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSASSA_PKCS4096_SignatureVerify() function verifies, in accordance | -| ||br| with RSASSA-PKCS1-V1_5, the signature text input to the | -| ||br| the first argument signature, and the message text or hash value input | -| ||br| to the second argument, message_hash, using the public wrapped key input | -| ||br| to the third argument, wrapped_key. When a message is specified | -| ||br| in the second argument, message_hash->data_type, a hash value is calculated | -| ||br| using the public wrapped key input to the third argument, wrapped_key, | -| ||br| and as specified by the fourth argument, hash_type. When specifying | -| ||br| a hash value in the second argument, message_hash->data_type, | -| ||br| a hash value calculated with a hash algorithm as specified | -| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to verify | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | - signature->data_length : Specifies | -| | | | |br| effective data length of the array | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_hash |Message text or hash value to verify | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 4096-bit RSA private wrapped key.| -| +---------+--------------------------+--------------------------------------------+ -| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_RSASSA_PKCS4096_SignatureVerify ( sce_rsa_byte_data_t \*\ signature, | +||br| sce_rsa_byte_data_t \*\ message_hash, sce_rsa4096_public_wrapped_key_t \*\ wrapped_key, | +||br| uint8_t hash_type ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSASSA_PKCS4096_SignatureVerify() function verifies, in accordance | +| ||br| with RSASSA-PKCS1-V1_5, the signature text input to the | +| ||br| the first argument signature, and the message text or hash value input | +| ||br| to the second argument, message_hash, using the public wrapped key input | +| ||br| to the third argument, wrapped_key. When a message is specified | +| ||br| in the second argument, message_hash->data_type, a hash value is calculated | +| ||br| using the public wrapped key input to the third argument, wrapped_key, | +| ||br| and as specified by the fourth argument, hash_type. When specifying | +| ||br| a hash value in the second argument, message_hash->data_type, | +| ||br| a hash value calculated with a hash algorithm as specified | +| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to verify | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | - signature->data_length : Specifies | +| | | | |br| effective data length of the array | +| +---------+--------------------------+--------------------------------------------+ +| |IN |message_hash |Message text or hash value to verify | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 4096-bit RSA private wrapped key.| +| +---------+--------------------------+--------------------------------------------+ +| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4235,44 +4235,44 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSAES_PKCS1024_Encrypt ( sce_rsa_byte_data_t \*\ plain, | -||br| sce_rsa_byte_data_t \*\ cipher, sce_rsa1024_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSAES_PKCS1024_Encrypt() function RSA-encrypts the plaintext | -| ||br| input to the first argument, plain, according to RSAES-PKCS1-V1_5. | -| ||br| It writes the encryption result to the second argument, cipher. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |plain |plaintext | -| | | | | -| | | | - plain->pdata : Specifies pointer to | -| | | | |br| array containing plaintext. | -| | | | - plain->data_length : Specifies valid data| -| | | | |br| length of plaintext array. | -| | | | |br| data size <= public key n size - 11 | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext | -| | | | | -| | | | - cipher->pdata : Specifies pointer to | -| | | | |br| array containing ciphertext. | -| | | | - cipher->data_length : Inputs ciphertext | -| | | | |br| buffer size. Outputs valid data | -| | | | |br| length after encryption | -| | | | |br| (public key n size). | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 1024-bit RSA public wrapped key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +|fsp_err_t R_SCE_RSAES_PKCS1024_Encrypt ( sce_rsa_byte_data_t \*\ plain, | +||br| sce_rsa_byte_data_t \*\ cipher, sce_rsa1024_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSAES_PKCS1024_Encrypt() function RSA-encrypts the plaintext | +| ||br| input to the first argument, plain, according to RSAES-PKCS1-V1_5. | +| ||br| It writes the encryption result to the second argument, cipher. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |plain |plaintext | +| | | | | +| | | | - plain->pdata : Specifies pointer to | +| | | | |br| array containing plaintext. | +| | | | - plain->data_length : Specifies valid data| +| | | | |br| length of plaintext array. | +| | | | |br| data size <= public key n size - 11 | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext | +| | | | | +| | | | - cipher->pdata : Specifies pointer to | +| | | | |br| array containing ciphertext. | +| | | | - cipher->data_length : Inputs ciphertext | +| | | | |br| buffer size. Outputs valid data | +| | | | |br| length after encryption | +| | | | |br| (public key n size). | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 1024-bit RSA public wrapped key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4280,50 +4280,50 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt ( sce_rsa_byte_data_t \*\ cipher, | -||br| sce_rsa_byte_data_t \*\ plain, sce_rsa1024_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSAES_PKCS1024_Decrypt() function RSA-decrypts the ciphertext | -| ||br| input to the first argument, cipher, according to RSAES-PKCS1-V1_5. | -| ||br| It writes the encryption result to the second argument, plain. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |cipher |ciphertext | -| | | | | -| | | | - cipher->pdata : Specifies pointer to | -| | | | |br| array containing ciphertext. | -| | | | - cipher->data_length : Inputs ciphertext | -| | | | |br| buffer size. Outputs valid data | -| | | | |br| length after encryption | -| | | | |br| (public key n size). | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext | -| | | | | -| | | | - plain->pdata : Specifies pointer to | -| | | | |br| array containing plaintext. | -| | | | - plain->data_length : Inputs plaintext | -| | | | |br| buffer size. The following size | -| | | | |br| is required. | -| | | | |br| Plaintext buffer size >= | -| | | | |br| publickey n size - 11. | -| | | | |br| Outputs valid data length after | -| | | | |br| decryption (publickey n size). | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 1024-bit RSA private wrapped key.| -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt ( sce_rsa_byte_data_t \*\ cipher, | +||br| sce_rsa_byte_data_t \*\ plain, sce_rsa1024_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSAES_PKCS1024_Decrypt() function RSA-decrypts the ciphertext | +| ||br| input to the first argument, cipher, according to RSAES-PKCS1-V1_5. | +| ||br| It writes the encryption result to the second argument, plain. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |cipher |ciphertext | +| | | | | +| | | | - cipher->pdata : Specifies pointer to | +| | | | |br| array containing ciphertext. | +| | | | - cipher->data_length : Inputs ciphertext | +| | | | |br| buffer size. Outputs valid data | +| | | | |br| length after encryption | +| | | | |br| (public key n size). | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext | +| | | | | +| | | | - plain->pdata : Specifies pointer to | +| | | | |br| array containing plaintext. | +| | | | - plain->data_length : Inputs plaintext | +| | | | |br| buffer size. The following size | +| | | | |br| is required. | +| | | | |br| Plaintext buffer size >= | +| | | | |br| publickey n size - 11. | +| | | | |br| Outputs valid data length after | +| | | | |br| decryption (publickey n size). | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 1024-bit RSA private wrapped key.| ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4331,44 +4331,44 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSAES_PKCS2048_Encrypt ( sce_rsa_byte_data_t \*\ plain, | -||br| sce_rsa_byte_data_t \*\ cipher, sce_rsa2048_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSAES_PKCS2048_Encrypt() function RSA-encrypts the plaintext | -| ||br| input to the first argument, plain, according to RSAES-PKCS1-V1_5. | -| ||br| It writes the encryption result to the second argument, cipher. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |plain |plaintext | -| | | | | -| | | | - plain->pdata : Specifies pointer to | -| | | | |br| array containing plaintext. | -| | | | - plain->data_length : Specifies valid data| -| | | | |br| length of plaintext array. | -| | | | |br| data size <= public key n size - 11 | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext | -| | | | | -| | | | - cipher->pdata : Specifies pointer to | -| | | | |br| array containing ciphertext. | -| | | | - cipher->data_length : Inputs ciphertext | -| | | | |br| buffer size. Outputs valid data | -| | | | |br| length after encryption | -| | | | |br| (public key n size). | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 2048-bit RSA public wrapped key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +|fsp_err_t R_SCE_RSAES_PKCS2048_Encrypt ( sce_rsa_byte_data_t \*\ plain, | +||br| sce_rsa_byte_data_t \*\ cipher, sce_rsa2048_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSAES_PKCS2048_Encrypt() function RSA-encrypts the plaintext | +| ||br| input to the first argument, plain, according to RSAES-PKCS1-V1_5. | +| ||br| It writes the encryption result to the second argument, cipher. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |plain |plaintext | +| | | | | +| | | | - plain->pdata : Specifies pointer to | +| | | | |br| array containing plaintext. | +| | | | - plain->data_length : Specifies valid data| +| | | | |br| length of plaintext array. | +| | | | |br| data size <= public key n size - 11 | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext | +| | | | | +| | | | - cipher->pdata : Specifies pointer to | +| | | | |br| array containing ciphertext. | +| | | | - cipher->data_length : Inputs ciphertext | +| | | | |br| buffer size. Outputs valid data | +| | | | |br| length after encryption | +| | | | |br| (public key n size). | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 2048-bit RSA public wrapped key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4376,50 +4376,50 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSAES_PKCS2048_Decrypt ( sce_rsa_byte_data_t \*\ cipher, | -||br| sce_rsa_byte_data_t \*\ plain, sce_rsa2048_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSAES_PKCS2048_Decrypt() function RSA-decrypts the ciphertext | -| ||br| input to the first argument, cipher, according to RSAES-PKCS1-V1_5. | -| ||br| It writes the encryption result to the second argument, plain. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |cipher |ciphertext | -| | | | | -| | | | - cipher->pdata : Specifies pointer to | -| | | | |br| array containing ciphertext. | -| | | | - cipher->data_length : Inputs ciphertext | -| | | | |br| buffer size. Outputs valid data | -| | | | |br| length after encryption | -| | | | |br| (public key n size). | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext | -| | | | | -| | | | - plain->pdata : Specifies pointer to | -| | | | |br| array containing plaintext. | -| | | | - plain->data_length : Inputs plaintext | -| | | | |br| buffer size. The following size | -| | | | |br| is required. | -| | | | |br| Plaintext buffer size >= | -| | | | |br| publickey n size - 11. | -| | | | |br| Outputs valid data length after | -| | | | |br| decryption (publickey n size). | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 2048-bit RSA private wrapped key.| -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +|fsp_err_t R_SCE_RSAES_PKCS2048_Decrypt ( sce_rsa_byte_data_t \*\ cipher, | +||br| sce_rsa_byte_data_t \*\ plain, sce_rsa2048_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSAES_PKCS2048_Decrypt() function RSA-decrypts the ciphertext | +| ||br| input to the first argument, cipher, according to RSAES-PKCS1-V1_5. | +| ||br| It writes the encryption result to the second argument, plain. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |cipher |ciphertext | +| | | | | +| | | | - cipher->pdata : Specifies pointer to | +| | | | |br| array containing ciphertext. | +| | | | - cipher->data_length : Inputs ciphertext | +| | | | |br| buffer size. Outputs valid data | +| | | | |br| length after encryption | +| | | | |br| (public key n size). | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |plain |plaintext | +| | | | | +| | | | - plain->pdata : Specifies pointer to | +| | | | |br| array containing plaintext. | +| | | | - plain->data_length : Inputs plaintext | +| | | | |br| buffer size. The following size | +| | | | |br| is required. | +| | | | |br| Plaintext buffer size >= | +| | | | |br| publickey n size - 11. | +| | | | |br| Outputs valid data length after | +| | | | |br| decryption (publickey n size). | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 2048-bit RSA private wrapped key.| ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4427,44 +4427,44 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt ( sce_rsa_byte_data_t \*\ plain, | -||br| sce_rsa_byte_data_t \*\ cipher, sce_rsa4096_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSAES_PKCS4096_Encrypt() function RSA-encrypts the plaintext | -| ||br| input to the first argument, plain, according to RSAES-PKCS1-V1_5. | -| ||br| It writes the encryption result to the second argument, cipher. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |plain |plaintext | -| | | | | -| | | | - plain->pdata : Specifies pointer to | -| | | | |br| array containing plaintext. | -| | | | - plain->data_length : Specifies valid data| -| | | | |br| length of plaintext array. | -| | | | |br| data size <= public key n size - 11 | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext | -| | | | | -| | | | - cipher->pdata : Specifies pointer to | -| | | | |br| array containing ciphertext. | -| | | | - cipher->data_length : Inputs ciphertext | -| | | | |br| buffer size. Outputs valid data | -| | | | |br| length after encryption | -| | | | |br| (public key n size). | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 4096-bit RSA public wrapped key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +|fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt ( sce_rsa_byte_data_t \*\ plain, | +||br| sce_rsa_byte_data_t \*\ cipher, sce_rsa4096_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |The R_SCE_RSAES_PKCS4096_Encrypt() function RSA-encrypts the plaintext | +| ||br| input to the first argument, plain, according to RSAES-PKCS1-V1_5. | +| ||br| It writes the encryption result to the second argument, cipher. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |plain |plaintext | +| | | | | +| | | | - plain->pdata : Specifies pointer to | +| | | | |br| array containing plaintext. | +| | | | - plain->data_length : Specifies valid data| +| | | | |br| length of plaintext array. | +| | | | |br| data size <= public key n size - 11 | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |cipher |ciphertext | +| | | | | +| | | | - cipher->pdata : Specifies pointer to | +| | | | |br| array containing ciphertext. | +| | | | - cipher->data_length : Inputs ciphertext | +| | | | |br| buffer size. Outputs valid data | +| | | | |br| length after encryption | +| | | | |br| (public key n size). | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Inputs the 4096-bit RSA public wrapped key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4472,64 +4472,64 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate ( sce_ecdsa_byte_data_t \*\ message_hash, | -||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a message is specified in the first argument, message_hash->data_type, | -| ||br| a SHA-256 hash of the message text input as the first argument, | -| ||br| message_hash->pdata, is calculated, and the signature text is written to | -| ||br| the second argument, signature, in accordance with secp192r1 using | -| ||br| the private wrapped key input as the third argument, wrapped_key. | -| ||br| When a hash value is specified in the first argument, | -| ||br| message_hash->data_type, the signature text for the first 24 bytes | -| ||br| of the SHA-256 hash value input to the first argument, message_hash->pdata, | -| ||br| is written to the second argument, signature, in accordance with secp192r1 | -| ||br| using the private wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |signature |Signature text storage | -| | | ||br| destination information | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "0 padding (64 bits) | -| | | | |br| || signature r (192bits) | -| | | | |br| || 0 padding (64 bits) | -| | | | |br| || signature s (192 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Input wrapped key of secp192r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate ( sce_ecdsa_byte_data_t \*\ message_hash, | +||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a message is specified in the first argument, message_hash->data_type, | +| ||br| a SHA-256 hash of the message text input as the first argument, | +| ||br| message_hash->pdata, is calculated, and the signature text is written to | +| ||br| the second argument, signature, in accordance with secp192r1 using | +| ||br| the private wrapped key input as the third argument, wrapped_key. | +| ||br| When a hash value is specified in the first argument, | +| ||br| message_hash->data_type, the signature text for the first 24 bytes | +| ||br| of the SHA-256 hash value input to the first argument, message_hash->pdata, | +| ||br| is written to the second argument, signature, in accordance with secp192r1 | +| ||br| using the private wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |signature |Signature text storage | +| | | ||br| destination information | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "0 padding (64 bits) | +| | | | |br| || signature r (192bits) | +| | | | |br| || 0 padding (64 bits) | +| | | | |br| || signature s (192 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Input wrapped key of secp192r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4537,64 +4537,64 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate ( sce_ecdsa_byte_data_t \*\ message_hash, | -||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a message is specified in the first argument, message_hash->data_type, | -| ||br| a SHA-256 hash of the message text input as the first argument, | -| ||br| message_hash->pdata, is calculated, and the signature text is written to | -| ||br| the second argument, signature, in accordance with secp224r1 using | -| ||br| the private wrapped key input as the third argument, wrapped_key. | -| ||br| When a hash value is specified in the first argument, | -| ||br| message_hash->data_type, the signature text for the first 28 bytes | -| ||br| of the SHA-256 hash value input to the first argument, message_hash->pdata, | -| ||br| is written to the second argument, signature, in accordance with secp224r1 | -| ||br| using the private wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |signature |Signature text storage | -| | | ||br| destination information | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "0 padding (32 bits) | -| | | | |br| || signature r (224bits) | -| | | | |br| || 0 padding (32 bits) | -| | | | |br| || signature s (224 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Input wrapped key of secp224r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate ( sce_ecdsa_byte_data_t \*\ message_hash, | +||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a message is specified in the first argument, message_hash->data_type, | +| ||br| a SHA-256 hash of the message text input as the first argument, | +| ||br| message_hash->pdata, is calculated, and the signature text is written to | +| ||br| the second argument, signature, in accordance with secp224r1 using | +| ||br| the private wrapped key input as the third argument, wrapped_key. | +| ||br| When a hash value is specified in the first argument, | +| ||br| message_hash->data_type, the signature text for the first 28 bytes | +| ||br| of the SHA-256 hash value input to the first argument, message_hash->pdata, | +| ||br| is written to the second argument, signature, in accordance with secp224r1 | +| ||br| using the private wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |signature |Signature text storage | +| | | ||br| destination information | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "0 padding (32 bits) | +| | | | |br| || signature r (224bits) | +| | | | |br| || 0 padding (32 bits) | +| | | | |br| || signature s (224 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Input wrapped key of secp224r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4602,62 +4602,62 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate ( sce_ecdsa_byte_data_t \*\ message_hash, | -||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a message is specified in the first argument, message_hash->data_type, | -| ||br| a SHA-256 hash of the message text input as the first argument, | -| ||br| message_hash->pdata, is calculated, and the signature text is written to | -| ||br| the second argument, signature, in accordance with secp256r1 using | -| ||br| the private wrapped key input as the third argument, wrapped_key. | -| ||br| When a hash value is specified in the first argument, | -| ||br| message_hash->data_type, the signature text for the first 32 bytes | -| ||br| of the SHA-256 hash value input to the first argument, message_hash->pdata, | -| ||br| is written to the second argument, signature, in accordance with secp256r1 | -| ||br| using the private wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |signature |Signature text storage | -| | | ||br| destination information | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "signature r (256bits) | -| | | | |br| || signature s (256 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Input wrapped key of secp256r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate ( sce_ecdsa_byte_data_t \*\ message_hash, | +||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a message is specified in the first argument, message_hash->data_type, | +| ||br| a SHA-256 hash of the message text input as the first argument, | +| ||br| message_hash->pdata, is calculated, and the signature text is written to | +| ||br| the second argument, signature, in accordance with secp256r1 using | +| ||br| the private wrapped key input as the third argument, wrapped_key. | +| ||br| When a hash value is specified in the first argument, | +| ||br| message_hash->data_type, the signature text for the first 32 bytes | +| ||br| of the SHA-256 hash value input to the first argument, message_hash->pdata, | +| ||br| is written to the second argument, signature, in accordance with secp256r1 | +| ||br| using the private wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |signature |Signature text storage | +| | | ||br| destination information | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "signature r (256bits) | +| | | | |br| || signature s (256 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Input wrapped key of secp256r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4666,56 +4666,56 @@ There are no global variables that can be used by users. +------------------------------------------------------------------------------------------------+ |fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate( sce_ecdsa_byte_data_t \*\ message_hash,| -||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a hash value is specified in the first argument, | -| ||br| message_hash->data_type, the signature text for the first 64 bytes | -| ||br| of the SHA-512 hash value input to the first argument, message_hash->pdata, | -| ||br| is written to the second argument, in accordance with BrainpoolP512r1 | -| ||br| using the private wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (only Hash value(1) is support) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |signature |Signature text storage | -| | | ||br| destination information | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "signature r (512bits) | -| | | | |br| || signature s (512 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |wrapped key of BrainpoolP512r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a hash value is specified in the first argument, | +| ||br| message_hash->data_type, the signature text for the first 64 bytes | +| ||br| of the SHA-512 hash value input to the first argument, message_hash->pdata, | +| ||br| is written to the second argument, in accordance with BrainpoolP512r1 | +| ||br| using the private wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (only Hash value(1) is support) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |signature |Signature text storage | +| | | ||br| destination information | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "signature r (512bits) | +| | | | |br| || signature s (512 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |wrapped key of BrainpoolP512r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4723,65 +4723,65 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | -||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a message is specified in the second argument, message_hash->data_type, | -| ||br| a SHA-256 hash of the message text input as the second argument, | -| ||br| message_hash->pdata, is calculated, and the signature text input to the | -| ||br| first argument, signature, is validated in accordance with secp192r1 using | -| ||br| the public wrapped key input as the third argument, wrapped_key. | -| ||br| When a hash value is specified in the second argument, | -| ||br| message_hash->data_type, the signature text for the first 24 bytes | -| ||br| of the SHA-256 hash value input to the second argument, message_hash->pdata,| -| ||br| is written to the first argument, signature, | -| ||br| is validated in accordance with secp192r1 | -| ||br| using the public wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to be verified | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "0 padding (64 bits) | -| | | | |br| || signature r (192bits) | -| | | | |br| || 0 padding (64 bits) | -| | | | |br| || signature s (192 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) (nonuse) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Input wrapped key of secp192r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| or signature verification failed. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | +||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a message is specified in the second argument, message_hash->data_type, | +| ||br| a SHA-256 hash of the message text input as the second argument, | +| ||br| message_hash->pdata, is calculated, and the signature text input to the | +| ||br| first argument, signature, is validated in accordance with secp192r1 using | +| ||br| the public wrapped key input as the third argument, wrapped_key. | +| ||br| When a hash value is specified in the second argument, | +| ||br| message_hash->data_type, the signature text for the first 24 bytes | +| ||br| of the SHA-256 hash value input to the second argument, message_hash->pdata,| +| ||br| is written to the first argument, signature, | +| ||br| is validated in accordance with secp192r1 | +| ||br| using the public wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to be verified | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "0 padding (64 bits) | +| | | | |br| || signature r (192bits) | +| | | | |br| || 0 padding (64 bits) | +| | | | |br| || signature s (192 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) (nonuse) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Input wrapped key of secp192r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| or signature verification failed. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4789,65 +4789,65 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | -||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a message is specified in the second argument, message_hash->data_type, | -| ||br| a SHA-224 hash of the message text input as the second argument, | -| ||br| message_hash->pdata, is calculated, and the signature text input to the | -| ||br| first argument, signature, is validated in accordance with secp224r1 using | -| ||br| the public wrapped key input as the third argument, wrapped_key. | -| ||br| When a hash value is specified in the second argument, | -| ||br| message_hash->data_type, the signature text for the first 28 bytes | -| ||br| of the SHA-224 hash value input to the second argument, message_hash->pdata,| -| ||br| is written to the first argument, signature, | -| ||br| is validated in accordance with secp224r1 | -| ||br| using the public wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to be verified | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "0 padding (32 bits) | -| | | | |br| || signature r (224bits) | -| | | | |br| || 0 padding (32 bits) | -| | | | |br| || signature s (224 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) (nonuse) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Input wrapped key of secp224r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| or signature verification failed. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | +||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a message is specified in the second argument, message_hash->data_type, | +| ||br| a SHA-224 hash of the message text input as the second argument, | +| ||br| message_hash->pdata, is calculated, and the signature text input to the | +| ||br| first argument, signature, is validated in accordance with secp224r1 using | +| ||br| the public wrapped key input as the third argument, wrapped_key. | +| ||br| When a hash value is specified in the second argument, | +| ||br| message_hash->data_type, the signature text for the first 28 bytes | +| ||br| of the SHA-224 hash value input to the second argument, message_hash->pdata,| +| ||br| is written to the first argument, signature, | +| ||br| is validated in accordance with secp224r1 | +| ||br| using the public wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to be verified | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "0 padding (32 bits) | +| | | | |br| || signature r (224bits) | +| | | | |br| || 0 padding (32 bits) | +| | | | |br| || signature s (224 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) (nonuse) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Input wrapped key of secp224r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| or signature verification failed. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4855,63 +4855,63 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | -||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a message is specified in the second argument, message_hash->data_type, | -| ||br| a SHA-256 hash of the message text input as the second argument, | -| ||br| message_hash->pdata, is calculated, and the signature text input to the | -| ||br| first argument, signature, is validated in accordance with secp256r1 using | -| ||br| the public wrapped key input as the third argument, wrapped_key. | -| ||br| When a hash value is specified in the second argument, | -| ||br| message_hash->data_type, the signature text for the first 32 bytes | -| ||br| of the SHA-256 hash value input to the second argument, message_hash->pdata,| -| ||br| is written to the first argument, signature, | -| ||br| is validated in accordance with secp256r1 | -| ||br| using the public wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to be verified | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "signature r (256bits) | -| | | | |br| || signature s (256 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) (nonuse) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Input wrapped key of secp256r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| or signature verification failed. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | +||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a message is specified in the second argument, message_hash->data_type, | +| ||br| a SHA-256 hash of the message text input as the second argument, | +| ||br| message_hash->pdata, is calculated, and the signature text input to the | +| ||br| first argument, signature, is validated in accordance with secp256r1 using | +| ||br| the public wrapped key input as the third argument, wrapped_key. | +| ||br| When a hash value is specified in the second argument, | +| ||br| message_hash->data_type, the signature text for the first 32 bytes | +| ||br| of the SHA-256 hash value input to the second argument, message_hash->pdata,| +| ||br| is written to the first argument, signature, | +| ||br| is validated in accordance with secp256r1 | +| ||br| using the public wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to be verified | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "signature r (256bits) | +| | | | |br| || signature s (256 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) (nonuse) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (Message: 0 Hash value: 1) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |Input wrapped key of secp256r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| or signature verification failed. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ ------------------------------------------------------- @@ -4919,62 +4919,62 @@ There are no global variables that can be used by users. ------------------------------------------------------- +------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | -||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a hash value is specified in the second argument, | -| ||br| message_hash->data_type, the signature text for the first 64 bytes | -| ||br| of the SHA-512 hash value input to the second argument, message_hash->pdata,| -| ||br| is written to the first argument, signature, | -| ||br| is validated in accordance with BrainpoolP512r1 | -| ||br| using the public wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to be verified | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "signature r (512bits) | -| | | | |br| || signature s (512 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) (nonuse) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (only Hash value(1) is support) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |wrapped key of BrainpoolP512r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| or signature verification failed. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +|fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | +||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | ++--------------+---------------------------------------------------------------------------------+ +| Description |When a hash value is specified in the second argument, | +| ||br| message_hash->data_type, the signature text for the first 64 bytes | +| ||br| of the SHA-512 hash value input to the second argument, message_hash->pdata,| +| ||br| is written to the first argument, signature, | +| ||br| is validated in accordance with BrainpoolP512r1 | +| ||br| using the public wrapped key input as the third argument, wrapped_key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Arguments |IN |signature |Signature text information to be verified | +| | | | | +| | | | - signature->pdata : Specifies pointer | +| | | | |br| to array storing the signature text | +| | | | |br| The signature format is | +| | | | |br| "signature r (512bits) | +| | | | |br| || signature s (512 bits)". | +| | | | - signature->data_length : data length | +| | | | |br| || (byte units) (nonuse) | +| +---------+--------------------------+--------------------------------------------+ +| |INOUT |message_hash |Message or hash value to | +| | | ||br| which to attach signature | +| | | | | +| | | | - message_hash->pdata : Specifies pointer | +| | | | |br| to array storing the message or | +| | | | |br| hash value | +| | | | - message_hash->data_length : Specifies | +| | | | |br| effective data length of the array | +| | | | |br| (Specify when Message is selected) | +| | | | - message_hash->data_type : Selects the | +| | | | |br| data type of message_hash | +| | | | |br| (only Hash value(1) is support) | +| +---------+--------------------------+--------------------------------------------+ +| |IN |wrapped_key |wrapped key of BrainpoolP512r1 private key. | ++--------------+---------+--------------------------+--------------------------------------------+ +| Return value |FSP_SUCCESS |Normal termination | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | +| | ||br| hardware resource needed by the | +| | ||br| processing routine was in use | +| | ||br| by another processing routine. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | +| | ||br| or signature verification failed. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | +| +------------------------------------+--------------------------------------------+ +| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | +--------------+------------------------------------+--------------------------------------------+ -| Note |none | +| Note |none | +--------------+---------------------------------------------------------------------------------+ .. |br| raw:: html - -
\ No newline at end of file + +
\ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/inc/api/r_sce_api.h b/core/arch/arm/plat-rz/common/drivers/r_sce/inc/api/r_sce_api.h index 9381c0b86..17e267782 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/inc/api/r_sce_api.h +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/inc/api/r_sce_api.h @@ -17,13 +17,13 @@ * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. *********************************************************************************************************************/ /********************************************************************************************************************** - * File Name : r_sce_api.h - * Version : 1.0 - * Description : SCE API header file + * File Name : r_sce_api.h + * Version : 1.0 + * Description : SCE API header file *********************************************************************************************************************/ /********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release *********************************************************************************************************************/ /*******************************************************************************************************************//** @@ -53,102 +53,102 @@ /********************************************************************************************************************** * Macro definitions **********************************************************************************************************************/ -#define FSP_PARAMETER_NOT_USED(p) ((void) ((p))) +#define FSP_PARAMETER_NOT_USED(p) ((void) ((p))) /* For AES operation. */ -#define HW_SCE_AES128_KEY_INDEX_WORD_SIZE (12U) -#define HW_SCE_AES256_KEY_INDEX_WORD_SIZE (16U) -#define HW_SCE_AES128_KEY_WORD_SIZE (4U) -#define HW_SCE_AES256_KEY_WORD_SIZE (8U) -#define HW_SCE_AES128_KEY_BYTE_SIZE (16U) -#define HW_SCE_AES256_KEY_BYTE_SIZE (32U) -#define HW_SCE_AES_BLOCK_BYTE_SIZE (16U) -#define HW_SCE_AES_BLOCK_BIT_SIZE (128U) -#define HW_SCE_AES_CBC_IV_BYTE_SIZE (16U) +#define HW_SCE_AES128_KEY_INDEX_WORD_SIZE (12U) +#define HW_SCE_AES256_KEY_INDEX_WORD_SIZE (16U) +#define HW_SCE_AES128_KEY_WORD_SIZE (4U) +#define HW_SCE_AES256_KEY_WORD_SIZE (8U) +#define HW_SCE_AES128_KEY_BYTE_SIZE (16U) +#define HW_SCE_AES256_KEY_BYTE_SIZE (32U) +#define HW_SCE_AES_BLOCK_BYTE_SIZE (16U) +#define HW_SCE_AES_BLOCK_BIT_SIZE (128U) +#define HW_SCE_AES_CBC_IV_BYTE_SIZE (16U) /* For SHA operation. */ -#define HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE (28U) -#define HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE (32U) -#define HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE (64U) +#define HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE (28U) +#define HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE (32U) +#define HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE (64U) /* For RSA operation. */ -#define HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE (128U) -#define HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE (4U) -#define HW_SCE_RSA_1024_KEY_D_LENGTH_BYTE_SIZE (128U) -#define HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE (256U) -#define HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE (4U) -#define HW_SCE_RSA_2048_KEY_D_LENGTH_BYTE_SIZE (256U) -#define HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE (128 * 4U) -#define HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE (4U) -#define HW_SCE_RSA_4096_KEY_D_LENGTH_BYTE_SIZE (128 * 4U) -#define HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) -#define HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE (36U) -#define HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) -#define HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE (68U) -#define HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) -#define HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE (68U) -#define HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) -#define HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE (132U) -#define HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) -#define HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE (4U) -#define HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE (12U) -#define HW_SCE_RSA1024_NE_KEY_BYTE_SIZE (144U) -#define HW_SCE_RSA1024_ND_KEY_BYTE_SIZE (256U) -#define HW_SCE_RSA2048_NE_KEY_BYTE_SIZE (272U) -#define HW_SCE_RSA2048_ND_KEY_BYTE_SIZE (512U) -#define HW_SCE_RSA4096_NE_KEY_BYTE_SIZE (128 * 4 + 16U) -#define HW_SCE_RSA4096_ND_KEY_BYTE_SIZE (256 * 4U) -#define HW_SCE_RSA1024_NE_KEY_INDEX_WORD_SIZE (76U) -#define HW_SCE_RSA1024_ND_KEY_INDEX_WORD_SIZE (104U) -#define HW_SCE_RSA2048_NE_KEY_INDEX_WORD_SIZE (140U) -#define HW_SCE_RSA2048_ND_KEY_INDEX_WORD_SIZE (200U) -#define HW_SCE_RSA4096_NE_KEY_INDEX_WORD_SIZE (140U) -#define HW_SCE_RSA4096_ND_KEY_INDEX_WORD_SIZE (261U) -#define HW_SCE_RSA1024_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE (76U) -#define HW_SCE_RSA1024_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE (104U) -#define HW_SCE_RSA2048_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE (140U) -#define HW_SCE_RSA2048_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE (200U) - -#define HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE (11U) -#define HW_SCE_RSA_1024_DATA_BYTE_SIZE (128U) -#define HW_SCE_RSA_2048_DATA_BYTE_SIZE (256U) -#define HW_SCE_RSA_4096_DATA_BYTE_SIZE (128 * 4U) +#define HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE (128U) +#define HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE (4U) +#define HW_SCE_RSA_1024_KEY_D_LENGTH_BYTE_SIZE (128U) +#define HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE (256U) +#define HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE (4U) +#define HW_SCE_RSA_2048_KEY_D_LENGTH_BYTE_SIZE (256U) +#define HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE (128 * 4U) +#define HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE (4U) +#define HW_SCE_RSA_4096_KEY_D_LENGTH_BYTE_SIZE (128 * 4U) +#define HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) +#define HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE (36U) +#define HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) +#define HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE (68U) +#define HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) +#define HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE (68U) +#define HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) +#define HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE (132U) +#define HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) +#define HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE (4U) +#define HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE (12U) +#define HW_SCE_RSA1024_NE_KEY_BYTE_SIZE (144U) +#define HW_SCE_RSA1024_ND_KEY_BYTE_SIZE (256U) +#define HW_SCE_RSA2048_NE_KEY_BYTE_SIZE (272U) +#define HW_SCE_RSA2048_ND_KEY_BYTE_SIZE (512U) +#define HW_SCE_RSA4096_NE_KEY_BYTE_SIZE (128 * 4 + 16U) +#define HW_SCE_RSA4096_ND_KEY_BYTE_SIZE (256 * 4U) +#define HW_SCE_RSA1024_NE_KEY_INDEX_WORD_SIZE (76U) +#define HW_SCE_RSA1024_ND_KEY_INDEX_WORD_SIZE (104U) +#define HW_SCE_RSA2048_NE_KEY_INDEX_WORD_SIZE (140U) +#define HW_SCE_RSA2048_ND_KEY_INDEX_WORD_SIZE (200U) +#define HW_SCE_RSA4096_NE_KEY_INDEX_WORD_SIZE (140U) +#define HW_SCE_RSA4096_ND_KEY_INDEX_WORD_SIZE (261U) +#define HW_SCE_RSA1024_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE (76U) +#define HW_SCE_RSA1024_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE (104U) +#define HW_SCE_RSA2048_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE (140U) +#define HW_SCE_RSA2048_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE (200U) + +#define HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE (11U) +#define HW_SCE_RSA_1024_DATA_BYTE_SIZE (128U) +#define HW_SCE_RSA_2048_DATA_BYTE_SIZE (256U) +#define HW_SCE_RSA_4096_DATA_BYTE_SIZE (128 * 4U) /* RSA HASH type. */ -#define HW_SCE_RSA_HASH_SHA256 (0x03) /* SHA-256 */ +#define HW_SCE_RSA_HASH_SHA256 (0x03) /* SHA-256 */ /* For ECC operation. */ -#define HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE (144U) -#define HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE (4U) -#define HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE (24U) -#define HW_SCE_ECC_PUBLIC_KEY_BYTE_SIZE (64U) -#define HW_SCE_ECC_PRIVATE_KEY_BYTE_SIZE (32U) -#define HW_SCE_ECDSA_DATA_BYTE_SIZE (64U) -#define HW_SCE_ECDSA_P512_DATA_BYTE_SIZE (128U) -#define HW_SCE_SHARED_SECRET_KEY_INDEX_WORD_SIZE (13U) +#define HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE (144U) +#define HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE (4U) +#define HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE (24U) +#define HW_SCE_ECC_PUBLIC_KEY_BYTE_SIZE (64U) +#define HW_SCE_ECC_PRIVATE_KEY_BYTE_SIZE (32U) +#define HW_SCE_ECDSA_DATA_BYTE_SIZE (64U) +#define HW_SCE_ECDSA_P512_DATA_BYTE_SIZE (128U) +#define HW_SCE_SHARED_SECRET_KEY_INDEX_WORD_SIZE (13U) /* Key update. */ -#define HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE (16U) - -#define SCE_OEM_KEY_SIZE_DUMMY_INST_DATA_WORD (0) -#define SCE_OEM_KEY_SIZE_AES128_INST_DATA_WORD (8) -#define SCE_OEM_KEY_SIZE_AES256_INST_DATA_WORD (12) - -#define SCE_OEM_KEY_SIZE_RSA1024_PUBLIC_KEY_INST_DATA_WORD (40) -#define SCE_OEM_KEY_SIZE_RSA1024_PRIVATE_KEY_INST_DATA_WORD (68) -#define SCE_OEM_KEY_SIZE_RSA2048_PUBLIC_KEY_INST_DATA_WORD (72) -#define SCE_OEM_KEY_SIZE_RSA2048_PRIVATE_KEY_INST_DATA_WORD (132) -#define SCE_OEM_KEY_SIZE_RSA4096_PUBLIC_KEY_INST_DATA_WORD (136) -#define SCE_OEM_KEY_SIZE_RSA4096_PRIVATE_KEY_INST_DATA_WORD (260) - -#define SCE_OEM_KEY_SIZE_ECCP192_PUBLIC_KEY_INST_DATA_WORD (20) -#define SCE_OEM_KEY_SIZE_ECCP192_PRIVATE_KEY_INST_DATA_WORD (12) -#define SCE_OEM_KEY_SIZE_ECCP224_PUBLIC_KEY_INST_DATA_WORD (20) -#define SCE_OEM_KEY_SIZE_ECCP224_PRIVATE_KEY_INST_DATA_WORD (12) -#define SCE_OEM_KEY_SIZE_ECCP256_PUBLIC_KEY_INST_DATA_WORD (20) -#define SCE_OEM_KEY_SIZE_ECCP256_PRIVATE_KEY_INST_DATA_WORD (12) -#define SCE_OEM_KEY_SIZE_ECCP512_PUBLIC_KEY_INST_DATA_WORD (36) -#define SCE_OEM_KEY_SIZE_ECCP512_PRIVATE_KEY_INST_DATA_WORD (20) +#define HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE (16U) + +#define SCE_OEM_KEY_SIZE_DUMMY_INST_DATA_WORD (0) +#define SCE_OEM_KEY_SIZE_AES128_INST_DATA_WORD (8) +#define SCE_OEM_KEY_SIZE_AES256_INST_DATA_WORD (12) + +#define SCE_OEM_KEY_SIZE_RSA1024_PUBLIC_KEY_INST_DATA_WORD (40) +#define SCE_OEM_KEY_SIZE_RSA1024_PRIVATE_KEY_INST_DATA_WORD (68) +#define SCE_OEM_KEY_SIZE_RSA2048_PUBLIC_KEY_INST_DATA_WORD (72) +#define SCE_OEM_KEY_SIZE_RSA2048_PRIVATE_KEY_INST_DATA_WORD (132) +#define SCE_OEM_KEY_SIZE_RSA4096_PUBLIC_KEY_INST_DATA_WORD (136) +#define SCE_OEM_KEY_SIZE_RSA4096_PRIVATE_KEY_INST_DATA_WORD (260) + +#define SCE_OEM_KEY_SIZE_ECCP192_PUBLIC_KEY_INST_DATA_WORD (20) +#define SCE_OEM_KEY_SIZE_ECCP192_PRIVATE_KEY_INST_DATA_WORD (12) +#define SCE_OEM_KEY_SIZE_ECCP224_PUBLIC_KEY_INST_DATA_WORD (20) +#define SCE_OEM_KEY_SIZE_ECCP224_PRIVATE_KEY_INST_DATA_WORD (12) +#define SCE_OEM_KEY_SIZE_ECCP256_PUBLIC_KEY_INST_DATA_WORD (20) +#define SCE_OEM_KEY_SIZE_ECCP256_PRIVATE_KEY_INST_DATA_WORD (12) +#define SCE_OEM_KEY_SIZE_ECCP512_PUBLIC_KEY_INST_DATA_WORD (36) +#define SCE_OEM_KEY_SIZE_ECCP512_PRIVATE_KEY_INST_DATA_WORD (20) #define SCE_INSTALL_KEY_RING_INDEX (0) /* 0-15 */ @@ -158,61 +158,61 @@ /* Return error codes fsp */ typedef enum e_fsp_err { - FSP_SUCCESS = 0, - - /* Start of Crypto specific (0x10000) @note Refer to sf_cryoto_err.h for Crypto error code. */ - FSP_ERR_CRYPTO_CONTINUE = 0x10000, ///< Continue executing function - FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT = 0x10001, ///< Hardware resource busy - FSP_ERR_CRYPTO_SCE_FAIL = 0x10002, ///< Internal I/O buffer is not empty - FSP_ERR_CRYPTO_SCE_HRK_INVALID_INDEX = 0x10003, ///< Invalid index - FSP_ERR_CRYPTO_SCE_RETRY = 0x10004, ///< Retry - FSP_ERR_CRYPTO_SCE_VERIFY_FAIL = 0x10005, ///< Verify is failed - FSP_ERR_CRYPTO_SCE_ALREADY_OPEN = 0x10006, ///< HW SCE module is already opened - FSP_ERR_CRYPTO_NOT_OPEN = 0x10007, ///< Hardware module is not initialized - FSP_ERR_CRYPTO_UNKNOWN = 0x10008, ///< Some unknown error occurred - FSP_ERR_CRYPTO_NULL_POINTER = 0x10009, ///< Null pointer input as a parameter - FSP_ERR_CRYPTO_NOT_IMPLEMENTED = 0x1000a, ///< Algorithm/size not implemented - FSP_ERR_CRYPTO_RNG_INVALID_PARAM = 0x1000b, ///< An invalid parameter is specified - FSP_ERR_CRYPTO_RNG_FATAL_ERROR = 0x1000c, ///< A fatal error occurred - FSP_ERR_CRYPTO_INVALID_SIZE = 0x1000d, ///< Size specified is invalid - FSP_ERR_CRYPTO_INVALID_STATE = 0x1000e, ///< Function used in an valid state - FSP_ERR_CRYPTO_ALREADY_OPEN = 0x1000f, ///< control block is already opened - FSP_ERR_CRYPTO_INSTALL_KEY_FAILED = 0x10010, ///< Specified input key is invalid. - FSP_ERR_CRYPTO_AUTHENTICATION_FAILED = 0x10011, ///< Authentication failed - FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL = 0x10012, ///< Failure to Init Cipher - FSP_ERR_CRYPTO_SCE_AUTHENTICATION = 0x10013, ///< Authentication failed - FSP_ERR_CRYPTO_SCE_PARAMETER = 0x10014, ///< Input date is illegal. - FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION = 0x10015, ///< An invalid function call occurred. - - /* Start of SF_CRYPTO specific */ - FSP_ERR_CRYPTO_COMMON_NOT_OPENED = 0x20000, ///< Crypto Framework Common is not opened - FSP_ERR_CRYPTO_HAL_ERROR = 0x20001, ///< Cryoto HAL module returned an error - FSP_ERR_CRYPTO_KEY_BUF_NOT_ENOUGH = 0x20002, ///< Key buffer size is not enough to generate a key - FSP_ERR_CRYPTO_BUF_OVERFLOW = 0x20003, ///< Attempt to write data larger than what the buffer can hold - FSP_ERR_CRYPTO_INVALID_OPERATION_MODE = 0x20004, ///< Invalid operation mode. - FSP_ERR_MESSAGE_TOO_LONG = 0x20005, ///< Message for RSA encryption is too long. - FSP_ERR_RSA_DECRYPTION_ERROR = 0x20006, ///< RSA Decryption error. + FSP_SUCCESS = 0, + + /* Start of Crypto specific (0x10000) @note Refer to sf_cryoto_err.h for Crypto error code. */ + FSP_ERR_CRYPTO_CONTINUE = 0x10000, ///< Continue executing function + FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT = 0x10001, ///< Hardware resource busy + FSP_ERR_CRYPTO_SCE_FAIL = 0x10002, ///< Internal I/O buffer is not empty + FSP_ERR_CRYPTO_SCE_HRK_INVALID_INDEX = 0x10003, ///< Invalid index + FSP_ERR_CRYPTO_SCE_RETRY = 0x10004, ///< Retry + FSP_ERR_CRYPTO_SCE_VERIFY_FAIL = 0x10005, ///< Verify is failed + FSP_ERR_CRYPTO_SCE_ALREADY_OPEN = 0x10006, ///< HW SCE module is already opened + FSP_ERR_CRYPTO_NOT_OPEN = 0x10007, ///< Hardware module is not initialized + FSP_ERR_CRYPTO_UNKNOWN = 0x10008, ///< Some unknown error occurred + FSP_ERR_CRYPTO_NULL_POINTER = 0x10009, ///< Null pointer input as a parameter + FSP_ERR_CRYPTO_NOT_IMPLEMENTED = 0x1000a, ///< Algorithm/size not implemented + FSP_ERR_CRYPTO_RNG_INVALID_PARAM = 0x1000b, ///< An invalid parameter is specified + FSP_ERR_CRYPTO_RNG_FATAL_ERROR = 0x1000c, ///< A fatal error occurred + FSP_ERR_CRYPTO_INVALID_SIZE = 0x1000d, ///< Size specified is invalid + FSP_ERR_CRYPTO_INVALID_STATE = 0x1000e, ///< Function used in an valid state + FSP_ERR_CRYPTO_ALREADY_OPEN = 0x1000f, ///< control block is already opened + FSP_ERR_CRYPTO_INSTALL_KEY_FAILED = 0x10010, ///< Specified input key is invalid. + FSP_ERR_CRYPTO_AUTHENTICATION_FAILED = 0x10011, ///< Authentication failed + FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL = 0x10012, ///< Failure to Init Cipher + FSP_ERR_CRYPTO_SCE_AUTHENTICATION = 0x10013, ///< Authentication failed + FSP_ERR_CRYPTO_SCE_PARAMETER = 0x10014, ///< Input date is illegal. + FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION = 0x10015, ///< An invalid function call occurred. + + /* Start of SF_CRYPTO specific */ + FSP_ERR_CRYPTO_COMMON_NOT_OPENED = 0x20000, ///< Crypto Framework Common is not opened + FSP_ERR_CRYPTO_HAL_ERROR = 0x20001, ///< Cryoto HAL module returned an error + FSP_ERR_CRYPTO_KEY_BUF_NOT_ENOUGH = 0x20002, ///< Key buffer size is not enough to generate a key + FSP_ERR_CRYPTO_BUF_OVERFLOW = 0x20003, ///< Attempt to write data larger than what the buffer can hold + FSP_ERR_CRYPTO_INVALID_OPERATION_MODE = 0x20004, ///< Invalid operation mode. + FSP_ERR_MESSAGE_TOO_LONG = 0x20005, ///< Message for RSA encryption is too long. + FSP_ERR_RSA_DECRYPTION_ERROR = 0x20006, ///< RSA Decryption error. } fsp_err_t; /** Data lifecycle */ typedef enum { - SCE_CM = 1, - SCE_SSD, - SCE_NSECSD, - SCE_DPL, - SCE_LCK_DBG, - SCE_LCK_BOOT, - SCE_RMA_REQ, - SCE_RMA_ACK, + SCE_CM = 1, + SCE_SSD, + SCE_NSECSD, + SCE_DPL, + SCE_LCK_DBG, + SCE_LCK_BOOT, + SCE_RMA_REQ, + SCE_RMA_ACK, } lifecycle_t; /** Byte data structure */ typedef struct sce_byte_data { - uint8_t * pdata; ///< pointer - uint32_t data_length; ///< data_length - uint32_t data_type; ///< data type + uint8_t * pdata; ///< pointer + uint32_t data_length; ///< data_length + uint32_t data_type; ///< data type } sce_byte_data_t; /** RSA byte data structure */ @@ -224,189 +224,189 @@ typedef sce_byte_data_t sce_ecdsa_byte_data_t; ///< byte data /** AES wrapped key data structure. DO NOT MODIFY. */ typedef struct sce_aes_wrapped_key { - uint32_t type; ///< key type + uint32_t type; ///< key type - /* AES128, AES256 are supported */ - uint32_t value[HW_SCE_AES256_KEY_INDEX_WORD_SIZE]; ///< wrapped key value + /* AES128, AES256 are supported */ + uint32_t value[HW_SCE_AES256_KEY_INDEX_WORD_SIZE]; ///< wrapped key value } sce_aes_wrapped_key_t; /** RSA 1024bit public wrapped key data structure. DO NOT MODIFY. */ typedef struct sce_rsa1024_public_wrapped_key { - uint32_t type; ///< key type - struct - { - /* key management information */ - uint32_t key_management_info1[HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; - /* RSA 1024-bit public key n (plaintext) */ - uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; - /* RSA 1024-bit public key e (plaintext) */ - uint8_t key_e[HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE]; - /* dummy */ - uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; - /* key management information */ - uint32_t key_management_info2[HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; - } value; + uint32_t type; ///< key type + struct + { + /* key management information */ + uint32_t key_management_info1[HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; + /* RSA 1024-bit public key n (plaintext) */ + uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; + /* RSA 1024-bit public key e (plaintext) */ + uint8_t key_e[HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE]; + /* dummy */ + uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; + /* key management information */ + uint32_t key_management_info2[HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; + } value; } sce_rsa1024_public_wrapped_key_t; /** RSA 1024bit private wrapped key data structure. DO NOT MODIFY. */ typedef struct sce_rsa1024_private_wrapped_key { - uint32_t type; ///< key type - struct - { - /* key management information */ - uint32_t key_management_info1[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; - /* RSA 1024-bit private key n (plaintext) */ - uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; - /* key management information */ - uint32_t key_management_info2[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; - } value; + uint32_t type; ///< key type + struct + { + /* key management information */ + uint32_t key_management_info1[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; + /* RSA 1024-bit private key n (plaintext) */ + uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; + /* key management information */ + uint32_t key_management_info2[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; + } value; } sce_rsa1024_private_wrapped_key_t; /** RSA 2048bit public wrapped key data structure. DO NOT MODIFY. */ typedef struct sce_rsa2048_public_wrapped_key { - uint32_t type; ///< Key type - struct - { - /* key management information */ - uint32_t key_management_info1[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; - /* RSA 2048-bit public key n (plaintext) */ - uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; - /* RSA 2048-bit public key e (plaintext) */ - uint8_t key_e[HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE]; - /* dummy */ - uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; - /* key management information */ - uint32_t key_management_info2[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; - } value; + uint32_t type; ///< Key type + struct + { + /* key management information */ + uint32_t key_management_info1[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; + /* RSA 2048-bit public key n (plaintext) */ + uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; + /* RSA 2048-bit public key e (plaintext) */ + uint8_t key_e[HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE]; + /* dummy */ + uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; + /* key management information */ + uint32_t key_management_info2[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; + } value; } sce_rsa2048_public_wrapped_key_t; /** RSA 2048bit private wrapped key data structure. DO NOT MODIFY. */ typedef struct sce_rsa2048_private_wrapped_key { - uint32_t type; ///< key type - struct - { - /* key management information */ - uint32_t key_management_info1[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; - /* RSA 2048-bit private key n (plaintext) */ - uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; - /* key management information */ - uint32_t key_management_info2[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; - } value; + uint32_t type; ///< key type + struct + { + /* key management information */ + uint32_t key_management_info1[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; + /* RSA 2048-bit private key n (plaintext) */ + uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; + /* key management information */ + uint32_t key_management_info2[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; + } value; } sce_rsa2048_private_wrapped_key_t; /** RSA 4096bit public wrapped key data structure. DO NOT MODIFY. */ typedef struct sce_rsa4096_public_wrapped_key { - uint32_t type; ///< Key type - struct - { - /* key management information */ - uint32_t key_management_info1[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; - /* RSA 4096-bit public key n (plaintext) */ - uint8_t key_n[HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE]; - /* RSA 4096-bit public key e (plaintext) */ - uint8_t key_e[HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE]; - /* dummy */ - uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; - /* key management information */ - uint32_t key_management_info2[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; - } value; + uint32_t type; ///< Key type + struct + { + /* key management information */ + uint32_t key_management_info1[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; + /* RSA 4096-bit public key n (plaintext) */ + uint8_t key_n[HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE]; + /* RSA 4096-bit public key e (plaintext) */ + uint8_t key_e[HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE]; + /* dummy */ + uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; + /* key management information */ + uint32_t key_management_info2[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; + } value; } sce_rsa4096_public_wrapped_key_t; /** RSA 1024bit wrapped key pair structure. DO NOT MODIFY. */ typedef struct sce_rsa1024_wrapped_pair_key { - sce_rsa1024_private_wrapped_key_t priv_key; ///< RSA 1024-bit private wrapped key - sce_rsa1024_public_wrapped_key_t pub_key; ///< RSA 1024-bit public wrapped key + sce_rsa1024_private_wrapped_key_t priv_key; ///< RSA 1024-bit private wrapped key + sce_rsa1024_public_wrapped_key_t pub_key; ///< RSA 1024-bit public wrapped key } sce_rsa1024_wrapped_pair_key_t; /** RSA 2048bit wrapped key pair structure. DO NOT MODIFY. */ typedef struct sce_rsa2048_wrapped_pair_key { - sce_rsa2048_private_wrapped_key_t priv_key; ///< RSA 2048-bit private wrapped key - sce_rsa2048_public_wrapped_key_t pub_key; ///< RSA 2048-bit public wrapped key + sce_rsa2048_private_wrapped_key_t priv_key; ///< RSA 2048-bit private wrapped key + sce_rsa2048_public_wrapped_key_t pub_key; ///< RSA 2048-bit public wrapped key } sce_rsa2048_wrapped_pair_key_t; /** ECC P-192/224/256/512 public wrapped key data structure */ typedef struct sce_ecc_public_wrapped_key { - uint32_t type; ///< key type - struct - { - /* key management information */ - uint32_t key_management_info[HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE]; - /* ECC public key Q (plaintext) */ - uint8_t key_q[HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE]; - } value; + uint32_t type; ///< key type + struct + { + /* key management information */ + uint32_t key_management_info[HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE]; + /* ECC public key Q (plaintext) */ + uint8_t key_q[HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE]; + } value; } sce_ecc_public_wrapped_key_t; /** ECC P-192/224/256/512 private wrapped key data structure */ typedef struct sce_ecc_private_wrapped_key { - uint32_t type; ///< key type - uint32_t value[HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE]; ///< wrapped key value + uint32_t type; ///< key type + uint32_t value[HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE]; ///< wrapped key value } sce_ecc_private_wrapped_key_t; /** ECC P-192/224/256 wrapped key pair structure */ typedef struct sce_ecc_wrapped_pair_key { - sce_ecc_private_wrapped_key_t priv_key; ///< ECC private wrapped key - sce_ecc_public_wrapped_key_t pub_key; ///< ECC public wrapped key + sce_ecc_private_wrapped_key_t priv_key; ///< ECC private wrapped key + sce_ecc_public_wrapped_key_t pub_key; ///< ECC public wrapped key } sce_ecc_wrapped_pair_key_t; /** Update key ring index data structure. DO NOT MODIFY. */ typedef struct sce_key_update_key { - uint32_t type; ///< key type - uint32_t value[HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE]; ///< wrapped key value + uint32_t type; ///< key type + uint32_t value[HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE]; ///< wrapped key value } sce_key_update_key_t; /** The work area for AES. DO NOT MODIFY. */ typedef struct sce_aes_handle { - /* serial number of this handle */ - uint32_t id; - /* wrapped key */ - sce_aes_wrapped_key_t wrapped_key; - /* text size under encryption / decryption */ - uint32_t current_input_data_size; - /* text array less than the block long */ - uint8_t last_1_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE]; - /* reserved */ - uint8_t last_2_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE * 2]; - /* current initialization vector used in CBC/CTR mode */ - uint8_t current_initial_vector[HW_SCE_AES_CBC_IV_BYTE_SIZE]; - /* control flag of calling function */ - uint8_t flag_call_init; + /* serial number of this handle */ + uint32_t id; + /* wrapped key */ + sce_aes_wrapped_key_t wrapped_key; + /* text size under encryption / decryption */ + uint32_t current_input_data_size; + /* text array less than the block long */ + uint8_t last_1_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE]; + /* reserved */ + uint8_t last_2_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE * 2]; + /* current initialization vector used in CBC/CTR mode */ + uint8_t current_initial_vector[HW_SCE_AES_CBC_IV_BYTE_SIZE]; + /* control flag of calling function */ + uint8_t flag_call_init; } sce_aes_handle_t; /** The work area for CMAC. DO NOT MODIFY. */ typedef struct sce_cmac_handle { - uint32_t id; ///< serial number of this handle - sce_aes_wrapped_key_t wrapped_key; ///< wrapped key - uint8_t cmac_buffer[HW_SCE_AES_BLOCK_BYTE_SIZE]; ///< message array less than the block long - uint32_t all_received_length; ///< entire length of message - /* message array length less than the block long */ - uint32_t buffering_length; - uint8_t flag_call_init; ///< control flag of calling function + uint32_t id; ///< serial number of this handle + sce_aes_wrapped_key_t wrapped_key; ///< wrapped key + uint8_t cmac_buffer[HW_SCE_AES_BLOCK_BYTE_SIZE]; ///< message array less than the block long + uint32_t all_received_length; ///< entire length of message + /* message array length less than the block long */ + uint32_t buffering_length; + uint8_t flag_call_init; ///< control flag of calling function } sce_cmac_handle_t; /** The work area for SHA. DO NOT MODIFY. */ typedef struct sce_sha_md5_handle { - uint32_t id; ///< serial number of this handle - uint8_t sha_buffer[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE * 4];///< message array length less than the block long - uint32_t all_received_length; ///< entire length of message - uint32_t buffering_length; ///< message array length less than the block long - - /* SHA1(20byte), SHA256(32byte), MD5(16byte) are supported */ - uint8_t current_hash[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE]; ///< last hash value - uint8_t flag_call_init; ///< control flag of calling function + uint32_t id; ///< serial number of this handle + uint8_t sha_buffer[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE * 4];///< message array length less than the block long + uint32_t all_received_length; ///< entire length of message + uint32_t buffering_length; ///< message array length less than the block long + + /* SHA1(20byte), SHA256(32byte), MD5(16byte) are supported */ + uint8_t current_hash[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE]; ///< last hash value + uint8_t flag_call_init; ///< control flag of calling function } sce_sha_md5_handle_t; /** SCE Control block. Allocate an instance specific control block to pass into the API calls. @@ -418,1083 +418,1083 @@ typedef void sce_ctrl_t; /** User configuration structure, used in open function */ typedef struct st_sce_cfg { - lifecycle_t lifecycle; ///< Data lifecycle + lifecycle_t lifecycle; ///< Data lifecycle } sce_cfg_t; /** Functions implemented at the HAL layer will follow this API. */ typedef struct st_sce_api { - /** Enables use of SCE functionality. - * @par Implemented as - * - @ref R_SCE_Open() - * - * @param[in] p_ctrl Pointer to control structure. - * @param[in] p_cfg Pointer to pin configuration structure. - */ - - /***** TODO: Replace "struct st_sce_ctrl" to "void" *****/ - fsp_err_t (* open)(sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg); - - /** Stops supply of power to the SCE. - * @par Implemented as - * - @ref R_SCE_Close() - * - * @param[in] p_ctrl Pointer to control structure. - */ - fsp_err_t (* close)(sce_ctrl_t * const p_ctrl); - - /** Software reset to SCE. - * @par Implemented as - * - @ref R_SCE_SoftwareReset() - * - */ - fsp_err_t (* softwareReset)(void); - - /** Generates 4 words random number. - * @par Implemented as - * - @ref R_SCE_RandomNumberGenerate() - * - * @param[in,out] random Stores 4words (16 bytes) random data. - */ - fsp_err_t (* randomNumberGenerate)(uint32_t * random); - - /** This API outputs 128-bit AES wrapped key. - * @par Implemented as - * - @ref R_SCE_AES128_WrappedKeyGenerate() - * - * @param[in,out] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* AES128_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); - - /** This API outputs 256-bit AES wrapped key. - * @par Implemented as - * - @ref R_SCE_AES256_WrappedKeyGenerate() - * - * @param[in,out] wrapped_key 256-bit AES wrapped key - */ - fsp_err_t (* AES256_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); - - /** This API outputs 128-bit AES wrapped key. - * @par Implemented as - * - @ref R_SCE_AES128_EncryptedKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* AES128_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); - - /** This API outputs 256-bit AES wrapped key. - * @par Implemented as - * - @ref R_SCE_AES256_EncryptedKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 256-bit AES wrapped key - */ - fsp_err_t (* AES256_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); - - /** Initialize AES128ECB encryption. - * @par Implemented as - * - @ref R_SCE_AES128ECB_EncryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* AES128ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES128ECB encryption. - * @par Implemented as - * - @ref R_SCE_AES128ECB_EncryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - */ - fsp_err_t (* AES128ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - /** Finalize AES128ECB encryption. - * @par Implemented as - * - @ref R_SCE_AES128ECB_EncryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - */ - fsp_err_t (* AES128ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - /** Initialize AES128ECB decryption. - * @par Implemented as - * - @ref R_SCE_AES128ECB_DecryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* AES128ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES128ECB decryption. - * @par Implemented as - * - @ref R_SCE_AES128ECB_DecryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - */ - fsp_err_t (* AES128ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - /** Finalize AES128ECB decryption. - * @par Implemented as - * - @ref R_SCE_AES128ECB_DecryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - */ - fsp_err_t (* AES128ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - /** Initialize AES256ECB encryption. - * @par Implemented as - * - @ref R_SCE_AES256ECB_EncryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - */ - fsp_err_t (* AES256ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES256ECB encryption. - * @par Implemented as - * - @ref R_SCE_AES256ECB_EncryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - */ - fsp_err_t (* AES256ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - /** Finalize AES256ECB encryption. - * @par Implemented as - * - @ref R_SCE_AES256ECB_EncryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - */ - fsp_err_t (* AES256ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - /** Initialize AES256ECB decryption. - * @par Implemented as - * - @ref R_SCE_AES256ECB_DecryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - */ - fsp_err_t (* AES256ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES256ECB decryption. - * @par Implemented as - * - @ref R_SCE_AES256ECB_DecryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - */ - fsp_err_t (* AES256ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - /** Finalize AES256ECB decryption. - * @par Implemented as - * - @ref R_SCE_AES256ECB_DecryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - */ - fsp_err_t (* AES256ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - /** Initialize AES128CBC encryption. - * @par Implemented as - * - @ref R_SCE_AES128CBC_EncryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES128CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES128CBC encryption. - * @par Implemented as - * - @ref R_SCE_AES128CBC_EncryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - */ - fsp_err_t (* AES128CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - /** Finalize AES128CBC encryption. - * @par Implemented as - * - @ref R_SCE_AES128CBC_EncryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - */ - fsp_err_t (* AES128CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - /** Initialize AES128CBC decryption. - * @par Implemented as - * - @ref R_SCE_AES128CBC_DecryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES128CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES128CBC decryption. - * @par Implemented as - * - @ref R_SCE_AES128CBC_DecryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - */ - fsp_err_t (* AES128CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - /** Finalize AES128CBC decryption. - * @par Implemented as - * - @ref R_SCE_AES128CBC_DecryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - */ - fsp_err_t (* AES128CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - /** Initialize AES256CBC encryption. - * @par Implemented as - * - @ref R_SCE_AES256CBC_EncryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES256CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES256CBC encryption. - * @par Implemented as - * - @ref R_SCE_AES256CBC_EncryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - */ - fsp_err_t (* AES256CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - /** Finalize AES256CBC encryption. - * @par Implemented as - * - @ref R_SCE_AES256CBC_EncryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - */ - fsp_err_t (* AES256CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - /** Initialize AES256CBC decryption. - * @par Implemented as - * - @ref R_SCE_AES256CBC_DecryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES256CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES256CBC decryption. - * @par Implemented as - * - @ref R_SCE_AES256CBC_DecryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - */ - fsp_err_t (* AES256CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - /** Finalize AES256CBC decryption. - * @par Implemented as - * - @ref R_SCE_AES256CBC_DecryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - */ - fsp_err_t (* AES256CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - /** Initialize AES128CTR encryption. - * @par Implemented as - * - @ref R_SCE_AES128CTR_EncryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES128CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES128CTR encryption. - * @par Implemented as - * - @ref R_SCE_AES128CTR_EncryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - */ - fsp_err_t (* AES128CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - /** Finalize AES128CTR encryption. - * @par Implemented as - * - @ref R_SCE_AES128CTR_EncryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - */ - fsp_err_t (* AES128CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - /** Initialize AES128CTR decryption. - * @par Implemented as - * - @ref R_SCE_AES128CTR_DecryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES128CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES128CTR decryption. - * @par Implemented as - * - @ref R_SCE_AES128CTR_DecryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - */ - fsp_err_t (* AES128CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - /** Finalize AES128CTR decryption. - * @par Implemented as - * - @ref R_SCE_AES128CTR_DecryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - */ - fsp_err_t (* AES128CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - /** Initialize AES256CTR encryption. - * @par Implemented as - * - @ref R_SCE_AES256CTR_EncryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES256CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES256CTR encryption. - * @par Implemented as - * - @ref R_SCE_AES256CTR_EncryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - */ - fsp_err_t (* AES256CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - /** Finalize AES256CTR encryption. - * @par Implemented as - * - @ref R_SCE_AES256CTR_EncryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - */ - fsp_err_t (* AES256CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - /** Initialize AES256CTR decryption. - * @par Implemented as - * - @ref R_SCE_AES256CTR_DecryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES256CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES256CTR decryption. - * @par Implemented as - * - @ref R_SCE_AES256CTR_DecryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - */ - fsp_err_t (* AES256CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - /** Finalize AES256CTR decryption. - * @par Implemented as - * - @ref R_SCE_AES256CTR_DecryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - */ - fsp_err_t (* AES256CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - /** Initialize AES128CMAC generation. - * @par Implemented as - * - @ref R_SCE_AES128CMAC_GenerateInit() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* AES128CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES128CMAC generation. - * @par Implemented as - * - @ref R_SCE_AES128CMAC_GenerateUpdate() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) - */ - fsp_err_t (* AES128CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - /** Finalize AES128CMAC generation. - * @par Implemented as - * - @ref R_SCE_AES128CMAC_GenerateFinal() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (16byte) - */ - fsp_err_t (* AES128CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); - - /** Initialize AES128CMAC verification. - * @par Implemented as - * - @ref R_SCE_AES128CMAC_VerifyInit() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* AES128CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES128CMAC verification. - * @par Implemented as - * - @ref R_SCE_AES128CMAC_VerifyUpdate() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) - */ - fsp_err_t (* AES128CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - /** Finalize AES128CMAC verification. - * @par Implemented as - * - @ref R_SCE_AES128CMAC_VerifyFinal() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (mac_length byte) - * @param[in,out] mac_length MAC data length (2 to 16 bytes) - */ - fsp_err_t (* AES128CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); - - /** Initialize AES256CMAC generation. - * @par Implemented as - * - @ref R_SCE_AES256CMAC_GenerateInit() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - */ - fsp_err_t (* AES256CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES256CMAC generation. - * @par Implemented as - * - @ref R_SCE_AES256CMAC_GenerateUpdate() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) - */ - fsp_err_t (* AES256CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - /** Finalize AES256CMAC generation. - * @par Implemented as - * - @ref R_SCE_AES256CMAC_GenerateFinal() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (16byte) - */ - fsp_err_t (* AES256CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); - - /** Initialize AES256CMAC verification. - * @par Implemented as - * - @ref R_SCE_AES256CMAC_VerifyInit() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - */ - fsp_err_t (* AES256CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES256CMAC verification. - * @par Implemented as - * - @ref R_SCE_AES256CMAC_VerifyUpdate() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) - */ - fsp_err_t (* AES256CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - /** Finalize AES256CMAC verification. - * @par Implemented as - * - @ref R_SCE_AES256CMAC_VerifyFinal() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (mac_length byte) - * @param[in,out] mac_length MAC data length (2 to 16 bytes) - */ - fsp_err_t (* AES256CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); - - /** Initialize SHA-256 Calculation. - * @par Implemented as - * - @ref R_SCE_SHA256_Init() - * - * @param[in,out] handle SHA handler (work area) - */ - fsp_err_t (* SHA256_Init)(sce_sha_md5_handle_t * handle); - - /** Update SHA-256 Calculation. - * @par Implemented as - * - @ref R_SCE_SHA256_Update() - * - * @param[in,out] handle SHA handler (work area) - * @param[in] message message data area - * @param[in] message_length message data length - */ - fsp_err_t (* SHA256_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); - - /** Finalize SHA-256 Calculation. - * @par Implemented as - * - @ref R_SCE_SHA256_Final() - * - * @param[in,out] handle SHA handler (work area) - * @param[in,out] digest hasha data area - * @param[in,out] digest_length hash data length (32bytes) - */ - fsp_err_t (* SHA256_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); - - /** Initialize SHA-224 Calculation. - * @par Implemented as - * - @ref R_SCE_SHA224_Init() - * - * @param[in,out] handle SHA handler (work area) - */ - fsp_err_t (* SHA224_Init)(sce_sha_md5_handle_t * handle); - - /** Update SHA-224 Calculation. - * @par Implemented as - * - @ref R_SCE_SHA224_Update() - * - * @param[in,out] handle SHA handler (work area) - * @param[in] message message data area - * @param[in] message_length message data length - */ - fsp_err_t (* SHA224_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); - - /** Finalize SHA-224 Calculation. - * @par Implemented as - * - @ref R_SCE_SHA224_Final() - * - * @param[in,out] handle SHA handler (work area) - * @param[in,out] digest hasha data area - * @param[in,out] digest_length hash data length (32bytes) - */ - fsp_err_t (* SHA224_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); - - /** This API outputs 1024-bit RSA wrapped pair key. - * @par Implemented as - * - @ref R_SCE_RSA1024_WrappedKeyPairGenerate() - * - * @param[in,out] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* RSA1024_WrappedKeyPairGenerate)(sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key); - - /** This API outputs 2048-bit RSA wrapped pair key. - * @par Implemented as - * - @ref R_SCE_RSA2048_WrappedKeyPairGenerate() - * - * @param[in,out] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* RSA2048_WrappedKeyPairGenerate)(sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key); - - /** This API outputs 1024-bit RSA public wrapped key. - * @par Implemented as - * - @ref R_SCE_RSA1024_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 1024-bit RSA public wrapped key - */ - fsp_err_t (* RSA1024_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_public_wrapped_key_t * wrapped_key); - - /** This API outputs 1024-bit RSA private wrapped key. - * @par Implemented as - * - @ref R_SCE_RSA1024_EncryptedPrivateKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 1024-bit RSA private wrapped key - */ - fsp_err_t (* RSA1024_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_private_wrapped_key_t * wrapped_key); - - /** This API outputs 2048-bit RSA public wrapped key. - * @par Implemented as - * - @ref R_SCE_RSA2048_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 2048-bit RSA public wrapped key - */ - fsp_err_t (* RSA2048_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_public_wrapped_key_t * wrapped_key); - - /** This API outputs 2048-bit RSA private wrapped key. - * @par Implemented as - * - @ref R_SCE_RSA2048_EncryptedPrivateKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 2048-bit RSA private wrapped key - */ - fsp_err_t (* RSA2048_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_private_wrapped_key_t * wrapped_key); - - /** This API outputs 4096-bit RSA public wrapped key. - * @par Implemented as - * - @ref R_SCE_RSA4096_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 4096-bit RSA public wrapped key - */ - fsp_err_t (* RSA4096_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa4096_public_wrapped_key_t * wrapped_key); - - /** RSASSA-PKCS1-V1_5 signature generation. - * @par Implemented as - * - @ref R_SCE_RSASSA_PKCS1024_SignatureGenerate() - * - * @param[in] message_hash Message or hash value to which to attach signature - * @param[in,out] signature Signature text storage destination information - * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - */ - fsp_err_t (* RSASSA_PKCS1024_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, - sce_rsa_byte_data_t * signature, sce_rsa1024_private_wrapped_key_t * wrapped_key, uint8_t hash_type); - - /** RSASSA-PKCS1-V1_5 signature generation. - * @par Implemented as - * - @ref R_SCE_RSASSA_PKCS2048_SignatureGenerate() - * - * @param[in] message_hash Message or hash value to which to attach signature - * @param[in,out] signature Signature text storage destination information - * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - */ - fsp_err_t (* RSASSA_PKCS2048_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, - sce_rsa_byte_data_t * signature, sce_rsa2048_private_wrapped_key_t * wrapped_key, uint8_t hash_type); - - /** RSASSA-PKCS1-V1_5 signature verification. - * @par Implemented as - * - @ref R_SCE_RSASSA_PKCS1024_SignatureVerify() - * - * @param[in] signature Signature text information to verify - * @param[in] message_hash Message text or hash value to verify - * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - */ - fsp_err_t (* RSASSA_PKCS1024_SignatureVerify)(sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, sce_rsa1024_public_wrapped_key_t * wrapped_key, uint8_t hash_type); - - /** RSASSA-PKCS1-V1_5 signature verification. - * @par Implemented as - * - @ref R_SCE_RSASSA_PKCS2048_SignatureVerify() - * - * @param[in] signature Signature text information to verify - * @param[in] message_hash Message text or hash value to verify - * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - */ - fsp_err_t (* RSASSA_PKCS2048_SignatureVerify)(sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, sce_rsa2048_public_wrapped_key_t * wrapped_key, uint8_t hash_type); - - /** RSASSA-PKCS1-V1_5 signature verification. - * @par Implemented as - * - @ref R_SCE_RSASSA_PKCS4096_SignatureVerify() - * - * @param[in] signature Signature text information to verify - * @param[in] message_hash Message text or hash value to verify - * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - */ - fsp_err_t (* RSASSA_PKCS4096_SignatureVerify)(sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, sce_rsa4096_public_wrapped_key_t * wrapped_key, uint8_t hash_type); - - /** RSAES-PKCS1-V1_5 encryption. - * @par Implemented as - * - @ref R_SCE_RSAES_PKCS1024_Encrypt() - * - * @param[in] plain plaintext - * @param[in,out] cipher ciphertext - * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. - */ - fsp_err_t (* RSAES_PKCS1024_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, - sce_rsa1024_public_wrapped_key_t * wrapped_key); - - /** RSAES-PKCS1-V1_5 encryption. - * @par Implemented as - * - @ref R_SCE_RSAES_PKCS2048_Encrypt() - * - * @param[in] plain plaintext - * @param[in,out] cipher ciphertext - * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. - */ - fsp_err_t (* RSAES_PKCS2048_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, - sce_rsa2048_public_wrapped_key_t * wrapped_key); - - /** RSAES-PKCS1-V1_5 encryption. - * @par Implemented as - * - @ref R_SCE_RSAES_PKCS4096_Encrypt() - * - * @param[in] plain plaintext - * @param[in,out] cipher ciphertext - * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. - */ - fsp_err_t (* RSAES_PKCS4096_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, - sce_rsa4096_public_wrapped_key_t * wrapped_key); - - /** RSAES-PKCS1-V1_5 decryption. - * @par Implemented as - * - @ref R_SCE_RSAES_PKCS1024_Decrypt() - * - * @param[in] cipher ciphertext - * @param[in,out] plain plaintext - * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. - */ - fsp_err_t (* RSAES_PKCS1024_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, - sce_rsa1024_private_wrapped_key_t * wrapped_key); - - /** RSAES-PKCS1-V1_5 decryption. - * @par Implemented as - * - @ref R_SCE_RSAES_PKCS2048_Decrypt() - * - * @param[in] cipher ciphertext - * @param[in,out] plain plaintext - * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. - */ - fsp_err_t (* RSAES_PKCS2048_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, - sce_rsa2048_private_wrapped_key_t * wrapped_key); - - /** This API outputs secp192r1 wrapped pair key. - * @par Implemented as - * - @ref R_SCE_ECC_secp192r1_WrappedKeyPairGenerate() - * - * @param[in,out] wrapped_pair_key Wrapped pair key for secp192r1 public key and private key pair - */ - fsp_err_t (* ECC_secp192r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - /** This API outputs secp224r1 wrapped pair key. - * @par Implemented as - * - @ref R_SCE_ECC_secp224r1_WrappedKeyPairGenerate() - * - * @param[in,out] wrapped_pair_key Wrapped pair key for secp224r1 public key and private key pair - */ - fsp_err_t (* ECC_secp224r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - /** This API outputs secp256r1 wrapped pair key. - * @par Implemented as - * - @ref R_SCE_ECC_secp256r1_WrappedKeyPairGenerate() - * - * @param[in,out] wrapped_pair_key Wrapped pair key for secp256r1 public key and private key pair - */ - fsp_err_t (* ECC_secp256r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - /** This API outputs BrainpoolP512r1 wrapped pair key. - * @par Implemented as - * - @ref R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate() - * - * @param[in,out] wrapped_pair_key Wrapped pair key for BrainpoolP512r1 public key and private key pair - */ - fsp_err_t (* ECC_BrainpoolP512r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - /** This API outputs secp192r1 public wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp192r1 public wrapped key - */ - fsp_err_t (* ECC_secp192r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** This API outputs secp224r1 public wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp224r1 public wrapped key - */ - fsp_err_t (* ECC_secp224r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** This API outputs secp256r1 public wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp256r1 public wrapped key - */ - fsp_err_t (* ECC_secp256r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** This API outputs BrainpoolP512r1 public wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key BrainpoolP512r1 public wrapped key - */ - fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** This API outputs secp192r1 private wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp192r1 private wrapped key - */ - fsp_err_t (* ECC_secp192r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** This API outputs secp224r1 private wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp224r1 private wrapped key - */ - fsp_err_t (* ECC_secp224r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** This API outputs secp256r1 private wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp256r1 private wrapped key - */ - fsp_err_t (* ECC_secp256r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** This API outputs BrainpoolP512r1 private wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key BrainpoolP512r1 private wrapped key - */ - fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** ECDSA signature generation. - * @par Implemented as - * - @ref R_SCE_ECDSA_secp192r1_SignatureGenerate() - * - * @param[in] message_hash Message or hash value to which to attach signature - * @param[in,out] signature Signature text storage destination information - * @param[in] wrapped_key Input wrapped key of secp192r1 private key. - */ - fsp_err_t (* ECDSA_secp192r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** ECDSA signature generation. - * @par Implemented as - * - @ref R_SCE_ECDSA_secp224r1_SignatureGenerate() - * - * @param[in] message_hash Message or hash value to which to attach signature - * @param[in,out] signature Signature text storage destination information - * @param[in] wrapped_key Input wrapped key of secp224r1 private key. - */ - fsp_err_t (* ECDSA_secp224r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** ECDSA signature generation. - * @par Implemented as - * - @ref R_SCE_ECDSA_secp256r1_SignatureGenerate() - * - * @param[in] message_hash Message or hash value to which to attach signature - * @param[in,out] signature Signature text storage destination information - * @param[in] wrapped_key Input wrapped key of secp256r1 private key. - */ - fsp_err_t (* ECDSA_secp256r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** ECDSA signature generation. - * @par Implemented as - * - @ref R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate() - * - * @param[in] message_hash Message or hash value to which to attach signature - * @param[in,out] signature Signature text storage destination information - * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 private key. - */ - fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** ECDSA signature verification. - * @par Implemented as - * - @ref R_SCE_ECDSA_secp192r1_SignatureVerify() - * - * @param[in] signature Signature text information to be verified - * @param[in,out] message_hash Message or hash value to be verified - * @param[in] wrapped_key Input wrapped key of secp192r1 public key. - */ - fsp_err_t (* ECDSA_secp192r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** ECDSA signature verification. - * @par Implemented as - * - @ref R_SCE_ECDSA_secp224r1_SignatureVerify() - * - * @param[in] signature Signature text information to be verified - * @param[in,out] message_hash Message or hash value to be verified - * @param[in] wrapped_key Input wrapped key of secp224r1 public key. - */ - fsp_err_t (* ECDSA_secp224r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** ECDSA signature verification. - * @par Implemented as - * - @ref R_SCE_ECDSA_secp256r1_SignatureVerify() - * - * @param[in] signature Signature text information to be verified - * @param[in,out] message_hash Message or hash value to be verified - * @param[in] wrapped_key Input wrapped key of secp256r1 public key. - */ - fsp_err_t (* ECDSA_secp256r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** ECDSA signature verification. - * @par Implemented as - * - @ref R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify() - * - * @param[in] signature Signature text information to be verified - * @param[in,out] message_hash Message or hash value to be verified - * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 public key. - */ - fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); + /** Enables use of SCE functionality. + * @par Implemented as + * - @ref R_SCE_Open() + * + * @param[in] p_ctrl Pointer to control structure. + * @param[in] p_cfg Pointer to pin configuration structure. + */ + + /***** TODO: Replace "struct st_sce_ctrl" to "void" *****/ + fsp_err_t (* open)(sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg); + + /** Stops supply of power to the SCE. + * @par Implemented as + * - @ref R_SCE_Close() + * + * @param[in] p_ctrl Pointer to control structure. + */ + fsp_err_t (* close)(sce_ctrl_t * const p_ctrl); + + /** Software reset to SCE. + * @par Implemented as + * - @ref R_SCE_SoftwareReset() + * + */ + fsp_err_t (* softwareReset)(void); + + /** Generates 4 words random number. + * @par Implemented as + * - @ref R_SCE_RandomNumberGenerate() + * + * @param[in,out] random Stores 4words (16 bytes) random data. + */ + fsp_err_t (* randomNumberGenerate)(uint32_t * random); + + /** This API outputs 128-bit AES wrapped key. + * @par Implemented as + * - @ref R_SCE_AES128_WrappedKeyGenerate() + * + * @param[in,out] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* AES128_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); + + /** This API outputs 256-bit AES wrapped key. + * @par Implemented as + * - @ref R_SCE_AES256_WrappedKeyGenerate() + * + * @param[in,out] wrapped_key 256-bit AES wrapped key + */ + fsp_err_t (* AES256_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); + + /** This API outputs 128-bit AES wrapped key. + * @par Implemented as + * - @ref R_SCE_AES128_EncryptedKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* AES128_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); + + /** This API outputs 256-bit AES wrapped key. + * @par Implemented as + * - @ref R_SCE_AES256_EncryptedKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 256-bit AES wrapped key + */ + fsp_err_t (* AES256_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); + + /** Initialize AES128ECB encryption. + * @par Implemented as + * - @ref R_SCE_AES128ECB_EncryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* AES128ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES128ECB encryption. + * @par Implemented as + * - @ref R_SCE_AES128ECB_EncryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + */ + fsp_err_t (* AES128ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + /** Finalize AES128ECB encryption. + * @par Implemented as + * - @ref R_SCE_AES128ECB_EncryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + */ + fsp_err_t (* AES128ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + /** Initialize AES128ECB decryption. + * @par Implemented as + * - @ref R_SCE_AES128ECB_DecryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* AES128ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES128ECB decryption. + * @par Implemented as + * - @ref R_SCE_AES128ECB_DecryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + */ + fsp_err_t (* AES128ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + /** Finalize AES128ECB decryption. + * @par Implemented as + * - @ref R_SCE_AES128ECB_DecryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + */ + fsp_err_t (* AES128ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + /** Initialize AES256ECB encryption. + * @par Implemented as + * - @ref R_SCE_AES256ECB_EncryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + */ + fsp_err_t (* AES256ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES256ECB encryption. + * @par Implemented as + * - @ref R_SCE_AES256ECB_EncryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + */ + fsp_err_t (* AES256ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + /** Finalize AES256ECB encryption. + * @par Implemented as + * - @ref R_SCE_AES256ECB_EncryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + */ + fsp_err_t (* AES256ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + /** Initialize AES256ECB decryption. + * @par Implemented as + * - @ref R_SCE_AES256ECB_DecryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + */ + fsp_err_t (* AES256ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES256ECB decryption. + * @par Implemented as + * - @ref R_SCE_AES256ECB_DecryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + */ + fsp_err_t (* AES256ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + /** Finalize AES256ECB decryption. + * @par Implemented as + * - @ref R_SCE_AES256ECB_DecryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + */ + fsp_err_t (* AES256ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + /** Initialize AES128CBC encryption. + * @par Implemented as + * - @ref R_SCE_AES128CBC_EncryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES128CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES128CBC encryption. + * @par Implemented as + * - @ref R_SCE_AES128CBC_EncryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + */ + fsp_err_t (* AES128CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + /** Finalize AES128CBC encryption. + * @par Implemented as + * - @ref R_SCE_AES128CBC_EncryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + */ + fsp_err_t (* AES128CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + /** Initialize AES128CBC decryption. + * @par Implemented as + * - @ref R_SCE_AES128CBC_DecryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES128CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES128CBC decryption. + * @par Implemented as + * - @ref R_SCE_AES128CBC_DecryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + */ + fsp_err_t (* AES128CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + /** Finalize AES128CBC decryption. + * @par Implemented as + * - @ref R_SCE_AES128CBC_DecryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + */ + fsp_err_t (* AES128CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + /** Initialize AES256CBC encryption. + * @par Implemented as + * - @ref R_SCE_AES256CBC_EncryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES256CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES256CBC encryption. + * @par Implemented as + * - @ref R_SCE_AES256CBC_EncryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + */ + fsp_err_t (* AES256CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + /** Finalize AES256CBC encryption. + * @par Implemented as + * - @ref R_SCE_AES256CBC_EncryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + */ + fsp_err_t (* AES256CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + /** Initialize AES256CBC decryption. + * @par Implemented as + * - @ref R_SCE_AES256CBC_DecryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES256CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES256CBC decryption. + * @par Implemented as + * - @ref R_SCE_AES256CBC_DecryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + */ + fsp_err_t (* AES256CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + /** Finalize AES256CBC decryption. + * @par Implemented as + * - @ref R_SCE_AES256CBC_DecryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + */ + fsp_err_t (* AES256CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + /** Initialize AES128CTR encryption. + * @par Implemented as + * - @ref R_SCE_AES128CTR_EncryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES128CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES128CTR encryption. + * @par Implemented as + * - @ref R_SCE_AES128CTR_EncryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + */ + fsp_err_t (* AES128CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + /** Finalize AES128CTR encryption. + * @par Implemented as + * - @ref R_SCE_AES128CTR_EncryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + */ + fsp_err_t (* AES128CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + /** Initialize AES128CTR decryption. + * @par Implemented as + * - @ref R_SCE_AES128CTR_DecryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES128CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES128CTR decryption. + * @par Implemented as + * - @ref R_SCE_AES128CTR_DecryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + */ + fsp_err_t (* AES128CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + /** Finalize AES128CTR decryption. + * @par Implemented as + * - @ref R_SCE_AES128CTR_DecryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + */ + fsp_err_t (* AES128CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + /** Initialize AES256CTR encryption. + * @par Implemented as + * - @ref R_SCE_AES256CTR_EncryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES256CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES256CTR encryption. + * @par Implemented as + * - @ref R_SCE_AES256CTR_EncryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area + * @param[in,out] plain_length plaintext data length (must be a multiple of 16) + */ + fsp_err_t (* AES256CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, + uint32_t plain_length); + + /** Finalize AES256CTR encryption. + * @par Implemented as + * - @ref R_SCE_AES256CTR_EncryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] cipher_length ciphertext data length (0 always written here) + */ + fsp_err_t (* AES256CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); + + /** Initialize AES256CTR decryption. + * @par Implemented as + * - @ref R_SCE_AES256CTR_DecryptInit() + * + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) + */ + fsp_err_t (* AES256CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); + + /** Update AES256CTR decryption. + * @par Implemented as + * - @ref R_SCE_AES256CTR_DecryptUpdate() + * + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area + * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) + */ + fsp_err_t (* AES256CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, + uint32_t cipher_length); + + /** Finalize AES256CTR decryption. + * @par Implemented as + * - @ref R_SCE_AES256CTR_DecryptFinal() + * + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] plain_length plaintext data length (0 always written here) + */ + fsp_err_t (* AES256CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + + /** Initialize AES128CMAC generation. + * @par Implemented as + * - @ref R_SCE_AES128CMAC_GenerateInit() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* AES128CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES128CMAC generation. + * @par Implemented as + * - @ref R_SCE_AES128CMAC_GenerateUpdate() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) + */ + fsp_err_t (* AES128CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + /** Finalize AES128CMAC generation. + * @par Implemented as + * - @ref R_SCE_AES128CMAC_GenerateFinal() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (16byte) + */ + fsp_err_t (* AES128CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); + + /** Initialize AES128CMAC verification. + * @par Implemented as + * - @ref R_SCE_AES128CMAC_VerifyInit() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* AES128CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES128CMAC verification. + * @par Implemented as + * - @ref R_SCE_AES128CMAC_VerifyUpdate() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) + */ + fsp_err_t (* AES128CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + /** Finalize AES128CMAC verification. + * @par Implemented as + * - @ref R_SCE_AES128CMAC_VerifyFinal() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (mac_length byte) + * @param[in,out] mac_length MAC data length (2 to 16 bytes) + */ + fsp_err_t (* AES128CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); + + /** Initialize AES256CMAC generation. + * @par Implemented as + * - @ref R_SCE_AES256CMAC_GenerateInit() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + */ + fsp_err_t (* AES256CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES256CMAC generation. + * @par Implemented as + * - @ref R_SCE_AES256CMAC_GenerateUpdate() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) + */ + fsp_err_t (* AES256CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + /** Finalize AES256CMAC generation. + * @par Implemented as + * - @ref R_SCE_AES256CMAC_GenerateFinal() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (16byte) + */ + fsp_err_t (* AES256CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); + + /** Initialize AES256CMAC verification. + * @par Implemented as + * - @ref R_SCE_AES256CMAC_VerifyInit() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + */ + fsp_err_t (* AES256CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); + + /** Update AES256CMAC verification. + * @par Implemented as + * - @ref R_SCE_AES256CMAC_VerifyUpdate() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) + */ + fsp_err_t (* AES256CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); + + /** Finalize AES256CMAC verification. + * @par Implemented as + * - @ref R_SCE_AES256CMAC_VerifyFinal() + * + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (mac_length byte) + * @param[in,out] mac_length MAC data length (2 to 16 bytes) + */ + fsp_err_t (* AES256CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); + + /** Initialize SHA-256 Calculation. + * @par Implemented as + * - @ref R_SCE_SHA256_Init() + * + * @param[in,out] handle SHA handler (work area) + */ + fsp_err_t (* SHA256_Init)(sce_sha_md5_handle_t * handle); + + /** Update SHA-256 Calculation. + * @par Implemented as + * - @ref R_SCE_SHA256_Update() + * + * @param[in,out] handle SHA handler (work area) + * @param[in] message message data area + * @param[in] message_length message data length + */ + fsp_err_t (* SHA256_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); + + /** Finalize SHA-256 Calculation. + * @par Implemented as + * - @ref R_SCE_SHA256_Final() + * + * @param[in,out] handle SHA handler (work area) + * @param[in,out] digest hasha data area + * @param[in,out] digest_length hash data length (32bytes) + */ + fsp_err_t (* SHA256_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); + + /** Initialize SHA-224 Calculation. + * @par Implemented as + * - @ref R_SCE_SHA224_Init() + * + * @param[in,out] handle SHA handler (work area) + */ + fsp_err_t (* SHA224_Init)(sce_sha_md5_handle_t * handle); + + /** Update SHA-224 Calculation. + * @par Implemented as + * - @ref R_SCE_SHA224_Update() + * + * @param[in,out] handle SHA handler (work area) + * @param[in] message message data area + * @param[in] message_length message data length + */ + fsp_err_t (* SHA224_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); + + /** Finalize SHA-224 Calculation. + * @par Implemented as + * - @ref R_SCE_SHA224_Final() + * + * @param[in,out] handle SHA handler (work area) + * @param[in,out] digest hasha data area + * @param[in,out] digest_length hash data length (32bytes) + */ + fsp_err_t (* SHA224_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); + + /** This API outputs 1024-bit RSA wrapped pair key. + * @par Implemented as + * - @ref R_SCE_RSA1024_WrappedKeyPairGenerate() + * + * @param[in,out] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* RSA1024_WrappedKeyPairGenerate)(sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key); + + /** This API outputs 2048-bit RSA wrapped pair key. + * @par Implemented as + * - @ref R_SCE_RSA2048_WrappedKeyPairGenerate() + * + * @param[in,out] wrapped_key 128-bit AES wrapped key + */ + fsp_err_t (* RSA2048_WrappedKeyPairGenerate)(sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key); + + /** This API outputs 1024-bit RSA public wrapped key. + * @par Implemented as + * - @ref R_SCE_RSA1024_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 1024-bit RSA public wrapped key + */ + fsp_err_t (* RSA1024_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_public_wrapped_key_t * wrapped_key); + + /** This API outputs 1024-bit RSA private wrapped key. + * @par Implemented as + * - @ref R_SCE_RSA1024_EncryptedPrivateKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 1024-bit RSA private wrapped key + */ + fsp_err_t (* RSA1024_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_private_wrapped_key_t * wrapped_key); + + /** This API outputs 2048-bit RSA public wrapped key. + * @par Implemented as + * - @ref R_SCE_RSA2048_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 2048-bit RSA public wrapped key + */ + fsp_err_t (* RSA2048_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_public_wrapped_key_t * wrapped_key); + + /** This API outputs 2048-bit RSA private wrapped key. + * @par Implemented as + * - @ref R_SCE_RSA2048_EncryptedPrivateKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 2048-bit RSA private wrapped key + */ + fsp_err_t (* RSA2048_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_private_wrapped_key_t * wrapped_key); + + /** This API outputs 4096-bit RSA public wrapped key. + * @par Implemented as + * - @ref R_SCE_RSA4096_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key 4096-bit RSA public wrapped key + */ + fsp_err_t (* RSA4096_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa4096_public_wrapped_key_t * wrapped_key); + + /** RSASSA-PKCS1-V1_5 signature generation. + * @par Implemented as + * - @ref R_SCE_RSASSA_PKCS1024_SignatureGenerate() + * + * @param[in] message_hash Message or hash value to which to attach signature + * @param[in,out] signature Signature text storage destination information + * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + */ + fsp_err_t (* RSASSA_PKCS1024_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, + sce_rsa_byte_data_t * signature, sce_rsa1024_private_wrapped_key_t * wrapped_key, uint8_t hash_type); + + /** RSASSA-PKCS1-V1_5 signature generation. + * @par Implemented as + * - @ref R_SCE_RSASSA_PKCS2048_SignatureGenerate() + * + * @param[in] message_hash Message or hash value to which to attach signature + * @param[in,out] signature Signature text storage destination information + * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + */ + fsp_err_t (* RSASSA_PKCS2048_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, + sce_rsa_byte_data_t * signature, sce_rsa2048_private_wrapped_key_t * wrapped_key, uint8_t hash_type); + + /** RSASSA-PKCS1-V1_5 signature verification. + * @par Implemented as + * - @ref R_SCE_RSASSA_PKCS1024_SignatureVerify() + * + * @param[in] signature Signature text information to verify + * @param[in] message_hash Message text or hash value to verify + * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + */ + fsp_err_t (* RSASSA_PKCS1024_SignatureVerify)(sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, sce_rsa1024_public_wrapped_key_t * wrapped_key, uint8_t hash_type); + + /** RSASSA-PKCS1-V1_5 signature verification. + * @par Implemented as + * - @ref R_SCE_RSASSA_PKCS2048_SignatureVerify() + * + * @param[in] signature Signature text information to verify + * @param[in] message_hash Message text or hash value to verify + * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + */ + fsp_err_t (* RSASSA_PKCS2048_SignatureVerify)(sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, sce_rsa2048_public_wrapped_key_t * wrapped_key, uint8_t hash_type); + + /** RSASSA-PKCS1-V1_5 signature verification. + * @par Implemented as + * - @ref R_SCE_RSASSA_PKCS4096_SignatureVerify() + * + * @param[in] signature Signature text information to verify + * @param[in] message_hash Message text or hash value to verify + * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + */ + fsp_err_t (* RSASSA_PKCS4096_SignatureVerify)(sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, sce_rsa4096_public_wrapped_key_t * wrapped_key, uint8_t hash_type); + + /** RSAES-PKCS1-V1_5 encryption. + * @par Implemented as + * - @ref R_SCE_RSAES_PKCS1024_Encrypt() + * + * @param[in] plain plaintext + * @param[in,out] cipher ciphertext + * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. + */ + fsp_err_t (* RSAES_PKCS1024_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, + sce_rsa1024_public_wrapped_key_t * wrapped_key); + + /** RSAES-PKCS1-V1_5 encryption. + * @par Implemented as + * - @ref R_SCE_RSAES_PKCS2048_Encrypt() + * + * @param[in] plain plaintext + * @param[in,out] cipher ciphertext + * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. + */ + fsp_err_t (* RSAES_PKCS2048_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, + sce_rsa2048_public_wrapped_key_t * wrapped_key); + + /** RSAES-PKCS1-V1_5 encryption. + * @par Implemented as + * - @ref R_SCE_RSAES_PKCS4096_Encrypt() + * + * @param[in] plain plaintext + * @param[in,out] cipher ciphertext + * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. + */ + fsp_err_t (* RSAES_PKCS4096_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, + sce_rsa4096_public_wrapped_key_t * wrapped_key); + + /** RSAES-PKCS1-V1_5 decryption. + * @par Implemented as + * - @ref R_SCE_RSAES_PKCS1024_Decrypt() + * + * @param[in] cipher ciphertext + * @param[in,out] plain plaintext + * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. + */ + fsp_err_t (* RSAES_PKCS1024_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, + sce_rsa1024_private_wrapped_key_t * wrapped_key); + + /** RSAES-PKCS1-V1_5 decryption. + * @par Implemented as + * - @ref R_SCE_RSAES_PKCS2048_Decrypt() + * + * @param[in] cipher ciphertext + * @param[in,out] plain plaintext + * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. + */ + fsp_err_t (* RSAES_PKCS2048_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, + sce_rsa2048_private_wrapped_key_t * wrapped_key); + + /** This API outputs secp192r1 wrapped pair key. + * @par Implemented as + * - @ref R_SCE_ECC_secp192r1_WrappedKeyPairGenerate() + * + * @param[in,out] wrapped_pair_key Wrapped pair key for secp192r1 public key and private key pair + */ + fsp_err_t (* ECC_secp192r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + /** This API outputs secp224r1 wrapped pair key. + * @par Implemented as + * - @ref R_SCE_ECC_secp224r1_WrappedKeyPairGenerate() + * + * @param[in,out] wrapped_pair_key Wrapped pair key for secp224r1 public key and private key pair + */ + fsp_err_t (* ECC_secp224r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + /** This API outputs secp256r1 wrapped pair key. + * @par Implemented as + * - @ref R_SCE_ECC_secp256r1_WrappedKeyPairGenerate() + * + * @param[in,out] wrapped_pair_key Wrapped pair key for secp256r1 public key and private key pair + */ + fsp_err_t (* ECC_secp256r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + /** This API outputs BrainpoolP512r1 wrapped pair key. + * @par Implemented as + * - @ref R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate() + * + * @param[in,out] wrapped_pair_key Wrapped pair key for BrainpoolP512r1 public key and private key pair + */ + fsp_err_t (* ECC_BrainpoolP512r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); + + /** This API outputs secp192r1 public wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp192r1 public wrapped key + */ + fsp_err_t (* ECC_secp192r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** This API outputs secp224r1 public wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp224r1 public wrapped key + */ + fsp_err_t (* ECC_secp224r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** This API outputs secp256r1 public wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp256r1 public wrapped key + */ + fsp_err_t (* ECC_secp256r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** This API outputs BrainpoolP512r1 public wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key BrainpoolP512r1 public wrapped key + */ + fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** This API outputs secp192r1 private wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp192r1 private wrapped key + */ + fsp_err_t (* ECC_secp192r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** This API outputs secp224r1 private wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp224r1 private wrapped key + */ + fsp_err_t (* ECC_secp224r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** This API outputs secp256r1 private wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key secp256r1 private wrapped key + */ + fsp_err_t (* ECC_secp256r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** This API outputs BrainpoolP512r1 private wrapped key. + * @par Implemented as + * - @ref R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap() + * + * @param[in] initial_vector Initialization vector when generating encrypted_key + * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key BrainpoolP512r1 private wrapped key + */ + fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** ECDSA signature generation. + * @par Implemented as + * - @ref R_SCE_ECDSA_secp192r1_SignatureGenerate() + * + * @param[in] message_hash Message or hash value to which to attach signature + * @param[in,out] signature Signature text storage destination information + * @param[in] wrapped_key Input wrapped key of secp192r1 private key. + */ + fsp_err_t (* ECDSA_secp192r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** ECDSA signature generation. + * @par Implemented as + * - @ref R_SCE_ECDSA_secp224r1_SignatureGenerate() + * + * @param[in] message_hash Message or hash value to which to attach signature + * @param[in,out] signature Signature text storage destination information + * @param[in] wrapped_key Input wrapped key of secp224r1 private key. + */ + fsp_err_t (* ECDSA_secp224r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** ECDSA signature generation. + * @par Implemented as + * - @ref R_SCE_ECDSA_secp256r1_SignatureGenerate() + * + * @param[in] message_hash Message or hash value to which to attach signature + * @param[in,out] signature Signature text storage destination information + * @param[in] wrapped_key Input wrapped key of secp256r1 private key. + */ + fsp_err_t (* ECDSA_secp256r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** ECDSA signature generation. + * @par Implemented as + * - @ref R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate() + * + * @param[in] message_hash Message or hash value to which to attach signature + * @param[in,out] signature Signature text storage destination information + * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 private key. + */ + fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); + + /** ECDSA signature verification. + * @par Implemented as + * - @ref R_SCE_ECDSA_secp192r1_SignatureVerify() + * + * @param[in] signature Signature text information to be verified + * @param[in,out] message_hash Message or hash value to be verified + * @param[in] wrapped_key Input wrapped key of secp192r1 public key. + */ + fsp_err_t (* ECDSA_secp192r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** ECDSA signature verification. + * @par Implemented as + * - @ref R_SCE_ECDSA_secp224r1_SignatureVerify() + * + * @param[in] signature Signature text information to be verified + * @param[in,out] message_hash Message or hash value to be verified + * @param[in] wrapped_key Input wrapped key of secp224r1 public key. + */ + fsp_err_t (* ECDSA_secp224r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** ECDSA signature verification. + * @par Implemented as + * - @ref R_SCE_ECDSA_secp256r1_SignatureVerify() + * + * @param[in] signature Signature text information to be verified + * @param[in,out] message_hash Message or hash value to be verified + * @param[in] wrapped_key Input wrapped key of secp256r1 public key. + */ + fsp_err_t (* ECDSA_secp256r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + + /** ECDSA signature verification. + * @par Implemented as + * - @ref R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify() + * + * @param[in] signature Signature text information to be verified + * @param[in,out] message_hash Message or hash value to be verified + * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 public key. + */ + fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); } sce_api_t; /** This structure encompasses everything that is needed to use an instance of this interface. */ typedef struct st_sce_instance { - sce_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance - sce_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance - sce_api_t const * p_api; ///< Pointer to the API structure for this instance + sce_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance + sce_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance + sce_api_t const * p_api; ///< Pointer to the API structure for this instance } sce_instance_t; -#endif /* R_SCE_API_H */ +#endif /* R_SCE_API_H */ /*******************************************************************************************************************//** * @} (end addtogroup SCE_PROTECTED_API) diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/inc/instances/r_sce.h b/core/arch/arm/plat-rz/common/drivers/r_sce/inc/instances/r_sce.h new file mode 100644 index 000000000..580290695 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/inc/instances/r_sce.h @@ -0,0 +1,423 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : r_sce.h + * Version : 1.0 + * Description : SCE API header file + *********************************************************************************************************************/ +/********************************************************************************************************************** + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release + *********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @addtogroup SCE_PROTECTED + * @{ + **********************************************************************************************************************/ + +#include +#include "r_sce_api.h" + +#ifndef R_SCE_H +#define R_SCE_H + + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* Various information. */ +#define HW_SCE_SIZE (0x10000) +#define HW_SCE_SRAM_WORD_SIZE (20U) +#define HW_SCE_SINST_WORD_SIZE (140U) +#define HW_SCE_SINST2_WORD_SIZE (16U) +#define HW_SCE_SHEAP_WORD_SIZE (1496U) +#define HW_SCE_MAC_SIZE (16U) + +/* ECC curve types. */ +#define SCE_ECC_CURVE_TYPE_NIST (0) +#define SCE_ECC_CURVE_TYPE_BRAINPOOL (1) +#define SCE_ECC_CURVE_TYPE_KOBLITZ (2) + +/* ECC curve size */ +#define SCE_ECC_KEY_LENGTH_256 (0) +#define SCE_ECC_KEY_LENGTH_224 (1) +#define SCE_ECC_KEY_LENGTH_192 (2) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/* key index type */ +typedef enum +{ + SCE_KEY_INDEX_TYPE_INVALID = 0U, + SCE_KEY_INDEX_TYPE_AES128, + SCE_KEY_INDEX_TYPE_AES256, + SCE_KEY_INDEX_TYPE_TDES, + SCE_KEY_INDEX_TYPE_HMAC_SHA1, + SCE_KEY_INDEX_TYPE_HMAC_SHA256, + SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE, + SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE, + SCE_KEY_INDEX_TYPE_RSA3072_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA3072_PRIVATE, + SCE_KEY_INDEX_TYPE_RSA4096_PUBLIC, + SCE_KEY_INDEX_TYPE_RSA4096_PRIVATE, + SCE_KEY_INDEX_TYPE_AES128_FOR_TLS, + SCE_KEY_INDEX_TYPE_AES192_FOR_TLS, + SCE_KEY_INDEX_TYPE_AES256_FOR_TLS, + SCE_KEY_INDEX_TYPE_HMAC_SHA1_FOR_TLS, + SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_TLS, + SCE_KEY_INDEX_TYPE_UPDATE_KEY_RING, + SCE_KEY_INDEX_TYPE_TLS_CA_CERTIFICATION_PUBLIC_KEY, + SCE_KEY_INDEX_TYPE_TLS_P256_ECC_KEY, + SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P384_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P384_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P256R1_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P384R1_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_P256R1_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_P384R1_PRIVATE, + SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PUBLIC, + SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PRIVATE, + SCE_KEY_INDEX_TYPE_ECDH_SHARED_SECRET, + SCE_KEY_INDEX_TYPE_AES128_FOR_ECDH, + SCE_KEY_INDEX_TYPE_AES256_FOR_ECDH, + SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_ECDH, + SCE_KEY_INDEX_TYPE_AES128_GCM_FOR_DLMS_COSEM, + SCE_KEY_INDEX_TYPE_AES256_GCM_FOR_DLMS_COSEM, + SCE_KEY_INDEX_TYPE_AES128_KEY_WRAP_FOR_DLMS_COSEM, + SCE_KEY_INDEX_TYPE_AES128_GCM_WITH_IV, +} SCE_KEY_INDEX_TYPE; + +/* OEM Command */ +typedef enum e_sce_oem_cmd +{ + SCE_OEM_CMD_AES128 = 5, + SCE_OEM_CMD_AES256 = 7, + SCE_OEM_CMD_RSA1024_PUBLIC = 10, + SCE_OEM_CMD_RSA1024_PRIVATE, + SCE_OEM_CMD_RSA2048_PUBLIC, + SCE_OEM_CMD_RSA2048_PRIVATE, + SCE_OEM_CMD_RSA3072_PUBLIC, + SCE_OEM_CMD_RSA3072_PRIVATE, + SCE_OEM_CMD_RSA4096_PUBLIC, + SCE_OEM_CMD_RSA4096_PRIVATE, + SCE_OEM_CMD_ECC_P192_PUBLIC, + SCE_OEM_CMD_ECC_P192_PRIVATE, + SCE_OEM_CMD_ECC_P224_PUBLIC, + SCE_OEM_CMD_ECC_P224_PRIVATE, + SCE_OEM_CMD_ECC_P256_PUBLIC, + SCE_OEM_CMD_ECC_P256_PRIVATE, + SCE_OEM_CMD_ECC_P384_PUBLIC, + SCE_OEM_CMD_ECC_P384_PRIVATE, + SCE_OEM_CMD_ECC_P512_PUBLIC, + SCE_OEM_CMD_ECC_P512_PRIVATE, + SCE_OEM_CMD_HMAC_SHA256 = 28, + SCE_OEM_CMD_NUM +} sce_oem_cmd_t; + +/** SCE private control block. DO NOT MODIFY. Initialization occurs when R_SCE_Open() is called. */ +typedef struct st_sce_instance_ctrl +{ + uint32_t open; // Indicates whether the open() API has been successfully +} sce_instance_ctrl_t; + +/********************************************************************************************************************** + * Exported global variables + **********************************************************************************************************************/ +/********************************************************************************************************************** + External global variables + *********************************************************************************************************************/ +/* memory area for SCE procedure */ +extern volatile uint32_t * gp_sce; + +/** @cond INC_HEADER_DEFS_SEC */ +/** Filled in Interface API structure for this Instance. */ +extern const sce_api_t g_sce_protected_on_sce; + +/** @endcond */ + +/********************************************************************************************************************** + * Public Function Prototypes + **********************************************************************************************************************/ +fsp_err_t R_SCE_Open(sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg); +fsp_err_t R_SCE_Close(sce_ctrl_t * const p_ctrl); +fsp_err_t R_SCE_SoftwareReset(void); + +fsp_err_t R_SCE_AES128_WrappedKeyGenerate(sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES256_WrappedKeyGenerate(sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSA1024_WrappedKeyPairGenerate(sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key); +fsp_err_t R_SCE_RSA2048_WrappedKeyPairGenerate(sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key); +fsp_err_t R_SCE_ECC_secp192r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); +fsp_err_t R_SCE_ECC_secp224r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); +fsp_err_t R_SCE_ECC_secp256r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); +fsp_err_t R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); +fsp_err_t R_SCE_RandomNumberGenerate(uint32_t * random); + +fsp_err_t R_SCE_AES128_EncryptedKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES256_EncryptedKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_aes_wrapped_key_t * wrapped_key); + +fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa4096_public_wrapped_key_t * wrapped_key); + +fsp_err_t R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key); + +fsp_err_t R_SCE_AES128ECB_EncryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES128ECB_EncryptUpdate(sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length); +fsp_err_t R_SCE_AES128ECB_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); +fsp_err_t R_SCE_AES128ECB_DecryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES128ECB_DecryptUpdate(sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length); +fsp_err_t R_SCE_AES128ECB_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); +fsp_err_t R_SCE_AES256ECB_EncryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES256ECB_EncryptUpdate(sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length); +fsp_err_t R_SCE_AES256ECB_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); +fsp_err_t R_SCE_AES256ECB_DecryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES256ECB_DecryptUpdate(sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length); +fsp_err_t R_SCE_AES256ECB_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + +fsp_err_t R_SCE_AES128CBC_EncryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES128CBC_EncryptUpdate(sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length); +fsp_err_t R_SCE_AES128CBC_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); +fsp_err_t R_SCE_AES128CBC_DecryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES128CBC_DecryptUpdate(sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length); +fsp_err_t R_SCE_AES128CBC_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); +fsp_err_t R_SCE_AES256CBC_EncryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES256CBC_EncryptUpdate(sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length); +fsp_err_t R_SCE_AES256CBC_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); +fsp_err_t R_SCE_AES256CBC_DecryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES256CBC_DecryptUpdate(sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length); +fsp_err_t R_SCE_AES256CBC_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + +fsp_err_t R_SCE_AES128CTR_EncryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES128CTR_EncryptUpdate(sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length); +fsp_err_t R_SCE_AES128CTR_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); +fsp_err_t R_SCE_AES128CTR_DecryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES128CTR_DecryptUpdate(sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length); +fsp_err_t R_SCE_AES128CTR_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); +fsp_err_t R_SCE_AES256CTR_EncryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES256CTR_EncryptUpdate(sce_aes_handle_t * handle, + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length); +fsp_err_t R_SCE_AES256CTR_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); +fsp_err_t R_SCE_AES256CTR_DecryptInit(sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector); +fsp_err_t R_SCE_AES256CTR_DecryptUpdate(sce_aes_handle_t * handle, + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length); +fsp_err_t R_SCE_AES256CTR_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); + +fsp_err_t R_SCE_AES128CMAC_GenerateInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES128CMAC_GenerateUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); +fsp_err_t R_SCE_AES128CMAC_GenerateFinal(sce_cmac_handle_t * handle, uint8_t * mac); +fsp_err_t R_SCE_AES128CMAC_VerifyInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES128CMAC_VerifyUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); +fsp_err_t R_SCE_AES128CMAC_VerifyFinal(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); +fsp_err_t R_SCE_AES256CMAC_GenerateInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES256CMAC_GenerateUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); +fsp_err_t R_SCE_AES256CMAC_GenerateFinal(sce_cmac_handle_t * handle, uint8_t * mac); +fsp_err_t R_SCE_AES256CMAC_VerifyInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_AES256CMAC_VerifyUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); +fsp_err_t R_SCE_AES256CMAC_VerifyFinal(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); + +fsp_err_t R_SCE_SHA224_Init(sce_sha_md5_handle_t * handle); +fsp_err_t R_SCE_SHA224_Update(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); +fsp_err_t R_SCE_SHA224_Final(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); +fsp_err_t R_SCE_SHA256_Init(sce_sha_md5_handle_t * handle); +fsp_err_t R_SCE_SHA256_Update(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); +fsp_err_t R_SCE_SHA256_Final(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); + +fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate(sce_rsa_byte_data_t * message_hash, + sce_rsa_byte_data_t * signature, + sce_rsa1024_private_wrapped_key_t * wrapped_key, + uint8_t hash_type); +fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureVerify(sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, + sce_rsa1024_public_wrapped_key_t * wrapped_key, + uint8_t hash_type); +fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate(sce_rsa_byte_data_t * message_hash, + sce_rsa_byte_data_t * signature, + sce_rsa2048_private_wrapped_key_t * wrapped_key, + uint8_t hash_type); +fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify(sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, + sce_rsa2048_public_wrapped_key_t * wrapped_key, + uint8_t hash_type); +fsp_err_t R_SCE_RSASSA_PKCS4096_SignatureVerify(sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, + sce_rsa4096_public_wrapped_key_t * wrapped_key, + uint8_t hash_type); + +fsp_err_t R_SCE_RSAES_PKCS1024_Encrypt(sce_rsa_byte_data_t * plain, + sce_rsa_byte_data_t * cipher, + sce_rsa1024_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt(sce_rsa_byte_data_t * cipher, + sce_rsa_byte_data_t * plain, + sce_rsa1024_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSAES_PKCS2048_Encrypt(sce_rsa_byte_data_t * plain, + sce_rsa_byte_data_t * cipher, + sce_rsa2048_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSAES_PKCS2048_Decrypt(sce_rsa_byte_data_t * cipher, + sce_rsa_byte_data_t * plain, + sce_rsa2048_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt(sce_rsa_byte_data_t * plain, + sce_rsa_byte_data_t * cipher, + sce_rsa4096_public_wrapped_key_t * wrapped_key); + +fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); +fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key); + +#endif /* R_SCE_H */ + +/*******************************************************************************************************************//** + * @} (end addtogroup SCE_PROTECTED) + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/private/inc/r_sce_private.h b/core/arch/arm/plat-rz/common/drivers/r_sce/private/inc/r_sce_private.h index f331cef42..583b47834 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/private/inc/r_sce_private.h +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/private/inc/r_sce_private.h @@ -17,13 +17,13 @@ * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. *********************************************************************************************************************/ /********************************************************************************************************************** - * File Name : r_sce_private.h - * Version : 1.0 - * Description : SCE Private API header file + * File Name : r_sce_private.h + * Version : 1.0 + * Description : SCE Private API header file *********************************************************************************************************************/ /********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release *********************************************************************************************************************/ /*********************************************************************************************************************** * Includes @@ -70,10 +70,10 @@ fsp_err_t R_SCE_LoadHukPrivate(lifecycle_t lifecycle); fsp_err_t R_SCE_FwIntegrityCheckPrivate(void); fsp_err_t R_SCE_UpdateOemKeyIndexPrivate(lifecycle_t lifecycle, - sce_oem_cmd_t key_type, - uint8_t * iv, - uint8_t * encrypted_oem_key, - uint32_t * key_index); + sce_oem_cmd_t key_type, + uint8_t * iv, + uint8_t * encrypted_oem_key, + uint32_t * key_index); fsp_err_t R_SCE_Aes128EcbEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); fsp_err_t R_SCE_Aes128EcbEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); @@ -118,51 +118,51 @@ fsp_err_t R_SCE_Aes128CmacGenerateUpdatePrivate(uint32_t * InData_Text, uint32_t fsp_err_t R_SCE_Aes128CmacGenerateFinalPrivate(uint32_t All_Msg_Len, uint32_t * InData_Text, uint32_t * OutData_DataT); fsp_err_t R_SCE_Aes128CmacVerifyInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); fsp_err_t R_SCE_Aes128CmacVerifyUpdatePrivate(uint32_t * InData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes128CmacVerifyFinalPrivate(uint32_t All_Msg_Len, - uint32_t * InData_Text, - uint32_t * InData_DataT, - uint32_t * InData_DataTLen); +fsp_err_t R_SCE_Aes128CmacVerifyFinalPrivate(uint32_t All_Msg_Len, + uint32_t * InData_Text, + uint32_t * InData_DataT, + uint32_t * InData_DataTLen); fsp_err_t R_SCE_Aes256CmacGenerateInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); fsp_err_t R_SCE_Aes256CmacGenerateUpdatePrivate(uint32_t * InData_Text, uint32_t MAX_CNT); fsp_err_t R_SCE_Aes256CmacGenerateFinalPrivate(uint32_t All_Msg_Len, uint32_t * InData_Text, uint32_t * OutData_DataT); fsp_err_t R_SCE_Aes256CmacVerifyInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); fsp_err_t R_SCE_Aes256CmacVerifyUpdatePrivate(uint32_t * InData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes256CmacVerifyFinalPrivate(uint32_t All_Msg_Len, - uint32_t * InData_Text, - uint32_t * InData_DataT, - uint32_t * InData_DataTLen); +fsp_err_t R_SCE_Aes256CmacVerifyFinalPrivate(uint32_t All_Msg_Len, + uint32_t * InData_Text, + uint32_t * InData_DataT, + uint32_t * InData_DataTLen); fsp_err_t R_SCE_Sha224InitPrivate(sce_sha_md5_handle_t * handle); fsp_err_t R_SCE_Sha224UpdatePrivate(sce_sha_md5_handle_t * handle, uint32_t * InData_PaddedMsg, uint32_t MAX_CNT); fsp_err_t R_SCE_Sha224FinalPrivate(sce_sha_md5_handle_t * handle, - uint32_t * InData_PaddedMsg, - uint32_t MAX_CNT, - uint32_t * OutData_MsgDigest, - uint32_t * OutData_Length); + uint32_t * InData_PaddedMsg, + uint32_t MAX_CNT, + uint32_t * OutData_MsgDigest, + uint32_t * OutData_Length); fsp_err_t R_SCE_Sha256InitPrivate(sce_sha_md5_handle_t * handle); fsp_err_t R_SCE_Sha256UpdatePrivate(sce_sha_md5_handle_t * handle, uint32_t * InData_PaddedMsg, uint32_t MAX_CNT); fsp_err_t R_SCE_Sha256FinalPrivate(sce_sha_md5_handle_t * handle, - uint32_t * InData_PaddedMsg, - uint32_t MAX_CNT, - uint32_t * OutData_MsgDigest, - uint32_t * OutData_Length); + uint32_t * InData_PaddedMsg, + uint32_t MAX_CNT, + uint32_t * OutData_MsgDigest, + uint32_t * OutData_Length); fsp_err_t R_SCE_Rsa1024ModularExponentEncryptPrivate(uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text); + uint32_t * InData_Text, + uint32_t * OutData_Text); fsp_err_t R_SCE_Rsa1024ModularExponentDecryptPrivate(uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text); + uint32_t * InData_Text, + uint32_t * OutData_Text); fsp_err_t R_SCE_Rsa2048ModularExponentEncryptPrivate(uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text); + uint32_t * InData_Text, + uint32_t * OutData_Text); fsp_err_t R_SCE_Rsa2048ModularExponentDecryptPrivate(uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text); + uint32_t * InData_Text, + uint32_t * OutData_Text); fsp_err_t R_SCE_Rsa4096ModularExponentEncryptPrivate(uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text); + uint32_t * InData_Text, + uint32_t * OutData_Text); /* --------------------- SCE control procedure related ---------------------- */ @@ -176,62 +176,62 @@ fsp_err_t R_SCE_StateCheckSub(uint32_t *fsm2_number); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_AES128_EncryptedKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_AES256_EncryptedKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(uint32_t *InData_CurveType, - uint32_t *InData_Cmd, - uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); + uint32_t *InData_Cmd, + uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(uint32_t *InData_CurveType, - uint32_t *InData_Cmd, - uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); + uint32_t *InData_Cmd, + uint32_t *InData_IV, + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); + uint32_t *InData_InstData, + uint32_t *OutData_KeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT **/ fsp_err_t R_SCE_GenerateAes128RandomKeyIndexSub(uint32_t * OutData_KeyIndex); @@ -240,24 +240,24 @@ fsp_err_t R_SCE_GenerateAes128RandomKeyIndexSub(uint32_t * OutData_KeyIndex); fsp_err_t R_SCE_GenerateAes256RandomKeyIndexSub(uint32_t * OutData_KeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_GenerateRsa1024RandomKeyIndexSub(uint32_t MAX_CNT, - uint32_t * OutData_PubKeyIndex, - uint32_t * OutData_PrivKeyIndex); +fsp_err_t R_SCE_GenerateRsa1024RandomKeyIndexSub(uint32_t MAX_CNT, + uint32_t * OutData_PubKeyIndex, + uint32_t * OutData_PrivKeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_GenerateRsa2048RandomKeyIndexSub(uint32_t MAX_CNT, - uint32_t * OutData_PubKeyIndex, - uint32_t * OutData_PrivKeyIndex); +fsp_err_t R_SCE_GenerateRsa2048RandomKeyIndexSub(uint32_t MAX_CNT, + uint32_t * OutData_PubKeyIndex, + uint32_t * OutData_PrivKeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_GenerateEccRandomKeyIndexSub(uint32_t * InData_CurveType, - uint32_t * InData_Cmd, - uint32_t * OutData_PubKeyIndex, - uint32_t * OutData_PrivKeyIndex); + uint32_t * InData_Cmd, + uint32_t * OutData_PubKeyIndex, + uint32_t * OutData_PrivKeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_GenerateEccP512RandomKeyIndexSub (uint32_t *OutData_PubKeyIndex, - uint32_t *OutData_PrivKeyIndex); + uint32_t *OutData_PrivKeyIndex); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT **/ fsp_err_t R_SCE_GenerateRandomNumberSub(uint32_t * OutData_Text); @@ -265,11 +265,11 @@ fsp_err_t R_SCE_GenerateRandomNumberSub(uint32_t * OutData_Text); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL * @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_Aes128EncryptDecryptInitSub(const uint32_t * InData_Cmd, - const uint32_t * InData_KeyIndex, - const uint32_t * InData_IV); + const uint32_t * InData_KeyIndex, + const uint32_t * InData_IV); void R_SCE_Aes128EncryptDecryptUpdateSub(const uint32_t * InData_Text, - uint32_t * OutData_Text, - const uint32_t MAX_CNT); + uint32_t * OutData_Text, + const uint32_t MAX_CNT); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_Aes128EncryptDecryptFinalSub(void); @@ -278,11 +278,11 @@ fsp_err_t R_SCE_Aes128EncryptDecryptFinalSub(void); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL * @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_Aes256EncryptDecryptInitSub(const uint32_t * InData_Cmd, - const uint32_t * InData_KeyIndex, - const uint32_t * InData_IV); + const uint32_t * InData_KeyIndex, + const uint32_t * InData_IV); void R_SCE_Aes256EncryptDecryptUpdateSub(const uint32_t * InData_Text, - uint32_t * OutData_Text, - const uint32_t MAX_CNT); + uint32_t * OutData_Text, + const uint32_t MAX_CNT); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_Aes256EncryptDecryptFinalSub(void); @@ -290,87 +290,87 @@ fsp_err_t R_SCE_Aes256EncryptDecryptFinalSub(void); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL * @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_Aes128CmacInitSub(uint32_t * InData_KeyIndex); -void R_SCE_Aes128CmacUpdateSub(uint32_t * InData_Text, uint32_t MAX_CNT); +void R_SCE_Aes128CmacUpdateSub(uint32_t * InData_Text, uint32_t MAX_CNT); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION **/ fsp_err_t R_SCE_Aes128CmacFinalSub(uint32_t * InData_Cmd, - uint32_t * InData_Text, - uint32_t * InData_DataT, - uint32_t * InData_DataTLen, - uint32_t * OutData_DataT); + uint32_t * InData_Text, + uint32_t * InData_DataT, + uint32_t * InData_DataTLen, + uint32_t * OutData_DataT); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL * @retval FSP_ERR_CRYPTO_SCE_FAIL **/ fsp_err_t R_SCE_Aes256CmacInitSub(uint32_t * InData_KeyIndex); -void R_SCE_Aes256CmacUpdateSub(uint32_t * InData_Text, uint32_t MAX_CNT); +void R_SCE_Aes256CmacUpdateSub(uint32_t * InData_Text, uint32_t MAX_CNT); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION **/ fsp_err_t R_SCE_Aes256CmacFinalSub(uint32_t * InData_Cmd, - uint32_t * InData_Text, - uint32_t * InData_DataT, - uint32_t * InData_DataTLen, - uint32_t * OutData_DataT); + uint32_t * InData_Text, + uint32_t * InData_DataT, + uint32_t * InData_DataTLen, + uint32_t * OutData_DataT); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT **/ fsp_err_t R_SCE_Sha224256GenerateMessageDigestSub(const uint32_t * InData_InitVal, - const uint32_t * InData_PaddedMsg, - const uint32_t MAX_CNT, - uint32_t * OutData_MsgDigest); + const uint32_t * InData_PaddedMsg, + const uint32_t MAX_CNT, + uint32_t * OutData_MsgDigest); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ fsp_err_t R_SCE_Rsa1024ModularExponentEncryptSub(const uint32_t * InData_KeyIndex, - const uint32_t * InData_Text, - uint32_t * OutData_Text); + const uint32_t * InData_Text, + uint32_t * OutData_Text); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ -fsp_err_t R_SCE_Rsa1024ModularExponentDecryptSub(uint32_t * InData_KeyIndex, - const uint32_t * InData_Text, - uint32_t * OutData_Text); +fsp_err_t R_SCE_Rsa1024ModularExponentDecryptSub(uint32_t * InData_KeyIndex, + const uint32_t * InData_Text, + uint32_t * OutData_Text); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ fsp_err_t R_SCE_Rsa2048ModularExponentEncryptSub(const uint32_t * InData_KeyIndex, - const uint32_t * InData_Text, - uint32_t * OutData_Text); + const uint32_t * InData_Text, + uint32_t * OutData_Text); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ -fsp_err_t R_SCE_Rsa2048ModularExponentDecryptSub(uint32_t * InData_KeyIndex, - const uint32_t * InData_Text, - uint32_t * OutData_Text); +fsp_err_t R_SCE_Rsa2048ModularExponentDecryptSub(uint32_t * InData_KeyIndex, + const uint32_t * InData_Text, + uint32_t * OutData_Text); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ fsp_err_t R_SCE_Rsa4096ModularExponentEncryptSub(const uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text); + uint32_t * InData_Text, + uint32_t * OutData_Text); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ fsp_err_t R_SCE_EcdsaSignatureGenerateSub(uint32_t * InData_CurveType, - uint32_t * InData_Cmd, - uint32_t * InData_KeyIndex, - uint32_t * InData_MsgDgst, - uint32_t * OutData_Signature); + uint32_t * InData_Cmd, + uint32_t * InData_KeyIndex, + uint32_t * InData_MsgDgst, + uint32_t * OutData_Signature); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ fsp_err_t R_SCE_EcdsaSignatureVerificationSub(uint32_t * InData_CurveType, - uint32_t * InData_Cmd, - uint32_t * InData_KeyIndex, - uint32_t * InData_MsgDgst, - uint32_t * InData_Signature); + uint32_t * InData_Cmd, + uint32_t * InData_KeyIndex, + uint32_t * InData_MsgDgst, + uint32_t * InData_Signature); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ fsp_err_t R_SCE_EcdsaP512SignatureVerificationSub (uint32_t *InData_KeyIndex, - uint32_t *InData_MsgDgst, - uint32_t *InData_Signature); + uint32_t *InData_MsgDgst, + uint32_t *InData_Signature); /** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ fsp_err_t R_SCE_EcdsaP512SignatureGenerateSub (uint32_t *InData_KeyIndex, - uint32_t *InData_MsgDgst, - uint32_t *OutData_Signature); + uint32_t *InData_MsgDgst, + uint32_t *OutData_Signature); uint32_t change_endian_long (volatile uint32_t value); -#endif /* R_SCE_PRIVATE_HEADER_FILE */ +#endif /* R_SCE_PRIVATE_HEADER_FILE */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/private/r_sce_private.c b/core/arch/arm/plat-rz/common/drivers/r_sce/private/r_sce_private.c index 49f815882..b2c498159 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/private/r_sce_private.c +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/private/r_sce_private.c @@ -17,13 +17,13 @@ * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. *********************************************************************************************************************/ /********************************************************************************************************************** - * File Name : r_sce_private.c - * Version : 1.0 - * Description : SCE Private API source file + * File Name : r_sce_private.c + * Version : 1.0 + * Description : SCE Private API source file *********************************************************************************************************************/ /********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release *********************************************************************************************************************/ /*********************************************************************************************************************** @@ -36,52 +36,52 @@ * Macro definitions **********************************************************************************************************************/ #ifndef SCE_HEX_6A09E667 -#define SCE_HEX_6A09E667 (0x6a09e667UL) +#define SCE_HEX_6A09E667 (0x6a09e667UL) #endif #ifndef SCE_HEX_BB67AE85 -#define SCE_HEX_BB67AE85 (0xbb67ae85UL) +#define SCE_HEX_BB67AE85 (0xbb67ae85UL) #endif #ifndef SCE_HEX_3C6EF372 -#define SCE_HEX_3C6EF372 (0x3c6ef372UL) +#define SCE_HEX_3C6EF372 (0x3c6ef372UL) #endif #ifndef SCE_HEX_A54FF53A -#define SCE_HEX_A54FF53A (0xa54ff53aUL) +#define SCE_HEX_A54FF53A (0xa54ff53aUL) #endif #ifndef SCE_HEX_510E527F -#define SCE_HEX_510E527F (0x510e527fUL) +#define SCE_HEX_510E527F (0x510e527fUL) #endif #ifndef SCE_HEX_9B05688C -#define SCE_HEX_9B05688C (0x9b05688cUL) +#define SCE_HEX_9B05688C (0x9b05688cUL) #endif #ifndef SCE_HEX_1F83D9AB -#define SCE_HEX_1F83D9AB (0x1f83d9abUL) +#define SCE_HEX_1F83D9AB (0x1f83d9abUL) #endif #ifndef SCE_HEX_5BE0CD19 -#define SCE_HEX_5BE0CD19 (0x5be0cd19UL) +#define SCE_HEX_5BE0CD19 (0x5be0cd19UL) #endif #ifndef SCE_HEX_C1059ED8 -#define SCE_HEX_C1059ED8 (0xc1059ed8UL) +#define SCE_HEX_C1059ED8 (0xc1059ed8UL) #endif #ifndef SCE_HEX_367CD507 -#define SCE_HEX_367CD507 (0x367cd507UL) +#define SCE_HEX_367CD507 (0x367cd507UL) #endif #ifndef SCE_HEX_3070DD17 -#define SCE_HEX_3070DD17 (0x3070dd17UL) +#define SCE_HEX_3070DD17 (0x3070dd17UL) #endif #ifndef SCE_HEX_F70E5939 -#define SCE_HEX_F70E5939 (0xf70e5939UL) +#define SCE_HEX_F70E5939 (0xf70e5939UL) #endif #ifndef SCE_HEX_FFC00B31 -#define SCE_HEX_FFC00B31 (0xffc00b31UL) +#define SCE_HEX_FFC00B31 (0xffc00b31UL) #endif #ifndef SCE_HEX_68581511 -#define SCE_HEX_68581511 (0x68581511UL) +#define SCE_HEX_68581511 (0x68581511UL) #endif #ifndef SCE_HEX_64F98FA7 -#define SCE_HEX_64F98FA7 (0x64f98fa7UL) +#define SCE_HEX_64F98FA7 (0x64f98fa7UL) #endif #ifndef SCE_HEX_BEFA4FA4 -#define SCE_HEX_BEFA4FA4 (0xbefa4fa4UL) +#define SCE_HEX_BEFA4FA4 (0xbefa4fa4UL) #endif /*********************************************************************************************************************** @@ -109,26 +109,26 @@ * * @param InData_KeyIndex User key generation information area. * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128EcbEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) { - uint32_t indata_cmd = 0; - uint32_t indata_iv[4] = /* dummy */ - { - 0 - }; - - if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(0); /* ECB-Encrypt command */ - - return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); + uint32_t indata_cmd = 0; + uint32_t indata_iv[4] = /* dummy */ + { + 0 + }; + + if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(0); /* ECB-Encrypt command */ + + return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); } /*******************************************************************************************************************//** @@ -136,32 +136,32 @@ fsp_err_t R_SCE_Aes128EcbEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyI * * @param InData_Text Input plain text. * @param OutData_Text Output cipher text. - * @param MAX_CNT Input byte size of plain. + * @param MAX_CNT Input byte size of plain. * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128EcbEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) { - R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Encrypt data to cipher using AES ECB mode algorithm with AES 128 key. * - * @param OutData_Text Output cipher text. + * @param OutData_Text Output cipher text. * @param OutData_length Output byte size of cipher. * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128EcbEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) { - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); - return R_SCE_Aes128EncryptDecryptFinalSub(); + return R_SCE_Aes128EncryptDecryptFinalSub(); } /*******************************************************************************************************************//** @@ -169,26 +169,26 @@ fsp_err_t R_SCE_Aes128EcbEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * * @param InData_KeyIndex User key generation information area. * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128EcbDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) { - uint32_t indata_cmd = 0; - uint32_t indata_iv[4] = /* dummy */ - { - 0 - }; - - if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(1); /* ECB-Decrypt command */ - - return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); + uint32_t indata_cmd = 0; + uint32_t indata_iv[4] = /* dummy */ + { + 0 + }; + + if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(1); /* ECB-Decrypt command */ + + return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); } /*******************************************************************************************************************//** @@ -196,32 +196,32 @@ fsp_err_t R_SCE_Aes128EcbDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyI * * @param InData_Text Input cipher text. * @param OutData_Text Output plain text. - * @param MAX_CNT Input byte size of cipher. + * @param MAX_CNT Input byte size of cipher. * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128EcbDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) { - R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Decrypt data to plain using AES ECB mode algorithm with AES 128 key. * - * @param OutData_Text Output plain text. + * @param OutData_Text Output plain text. * @param OutData_length Output byte size of plain. * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128EcbDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) { - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); - return R_SCE_Aes128EncryptDecryptFinalSub(); + return R_SCE_Aes128EncryptDecryptFinalSub(); } /*******************************************************************************************************************//** @@ -229,26 +229,26 @@ fsp_err_t R_SCE_Aes128EcbDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * * @param InData_KeyIndex User key generation information area. * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256EcbEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) { - uint32_t indata_cmd = 0; - uint32_t indata_iv[4] = /* dummy */ - { - 0 - }; - - if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(0); /* ECB-Encrypt command */ - - return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); + uint32_t indata_cmd = 0; + uint32_t indata_iv[4] = /* dummy */ + { + 0 + }; + + if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(0); /* ECB-Encrypt command */ + + return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); } /*******************************************************************************************************************//** @@ -256,32 +256,32 @@ fsp_err_t R_SCE_Aes256EcbEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyI * * @param InData_Text Input plain text. * @param OutData_Text Output cipher text. - * @param MAX_CNT Input byte size of plain. + * @param MAX_CNT Input byte size of plain. * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256EcbEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) { - R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Encrypt data to cipher using AES ECB mode algorithm with AES 256 key. * - * @param OutData_Text Output cipher text. + * @param OutData_Text Output cipher text. * @param OutData_length Output byte size of cipher. * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256EcbEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) { - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); - return R_SCE_Aes256EncryptDecryptFinalSub(); + return R_SCE_Aes256EncryptDecryptFinalSub(); } /*******************************************************************************************************************//** @@ -289,26 +289,26 @@ fsp_err_t R_SCE_Aes256EcbEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * * @param InData_KeyIndex User key generation information area. * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256EcbDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) { - uint32_t indata_cmd = 0; - uint32_t indata_iv[4] = /* dummy */ - { - 0 - }; - - if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(1); /* ECB-Decrypt command */ - - return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); + uint32_t indata_cmd = 0; + uint32_t indata_iv[4] = /* dummy */ + { + 0 + }; + + if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(1); /* ECB-Decrypt command */ + + return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); } /*******************************************************************************************************************//** @@ -316,56 +316,56 @@ fsp_err_t R_SCE_Aes256EcbDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyI * * @param InData_Text Input cipher text. * @param OutData_Text Output plain text. - * @param MAX_CNT Input byte size of cipher. + * @param MAX_CNT Input byte size of cipher. * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256EcbDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) { - R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Decrypt data to plain using AES ECB mode algorithm with AES 256 key. * - * @param OutData_Text Output plain text. + * @param OutData_Text Output plain text. * @param OutData_length Output byte size of plain. * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256EcbDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) { - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); - return R_SCE_Aes256EncryptDecryptFinalSub(); + return R_SCE_Aes256EncryptDecryptFinalSub(); } /*******************************************************************************************************************//** * Encrypt data to cipher using AES CBC mode algorithm with AES 128 key. * * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. + * @param InData_IV Input initial vector. * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CbcEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) { - uint32_t indata_cmd = 0; + uint32_t indata_cmd = 0; - if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(2); /* CBC-Encrypt command */ + if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(2); /* CBC-Encrypt command */ - return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); + return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); } /*******************************************************************************************************************//** @@ -373,56 +373,56 @@ fsp_err_t R_SCE_Aes128CbcEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyI * * @param InData_Text Input plain text. * @param OutData_Text Output cipher text. - * @param MAX_CNT Input byte size of plain. + * @param MAX_CNT Input byte size of plain. * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CbcEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) { - R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Encrypt data to cipher using AES CBC mode algorithm with AES 128 key. * - * @param OutData_Text Output cipher text. + * @param OutData_Text Output cipher text. * @param OutData_length Output byte size of cipher. * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CbcEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) { - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); - return R_SCE_Aes128EncryptDecryptFinalSub(); + return R_SCE_Aes128EncryptDecryptFinalSub(); } /*******************************************************************************************************************//** * Decrypt data to plain using AES CBC mode algorithm with AES 128 key. * * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. + * @param InData_IV Input initial vector. * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CbcDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) { - uint32_t indata_cmd = 0; + uint32_t indata_cmd = 0; - if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(3); /* CBC-Decrypt command */ + if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(3); /* CBC-Decrypt command */ - return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); + return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); } /*******************************************************************************************************************//** @@ -430,56 +430,56 @@ fsp_err_t R_SCE_Aes128CbcDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyI * * @param InData_Text Input cipher text. * @param OutData_Text Output plain text. - * @param MAX_CNT Input byte size of cipher. + * @param MAX_CNT Input byte size of cipher. * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CbcDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) { - R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Decrypt data to plain using AES CBC mode algorithm with AES 128 key. * - * @param OutData_Text Output plain text. + * @param OutData_Text Output plain text. * @param OutData_length Output byte size of plain. * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CbcDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) { - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); - return R_SCE_Aes128EncryptDecryptFinalSub(); + return R_SCE_Aes128EncryptDecryptFinalSub(); } /*******************************************************************************************************************//** * Encrypt data to cipher using AES CBC mode algorithm with AES 256 key. * * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. + * @param InData_IV Input initial vector. * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CbcEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) { - uint32_t indata_cmd = 0; + uint32_t indata_cmd = 0; - if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(2); /* CBC-Encrypt command */ + if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(2); /* CBC-Encrypt command */ - return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); + return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); } /*******************************************************************************************************************//** @@ -487,56 +487,56 @@ fsp_err_t R_SCE_Aes256CbcEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyI * * @param InData_Text Input plain text. * @param OutData_Text Output cipher text. - * @param MAX_CNT Input byte size of plain. + * @param MAX_CNT Input byte size of plain. * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CbcEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) { - R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Encrypt data to cipher using AES CBC mode algorithm with AES 256 key. * - * @param OutData_Text Output cipher text. + * @param OutData_Text Output cipher text. * @param OutData_length Output byte size of cipher. * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CbcEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) { - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); - return R_SCE_Aes256EncryptDecryptFinalSub(); + return R_SCE_Aes256EncryptDecryptFinalSub(); } /*******************************************************************************************************************//** * Decrypt data to plain using AES CBC mode algorithm with AES 256 key. * * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. + * @param InData_IV Input initial vector. * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CbcDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) { - uint32_t indata_cmd = 0; + uint32_t indata_cmd = 0; - if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(3); /* CBC-Decrypt command */ + if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(3); /* CBC-Decrypt command */ - return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); + return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); } /*******************************************************************************************************************//** @@ -544,56 +544,56 @@ fsp_err_t R_SCE_Aes256CbcDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyI * * @param InData_Text Input cipher text. * @param OutData_Text Output plain text. - * @param MAX_CNT Input byte size of cipher. + * @param MAX_CNT Input byte size of cipher. * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CbcDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) { - R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Decrypt data to plain using AES CBC mode algorithm with AES 256 key. * - * @param OutData_Text Output plain text. + * @param OutData_Text Output plain text. * @param OutData_length Output byte size of plain. * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CbcDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) { - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); - return R_SCE_Aes256EncryptDecryptFinalSub(); + return R_SCE_Aes256EncryptDecryptFinalSub(); } /*******************************************************************************************************************//** * Encrypt data to cipher using AES CTR mode algorithm with AES 128 key. * * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. + * @param InData_IV Input initial vector. * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CtrEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) { - uint32_t indata_cmd = 0; + uint32_t indata_cmd = 0; - if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(4); /* CTR-Encrypt command */ + if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(4); /* CTR-Encrypt command */ - return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); + return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); } /*******************************************************************************************************************//** @@ -601,56 +601,56 @@ fsp_err_t R_SCE_Aes128CtrEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyI * * @param InData_Text Input plain text. * @param OutData_Text Output cipher text. - * @param MAX_CNT Input byte size of plain. + * @param MAX_CNT Input byte size of plain. * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CtrEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) { - R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Encrypt data to cipher using AES CTR mode algorithm with AES 128 key. * - * @param OutData_Text Output cipher text. + * @param OutData_Text Output cipher text. * @param OutData_length Output byte size of cipher. * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CtrEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) { - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); - return R_SCE_Aes128EncryptDecryptFinalSub(); + return R_SCE_Aes128EncryptDecryptFinalSub(); } /*******************************************************************************************************************//** * Decrypt data to plain using AES CTR mode algorithm with AES 128 key. * * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. + * @param InData_IV Input initial vector. * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CtrDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) { - uint32_t indata_cmd = 0; + uint32_t indata_cmd = 0; - if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(4); /* CTR-Decrypt command */ + if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(4); /* CTR-Decrypt command */ - return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); + return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); } /*******************************************************************************************************************//** @@ -658,56 +658,56 @@ fsp_err_t R_SCE_Aes128CtrDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyI * * @param InData_Text Input cipher text. * @param OutData_Text Output plain text. - * @param MAX_CNT Input byte size of cipher. + * @param MAX_CNT Input byte size of cipher. * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CtrDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) { - R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Decrypt data to plain using AES CTR mode algorithm with AES 128 key. * - * @param OutData_Text Output plain text. + * @param OutData_Text Output plain text. * @param OutData_length Output byte size of plain. * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CtrDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) { - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); - return R_SCE_Aes128EncryptDecryptFinalSub(); + return R_SCE_Aes128EncryptDecryptFinalSub(); } /*******************************************************************************************************************//** * Encrypt data to cipher using AES CTR mode algorithm with AES 256 key. * * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. + * @param InData_IV Input initial vector. * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CtrEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) { - uint32_t indata_cmd = 0; + uint32_t indata_cmd = 0; - if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(4); /* CTR-Encrypt command */ + if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(4); /* CTR-Encrypt command */ - return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); + return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); } /*******************************************************************************************************************//** @@ -715,56 +715,56 @@ fsp_err_t R_SCE_Aes256CtrEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyI * * @param InData_Text Input plain text. * @param OutData_Text Output cipher text. - * @param MAX_CNT Input byte size of plain. + * @param MAX_CNT Input byte size of plain. * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CtrEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) { - R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Encrypt data to cipher using AES CTR mode algorithm with AES 256 key. * - * @param OutData_Text Output cipher text. + * @param OutData_Text Output cipher text. * @param OutData_length Output byte size of cipher. * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CtrEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) { - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); - return R_SCE_Aes256EncryptDecryptFinalSub(); + return R_SCE_Aes256EncryptDecryptFinalSub(); } /*******************************************************************************************************************//** * Decrypt data to plain using AES CTR mode algorithm with AES 256 key. * * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. + * @param InData_IV Input initial vector. * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CtrDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) { - uint32_t indata_cmd = 0; + uint32_t indata_cmd = 0; - if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(4); /* CTR-Decrypt command */ + if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) + { + return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; + } + indata_cmd = change_endian_long(4); /* CTR-Decrypt command */ - return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); + return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); } /*******************************************************************************************************************//** @@ -772,32 +772,32 @@ fsp_err_t R_SCE_Aes256CtrDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyI * * @param InData_Text Input cipher text. * @param OutData_Text Output plain text. - * @param MAX_CNT Input byte size of cipher. + * @param MAX_CNT Input byte size of cipher. * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CtrDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) { - R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); + R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Decrypt data to plain using AES CTR mode algorithm with AES 256 key. * - * @param OutData_Text Output plain text. + * @param OutData_Text Output plain text. * @param OutData_length Output byte size of plain. * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CtrDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) { - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); + FSP_PARAMETER_NOT_USED(OutData_Text); + FSP_PARAMETER_NOT_USED(OutData_length); - return R_SCE_Aes256EncryptDecryptFinalSub(); + return R_SCE_Aes256EncryptDecryptFinalSub(); } /*******************************************************************************************************************//** @@ -805,61 +805,61 @@ fsp_err_t R_SCE_Aes256CtrDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * * @param InData_KeyIndex User key generation information area * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CmacGenerateInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) { - return R_SCE_Aes128CmacInitSub(InData_KeyIndex->value); + return R_SCE_Aes128CmacInitSub(InData_KeyIndex->value); } /*******************************************************************************************************************//** * Generates a MAC value from the message specified. * * @param InData_Text Message data area (data_len byte) - * @param MAX_CNT Message data length (0 to arbitrary byte) + * @param MAX_CNT Message data length (0 to arbitrary byte) * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CmacGenerateUpdatePrivate (uint32_t * InData_Text, uint32_t MAX_CNT) { - R_SCE_Aes128CmacUpdateSub(InData_Text, MAX_CNT); + R_SCE_Aes128CmacUpdateSub(InData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Outputs the Mac value. * - * @param All_Msg_Len Input byte size of message data. - * @param InData_Text Input message data. + * @param All_Msg_Len Input byte size of message data. + * @param InData_Text Input message data. * @param OutData_DataT MAC data area (data_len byte) * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Reserved. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CmacGenerateFinalPrivate (uint32_t All_Msg_Len, uint32_t * InData_Text, uint32_t * OutData_DataT) { - uint32_t indata_cmd = 0; - uint32_t indata_datat[4] = /* dummy */ - { - 0 - }; - uint32_t indata_datat_len = 0; /* dummy */ - - if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) - { - indata_cmd = 0; - } - else - { - indata_cmd = 1; - } - - return R_SCE_Aes128CmacFinalSub(&indata_cmd, InData_Text, indata_datat, &indata_datat_len, OutData_DataT); + uint32_t indata_cmd = 0; + uint32_t indata_datat[4] = /* dummy */ + { + 0 + }; + uint32_t indata_datat_len = 0; /* dummy */ + + if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) + { + indata_cmd = 0; + } + else + { + indata_cmd = 1; + } + + return R_SCE_Aes128CmacFinalSub(&indata_cmd, InData_Text, indata_datat, &indata_datat_len, OutData_DataT); } /*******************************************************************************************************************//** @@ -867,64 +867,64 @@ fsp_err_t R_SCE_Aes128CmacGenerateFinalPrivate (uint32_t All_Msg_Len, uint32_t * * * @param InData_KeyIndex User key generation information area * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CmacVerifyInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) { - return R_SCE_Aes128CmacInitSub(InData_KeyIndex->value); + return R_SCE_Aes128CmacInitSub(InData_KeyIndex->value); } /*******************************************************************************************************************//** * Verifies the MAC value. * * @param InData_Text Message data area (data_len byte) - * @param MAX_CNT Message data length (0 to arbitrary byte) + * @param MAX_CNT Message data length (0 to arbitrary byte) * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes128CmacVerifyUpdatePrivate (uint32_t * InData_Text, uint32_t MAX_CNT) { - R_SCE_Aes128CmacUpdateSub(InData_Text, MAX_CNT); + R_SCE_Aes128CmacUpdateSub(InData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Validates the Mac value. * - * @param All_Msg_Len Input byte size of message data. - * @param InData_Text Input message data. - * @param InData_DataT MAC data area (data_len byte) + * @param All_Msg_Len Input byte size of message data. + * @param InData_Text Input message data. + * @param InData_DataT MAC data area (data_len byte) * @param InData_DataTLen MAC data length * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication NG **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CmacVerifyFinalPrivate (uint32_t All_Msg_Len, - uint32_t * InData_Text, - uint32_t * InData_DataT, - uint32_t * InData_DataTLen) +fsp_err_t R_SCE_Aes128CmacVerifyFinalPrivate (uint32_t All_Msg_Len, + uint32_t * InData_Text, + uint32_t * InData_DataT, + uint32_t * InData_DataTLen) { - uint32_t indata_cmd = 0; - uint32_t out_data[4] = - { - 0 - }; - - if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) - { - indata_cmd = 2; - } - else - { - indata_cmd = 3; - } - - return R_SCE_Aes128CmacFinalSub(&indata_cmd, InData_Text, InData_DataT, InData_DataTLen, out_data); + uint32_t indata_cmd = 0; + uint32_t out_data[4] = + { + 0 + }; + + if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) + { + indata_cmd = 2; + } + else + { + indata_cmd = 3; + } + + return R_SCE_Aes128CmacFinalSub(&indata_cmd, InData_Text, InData_DataT, InData_DataTLen, out_data); } /*******************************************************************************************************************//** @@ -932,61 +932,61 @@ fsp_err_t R_SCE_Aes128CmacVerifyFinalPrivate (uint32_t All_Msg_Len, * * @param InData_KeyIndex User key generation information area * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CmacGenerateInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) { - return R_SCE_Aes256CmacInitSub(InData_KeyIndex->value); + return R_SCE_Aes256CmacInitSub(InData_KeyIndex->value); } /*******************************************************************************************************************//** * Generates a MAC value from the message specified. * * @param InData_Text Message data area (data_len byte) - * @param MAX_CNT Message data length (0 to arbitrary byte) + * @param MAX_CNT Message data length (0 to arbitrary byte) * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CmacGenerateUpdatePrivate (uint32_t * InData_Text, uint32_t MAX_CNT) { - R_SCE_Aes256CmacUpdateSub(InData_Text, MAX_CNT); + R_SCE_Aes256CmacUpdateSub(InData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Outputs the Mac value. * - * @param All_Msg_Len Input byte size of message data. - * @param InData_Text Input message data. + * @param All_Msg_Len Input byte size of message data. + * @param InData_Text Input message data. * @param OutData_DataT MAC data area (data_len byte) * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Reserved. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CmacGenerateFinalPrivate (uint32_t All_Msg_Len, uint32_t * InData_Text, uint32_t * OutData_DataT) { - uint32_t indata_cmd = 0; - uint32_t indata_datat[4] = /* dummy */ - { - 0 - }; - uint32_t indata_datat_len = 0; /* dummy */ - - if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) - { - indata_cmd = 0; - } - else - { - indata_cmd = 1; - } - - return R_SCE_Aes256CmacFinalSub(&indata_cmd, InData_Text, indata_datat, &indata_datat_len, OutData_DataT); + uint32_t indata_cmd = 0; + uint32_t indata_datat[4] = /* dummy */ + { + 0 + }; + uint32_t indata_datat_len = 0; /* dummy */ + + if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) + { + indata_cmd = 0; + } + else + { + indata_cmd = 1; + } + + return R_SCE_Aes256CmacFinalSub(&indata_cmd, InData_Text, indata_datat, &indata_datat_len, OutData_DataT); } /*******************************************************************************************************************//** @@ -994,64 +994,64 @@ fsp_err_t R_SCE_Aes256CmacGenerateFinalPrivate (uint32_t All_Msg_Len, uint32_t * * * @param InData_KeyIndex User key generation information area * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CmacVerifyInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) { - return R_SCE_Aes256CmacInitSub(InData_KeyIndex->value); + return R_SCE_Aes256CmacInitSub(InData_KeyIndex->value); } /*******************************************************************************************************************//** * Verifies the MAC value. * * @param InData_Text Message data area (data_len byte) - * @param MAX_CNT Message data length (0 to arbitrary byte) + * @param MAX_CNT Message data length (0 to arbitrary byte) * * @retval FSP_SUCCESS Normal termination. **********************************************************************************************************************/ fsp_err_t R_SCE_Aes256CmacVerifyUpdatePrivate (uint32_t * InData_Text, uint32_t MAX_CNT) { - R_SCE_Aes256CmacUpdateSub(InData_Text, MAX_CNT); + R_SCE_Aes256CmacUpdateSub(InData_Text, MAX_CNT); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Validates the Mac value. * - * @param All_Msg_Len Input byte size of message data. - * @param InData_Text Input message data. - * @param InData_DataT MAC data area (data_len byte) + * @param All_Msg_Len Input byte size of message data. + * @param InData_Text Input message data. + * @param InData_DataT MAC data area (data_len byte) * @param InData_DataTLen MAC data length * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication NG **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CmacVerifyFinalPrivate (uint32_t All_Msg_Len, - uint32_t * InData_Text, - uint32_t * InData_DataT, - uint32_t * InData_DataTLen) +fsp_err_t R_SCE_Aes256CmacVerifyFinalPrivate (uint32_t All_Msg_Len, + uint32_t * InData_Text, + uint32_t * InData_DataT, + uint32_t * InData_DataTLen) { - uint32_t indata_cmd = 0; - uint32_t out_data[4] = - { - 0 - }; - - if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) - { - indata_cmd = 2; - } - else - { - indata_cmd = 3; - } - - return R_SCE_Aes256CmacFinalSub(&indata_cmd, InData_Text, InData_DataT, InData_DataTLen, out_data); + uint32_t indata_cmd = 0; + uint32_t out_data[4] = + { + 0 + }; + + if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) + { + indata_cmd = 2; + } + else + { + indata_cmd = 3; + } + + return R_SCE_Aes256CmacFinalSub(&indata_cmd, InData_Text, InData_DataT, InData_DataTLen, out_data); } /*******************************************************************************************************************//** @@ -1063,88 +1063,88 @@ fsp_err_t R_SCE_Aes256CmacVerifyFinalPrivate (uint32_t All_Msg_Len, **********************************************************************************************************************/ fsp_err_t R_SCE_Sha256InitPrivate (sce_sha_md5_handle_t * handle) { - uint32_t indata_sha256initval[8] = - { - 0 - }; + uint32_t indata_sha256initval[8] = + { + 0 + }; - FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(handle); - indata_sha256initval[0] = change_endian_long(SCE_HEX_6A09E667); - indata_sha256initval[1] = change_endian_long(SCE_HEX_BB67AE85); - indata_sha256initval[2] = change_endian_long(SCE_HEX_3C6EF372); - indata_sha256initval[3] = change_endian_long(SCE_HEX_A54FF53A); - indata_sha256initval[4] = change_endian_long(SCE_HEX_510E527F); - indata_sha256initval[5] = change_endian_long(SCE_HEX_9B05688C); - indata_sha256initval[6] = change_endian_long(SCE_HEX_1F83D9AB); - indata_sha256initval[7] = change_endian_long(SCE_HEX_5BE0CD19); + indata_sha256initval[0] = change_endian_long(SCE_HEX_6A09E667); + indata_sha256initval[1] = change_endian_long(SCE_HEX_BB67AE85); + indata_sha256initval[2] = change_endian_long(SCE_HEX_3C6EF372); + indata_sha256initval[3] = change_endian_long(SCE_HEX_A54FF53A); + indata_sha256initval[4] = change_endian_long(SCE_HEX_510E527F); + indata_sha256initval[5] = change_endian_long(SCE_HEX_9B05688C); + indata_sha256initval[6] = change_endian_long(SCE_HEX_1F83D9AB); + indata_sha256initval[7] = change_endian_long(SCE_HEX_5BE0CD19); - memcpy(handle->current_hash, indata_sha256initval, HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE); + memcpy(handle->current_hash, indata_sha256initval, HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * calculate a hash value * - * @param handle SHA256 handler (work area) + * @param handle SHA256 handler (work area) * @param InData_PaddedMsg Input message. - * @param MAX_CNT Input message length + * @param MAX_CNT Input message length * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict **********************************************************************************************************************/ fsp_err_t R_SCE_Sha256UpdatePrivate (sce_sha_md5_handle_t * handle, uint32_t * InData_PaddedMsg, uint32_t MAX_CNT) { - uint32_t out_data[8] = - { - 0 - }; - fsp_err_t ercd = FSP_SUCCESS; - - FSP_PARAMETER_NOT_USED(handle); - - /*Casting uint32_t pointer is used for address.*/ - ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, - InData_PaddedMsg, - MAX_CNT, - out_data); - memcpy(handle->current_hash, out_data, HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE); - - return ercd; + uint32_t out_data[8] = + { + 0 + }; + fsp_err_t ercd = FSP_SUCCESS; + + FSP_PARAMETER_NOT_USED(handle); + + /*Casting uint32_t pointer is used for address.*/ + ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, + InData_PaddedMsg, + MAX_CNT, + out_data); + memcpy(handle->current_hash, out_data, HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE); + + return ercd; } /*******************************************************************************************************************//** * calculate a hash value * - * @param handle SHA256 handler (work area). - * @param InData_PaddedMsg Input Message data - * @param MAX_CNT Input message length + * @param handle SHA256 handler (work area). + * @param InData_PaddedMsg Input Message data + * @param MAX_CNT Input message length * @param OutData_MsgDigest Output Hash data - * @param OutData_Length Output Hash length + * @param OutData_Length Output Hash length * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict **********************************************************************************************************************/ fsp_err_t R_SCE_Sha256FinalPrivate (sce_sha_md5_handle_t * handle, - uint32_t * InData_PaddedMsg, - uint32_t MAX_CNT, - uint32_t * OutData_MsgDigest, - uint32_t * OutData_Length) + uint32_t * InData_PaddedMsg, + uint32_t MAX_CNT, + uint32_t * OutData_MsgDigest, + uint32_t * OutData_Length) { - fsp_err_t ercd = FSP_SUCCESS; + fsp_err_t ercd = FSP_SUCCESS; - FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(handle); - /*Casting uint32_t pointer is used for address.*/ - ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, - InData_PaddedMsg, - MAX_CNT, - OutData_MsgDigest); - memcpy(handle->current_hash, OutData_MsgDigest, HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE); - *OutData_Length = HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE; + /*Casting uint32_t pointer is used for address.*/ + ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, + InData_PaddedMsg, + MAX_CNT, + OutData_MsgDigest); + memcpy(handle->current_hash, OutData_MsgDigest, HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE); + *OutData_Length = HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE; - return ercd; + return ercd; } /*******************************************************************************************************************//** @@ -1156,179 +1156,179 @@ fsp_err_t R_SCE_Sha256FinalPrivate (sce_sha_md5_handle_t * handle, **********************************************************************************************************************/ fsp_err_t R_SCE_Sha224InitPrivate (sce_sha_md5_handle_t * handle) { - uint32_t indata_sha224initval[8] = - { - 0 - }; + uint32_t indata_sha224initval[8] = + { + 0 + }; - FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(handle); - indata_sha224initval[0] = change_endian_long(SCE_HEX_C1059ED8); - indata_sha224initval[1] = change_endian_long(SCE_HEX_367CD507); - indata_sha224initval[2] = change_endian_long(SCE_HEX_3070DD17); - indata_sha224initval[3] = change_endian_long(SCE_HEX_F70E5939); - indata_sha224initval[4] = change_endian_long(SCE_HEX_FFC00B31); - indata_sha224initval[5] = change_endian_long(SCE_HEX_68581511); - indata_sha224initval[6] = change_endian_long(SCE_HEX_64F98FA7); - indata_sha224initval[7] = change_endian_long(SCE_HEX_BEFA4FA4); + indata_sha224initval[0] = change_endian_long(SCE_HEX_C1059ED8); + indata_sha224initval[1] = change_endian_long(SCE_HEX_367CD507); + indata_sha224initval[2] = change_endian_long(SCE_HEX_3070DD17); + indata_sha224initval[3] = change_endian_long(SCE_HEX_F70E5939); + indata_sha224initval[4] = change_endian_long(SCE_HEX_FFC00B31); + indata_sha224initval[5] = change_endian_long(SCE_HEX_68581511); + indata_sha224initval[6] = change_endian_long(SCE_HEX_64F98FA7); + indata_sha224initval[7] = change_endian_long(SCE_HEX_BEFA4FA4); - memcpy(handle->current_hash, indata_sha224initval, HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE + 4); + memcpy(handle->current_hash, indata_sha224initval, HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE + 4); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** * calculate a hash value * - * @param handle SHA224 handler (work area) + * @param handle SHA224 handler (work area) * @param InData_PaddedMsg Input message. - * @param MAX_CNT Input message length + * @param MAX_CNT Input message length * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict **********************************************************************************************************************/ fsp_err_t R_SCE_Sha224UpdatePrivate (sce_sha_md5_handle_t * handle, uint32_t * InData_PaddedMsg, uint32_t MAX_CNT) { - uint32_t out_data[8] = - { - 0 - }; - fsp_err_t ercd = FSP_SUCCESS; - - FSP_PARAMETER_NOT_USED(handle); - - /*Casting uint32_t pointer is used for address.*/ - ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, - InData_PaddedMsg, - MAX_CNT, - out_data); - memcpy(handle->current_hash, out_data, HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE + 4); - - return ercd; + uint32_t out_data[8] = + { + 0 + }; + fsp_err_t ercd = FSP_SUCCESS; + + FSP_PARAMETER_NOT_USED(handle); + + /*Casting uint32_t pointer is used for address.*/ + ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, + InData_PaddedMsg, + MAX_CNT, + out_data); + memcpy(handle->current_hash, out_data, HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE + 4); + + return ercd; } /*******************************************************************************************************************//** * calculate a hash value * - * @param handle SHA224 handler (work area). - * @param InData_PaddedMsg Input Message data - * @param MAX_CNT Input message length + * @param handle SHA224 handler (work area). + * @param InData_PaddedMsg Input Message data + * @param MAX_CNT Input message length * @param OutData_MsgDigest Output Hash data - * @param OutData_Length Output Hash length + * @param OutData_Length Output Hash length * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict **********************************************************************************************************************/ fsp_err_t R_SCE_Sha224FinalPrivate (sce_sha_md5_handle_t * handle, - uint32_t * InData_PaddedMsg, - uint32_t MAX_CNT, - uint32_t * OutData_MsgDigest, - uint32_t * OutData_Length) + uint32_t * InData_PaddedMsg, + uint32_t MAX_CNT, + uint32_t * OutData_MsgDigest, + uint32_t * OutData_Length) { - fsp_err_t ercd = FSP_SUCCESS; + fsp_err_t ercd = FSP_SUCCESS; - FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(handle); - /*Casting uint32_t pointer is used for address.*/ - ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, - InData_PaddedMsg, - MAX_CNT, - (uint32_t *) handle->current_hash); - memcpy(OutData_MsgDigest, handle->current_hash, HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE); - *OutData_Length = HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE; + /*Casting uint32_t pointer is used for address.*/ + ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, + InData_PaddedMsg, + MAX_CNT, + (uint32_t *) handle->current_hash); + memcpy(OutData_MsgDigest, handle->current_hash, HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE); + *OutData_Length = HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE; - return ercd; + return ercd; } /*******************************************************************************************************************//** * Modular exponentiation operation with RSA 1024bit public key * * @param InData_KeyIndex the public key index information - * @param InData_Text input data - * @param OutData_Text output data + * @param InData_Text input data + * @param OutData_Text output data * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information **********************************************************************************************************************/ fsp_err_t R_SCE_Rsa1024ModularExponentEncryptPrivate (uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text) + uint32_t * InData_Text, + uint32_t * OutData_Text) { - return R_SCE_Rsa1024ModularExponentEncryptSub(InData_KeyIndex, InData_Text, OutData_Text); + return R_SCE_Rsa1024ModularExponentEncryptSub(InData_KeyIndex, InData_Text, OutData_Text); } /*******************************************************************************************************************//** * Modular exponentiation operation with RSA 1024bit private key * * @param InData_KeyIndex the private key index information - * @param InData_Text input data - * @param OutData_Text output data + * @param InData_Text input data + * @param OutData_Text output data * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information **********************************************************************************************************************/ fsp_err_t R_SCE_Rsa1024ModularExponentDecryptPrivate (uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text) + uint32_t * InData_Text, + uint32_t * OutData_Text) { - return R_SCE_Rsa1024ModularExponentDecryptSub(InData_KeyIndex, InData_Text, OutData_Text); + return R_SCE_Rsa1024ModularExponentDecryptSub(InData_KeyIndex, InData_Text, OutData_Text); } /*******************************************************************************************************************//** * Modular exponentiation operation with RSA 2048bit public key * * @param InData_KeyIndex the public key index information - * @param InData_Text input data - * @param OutData_Text output data + * @param InData_Text input data + * @param OutData_Text output data * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information **********************************************************************************************************************/ fsp_err_t R_SCE_Rsa2048ModularExponentEncryptPrivate (uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text) + uint32_t * InData_Text, + uint32_t * OutData_Text) { - return R_SCE_Rsa2048ModularExponentEncryptSub(InData_KeyIndex, InData_Text, OutData_Text); + return R_SCE_Rsa2048ModularExponentEncryptSub(InData_KeyIndex, InData_Text, OutData_Text); } /*******************************************************************************************************************//** * Modular exponentiation operation with RSA 2048bit private key * * @param InData_KeyIndex the private key index information - * @param InData_Text input data - * @param OutData_Text output data + * @param InData_Text input data + * @param OutData_Text output data * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information **********************************************************************************************************************/ fsp_err_t R_SCE_Rsa2048ModularExponentDecryptPrivate (uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text) + uint32_t * InData_Text, + uint32_t * OutData_Text) { - return R_SCE_Rsa2048ModularExponentDecryptSub(InData_KeyIndex, InData_Text, OutData_Text); + return R_SCE_Rsa2048ModularExponentDecryptSub(InData_KeyIndex, InData_Text, OutData_Text); } /*******************************************************************************************************************//** * Modular exponentiation operation with RSA 4096bit public key * * @param InData_KeyIndex the public key index information - * @param InData_Text input data - * @param OutData_Text output data + * @param InData_Text input data + * @param OutData_Text output data * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information **********************************************************************************************************************/ fsp_err_t R_SCE_Rsa4096ModularExponentEncryptPrivate (uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text) + uint32_t * InData_Text, + uint32_t * OutData_Text) { - return R_SCE_Rsa4096ModularExponentEncryptSub(InData_KeyIndex, InData_Text, OutData_Text); + return R_SCE_Rsa4096ModularExponentEncryptSub(InData_KeyIndex, InData_Text, OutData_Text); } /*******************************************************************************************************************//** @@ -1341,6 +1341,6 @@ fsp_err_t R_SCE_Rsa4096ModularExponentEncryptPrivate (uint32_t * InData_KeyIndex uint32_t change_endian_long (volatile uint32_t data) { - return ((((data) & 0xFF000000) >> 24) | (((data) & 0x00FF0000) >> 8) | (((data) & 0x0000FF00) << 8) | - (((data) & 0x000000FF) << 24)); + return ((((data) & 0xFF000000) >> 24) | (((data) & 0x00FF0000) >> 8) | (((data) & 0x0000FF00) << 8) | + (((data) & 0x000000FF) << 24)); } \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce.c b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce.c index 931ba0ef1..c9f3f9308 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce.c +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce.c @@ -17,13 +17,13 @@ * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. *********************************************************************************************************************/ /********************************************************************************************************************** - * File Name : r_sce.c - * Version : 1.0 - * Description : SCE Common Public API source file + * File Name : r_sce.c + * Version : 1.0 + * Description : SCE Common Public API source file *********************************************************************************************************************/ /********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release *********************************************************************************************************************/ @@ -36,8 +36,8 @@ /*********************************************************************************************************************** * Macro definitions **********************************************************************************************************************/ -#define HW_STATE_UNAVAILABLE (1) -#define HW_STATE_AVAILABLE (2) +#define HW_STATE_UNAVAILABLE (1) +#define HW_STATE_AVAILABLE (2) /* 5*(key_length/2)*2 is recommended by NIST FIPS186-4 */ #define SCE_RSA_RETRY_COUNT_FOR_RSA1024_KEY_GENERATION (5*(1024/2)*2) @@ -64,7 +64,7 @@ uint32_t S_RAM[HW_SCE_SRAM_WORD_SIZE]; uint32_t S_HEAP[HW_SCE_SHEAP_WORD_SIZE]; uint32_t S_INST2[HW_SCE_SINST2_WORD_SIZE]; -uint32_t g_private_id_counter; +uint32_t g_private_id_counter; extern uint32_t g_aes128ecbenc_private_id; extern uint32_t g_aes128ecbdec_private_id; extern uint32_t g_aes256ecbenc_private_id; @@ -86,105 +86,105 @@ extern uint32_t g_sha256_private_id; const sce_api_t g_sce_protected_on_sce = { - .open = R_SCE_Open, - .close = R_SCE_Close, - .softwareReset = R_SCE_SoftwareReset, - .randomNumberGenerate = R_SCE_RandomNumberGenerate, - .AES128_WrappedKeyGenerate = R_SCE_AES128_WrappedKeyGenerate, - .AES256_WrappedKeyGenerate = R_SCE_AES256_WrappedKeyGenerate, - .AES128_EncryptedKeyWrap = R_SCE_AES128_EncryptedKeyWrap, - .AES256_EncryptedKeyWrap = R_SCE_AES256_EncryptedKeyWrap, - .AES128ECB_EncryptInit = R_SCE_AES128ECB_EncryptInit, - .AES128ECB_EncryptUpdate = R_SCE_AES128ECB_EncryptUpdate, - .AES128ECB_EncryptFinal = R_SCE_AES128ECB_EncryptFinal, - .AES128ECB_DecryptInit = R_SCE_AES128ECB_DecryptInit, - .AES128ECB_DecryptUpdate = R_SCE_AES128ECB_DecryptUpdate, - .AES128ECB_DecryptFinal = R_SCE_AES128ECB_DecryptFinal, - .AES256ECB_EncryptInit = R_SCE_AES256ECB_EncryptInit, - .AES256ECB_EncryptUpdate = R_SCE_AES256ECB_EncryptUpdate, - .AES256ECB_EncryptFinal = R_SCE_AES256ECB_EncryptFinal, - .AES256ECB_DecryptInit = R_SCE_AES256ECB_DecryptInit, - .AES256ECB_DecryptUpdate = R_SCE_AES256ECB_DecryptUpdate, - .AES256ECB_DecryptFinal = R_SCE_AES256ECB_DecryptFinal, - .AES128CBC_EncryptInit = R_SCE_AES128CBC_EncryptInit, - .AES128CBC_EncryptUpdate = R_SCE_AES128CBC_EncryptUpdate, - .AES128CBC_EncryptFinal = R_SCE_AES128CBC_EncryptFinal, - .AES128CBC_DecryptInit = R_SCE_AES128CBC_DecryptInit, - .AES128CBC_DecryptUpdate = R_SCE_AES128CBC_DecryptUpdate, - .AES128CBC_DecryptFinal = R_SCE_AES128CBC_DecryptFinal, - .AES256CBC_EncryptInit = R_SCE_AES256CBC_EncryptInit, - .AES256CBC_EncryptUpdate = R_SCE_AES256CBC_EncryptUpdate, - .AES256CBC_EncryptFinal = R_SCE_AES256CBC_EncryptFinal, - .AES256CBC_DecryptInit = R_SCE_AES256CBC_DecryptInit, - .AES256CBC_DecryptUpdate = R_SCE_AES256CBC_DecryptUpdate, - .AES256CBC_DecryptFinal = R_SCE_AES256CBC_DecryptFinal, - .AES128CTR_EncryptInit = R_SCE_AES128CTR_EncryptInit, - .AES128CTR_EncryptUpdate = R_SCE_AES128CTR_EncryptUpdate, - .AES128CTR_EncryptFinal = R_SCE_AES128CTR_EncryptFinal, - .AES128CTR_DecryptInit = R_SCE_AES128CTR_DecryptInit, - .AES128CTR_DecryptUpdate = R_SCE_AES128CTR_DecryptUpdate, - .AES128CTR_DecryptFinal = R_SCE_AES128CTR_DecryptFinal, - .AES256CTR_EncryptInit = R_SCE_AES256CTR_EncryptInit, - .AES256CTR_EncryptUpdate = R_SCE_AES256CTR_EncryptUpdate, - .AES256CTR_EncryptFinal = R_SCE_AES256CTR_EncryptFinal, - .AES256CTR_DecryptInit = R_SCE_AES256CTR_DecryptInit, - .AES256CTR_DecryptUpdate = R_SCE_AES256CTR_DecryptUpdate, - .AES256CTR_DecryptFinal = R_SCE_AES256CTR_DecryptFinal, - .AES128CMAC_GenerateInit = R_SCE_AES128CMAC_GenerateInit, - .AES128CMAC_GenerateUpdate = R_SCE_AES128CMAC_GenerateUpdate, - .AES128CMAC_GenerateFinal = R_SCE_AES128CMAC_GenerateFinal, - .AES128CMAC_VerifyInit = R_SCE_AES128CMAC_VerifyInit, - .AES128CMAC_VerifyUpdate = R_SCE_AES128CMAC_VerifyUpdate, - .AES128CMAC_VerifyFinal = R_SCE_AES128CMAC_VerifyFinal, - .AES256CMAC_GenerateInit = R_SCE_AES256CMAC_GenerateInit, - .AES256CMAC_GenerateUpdate = R_SCE_AES256CMAC_GenerateUpdate, - .AES256CMAC_GenerateFinal = R_SCE_AES256CMAC_GenerateFinal, - .AES256CMAC_VerifyInit = R_SCE_AES256CMAC_VerifyInit, - .AES256CMAC_VerifyUpdate = R_SCE_AES256CMAC_VerifyUpdate, - .AES256CMAC_VerifyFinal = R_SCE_AES256CMAC_VerifyFinal, - .SHA224_Init = R_SCE_SHA224_Init, - .SHA224_Update = R_SCE_SHA224_Update, - .SHA224_Final = R_SCE_SHA224_Final, - .SHA256_Init = R_SCE_SHA256_Init, - .SHA256_Update = R_SCE_SHA256_Update, - .SHA256_Final = R_SCE_SHA256_Final, - .RSA1024_WrappedKeyPairGenerate = R_SCE_RSA1024_WrappedKeyPairGenerate, - .RSA2048_WrappedKeyPairGenerate = R_SCE_RSA2048_WrappedKeyPairGenerate, - .RSA1024_EncryptedPublicKeyWrap = R_SCE_RSA1024_EncryptedPublicKeyWrap, - .RSA1024_EncryptedPrivateKeyWrap = R_SCE_RSA1024_EncryptedPrivateKeyWrap, - .RSA2048_EncryptedPublicKeyWrap = R_SCE_RSA2048_EncryptedPublicKeyWrap, - .RSA2048_EncryptedPrivateKeyWrap = R_SCE_RSA2048_EncryptedPrivateKeyWrap, - .RSA4096_EncryptedPublicKeyWrap = R_SCE_RSA4096_EncryptedPublicKeyWrap, - .RSASSA_PKCS1024_SignatureGenerate = R_SCE_RSASSA_PKCS1024_SignatureGenerate, - .RSASSA_PKCS2048_SignatureGenerate = R_SCE_RSASSA_PKCS2048_SignatureGenerate, - .RSASSA_PKCS1024_SignatureVerify = R_SCE_RSASSA_PKCS1024_SignatureVerify, - .RSASSA_PKCS2048_SignatureVerify = R_SCE_RSASSA_PKCS2048_SignatureVerify, - .RSASSA_PKCS4096_SignatureVerify = R_SCE_RSASSA_PKCS4096_SignatureVerify, - .RSAES_PKCS1024_Encrypt = R_SCE_RSAES_PKCS1024_Encrypt, - .RSAES_PKCS2048_Encrypt = R_SCE_RSAES_PKCS2048_Encrypt, - .RSAES_PKCS4096_Encrypt = R_SCE_RSAES_PKCS4096_Encrypt, - .RSAES_PKCS1024_Decrypt = R_SCE_RSAES_PKCS1024_Decrypt, - .RSAES_PKCS2048_Decrypt = R_SCE_RSAES_PKCS2048_Decrypt, - .ECC_secp192r1_WrappedKeyPairGenerate = R_SCE_ECC_secp192r1_WrappedKeyPairGenerate, - .ECC_secp224r1_WrappedKeyPairGenerate = R_SCE_ECC_secp224r1_WrappedKeyPairGenerate, - .ECC_secp256r1_WrappedKeyPairGenerate = R_SCE_ECC_secp256r1_WrappedKeyPairGenerate, - .ECC_BrainpoolP512r1_WrappedKeyPairGenerate = R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate, - .ECC_secp192r1_EncryptedPublicKeyWrap = R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap, - .ECC_secp224r1_EncryptedPublicKeyWrap = R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap, - .ECC_secp256r1_EncryptedPublicKeyWrap = R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap, - .ECC_BrainpoolP512r1_EncryptedPublicKeyWrap = R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap, - .ECC_secp192r1_EncryptedPrivateKeyWrap = R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap, - .ECC_secp224r1_EncryptedPrivateKeyWrap = R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap, - .ECC_secp256r1_EncryptedPrivateKeyWrap = R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap, - .ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap = R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap, - .ECDSA_secp192r1_SignatureGenerate = R_SCE_ECDSA_secp192r1_SignatureGenerate, - .ECDSA_secp224r1_SignatureGenerate = R_SCE_ECDSA_secp224r1_SignatureGenerate, - .ECDSA_secp256r1_SignatureGenerate = R_SCE_ECDSA_secp256r1_SignatureGenerate, - .ECDSA_BrainpoolP512r1_SignatureGenerate = R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate, - .ECDSA_secp192r1_SignatureVerify = R_SCE_ECDSA_secp192r1_SignatureVerify, - .ECDSA_secp224r1_SignatureVerify = R_SCE_ECDSA_secp224r1_SignatureVerify, - .ECDSA_secp256r1_SignatureVerify = R_SCE_ECDSA_secp256r1_SignatureVerify, - .ECDSA_BrainpoolP512r1_SignatureVerify = R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify, + .open = R_SCE_Open, + .close = R_SCE_Close, + .softwareReset = R_SCE_SoftwareReset, + .randomNumberGenerate = R_SCE_RandomNumberGenerate, + .AES128_WrappedKeyGenerate = R_SCE_AES128_WrappedKeyGenerate, + .AES256_WrappedKeyGenerate = R_SCE_AES256_WrappedKeyGenerate, + .AES128_EncryptedKeyWrap = R_SCE_AES128_EncryptedKeyWrap, + .AES256_EncryptedKeyWrap = R_SCE_AES256_EncryptedKeyWrap, + .AES128ECB_EncryptInit = R_SCE_AES128ECB_EncryptInit, + .AES128ECB_EncryptUpdate = R_SCE_AES128ECB_EncryptUpdate, + .AES128ECB_EncryptFinal = R_SCE_AES128ECB_EncryptFinal, + .AES128ECB_DecryptInit = R_SCE_AES128ECB_DecryptInit, + .AES128ECB_DecryptUpdate = R_SCE_AES128ECB_DecryptUpdate, + .AES128ECB_DecryptFinal = R_SCE_AES128ECB_DecryptFinal, + .AES256ECB_EncryptInit = R_SCE_AES256ECB_EncryptInit, + .AES256ECB_EncryptUpdate = R_SCE_AES256ECB_EncryptUpdate, + .AES256ECB_EncryptFinal = R_SCE_AES256ECB_EncryptFinal, + .AES256ECB_DecryptInit = R_SCE_AES256ECB_DecryptInit, + .AES256ECB_DecryptUpdate = R_SCE_AES256ECB_DecryptUpdate, + .AES256ECB_DecryptFinal = R_SCE_AES256ECB_DecryptFinal, + .AES128CBC_EncryptInit = R_SCE_AES128CBC_EncryptInit, + .AES128CBC_EncryptUpdate = R_SCE_AES128CBC_EncryptUpdate, + .AES128CBC_EncryptFinal = R_SCE_AES128CBC_EncryptFinal, + .AES128CBC_DecryptInit = R_SCE_AES128CBC_DecryptInit, + .AES128CBC_DecryptUpdate = R_SCE_AES128CBC_DecryptUpdate, + .AES128CBC_DecryptFinal = R_SCE_AES128CBC_DecryptFinal, + .AES256CBC_EncryptInit = R_SCE_AES256CBC_EncryptInit, + .AES256CBC_EncryptUpdate = R_SCE_AES256CBC_EncryptUpdate, + .AES256CBC_EncryptFinal = R_SCE_AES256CBC_EncryptFinal, + .AES256CBC_DecryptInit = R_SCE_AES256CBC_DecryptInit, + .AES256CBC_DecryptUpdate = R_SCE_AES256CBC_DecryptUpdate, + .AES256CBC_DecryptFinal = R_SCE_AES256CBC_DecryptFinal, + .AES128CTR_EncryptInit = R_SCE_AES128CTR_EncryptInit, + .AES128CTR_EncryptUpdate = R_SCE_AES128CTR_EncryptUpdate, + .AES128CTR_EncryptFinal = R_SCE_AES128CTR_EncryptFinal, + .AES128CTR_DecryptInit = R_SCE_AES128CTR_DecryptInit, + .AES128CTR_DecryptUpdate = R_SCE_AES128CTR_DecryptUpdate, + .AES128CTR_DecryptFinal = R_SCE_AES128CTR_DecryptFinal, + .AES256CTR_EncryptInit = R_SCE_AES256CTR_EncryptInit, + .AES256CTR_EncryptUpdate = R_SCE_AES256CTR_EncryptUpdate, + .AES256CTR_EncryptFinal = R_SCE_AES256CTR_EncryptFinal, + .AES256CTR_DecryptInit = R_SCE_AES256CTR_DecryptInit, + .AES256CTR_DecryptUpdate = R_SCE_AES256CTR_DecryptUpdate, + .AES256CTR_DecryptFinal = R_SCE_AES256CTR_DecryptFinal, + .AES128CMAC_GenerateInit = R_SCE_AES128CMAC_GenerateInit, + .AES128CMAC_GenerateUpdate = R_SCE_AES128CMAC_GenerateUpdate, + .AES128CMAC_GenerateFinal = R_SCE_AES128CMAC_GenerateFinal, + .AES128CMAC_VerifyInit = R_SCE_AES128CMAC_VerifyInit, + .AES128CMAC_VerifyUpdate = R_SCE_AES128CMAC_VerifyUpdate, + .AES128CMAC_VerifyFinal = R_SCE_AES128CMAC_VerifyFinal, + .AES256CMAC_GenerateInit = R_SCE_AES256CMAC_GenerateInit, + .AES256CMAC_GenerateUpdate = R_SCE_AES256CMAC_GenerateUpdate, + .AES256CMAC_GenerateFinal = R_SCE_AES256CMAC_GenerateFinal, + .AES256CMAC_VerifyInit = R_SCE_AES256CMAC_VerifyInit, + .AES256CMAC_VerifyUpdate = R_SCE_AES256CMAC_VerifyUpdate, + .AES256CMAC_VerifyFinal = R_SCE_AES256CMAC_VerifyFinal, + .SHA224_Init = R_SCE_SHA224_Init, + .SHA224_Update = R_SCE_SHA224_Update, + .SHA224_Final = R_SCE_SHA224_Final, + .SHA256_Init = R_SCE_SHA256_Init, + .SHA256_Update = R_SCE_SHA256_Update, + .SHA256_Final = R_SCE_SHA256_Final, + .RSA1024_WrappedKeyPairGenerate = R_SCE_RSA1024_WrappedKeyPairGenerate, + .RSA2048_WrappedKeyPairGenerate = R_SCE_RSA2048_WrappedKeyPairGenerate, + .RSA1024_EncryptedPublicKeyWrap = R_SCE_RSA1024_EncryptedPublicKeyWrap, + .RSA1024_EncryptedPrivateKeyWrap = R_SCE_RSA1024_EncryptedPrivateKeyWrap, + .RSA2048_EncryptedPublicKeyWrap = R_SCE_RSA2048_EncryptedPublicKeyWrap, + .RSA2048_EncryptedPrivateKeyWrap = R_SCE_RSA2048_EncryptedPrivateKeyWrap, + .RSA4096_EncryptedPublicKeyWrap = R_SCE_RSA4096_EncryptedPublicKeyWrap, + .RSASSA_PKCS1024_SignatureGenerate = R_SCE_RSASSA_PKCS1024_SignatureGenerate, + .RSASSA_PKCS2048_SignatureGenerate = R_SCE_RSASSA_PKCS2048_SignatureGenerate, + .RSASSA_PKCS1024_SignatureVerify = R_SCE_RSASSA_PKCS1024_SignatureVerify, + .RSASSA_PKCS2048_SignatureVerify = R_SCE_RSASSA_PKCS2048_SignatureVerify, + .RSASSA_PKCS4096_SignatureVerify = R_SCE_RSASSA_PKCS4096_SignatureVerify, + .RSAES_PKCS1024_Encrypt = R_SCE_RSAES_PKCS1024_Encrypt, + .RSAES_PKCS2048_Encrypt = R_SCE_RSAES_PKCS2048_Encrypt, + .RSAES_PKCS4096_Encrypt = R_SCE_RSAES_PKCS4096_Encrypt, + .RSAES_PKCS1024_Decrypt = R_SCE_RSAES_PKCS1024_Decrypt, + .RSAES_PKCS2048_Decrypt = R_SCE_RSAES_PKCS2048_Decrypt, + .ECC_secp192r1_WrappedKeyPairGenerate = R_SCE_ECC_secp192r1_WrappedKeyPairGenerate, + .ECC_secp224r1_WrappedKeyPairGenerate = R_SCE_ECC_secp224r1_WrappedKeyPairGenerate, + .ECC_secp256r1_WrappedKeyPairGenerate = R_SCE_ECC_secp256r1_WrappedKeyPairGenerate, + .ECC_BrainpoolP512r1_WrappedKeyPairGenerate = R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate, + .ECC_secp192r1_EncryptedPublicKeyWrap = R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap, + .ECC_secp224r1_EncryptedPublicKeyWrap = R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap, + .ECC_secp256r1_EncryptedPublicKeyWrap = R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap, + .ECC_BrainpoolP512r1_EncryptedPublicKeyWrap = R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap, + .ECC_secp192r1_EncryptedPrivateKeyWrap = R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap, + .ECC_secp224r1_EncryptedPrivateKeyWrap = R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap, + .ECC_secp256r1_EncryptedPrivateKeyWrap = R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap, + .ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap = R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap, + .ECDSA_secp192r1_SignatureGenerate = R_SCE_ECDSA_secp192r1_SignatureGenerate, + .ECDSA_secp224r1_SignatureGenerate = R_SCE_ECDSA_secp224r1_SignatureGenerate, + .ECDSA_secp256r1_SignatureGenerate = R_SCE_ECDSA_secp256r1_SignatureGenerate, + .ECDSA_BrainpoolP512r1_SignatureGenerate = R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate, + .ECDSA_secp192r1_SignatureVerify = R_SCE_ECDSA_secp192r1_SignatureVerify, + .ECDSA_secp224r1_SignatureVerify = R_SCE_ECDSA_secp224r1_SignatureVerify, + .ECDSA_secp256r1_SignatureVerify = R_SCE_ECDSA_secp256r1_SignatureVerify, + .ECDSA_BrainpoolP512r1_SignatureVerify = R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify, }; /*******************************************************************************************************************//** @@ -202,65 +202,65 @@ const sce_api_t g_sce_protected_on_sce = * @param[in] p_ctrl Pointer to control structure. * @param[in] p_cfg Pointer to pin configuration structure. * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL The error-detection self-test failed to terminate normally. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL The error-detection self-test failed to terminate normally. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_RETRY Indicates that an entropy evaluation failure occurred. - * Run the function again. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_RETRY Indicates that an entropy evaluation failure occurred. + * Run the function again. * * @return See @ref RENESAS_ERROR_CODES or functions called by this function for other possible return codes. * * @note The valid pre-run state is SCE disabled. - * The pre-run state is SCE Disabled State. - * After the function runs the state transitions to SCE Enabled State. + * The pre-run state is SCE Disabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_Open (sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg) { - fsp_err_t error_code = FSP_SUCCESS; - uint32_t state; - - sce_instance_ctrl_t * p_instance_ctrl = (sce_instance_ctrl_t *) p_ctrl; - p_instance_ctrl->open = 1; - gs_lifecycle = p_cfg->lifecycle; - - /* Check for need to do self-test */ - error_code = R_SCE_StateCheckSub(&state); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - if (HW_STATE_UNAVAILABLE == state) - { - error_code = R_SCE_SelfCheck2Private(); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - } - - g_private_id_counter = 0; - g_aes128ecbenc_private_id = 0; - g_aes128ecbdec_private_id = 0; - g_aes256ecbenc_private_id = 0; - g_aes256ecbdec_private_id = 0; - g_aes128cbcenc_private_id = 0; - g_aes128cbcdec_private_id = 0; - g_aes256cbcenc_private_id = 0; - g_aes256cbcdec_private_id = 0; - g_aes128ctrenc_private_id = 0; - g_aes128ctrdec_private_id = 0; - g_aes256ctrenc_private_id = 0; - g_aes256ctrdec_private_id = 0; - g_aes128cmacgen_private_id = 0; - g_aes128cmacver_private_id = 0; - g_aes256cmacgen_private_id = 0; - g_aes256cmacver_private_id = 0; - g_sha224_private_id = 0; - g_sha256_private_id = 0; - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t state; + + sce_instance_ctrl_t * p_instance_ctrl = (sce_instance_ctrl_t *) p_ctrl; + p_instance_ctrl->open = 1; + gs_lifecycle = p_cfg->lifecycle; + + /* Check for need to do self-test */ + error_code = R_SCE_StateCheckSub(&state); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + if (HW_STATE_UNAVAILABLE == state) + { + error_code = R_SCE_SelfCheck2Private(); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + } + + g_private_id_counter = 0; + g_aes128ecbenc_private_id = 0; + g_aes128ecbdec_private_id = 0; + g_aes256ecbenc_private_id = 0; + g_aes256ecbdec_private_id = 0; + g_aes128cbcenc_private_id = 0; + g_aes128cbcdec_private_id = 0; + g_aes256cbcenc_private_id = 0; + g_aes256cbcdec_private_id = 0; + g_aes128ctrenc_private_id = 0; + g_aes128ctrdec_private_id = 0; + g_aes256ctrenc_private_id = 0; + g_aes256ctrdec_private_id = 0; + g_aes128cmacgen_private_id = 0; + g_aes128cmacver_private_id = 0; + g_aes256cmacgen_private_id = 0; + g_aes256cmacver_private_id = 0; + g_sha224_private_id = 0; + g_sha256_private_id = 0; + + return error_code; } /*******************************************************************************************************************//** @@ -268,17 +268,17 @@ fsp_err_t R_SCE_Open (sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg) * * @param[in] p_ctrl Pointer to control structure. * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * * @note The pre-run state is any state. - * After the function runs the state transitions to SCE Disabled State. + * After the function runs the state transitions to SCE Disabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_Close (sce_ctrl_t * const p_ctrl) { - sce_instance_ctrl_t * p_instance_ctrl = (sce_instance_ctrl_t *) p_ctrl; - p_instance_ctrl->open = 0; + sce_instance_ctrl_t * p_instance_ctrl = (sce_instance_ctrl_t *) p_ctrl; + p_instance_ctrl->open = 0; - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -286,16 +286,16 @@ fsp_err_t R_SCE_Close (sce_ctrl_t * const p_ctrl) * * Reverts the state to the SCE initial state. * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * * @note The pre-run state is any state. - * After the function runs the state transitions to SCE Disabled State. + * After the function runs the state transitions to SCE Disabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_SoftwareReset (void) { - R_SCE_SoftwareResetSub(); + R_SCE_SoftwareResetSub(); - return FSP_SUCCESS; + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -303,16 +303,16 @@ fsp_err_t R_SCE_SoftwareReset (void) * * @param[in,out] random Stores 4words (16 bytes) random data. * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. + * by the processing routine was in use by another processing routine. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_RandomNumberGenerate (uint32_t * random) { - return R_SCE_GenerateRandomNumberSub(random); + return R_SCE_GenerateRandomNumberSub(random); } /*******************************************************************************************************************//** @@ -323,31 +323,31 @@ fsp_err_t R_SCE_RandomNumberGenerate (uint32_t * random) * * @param[in,out] wrapped_key 128-bit AES wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. + * by the processing routine was in use by another processing routine. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Disabled State. + * After the function runs the state transitions to SCE Disabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128_WrappedKeyGenerate (sce_aes_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - error_code = R_SCE_GenerateAes128RandomKeyIndexSub(wrapped_key->value); - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_AES128; - } - else if (FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - else - { - /* not used */ - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + error_code = R_SCE_GenerateAes128RandomKeyIndexSub(wrapped_key->value); + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_AES128; + } + else if (FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + else + { + /* not used */ + } + + return error_code; } /*******************************************************************************************************************//** @@ -358,117 +358,117 @@ fsp_err_t R_SCE_AES128_WrappedKeyGenerate (sce_aes_wrapped_key_t * wrapped_key) * * @param[in,out] wrapped_key 256-bit AES wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. + * by the processing routine was in use by another processing routine. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Disabled State. + * After the function runs the state transitions to SCE Disabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256_WrappedKeyGenerate (sce_aes_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - error_code = R_SCE_GenerateAes256RandomKeyIndexSub(wrapped_key->value); - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_AES256; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + error_code = R_SCE_GenerateAes256RandomKeyIndexSub(wrapped_key->value); + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_AES256; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps 128-bit AES key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 128-bit AES wrapped key + * @param[in,out] wrapped_key 128-bit AES wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128_EncryptedKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_aes_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_AES128_EncryptedKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_aes_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_AES128; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_AES128; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_AES128; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_AES128; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps 256-bit AES key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 256-bit AES wrapped key + * @param[in,out] wrapped_key 256-bit AES wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256_EncryptedKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_aes_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_AES256_EncryptedKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_aes_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_AES256; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_AES256; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_AES256; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_AES256; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** @@ -480,33 +480,33 @@ fsp_err_t R_SCE_AES256_EncryptedKeyWrap (uint8_t * initial_vector, * * @param [in,out] wrapped_pair_key User key index for RSA 1024-bit public key and private key pair * - * @retval FSP_SUCCESS Normal end + * @retval FSP_SUCCESS Normal end * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. Key generation failed. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. Key generation failed. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_RSA1024_WrappedKeyPairGenerate (sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key) { - fsp_err_t error_code = FSP_SUCCESS; - error_code = R_SCE_GenerateRsa1024RandomKeyIndexSub(SCE_RSA_RETRY_COUNT_FOR_RSA1024_KEY_GENERATION, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_pair_key->pub_key.value, - (uint32_t *) &wrapped_pair_key->priv_key.value); - if (FSP_SUCCESS == error_code) - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE; - } - else - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + error_code = R_SCE_GenerateRsa1024RandomKeyIndexSub(SCE_RSA_RETRY_COUNT_FOR_RSA1024_KEY_GENERATION, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_pair_key->pub_key.value, + (uint32_t *) &wrapped_pair_key->priv_key.value); + if (FSP_SUCCESS == error_code) + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE; + } + else + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** @@ -518,258 +518,258 @@ fsp_err_t R_SCE_RSA1024_WrappedKeyPairGenerate (sce_rsa1024_wrapped_pair_key_t * * * @param [in,out] wrapped_pair_key User key index for RSA 2048-bit public key and private key pair * - * @retval FSP_SUCCESS Normal end + * @retval FSP_SUCCESS Normal end * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. Key generation failed. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. Key generation failed. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_RSA2048_WrappedKeyPairGenerate (sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key) { - fsp_err_t error_code = FSP_SUCCESS; - error_code = R_SCE_GenerateRsa2048RandomKeyIndexSub(SCE_RSA_RETRY_COUNT_FOR_RSA2048_KEY_GENERATION, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_pair_key->pub_key.value, - (uint32_t *) &wrapped_pair_key->priv_key.value); - if (FSP_SUCCESS == error_code) - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE; - } - else - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + error_code = R_SCE_GenerateRsa2048RandomKeyIndexSub(SCE_RSA_RETRY_COUNT_FOR_RSA2048_KEY_GENERATION, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_pair_key->pub_key.value, + (uint32_t *) &wrapped_pair_key->priv_key.value); + if (FSP_SUCCESS == error_code) + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE; + } + else + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps 1024-bit RSA public key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 1024-bit RSA public wrapped key + * @param[in,out] wrapped_key 1024-bit RSA public wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_public_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA1024_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA1024_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps 1024-bit RSA private key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 1024-bit RSA private wrapped key + * @param[in,out] wrapped_key 1024-bit RSA private wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_private_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa1024_private_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA1024_PRIVATE; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA1024_PRIVATE; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps 2048-bit RSA public key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 1024-bit RSA public wrapped key + * @param[in,out] wrapped_key 1024-bit RSA public wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_public_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA2048_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA2048_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps 2048-bit RSA private key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 2048-bit RSA private wrapped key + * @param[in,out] wrapped_key 2048-bit RSA private wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_private_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa2048_private_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA2048_PRIVATE; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA2048_PRIVATE; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps 4096-bit RSA public key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 1024-bit RSA public wrapped key + * @param[in,out] wrapped_key 1024-bit RSA public wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa4096_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_rsa4096_public_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA4096_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA4096_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA4096_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA4096_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** @@ -781,39 +781,39 @@ fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap (uint8_t * initial_vector, * * @param[in,out] wrapped_pair_key Wrapped pair key for secp192r1 public key and private key pair * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_ECC_secp192r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * wrapped_pair_key) { - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_GenerateEccRandomKeyIndexSub(&curvetype, - /* Casting uint32_t pointer is used for address. */ - &indata_cmd, - (uint32_t *) &wrapped_pair_key->pub_key.value, - (uint32_t *) &wrapped_pair_key->priv_key.value); - if (FSP_SUCCESS == error_code) - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE; - } - else - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_GenerateEccRandomKeyIndexSub(&curvetype, + /* Casting uint32_t pointer is used for address. */ + &indata_cmd, + (uint32_t *) &wrapped_pair_key->pub_key.value, + (uint32_t *) &wrapped_pair_key->priv_key.value); + if (FSP_SUCCESS == error_code) + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE; + } + else + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** @@ -825,39 +825,39 @@ fsp_err_t R_SCE_ECC_secp192r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * * @param[in,out] wrapped_pair_key Wrapped pair key for secp224r1 public key and private key pair * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_ECC_secp224r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * wrapped_pair_key) { - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_GenerateEccRandomKeyIndexSub(&curvetype, - /* Casting uint32_t pointer is used for address. */ - &indata_cmd, - (uint32_t *) &wrapped_pair_key->pub_key.value, - (uint32_t *) &wrapped_pair_key->priv_key.value); - if (FSP_SUCCESS == error_code) - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE; - } - else - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_GenerateEccRandomKeyIndexSub(&curvetype, + /* Casting uint32_t pointer is used for address. */ + &indata_cmd, + (uint32_t *) &wrapped_pair_key->pub_key.value, + (uint32_t *) &wrapped_pair_key->priv_key.value); + if (FSP_SUCCESS == error_code) + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE; + } + else + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** @@ -869,39 +869,39 @@ fsp_err_t R_SCE_ECC_secp224r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * * @param[in,out] wrapped_pair_key Wrapped pair key for secp256r1 public key and private key pair * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_ECC_secp256r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * wrapped_pair_key) { - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_GenerateEccRandomKeyIndexSub(&curvetype, - /* Casting uint32_t pointer is used for address. */ - &indata_cmd, - (uint32_t *) &wrapped_pair_key->pub_key.value, - (uint32_t *) &wrapped_pair_key->priv_key.value); - if (FSP_SUCCESS == error_code) - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE; - } - else - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_GenerateEccRandomKeyIndexSub(&curvetype, + /* Casting uint32_t pointer is used for address. */ + &indata_cmd, + (uint32_t *) &wrapped_pair_key->pub_key.value, + (uint32_t *) &wrapped_pair_key->priv_key.value); + if (FSP_SUCCESS == error_code) + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE; + } + else + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** @@ -913,394 +913,394 @@ fsp_err_t R_SCE_ECC_secp256r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * * @param[in,out] wrapped_pair_key Wrapped pair key for BrainpoolP512r1 public key and private key pair * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * wrapped_pair_key) { - fsp_err_t error_code = FSP_SUCCESS; - - error_code = R_SCE_GenerateEccP512RandomKeyIndexSub( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_pair_key->pub_key.value, - (uint32_t *) &wrapped_pair_key->priv_key.value); - if (FSP_SUCCESS == error_code) - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE; - } - else - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + + error_code = R_SCE_GenerateEccP512RandomKeyIndexSub( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_pair_key->pub_key.value, + (uint32_t *) &wrapped_pair_key->priv_key.value); + if (FSP_SUCCESS == error_code) + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE; + } + else + { + wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; + wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps secp192r1 public key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp192r1 public wrapped key + * @param[in,out] wrapped_key secp192r1 public wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P192_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P192_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps secp224r1 public key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp224r1 public wrapped key + * @param[in,out] wrapped_key secp224r1 public wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P224_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P224_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps secp256r1 public key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp256r1 public wrapped key + * @param[in,out] wrapped_key secp256r1 public wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P256_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P256_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps BrainpoolP512r1 public key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key BrainpoolP512r1 public wrapped key + * @param[in,out] wrapped_key BrainpoolP512r1 public wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key) + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_public_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P512_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P512_PUBLIC; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps secp192r1 private key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp192r1 private wrapped key + * @param[in,out] wrapped_key secp192r1 private wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P192_PRIVATE; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P192_PRIVATE; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps secp224r1 private key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp224r1 private wrapped key + * @param[in,out] wrapped_key secp224r1 private wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P224_PRIVATE; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P224_PRIVATE; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps secp256r1 private key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp256r1 private wrapped key + * @param[in,out] wrapped_key secp256r1 private wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P256_PRIVATE; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P256_PRIVATE; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** * This API wraps BrainpoolP512r1 private key within the user routine. * * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended + * @param[in] encrypted_key User key encryptedand MAC appended * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key BrainpoolP512r1 private wrapped key + * @param[in,out] wrapped_key BrainpoolP512r1 private wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, + uint8_t * encrypted_key, + sce_key_update_key_t * key_update_key, + sce_ecc_private_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P512_PRIVATE; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + lifecycle_t lifecycle = gs_lifecycle; + sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P512_PRIVATE; + + memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); + + error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, + key_type, + initial_vector, + encrypted_key, + (uint32_t *) &wrapped_key->value); + + if (FSP_SUCCESS == error_code) + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE; + } + else + { + wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; + } + + return error_code; } /*******************************************************************************************************************//** @@ -1314,134 +1314,134 @@ fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap (uint8_t * in /*******************************************************************************************************************//** * Self check No2 * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RETRY self-test2 fail + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_SCE_RETRY self-test2 fail * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict **********************************************************************************************************************/ fsp_err_t R_SCE_SelfCheck2Private (void) { - return R_SCE_SelfCheck2Sub(); + return R_SCE_SelfCheck2Sub(); } /*******************************************************************************************************************//** * This API Updates OEM key index (wrapped key). * - * @param[in] lifecycle (no use) - * @param[in] key_type User key type define in sce_oem_cmd_t + * @param[in] lifecycle (no use) + * @param[in] key_type User key type define in sce_oem_cmd_t * @param[in] encrypted_oem_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key wrapped key + * @param[in] key_update_key Key update keyring + * @param[in,out] wrapped_key wrapped key * * @retval FSP_SUCCESS * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT * @retval FSP_ERR_CRYPTO_SCE_FAIL **********************************************************************************************************************/ -fsp_err_t R_SCE_UpdateOemKeyIndexPrivate (lifecycle_t lifecycle, - sce_oem_cmd_t key_type, - uint8_t * iv, - uint8_t * encrypted_oem_key, - uint32_t * key_index) +fsp_err_t R_SCE_UpdateOemKeyIndexPrivate (lifecycle_t lifecycle, + sce_oem_cmd_t key_type, + uint8_t * iv, + uint8_t * encrypted_oem_key, + uint32_t * key_index) { - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - - FSP_PARAMETER_NOT_USED(lifecycle); - - switch (key_type) - { - case SCE_OEM_CMD_AES128: - error_code = R_SCE_AES128_EncryptedKeyWrapSub((uint32_t *) iv, (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_AES256: - error_code = R_SCE_AES256_EncryptedKeyWrapSub((uint32_t *) iv, (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_RSA1024_PUBLIC: - error_code = R_SCE_RSA1024_EncryptedPublicKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_RSA1024_PRIVATE: - error_code = R_SCE_RSA1024_EncryptedPrivateKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_RSA2048_PUBLIC: - error_code = R_SCE_RSA2048_EncryptedPublicKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_RSA2048_PRIVATE: - error_code = R_SCE_RSA2048_EncryptedPrivateKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_RSA4096_PUBLIC: - error_code = R_SCE_RSA4096_EncryptedPublicKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_ECC_P192_PUBLIC: - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(&curvetype, - &indata_cmd, - (uint32_t *) iv, - (uint32_t *) encrypted_oem_key, - key_index); - break; - case SCE_OEM_CMD_ECC_P224_PUBLIC: - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(&curvetype, - &indata_cmd, - (uint32_t *) iv, - (uint32_t *) encrypted_oem_key, - key_index); - break; - case SCE_OEM_CMD_ECC_P256_PUBLIC: - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(&curvetype, - &indata_cmd, - (uint32_t *) iv, - (uint32_t *) encrypted_oem_key, - key_index); - break; - case SCE_OEM_CMD_ECC_P512_PUBLIC: - error_code = R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_ECC_P192_PRIVATE: - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(&curvetype, - &indata_cmd, - (uint32_t *) iv, - (uint32_t *) encrypted_oem_key, - key_index); - break; - case SCE_OEM_CMD_ECC_P224_PRIVATE: - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(&curvetype, - &indata_cmd, - (uint32_t *) iv, - (uint32_t *) encrypted_oem_key, - key_index); - break; - case SCE_OEM_CMD_ECC_P256_PRIVATE: - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(&curvetype, - &indata_cmd, - (uint32_t *) iv, - (uint32_t *) encrypted_oem_key, - key_index); - break; - case SCE_OEM_CMD_ECC_P512_PRIVATE: - error_code = R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - default: - error_code = FSP_ERR_CRYPTO_SCE_FAIL; /* Not support Key type */ - break; - } - - return error_code; + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + + FSP_PARAMETER_NOT_USED(lifecycle); + + switch (key_type) + { + case SCE_OEM_CMD_AES128: + error_code = R_SCE_AES128_EncryptedKeyWrapSub((uint32_t *) iv, (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_AES256: + error_code = R_SCE_AES256_EncryptedKeyWrapSub((uint32_t *) iv, (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_RSA1024_PUBLIC: + error_code = R_SCE_RSA1024_EncryptedPublicKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_RSA1024_PRIVATE: + error_code = R_SCE_RSA1024_EncryptedPrivateKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_RSA2048_PUBLIC: + error_code = R_SCE_RSA2048_EncryptedPublicKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_RSA2048_PRIVATE: + error_code = R_SCE_RSA2048_EncryptedPrivateKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_RSA4096_PUBLIC: + error_code = R_SCE_RSA4096_EncryptedPublicKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_ECC_P192_PUBLIC: + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(&curvetype, + &indata_cmd, + (uint32_t *) iv, + (uint32_t *) encrypted_oem_key, + key_index); + break; + case SCE_OEM_CMD_ECC_P224_PUBLIC: + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(&curvetype, + &indata_cmd, + (uint32_t *) iv, + (uint32_t *) encrypted_oem_key, + key_index); + break; + case SCE_OEM_CMD_ECC_P256_PUBLIC: + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(&curvetype, + &indata_cmd, + (uint32_t *) iv, + (uint32_t *) encrypted_oem_key, + key_index); + break; + case SCE_OEM_CMD_ECC_P512_PUBLIC: + error_code = R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + case SCE_OEM_CMD_ECC_P192_PRIVATE: + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(&curvetype, + &indata_cmd, + (uint32_t *) iv, + (uint32_t *) encrypted_oem_key, + key_index); + break; + case SCE_OEM_CMD_ECC_P224_PRIVATE: + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(&curvetype, + &indata_cmd, + (uint32_t *) iv, + (uint32_t *) encrypted_oem_key, + key_index); + break; + case SCE_OEM_CMD_ECC_P256_PRIVATE: + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(&curvetype, + &indata_cmd, + (uint32_t *) iv, + (uint32_t *) encrypted_oem_key, + key_index); + break; + case SCE_OEM_CMD_ECC_P512_PRIVATE: + error_code = R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrapSub((uint32_t *) iv, + (uint32_t *) encrypted_oem_key, key_index); + break; + default: + error_code = FSP_ERR_CRYPTO_SCE_FAIL; /* Not support Key type */ + break; + } + + return error_code; } diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_aes.c b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_aes.c index a630e513c..f3ef3c836 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_aes.c +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_aes.c @@ -17,13 +17,13 @@ * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. *********************************************************************************************************************/ /********************************************************************************************************************** - * File Name : r_sce_aes.c - * Version : 1.0 - * Description : SCE AES Public API source file + * File Name : r_sce_aes.c + * Version : 1.0 + * Description : SCE AES Public API source file *********************************************************************************************************************/ /********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release *********************************************************************************************************************/ /*********************************************************************************************************************** @@ -37,15 +37,15 @@ **********************************************************************************************************************/ /* Initialization function call state */ -#define CALL_ONLY_INIT (0) -#define CALL_ONLY_UPDATE_FINAL (1) +#define CALL_ONLY_INIT (0) +#define CALL_ONLY_UPDATE_FINAL (1) /* Magic numbers */ #ifndef SCE_HEX_E000000 -#define SCE_HEX_E000000 (0xe000000U) +#define SCE_HEX_E000000 (0xe000000U) #endif #ifndef SCE_DEC_110 -#define SCE_DEC_110 (110) +#define SCE_DEC_110 (110) #endif /*********************************************************************************************************************** @@ -65,22 +65,22 @@ static void cal_current_ivec_ctrmode(sce_aes_handle_t *handle , uint32_t block_n * Global variables **********************************************************************************************************************/ extern uint32_t g_private_id_counter; -uint32_t g_aes128ecbenc_private_id; -uint32_t g_aes128ecbdec_private_id; -uint32_t g_aes256ecbenc_private_id; -uint32_t g_aes256ecbdec_private_id; -uint32_t g_aes128cbcenc_private_id; -uint32_t g_aes128cbcdec_private_id; -uint32_t g_aes256cbcenc_private_id; -uint32_t g_aes256cbcdec_private_id; -uint32_t g_aes128ctrenc_private_id; -uint32_t g_aes128ctrdec_private_id; -uint32_t g_aes256ctrenc_private_id; -uint32_t g_aes256ctrdec_private_id; -uint32_t g_aes128cmacgen_private_id; -uint32_t g_aes128cmacver_private_id; -uint32_t g_aes256cmacgen_private_id; -uint32_t g_aes256cmacver_private_id; +uint32_t g_aes128ecbenc_private_id; +uint32_t g_aes128ecbdec_private_id; +uint32_t g_aes256ecbenc_private_id; +uint32_t g_aes256ecbdec_private_id; +uint32_t g_aes128cbcenc_private_id; +uint32_t g_aes128cbcdec_private_id; +uint32_t g_aes256cbcenc_private_id; +uint32_t g_aes256cbcdec_private_id; +uint32_t g_aes128ctrenc_private_id; +uint32_t g_aes128ctrdec_private_id; +uint32_t g_aes256ctrenc_private_id; +uint32_t g_aes256ctrdec_private_id; +uint32_t g_aes128cmacgen_private_id; +uint32_t g_aes128cmacver_private_id; +uint32_t g_aes256cmacgen_private_id; +uint32_t g_aes256cmacver_private_id; /*******************************************************************************************************************//** * @addtogroup SCE_PROTECTED @@ -96,27 +96,27 @@ uint32_t g_aes256cmacver_private_id; * and writes the result to the first argument, handle. The value of handle is used as an argument * in the subsequent R_SCE_AES128ECB_EncryptUpdate() function and R_SCE_AES128ECB_EncryptFinal() function. * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. * - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128ECB_EncryptInit (sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) { - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128ecbenc_private_id = g_private_id_counter; - handle->id = g_aes128ecbenc_private_id; + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128ecbenc_private_id = g_private_id_counter; + handle->id = g_aes128ecbenc_private_id; - return R_SCE_Aes128EcbEncryptInitPrivate(wrapped_key); + return R_SCE_Aes128EcbEncryptInitPrivate(wrapped_key); } /*******************************************************************************************************************//** @@ -128,40 +128,40 @@ fsp_err_t R_SCE_AES128ECB_EncryptInit (sce_aes_handle_t * handle, sce_aes_wrappe * Specify areas for plain and cipher that do not overlap. For plain and cipher, * specify RAM addresses that are multiples of 4. * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area * @param[in,out] plain_length plaintext data length (must be a multiple of 16) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128ECB_EncryptUpdate (sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length) + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128ecbenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - memcpy(handle->last_1_block_as_fraction, - (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - handle->current_input_data_size = plain_length; - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128EcbEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128ecbenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + memcpy(handle->last_1_block_as_fraction, + (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + handle->current_input_data_size = plain_length; + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128EcbEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); } /*******************************************************************************************************************//** @@ -173,36 +173,36 @@ fsp_err_t R_SCE_AES128ECB_EncryptUpdate (sce_aes_handle_t * handle, * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length * are provided for compatibility in anticipation of the time when this restriction is lifted. * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) * @param[in,out] cipher_length ciphertext data length (0 always written here) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128ECB_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128ecbenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *cipher_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128EcbEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128ecbenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *cipher_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128EcbEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); } /*******************************************************************************************************************//** @@ -210,27 +210,27 @@ fsp_err_t R_SCE_AES128ECB_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cip * and writes the result to the first argument, handle. The value of handle is used as an argument * in the subsequent R_SCE_AES128ECB_DecryptUpdate() function and R_SCE_AES128ECB_DecryptFinal() function. * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128ECB_DecryptInit (sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) { - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128ecbdec_private_id = g_private_id_counter; - handle->id = g_aes128ecbdec_private_id; + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128ecbdec_private_id = g_private_id_counter; + handle->id = g_aes128ecbdec_private_id; - return R_SCE_Aes128EcbDecryptInitPrivate(wrapped_key); + return R_SCE_Aes128EcbDecryptInitPrivate(wrapped_key); } /*******************************************************************************************************************//** @@ -242,40 +242,40 @@ fsp_err_t R_SCE_AES128ECB_DecryptInit (sce_aes_handle_t * handle, sce_aes_wrappe * Specify areas for plain and cipher that do not overlap. For plain and cipher, * specify RAM addresses that are multiples of 4. * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128ECB_DecryptUpdate (sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length) + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128ecbdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = cipher_length; - memcpy(handle->last_1_block_as_fraction, - (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128EcbDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128ecbdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = cipher_length; + memcpy(handle->last_1_block_as_fraction, + (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128EcbDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); } /*******************************************************************************************************************//** @@ -287,36 +287,36 @@ fsp_err_t R_SCE_AES128ECB_DecryptUpdate (sce_aes_handle_t * handle, * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length * are provided for compatibility in anticipation of the time when this restriction is lifted. * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) * @param[in,out] plain_length plaintext data length (0 always written here) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128ECB_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128ecbdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *plain_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128EcbDecryptFinalPrivate((uint32_t *) (plain), plain_length); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128ecbdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *plain_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128EcbDecryptFinalPrivate((uint32_t *) (plain), plain_length); } /*******************************************************************************************************************//** @@ -324,27 +324,27 @@ fsp_err_t R_SCE_AES128ECB_DecryptFinal (sce_aes_handle_t * handle, uint8_t * pla * and writes the result to the first argument, handle. The value of handle is used as an argument * in the subsequent R_SCE_AES256ECB_EncryptUpdate() function and R_SCE_AES256ECB_EncryptFinal() function. * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256ECB_EncryptInit (sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) { - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256ecbenc_private_id = g_private_id_counter; - handle->id = g_aes256ecbenc_private_id; + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256ecbenc_private_id = g_private_id_counter; + handle->id = g_aes256ecbenc_private_id; - return R_SCE_Aes256EcbEncryptInitPrivate(wrapped_key); + return R_SCE_Aes256EcbEncryptInitPrivate(wrapped_key); } /*******************************************************************************************************************//** @@ -356,40 +356,40 @@ fsp_err_t R_SCE_AES256ECB_EncryptInit (sce_aes_handle_t * handle, sce_aes_wrappe * Specify areas for plain and cipher that do not overlap. For plain and cipher, * specify RAM addresses that are multiples of 4. * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area * @param[in,out] plain_length plaintext data length (must be a multiple of 16) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256ECB_EncryptUpdate (sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length) + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256ecbenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = plain_length; - memcpy(handle->last_1_block_as_fraction, - (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256EcbEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256ecbenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = plain_length; + memcpy(handle->last_1_block_as_fraction, + (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256EcbEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); } /*******************************************************************************************************************//** @@ -401,36 +401,36 @@ fsp_err_t R_SCE_AES256ECB_EncryptUpdate (sce_aes_handle_t * handle, * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length * are provided for compatibility in anticipation of the time when this restriction is lifted. * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) * @param[in,out] cipher_length ciphertext data length (0 always written here) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256ECB_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256ecbenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *cipher_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256EcbEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256ecbenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *cipher_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256EcbEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); } /*******************************************************************************************************************//** @@ -438,26 +438,26 @@ fsp_err_t R_SCE_AES256ECB_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cip * and writes the result to the first argument, handle. The value of handle is used as an argument * in the subsequent R_SCE_AES128ECB_DecryptUpdate() function and R_SCE_AES128ECB_DecryptFinal() function. * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256ECB_DecryptInit (sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) { - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256ecbdec_private_id = g_private_id_counter; - handle->id = g_aes256ecbdec_private_id; - return R_SCE_Aes256EcbDecryptInitPrivate(wrapped_key); + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256ecbdec_private_id = g_private_id_counter; + handle->id = g_aes256ecbdec_private_id; + return R_SCE_Aes256EcbDecryptInitPrivate(wrapped_key); } /*******************************************************************************************************************//** @@ -469,40 +469,40 @@ fsp_err_t R_SCE_AES256ECB_DecryptInit (sce_aes_handle_t * handle, sce_aes_wrappe * Specify areas for plain and cipher that do not overlap. For plain and cipher, * specify RAM addresses that are multiples of 4. * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256ECB_DecryptUpdate (sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length) + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256ecbdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = cipher_length; - memcpy(handle->last_1_block_as_fraction, - (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256EcbDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256ecbdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = cipher_length; + memcpy(handle->last_1_block_as_fraction, + (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256EcbDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); } /*******************************************************************************************************************//** @@ -514,36 +514,36 @@ fsp_err_t R_SCE_AES256ECB_DecryptUpdate (sce_aes_handle_t * handle, * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length * are provided for compatibility in anticipation of the time when this restriction is lifted. * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) * @param[in,out] plain_length plaintext data length (0 always written here) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256ECB_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256ecbdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *plain_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256EcbDecryptFinalPrivate((uint32_t *) (plain), plain_length); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256ecbdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *plain_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256EcbDecryptFinalPrivate((uint32_t *) (plain), plain_length); } /*******************************************************************************************************************//** @@ -551,32 +551,32 @@ fsp_err_t R_SCE_AES256ECB_DecryptFinal (sce_aes_handle_t * handle, uint8_t * pla * and writes the result to the first argument, handle. The value of handle is used as an argument * in the subsequent R_SCE_AES128CBC_EncryptUpdate() function and R_SCE_AES128CBC_EncryptFinal() function. * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initialization vector area (16byte) + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initialization vector area (16byte) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CBC_EncryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) +fsp_err_t R_SCE_AES128CBC_EncryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) { - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128cbcenc_private_id = g_private_id_counter; - handle->id = g_aes128cbcenc_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CbcEncryptInitPrivate(wrapped_key, (uint32_t *) (initial_vector)); + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128cbcenc_private_id = g_private_id_counter; + handle->id = g_aes128cbcenc_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CbcEncryptInitPrivate(wrapped_key, (uint32_t *) (initial_vector)); } /*******************************************************************************************************************//** @@ -588,45 +588,45 @@ fsp_err_t R_SCE_AES128CBC_EncryptInit (sce_aes_handle_t * handle, * Specify areas for plain and cipher that do not overlap. For plain and cipher, * specify RAM addresses that are multiples of 4. * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area * @param[in,out] plain_length plaintext data length (must be a multiple of 16) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CBC_EncryptUpdate (sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length) + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128cbcenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = plain_length; - memcpy(handle->last_1_block_as_fraction, - (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes128CbcEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); - memcpy(handle->current_initial_vector, - (cipher + (plain_length - HW_SCE_AES_BLOCK_BYTE_SIZE)), - HW_SCE_AES_CBC_IV_BYTE_SIZE); - - return FSP_SUCCESS; + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128cbcenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = plain_length; + memcpy(handle->last_1_block_as_fraction, + (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes128CbcEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); + memcpy(handle->current_initial_vector, + (cipher + (plain_length - HW_SCE_AES_BLOCK_BYTE_SIZE)), + HW_SCE_AES_CBC_IV_BYTE_SIZE); + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -638,36 +638,36 @@ fsp_err_t R_SCE_AES128CBC_EncryptUpdate (sce_aes_handle_t * handle, * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length * are provided for compatibility in anticipation of the time when this restriction is lifted. * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) * @param[in,out] cipher_length ciphertext data length (0 always written here) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CBC_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128cbcenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *cipher_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CbcEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128cbcenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *cipher_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CbcEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); } /*******************************************************************************************************************//** @@ -675,32 +675,32 @@ fsp_err_t R_SCE_AES128CBC_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cip * and writes the result to the first argument, handle. The value of handle is used as an argument * in the subsequent R_SCE_AES128CBC_DecryptUpdate() function and R_SCE_AES128CBC_DecryptFinal() function. * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initialization vector area (16byte) + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initialization vector area (16byte) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CBC_DecryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) +fsp_err_t R_SCE_AES128CBC_DecryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) { - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128cbcdec_private_id = g_private_id_counter; - handle->id = g_aes128cbcdec_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CbcDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128cbcdec_private_id = g_private_id_counter; + handle->id = g_aes128cbcdec_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CbcDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); } /*******************************************************************************************************************//** @@ -712,45 +712,45 @@ fsp_err_t R_SCE_AES128CBC_DecryptInit (sce_aes_handle_t * handle, * Specify areas for plain and cipher that do not overlap. For plain and cipher, * specify RAM addresses that are multiples of 4. * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CBC_DecryptUpdate (sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length) + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128cbcdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = cipher_length; - memcpy(handle->last_1_block_as_fraction, - (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes128CbcDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); - memcpy(handle->current_initial_vector, - (plain + (cipher_length - HW_SCE_AES_BLOCK_BYTE_SIZE)), - HW_SCE_AES_CBC_IV_BYTE_SIZE); - - return FSP_SUCCESS; + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128cbcdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = cipher_length; + memcpy(handle->last_1_block_as_fraction, + (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes128CbcDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); + memcpy(handle->current_initial_vector, + (plain + (cipher_length - HW_SCE_AES_BLOCK_BYTE_SIZE)), + HW_SCE_AES_CBC_IV_BYTE_SIZE); + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -762,36 +762,36 @@ fsp_err_t R_SCE_AES128CBC_DecryptUpdate (sce_aes_handle_t * handle, * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length * are provided for compatibility in anticipation of the time when this restriction is lifted. * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) * @param[in,out] plain_length plaintext data length (0 always written here) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CBC_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128cbcdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *plain_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CbcDecryptFinalPrivate((uint32_t *) (plain), plain_length); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128cbcdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *plain_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CbcDecryptFinalPrivate((uint32_t *) (plain), plain_length); } /*******************************************************************************************************************//** @@ -799,32 +799,32 @@ fsp_err_t R_SCE_AES128CBC_DecryptFinal (sce_aes_handle_t * handle, uint8_t * pla * and writes the result to the first argument, handle. The value of handle is used as an argument * in the subsequent R_SCE_AES256CBC_EncryptUpdate() function and R_SCE_AES256CBC_EncryptFinal() function. * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CBC_EncryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) +fsp_err_t R_SCE_AES256CBC_EncryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) { - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256cbcenc_private_id = g_private_id_counter; - handle->id = g_aes256cbcenc_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CbcEncryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256cbcenc_private_id = g_private_id_counter; + handle->id = g_aes256cbcenc_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CbcEncryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); } /*******************************************************************************************************************//** @@ -836,45 +836,45 @@ fsp_err_t R_SCE_AES256CBC_EncryptInit (sce_aes_handle_t * handle, * Specify areas for plain and cipher that do not overlap. For plain and cipher, * specify RAM addresses that are multiples of 4. * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area * @param[in,out] plain_length plaintext data length (must be a multiple of 16) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CBC_EncryptUpdate (sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length) + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256cbcenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = plain_length; - memcpy(handle->last_1_block_as_fraction, - (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes256CbcEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); - memcpy(handle->current_initial_vector, - cipher + (plain_length - HW_SCE_AES_BLOCK_BYTE_SIZE), - HW_SCE_AES_CBC_IV_BYTE_SIZE); - - return FSP_SUCCESS; + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256cbcenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = plain_length; + memcpy(handle->last_1_block_as_fraction, + (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes256CbcEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); + memcpy(handle->current_initial_vector, + cipher + (plain_length - HW_SCE_AES_BLOCK_BYTE_SIZE), + HW_SCE_AES_CBC_IV_BYTE_SIZE); + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -886,36 +886,36 @@ fsp_err_t R_SCE_AES256CBC_EncryptUpdate (sce_aes_handle_t * handle, * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length * are provided for compatibility in anticipation of the time when this restriction is lifted. * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) * @param[in,out] cipher_length ciphertext data length (0 always written here) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CBC_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256cbcenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *cipher_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CbcEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256cbcenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *cipher_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CbcEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); } /*******************************************************************************************************************//** @@ -923,32 +923,32 @@ fsp_err_t R_SCE_AES256CBC_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cip * and writes the result to the first argument, handle. The value of handle is used as an argument * in the subsequent R_SCE_AES256CBC_DecryptUpdate() function and R_SCE_AES256CBC_DecryptFinal() function. * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initialization vector area (16byte) + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initialization vector area (16byte) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CBC_DecryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) +fsp_err_t R_SCE_AES256CBC_DecryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) { - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256cbcdec_private_id = g_private_id_counter; - handle->id = g_aes256cbcdec_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CbcDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256cbcdec_private_id = g_private_id_counter; + handle->id = g_aes256cbcdec_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CbcDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); } /*******************************************************************************************************************//** @@ -960,45 +960,45 @@ fsp_err_t R_SCE_AES256CBC_DecryptInit (sce_aes_handle_t * handle, * Specify areas for plain and cipher that do not overlap. For plain and cipher, * specify RAM addresses that are multiples of 4. * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CBC_DecryptUpdate (sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length) + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256cbcdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = cipher_length; - memcpy(handle->last_1_block_as_fraction, - (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes256CbcDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); - memcpy(handle->current_initial_vector, - plain + (cipher_length - HW_SCE_AES_BLOCK_BYTE_SIZE), - HW_SCE_AES_CBC_IV_BYTE_SIZE); - - return FSP_SUCCESS; + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256cbcdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = cipher_length; + memcpy(handle->last_1_block_as_fraction, + (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes256CbcDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); + memcpy(handle->current_initial_vector, + plain + (cipher_length - HW_SCE_AES_BLOCK_BYTE_SIZE), + HW_SCE_AES_CBC_IV_BYTE_SIZE); + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -1010,36 +1010,36 @@ fsp_err_t R_SCE_AES256CBC_DecryptUpdate (sce_aes_handle_t * handle, * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length * are provided for compatibility in anticipation of the time when this restriction is lifted. * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) * @param[in,out] plain_length plaintext data length (0 always written here) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CBC_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256cbcdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *plain_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CbcDecryptFinalPrivate((uint32_t *) (plain), plain_length); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256cbcdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *plain_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CbcDecryptFinalPrivate((uint32_t *) (plain), plain_length); } /*******************************************************************************************************************//** @@ -1047,32 +1047,32 @@ fsp_err_t R_SCE_AES256CBC_DecryptFinal (sce_aes_handle_t * handle, uint8_t * pla * and writes the result to the first argument, handle. The value of handle is used as an argument * in the subsequent R_SCE_AES128CTR_EncryptUpdate() function and R_SCE_AES128CTR_EncryptFinal() function. * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initialization vector area (16byte) + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initialization vector area (16byte) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CTR_EncryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) +fsp_err_t R_SCE_AES128CTR_EncryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) { - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128ctrenc_private_id = g_private_id_counter; - handle->id = g_aes128ctrenc_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CtrEncryptInitPrivate(wrapped_key, (uint32_t *) (initial_vector)); + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128ctrenc_private_id = g_private_id_counter; + handle->id = g_aes128ctrenc_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CtrEncryptInitPrivate(wrapped_key, (uint32_t *) (initial_vector)); } /*******************************************************************************************************************//** @@ -1084,44 +1084,44 @@ fsp_err_t R_SCE_AES128CTR_EncryptInit (sce_aes_handle_t * handle, * Specify areas for plain and cipher that do not overlap. For plain and cipher, * specify RAM addresses that are multiples of 4. * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area * @param[in,out] plain_length plaintext data length (must be a multiple of 16) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CTR_EncryptUpdate (sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length) + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length) { - uint32_t block_num = (plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE); - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128ctrenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = plain_length; - memcpy(handle->last_1_block_as_fraction, - (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes128CtrEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); - cal_current_ivec_ctrmode(handle, block_num); - - return FSP_SUCCESS; + uint32_t block_num = (plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128ctrenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = plain_length; + memcpy(handle->last_1_block_as_fraction, + (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes128CtrEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); + cal_current_ivec_ctrmode(handle, block_num); + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -1133,36 +1133,36 @@ fsp_err_t R_SCE_AES128CTR_EncryptUpdate (sce_aes_handle_t * handle, * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length * are provided for compatibility in anticipation of the time when this restriction is lifted. * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) * @param[in,out] cipher_length ciphertext data length (0 always written here) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CTR_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128ctrenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *cipher_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CtrEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128ctrenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *cipher_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CtrEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); } /*******************************************************************************************************************//** @@ -1170,32 +1170,32 @@ fsp_err_t R_SCE_AES128CTR_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cip * and writes the result to the first argument, handle. The value of handle is used as an argument * in the subsequent R_SCE_AES128CTR_DecryptUpdate() function and R_SCE_AES128CTR_DecryptFinal() function. * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initialization vector area (16byte) + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in] initial_vector initialization vector area (16byte) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CTR_DecryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) +fsp_err_t R_SCE_AES128CTR_DecryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) { - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128ctrdec_private_id = g_private_id_counter; - handle->id = g_aes128ctrdec_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CtrDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128ctrdec_private_id = g_private_id_counter; + handle->id = g_aes128ctrdec_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CtrDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); } /*******************************************************************************************************************//** @@ -1207,44 +1207,44 @@ fsp_err_t R_SCE_AES128CTR_DecryptInit (sce_aes_handle_t * handle, * Specify areas for plain and cipher that do not overlap. For plain and cipher, * specify RAM addresses that are multiples of 4. * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CTR_DecryptUpdate (sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length) + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length) { - uint32_t block_num = (cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE); - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128ctrdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = cipher_length; - memcpy(handle->last_1_block_as_fraction, - (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes128CtrDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); - cal_current_ivec_ctrmode(handle, block_num); - - return FSP_SUCCESS; + uint32_t block_num = (cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128ctrdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = cipher_length; + memcpy(handle->last_1_block_as_fraction, + (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes128CtrDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); + cal_current_ivec_ctrmode(handle, block_num); + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -1256,36 +1256,36 @@ fsp_err_t R_SCE_AES128CTR_DecryptUpdate (sce_aes_handle_t * handle, * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length * are provided for compatibility in anticipation of the time when this restriction is lifted. * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) * @param[in,out] plain_length plaintext data length (0 always written here) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CTR_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128ctrdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *plain_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CtrDecryptFinalPrivate((uint32_t *) (plain), plain_length); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128ctrdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *plain_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes128CtrDecryptFinalPrivate((uint32_t *) (plain), plain_length); } /*******************************************************************************************************************//** @@ -1293,32 +1293,32 @@ fsp_err_t R_SCE_AES128CTR_DecryptFinal (sce_aes_handle_t * handle, uint8_t * pla * and writes the result to the first argument, handle. The value of handle is used as an argument * in the subsequent R_SCE_AES256CTR_EncryptUpdate() function and R_SCE_AES256CTR_EncryptFinal() function. * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initial vector area (16byte) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CTR_EncryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) +fsp_err_t R_SCE_AES256CTR_EncryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) { - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256ctrenc_private_id = g_private_id_counter; - handle->id = g_aes256ctrenc_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CtrEncryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256ctrenc_private_id = g_private_id_counter; + handle->id = g_aes256ctrenc_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CtrEncryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); } /*******************************************************************************************************************//** @@ -1330,44 +1330,44 @@ fsp_err_t R_SCE_AES256CTR_EncryptInit (sce_aes_handle_t * handle, * Specify areas for plain and cipher that do not overlap. For plain and cipher, * specify RAM addresses that are multiples of 4. * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area + * @param[in,out] handle AES handler (work area) + * @param[in] plain plaintext data area + * @param[in,out] cipher ciphertext data area * @param[in,out] plain_length plaintext data length (must be a multiple of 16) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CTR_EncryptUpdate (sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length) + uint8_t * plain, + uint8_t * cipher, + uint32_t plain_length) { - uint32_t block_num = (plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE); - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256ctrenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = plain_length; - memcpy(handle->last_1_block_as_fraction, - (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes256CtrEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); - cal_current_ivec_ctrmode(handle, block_num); - - return FSP_SUCCESS; + uint32_t block_num = (plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256ctrenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = plain_length; + memcpy(handle->last_1_block_as_fraction, + (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes256CtrEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); + cal_current_ivec_ctrmode(handle, block_num); + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -1379,36 +1379,36 @@ fsp_err_t R_SCE_AES256CTR_EncryptUpdate (sce_aes_handle_t * handle, * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length * are provided for compatibility in anticipation of the time when this restriction is lifted. * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) + * @param[in,out] handle AES handler (work area) + * @param[in,out] cipher ciphertext data area (nothing ever written here) * @param[in,out] cipher_length ciphertext data length (0 always written here) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CTR_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256ctrenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *cipher_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CtrEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256ctrenc_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *cipher_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CtrEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); } /*******************************************************************************************************************//** @@ -1416,32 +1416,32 @@ fsp_err_t R_SCE_AES256CTR_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cip * and writes the result to the first argument, handle. The value of handle is used as an argument * in the subsequent R_SCE_AES256CTR_DecryptUpdate() function and R_SCE_AES256CTR_DecryptFinal() function. * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initialization vector area (16byte) + * @param[in,out] handle AES handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in] initial_vector initialization vector area (16byte) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CTR_DecryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) +fsp_err_t R_SCE_AES256CTR_DecryptInit (sce_aes_handle_t * handle, + sce_aes_wrapped_key_t * wrapped_key, + uint8_t * initial_vector) { - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256ctrdec_private_id = g_private_id_counter; - handle->id = g_aes256ctrdec_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CtrDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); + memset(handle, 0, sizeof(sce_aes_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256ctrdec_private_id = g_private_id_counter; + handle->id = g_aes256ctrdec_private_id; + memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CtrDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); } /*******************************************************************************************************************//** @@ -1453,44 +1453,44 @@ fsp_err_t R_SCE_AES256CTR_DecryptInit (sce_aes_handle_t * handle, * Specify areas for plain and cipher that do not overlap. For plain and cipher, * specify RAM addresses that are multiples of 4. * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area + * @param[in,out] handle AES handler (work area) + * @param[in] cipher ciphertext data area + * @param[in,out] plain plaintext data area * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CTR_DecryptUpdate (sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length) + uint8_t * cipher, + uint8_t * plain, + uint32_t cipher_length) { - uint32_t block_num = (cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE); - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256ctrdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = cipher_length; - memcpy(handle->last_1_block_as_fraction, - (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes256CtrDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); - cal_current_ivec_ctrmode(handle, block_num); - - return FSP_SUCCESS; + uint32_t block_num = (cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256ctrdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->current_input_data_size = cipher_length; + memcpy(handle->last_1_block_as_fraction, + (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), + (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes256CtrDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); + cal_current_ivec_ctrmode(handle, block_num); + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -1502,36 +1502,36 @@ fsp_err_t R_SCE_AES256CTR_DecryptUpdate (sce_aes_handle_t * handle, * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length * are provided for compatibility in anticipation of the time when this restriction is lifted. * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) + * @param[in,out] handle AES handler (work area) + * @param[in,out] plain plaintext data area (nothing ever written here) * @param[in,out] plain_length plaintext data length (0 always written here) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CTR_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) { - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256ctrdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *plain_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CtrDecryptFinalPrivate((uint32_t *) (plain), plain_length); + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256ctrdec_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + *plain_length = 0; + memset(handle, 0, sizeof(sce_aes_handle_t)); + + /* Casting uint32_t pointer is used for address. */ + return R_SCE_Aes256CtrDecryptFinalPrivate((uint32_t *) (plain), plain_length); } /*******************************************************************************************************************//** @@ -1539,29 +1539,29 @@ fsp_err_t R_SCE_AES256CTR_DecryptFinal (sce_aes_handle_t * handle, uint8_t * pla * and writes the result to the first argument, handle. The value of handle is used as an argument in the subsequent * R_SCE_AES128CMAC_GenerateUpdate() function and R_SCE_AES128CMAC_GenerateFinal() function. * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CMAC_GenerateInit (sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) { - memset(handle, 0, sizeof(sce_cmac_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128cmacgen_private_id = g_private_id_counter; - handle->id = g_aes128cmacgen_private_id; - memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES128_KEY_INDEX_WORD_SIZE * 4); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - - return R_SCE_Aes128CmacGenerateInitPrivate(wrapped_key); + memset(handle, 0, sizeof(sce_cmac_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128cmacgen_private_id = g_private_id_counter; + handle->id = g_aes128cmacgen_private_id; + memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES128_KEY_INDEX_WORD_SIZE * 4); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + + return R_SCE_Aes128CmacGenerateInitPrivate(wrapped_key); } /*******************************************************************************************************************//** @@ -1573,62 +1573,62 @@ fsp_err_t R_SCE_AES128CMAC_GenerateInit (sce_cmac_handle_t * handle, sce_aes_wra * to input when the user calls this function. If the input value, message, is not a multiple of 16 bytes, * it will be padded within the function. For message, specify a RAM address that are multiples of 4. * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CMAC_GenerateUpdate (sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length) { - uint32_t length_rest = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128cmacgen_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->all_received_length += message_length; - if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), - message, - HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes128CmacGenerateUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); - length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - R_SCE_Aes128CmacGenerateUpdatePrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), - (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); - length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); - } - - handle->buffering_length = 0; - memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); - handle->buffering_length = length_rest; - } - else - { - memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); - handle->buffering_length += message_length; - } - - return FSP_SUCCESS; + uint32_t length_rest = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128cmacgen_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->all_received_length += message_length; + if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), + message, + HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes128CmacGenerateUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); + length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + R_SCE_Aes128CmacGenerateUpdatePrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), + (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); + length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); + } + + handle->buffering_length = 0; + memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); + handle->buffering_length = length_rest; + } + else + { + memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); + handle->buffering_length += message_length; + } + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -1636,46 +1636,46 @@ fsp_err_t R_SCE_AES128CMAC_GenerateUpdate (sce_cmac_handle_t * handle, uint8_t * * in the second argument, mac, and ends CMAC mode. * * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (16byte) + * @param[in,out] mac MAC data area (16byte) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Not used. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Not used. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CMAC_GenerateFinal (sce_cmac_handle_t * handle, uint8_t * mac) { - fsp_err_t ercd = FSP_SUCCESS; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128cmacgen_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) - { - handle->cmac_buffer[handle->buffering_length] = 1 << 7; - memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, - HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); - } - - ercd = R_SCE_Aes128CmacGenerateFinalPrivate(handle->all_received_length, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (handle->cmac_buffer), - (uint32_t *) (mac)); - memset(handle, 0, sizeof(sce_cmac_handle_t)); - - return ercd; + fsp_err_t ercd = FSP_SUCCESS; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128cmacgen_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) + { + handle->cmac_buffer[handle->buffering_length] = 1 << 7; + memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, + HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); + } + + ercd = R_SCE_Aes128CmacGenerateFinalPrivate(handle->all_received_length, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (handle->cmac_buffer), + (uint32_t *) (mac)); + memset(handle, 0, sizeof(sce_cmac_handle_t)); + + return ercd; } /*******************************************************************************************************************//** @@ -1683,29 +1683,29 @@ fsp_err_t R_SCE_AES128CMAC_GenerateFinal (sce_cmac_handle_t * handle, uint8_t * * and writes the result to the first argument, handle. The value of handle is used as an argumentin the subsequent * R_SCE_AES128CMAC_VerifyUpdate() function and R_SCE_AES128CMAC_VerifyFinal() function. * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 128-bit AES wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CMAC_VerifyInit (sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) { - memset(handle, 0, sizeof(sce_cmac_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128cmacver_private_id = g_private_id_counter; - handle->id = g_aes128cmacver_private_id; - memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES128_KEY_INDEX_WORD_SIZE * 4); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - - return R_SCE_Aes128CmacVerifyInitPrivate(wrapped_key); + memset(handle, 0, sizeof(sce_cmac_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes128cmacver_private_id = g_private_id_counter; + handle->id = g_aes128cmacver_private_id; + memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES128_KEY_INDEX_WORD_SIZE * 4); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + + return R_SCE_Aes128CmacVerifyInitPrivate(wrapped_key); } /*******************************************************************************************************************//** @@ -1717,62 +1717,62 @@ fsp_err_t R_SCE_AES128CMAC_VerifyInit (sce_cmac_handle_t * handle, sce_aes_wrapp * when the user calls this function. If the input value, message, is not a multiple of 16 bytes, * it will be padded within the function. For message, specify a RAM address that are multiples of 4. * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CMAC_VerifyUpdate (sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length) { - uint32_t length_rest = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128cmacver_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->all_received_length += message_length; - if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), - message, - HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes128CmacVerifyUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); - length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - R_SCE_Aes128CmacVerifyUpdatePrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), - (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); - length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); - } - - handle->buffering_length = 0; - memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); - handle->buffering_length = length_rest; - } - else - { - memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); - handle->buffering_length += message_length; - } - - return FSP_SUCCESS; + uint32_t length_rest = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes128cmacver_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->all_received_length += message_length; + if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), + message, + HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes128CmacVerifyUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); + length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + R_SCE_Aes128CmacVerifyUpdatePrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), + (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); + length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); + } + + handle->buffering_length = 0; + memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); + handle->buffering_length = length_rest; + } + else + { + memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); + handle->buffering_length += message_length; + } + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -1780,62 +1780,62 @@ fsp_err_t R_SCE_AES128CMAC_VerifyUpdate (sce_cmac_handle_t * handle, uint8_t * m * in the second argument, mac, and verifies the MAC value. If authentication fails, the return value will be * TSIP_ERR_AUTHENTICATION. If the MAC value is less than 16 bytes, it will be padded with zeros inside the function. * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (mac_length byte) + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (mac_length byte) * @param[in,out] mac_length MAC data length (2 to 16 bytes) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES128CMAC_VerifyFinal (sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length) { - fsp_err_t ercd = FSP_SUCCESS; - uint32_t mac_tmp[16 / sizeof(uint32_t)] = - { - 0 /* mac_tmp is initialized with 0. */ - }; - uint32_t mac_length_bit = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128cmacver_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((2 > mac_length) || (mac_length > HW_SCE_AES_BLOCK_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) - { - handle->cmac_buffer[handle->buffering_length] = 1 << 7; - memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, - HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); - } - - memcpy(mac_tmp, mac, mac_length); - mac_length_bit = change_endian_long(mac_length * 8); - - ercd = R_SCE_Aes128CmacVerifyFinalPrivate(handle->all_received_length, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) handle->cmac_buffer, - (uint32_t *) mac_tmp, - &mac_length_bit); - memset(handle, 0, sizeof(sce_cmac_handle_t)); - - return ercd; + fsp_err_t ercd = FSP_SUCCESS; + uint32_t mac_tmp[16 / sizeof(uint32_t)] = + { + 0 /* mac_tmp is initialized with 0. */ + }; + uint32_t mac_length_bit = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes128cmacver_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((2 > mac_length) || (mac_length > HW_SCE_AES_BLOCK_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) + { + handle->cmac_buffer[handle->buffering_length] = 1 << 7; + memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, + HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); + } + + memcpy(mac_tmp, mac, mac_length); + mac_length_bit = change_endian_long(mac_length * 8); + + ercd = R_SCE_Aes128CmacVerifyFinalPrivate(handle->all_received_length, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) handle->cmac_buffer, + (uint32_t *) mac_tmp, + &mac_length_bit); + memset(handle, 0, sizeof(sce_cmac_handle_t)); + + return ercd; } /*******************************************************************************************************************//** @@ -1843,29 +1843,29 @@ fsp_err_t R_SCE_AES128CMAC_VerifyFinal (sce_cmac_handle_t * handle, uint8_t * ma * and writes the result to the first argument, handle. The value of handle is used as an argument in the subsequent * R_SCE_AES256CMAC_GenerateUpdate() function and R_SCE_AES256CMAC_GenerateFinal() function. * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CMAC_GenerateInit (sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) { - memset(handle, 0, sizeof(sce_cmac_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256cmacgen_private_id = g_private_id_counter; - handle->id = g_aes256cmacgen_private_id; - memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES256_KEY_INDEX_WORD_SIZE * 4); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - - return R_SCE_Aes256CmacGenerateInitPrivate(wrapped_key); + memset(handle, 0, sizeof(sce_cmac_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256cmacgen_private_id = g_private_id_counter; + handle->id = g_aes256cmacgen_private_id; + memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES256_KEY_INDEX_WORD_SIZE * 4); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + + return R_SCE_Aes256CmacGenerateInitPrivate(wrapped_key); } /*******************************************************************************************************************//** @@ -1877,62 +1877,62 @@ fsp_err_t R_SCE_AES256CMAC_GenerateInit (sce_cmac_handle_t * handle, sce_aes_wra * to input when the user calls this function. If the input value, message, is not a multiple of 16 bytes, * it will be padded within the function. For message, specify a RAM address that are multiples of 4. * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CMAC_GenerateUpdate (sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length) { - uint32_t length_rest = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256cmacgen_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->all_received_length += message_length; - if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), - message, - HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes256CmacGenerateUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); - length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - R_SCE_Aes256CmacGenerateUpdatePrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), - (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); - length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); - } - - handle->buffering_length = 0; - memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); - handle->buffering_length = length_rest; - } - else - { - memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); - handle->buffering_length += message_length; - } - - return FSP_SUCCESS; + uint32_t length_rest = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256cmacgen_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->all_received_length += message_length; + if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), + message, + HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes256CmacGenerateUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); + length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + R_SCE_Aes256CmacGenerateUpdatePrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), + (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); + length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); + } + + handle->buffering_length = 0; + memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); + handle->buffering_length = length_rest; + } + else + { + memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); + handle->buffering_length += message_length; + } + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -1940,46 +1940,46 @@ fsp_err_t R_SCE_AES256CMAC_GenerateUpdate (sce_cmac_handle_t * handle, uint8_t * * in the second argument, mac, and ends CMAC mode. * * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (16byte) + * @param[in,out] mac MAC data area (16byte) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Not used. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Not used. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CMAC_GenerateFinal (sce_cmac_handle_t * handle, uint8_t * mac) { - fsp_err_t ercd = FSP_SUCCESS; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256cmacgen_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) - { - handle->cmac_buffer[handle->buffering_length] = 1 << 7; - memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, - HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); - } - - ercd = R_SCE_Aes256CmacGenerateFinalPrivate(handle->all_received_length, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (handle->cmac_buffer), - (uint32_t *) (mac)); - memset(handle, 0, sizeof(sce_cmac_handle_t)); - - return ercd; + fsp_err_t ercd = FSP_SUCCESS; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256cmacgen_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) + { + handle->cmac_buffer[handle->buffering_length] = 1 << 7; + memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, + HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); + } + + ercd = R_SCE_Aes256CmacGenerateFinalPrivate(handle->all_received_length, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (handle->cmac_buffer), + (uint32_t *) (mac)); + memset(handle, 0, sizeof(sce_cmac_handle_t)); + + return ercd; } /*******************************************************************************************************************//** @@ -1987,29 +1987,29 @@ fsp_err_t R_SCE_AES256CMAC_GenerateFinal (sce_cmac_handle_t * handle, uint8_t * * and writes the result to the first argument, handle. The value of handle is used as an argumentin the subsequent * R_SCE_AES256CMAC_VerifyUpdate() function and R_SCE_AES256CMAC_VerifyFinal() function. * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] wrapped_key 256-bit AES wrapped key * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CMAC_VerifyInit (sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) { - memset(handle, 0, sizeof(sce_cmac_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256cmacver_private_id = g_private_id_counter; - handle->id = g_aes256cmacver_private_id; - memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES256_KEY_INDEX_WORD_SIZE * 4); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - - return R_SCE_Aes256CmacVerifyInitPrivate(wrapped_key); + memset(handle, 0, sizeof(sce_cmac_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_aes256cmacver_private_id = g_private_id_counter; + handle->id = g_aes256cmacver_private_id; + memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES256_KEY_INDEX_WORD_SIZE * 4); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + + return R_SCE_Aes256CmacVerifyInitPrivate(wrapped_key); } /*******************************************************************************************************************//** @@ -2021,62 +2021,62 @@ fsp_err_t R_SCE_AES256CMAC_VerifyInit (sce_cmac_handle_t * handle, sce_aes_wrapp * when the user calls this function. If the input value, message, is not a multiple of 16 bytes, * it will be padded within the function. For message, specify a RAM address that are multiples of 4. * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in] message message data area (message_length byte) + * @param[in] message_length message data length (0 or more bytes) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CMAC_VerifyUpdate (sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length) { - uint32_t length_rest = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256cmacver_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->all_received_length += message_length; - if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), - message, - HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes256CmacVerifyUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); - length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - R_SCE_Aes256CmacVerifyUpdatePrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), - (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); - length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); - } - - handle->buffering_length = 0; - memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); - handle->buffering_length = length_rest; - } - else - { - memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); - handle->buffering_length += message_length; - } - - return FSP_SUCCESS; + uint32_t length_rest = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_aes256cmacver_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->all_received_length += message_length; + if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), + message, + HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + + /* Casting uint32_t pointer is used for address. */ + R_SCE_Aes256CmacVerifyUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); + length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); + memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); + if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) + { + R_SCE_Aes256CmacVerifyUpdatePrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), + (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); + length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); + } + + handle->buffering_length = 0; + memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); + handle->buffering_length = length_rest; + } + else + { + memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); + handle->buffering_length += message_length; + } + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -2084,62 +2084,62 @@ fsp_err_t R_SCE_AES256CMAC_VerifyUpdate (sce_cmac_handle_t * handle, uint8_t * m * in the second argument, mac, and verifies the MAC value. If authentication fails, the return value will be * TSIP_ERR_AUTHENTICATION. If the MAC value is less than 16 bytes, it will be padded with zeros inside the function. * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (mac_length byte) + * @param[in,out] handle AES-CMAC handler (work area) + * @param[in,out] mac MAC data area (mac_length byte) * @param[in,out] mac_length MAC data length (2 to 16 bytes) * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * @retval FSP_SUCCESS Normal termination + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_AES256CMAC_VerifyFinal (sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length) { - fsp_err_t ercd = FSP_SUCCESS; - uint32_t mac_tmp[16 / sizeof(uint32_t)] = - { - 0 /* mac_tmp is initialized with 0. */ - }; - uint32_t mac_length_bit = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256cmacver_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((2 > mac_length) || (mac_length > HW_SCE_AES_BLOCK_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) - { - handle->cmac_buffer[handle->buffering_length] = 1 << 7; - memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, - HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); - } - - memcpy(mac_tmp, mac, mac_length); - mac_length_bit = change_endian_long(mac_length * 8); - - ercd = R_SCE_Aes256CmacVerifyFinalPrivate(handle->all_received_length, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) handle->cmac_buffer, - (uint32_t *) mac_tmp, - &mac_length_bit); - memset(handle, 0, sizeof(sce_cmac_handle_t)); - - return ercd; + fsp_err_t ercd = FSP_SUCCESS; + uint32_t mac_tmp[16 / sizeof(uint32_t)] = + { + 0 /* mac_tmp is initialized with 0. */ + }; + uint32_t mac_length_bit = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_aes256cmacver_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((2 > mac_length) || (mac_length > HW_SCE_AES_BLOCK_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) + { + handle->cmac_buffer[handle->buffering_length] = 1 << 7; + memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, + HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); + } + + memcpy(mac_tmp, mac, mac_length); + mac_length_bit = change_endian_long(mac_length * 8); + + ercd = R_SCE_Aes256CmacVerifyFinalPrivate(handle->all_received_length, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) handle->cmac_buffer, + (uint32_t *) mac_tmp, + &mac_length_bit); + memset(handle, 0, sizeof(sce_cmac_handle_t)); + + return ercd; } /*******************************************************************************************************************//** @@ -2153,22 +2153,22 @@ fsp_err_t R_SCE_AES256CMAC_VerifyFinal (sce_cmac_handle_t * handle, uint8_t * ma /****************************************************************************** * calculate curent ivec after update process on AES COUNTER mode * - * @param[in] block_num encrypted block number. - * @param[in,out] handle Handler for AES(work area). + * @param[in] block_num encrypted block number. + * @param[in,out] handle Handler for AES(work area). * * Return Value :none *****************************************************************************/ static void cal_current_ivec_ctrmode(sce_aes_handle_t *handle , uint32_t block_num) { - uint8_t carry_num = 0; - for (uint8_t i = 0; i < 16; i++) - { - uint16_t current_byte_sum = (uint16_t)(carry_num + handle->current_initial_vector[15 - i]); - if (i < (sizeof(block_num))) - { - current_byte_sum = (uint16_t)((uint32_t)current_byte_sum + ((block_num >> (i * 8)) & 0xFF)); - } - handle->current_initial_vector[15 - i] = (uint8_t)(current_byte_sum & 0xFF); - carry_num = (uint8_t)(current_byte_sum >> 8) & 0xFF; - } + uint8_t carry_num = 0; + for (uint8_t i = 0; i < 16; i++) + { + uint16_t current_byte_sum = (uint16_t)(carry_num + handle->current_initial_vector[15 - i]); + if (i < (sizeof(block_num))) + { + current_byte_sum = (uint16_t)((uint32_t)current_byte_sum + ((block_num >> (i * 8)) & 0xFF)); + } + handle->current_initial_vector[15 - i] = (uint8_t)(current_byte_sum & 0xFF); + carry_num = (uint8_t)(current_byte_sum >> 8) & 0xFF; + } } diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_ecc.c b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_ecc.c index 103a17c0d..ff775ae5c 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_ecc.c +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_ecc.c @@ -17,13 +17,13 @@ * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. *********************************************************************************************************************/ /********************************************************************************************************************** - * File Name : r_sce_ecc.c - * Version : 1.0 - * Description : SCE ECC Public API source file + * File Name : r_sce_ecc.c + * Version : 1.0 + * Description : SCE ECC Public API source file *********************************************************************************************************************/ /********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release *********************************************************************************************************************/ /*********************************************************************************************************************** @@ -36,22 +36,22 @@ * Macro definitions **********************************************************************************************************************/ /* Hash data output position for ECDSA P-192. : (256 - 192) / 32 */ -#define SCE_PRV_HASH_WORD_POS_ECDSA_P192 (2) +#define SCE_PRV_HASH_WORD_POS_ECDSA_P192 (2) /* Hash data output position for ECDSA P-224. : (256 - 224) / 32 */ -#define SCE_PRV_HASH_WORD_POS_ECDSA_P224 (1) +#define SCE_PRV_HASH_WORD_POS_ECDSA_P224 (1) /* Hash data output position for ECDSA P-256. : (256 - 256) / 32 */ -#define SCE_PRV_HASH_WORD_POS_ECDSA_P256 (0) +#define SCE_PRV_HASH_WORD_POS_ECDSA_P256 (0) /* For ECDSA P-512 : (256 - 512) / 32 */ -#define SCE_PRV_HASH_WORD_POS_ECDSA_P512 (0xFFFFFFF8UL) +#define SCE_PRV_HASH_WORD_POS_ECDSA_P512 (0xFFFFFFF8UL) #ifndef SCE_HEX_FF -#define SCE_HEX_FF (0xFF) +#define SCE_HEX_FF (0xFF) #endif #ifndef SCE_HEX_80 -#define SCE_HEX_80 (0x80) +#define SCE_HEX_80 (0x80) #endif #ifndef SCE_DEC_64 -#define SCE_DEC_64 (64) +#define SCE_DEC_64 (64) #endif /*********************************************************************************************************************** @@ -62,8 +62,8 @@ * Private function prototypes **********************************************************************************************************************/ static fsp_err_t set_ecdsa_hash_data(sce_ecdsa_byte_data_t * p_message_hash, - uint32_t * data_buff, - uint32_t hash_word_pos); + uint32_t * data_buff, + uint32_t hash_word_pos); /*********************************************************************************************************************** * Private global variables @@ -93,62 +93,62 @@ static fsp_err_t set_ecdsa_hash_data(sce_ecdsa_byte_data_t * p_message_hash, * argument, signature, in accordance with secp192r1 using the private wrapped key input as the third argument, * wrapped_key. * - * @param[in] message_hash Message or hash value to which to attach signature - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in,out] signature Signature text storage destination information - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "0 padding (64 bits) || - * signature r (192 bits) || 0 padding (64 bits) || - * signature s (192 bits)". - * @arg signature->data_length : Data length (byte units) - * @param[in] wrapped_key Input wrapped key of secp192r1 private key. - * - * @retval FSP_SUCCESS Normal end + * @param[in] message_hash Message or hash value to which to attach signature + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in,out] signature Signature text storage destination information + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "0 padding (64 bits) || + * signature r (192 bits) || 0 padding (64 bits) || + * signature s (192 bits)". + * @arg signature->data_length : Data length (byte units) + * @param[in] wrapped_key Input wrapped key of secp192r1 private key. + * + * @retval FSP_SUCCESS Normal end * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key) { - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P192 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P192); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_EcdsaSignatureGenerateSub( - /* Casting uint32_t pointer is used for address. */ - &curvetype, - &indata_cmd, - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - signature->data_length = HW_SCE_ECDSA_DATA_BYTE_SIZE; - - return error_code; + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P192 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P192); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_EcdsaSignatureGenerateSub( + /* Casting uint32_t pointer is used for address. */ + &curvetype, + &indata_cmd, + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + signature->data_length = HW_SCE_ECDSA_DATA_BYTE_SIZE; + + return error_code; } /*******************************************************************************************************************//** @@ -162,62 +162,62 @@ fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate (sce_ecdsa_byte_data_t * mes * argument, signature, in accordance with secp224r1 using the private wrapped key input as the third argument, * wrapped_key. * - * @param[in] message_hash Message or hash value to which to attach signature - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in,out] signature Signature text storage destination information - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "0 padding (32 bits) || - * signature r (224 bits) || 0 padding (32 bits) || - * signature s (224 bits)". - * @arg signature->data_length : Data length (byte units) - * @param[in] wrapped_key Input wrapped key of secp224r1 private key. - * - * @retval FSP_SUCCESS Normal end + * @param[in] message_hash Message or hash value to which to attach signature + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in,out] signature Signature text storage destination information + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "0 padding (32 bits) || + * signature r (224 bits) || 0 padding (32 bits) || + * signature s (224 bits)". + * @arg signature->data_length : Data length (byte units) + * @param[in] wrapped_key Input wrapped key of secp224r1 private key. + * + * @retval FSP_SUCCESS Normal end * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key) { - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P224 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P224); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_EcdsaSignatureGenerateSub( - /* Casting uint32_t pointer is used for address. */ - &curvetype, - &indata_cmd, - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - signature->data_length = HW_SCE_ECDSA_DATA_BYTE_SIZE; - - return error_code; + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P224 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P224); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_EcdsaSignatureGenerateSub( + /* Casting uint32_t pointer is used for address. */ + &curvetype, + &indata_cmd, + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + signature->data_length = HW_SCE_ECDSA_DATA_BYTE_SIZE; + + return error_code; } /*******************************************************************************************************************//** @@ -231,61 +231,61 @@ fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate (sce_ecdsa_byte_data_t * mes * argument, signature, in accordance with secp256r1 using the private wrapped key input as the third argument, * wrapped_key. * - * @param[in] message_hash Message or hash value to which to attach signature - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in,out] signature Signature text storage destination information - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "signature r (256 bits) || - * signature s (256 bits)". - * @arg signature->data_length : Data length (byte units) - * @param[in] wrapped_key Input wrapped key of secp256r1 private key. - * - * @retval FSP_SUCCESS Normal end + * @param[in] message_hash Message or hash value to which to attach signature + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in,out] signature Signature text storage destination information + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "signature r (256 bits) || + * signature s (256 bits)". + * @arg signature->data_length : Data length (byte units) + * @param[in] wrapped_key Input wrapped key of secp256r1 private key. + * + * @retval FSP_SUCCESS Normal end * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key) { - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P256 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P256); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_EcdsaSignatureGenerateSub( - /* Casting uint32_t pointer is used for address. */ - &curvetype, - &indata_cmd, - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - signature->data_length = HW_SCE_ECDSA_DATA_BYTE_SIZE; - - return error_code; + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P256 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P256); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_EcdsaSignatureGenerateSub( + /* Casting uint32_t pointer is used for address. */ + &curvetype, + &indata_cmd, + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + signature->data_length = HW_SCE_ECDSA_DATA_BYTE_SIZE; + + return error_code; } /*******************************************************************************************************************//** @@ -294,60 +294,60 @@ fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate (sce_ecdsa_byte_data_t * mes * argument, signature, in accordance with BrainpoolP512r1 using the private wrapped key input as the third argument, * wrapped_key. * - * @param[in] message_hash Message or hash value to which to attach signature - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (only Hash value(1) is support) - * @param[in,out] signature Signature text storage destination information - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "signature r (512 bits) || - * signature s (512 bits)". - * @arg signature->data_length : Data length (byte units) - * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 private key. - * - * @retval FSP_SUCCESS Normal end + * @param[in] message_hash Message or hash value to which to attach signature + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (only Hash value(1) is support) + * @param[in,out] signature Signature text storage destination information + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "signature r (512 bits) || + * signature s (512 bits)". + * @arg signature->data_length : Data length (byte units) + * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 private key. + * + * @retval FSP_SUCCESS Normal end * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, + sce_ecdsa_byte_data_t * signature, + sce_ecc_private_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[(HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - if (1 != message_hash->data_type) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P512); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = R_SCE_EcdsaP512SignatureGenerateSub( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - signature->data_length = HW_SCE_ECDSA_P512_DATA_BYTE_SIZE; - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[(HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + if (1 != message_hash->data_type) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P512); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = R_SCE_EcdsaP512SignatureGenerateSub( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + signature->data_length = HW_SCE_ECDSA_P512_DATA_BYTE_SIZE; + + return error_code; } /*******************************************************************************************************************//** @@ -361,61 +361,61 @@ fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate (sce_ecdsa_byte_data_t * signature, is validated in accordance with secp192r1 using the public wrapped key input as the third argument, * wrapped_key. * - * @param[in] signature Signature text information to be verified - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "0 padding (64 bits) || - * signature r (192 bits) || 0 padding (64 bits) || - * signature s (192 bits)". - * @arg signature->data_length : Specifies the data length (byte units) (nonuse) + * @param[in] signature Signature text information to be verified + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "0 padding (64 bits) || + * signature r (192 bits) || 0 padding (64 bits) || + * signature s (192 bits)". + * @arg signature->data_length : Specifies the data length (byte units) (nonuse) * @param[in,out] message_hash Message or hash value to be verified - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in] wrapped_key Input wrapped key of secp192r1 public key. - * - * @retval FSP_SUCCESS Normal end + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in] wrapped_key Input wrapped key of secp192r1 public key. + * + * @retval FSP_SUCCESS Normal end * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key) { - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P192 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P192); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_EcdsaSignatureVerificationSub( - /* Casting uint32_t pointer is used for address. */ - &curvetype, - &indata_cmd, - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - - return error_code; + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P192 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P192); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_EcdsaSignatureVerificationSub( + /* Casting uint32_t pointer is used for address. */ + &curvetype, + &indata_cmd, + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + + return error_code; } /*******************************************************************************************************************//** @@ -429,61 +429,61 @@ fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify (sce_ecdsa_byte_data_t * sign * signature, is validated in accordance with secp224r1 using the public wrapped key input as the third argument, * wrapped_key. * - * @param[in] signature Signature text information to be verified - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "0 padding (32 bits) || - * signature r (224 bits) || 0 padding (32 bits) || - * signature s (224 bits)". - * @arg signature->data_length : Specifies the data length (byte units) (nonuse) + * @param[in] signature Signature text information to be verified + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "0 padding (32 bits) || + * signature r (224 bits) || 0 padding (32 bits) || + * signature s (224 bits)". + * @arg signature->data_length : Specifies the data length (byte units) (nonuse) * @param[in,out] message_hash Message or hash value to be verified - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in] wrapped_key Input wrapped key of secp224r1 public key. - * - * @retval FSP_SUCCESS Normal end + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in] wrapped_key Input wrapped key of secp224r1 public key. + * + * @retval FSP_SUCCESS Normal end * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key) { - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P224 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P224); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_EcdsaSignatureVerificationSub( - /* Casting uint32_t pointer is used for address. */ - &curvetype, - &indata_cmd, - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - - return error_code; + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P224 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P224); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_EcdsaSignatureVerificationSub( + /* Casting uint32_t pointer is used for address. */ + &curvetype, + &indata_cmd, + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + + return error_code; } /*******************************************************************************************************************//** @@ -497,60 +497,60 @@ fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify (sce_ecdsa_byte_data_t * sign * signature, is validated in accordance with secp256r1 using the public wrapped key input as the third argument, * wrapped_key. * - * @param[in] signature Signature text information to be verified - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "signature r (256 bits) || - * signature s (256 bits)". - * @arg signature->data_length : Specifies the data length (byte units) (nonuse) + * @param[in] signature Signature text information to be verified + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "signature r (256 bits) || + * signature s (256 bits)". + * @arg signature->data_length : Specifies the data length (byte units) (nonuse) * @param[in,out] message_hash Message or hash value to be verified - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in] wrapped_key Input wrapped key of secp256r1 public key. - * - * @retval FSP_SUCCESS Normal end + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in] wrapped_key Input wrapped key of secp256r1 public key. + * + * @retval FSP_SUCCESS Normal end * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key) { - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P256 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P256); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_EcdsaSignatureVerificationSub( - /* Casting uint32_t pointer is used for address. */ - &curvetype, - &indata_cmd, - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - - return error_code; + uint32_t indata_cmd; + uint32_t curvetype; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P256 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P256); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); + curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); + error_code = R_SCE_EcdsaSignatureVerificationSub( + /* Casting uint32_t pointer is used for address. */ + &curvetype, + &indata_cmd, + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + + return error_code; } /*******************************************************************************************************************//** @@ -559,59 +559,59 @@ fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify (sce_ecdsa_byte_data_t * sign * signature, is validated in accordance with BrainpoolP512r1 using the public wrapped key input as the third argument, * wrapped_key. * - * @param[in] signature Signature text information to be verified - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "signature r (512 bits) || - * signature s (512 bits)". - * @arg signature->data_length : Specifies the data length (byte units) (nonuse) + * @param[in] signature Signature text information to be verified + * @arg signature->pdata : Specifies pointer to array storing signature text + * The signature format is "signature r (512 bits) || + * signature s (512 bits)". + * @arg signature->data_length : Specifies the data length (byte units) (nonuse) * @param[in,out] message_hash Message or hash value to be verified - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (only Hash value(1) is support) - * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 public key. - * - * @retval FSP_SUCCESS Normal end + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (only Hash value(1) is support) + * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 public key. + * + * @retval FSP_SUCCESS Normal end * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, + sce_ecdsa_byte_data_t * message_hash, + sce_ecc_public_wrapped_key_t * wrapped_key) { - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[(HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - if (1 != message_hash->data_type) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P512); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = R_SCE_EcdsaP512SignatureVerificationSub( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + uint32_t data_buff[(HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = + { + 0 + }; + + if (1 != message_hash->data_type) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P512); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = R_SCE_EcdsaP512SignatureVerificationSub( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) data_buff, + (uint32_t *) signature->pdata); + + return error_code; } /*******************************************************************************************************************//** @@ -626,60 +626,60 @@ fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify (sce_ecdsa_byte_data_t * * For messages, SHA hash operation is performed and the hash value is set according to ECDSA. * * @param p_message_hash message or hash value information - * @param data_buff pointer to the hash value area, including 0 padding - * @param hash_word_pos hash value output word position from the beginning of the data_buff + * @param data_buff pointer to the hash value area, including 0 padding + * @param hash_word_pos hash value output word position from the beginning of the data_buff * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input parameter illegal - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input parameter illegal + * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. **********************************************************************************************************************/ static fsp_err_t set_ecdsa_hash_data (sce_ecdsa_byte_data_t * p_message_hash, - uint32_t * data_buff, - uint32_t hash_word_pos) + uint32_t * data_buff, + uint32_t hash_word_pos) { - fsp_err_t error_code = FSP_SUCCESS; - sce_sha_md5_handle_t ex_sha_handle = - { - 0 - }; - uint32_t hash_length = 0; - - if (0 == p_message_hash->data_type) - { - if (SCE_PRV_HASH_WORD_POS_ECDSA_P512 != hash_word_pos) - { - R_SCE_SHA256_Init(&ex_sha_handle); - error_code = R_SCE_SHA256_Update(&ex_sha_handle, p_message_hash->pdata, p_message_hash->data_length); - if (FSP_SUCCESS == error_code) - { - /* Casting uint8_t pointer is used for address. */ - error_code = R_SCE_SHA256_Final(&ex_sha_handle, (uint8_t *) &data_buff[hash_word_pos], &hash_length); - } - } - else - { - error_code = FSP_ERR_CRYPTO_SCE_FAIL; - } - } - else if (1 == p_message_hash->data_type) - { - if (SCE_PRV_HASH_WORD_POS_ECDSA_P512 != hash_word_pos) - { - memcpy(&data_buff[hash_word_pos], - p_message_hash->pdata, - HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE - (hash_word_pos * sizeof(uint32_t))); - } - else - { - memcpy(data_buff, p_message_hash->pdata, HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE); - } - } - else - { - error_code = FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + sce_sha_md5_handle_t ex_sha_handle = + { + 0 + }; + uint32_t hash_length = 0; + + if (0 == p_message_hash->data_type) + { + if (SCE_PRV_HASH_WORD_POS_ECDSA_P512 != hash_word_pos) + { + R_SCE_SHA256_Init(&ex_sha_handle); + error_code = R_SCE_SHA256_Update(&ex_sha_handle, p_message_hash->pdata, p_message_hash->data_length); + if (FSP_SUCCESS == error_code) + { + /* Casting uint8_t pointer is used for address. */ + error_code = R_SCE_SHA256_Final(&ex_sha_handle, (uint8_t *) &data_buff[hash_word_pos], &hash_length); + } + } + else + { + error_code = FSP_ERR_CRYPTO_SCE_FAIL; + } + } + else if (1 == p_message_hash->data_type) + { + if (SCE_PRV_HASH_WORD_POS_ECDSA_P512 != hash_word_pos) + { + memcpy(&data_buff[hash_word_pos], + p_message_hash->pdata, + HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE - (hash_word_pos * sizeof(uint32_t))); + } + else + { + memcpy(data_buff, p_message_hash->pdata, HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE); + } + } + else + { + error_code = FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + return error_code; } diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_rsa.c b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_rsa.c index a4e2a9920..c43fdd2c5 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_rsa.c +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_rsa.c @@ -17,13 +17,13 @@ * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. *********************************************************************************************************************/ /********************************************************************************************************************** - * File Name : r_sce_rsa.c - * Version : 1.0 - * Description : SCE RSA Public API source file + * File Name : r_sce_rsa.c + * Version : 1.0 + * Description : SCE RSA Public API source file *********************************************************************************************************************/ /********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release *********************************************************************************************************************/ /*********************************************************************************************************************** @@ -36,28 +36,28 @@ /*********************************************************************************************************************** * Macro definitions **********************************************************************************************************************/ -#define SCE_RSA_SIG_SHA256_PREFIX_00 (0x30) -#define SCE_RSA_SIG_SHA256_PREFIX_01 (0x31) -#define SCE_RSA_SIG_SHA256_PREFIX_02 (0x30) -#define SCE_RSA_SIG_SHA256_PREFIX_03 (0x0d) -#define SCE_RSA_SIG_SHA256_PREFIX_04 (0x06) -#define SCE_RSA_SIG_SHA256_PREFIX_05 (0x09) -#define SCE_RSA_SIG_SHA256_PREFIX_06 (0x60) -#define SCE_RSA_SIG_SHA256_PREFIX_07 (0x86) -#define SCE_RSA_SIG_SHA256_PREFIX_08 (0x48) -#define SCE_RSA_SIG_SHA256_PREFIX_09 (0x01) -#define SCE_RSA_SIG_SHA256_PREFIX_10 (0x65) -#define SCE_RSA_SIG_SHA256_PREFIX_11 (0x03) -#define SCE_RSA_SIG_SHA256_PREFIX_12 (0x04) -#define SCE_RSA_SIG_SHA256_PREFIX_13 (0x02) -#define SCE_RSA_SIG_SHA256_PREFIX_14 (0x01) -#define SCE_RSA_SIG_SHA256_PREFIX_15 (0x05) -#define SCE_RSA_SIG_SHA256_PREFIX_16 (0x00) -#define SCE_RSA_SIG_SHA256_PREFIX_17 (0x04) -#define SCE_RSA_SIG_SHA256_PREFIX_18 (0x20) +#define SCE_RSA_SIG_SHA256_PREFIX_00 (0x30) +#define SCE_RSA_SIG_SHA256_PREFIX_01 (0x31) +#define SCE_RSA_SIG_SHA256_PREFIX_02 (0x30) +#define SCE_RSA_SIG_SHA256_PREFIX_03 (0x0d) +#define SCE_RSA_SIG_SHA256_PREFIX_04 (0x06) +#define SCE_RSA_SIG_SHA256_PREFIX_05 (0x09) +#define SCE_RSA_SIG_SHA256_PREFIX_06 (0x60) +#define SCE_RSA_SIG_SHA256_PREFIX_07 (0x86) +#define SCE_RSA_SIG_SHA256_PREFIX_08 (0x48) +#define SCE_RSA_SIG_SHA256_PREFIX_09 (0x01) +#define SCE_RSA_SIG_SHA256_PREFIX_10 (0x65) +#define SCE_RSA_SIG_SHA256_PREFIX_11 (0x03) +#define SCE_RSA_SIG_SHA256_PREFIX_12 (0x04) +#define SCE_RSA_SIG_SHA256_PREFIX_13 (0x02) +#define SCE_RSA_SIG_SHA256_PREFIX_14 (0x01) +#define SCE_RSA_SIG_SHA256_PREFIX_15 (0x05) +#define SCE_RSA_SIG_SHA256_PREFIX_16 (0x00) +#define SCE_RSA_SIG_SHA256_PREFIX_17 (0x04) +#define SCE_RSA_SIG_SHA256_PREFIX_18 (0x20) #ifndef SCE_HEX_FF -#define SCE_HEX_FF (0xff) +#define SCE_HEX_FF (0xff) #endif /*********************************************************************************************************************** @@ -69,10 +69,10 @@ **********************************************************************************************************************/ static fsp_err_t calc_hash_data(uint8_t * p_mes, uint8_t * p_hash, uint32_t mes_len, uint8_t hash_type); static fsp_err_t set_rsassapkcs_hash_data(sce_rsa_byte_data_t * p_message_hash, - uint8_t hash_type, - uint32_t rsa_key_byte_size, - uint8_t * data_buff); -static uint32_t get_keyn_size(uint32_t * prsa_key_index, uint32_t key_max_size); + uint8_t hash_type, + uint32_t rsa_key_byte_size, + uint8_t * data_buff); +static uint32_t get_keyn_size(uint32_t * prsa_key_index, uint32_t key_max_size); static fsp_err_t get_rand_rsaes_pkcs(uint32_t rand_size, uint8_t * prand_data); /*********************************************************************************************************************** @@ -80,25 +80,25 @@ static fsp_err_t get_rand_rsaes_pkcs(uint32_t rand_size, uint8_t * prand_data); **********************************************************************************************************************/ static uint8_t gs_rsa_sig_sha256_prefix[] = { - SCE_RSA_SIG_SHA256_PREFIX_00, - SCE_RSA_SIG_SHA256_PREFIX_01, - SCE_RSA_SIG_SHA256_PREFIX_02, - SCE_RSA_SIG_SHA256_PREFIX_03, - SCE_RSA_SIG_SHA256_PREFIX_04, - SCE_RSA_SIG_SHA256_PREFIX_05, - SCE_RSA_SIG_SHA256_PREFIX_06, - SCE_RSA_SIG_SHA256_PREFIX_07, - SCE_RSA_SIG_SHA256_PREFIX_08, - SCE_RSA_SIG_SHA256_PREFIX_09, - SCE_RSA_SIG_SHA256_PREFIX_10, - SCE_RSA_SIG_SHA256_PREFIX_11, - SCE_RSA_SIG_SHA256_PREFIX_12, - SCE_RSA_SIG_SHA256_PREFIX_13, - SCE_RSA_SIG_SHA256_PREFIX_14, - SCE_RSA_SIG_SHA256_PREFIX_15, - SCE_RSA_SIG_SHA256_PREFIX_16, - SCE_RSA_SIG_SHA256_PREFIX_17, - SCE_RSA_SIG_SHA256_PREFIX_18 + SCE_RSA_SIG_SHA256_PREFIX_00, + SCE_RSA_SIG_SHA256_PREFIX_01, + SCE_RSA_SIG_SHA256_PREFIX_02, + SCE_RSA_SIG_SHA256_PREFIX_03, + SCE_RSA_SIG_SHA256_PREFIX_04, + SCE_RSA_SIG_SHA256_PREFIX_05, + SCE_RSA_SIG_SHA256_PREFIX_06, + SCE_RSA_SIG_SHA256_PREFIX_07, + SCE_RSA_SIG_SHA256_PREFIX_08, + SCE_RSA_SIG_SHA256_PREFIX_09, + SCE_RSA_SIG_SHA256_PREFIX_10, + SCE_RSA_SIG_SHA256_PREFIX_11, + SCE_RSA_SIG_SHA256_PREFIX_12, + SCE_RSA_SIG_SHA256_PREFIX_13, + SCE_RSA_SIG_SHA256_PREFIX_14, + SCE_RSA_SIG_SHA256_PREFIX_15, + SCE_RSA_SIG_SHA256_PREFIX_16, + SCE_RSA_SIG_SHA256_PREFIX_17, + SCE_RSA_SIG_SHA256_PREFIX_18 }; /*********************************************************************************************************************** @@ -123,55 +123,55 @@ static uint8_t gs_rsa_sig_sha256_prefix[] = * message_hash->data_type, a hash value calculated with a hash algorithm as specified by the fourth argument, * hash_type, must be input to message_hash->pdata. * - * @param[in] message_hash Message or hash value to which to attach signature - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in,out] signature Signature text storage destination information - * @arg signature->pdata : Specifies pointer to array storing the signature text - * @arg signature->data_length : data length - * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + * @param[in] message_hash Message or hash value to which to attach signature + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in,out] signature Signature text storage destination information + * @arg signature->pdata : Specifies pointer to array storing the signature text + * @arg signature->data_length : data length + * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate (sce_rsa_byte_data_t * message_hash, - sce_rsa_byte_data_t * signature, - sce_rsa1024_private_wrapped_key_t * wrapped_key, - uint8_t hash_type) +fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate (sce_rsa_byte_data_t * message_hash, + sce_rsa_byte_data_t * signature, + sce_rsa1024_private_wrapped_key_t * wrapped_key, + uint8_t hash_type) { - fsp_err_t error_code = FSP_SUCCESS; - uint8_t data_buff[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - - error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_1024_DATA_BYTE_SIZE, data_buff); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = R_SCE_Rsa1024ModularExponentDecryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (data_buff), - (uint32_t *) (signature->pdata)); - - signature->data_length = HW_SCE_RSA_1024_DATA_BYTE_SIZE; - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + uint8_t data_buff[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + + error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_1024_DATA_BYTE_SIZE, data_buff); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = R_SCE_Rsa1024ModularExponentDecryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (data_buff), + (uint32_t *) (signature->pdata)); + + signature->data_length = HW_SCE_RSA_1024_DATA_BYTE_SIZE; + + return error_code; } /*******************************************************************************************************************//** @@ -184,274 +184,274 @@ fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate (sce_rsa_byte_data_t * mes * in the second argument, message_hash->data_type, a hash value calculated with a hash algorithm as specified by the * fourth argument, hash_type, must be input to message_hash->pdata. * - * @param[in] signature Signature text information to verify - * @arg signature->pdata : Specifies pointer to array storing the signature text - * @arg signature->data_length : Specifies effective data length of the array + * @param[in] signature Signature text information to verify + * @arg signature->pdata : Specifies pointer to array storing the signature text + * @arg signature->data_length : Specifies effective data length of the array * @param[in] message_hash Message text or hash value to verify - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureVerify (sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, - sce_rsa1024_public_wrapped_key_t * wrapped_key, - uint8_t hash_type) +fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureVerify (sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, + sce_rsa1024_public_wrapped_key_t * wrapped_key, + uint8_t hash_type) { - fsp_err_t error_code = FSP_SUCCESS; - uint8_t data_buff[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t decrypt_data[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t data_ptr = 0; - - data_ptr = HW_SCE_RSA_1024_DATA_BYTE_SIZE - signature->data_length; - memcpy(data_buff + data_ptr, signature->pdata, signature->data_length); - - error_code = R_SCE_Rsa1024ModularExponentEncryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (data_buff), - (uint32_t *) (decrypt_data)); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_1024_DATA_BYTE_SIZE, data_buff); - if (FSP_SUCCESS == error_code) - { - if (memcmp(data_buff, decrypt_data, HW_SCE_RSA_1024_DATA_BYTE_SIZE)) - { - error_code = FSP_ERR_CRYPTO_SCE_AUTHENTICATION; - } - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + uint8_t data_buff[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t decrypt_data[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t data_ptr = 0; + + data_ptr = HW_SCE_RSA_1024_DATA_BYTE_SIZE - signature->data_length; + memcpy(data_buff + data_ptr, signature->pdata, signature->data_length); + + error_code = R_SCE_Rsa1024ModularExponentEncryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (data_buff), + (uint32_t *) (decrypt_data)); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_1024_DATA_BYTE_SIZE, data_buff); + if (FSP_SUCCESS == error_code) + { + if (memcmp(data_buff, decrypt_data, HW_SCE_RSA_1024_DATA_BYTE_SIZE)) + { + error_code = FSP_ERR_CRYPTO_SCE_AUTHENTICATION; + } + } + + return error_code; } /*******************************************************************************************************************//** * The R_SCE_RSAES_PKCS1024_Encrypt() function RSA-encrypts the plaintext input to the first argument, plain, * according to RSAES-PKCS1-V1_5. It writes the encryption result to the second argument, cipher. * - * @param[in] plain plaintext - * @arg plain->pdata : Specifies pointer to array containing plaintext. - * @arg plain->data_length : Specifies valid data length of plaintext array. - * data size <= public key n size - 11 - * @param[in,out] cipher ciphertext - * @arg cipher->pdata : Specifies pointer to array containing ciphertext. - * @arg cipher->data_length : Inputs ciphertext buffer size. - * Outputs valid data length after encryption - * (public key n size). - * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. + * @param[in] plain plaintext + * @arg plain->pdata : Specifies pointer to array containing plaintext. + * @arg plain->data_length : Specifies valid data length of plaintext array. + * data size <= public key n size - 11 + * @param[in,out] cipher ciphertext + * @arg cipher->pdata : Specifies pointer to array containing ciphertext. + * @arg cipher->data_length : Inputs ciphertext buffer size. + * Outputs valid data length after encryption + * (public key n size). + * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSAES_PKCS1024_Encrypt (sce_rsa_byte_data_t * plain, - sce_rsa_byte_data_t * cipher, - sce_rsa1024_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_RSAES_PKCS1024_Encrypt (sce_rsa_byte_data_t * plain, + sce_rsa_byte_data_t * cipher, + sce_rsa1024_public_wrapped_key_t * wrapped_key) { - fsp_err_t ercd = FSP_SUCCESS; - uint8_t input_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t output_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t key_size = 0; - uint32_t ptr = 0; - - /* Casting uint32_t pointer is used for address. */ - key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_1024_DATA_BYTE_SIZE); - if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((plain->data_length) > (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (cipher->data_length < key_size) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - cipher->data_length = key_size; - - /*** RSAES-PKCS#1_V1.5 format ***/ - /* (1) | (2) | (3) | (4) | (5) */ - /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ - ptr = HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size; - input_data_arry[ptr] = 0x00; - ptr++; - input_data_arry[ptr] = 0x02; - ptr++; - - get_rand_rsaes_pkcs(((key_size - plain->data_length) - 3), &input_data_arry[ptr]); - ptr += ((key_size - plain->data_length) - 3); - input_data_arry[ptr] = 0x00; - ptr++; - - memcpy(&input_data_arry[ptr], plain->pdata, plain->data_length); - - ercd = R_SCE_Rsa1024ModularExponentEncryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (input_data_arry), - (uint32_t *) (output_data_arry)); - memcpy(cipher->pdata, &output_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size], cipher->data_length); - - return ercd; + fsp_err_t ercd = FSP_SUCCESS; + uint8_t input_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t output_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t key_size = 0; + uint32_t ptr = 0; + + /* Casting uint32_t pointer is used for address. */ + key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_1024_DATA_BYTE_SIZE); + if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((plain->data_length) > (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (cipher->data_length < key_size) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + cipher->data_length = key_size; + + /*** RSAES-PKCS#1_V1.5 format ***/ + /* (1) | (2) | (3) | (4) | (5) */ + /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ + ptr = HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size; + input_data_arry[ptr] = 0x00; + ptr++; + input_data_arry[ptr] = 0x02; + ptr++; + + get_rand_rsaes_pkcs(((key_size - plain->data_length) - 3), &input_data_arry[ptr]); + ptr += ((key_size - plain->data_length) - 3); + input_data_arry[ptr] = 0x00; + ptr++; + + memcpy(&input_data_arry[ptr], plain->pdata, plain->data_length); + + ercd = R_SCE_Rsa1024ModularExponentEncryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (input_data_arry), + (uint32_t *) (output_data_arry)); + memcpy(cipher->pdata, &output_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size], cipher->data_length); + + return ercd; } /*******************************************************************************************************************//** * The R_SCE_RSAES_PKCS1024_Decrypt() function RSA-decrypts the ciphertext input to the first argument, cipher, * according to RSAES-PKCS1-V1_5. It writes the decryption result to the second argument, plain. * - * @param[in] cipher ciphertext - * @arg cipher->pdata : Specifies pointer to array containing ciphertext. - * @arg cipher->data_length : Inputs ciphertext buffer size. - * Outputs valid data length after encryption - * (public key n size). - * @param[in,out] plain plaintext - * @arg plain->pdata : Specifies pointer to array containing plaintext. - * @arg plain->data_length : Inputs plaintext buffer size. - * The following size is required. - * Plaintext buffer size >= public key n size -11. - * Outputs valid data length after decryption - * (public key n size). - * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. + * @param[in] cipher ciphertext + * @arg cipher->pdata : Specifies pointer to array containing ciphertext. + * @arg cipher->data_length : Inputs ciphertext buffer size. + * Outputs valid data length after encryption + * (public key n size). + * @param[in,out] plain plaintext + * @arg plain->pdata : Specifies pointer to array containing plaintext. + * @arg plain->data_length : Inputs plaintext buffer size. + * The following size is required. + * Plaintext buffer size >= public key n size -11. + * Outputs valid data length after decryption + * (public key n size). + * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt (sce_rsa_byte_data_t * cipher, - sce_rsa_byte_data_t * plain, - sce_rsa1024_private_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt (sce_rsa_byte_data_t * cipher, + sce_rsa_byte_data_t * plain, + sce_rsa1024_private_wrapped_key_t * wrapped_key) { - fsp_err_t ercd = FSP_SUCCESS; - uint8_t input_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t output_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t key_size = 0; - uint32_t ptr = 0; - uint32_t ptr_start = 0; - uint8_t * p_start = 0; - uint8_t * p_zero_ptr = 0; - - /* Casting uint32_t pointer is used for address. */ - key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_1024_DATA_BYTE_SIZE); - if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (cipher->data_length != key_size) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (plain->data_length < (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - memcpy(&input_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size], cipher->pdata, cipher->data_length); - ercd = R_SCE_Rsa1024ModularExponentDecryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (input_data_arry), - (uint32_t *) (output_data_arry)); - if (FSP_SUCCESS != ercd) - { - return ercd; - } - - /*** RSAES-PKCS#1_V1.5 format ***/ - /* (1) | (2) | (3) | (4) | (5) */ - /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ - ptr = HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size; - ptr_start = ptr; - - /* (1) */ - if (0x00 != output_data_arry[ptr]) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - ptr++; - - /* (2) */ - if (0x02 != output_data_arry[ptr]) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - ptr++; - - /* (3) and (4) */ - p_start = &output_data_arry[ptr]; - - /* Casting uint8_t pointer is used for address. */ - p_zero_ptr = (uint8_t *) memchr(p_start, 0x00, key_size - 2); /* "2" is (1)+(2) */ - if (NULL == p_zero_ptr) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - if ((HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE - 3) > (uint32_t) (p_zero_ptr - p_start)) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - ptr += (uint32_t) ((p_zero_ptr - p_start) + 1); - - plain->data_length = key_size - (ptr - ptr_start); - memcpy(plain->pdata, &output_data_arry[ptr], plain->data_length); - - return FSP_SUCCESS; + fsp_err_t ercd = FSP_SUCCESS; + uint8_t input_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t output_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t key_size = 0; + uint32_t ptr = 0; + uint32_t ptr_start = 0; + uint8_t * p_start = 0; + uint8_t * p_zero_ptr = 0; + + /* Casting uint32_t pointer is used for address. */ + key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_1024_DATA_BYTE_SIZE); + if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (cipher->data_length != key_size) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (plain->data_length < (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + memcpy(&input_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size], cipher->pdata, cipher->data_length); + ercd = R_SCE_Rsa1024ModularExponentDecryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (input_data_arry), + (uint32_t *) (output_data_arry)); + if (FSP_SUCCESS != ercd) + { + return ercd; + } + + /*** RSAES-PKCS#1_V1.5 format ***/ + /* (1) | (2) | (3) | (4) | (5) */ + /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ + ptr = HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size; + ptr_start = ptr; + + /* (1) */ + if (0x00 != output_data_arry[ptr]) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + ptr++; + + /* (2) */ + if (0x02 != output_data_arry[ptr]) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + ptr++; + + /* (3) and (4) */ + p_start = &output_data_arry[ptr]; + + /* Casting uint8_t pointer is used for address. */ + p_zero_ptr = (uint8_t *) memchr(p_start, 0x00, key_size - 2); /* "2" is (1)+(2) */ + if (NULL == p_zero_ptr) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + if ((HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE - 3) > (uint32_t) (p_zero_ptr - p_start)) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + ptr += (uint32_t) ((p_zero_ptr - p_start) + 1); + + plain->data_length = key_size - (ptr - ptr_start); + memcpy(plain->pdata, &output_data_arry[ptr], plain->data_length); + + return FSP_SUCCESS; } /*******************************************************************************************************************//** @@ -463,55 +463,55 @@ fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt (sce_rsa_byte_data_t * cipher, * message_hash->data_type, a hash value calculated with a hash algorithm as specified by the fourth argument, * hash_type, must be input to message_hash->pdata. * - * @param[in] message_hash Message or hash value to which to attach signature - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in,out] signature Signature text storage destination information - * @arg signature->pdata : Specifies pointer to array storing the signature text - * @arg signature->data_length : data length - * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + * @param[in] message_hash Message or hash value to which to attach signature + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) + * @param[in,out] signature Signature text storage destination information + * @arg signature->pdata : Specifies pointer to array storing the signature text + * @arg signature->data_length : data length + * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate (sce_rsa_byte_data_t * message_hash, - sce_rsa_byte_data_t * signature, - sce_rsa2048_private_wrapped_key_t * wrapped_key, - uint8_t hash_type) +fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate (sce_rsa_byte_data_t * message_hash, + sce_rsa_byte_data_t * signature, + sce_rsa2048_private_wrapped_key_t * wrapped_key, + uint8_t hash_type) { - fsp_err_t error_code = FSP_SUCCESS; - uint8_t data_buff[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - - error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_2048_DATA_BYTE_SIZE, data_buff); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = R_SCE_Rsa2048ModularExponentDecryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (data_buff), - (uint32_t *) (signature->pdata)); - - signature->data_length = HW_SCE_RSA_2048_DATA_BYTE_SIZE; - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + uint8_t data_buff[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + + error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_2048_DATA_BYTE_SIZE, data_buff); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = R_SCE_Rsa2048ModularExponentDecryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (data_buff), + (uint32_t *) (signature->pdata)); + + signature->data_length = HW_SCE_RSA_2048_DATA_BYTE_SIZE; + + return error_code; } /*******************************************************************************************************************//** @@ -524,69 +524,69 @@ fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate (sce_rsa_byte_data_t * mes * in the second argument, message_hash->data_type, a hash value calculated with a hash algorithm as specified by the * fourth argument, hash_type, must be input to message_hash->pdata. * - * @param[in] signature Signature text information to verify - * @arg signature->pdata : Specifies pointer to array storing the signature text - * @arg signature->data_length : Specifies effective data length of the array + * @param[in] signature Signature text information to verify + * @arg signature->pdata : Specifies pointer to array storing the signature text + * @arg signature->data_length : Specifies effective data length of the array * @param[in] message_hash Message text or hash value to verify - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify (sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, - sce_rsa2048_public_wrapped_key_t * wrapped_key, - uint8_t hash_type) +fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify (sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, + sce_rsa2048_public_wrapped_key_t * wrapped_key, + uint8_t hash_type) { - fsp_err_t error_code = FSP_SUCCESS; - uint8_t data_buff[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t decrypt_data[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t data_ptr = 0; - - data_ptr = HW_SCE_RSA_2048_DATA_BYTE_SIZE - signature->data_length; - memcpy(data_buff + data_ptr, signature->pdata, signature->data_length); - - error_code = R_SCE_Rsa2048ModularExponentEncryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (data_buff), - (uint32_t *) (decrypt_data)); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_2048_DATA_BYTE_SIZE, data_buff); - if (FSP_SUCCESS == error_code) - { - if (memcmp(data_buff, decrypt_data, HW_SCE_RSA_2048_DATA_BYTE_SIZE)) - { - error_code = FSP_ERR_CRYPTO_SCE_AUTHENTICATION; - } - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + uint8_t data_buff[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t decrypt_data[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t data_ptr = 0; + + data_ptr = HW_SCE_RSA_2048_DATA_BYTE_SIZE - signature->data_length; + memcpy(data_buff + data_ptr, signature->pdata, signature->data_length); + + error_code = R_SCE_Rsa2048ModularExponentEncryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (data_buff), + (uint32_t *) (decrypt_data)); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_2048_DATA_BYTE_SIZE, data_buff); + if (FSP_SUCCESS == error_code) + { + if (memcmp(data_buff, decrypt_data, HW_SCE_RSA_2048_DATA_BYTE_SIZE)) + { + error_code = FSP_ERR_CRYPTO_SCE_AUTHENTICATION; + } + } + + return error_code; } /*******************************************************************************************************************//** @@ -599,359 +599,359 @@ fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify (sce_rsa_byte_data_t * signa * in the second argument, message_hash->data_type, a hash value calculated with a hash algorithm as specified by the * fourth argument, hash_type, must be input to message_hash->pdata. * - * @param[in] signature Signature text information to verify - * @arg signature->pdata : Specifies pointer to array storing the signature text - * @arg signature->data_length : Specifies effective data length of the array + * @param[in] signature Signature text information to verify + * @arg signature->pdata : Specifies pointer to array storing the signature text + * @arg signature->data_length : Specifies effective data length of the array * @param[in] message_hash Message text or hash value to verify - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) + * @arg message_hash->pdata : Specifies pointer to array storing the message or + * hash value + * @arg message_hash->data_length : Specifies effective data length of the array + * (Specify only when Message is selected) + * @arg message_hash->data_type : Selects the data type of message_hash + * (Message: 0 Hash value: 1) * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported + * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSASSA_PKCS4096_SignatureVerify (sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, - sce_rsa4096_public_wrapped_key_t * wrapped_key, - uint8_t hash_type) +fsp_err_t R_SCE_RSASSA_PKCS4096_SignatureVerify (sce_rsa_byte_data_t * signature, + sce_rsa_byte_data_t * message_hash, + sce_rsa4096_public_wrapped_key_t * wrapped_key, + uint8_t hash_type) { - fsp_err_t error_code = FSP_SUCCESS; - uint8_t data_buff[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t decrypt_data[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t data_ptr = 0; - - data_ptr = HW_SCE_RSA_4096_DATA_BYTE_SIZE - signature->data_length; - memcpy(data_buff + data_ptr, signature->pdata, signature->data_length); - - error_code = R_SCE_Rsa4096ModularExponentEncryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (data_buff), - (uint32_t *) (decrypt_data)); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_4096_DATA_BYTE_SIZE, data_buff); - if (FSP_SUCCESS == error_code) - { - if (memcmp(data_buff, decrypt_data, HW_SCE_RSA_4096_DATA_BYTE_SIZE)) - { - error_code = FSP_ERR_CRYPTO_SCE_AUTHENTICATION; - } - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + uint8_t data_buff[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t decrypt_data[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t data_ptr = 0; + + data_ptr = HW_SCE_RSA_4096_DATA_BYTE_SIZE - signature->data_length; + memcpy(data_buff + data_ptr, signature->pdata, signature->data_length); + + error_code = R_SCE_Rsa4096ModularExponentEncryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (data_buff), + (uint32_t *) (decrypt_data)); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_4096_DATA_BYTE_SIZE, data_buff); + if (FSP_SUCCESS == error_code) + { + if (memcmp(data_buff, decrypt_data, HW_SCE_RSA_4096_DATA_BYTE_SIZE)) + { + error_code = FSP_ERR_CRYPTO_SCE_AUTHENTICATION; + } + } + + return error_code; } /*******************************************************************************************************************//** * The R_SCE_RSAES_PKCS2048_Encrypt() function RSA-encrypts the plaintext input to the first argument, plain, * according to RSAES-PKCS1-V1_5. It writes the encryption result to the second argument, cipher. * - * @param[in] plain plaintext - * @arg plain->pdata : Specifies pointer to array containing plaintext. - * @arg plain->data_length : Specifies valid data length of plaintext array. - * data size <= public key n size - 11 - * @param[in,out] cipher ciphertext - * @arg cipher->pdata : Specifies pointer to array containing ciphertext. - * @arg cipher->data_length : Inputs ciphertext buffer size. - * Outputs valid data length after encryption - * (public key n size). - * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. + * @param[in] plain plaintext + * @arg plain->pdata : Specifies pointer to array containing plaintext. + * @arg plain->data_length : Specifies valid data length of plaintext array. + * data size <= public key n size - 11 + * @param[in,out] cipher ciphertext + * @arg cipher->pdata : Specifies pointer to array containing ciphertext. + * @arg cipher->data_length : Inputs ciphertext buffer size. + * Outputs valid data length after encryption + * (public key n size). + * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSAES_PKCS2048_Encrypt (sce_rsa_byte_data_t * plain, - sce_rsa_byte_data_t * cipher, - sce_rsa2048_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_RSAES_PKCS2048_Encrypt (sce_rsa_byte_data_t * plain, + sce_rsa_byte_data_t * cipher, + sce_rsa2048_public_wrapped_key_t * wrapped_key) { - fsp_err_t ercd = FSP_SUCCESS; - uint8_t input_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t output_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t key_size = 0; - uint32_t ptr = 0; - - /* Casting uint32_t pointer is used for address. */ - key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_2048_DATA_BYTE_SIZE); - if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((plain->data_length) > (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (cipher->data_length < key_size) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - cipher->data_length = key_size; - - /*** RSAES-PKCS#1_V1.5 format ***/ - /* (1) | (2) | (3) | (4) | (5) */ - /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ - ptr = HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size; - input_data_arry[ptr] = 0x00; - ptr++; - input_data_arry[ptr] = 0x02; - ptr++; - - get_rand_rsaes_pkcs(((key_size - plain->data_length) - 3), &input_data_arry[ptr]); - ptr += ((key_size - plain->data_length) - 3); - input_data_arry[ptr] = 0x00; - ptr++; - - memcpy(&input_data_arry[ptr], plain->pdata, plain->data_length); - - ercd = R_SCE_Rsa2048ModularExponentEncryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (input_data_arry), - (uint32_t *) (output_data_arry)); - memcpy(cipher->pdata, &output_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size], cipher->data_length); - - return ercd; + fsp_err_t ercd = FSP_SUCCESS; + uint8_t input_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t output_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t key_size = 0; + uint32_t ptr = 0; + + /* Casting uint32_t pointer is used for address. */ + key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_2048_DATA_BYTE_SIZE); + if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((plain->data_length) > (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (cipher->data_length < key_size) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + cipher->data_length = key_size; + + /*** RSAES-PKCS#1_V1.5 format ***/ + /* (1) | (2) | (3) | (4) | (5) */ + /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ + ptr = HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size; + input_data_arry[ptr] = 0x00; + ptr++; + input_data_arry[ptr] = 0x02; + ptr++; + + get_rand_rsaes_pkcs(((key_size - plain->data_length) - 3), &input_data_arry[ptr]); + ptr += ((key_size - plain->data_length) - 3); + input_data_arry[ptr] = 0x00; + ptr++; + + memcpy(&input_data_arry[ptr], plain->pdata, plain->data_length); + + ercd = R_SCE_Rsa2048ModularExponentEncryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (input_data_arry), + (uint32_t *) (output_data_arry)); + memcpy(cipher->pdata, &output_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size], cipher->data_length); + + return ercd; } /*******************************************************************************************************************//** * The R_SCE_RSAES_PKCS2048_Decrypt() function RSA-decrypts the ciphertext input to the first argument, cipher, * according to RSAES-PKCS1-V1_5. It writes the decryption result to the second argument, plain. * - * @param[in] cipher ciphertext - * @arg cipher->pdata : Specifies pointer to array containing ciphertext. - * @arg cipher->data_length : Inputs ciphertext buffer size. - * Outputs valid data length after encryption - * (public key n size). - * @param[in,out] plain plaintext - * @arg plain->pdata : Specifies pointer to array containing plaintext. - * @arg plain->data_length : Inputs plaintext buffer size. - * The following size is required. - * Plaintext buffer size >= public key n size -11. - * Outputs valid data length after decryption - * (public key n size). - * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. + * @param[in] cipher ciphertext + * @arg cipher->pdata : Specifies pointer to array containing ciphertext. + * @arg cipher->data_length : Inputs ciphertext buffer size. + * Outputs valid data length after encryption + * (public key n size). + * @param[in,out] plain plaintext + * @arg plain->pdata : Specifies pointer to array containing plaintext. + * @arg plain->data_length : Inputs plaintext buffer size. + * The following size is required. + * Plaintext buffer size >= public key n size -11. + * Outputs valid data length after decryption + * (public key n size). + * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSAES_PKCS2048_Decrypt (sce_rsa_byte_data_t * cipher, - sce_rsa_byte_data_t * plain, - sce_rsa2048_private_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_RSAES_PKCS2048_Decrypt (sce_rsa_byte_data_t * cipher, + sce_rsa_byte_data_t * plain, + sce_rsa2048_private_wrapped_key_t * wrapped_key) { - fsp_err_t ercd = FSP_SUCCESS; - uint8_t input_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t output_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t key_size = 0; - uint32_t ptr = 0; - uint32_t ptr_start = 0; - uint8_t * p_start = 0; - uint8_t * p_zero_ptr = 0; - - /* Casting uint32_t pointer is used for address. */ - key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_2048_DATA_BYTE_SIZE); - if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (cipher->data_length != key_size) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (plain->data_length < (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - memcpy(&input_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size], cipher->pdata, cipher->data_length); - ercd = R_SCE_Rsa2048ModularExponentDecryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (input_data_arry), - (uint32_t *) (output_data_arry)); - if (FSP_SUCCESS != ercd) - { - return ercd; - } - - /*** RSAES-PKCS#1_V1.5 format ***/ - /* (1) | (2) | (3) | (4) | (5) */ - /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ - ptr = HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size; - ptr_start = ptr; - - /* (1) */ - if (0x00 != output_data_arry[ptr]) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - ptr++; - - /* (2) */ - if (0x02 != output_data_arry[ptr]) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - ptr++; - - /* (3) and (4) */ - p_start = &output_data_arry[ptr]; - - /* Casting uint8_t pointer is used for address. */ - p_zero_ptr = (uint8_t *) memchr(p_start, 0x00, key_size - 2); /* "2" is (1)+(2) */ - if (NULL == p_zero_ptr) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - if ((HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE - 3) > (uint32_t) (p_zero_ptr - p_start)) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - ptr += (uint32_t) ((p_zero_ptr - p_start) + 1); - - plain->data_length = key_size - (ptr - ptr_start); - memcpy(plain->pdata, &output_data_arry[ptr], plain->data_length); - - return FSP_SUCCESS; + fsp_err_t ercd = FSP_SUCCESS; + uint8_t input_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t output_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t key_size = 0; + uint32_t ptr = 0; + uint32_t ptr_start = 0; + uint8_t * p_start = 0; + uint8_t * p_zero_ptr = 0; + + /* Casting uint32_t pointer is used for address. */ + key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_2048_DATA_BYTE_SIZE); + if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (cipher->data_length != key_size) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (plain->data_length < (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + memcpy(&input_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size], cipher->pdata, cipher->data_length); + ercd = R_SCE_Rsa2048ModularExponentDecryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (input_data_arry), + (uint32_t *) (output_data_arry)); + if (FSP_SUCCESS != ercd) + { + return ercd; + } + + /*** RSAES-PKCS#1_V1.5 format ***/ + /* (1) | (2) | (3) | (4) | (5) */ + /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ + ptr = HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size; + ptr_start = ptr; + + /* (1) */ + if (0x00 != output_data_arry[ptr]) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + ptr++; + + /* (2) */ + if (0x02 != output_data_arry[ptr]) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + ptr++; + + /* (3) and (4) */ + p_start = &output_data_arry[ptr]; + + /* Casting uint8_t pointer is used for address. */ + p_zero_ptr = (uint8_t *) memchr(p_start, 0x00, key_size - 2); /* "2" is (1)+(2) */ + if (NULL == p_zero_ptr) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + if ((HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE - 3) > (uint32_t) (p_zero_ptr - p_start)) + { + return FSP_ERR_CRYPTO_SCE_FAIL; + } + + ptr += (uint32_t) ((p_zero_ptr - p_start) + 1); + + plain->data_length = key_size - (ptr - ptr_start); + memcpy(plain->pdata, &output_data_arry[ptr], plain->data_length); + + return FSP_SUCCESS; } /*******************************************************************************************************************//** * The R_SCE_RSAES_PKCS4096_Encrypt() function RSA-encrypts the plaintext input to the first argument, plain, * according to RSAES-PKCS1-V1_5. It writes the encryption result to the second argument, cipher. * - * @param[in] plain plaintext - * @arg plain->pdata : Specifies pointer to array containing plaintext. - * @arg plain->data_length : Specifies valid data length of plaintext array. - * data size <= public key n size - 11 - * @param[in,out] cipher ciphertext - * @arg cipher->pdata : Specifies pointer to array containing ciphertext. - * @arg cipher->data_length : Inputs ciphertext buffer size. - * Outputs valid data length after encryption - * (public key n size). - * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. + * @param[in] plain plaintext + * @arg plain->pdata : Specifies pointer to array containing plaintext. + * @arg plain->data_length : Specifies valid data length of plaintext array. + * data size <= public key n size - 11 + * @param[in,out] cipher ciphertext + * @arg cipher->pdata : Specifies pointer to array containing ciphertext. + * @arg cipher->data_length : Inputs ciphertext buffer size. + * Outputs valid data length after encryption + * (public key n size). + * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ -fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt (sce_rsa_byte_data_t * plain, - sce_rsa_byte_data_t * cipher, - sce_rsa4096_public_wrapped_key_t * wrapped_key) +fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt (sce_rsa_byte_data_t * plain, + sce_rsa_byte_data_t * cipher, + sce_rsa4096_public_wrapped_key_t * wrapped_key) { - fsp_err_t ercd = FSP_SUCCESS; - uint8_t input_data_arry[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t output_data_arry[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t key_size = 0; - uint32_t ptr = 0; - - /* Casting uint32_t pointer is used for address. */ - key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_4096_DATA_BYTE_SIZE); - if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((plain->data_length) > (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (cipher->data_length < key_size) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - cipher->data_length = key_size; - - /*** RSAES-PKCS#1_V1.5 format ***/ - /* (1) | (2) | (3) | (4) | (5) */ - /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ - ptr = HW_SCE_RSA_4096_DATA_BYTE_SIZE - key_size; - input_data_arry[ptr] = 0x00; - ptr++; - input_data_arry[ptr] = 0x02; - ptr++; - - get_rand_rsaes_pkcs(((key_size - plain->data_length) - 3), &input_data_arry[ptr]); - ptr += ((key_size - plain->data_length) - 3); - input_data_arry[ptr] = 0x00; - ptr++; - - memcpy(&input_data_arry[ptr], plain->pdata, plain->data_length); - - ercd = R_SCE_Rsa4096ModularExponentEncryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (input_data_arry), - (uint32_t *) (output_data_arry)); - memcpy(cipher->pdata, &output_data_arry[HW_SCE_RSA_4096_DATA_BYTE_SIZE - key_size], cipher->data_length); - - return ercd; + fsp_err_t ercd = FSP_SUCCESS; + uint8_t input_data_arry[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = + { + 0 + }; + uint8_t output_data_arry[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = + { + 0 + }; + uint32_t key_size = 0; + uint32_t ptr = 0; + + /* Casting uint32_t pointer is used for address. */ + key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_4096_DATA_BYTE_SIZE); + if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if ((plain->data_length) > (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (cipher->data_length < key_size) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + cipher->data_length = key_size; + + /*** RSAES-PKCS#1_V1.5 format ***/ + /* (1) | (2) | (3) | (4) | (5) */ + /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ + ptr = HW_SCE_RSA_4096_DATA_BYTE_SIZE - key_size; + input_data_arry[ptr] = 0x00; + ptr++; + input_data_arry[ptr] = 0x02; + ptr++; + + get_rand_rsaes_pkcs(((key_size - plain->data_length) - 3), &input_data_arry[ptr]); + ptr += ((key_size - plain->data_length) - 3); + input_data_arry[ptr] = 0x00; + ptr++; + + memcpy(&input_data_arry[ptr], plain->pdata, plain->data_length); + + ercd = R_SCE_Rsa4096ModularExponentEncryptPrivate( + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) &wrapped_key->value, + (uint32_t *) (input_data_arry), + (uint32_t *) (output_data_arry)); + memcpy(cipher->pdata, &output_data_arry[HW_SCE_RSA_4096_DATA_BYTE_SIZE - key_size], cipher->data_length); + + return ercd; } /*******************************************************************************************************************//** @@ -965,198 +965,198 @@ fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt (sce_rsa_byte_data_t * plain, /*******************************************************************************************************************//** * Hash message text according to the hash type. * - * @param p_mes message text - * @param p_hash pointer of hash data - * @param mes_len message size(byte) + * @param p_mes message text + * @param p_hash pointer of hash data + * @param mes_len message size(byte) * @param hash_type hash type * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input parameter illegal + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input parameter illegal * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. **********************************************************************************************************************/ static fsp_err_t calc_hash_data (uint8_t * p_mes, uint8_t * p_hash, uint32_t mes_len, uint8_t hash_type) { - fsp_err_t error_code = FSP_SUCCESS; - sce_sha_md5_handle_t ex_sha_handle = - { - 0 - }; - uint32_t hash_length = 0; - - if (HW_SCE_RSA_HASH_SHA256 == hash_type) - { - R_SCE_SHA256_Init(&ex_sha_handle); - error_code = R_SCE_SHA256_Update(&ex_sha_handle, p_mes, mes_len); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = R_SCE_SHA256_Final(&ex_sha_handle, p_hash, &hash_length); - } - - return error_code; + fsp_err_t error_code = FSP_SUCCESS; + sce_sha_md5_handle_t ex_sha_handle = + { + 0 + }; + uint32_t hash_length = 0; + + if (HW_SCE_RSA_HASH_SHA256 == hash_type) + { + R_SCE_SHA256_Init(&ex_sha_handle); + error_code = R_SCE_SHA256_Update(&ex_sha_handle, p_mes, mes_len); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + + error_code = R_SCE_SHA256_Final(&ex_sha_handle, p_hash, &hash_length); + } + + return error_code; } /*******************************************************************************************************************//** * Prefix the hash of the message according to RSASSA-PKCS1-V1_5. * - * @param p_message_hash message text or hash value - * @param hash_type hash type + * @param p_message_hash message text or hash value + * @param hash_type hash type * @param rsa_key_byte_size RSA data size - * @param data_buff pointer of Sig data + * @param data_buff pointer of Sig data * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input parameter illegal + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input parameter illegal * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. **********************************************************************************************************************/ static fsp_err_t set_rsassapkcs_hash_data (sce_rsa_byte_data_t * p_message_hash, - uint8_t hash_type, - uint32_t rsa_key_byte_size, - uint8_t * data_buff) + uint8_t hash_type, + uint32_t rsa_key_byte_size, + uint8_t * data_buff) { - fsp_err_t error_code = FSP_SUCCESS; - sce_rsa_byte_data_t prefix = - { - 0 - }; - uint32_t hash_data_buff[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t)] = - { - 0 - }; - uint32_t hash_length = 0; - uint32_t data_ptr = 0; - - if ((HW_SCE_RSA_HASH_SHA256 < hash_type) || (1 < p_message_hash->data_type)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (0 == p_message_hash->data_type) - { - /* Casting uint8_t pointer is used for address. */ - error_code = calc_hash_data(p_message_hash->pdata, - (uint8_t *) hash_data_buff, - p_message_hash->data_length, - hash_type); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - } - - if (HW_SCE_RSA_HASH_SHA256 == hash_type) - { - prefix.pdata = gs_rsa_sig_sha256_prefix; - prefix.data_length = sizeof(gs_rsa_sig_sha256_prefix); - hash_length = HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE; - } - - data_buff[0] = 0x00; - data_buff[1] = 0x01; - data_ptr = ((rsa_key_byte_size - prefix.data_length) - hash_length) - 1; - memset(data_buff + 2, SCE_HEX_FF, data_ptr); - data_buff[data_ptr] = 0x0; - data_ptr++; - memcpy(data_buff + data_ptr, prefix.pdata, prefix.data_length); - data_ptr += prefix.data_length; - if (0 == p_message_hash->data_type) - { - memcpy(data_buff + data_ptr, hash_data_buff, hash_length); - } - else /* if (1 == p_message_hash->data_type) */ - { - memcpy(data_buff + data_ptr, p_message_hash->pdata, hash_length); - } - - return FSP_SUCCESS; + fsp_err_t error_code = FSP_SUCCESS; + sce_rsa_byte_data_t prefix = + { + 0 + }; + uint32_t hash_data_buff[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t)] = + { + 0 + }; + uint32_t hash_length = 0; + uint32_t data_ptr = 0; + + if ((HW_SCE_RSA_HASH_SHA256 < hash_type) || (1 < p_message_hash->data_type)) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + if (0 == p_message_hash->data_type) + { + /* Casting uint8_t pointer is used for address. */ + error_code = calc_hash_data(p_message_hash->pdata, + (uint8_t *) hash_data_buff, + p_message_hash->data_length, + hash_type); + if (FSP_SUCCESS != error_code) + { + return error_code; + } + } + + if (HW_SCE_RSA_HASH_SHA256 == hash_type) + { + prefix.pdata = gs_rsa_sig_sha256_prefix; + prefix.data_length = sizeof(gs_rsa_sig_sha256_prefix); + hash_length = HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE; + } + + data_buff[0] = 0x00; + data_buff[1] = 0x01; + data_ptr = ((rsa_key_byte_size - prefix.data_length) - hash_length) - 1; + memset(data_buff + 2, SCE_HEX_FF, data_ptr); + data_buff[data_ptr] = 0x0; + data_ptr++; + memcpy(data_buff + data_ptr, prefix.pdata, prefix.data_length); + data_ptr += prefix.data_length; + if (0 == p_message_hash->data_type) + { + memcpy(data_buff + data_ptr, hash_data_buff, hash_length); + } + else /* if (1 == p_message_hash->data_type) */ + { + memcpy(data_buff + data_ptr, p_message_hash->pdata, hash_length); + } + + return FSP_SUCCESS; } /*******************************************************************************************************************//** * Get key n size from RSA key index * * @param prsa_key_index RSA key index - * @param key_max_size key data max byte size + * @param key_max_size key data max byte size * * @return key_size **********************************************************************************************************************/ static uint32_t get_keyn_size (uint32_t * prsa_key_index, uint32_t key_max_size) { - bool get_output_data_length = false; - - /* Casting uint8_t pointer is used for address. */ - uint8_t * p_rsa_key_n_data = (uint8_t *) prsa_key_index; - uint32_t key_size_tmp = 0; - - key_size_tmp = key_max_size; - for (uint32_t i = 0; i < (key_max_size); i++) - { - if (!get_output_data_length) - { - if (0 == p_rsa_key_n_data[i]) - { - key_size_tmp--; - } - else - { - get_output_data_length = true; - } - } - } - - return key_size_tmp; + bool get_output_data_length = false; + + /* Casting uint8_t pointer is used for address. */ + uint8_t * p_rsa_key_n_data = (uint8_t *) prsa_key_index; + uint32_t key_size_tmp = 0; + + key_size_tmp = key_max_size; + for (uint32_t i = 0; i < (key_max_size); i++) + { + if (!get_output_data_length) + { + if (0 == p_rsa_key_n_data[i]) + { + key_size_tmp--; + } + else + { + get_output_data_length = true; + } + } + } + + return key_size_tmp; } /*******************************************************************************************************************//** * In accordance with RSAES-PKCS1-V1_5 to obtain random number data of rand_size that does not contain 0. * - * @param rand_size random data size + * @param rand_size random data size * @param prand_data random data area pointer * - * @retval FSP_SUCCESS Normal termination. + * @retval FSP_SUCCESS Normal termination. * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict **********************************************************************************************************************/ static fsp_err_t get_rand_rsaes_pkcs (uint32_t rand_size, uint8_t * prand_data) { - fsp_err_t ercd = FSP_SUCCESS; - uint8_t rand_tmp[16] = - { - 0 - }; - uint32_t rest_size = rand_size; - uint32_t rand_ptr = 0; - uint32_t i = 0; - - while (rest_size) - { + fsp_err_t ercd = FSP_SUCCESS; + uint8_t rand_tmp[16] = + { + 0 + }; + uint32_t rest_size = rand_size; + uint32_t rand_ptr = 0; + uint32_t i = 0; + + while (rest_size) + { #if defined RSA_ENC_TEST_MODE - memset(rand_tmp, SCE_HEX_FF, sizeof(rand_tmp)); + memset(rand_tmp, SCE_HEX_FF, sizeof(rand_tmp)); #else - /* Casting uint32_t pointer is used for address. */ - ercd = R_SCE_RandomNumberGenerate((uint32_t *) rand_tmp); - if (FSP_SUCCESS != ercd) - { - break; - } -#endif /* defined RSA_ENC_TEST_MODE */ - for (i = 0; i < 16; i++) - { - if (0 != rand_tmp[i]) - { - prand_data[rand_ptr] = rand_tmp[i]; - rand_ptr++; - rest_size--; - } - - if (0 == rest_size) - { - break; - } - } - } - - return ercd; + /* Casting uint32_t pointer is used for address. */ + ercd = R_SCE_RandomNumberGenerate((uint32_t *) rand_tmp); + if (FSP_SUCCESS != ercd) + { + break; + } +#endif /* defined RSA_ENC_TEST_MODE */ + for (i = 0; i < 16; i++) + { + if (0 != rand_tmp[i]) + { + prand_data[rand_ptr] = rand_tmp[i]; + rand_ptr++; + rest_size--; + } + + if (0 == rest_size) + { + break; + } + } + } + + return ercd; } diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_sha.c b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_sha.c index 3294d898d..2ba105dc6 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_sha.c +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/public/r_sce_sha.c @@ -17,13 +17,13 @@ * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. *********************************************************************************************************************/ /********************************************************************************************************************** - * File Name : r_sce_sha.c - * Version : 1.0 - * Description : SCE Hash Public API source file + * File Name : r_sce_sha.c + * Version : 1.0 + * Description : SCE Hash Public API source file *********************************************************************************************************************/ /********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release + * History : DD.MM.YYYY Version Description + * : 03.31.2022 1.00 First Release *********************************************************************************************************************/ /*********************************************************************************************************************** @@ -37,23 +37,23 @@ **********************************************************************************************************************/ /* Block length (in bytes) of SHA */ -#define SHA_BLOCK8_LEN (64U) +#define SHA_BLOCK8_LEN (64U) /* Initialization function call state */ -#define CALL_ONLY_INIT (0) -#define CALL_ONLY_UPDATE_FINAL (1) +#define CALL_ONLY_INIT (0) +#define CALL_ONLY_UPDATE_FINAL (1) #ifndef SCE_HEX_FF -#define SCE_HEX_FF (0xff) +#define SCE_HEX_FF (0xff) #endif #ifndef SCE_HEX_80 -#define SCE_HEX_80 (0x80) +#define SCE_HEX_80 (0x80) #endif #ifndef SCE_DEC_32 -#define SCE_DEC_32 (32) +#define SCE_DEC_32 (32) #endif #ifndef SCE_DEC_64 -#define SCE_DEC_64 (64) +#define SCE_DEC_64 (64) #endif /*********************************************************************************************************************** @@ -72,8 +72,8 @@ * Global variables **********************************************************************************************************************/ extern uint32_t g_private_id_counter; -uint32_t g_sha224_private_id; -uint32_t g_sha256_private_id; +uint32_t g_sha224_private_id; +uint32_t g_sha256_private_id; /*******************************************************************************************************************//** * @addtogroup SCE_PROTECTED @@ -94,18 +94,18 @@ uint32_t g_sha256_private_id; * @retval FSP_SUCCESS Normal termination * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_SHA224_Init (sce_sha_md5_handle_t * handle) { - memset(handle, 0, sizeof(sce_sha_md5_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_sha224_private_id = g_private_id_counter; - handle->id = g_sha224_private_id; - memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); - - return R_SCE_Sha224InitPrivate(handle); + memset(handle, 0, sizeof(sce_sha_md5_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_sha224_private_id = g_private_id_counter; + handle->id = g_sha224_private_id; + memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); + + return R_SCE_Sha224InitPrivate(handle); } /*******************************************************************************************************************//** @@ -113,63 +113,63 @@ fsp_err_t R_SCE_SHA224_Init (sce_sha_md5_handle_t * handle) * and the third argument, message_length, and writes the ongoing status to the first argument, handle. * After message input is completed, call R_SCE_SHA224_Final(). * - * @param[in,out] handle SHA handler (work area) - * @param[in] message message data area - * @param[in] message_length message data length + * @param[in,out] handle SHA handler (work area) + * @param[in] message message data area + * @param[in] message_length message data length * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_SHA224_Update (sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length) { - fsp_err_t ercd = FSP_SUCCESS; - uint32_t length_rest = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_sha224_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->all_received_length += message_length; - if ((handle->buffering_length + message_length) >= SHA_BLOCK8_LEN) - { - memcpy(handle->sha_buffer + handle->buffering_length, message, SHA_BLOCK8_LEN - handle->buffering_length); - - /*Casting uint32_t pointer is used for address.*/ - ercd = R_SCE_Sha224UpdatePrivate(handle, (uint32_t *) (handle->sha_buffer), SHA_BLOCK8_LEN >> 2); - length_rest = message_length - (SHA_BLOCK8_LEN - handle->buffering_length); - memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); - if (length_rest >= SHA_BLOCK8_LEN) - { - ercd = R_SCE_Sha224UpdatePrivate(handle, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (message + (SHA_BLOCK8_LEN - handle->buffering_length)), - ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN) >> 2); - length_rest -= ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN); - } - - handle->buffering_length = 0; - memcpy(handle->sha_buffer, message + (message_length - length_rest), length_rest); - handle->buffering_length = length_rest; - } - else - { - memcpy(handle->sha_buffer + handle->buffering_length, message, message_length); - handle->buffering_length += message_length; - } - - return ercd; + fsp_err_t ercd = FSP_SUCCESS; + uint32_t length_rest = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_sha224_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->all_received_length += message_length; + if ((handle->buffering_length + message_length) >= SHA_BLOCK8_LEN) + { + memcpy(handle->sha_buffer + handle->buffering_length, message, SHA_BLOCK8_LEN - handle->buffering_length); + + /*Casting uint32_t pointer is used for address.*/ + ercd = R_SCE_Sha224UpdatePrivate(handle, (uint32_t *) (handle->sha_buffer), SHA_BLOCK8_LEN >> 2); + length_rest = message_length - (SHA_BLOCK8_LEN - handle->buffering_length); + memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); + if (length_rest >= SHA_BLOCK8_LEN) + { + ercd = R_SCE_Sha224UpdatePrivate(handle, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (message + (SHA_BLOCK8_LEN - handle->buffering_length)), + ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN) >> 2); + length_rest -= ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN); + } + + handle->buffering_length = 0; + memcpy(handle->sha_buffer, message + (message_length - length_rest), length_rest); + handle->buffering_length = length_rest; + } + else + { + memcpy(handle->sha_buffer + handle->buffering_length, message, message_length); + handle->buffering_length += message_length; + } + + return ercd; } /*******************************************************************************************************************//** @@ -177,88 +177,88 @@ fsp_err_t R_SCE_SHA224_Update (sce_sha_md5_handle_t * handle, uint8_t * message, * result to the second argument, digest, and writes the length of the calculation result to the third argument, * digest_length. * - * @param[in,out] handle SHA handler (work area) - * @param[in,out] digest hasha data area + * @param[in,out] handle SHA handler (work area) + * @param[in,out] digest hasha data area * @param[in,out] digest_length hash data length (32bytes) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_SHA224_Final (sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length) { - uint32_t max_cnt_byte = 0; - fsp_err_t ercd = FSP_SUCCESS; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_sha224_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->sha_buffer[handle->buffering_length] = SCE_HEX_80; - if ((SHA_BLOCK8_LEN - handle->buffering_length) >= 9) /* another block unnecessary */ - { - memset(handle->sha_buffer + (handle->buffering_length + 1), 0, - (SHA_BLOCK8_LEN - 4) - (handle->buffering_length + 1)); - - /* According c., but support only l < 2**32 case */ - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 3] = (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 2] = (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); - max_cnt_byte = SHA_BLOCK8_LEN; - } - else - { - /* another block necessary */ - memset(handle->sha_buffer + (handle->buffering_length + 1), 0, - ((2 * SHA_BLOCK8_LEN) - 4) - (handle->buffering_length + 1)); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 3] = - (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 2] = - (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); - max_cnt_byte = 2 * SHA_BLOCK8_LEN; - } - - ercd = R_SCE_Sha224FinalPrivate(handle, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (handle->sha_buffer), - max_cnt_byte >> 2, - (uint32_t *) (digest), - digest_length); - handle->all_received_length = 0; - handle->buffering_length = 0; - memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); - - return ercd; + uint32_t max_cnt_byte = 0; + fsp_err_t ercd = FSP_SUCCESS; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_sha224_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->sha_buffer[handle->buffering_length] = SCE_HEX_80; + if ((SHA_BLOCK8_LEN - handle->buffering_length) >= 9) /* another block unnecessary */ + { + memset(handle->sha_buffer + (handle->buffering_length + 1), 0, + (SHA_BLOCK8_LEN - 4) - (handle->buffering_length + 1)); + + /* According c., but support only l < 2**32 case */ + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 3] = (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 2] = (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); + max_cnt_byte = SHA_BLOCK8_LEN; + } + else + { + /* another block necessary */ + memset(handle->sha_buffer + (handle->buffering_length + 1), 0, + ((2 * SHA_BLOCK8_LEN) - 4) - (handle->buffering_length + 1)); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 3] = + (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 2] = + (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); + max_cnt_byte = 2 * SHA_BLOCK8_LEN; + } + + ercd = R_SCE_Sha224FinalPrivate(handle, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (handle->sha_buffer), + max_cnt_byte >> 2, + (uint32_t *) (digest), + digest_length); + handle->all_received_length = 0; + handle->buffering_length = 0; + memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); + + return ercd; } /*******************************************************************************************************************//** @@ -271,18 +271,18 @@ fsp_err_t R_SCE_SHA224_Final (sce_sha_md5_handle_t * handle, uint8_t * digest, u * @retval FSP_SUCCESS Normal termination * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_SHA256_Init (sce_sha_md5_handle_t * handle) { - memset(handle, 0, sizeof(sce_sha_md5_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_sha256_private_id = g_private_id_counter; - handle->id = g_sha256_private_id; - memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); - - return R_SCE_Sha256InitPrivate(handle); + memset(handle, 0, sizeof(sce_sha_md5_handle_t)); + handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; + g_private_id_counter++; + g_sha256_private_id = g_private_id_counter; + handle->id = g_sha256_private_id; + memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); + + return R_SCE_Sha256InitPrivate(handle); } /*******************************************************************************************************************//** @@ -290,63 +290,63 @@ fsp_err_t R_SCE_SHA256_Init (sce_sha_md5_handle_t * handle) * and the third argument, message_length, and writes the ongoing status to the first argument, handle. * After message input is completed, call R_SCE_SHA256_Final(). * - * @param[in,out] handle SHA handler (work area) - * @param[in] message message data area - * @param[in] message_length message data length + * @param[in,out] handle SHA handler (work area) + * @param[in] message message data area + * @param[in] message_length message data length * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_SHA256_Update (sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length) { - fsp_err_t ercd = FSP_SUCCESS; - uint32_t length_rest = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_sha256_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->all_received_length += message_length; - if ((handle->buffering_length + message_length) >= SHA_BLOCK8_LEN) - { - memcpy(handle->sha_buffer + handle->buffering_length, message, SHA_BLOCK8_LEN - handle->buffering_length); - - /*Casting uint32_t pointer is used for address.*/ - ercd = R_SCE_Sha256UpdatePrivate(handle, (uint32_t *) (handle->sha_buffer), SHA_BLOCK8_LEN >> 2); - length_rest = message_length - (SHA_BLOCK8_LEN - handle->buffering_length); - memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); - if (length_rest >= SHA_BLOCK8_LEN) - { - ercd = R_SCE_Sha256UpdatePrivate(handle, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (message + (SHA_BLOCK8_LEN - handle->buffering_length)), - ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN) >> 2); - length_rest -= ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN); - } - - handle->buffering_length = 0; - memcpy(handle->sha_buffer, message + (message_length - length_rest), length_rest); - handle->buffering_length = length_rest; - } - else - { - memcpy(handle->sha_buffer + handle->buffering_length, message, message_length); - handle->buffering_length += message_length; - } - - return ercd; + fsp_err_t ercd = FSP_SUCCESS; + uint32_t length_rest = 0; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + if (handle->id != g_sha256_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->all_received_length += message_length; + if ((handle->buffering_length + message_length) >= SHA_BLOCK8_LEN) + { + memcpy(handle->sha_buffer + handle->buffering_length, message, SHA_BLOCK8_LEN - handle->buffering_length); + + /*Casting uint32_t pointer is used for address.*/ + ercd = R_SCE_Sha256UpdatePrivate(handle, (uint32_t *) (handle->sha_buffer), SHA_BLOCK8_LEN >> 2); + length_rest = message_length - (SHA_BLOCK8_LEN - handle->buffering_length); + memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); + if (length_rest >= SHA_BLOCK8_LEN) + { + ercd = R_SCE_Sha256UpdatePrivate(handle, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (message + (SHA_BLOCK8_LEN - handle->buffering_length)), + ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN) >> 2); + length_rest -= ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN); + } + + handle->buffering_length = 0; + memcpy(handle->sha_buffer, message + (message_length - length_rest), length_rest); + handle->buffering_length = length_rest; + } + else + { + memcpy(handle->sha_buffer + handle->buffering_length, message, message_length); + handle->buffering_length += message_length; + } + + return ercd; } /*******************************************************************************************************************//** @@ -354,88 +354,88 @@ fsp_err_t R_SCE_SHA256_Update (sce_sha_md5_handle_t * handle, uint8_t * message, * result to the second argument, digest, and writes the length of the calculation result to the third argument, * digest_length. * - * @param[in,out] handle SHA handler (work area) - * @param[in,out] digest hasha data area + * @param[in,out] handle SHA handler (work area) + * @param[in,out] digest hasha data area * @param[in,out] digest_length hash data length (32bytes) * - * @retval FSP_SUCCESS Normal termination + * @retval FSP_SUCCESS Normal termination * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. + * by the processing routine was in use by another processing routine. + * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. * * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. + * After the function runs the state transitions to SCE Enabled State. **********************************************************************************************************************/ fsp_err_t R_SCE_SHA256_Final (sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length) { - uint32_t max_cnt_byte = 0; - fsp_err_t ercd = FSP_SUCCESS; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_sha256_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->sha_buffer[handle->buffering_length] = SCE_HEX_80; - if ((SHA_BLOCK8_LEN - handle->buffering_length) >= 9) /* another block unnecessary */ - { - memset(handle->sha_buffer + (handle->buffering_length + 1), 0, - (SHA_BLOCK8_LEN - 4) - (handle->buffering_length + 1)); - - /* According c., but support only l < 2**32 case */ - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 3] = (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 2] = (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); - max_cnt_byte = SHA_BLOCK8_LEN; - } - else - { - /* another block necessary */ - memset(handle->sha_buffer + (handle->buffering_length + 1), 0, - ((2 * SHA_BLOCK8_LEN) - 4) - (handle->buffering_length + 1)); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 3] = - (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 2] = - (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); - max_cnt_byte = 2 * SHA_BLOCK8_LEN; - } - - ercd = R_SCE_Sha256FinalPrivate(handle, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (handle->sha_buffer), - max_cnt_byte >> 2, - (uint32_t *) (digest), - digest_length); - handle->all_received_length = 0; - handle->buffering_length = 0; - memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); - - return ercd; + uint32_t max_cnt_byte = 0; + fsp_err_t ercd = FSP_SUCCESS; + + if (CALL_ONLY_INIT == handle->flag_call_init) + { + return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; + } + + handle->flag_call_init = CALL_ONLY_INIT; + if (handle->id != g_sha256_private_id) + { + return FSP_ERR_CRYPTO_SCE_PARAMETER; + } + + handle->sha_buffer[handle->buffering_length] = SCE_HEX_80; + if ((SHA_BLOCK8_LEN - handle->buffering_length) >= 9) /* another block unnecessary */ + { + memset(handle->sha_buffer + (handle->buffering_length + 1), 0, + (SHA_BLOCK8_LEN - 4) - (handle->buffering_length + 1)); + + /* According c., but support only l < 2**32 case */ + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 3] = (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 2] = (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[SHA_BLOCK8_LEN - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); + max_cnt_byte = SHA_BLOCK8_LEN; + } + else + { + /* another block necessary */ + memset(handle->sha_buffer + (handle->buffering_length + 1), 0, + ((2 * SHA_BLOCK8_LEN) - 4) - (handle->buffering_length + 1)); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 3] = + (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 2] = + (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); + + /* Casting uint32_t data to uint8_t data array. */ + handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); + max_cnt_byte = 2 * SHA_BLOCK8_LEN; + } + + ercd = R_SCE_Sha256FinalPrivate(handle, + /* Casting uint32_t pointer is used for address. */ + (uint32_t *) (handle->sha_buffer), + max_cnt_byte >> 2, + (uint32_t *) (digest), + digest_length); + handle->all_received_length = 0; + handle->buffering_length = 0; + memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); + + return ercd; } /*******************************************************************************************************************//** diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/sub.mk b/core/arch/arm/plat-rz/common/drivers/r_sce/sub.mk index 89e5ed0eb..a30f4a8e6 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/sub.mk +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/sub.mk @@ -6,3 +6,4 @@ srcs-y += public/r_sce.c srcs-y += private/r_sce_private.c global-incdirs-y += private/inc global-incdirs-y += inc/api +global-incdirs-y += inc/instances diff --git a/core/arch/arm/plat-rz/common/drivers/sce.c b/core/arch/arm/plat-rz/common/drivers/sce.c index 412861910..c3265bc8c 100644 --- a/core/arch/arm/plat-rz/common/drivers/sce.c +++ b/core/arch/arm/plat-rz/common/drivers/sce.c @@ -10,6 +10,7 @@ #include #include +#include "platform_config.h" register_phys_mem_pgdir(MEM_AREA_IO_SEC, HW_SCE_BASE, HW_SCE_SIZE); @@ -18,33 +19,33 @@ static sce_instance_ctrl_t sce_instance_ctrl; static TEE_Result SCE_Init(void) { - fsp_err_t err; - - int32_t retry_cnt = 3; - - gp_sce = (uint32_t *) phys_to_virt_io(HW_SCE_BASE, HW_SCE_SIZE); - - while (0 < retry_cnt) - { - err = g_sce_protected_on_sce.open(&sce_instance_ctrl, &sce_cfg); - switch (err) - { - case FSP_ERR_CRYPTO_SCE_RETRY: - retry_cnt--; - break; - default: - retry_cnt = 0; - break; - } - } - - if (FSP_SUCCESS != err) - { - EMSG("Failed to initialize SCE (0x%08x).", err); - panic(); - } - - return TEE_SUCCESS; + fsp_err_t err; + + int32_t retry_cnt = 3; + + gp_sce = (uint32_t *) phys_to_virt_io(HW_SCE_BASE, HW_SCE_SIZE); + + while (0 < retry_cnt) + { + err = g_sce_protected_on_sce.open(&sce_instance_ctrl, &sce_cfg); + switch (err) + { + case FSP_ERR_CRYPTO_SCE_RETRY: + retry_cnt--; + break; + default: + retry_cnt = 0; + break; + } + } + + if (FSP_SUCCESS != err) + { + EMSG("Failed to initialize SCE (0x%08x).", err); + panic(); + } + + return TEE_SUCCESS; } driver_init(SCE_Init); diff --git a/core/arch/arm/plat-rz/common/drivers/sub.mk b/core/arch/arm/plat-rz/common/drivers/sub.mk index 406309146..8f4d9b049 100644 --- a/core/arch/arm/plat-rz/common/drivers/sub.mk +++ b/core/arch/arm/plat-rz/common/drivers/sub.mk @@ -5,4 +5,8 @@ srcs-$(CFG_RZ_SCIF) += scif.c subdirs-$(CFG_RZ_XSPI) += xspi srcs-$(CFG_RZ_SCE) += sce.c hw_rng.c -subdirs-$(CFG_RZ_SCE) += r_sce \ No newline at end of file +subdirs-$(CFG_RZ_SCE) += r_sce + +ifeq ($(PLATFORM_FLAVOR),v2h_evk_1) +ldflags-external += $(CFG_RZ_SCE_LIB_DIR)/libr_secure_ip_2_0.a.1.0.0 +endif \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/pta/include/pta_flash.h b/core/arch/arm/plat-rz/common/pta/include/pta_flash.h index 0d02e2ad1..7cc975e96 100644 --- a/core/arch/arm/plat-rz/common/pta/include/pta_flash.h +++ b/core/arch/arm/plat-rz/common/pta/include/pta_flash.h @@ -7,13 +7,13 @@ #ifndef PTA_FLASH_H_ #define PTA_FLASH_H_ -#define FLASH_UUID \ - { \ - 0x2c0fca92, 0x5ab1, 0x11eb, \ - { \ - 0x81, 0x53, 0xc7, 0xd7, 0x50, 0xe0, 0xae, 0x47 \ - } \ - } +#define FLASH_UUID \ + { \ + 0x2c0fca92, 0x5ab1, 0x11eb, \ + { \ + 0x81, 0x53, 0xc7, 0xd7, 0x50, 0xe0, 0xae, 0x47 \ + } \ + } /* * FLASH_CMD_WRITE_SPI - Write data to SPI Flash diff --git a/core/arch/arm/plat-rz/common/pta/include/pta_sce.h b/core/arch/arm/plat-rz/common/pta/include/pta_sce.h new file mode 100644 index 000000000..790d6c60e --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/include/pta_sce.h @@ -0,0 +1,179 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ +#ifndef __PTA_SCE_H +#define __PTA_SCE_H + +#include + +#define PTA_SCE_UUID \ + { 0x3b221d77, 0xe679, 0x4ca5, \ + { 0xa4, 0x48, 0x1f, 0x9f, 0x16, 0x02, 0x15, 0xc5 } } + +/* + * [in/out] memref[0] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES128_WrappedKeyGenerate (0x00010000) + +/* + * [in/out] memref[0] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES256_WrappedKeyGenerate (0x00010100) + +/* + * [in/out] memref[0] : Wrapped key (sce_rsa1024_wrapped_pair_key_t) + */ +#define PTA_CMD_RSA1024_WrappedKeyPairGenerate (0x00011000) + +/* + * [in/out] memref[0] : Wrapped key (sce_rsa2048_wrapped_pair_key_t) + */ +#define PTA_CMD_RSA2048_WrappedKeyPairGenerate (0x00011100) + +/* + * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) + */ +#define PTA_CMD_ECC_secp192r1_WrappedKeyPairGenerate (0x00012000) + +/* + * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) + */ +#define PTA_CMD_ECC_secp224r1_WrappedKeyPairGenerate (0x00012100) + +/* + * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) + */ +#define PTA_CMD_ECC_secp256r1_WrappedKeyPairGenerate (0x00012200) + +/* + * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) + */ +#define PTA_CMD_ECC_BrainpoolP512r1_WrappedKeyPairGenerate (0x00013000) + +/* + * [in/out] memref[0] : random data (16byte) + */ +#define PTA_CMD_RandomNumberGenerate (0x00014000) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (32byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES128_EncryptedKeyWrap (0x00015000) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (64byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES256_EncryptedKeyWrap (0x00015100) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (160byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_rsa1024_public_wrapped_key_t) + */ +#define PTA_CMD_RSA1024_EncryptedPublicKeyWrap (0x00016000) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (272byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_rsa1024_private_wrapped_key_t) + */ +#define PTA_CMD_RSA1024_EncryptedPrivateKeyWrap (0x00016010) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (288byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_rsa2048_public_wrapped_key_t) + */ +#define PTA_CMD_RSA2048_EncryptedPublicKeyWrap (0x00016100) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (528byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_rsa2048_private_wrapped_key_t) + */ +#define PTA_CMD_RSA2048_EncryptedPrivateKeyWrap (0x00016110) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (544byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_rsa4096_public_wrapped_key_t) + */ +#define PTA_CMD_RSA4096_EncryptedPublicKeyWrap (0x00016200) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECC_secp192r1_EncryptedPublicKeyWrap (0x00017000) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECC_secp192r1_EncryptedPrivateKeyWrap (0x00017010) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECC_secp224r1_EncryptedPublicKeyWrap (0x00017100) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECC_secp224r1_EncryptedPrivateKeyWrap (0x00017110) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECC_secp256r1_EncryptedPublicKeyWrap (0x00017200) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECC_secp256r1_EncryptedPrivateKeyWrap (0x00017210) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (144byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap (0x00018000) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (sce_key_update_key_t) + * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap (0x00018010) + +#endif /* __PTA_SCE_H */ diff --git a/core/arch/arm/plat-rz/common/pta/include/pta_sce_aes.h b/core/arch/arm/plat-rz/common/pta/include/pta_sce_aes.h new file mode 100644 index 000000000..7d552797b --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/include/pta_sce_aes.h @@ -0,0 +1,279 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ +#ifndef __PTA_SCE_AES_H +#define __PTA_SCE_AES_H + +#include + +#define PTA_SCE_AES_UUID \ + { 0x4be7b9c4, 0x4951, 0x4105, \ + { 0xa3, 0xd3, 0x08, 0x1b, 0x50, 0x98, 0x10, 0xef } } + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES128ECB_EncryptInit (0x00020001) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : plain (length must be a multiple of 16) + * [in/out] memref[2] : cipher + */ +#define PTA_CMD_AES128ECB_EncryptUpdate (0x00020002) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES128ECB_EncryptFinal (0x00020003) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES128ECB_DecryptInit (0x00020011) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : cipher (length must be a multiple of 16) + * [in/out] memref[2] : plain + */ +#define PTA_CMD_AES128ECB_DecryptUpdate (0x00020012) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES128ECB_DecryptFinal (0x00020013) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES256ECB_EncryptInit (0x00020101) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : plain (length must be a multiple of 16) + * [in/out] memref[2] : cipher + */ +#define PTA_CMD_AES256ECB_EncryptUpdate (0x00020102) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES256ECB_EncryptFinal (0x00020103) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES256ECB_DecryptInit (0x00020111) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : cipher (length must be a multiple of 16) + * [in/out] memref[2] : plain + */ +#define PTA_CMD_AES256ECB_DecryptUpdate (0x00020112) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES256ECB_DecryptFinal (0x00020113) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES128CBC_EncryptInit (0x00021001) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : plain (length must be a multiple of 16) + * [in/out] memref[2] : cipher + */ +#define PTA_CMD_AES128CBC_EncryptUpdate (0x00021002) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES128CBC_EncryptFinal (0x00021003) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES128CBC_DecryptInit (0x00021011) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : cipher (length must be a multiple of 16) + * [in/out] memref[2] : plain + */ +#define PTA_CMD_AES128CBC_DecryptUpdate (0x00021012) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES128CBC_DecryptFinal (0x00021013) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES256CBC_EncryptInit (0x00021101) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : plain (length must be a multiple of 16) + * [in/out] memref[2] : cipher + */ +#define PTA_CMD_AES256CBC_EncryptUpdate (0x00021102) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES256CBC_EncryptFinal (0x00021103) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES256CBC_DecryptInit (0x00021111) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : cipher (length must be a multiple of 16) + * [in/out] memref[2] : plain + */ +#define PTA_CMD_AES256CBC_DecryptUpdate (0x00021112) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES256CBC_DecryptFinal (0x00021113) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES128CTR_EncryptInit (0x00022001) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : plain (length must be a multiple of 16) + * [in/out] memref[2] : cipher + */ +#define PTA_CMD_AES128CTR_EncryptUpdate (0x00022002) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES128CTR_EncryptFinal (0x00022003) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES128CTR_DecryptInit (0x00022011) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : cipher (length must be a multiple of 16) + * [in/out] memref[2] : plain + */ +#define PTA_CMD_AES128CTR_DecryptUpdate (0x00022012) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES128CTR_DecryptFinal (0x00022013) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES256CTR_EncryptInit (0x00022101) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : plain (length must be a multiple of 16) + * [in/out] memref[2] : cipher + */ +#define PTA_CMD_AES256CTR_EncryptUpdate (0x00022102) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES256CTR_EncryptFinal (0x00022103) + +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + * [in] memref[2] : Initial Vector(16byte) + */ +#define PTA_CMD_AES256CTR_DecryptInit (0x00022111) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + * [in] memref[1] : cipher (length must be a multiple of 16) + * [in/out] memref[2] : plain + */ +#define PTA_CMD_AES256CTR_DecryptUpdate (0x00022112) +/* + * [in/out] memref[0] : AES handler (sce_aes_handle_t) + */ +#define PTA_CMD_AES256CTR_DecryptFinal (0x00022113) + +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES128CMAC_GenerateInit (0x00023001) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : message + */ +#define PTA_CMD_AES128CMAC_GenerateUpdate (0x00023002) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in/out] memref[1] : mac (16byte) + */ +#define PTA_CMD_AES128CMAC_GenerateFinal (0x00023003) + +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES128CMAC_VerifyInit (0x00023011) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : message + */ +#define PTA_CMD_AES128CMAC_VerifyUpdate (0x00023012) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : mac (2 to 16bytes) + */ +#define PTA_CMD_AES128CMAC_VerifyFinal (0x00023013) + +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES256CMAC_GenerateInit (0x00023101) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : message + */ +#define PTA_CMD_AES256CMAC_GenerateUpdate (0x00023102) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in/out] memref[1] : mac (16byte) + */ +#define PTA_CMD_AES256CMAC_GenerateFinal (0x00023103) + +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) + */ +#define PTA_CMD_AES256CMAC_VerifyInit (0x00023111) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : message + */ +#define PTA_CMD_AES256CMAC_VerifyUpdate (0x00023112) +/* + * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) + * [in] memref[1] : mac (2 to 16bytes) + */ +#define PTA_CMD_AES256CMAC_VerifyFinal (0x00023113) + + +#endif /* __PTA_SCE_AES_H */ diff --git a/core/arch/arm/plat-rz/common/pta/include/pta_sce_ecc.h b/core/arch/arm/plat-rz/common/pta/include/pta_sce_ecc.h new file mode 100644 index 000000000..cf0baf464 --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/include/pta_sce_ecc.h @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ +#ifndef __PTA_SCE_ECC_H +#define __PTA_SCE_ECC_H + +#include + +#define PTA_SCE_ECC_UUID \ + { 0xa0c74f91, 0xbaac, 0x4ba3, \ + { 0x96, 0xbe, 0x58, 0xe5, 0x1f, 0xb1, 0xd1, 0xba } } + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (64byte) + * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_secp192r1_SignatureGenerate (0x00050000) + +/* + * [in] memref[0] : Signature (64byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_secp192r1_SignatureVerify (0x00050010) + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (64byte) + * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_secp224r1_SignatureGenerate (0x00050100) + +/* + * [in] memref[0] : Signature (64byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_secp224r1_SignatureVerify (0x00050110) + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (64byte) + * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_secp256r1_SignatureGenerate (0x00050200) + +/* + * [in] memref[0] : Signature (64byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_secp256r1_SignatureVerify (0x00050210) + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (64byte) + * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_BrainpoolP512r1_SignatureGenerate (0x00051000) + +/* + * [in] memref[0] : Signature (64byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) + */ +#define PTA_CMD_ECDSA_BrainpoolP512r1_SignatureVerify (0x00051010) + +#endif /* __PTA_SCE_ECC_H */ diff --git a/core/arch/arm/plat-rz/common/pta/include/pta_sce_rsa.h b/core/arch/arm/plat-rz/common/pta/include/pta_sce_rsa.h new file mode 100644 index 000000000..97bcc9298 --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/include/pta_sce_rsa.h @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ +#ifndef __PTA_SCE_RSA_H +#define __PTA_SCE_RSA_H + +#include + +#define PTA_SCE_RSA_UUID \ + { 0x5ad57120, 0xc447, 0x4b17, \ + { 0x90, 0x7b, 0x03, 0x1a, 0xd8, 0xd9, 0xb1, 0x7c } } + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (128byte) + * [in] memref[2] : Wrapped key (sce_rsa1024_private_wrapped_key_t) + */ +#define PTA_CMD_RSASSA_PKCS1024_SignatureGenerate (0x00040000) + +/* + * [in] memref[0] : Signature (128byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_rsa1024_public_wrapped_key_t) + */ +#define PTA_CMD_RSASSA_PKCS1024_SignatureVerify (0x00040010) + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (256byte) + * [in] memref[2] : Wrapped key (sce_rsa2048_private_wrapped_key_t) + */ +#define PTA_CMD_RSASSA_PKCS2048_SignatureGenerate (0x00040100) + +/* + * [in] memref[0] : Signature (256byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_rsa2048_public_wrapped_key_t) + */ +#define PTA_CMD_RSASSA_PKCS2048_SignatureVerify (0x00040110) + +/* + * [in] memref[0] : Signature (512byte) + * [in] memref[1] : Message + * [in] memref[2] : Wrapped key (sce_rsa4096_public_wrapped_key_t) + */ +#define PTA_CMD_RSASSA_PKCS4096_SignatureVerify (0x00040210) + +/* + * [in] memref[0] : plain (size <= public key n size - 11 byte) + * [in/out] memref[1] : cipher (size >= public key n byte) + * [in] memref[2] : Wrapped key (sce_rsa1024_public_wrapped_key_t) + */ +#define PTA_CMD_RSAES_PKCS1024_Encrypt (0x00041000) + +/* + * [in] memref[0] : cipher (size == public key n byte) + * [in/out] memref[1] : plain (size >= public key n - 11 byte) + * [in] memref[2] : Wrapped key (sce_rsa1024_private_wrapped_key_t) + */ +#define PTA_CMD_RSAES_PKCS1024_Decrypt (0x00041010) + +/* + * [in] memref[0] : plain (size <= public key n - 11 byte) + * [in/out] memref[1] : cipher (size >= public key n byte) + * [in] memref[2] : Wrapped key (sce_rsa2048_public_wrapped_key_t) + */ +#define PTA_CMD_RSAES_PKCS2048_Encrypt (0x00041100) + +/* + * [in] memref[0] : cipher (size == public key n byte) + * [in/out] memref[1] : plain (size >= public key n - 11 byte) + * [in] memref[2] : Wrapped key (sce_rsa2048_private_wrapped_key_t) + */ +#define PTA_CMD_RSAES_PKCS2048_Decrypt (0x00041110) + +/* + * [in] memref[0] : plain (size <= public key n - 11 byte) + * [in/out] memref[1] : cipher (size >= public key n byte) + * [in] memref[2] : Wrapped key (sce_rsa4096_public_wrapped_key_t) + */ +#define PTA_CMD_RSAES_PKCS4096_Encrypt (0x00041200) + +#endif /* __PTA_SCE_RSA_H */ diff --git a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_sha.h b/core/arch/arm/plat-rz/common/pta/include/pta_sce_sha.h similarity index 58% rename from core/arch/arm/plat-rz/v2h/pta/include/pta_sce_sha.h rename to core/arch/arm/plat-rz/common/pta/include/pta_sce_sha.h index c112ce0f7..414bb53d1 100644 --- a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_sha.h +++ b/core/arch/arm/plat-rz/common/pta/include/pta_sce_sha.h @@ -8,41 +8,41 @@ #include #define PTA_SCE_SHA_UUID \ - { 0x5b6cecf4, 0x12ae, 0x4c0f, \ - { 0x94, 0xb5, 0xce, 0xcc, 0x5f, 0x48, 0x62, 0xe4 } } + { 0x5b6cecf4, 0x12ae, 0x4c0f, \ + { 0x94, 0xb5, 0xce, 0xcc, 0x5f, 0x48, 0x62, 0xe4 } } /* * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) */ -#define PTA_CMD_SHA224_Init (0x00030000) +#define PTA_CMD_SHA224_Init (0x00030000) /* * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) - * [in] memref[1] : Message + * [in] memref[1] : Message */ -#define PTA_CMD_SHA224_Update (0x00030001) +#define PTA_CMD_SHA224_Update (0x00030001) /* * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) * [in/out] memref[1] : Digest (28byte) */ -#define PTA_CMD_SHA224_Final (0x00030002) +#define PTA_CMD_SHA224_Final (0x00030002) /* * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) */ -#define PTA_CMD_SHA256_Init (0x00030100) +#define PTA_CMD_SHA256_Init (0x00030100) /* * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) - * [in] memref[1] : Message + * [in] memref[1] : Message */ -#define PTA_CMD_SHA256_Update (0x00030101) +#define PTA_CMD_SHA256_Update (0x00030101) /* * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) * [in/out] memref[1] : Digest (32byte) */ -#define PTA_CMD_SHA256_Final (0x00030102) +#define PTA_CMD_SHA256_Final (0x00030102) #endif /* __PTA_SCE_SHA_H */ diff --git a/core/arch/arm/plat-rz/common/pta/pta_sce.c b/core/arch/arm/plat-rz/common/pta/pta_sce.c new file mode 100644 index 000000000..86f44dca7 --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/pta_sce.c @@ -0,0 +1,1170 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ + +#include + +#include +#include + +#define PTA_NAME "sce.pta" + +static TEE_Result aes128_wrappedkeygenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128_WrappedKeyGenerate(wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ + return TEE_ERROR_ACCESS_CONFLICT; + } + + params[0].memref.size = sizeof(sce_aes_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256_wrappedkeygenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256_WrappedKeyGenerate(wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ + return TEE_ERROR_ACCESS_CONFLICT; + } + + params[0].memref.size = sizeof(sce_aes_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa1024_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pair_key = (sce_rsa1024_wrapped_pair_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_pair_key) || (sizeof(sce_rsa1024_wrapped_pair_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA1024_WrappedKeyPairGenerate(wrapped_pair_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_rsa1024_wrapped_pair_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa2048_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pair_key = (sce_rsa2048_wrapped_pair_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_pair_key) || (sizeof(sce_rsa2048_wrapped_pair_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA2048_WrappedKeyPairGenerate(wrapped_pair_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_rsa2048_wrapped_pair_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp192r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecc_wrapped_pair_key_t * wrapped_pair_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp192r1_WrappedKeyPairGenerate(wrapped_pair_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp224r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecc_wrapped_pair_key_t * wrapped_pair_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp224r1_WrappedKeyPairGenerate(wrapped_pair_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp256r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecc_wrapped_pair_key_t * wrapped_pair_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp256r1_WrappedKeyPairGenerate(wrapped_pair_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_brainpoolp512r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecc_wrapped_pair_key_t * wrapped_pair_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; + if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_BrainpoolP512r1_WrappedKeyPairGenerate(wrapped_pair_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result randomnumbergenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint32_t * random; + + const uint32_t random_length = 16; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + random = (uint32_t *)params[0].memref.buffer; + if ((NULL == random) || (random_length > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.randomNumberGenerate(random); + switch (err) + { + case FSP_SUCCESS: + break; + default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ + return TEE_ERROR_ACCESS_CONFLICT; + } + + params[0].memref.size = random_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128_encryptedkeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || ((SCE_OEM_KEY_SIZE_AES128_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128_EncryptedKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_aes_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256_encryptedkeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || ((SCE_OEM_KEY_SIZE_AES256_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256_EncryptedKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_aes_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa1024_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_rsa1024_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_RSA1024_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa1024_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA1024_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_rsa1024_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa1024_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_rsa1024_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_RSA1024_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa1024_private_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_private_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA1024_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_rsa1024_private_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa2048_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_rsa2048_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_RSA2048_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa2048_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA2048_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_rsa2048_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa2048_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_rsa2048_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_RSA2048_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa2048_private_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_private_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA2048_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_rsa2048_private_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result rsa4096_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_rsa4096_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_RSA4096_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa4096_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa4096_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSA4096_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_rsa4096_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp192r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP192_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp192r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp192r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP192_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp192r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp224r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP224_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp224r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp224r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP224_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp224r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp256r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP256_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp256r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_secp256r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP256_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_secp256r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_brainpoolp512r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP512_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_BrainpoolP512r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result ecc_brainpoolp512r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + sce_key_update_key_t * key_update_key; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((NULL == encrypted_key) || + ((SCE_OEM_KEY_SIZE_ECCP512_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; + if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); + + return TEE_SUCCESS; +} + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_AES128_WrappedKeyGenerate : + return aes128_wrappedkeygenerate(ptypes, params); + case PTA_CMD_AES256_WrappedKeyGenerate : + return aes256_wrappedkeygenerate(ptypes, params); + case PTA_CMD_RSA1024_WrappedKeyPairGenerate : + return rsa1024_wrappedkeypairgenerate(ptypes, params); + case PTA_CMD_RSA2048_WrappedKeyPairGenerate : + return rsa2048_wrappedkeypairgenerate(ptypes, params); + case PTA_CMD_ECC_secp192r1_WrappedKeyPairGenerate : + return ecc_secp192r1_wrappedkeypairgenerate(ptypes, params); + case PTA_CMD_ECC_secp224r1_WrappedKeyPairGenerate : + return ecc_secp224r1_wrappedkeypairgenerate(ptypes, params); + case PTA_CMD_ECC_secp256r1_WrappedKeyPairGenerate : + return ecc_secp256r1_wrappedkeypairgenerate(ptypes, params); + case PTA_CMD_ECC_BrainpoolP512r1_WrappedKeyPairGenerate : + return ecc_brainpoolp512r1_wrappedkeypairgenerate(ptypes, params); + case PTA_CMD_RandomNumberGenerate : + return randomnumbergenerate(ptypes, params); + case PTA_CMD_AES128_EncryptedKeyWrap : + return aes128_encryptedkeywrap(ptypes, params); + case PTA_CMD_AES256_EncryptedKeyWrap : + return aes256_encryptedkeywrap(ptypes, params); + case PTA_CMD_RSA1024_EncryptedPublicKeyWrap : + return rsa1024_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_RSA1024_EncryptedPrivateKeyWrap : + return rsa1024_encryptedprivatekeywrap(ptypes, params); + case PTA_CMD_RSA2048_EncryptedPublicKeyWrap : + return rsa2048_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_RSA2048_EncryptedPrivateKeyWrap : + return rsa2048_encryptedprivatekeywrap(ptypes, params); + case PTA_CMD_RSA4096_EncryptedPublicKeyWrap : + return rsa4096_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_ECC_secp192r1_EncryptedPublicKeyWrap : + return ecc_secp192r1_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_ECC_secp224r1_EncryptedPublicKeyWrap : + return ecc_secp224r1_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_ECC_secp256r1_EncryptedPublicKeyWrap : + return ecc_secp256r1_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap : + return ecc_brainpoolp512r1_encryptedpublickeywrap(ptypes, params); + case PTA_CMD_ECC_secp192r1_EncryptedPrivateKeyWrap : + return ecc_secp192r1_encryptedprivatekeywrap(ptypes, params); + case PTA_CMD_ECC_secp224r1_EncryptedPrivateKeyWrap : + return ecc_secp224r1_encryptedprivatekeywrap(ptypes, params); + case PTA_CMD_ECC_secp256r1_EncryptedPrivateKeyWrap : + return ecc_secp256r1_encryptedprivatekeywrap(ptypes, params); + case PTA_CMD_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap : + return ecc_brainpoolp512r1_encryptedprivatekeywrap(ptypes, params); + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_SCE_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/common/pta/pta_sce_aes.c b/core/arch/arm/plat-rz/common/pta/pta_sce_aes.c new file mode 100644 index 000000000..4ada2c9c1 --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/pta_sce_aes.c @@ -0,0 +1,2257 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ + +#include + +#include +#include + +#define PTA_NAME "sce_aes.pta" + +static TEE_Result aes128ecb_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128ECB_EncryptInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128ecb_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[2].memref.buffer; + cipher_length = (uint32_t)params[2].memref.size; + if ((NULL == cipher) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128ECB_EncryptUpdate(handle, plain, cipher, plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128ecb_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = NULL; // nothing ever written here + cipher_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES128ECB_EncryptFinal(handle, cipher, &cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128ecb_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128ECB_DecryptInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128ecb_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[2].memref.buffer; + plain_length = (uint32_t)params[2].memref.size; + if ((NULL == plain) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128ECB_DecryptUpdate(handle, cipher, plain, cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128ecb_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = NULL; // nothing ever written here + plain_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES128ECB_DecryptFinal(handle, plain, &plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256ecb_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256ECB_EncryptInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256ecb_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[2].memref.buffer; + cipher_length = (uint32_t)params[2].memref.size; + if ((NULL == cipher) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256ECB_EncryptUpdate(handle, plain, cipher, plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes256ecb_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = NULL; // nothing ever written here + cipher_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES256ECB_EncryptFinal(handle, cipher, &cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256ecb_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256ECB_DecryptInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256ecb_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[2].memref.buffer; + plain_length = (uint32_t)params[2].memref.size; + if ((NULL == plain) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256ECB_DecryptUpdate(handle, cipher, plain, cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes256ecb_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = NULL; // nothing ever written here + plain_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES256ECB_DecryptFinal(handle, plain, &plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128cbc_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CBC_EncryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128cbc_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[2].memref.buffer; + cipher_length = (uint32_t)params[2].memref.size; + if ((NULL == cipher) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CBC_EncryptUpdate(handle, plain, cipher, plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128cbc_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = NULL; // nothing ever written here + cipher_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES128CBC_EncryptFinal(handle, cipher, &cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128cbc_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CBC_DecryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128cbc_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[2].memref.buffer; + plain_length = (uint32_t)params[2].memref.size; + if ((NULL == plain) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CBC_DecryptUpdate(handle, cipher, plain, cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128cbc_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = NULL; // nothing ever written here + plain_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES128CBC_DecryptFinal(handle, plain, &plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256cbc_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CBC_EncryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256cbc_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[2].memref.buffer; + cipher_length = (uint32_t)params[2].memref.size; + if ((NULL == cipher) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CBC_EncryptUpdate(handle, plain, cipher, plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes256cbc_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = NULL; // nothing ever written here + cipher_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES256CBC_EncryptFinal(handle, cipher, &cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256cbc_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CBC_DecryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256cbc_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[2].memref.buffer; + plain_length = (uint32_t)params[2].memref.size; + if ((NULL == plain) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CBC_DecryptUpdate(handle, cipher, plain, cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes256cbc_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = NULL; // nothing ever written here + plain_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES256CBC_DecryptFinal(handle, plain, &plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128ctr_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CTR_EncryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128ctr_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[2].memref.buffer; + cipher_length = (uint32_t)params[2].memref.size; + if ((NULL == cipher) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CTR_EncryptUpdate(handle, plain, cipher, plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128ctr_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = NULL; // nothing ever written here + cipher_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES128CTR_EncryptFinal(handle, cipher, &cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128ctr_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CTR_DecryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128ctr_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[2].memref.buffer; + plain_length = (uint32_t)params[2].memref.size; + if ((NULL == plain) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CTR_DecryptUpdate(handle, cipher, plain, cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128ctr_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = NULL; // nothing ever written here + plain_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES128CTR_DecryptFinal(handle, plain, &plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256ctr_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CTR_EncryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256ctr_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[2].memref.buffer; + cipher_length = (uint32_t)params[2].memref.size; + if ((NULL == cipher) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CTR_EncryptUpdate(handle, plain, cipher, plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes256ctr_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = NULL; // nothing ever written here + cipher_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES256CTR_EncryptFinal(handle, cipher, &cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256ctr_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[2].memref.buffer; + if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CTR_DecryptInit(handle, wrapped_key, initial_vector); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_aes_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256ctr_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[2].memref.buffer; + plain_length = (uint32_t)params[2].memref.size; + if ((NULL == plain) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CTR_DecryptUpdate(handle, cipher, plain, cipher_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[2].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes256ctr_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_aes_handle_t * handle; + uint8_t * plain; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_aes_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = NULL; // nothing ever written here + plain_length = 0; // 0 always written here + + err = g_sce_protected_on_sce.AES256CTR_DecryptFinal(handle, plain, &plain_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128cmac_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CMAC_GenerateInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_cmac_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128cmac_generateupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (NULL == message) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CMAC_GenerateUpdate(handle, message, message_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128cmac_generatefinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * mac; + uint32_t mac_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + mac = (uint8_t *)params[1].memref.buffer; + mac_length = params[1].memref.size; + if ((NULL == mac) || (HW_SCE_AES_BLOCK_BYTE_SIZE > mac_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CMAC_GenerateFinal(handle, mac); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION: + return TEE_ERROR_BAD_STATE; + default: /* FSP_ERR_CRYPTO_SCE_AUTHENTICATION */ + return TEE_ERROR_MAC_INVALID; + } + + params[1].memref.size = HW_SCE_AES_BLOCK_BYTE_SIZE; + + return TEE_SUCCESS; +} + +static TEE_Result aes128cmac_verifyinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CMAC_VerifyInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_cmac_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes128cmac_verifyupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (NULL == message) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CMAC_VerifyUpdate(handle, message, message_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes128cmac_verifyfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * mac; + uint32_t mac_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + mac = (uint8_t *)params[1].memref.buffer; + mac_length = params[1].memref.size; + if ((NULL == mac) || (2 > mac_length) || (HW_SCE_AES_BLOCK_BYTE_SIZE < mac_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES128CMAC_VerifyFinal(handle, mac, mac_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: + return TEE_ERROR_MAC_INVALID; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256cmac_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CMAC_GenerateInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_cmac_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256cmac_generateupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (NULL == message) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CMAC_GenerateUpdate(handle, message, message_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256cmac_generatefinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * mac; + uint32_t mac_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + mac = (uint8_t *)params[1].memref.buffer; + mac_length = params[1].memref.size; + if ((NULL == mac) || (HW_SCE_AES_BLOCK_BYTE_SIZE > mac_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CMAC_GenerateFinal(handle, mac); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION: + return TEE_ERROR_BAD_STATE; + default: /* FSP_ERR_CRYPTO_SCE_AUTHENTICATION */ + return TEE_ERROR_MAC_INVALID; + } + + params[1].memref.size = HW_SCE_AES_BLOCK_BYTE_SIZE; + + return TEE_SUCCESS; +} + +static TEE_Result aes256cmac_verifyinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + sce_aes_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CMAC_VerifyInit(handle, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_cmac_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result aes256cmac_verifyupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (NULL == message) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CMAC_VerifyUpdate(handle, message, message_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes256cmac_verifyfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_cmac_handle_t * handle; + uint8_t * mac; + uint32_t mac_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_cmac_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + mac = (uint8_t *)params[1].memref.buffer; + mac_length = params[1].memref.size; + if ((NULL == mac) || (2 > mac_length) || (HW_SCE_AES_BLOCK_BYTE_SIZE < mac_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.AES256CMAC_VerifyFinal(handle, mac, mac_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: + return TEE_ERROR_MAC_INVALID; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result invoke_command( + void *session __unused, + uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS] + ) +{ + DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_AES128ECB_EncryptInit : + return aes128ecb_encryptinit(ptypes, params); + case PTA_CMD_AES128ECB_EncryptUpdate : + return aes128ecb_encryptupdate(ptypes, params); + case PTA_CMD_AES128ECB_EncryptFinal : + return aes128ecb_encryptfinal(ptypes, params); + case PTA_CMD_AES128ECB_DecryptInit : + return aes128ecb_decryptinit(ptypes, params); + case PTA_CMD_AES128ECB_DecryptUpdate : + return aes128ecb_decryptupdate(ptypes, params); + case PTA_CMD_AES128ECB_DecryptFinal : + return aes128ecb_decryptfinal(ptypes, params); + case PTA_CMD_AES256ECB_EncryptInit : + return aes256ecb_encryptinit(ptypes, params); + case PTA_CMD_AES256ECB_EncryptUpdate : + return aes256ecb_encryptupdate(ptypes, params); + case PTA_CMD_AES256ECB_EncryptFinal : + return aes256ecb_encryptfinal(ptypes, params); + case PTA_CMD_AES256ECB_DecryptInit : + return aes256ecb_decryptinit(ptypes, params); + case PTA_CMD_AES256ECB_DecryptUpdate : + return aes256ecb_decryptupdate(ptypes, params); + case PTA_CMD_AES256ECB_DecryptFinal : + return aes256ecb_decryptfinal(ptypes, params); + case PTA_CMD_AES128CBC_EncryptInit : + return aes128cbc_encryptinit(ptypes, params); + case PTA_CMD_AES128CBC_EncryptUpdate : + return aes128cbc_encryptupdate(ptypes, params); + case PTA_CMD_AES128CBC_EncryptFinal : + return aes128cbc_encryptfinal(ptypes, params); + case PTA_CMD_AES128CBC_DecryptInit : + return aes128cbc_decryptinit(ptypes, params); + case PTA_CMD_AES128CBC_DecryptUpdate : + return aes128cbc_decryptupdate(ptypes, params); + case PTA_CMD_AES128CBC_DecryptFinal : + return aes128cbc_decryptfinal(ptypes, params); + case PTA_CMD_AES256CBC_EncryptInit : + return aes256cbc_encryptinit(ptypes, params); + case PTA_CMD_AES256CBC_EncryptUpdate : + return aes256cbc_encryptupdate(ptypes, params); + case PTA_CMD_AES256CBC_EncryptFinal : + return aes256cbc_encryptfinal(ptypes, params); + case PTA_CMD_AES256CBC_DecryptInit : + return aes256cbc_decryptinit(ptypes, params); + case PTA_CMD_AES256CBC_DecryptUpdate : + return aes256cbc_decryptupdate(ptypes, params); + case PTA_CMD_AES256CBC_DecryptFinal : + return aes256cbc_decryptfinal(ptypes, params); + case PTA_CMD_AES128CTR_EncryptInit : + return aes128ctr_encryptinit(ptypes, params); + case PTA_CMD_AES128CTR_EncryptUpdate : + return aes128ctr_encryptupdate(ptypes, params); + case PTA_CMD_AES128CTR_EncryptFinal : + return aes128ctr_encryptfinal(ptypes, params); + case PTA_CMD_AES128CTR_DecryptInit : + return aes128ctr_decryptinit(ptypes, params); + case PTA_CMD_AES128CTR_DecryptUpdate : + return aes128ctr_decryptupdate(ptypes, params); + case PTA_CMD_AES128CTR_DecryptFinal : + return aes128ctr_decryptfinal(ptypes, params); + case PTA_CMD_AES256CTR_EncryptInit : + return aes256ctr_encryptinit(ptypes, params); + case PTA_CMD_AES256CTR_EncryptUpdate : + return aes256ctr_encryptupdate(ptypes, params); + case PTA_CMD_AES256CTR_EncryptFinal : + return aes256ctr_encryptfinal(ptypes, params); + case PTA_CMD_AES256CTR_DecryptInit : + return aes256ctr_decryptinit(ptypes, params); + case PTA_CMD_AES256CTR_DecryptUpdate : + return aes256ctr_decryptupdate(ptypes, params); + case PTA_CMD_AES256CTR_DecryptFinal : + return aes256ctr_decryptfinal(ptypes, params); + case PTA_CMD_AES128CMAC_GenerateInit : + return aes128cmac_generateinit(ptypes, params); + case PTA_CMD_AES128CMAC_GenerateUpdate : + return aes128cmac_generateupdate(ptypes, params); + case PTA_CMD_AES128CMAC_GenerateFinal : + return aes128cmac_generatefinal(ptypes, params); + case PTA_CMD_AES128CMAC_VerifyInit : + return aes128cmac_verifyinit(ptypes, params); + case PTA_CMD_AES128CMAC_VerifyUpdate : + return aes128cmac_verifyupdate(ptypes, params); + case PTA_CMD_AES128CMAC_VerifyFinal : + return aes128cmac_verifyfinal(ptypes, params); + case PTA_CMD_AES256CMAC_GenerateInit : + return aes256cmac_generateinit(ptypes, params); + case PTA_CMD_AES256CMAC_GenerateUpdate : + return aes256cmac_generateupdate(ptypes, params); + case PTA_CMD_AES256CMAC_GenerateFinal : + return aes256cmac_generatefinal(ptypes, params); + case PTA_CMD_AES256CMAC_VerifyInit : + return aes256cmac_verifyinit(ptypes, params); + case PTA_CMD_AES256CMAC_VerifyUpdate : + return aes256cmac_verifyupdate(ptypes, params); + case PTA_CMD_AES256CMAC_VerifyFinal : + return aes256cmac_verifyfinal(ptypes, params); + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register( + .uuid = PTA_SCE_AES_UUID, + .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS | TA_FLAG_DEVICE_ENUM, + .invoke_command_entry_point = invoke_command +); diff --git a/core/arch/arm/plat-rz/common/pta/pta_sce_ecc.c b/core/arch/arm/plat-rz/common/pta/pta_sce_ecc.c new file mode 100644 index 000000000..3a2856b2c --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/pta_sce_ecc.c @@ -0,0 +1,483 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ + +#include +#include + +#include +#include + +#define PTA_NAME "sce_ecc.pta" + +static uint32_t sha512_hash[HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t)]; + +static TEE_Result ecdsa_secp192r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t message_hash; + sce_ecdsa_byte_data_t signature; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[0].memref.buffer; + message_hash.data_length = params[0].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[1].memref.buffer; + signature.data_length = params[1].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE > signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_secp192r1_SignatureGenerate(&message_hash, &signature, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = signature.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp192r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t signature; + sce_ecdsa_byte_data_t message_hash; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[1].memref.buffer; + message_hash.data_length = params[1].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_secp192r1_SignatureVerify(&signature, &message_hash, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp224r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t message_hash; + sce_ecdsa_byte_data_t signature; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[0].memref.buffer; + message_hash.data_length = params[0].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[1].memref.buffer; + signature.data_length = params[1].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE > signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_secp224r1_SignatureGenerate(&message_hash, &signature, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = signature.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp224r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t signature; + sce_ecdsa_byte_data_t message_hash; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[1].memref.buffer; + message_hash.data_length = params[1].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_secp224r1_SignatureVerify(&signature, &message_hash, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp256r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t message_hash; + sce_ecdsa_byte_data_t signature; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[0].memref.buffer; + message_hash.data_length = params[0].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[1].memref.buffer; + signature.data_length = params[1].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE > signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_secp256r1_SignatureGenerate(&message_hash, &signature, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = signature.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp256r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t signature; + sce_ecdsa_byte_data_t message_hash; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[1].memref.buffer; + message_hash.data_length = params[1].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_secp256r1_SignatureVerify(&signature, &message_hash, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_brainpoolp512r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t message_hash; + sce_ecdsa_byte_data_t signature; + sce_ecc_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)sha512_hash; + message_hash.data_length = HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE; + message_hash.data_type = 1; + err = tee_hash_createdigest(TEE_ALG_SHA512, params[0].memref.buffer, params[0].memref.size, + message_hash.pdata, message_hash.data_length); + if (err) { + return err; + } + + signature.pdata = (uint8_t *)params[1].memref.buffer; + signature.data_length = params[1].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_P512_DATA_BYTE_SIZE > signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_BrainpoolP512r1_SignatureGenerate(&message_hash, &signature, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = signature.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_brainpoolp512r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_ecdsa_byte_data_t signature; + sce_ecdsa_byte_data_t message_hash; + sce_ecc_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_ECDSA_P512_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)sha512_hash; + message_hash.data_length = HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE; + message_hash.data_type = 1; + err = tee_hash_createdigest(TEE_ALG_SHA512, params[1].memref.buffer, params[1].memref.size, + message_hash.pdata, message_hash.data_length); + if (err) { + return err; + } + + wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.ECDSA_BrainpoolP512r1_SignatureVerify(&signature, &message_hash, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) + { + case PTA_CMD_ECDSA_secp192r1_SignatureGenerate : + return ecdsa_secp192r1_signaturegenerate(ptypes, params); + case PTA_CMD_ECDSA_secp192r1_SignatureVerify : + return ecdsa_secp192r1_signatureverify(ptypes, params); + case PTA_CMD_ECDSA_secp224r1_SignatureGenerate : + return ecdsa_secp224r1_signaturegenerate(ptypes, params); + case PTA_CMD_ECDSA_secp224r1_SignatureVerify : + return ecdsa_secp224r1_signatureverify(ptypes, params); + case PTA_CMD_ECDSA_secp256r1_SignatureGenerate : + return ecdsa_secp256r1_signaturegenerate(ptypes, params); + case PTA_CMD_ECDSA_secp256r1_SignatureVerify : + return ecdsa_secp256r1_signatureverify(ptypes, params); + case PTA_CMD_ECDSA_BrainpoolP512r1_SignatureGenerate : + return ecdsa_brainpoolp512r1_signaturegenerate(ptypes, params); + case PTA_CMD_ECDSA_BrainpoolP512r1_SignatureVerify : + return ecdsa_brainpoolp512r1_signatureverify(ptypes, params); + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_SCE_ECC_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/common/pta/pta_sce_rsa.c b/core/arch/arm/plat-rz/common/pta/pta_sce_rsa.c new file mode 100644 index 000000000..6fb85f4ee --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/pta_sce_rsa.c @@ -0,0 +1,576 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ + +#include + +#include +#include + +#define PTA_NAME "sce_rsa.pta" + +static TEE_Result rsassa_pkcs1024_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t message_hash; + sce_rsa_byte_data_t signature; + sce_rsa1024_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[0].memref.buffer; + message_hash.data_length = params[0].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[1].memref.buffer; + signature.data_length = params[1].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_RSA_1024_DATA_BYTE_SIZE > signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa1024_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSASSA_PKCS1024_SignatureGenerate(&message_hash, &signature, wrapped_key, HW_SCE_RSA_HASH_SHA256); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = signature.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result rsassa_pkcs1024_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t signature; + sce_rsa_byte_data_t message_hash; + sce_rsa1024_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_RSA_1024_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[1].memref.buffer; + message_hash.data_length = params[1].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa1024_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSASSA_PKCS1024_SignatureVerify(&signature, &message_hash, wrapped_key, HW_SCE_RSA_HASH_SHA256); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: + return TEE_ERROR_SIGNATURE_INVALID; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result rsassa_pkcs2048_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t message_hash; + sce_rsa_byte_data_t signature; + sce_rsa2048_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[0].memref.buffer; + message_hash.data_length = params[0].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[1].memref.buffer; + signature.data_length = params[1].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_RSA_2048_DATA_BYTE_SIZE > signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa2048_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSASSA_PKCS2048_SignatureGenerate(&message_hash, &signature, wrapped_key, HW_SCE_RSA_HASH_SHA256); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = signature.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result rsassa_pkcs2048_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t signature; + sce_rsa_byte_data_t message_hash; + sce_rsa2048_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_RSA_2048_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[1].memref.buffer; + message_hash.data_length = params[1].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa2048_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSASSA_PKCS2048_SignatureVerify(&signature, &message_hash, wrapped_key, HW_SCE_RSA_HASH_SHA256); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: + return TEE_ERROR_SIGNATURE_INVALID; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result rsassa_pkcs4096_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t signature; + sce_rsa_byte_data_t message_hash; + sce_rsa4096_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature.pdata = (uint8_t *)params[0].memref.buffer; + signature.data_length = params[0].memref.size; + signature.data_type = 0; + if ((NULL == signature.pdata) || (HW_SCE_RSA_4096_DATA_BYTE_SIZE != signature.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message_hash.pdata = (uint8_t *)params[1].memref.buffer; + message_hash.data_length = params[1].memref.size; + message_hash.data_type = 0; + if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa4096_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa4096_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSASSA_PKCS4096_SignatureVerify(&signature, &message_hash, wrapped_key, HW_SCE_RSA_HASH_SHA256); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: + return TEE_ERROR_SIGNATURE_INVALID; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result rsaes_pkcs1024_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t plain; + sce_rsa_byte_data_t cipher; + sce_rsa1024_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain.pdata = (uint8_t *)params[0].memref.buffer; + plain.data_length = params[0].memref.size; + plain.data_type = 0; + if (NULL == plain.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher.pdata = (uint8_t *)params[1].memref.buffer; + cipher.data_length = params[1].memref.size; + cipher.data_type = 0; + if (NULL == cipher.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa1024_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSAES_PKCS1024_Encrypt(&plain, &cipher, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PARAMETER */ + return TEE_ERROR_BAD_PARAMETERS; + } + + params[1].memref.size = cipher.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result rsaes_pkcs1024_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t plain; + sce_rsa_byte_data_t cipher; + sce_rsa1024_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher.pdata = (uint8_t *)params[0].memref.buffer; + cipher.data_length = params[0].memref.size; + cipher.data_type = 0; + if (NULL == cipher.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain.pdata = (uint8_t *)params[1].memref.buffer; + plain.data_length = params[1].memref.size; + plain.data_type = 0; + if (NULL == plain.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa1024_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSAES_PKCS1024_Decrypt(&cipher, &plain, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} +static TEE_Result rsaes_pkcs2048_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t plain; + sce_rsa_byte_data_t cipher; + sce_rsa2048_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain.pdata = (uint8_t *)params[0].memref.buffer; + plain.data_length = params[0].memref.size; + plain.data_type = 0; + if (NULL == plain.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher.pdata = (uint8_t *)params[1].memref.buffer; + cipher.data_length = params[1].memref.size; + cipher.data_type = 0; + if (NULL == cipher.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa2048_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSAES_PKCS2048_Encrypt(&plain, &cipher, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PARAMETER */ + return TEE_ERROR_BAD_PARAMETERS; + } + + params[1].memref.size = cipher.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result rsaes_pkcs2048_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t plain; + sce_rsa_byte_data_t cipher; + sce_rsa2048_private_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher.pdata = (uint8_t *)params[0].memref.buffer; + cipher.data_length = params[0].memref.size; + cipher.data_type = 0; + if (NULL == cipher.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain.pdata = (uint8_t *)params[1].memref.buffer; + plain.data_length = params[1].memref.size; + plain.data_type = 0; + if (NULL == plain.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa2048_private_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_private_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSAES_PKCS2048_Decrypt(&cipher, &plain, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_FAIL */ + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +static TEE_Result rsaes_pkcs4096_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_rsa_byte_data_t plain; + sce_rsa_byte_data_t cipher; + sce_rsa4096_public_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain.pdata = (uint8_t *)params[0].memref.buffer; + plain.data_length = params[0].memref.size; + plain.data_type = 0; + if (NULL == plain.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher.pdata = (uint8_t *)params[1].memref.buffer; + cipher.data_length = params[1].memref.size; + cipher.data_type = 0; + if (NULL == cipher.pdata) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (sce_rsa4096_public_wrapped_key_t *)params[2].memref.buffer; + if ((NULL == wrapped_key) || (sizeof(sce_rsa4096_public_wrapped_key_t) != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.RSAES_PKCS4096_Encrypt(&plain, &cipher, wrapped_key); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PARAMETER */ + return TEE_ERROR_BAD_PARAMETERS; + } + + params[1].memref.size = cipher.data_length; + + return TEE_SUCCESS; +} + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_RSASSA_PKCS1024_SignatureGenerate : + return rsassa_pkcs1024_signaturegenerate(ptypes, params); + case PTA_CMD_RSASSA_PKCS1024_SignatureVerify : + return rsassa_pkcs1024_signatureverify(ptypes, params); + case PTA_CMD_RSASSA_PKCS2048_SignatureGenerate : + return rsassa_pkcs2048_signaturegenerate(ptypes, params); + case PTA_CMD_RSASSA_PKCS2048_SignatureVerify : + return rsassa_pkcs2048_signatureverify(ptypes, params); + case PTA_CMD_RSASSA_PKCS4096_SignatureVerify : + return rsassa_pkcs4096_signatureverify(ptypes, params); + case PTA_CMD_RSAES_PKCS1024_Encrypt : + return rsaes_pkcs1024_encrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS1024_Decrypt : + return rsaes_pkcs1024_decrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS2048_Encrypt : + return rsaes_pkcs2048_encrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS2048_Decrypt : + return rsaes_pkcs2048_decrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS4096_Encrypt : + return rsaes_pkcs4096_encrypt(ptypes, params); + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_SCE_RSA_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/common/pta/pta_sce_sha.c b/core/arch/arm/plat-rz/common/pta/pta_sce_sha.c new file mode 100644 index 000000000..864fcd6bc --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/pta_sce_sha.c @@ -0,0 +1,269 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022, Renesas Electronics + */ + +#include + +#include +#include + +#define PTA_NAME "sce_sha.pta" + +static TEE_Result sha224_init(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_sha_md5_handle_t * handle; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.SHA224_Init(handle); + switch (err) + { + case FSP_SUCCESS: + break; + default: + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_sha_md5_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result sha224_update(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_sha_md5_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + + err = g_sce_protected_on_sce.SHA224_Update(handle, message, message_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result sha224_final(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_sha_md5_handle_t * handle; + uint8_t * digest; + uint32_t digest_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + digest = (uint8_t *)params[1].memref.buffer; + digest_length = (uint32_t)params[1].memref.size; + if ((NULL == digest) || (HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE > digest_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.SHA224_Final(handle, digest, &digest_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = digest_length; + + return TEE_SUCCESS; +} + +static TEE_Result sha256_init(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_sha_md5_handle_t * handle; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.SHA256_Init(handle); + switch (err) + { + case FSP_SUCCESS: + break; + default: + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(sce_sha_md5_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result sha256_update(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_sha_md5_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + + err = g_sce_protected_on_sce.SHA256_Update(handle, message, message_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result sha256_final(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + sce_sha_md5_handle_t * handle; + uint8_t * digest; + uint32_t digest_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; + if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + digest = (uint8_t *)params[1].memref.buffer; + digest_length = (uint32_t)params[1].memref.size; + if ((NULL == digest) || (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE > digest_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = g_sce_protected_on_sce.SHA256_Final(handle, digest, &digest_length); + switch (err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_SCE_PARAMETER: + return TEE_ERROR_BAD_PARAMETERS; + default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = digest_length; + + return TEE_SUCCESS; +} + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_SHA224_Init : + return sha224_init(ptypes, params); + case PTA_CMD_SHA224_Update : + return sha224_update(ptypes, params); + case PTA_CMD_SHA224_Final : + return sha224_final(ptypes, params); + case PTA_CMD_SHA256_Init : + return sha256_init(ptypes, params); + case PTA_CMD_SHA256_Update : + return sha256_update(ptypes, params); + case PTA_CMD_SHA256_Final : + return sha256_final(ptypes, params); + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_SCE_SHA_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/common/pta/sub.mk b/core/arch/arm/plat-rz/common/pta/sub.mk index 1dd1a770c..596449565 100644 --- a/core/arch/arm/plat-rz/common/pta/sub.mk +++ b/core/arch/arm/plat-rz/common/pta/sub.mk @@ -1,3 +1,4 @@ global-incdirs-y += include -srcs-y += pta_flash.c \ No newline at end of file +srcs-y += pta_flash.c +srcs-$(CFG_RZ_SCE) += pta_sce.c pta_sce_ecc.c pta_sce_rsa.c pta_sce_sha.c pta_sce_aes.c diff --git a/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.c b/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.c index 743b93415..acd9d1add 100644 --- a/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.c +++ b/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg.c @@ -108,11 +108,6 @@ static void cpg_clkon_rst(CPG_SETUP_DATA const *array, uint32_t num) cpg_io_write(array->reg.addr, val); - /* - * This generic function needs to handle case where Montitor for clock - * is looking for a HIGH as clock active whereas Montitoring a reset - * it is looking for a LOW to indicate reset release. - */ mask = array->mon.val; cmp = mask; @@ -137,20 +132,15 @@ static void cpg_clkoff_rst(CPG_SETUP_DATA const *array, uint32_t num) uint32_t val = (array->reg.val & 0xFFFF) | ((array->reg.val & 0xFFFF) << 16); - if (array->type == CPG_T_CLK) + if ((array->type == CPG_T_CLK) || (array->type == CPG_T_RST)) val = val & 0xffff0000; cpg_io_write(array->reg.addr, val); - /* - * This generic function needs to handle case where Montitor for clock - * is looking for a HIGH as clock active whereas Montitoring a reset - * it is looking for a LOW to indicate reset release. - */ mask = array->mon.val; cmp = mask; - if ((array->type == CPG_T_CLK) || (array->type == CPG_T_RST)) + if (array->type == CPG_T_CLK) cmp = ~cmp; while ((cpg_io_read(array->mon.addr) & mask) != (cmp & mask)) @@ -163,21 +153,25 @@ static void cpg_clkoff_rst(CPG_SETUP_DATA const *array, uint32_t num) void cpg_xspi_start(void) { DMSG("cpg_xspi_start is called."); - cpg_io_write(CPG_BUS_4_MSTOP, 0x00200000); - cpg_io_write(CPG_BUS_5_MSTOP, 0x00200000); + cpg_clkon_rst(&cpg_clk_on_tbl[0], ARRAY_SIZE(cpg_clk_on_tbl)); cpg_clkon_rst(&cpg_reset_tbl[0], ARRAY_SIZE(cpg_reset_tbl)); + + cpg_io_write(CPG_BUS_4_MSTOP, 0x00200000); + cpg_io_write(CPG_BUS_5_MSTOP, 0x00200000); } void cpg_xspi_stop(void) { DMSG("cpg_xspi_stop is called."); - cpg_io_write(CPG_BUS_4_MSTOP, 0x00200020); - cpg_io_write(CPG_BUS_5_MSTOP, 0x00200020); + cpg_clkoff_rst(&cpg_clk_on_tbl[0], ARRAY_SIZE(cpg_clk_on_tbl)); cpg_clkoff_rst(&cpg_reset_tbl[0], ARRAY_SIZE(cpg_reset_tbl)); + + cpg_io_write(CPG_BUS_4_MSTOP, 0x00200020); + cpg_io_write(CPG_BUS_5_MSTOP, 0x00200020); } static TEE_Result cpg_init(void) diff --git a/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg_regs.h b/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg_regs.h index 2d13f4a1f..76866b9be 100644 --- a/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg_regs.h +++ b/core/arch/arm/plat-rz/v2h/drivers/cpg/cpg_regs.h @@ -14,8 +14,8 @@ #define CPG_CLKMON_5 (0x0814) /* CGC Monitor Register xSPI */ -#define CPG_BUS_4_MSTOP (0x0D0C) /* MSTOP register 4 */ -#define CPG_BUS_5_MSTOP (0x0D10) /* MSTOP register 5 */ +#define CPG_BUS_4_MSTOP (0x0D0C) /* MSTOP register 4 */ +#define CPG_BUS_5_MSTOP (0x0D10) /* MSTOP register 5 */ #define CPG_RST_10 (0x0928) /* Reset Control Register xSPI */ #define CPG_RSTMON_4 (0x0A10) /* Reset Monitor Registers xSPI */ diff --git a/core/arch/arm/plat-rz/v2h/drivers/sce_lib/inc/instances/r_sce.h b/core/arch/arm/plat-rz/v2h/drivers/sce_lib/inc/instances/r_sce.h deleted file mode 100644 index e143df4be..000000000 --- a/core/arch/arm/plat-rz/v2h/drivers/sce_lib/inc/instances/r_sce.h +++ /dev/null @@ -1,424 +0,0 @@ -/********************************************************************************************************************** - * DISCLAIMER - * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No - * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all - * applicable laws, including copyright laws. - * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING - * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM - * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES - * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO - * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of - * this software. By using this software, you agree to the additional terms and conditions found by accessing the - * following link: - * http://www.renesas.com/disclaimer - * - * Copyright (C) 2022-2024 Renesas Electronics Corporation. All rights reserved. - *********************************************************************************************************************/ -/********************************************************************************************************************** - * File Name : r_sce.h - * Version : 1.0 - * Description : SCE API header file - *********************************************************************************************************************/ -/********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release - *********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * @addtogroup SCE_PROTECTED - * @{ - **********************************************************************************************************************/ - -#include -#include "r_sce_api.h" - -#ifndef R_SCE_H -#define R_SCE_H - - -/*********************************************************************************************************************** - * Macro definitions - **********************************************************************************************************************/ - -/* Various information. */ -#define HW_SCE_BASE (0x10440000) -#define HW_SCE_SIZE (0x10000) -#define HW_SCE_SRAM_WORD_SIZE (20U) -#define HW_SCE_SINST_WORD_SIZE (140U) -#define HW_SCE_SINST2_WORD_SIZE (16U) -#define HW_SCE_SHEAP_WORD_SIZE (1496U) -#define HW_SCE_MAC_SIZE (16U) - -/* ECC curve types. */ -#define SCE_ECC_CURVE_TYPE_NIST (0) -#define SCE_ECC_CURVE_TYPE_BRAINPOOL (1) -#define SCE_ECC_CURVE_TYPE_KOBLITZ (2) - -/* ECC curve size */ -#define SCE_ECC_KEY_LENGTH_256 (0) -#define SCE_ECC_KEY_LENGTH_224 (1) -#define SCE_ECC_KEY_LENGTH_192 (2) - -/*********************************************************************************************************************** - * Typedef definitions - **********************************************************************************************************************/ - -/* key index type */ -typedef enum -{ - SCE_KEY_INDEX_TYPE_INVALID = 0U, - SCE_KEY_INDEX_TYPE_AES128, - SCE_KEY_INDEX_TYPE_AES256, - SCE_KEY_INDEX_TYPE_TDES, - SCE_KEY_INDEX_TYPE_HMAC_SHA1, - SCE_KEY_INDEX_TYPE_HMAC_SHA256, - SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE, - SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE, - SCE_KEY_INDEX_TYPE_RSA3072_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA3072_PRIVATE, - SCE_KEY_INDEX_TYPE_RSA4096_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA4096_PRIVATE, - SCE_KEY_INDEX_TYPE_AES128_FOR_TLS, - SCE_KEY_INDEX_TYPE_AES192_FOR_TLS, - SCE_KEY_INDEX_TYPE_AES256_FOR_TLS, - SCE_KEY_INDEX_TYPE_HMAC_SHA1_FOR_TLS, - SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_TLS, - SCE_KEY_INDEX_TYPE_UPDATE_KEY_RING, - SCE_KEY_INDEX_TYPE_TLS_CA_CERTIFICATION_PUBLIC_KEY, - SCE_KEY_INDEX_TYPE_TLS_P256_ECC_KEY, - SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P384_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P384_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P256R1_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P384R1_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P256R1_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P384R1_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PRIVATE, - SCE_KEY_INDEX_TYPE_ECDH_SHARED_SECRET, - SCE_KEY_INDEX_TYPE_AES128_FOR_ECDH, - SCE_KEY_INDEX_TYPE_AES256_FOR_ECDH, - SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_ECDH, - SCE_KEY_INDEX_TYPE_AES128_GCM_FOR_DLMS_COSEM, - SCE_KEY_INDEX_TYPE_AES256_GCM_FOR_DLMS_COSEM, - SCE_KEY_INDEX_TYPE_AES128_KEY_WRAP_FOR_DLMS_COSEM, - SCE_KEY_INDEX_TYPE_AES128_GCM_WITH_IV, -} SCE_KEY_INDEX_TYPE; - -/* OEM Command */ -typedef enum e_sce_oem_cmd -{ - SCE_OEM_CMD_AES128 = 5, - SCE_OEM_CMD_AES256 = 7, - SCE_OEM_CMD_RSA1024_PUBLIC = 10, - SCE_OEM_CMD_RSA1024_PRIVATE, - SCE_OEM_CMD_RSA2048_PUBLIC, - SCE_OEM_CMD_RSA2048_PRIVATE, - SCE_OEM_CMD_RSA3072_PUBLIC, - SCE_OEM_CMD_RSA3072_PRIVATE, - SCE_OEM_CMD_RSA4096_PUBLIC, - SCE_OEM_CMD_RSA4096_PRIVATE, - SCE_OEM_CMD_ECC_P192_PUBLIC, - SCE_OEM_CMD_ECC_P192_PRIVATE, - SCE_OEM_CMD_ECC_P224_PUBLIC, - SCE_OEM_CMD_ECC_P224_PRIVATE, - SCE_OEM_CMD_ECC_P256_PUBLIC, - SCE_OEM_CMD_ECC_P256_PRIVATE, - SCE_OEM_CMD_ECC_P384_PUBLIC, - SCE_OEM_CMD_ECC_P384_PRIVATE, - SCE_OEM_CMD_ECC_P512_PUBLIC, - SCE_OEM_CMD_ECC_P512_PRIVATE, - SCE_OEM_CMD_HMAC_SHA256 = 28, - SCE_OEM_CMD_NUM -} sce_oem_cmd_t; - -/** SCE private control block. DO NOT MODIFY. Initialization occurs when R_SCE_Open() is called. */ -typedef struct st_sce_instance_ctrl -{ - uint32_t open; // Indicates whether the open() API has been successfully -} sce_instance_ctrl_t; - -/********************************************************************************************************************** - * Exported global variables - **********************************************************************************************************************/ -/********************************************************************************************************************** - External global variables - *********************************************************************************************************************/ -/* memory area for SCE procedure */ -extern volatile uint32_t * gp_sce; - -/** @cond INC_HEADER_DEFS_SEC */ -/** Filled in Interface API structure for this Instance. */ -extern const sce_api_t g_sce_protected_on_sce; - -/** @endcond */ - -/********************************************************************************************************************** - * Public Function Prototypes - **********************************************************************************************************************/ -fsp_err_t R_SCE_Open(sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg); -fsp_err_t R_SCE_Close(sce_ctrl_t * const p_ctrl); -fsp_err_t R_SCE_SoftwareReset(void); - -fsp_err_t R_SCE_AES128_WrappedKeyGenerate(sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES256_WrappedKeyGenerate(sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSA1024_WrappedKeyPairGenerate(sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key); -fsp_err_t R_SCE_RSA2048_WrappedKeyPairGenerate(sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key); -fsp_err_t R_SCE_ECC_secp192r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); -fsp_err_t R_SCE_ECC_secp224r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); -fsp_err_t R_SCE_ECC_secp256r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); -fsp_err_t R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); -fsp_err_t R_SCE_RandomNumberGenerate(uint32_t * random); - -fsp_err_t R_SCE_AES128_EncryptedKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES256_EncryptedKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_aes_wrapped_key_t * wrapped_key); - -fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa4096_public_wrapped_key_t * wrapped_key); - -fsp_err_t R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - -fsp_err_t R_SCE_AES128ECB_EncryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES128ECB_EncryptUpdate(sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length); -fsp_err_t R_SCE_AES128ECB_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); -fsp_err_t R_SCE_AES128ECB_DecryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES128ECB_DecryptUpdate(sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length); -fsp_err_t R_SCE_AES128ECB_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); -fsp_err_t R_SCE_AES256ECB_EncryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES256ECB_EncryptUpdate(sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length); -fsp_err_t R_SCE_AES256ECB_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); -fsp_err_t R_SCE_AES256ECB_DecryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES256ECB_DecryptUpdate(sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length); -fsp_err_t R_SCE_AES256ECB_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - -fsp_err_t R_SCE_AES128CBC_EncryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES128CBC_EncryptUpdate(sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length); -fsp_err_t R_SCE_AES128CBC_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); -fsp_err_t R_SCE_AES128CBC_DecryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES128CBC_DecryptUpdate(sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length); -fsp_err_t R_SCE_AES128CBC_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); -fsp_err_t R_SCE_AES256CBC_EncryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES256CBC_EncryptUpdate(sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length); -fsp_err_t R_SCE_AES256CBC_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); -fsp_err_t R_SCE_AES256CBC_DecryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES256CBC_DecryptUpdate(sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length); -fsp_err_t R_SCE_AES256CBC_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - -fsp_err_t R_SCE_AES128CTR_EncryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES128CTR_EncryptUpdate(sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length); -fsp_err_t R_SCE_AES128CTR_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); -fsp_err_t R_SCE_AES128CTR_DecryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES128CTR_DecryptUpdate(sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length); -fsp_err_t R_SCE_AES128CTR_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); -fsp_err_t R_SCE_AES256CTR_EncryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES256CTR_EncryptUpdate(sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length); -fsp_err_t R_SCE_AES256CTR_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); -fsp_err_t R_SCE_AES256CTR_DecryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES256CTR_DecryptUpdate(sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length); -fsp_err_t R_SCE_AES256CTR_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - -fsp_err_t R_SCE_AES128CMAC_GenerateInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES128CMAC_GenerateUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); -fsp_err_t R_SCE_AES128CMAC_GenerateFinal(sce_cmac_handle_t * handle, uint8_t * mac); -fsp_err_t R_SCE_AES128CMAC_VerifyInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES128CMAC_VerifyUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); -fsp_err_t R_SCE_AES128CMAC_VerifyFinal(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); -fsp_err_t R_SCE_AES256CMAC_GenerateInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES256CMAC_GenerateUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); -fsp_err_t R_SCE_AES256CMAC_GenerateFinal(sce_cmac_handle_t * handle, uint8_t * mac); -fsp_err_t R_SCE_AES256CMAC_VerifyInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES256CMAC_VerifyUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); -fsp_err_t R_SCE_AES256CMAC_VerifyFinal(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); - -fsp_err_t R_SCE_SHA224_Init(sce_sha_md5_handle_t * handle); -fsp_err_t R_SCE_SHA224_Update(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); -fsp_err_t R_SCE_SHA224_Final(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); -fsp_err_t R_SCE_SHA256_Init(sce_sha_md5_handle_t * handle); -fsp_err_t R_SCE_SHA256_Update(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); -fsp_err_t R_SCE_SHA256_Final(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); - -fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate(sce_rsa_byte_data_t * message_hash, - sce_rsa_byte_data_t * signature, - sce_rsa1024_private_wrapped_key_t * wrapped_key, - uint8_t hash_type); -fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureVerify(sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, - sce_rsa1024_public_wrapped_key_t * wrapped_key, - uint8_t hash_type); -fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate(sce_rsa_byte_data_t * message_hash, - sce_rsa_byte_data_t * signature, - sce_rsa2048_private_wrapped_key_t * wrapped_key, - uint8_t hash_type); -fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify(sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, - sce_rsa2048_public_wrapped_key_t * wrapped_key, - uint8_t hash_type); -fsp_err_t R_SCE_RSASSA_PKCS4096_SignatureVerify(sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, - sce_rsa4096_public_wrapped_key_t * wrapped_key, - uint8_t hash_type); - -fsp_err_t R_SCE_RSAES_PKCS1024_Encrypt(sce_rsa_byte_data_t * plain, - sce_rsa_byte_data_t * cipher, - sce_rsa1024_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt(sce_rsa_byte_data_t * cipher, - sce_rsa_byte_data_t * plain, - sce_rsa1024_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSAES_PKCS2048_Encrypt(sce_rsa_byte_data_t * plain, - sce_rsa_byte_data_t * cipher, - sce_rsa2048_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSAES_PKCS2048_Decrypt(sce_rsa_byte_data_t * cipher, - sce_rsa_byte_data_t * plain, - sce_rsa2048_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt(sce_rsa_byte_data_t * plain, - sce_rsa_byte_data_t * cipher, - sce_rsa4096_public_wrapped_key_t * wrapped_key); - -fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - -#endif /* R_SCE_H */ - -/*******************************************************************************************************************//** - * @} (end addtogroup SCE_PROTECTED) - **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/v2h/drivers/sce_lib/sub.mk b/core/arch/arm/plat-rz/v2h/drivers/sce_lib/sub.mk deleted file mode 100644 index 82da2488a..000000000 --- a/core/arch/arm/plat-rz/v2h/drivers/sce_lib/sub.mk +++ /dev/null @@ -1,4 +0,0 @@ - -global-incdirs-y += inc/instances - -ldflags-external += $(CFG_RZ_SCE_LIB_DIR)/libr_secure_ip_2_0.a.1.0.0 diff --git a/core/arch/arm/plat-rz/v2h/drivers/sub.mk b/core/arch/arm/plat-rz/v2h/drivers/sub.mk index 2680d487b..a27ce598b 100644 --- a/core/arch/arm/plat-rz/v2h/drivers/sub.mk +++ b/core/arch/arm/plat-rz/v2h/drivers/sub.mk @@ -2,6 +2,4 @@ global-incdirs-y += . srcs-y += sflash.c -subdirs-$(CFG_RZ_SCE) += sce_lib - subdirs-y += cpg \ No newline at end of file diff --git a/core/arch/arm/plat-rz/v2h/main.c b/core/arch/arm/plat-rz/v2h/main.c index 74cfba29b..10376e776 100644 --- a/core/arch/arm/plat-rz/v2h/main.c +++ b/core/arch/arm/plat-rz/v2h/main.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause /* * Copyright (c) 2016, GlobalLogic - * Copyright (c) 2021-2024, Renesas Electronics + * Copyright (c) 2021, Renesas Electronics */ #include diff --git a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce.h b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce.h deleted file mode 100644 index 7d2f2364e..000000000 --- a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce.h +++ /dev/null @@ -1,179 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ -#ifndef __PTA_SCE_H -#define __PTA_SCE_H - -#include - -#define PTA_SCE_UUID \ - { 0x3b221d77, 0xe679, 0x4ca5, \ - { 0xa4, 0x48, 0x1f, 0x9f, 0x16, 0x02, 0x15, 0xc5 } } - -/* - * [in/out] memref[0] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES128_WrappedKeyGenerate (0x00010000) - -/* - * [in/out] memref[0] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES256_WrappedKeyGenerate (0x00010100) - -/* - * [in/out] memref[0] : Wrapped key (sce_rsa1024_wrapped_pair_key_t) - */ -#define PTA_CMD_RSA1024_WrappedKeyPairGenerate (0x00011000) - -/* - * [in/out] memref[0] : Wrapped key (sce_rsa2048_wrapped_pair_key_t) - */ -#define PTA_CMD_RSA2048_WrappedKeyPairGenerate (0x00011100) - -/* - * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) - */ -#define PTA_CMD_ECC_secp192r1_WrappedKeyPairGenerate (0x00012000) - -/* - * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) - */ -#define PTA_CMD_ECC_secp224r1_WrappedKeyPairGenerate (0x00012100) - -/* - * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) - */ -#define PTA_CMD_ECC_secp256r1_WrappedKeyPairGenerate (0x00012200) - -/* - * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) - */ -#define PTA_CMD_ECC_BrainpoolP512r1_WrappedKeyPairGenerate (0x00013000) - -/* - * [in/out] memref[0] : random data (16byte) - */ -#define PTA_CMD_RandomNumberGenerate (0x00014000) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (32byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES128_EncryptedKeyWrap (0x00015000) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (64byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES256_EncryptedKeyWrap (0x00015100) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (160byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_rsa1024_public_wrapped_key_t) - */ -#define PTA_CMD_RSA1024_EncryptedPublicKeyWrap (0x00016000) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (272byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_rsa1024_private_wrapped_key_t) - */ -#define PTA_CMD_RSA1024_EncryptedPrivateKeyWrap (0x00016010) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (288byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_rsa2048_public_wrapped_key_t) - */ -#define PTA_CMD_RSA2048_EncryptedPublicKeyWrap (0x00016100) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (528byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_rsa2048_private_wrapped_key_t) - */ -#define PTA_CMD_RSA2048_EncryptedPrivateKeyWrap (0x00016110) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (544byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_rsa4096_public_wrapped_key_t) - */ -#define PTA_CMD_RSA4096_EncryptedPublicKeyWrap (0x00016200) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (80byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) - */ -#define PTA_CMD_ECC_secp192r1_EncryptedPublicKeyWrap (0x00017000) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (48byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) - */ -#define PTA_CMD_ECC_secp192r1_EncryptedPrivateKeyWrap (0x00017010) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (80byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) - */ -#define PTA_CMD_ECC_secp224r1_EncryptedPublicKeyWrap (0x00017100) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (48byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) - */ -#define PTA_CMD_ECC_secp224r1_EncryptedPrivateKeyWrap (0x00017110) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (80byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) - */ -#define PTA_CMD_ECC_secp256r1_EncryptedPublicKeyWrap (0x00017200) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (48byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) - */ -#define PTA_CMD_ECC_secp256r1_EncryptedPrivateKeyWrap (0x00017210) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (144byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) - */ -#define PTA_CMD_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap (0x00018000) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (80byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) - */ -#define PTA_CMD_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap (0x00018010) - -#endif /* __PTA_SCE_H */ diff --git a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_aes.h b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_aes.h deleted file mode 100644 index 101b869f2..000000000 --- a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_aes.h +++ /dev/null @@ -1,279 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ -#ifndef __PTA_SCE_AES_H -#define __PTA_SCE_AES_H - -#include - -#define PTA_SCE_AES_UUID \ - { 0x4be7b9c4, 0x4951, 0x4105, \ - { 0xa3, 0xd3, 0x08, 0x1b, 0x50, 0x98, 0x10, 0xef } } - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES128ECB_EncryptInit (0x00020001) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : plain (length must be a multiple of 16) - * [in/out] memref[2] : cipher - */ -#define PTA_CMD_AES128ECB_EncryptUpdate (0x00020002) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES128ECB_EncryptFinal (0x00020003) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES128ECB_DecryptInit (0x00020011) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : cipher (length must be a multiple of 16) - * [in/out] memref[2] : plain - */ -#define PTA_CMD_AES128ECB_DecryptUpdate (0x00020012) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES128ECB_DecryptFinal (0x00020013) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES256ECB_EncryptInit (0x00020101) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : plain (length must be a multiple of 16) - * [in/out] memref[2] : cipher - */ -#define PTA_CMD_AES256ECB_EncryptUpdate (0x00020102) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES256ECB_EncryptFinal (0x00020103) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES256ECB_DecryptInit (0x00020111) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : cipher (length must be a multiple of 16) - * [in/out] memref[2] : plain - */ -#define PTA_CMD_AES256ECB_DecryptUpdate (0x00020112) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES256ECB_DecryptFinal (0x00020113) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES128CBC_EncryptInit (0x00021001) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : plain (length must be a multiple of 16) - * [in/out] memref[2] : cipher - */ -#define PTA_CMD_AES128CBC_EncryptUpdate (0x00021002) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES128CBC_EncryptFinal (0x00021003) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES128CBC_DecryptInit (0x00021011) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : cipher (length must be a multiple of 16) - * [in/out] memref[2] : plain - */ -#define PTA_CMD_AES128CBC_DecryptUpdate (0x00021012) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES128CBC_DecryptFinal (0x00021013) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES256CBC_EncryptInit (0x00021101) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : plain (length must be a multiple of 16) - * [in/out] memref[2] : cipher - */ -#define PTA_CMD_AES256CBC_EncryptUpdate (0x00021102) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES256CBC_EncryptFinal (0x00021103) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES256CBC_DecryptInit (0x00021111) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : cipher (length must be a multiple of 16) - * [in/out] memref[2] : plain - */ -#define PTA_CMD_AES256CBC_DecryptUpdate (0x00021112) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES256CBC_DecryptFinal (0x00021113) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES128CTR_EncryptInit (0x00022001) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : plain (length must be a multiple of 16) - * [in/out] memref[2] : cipher - */ -#define PTA_CMD_AES128CTR_EncryptUpdate (0x00022002) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES128CTR_EncryptFinal (0x00022003) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES128CTR_DecryptInit (0x00022011) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : cipher (length must be a multiple of 16) - * [in/out] memref[2] : plain - */ -#define PTA_CMD_AES128CTR_DecryptUpdate (0x00022012) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES128CTR_DecryptFinal (0x00022013) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES256CTR_EncryptInit (0x00022101) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : plain (length must be a multiple of 16) - * [in/out] memref[2] : cipher - */ -#define PTA_CMD_AES256CTR_EncryptUpdate (0x00022102) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES256CTR_EncryptFinal (0x00022103) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES256CTR_DecryptInit (0x00022111) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : cipher (length must be a multiple of 16) - * [in/out] memref[2] : plain - */ -#define PTA_CMD_AES256CTR_DecryptUpdate (0x00022112) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES256CTR_DecryptFinal (0x00022113) - -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES128CMAC_GenerateInit (0x00023001) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : message - */ -#define PTA_CMD_AES128CMAC_GenerateUpdate (0x00023002) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in/out] memref[1] : mac (16byte) - */ -#define PTA_CMD_AES128CMAC_GenerateFinal (0x00023003) - -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES128CMAC_VerifyInit (0x00023011) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : message - */ -#define PTA_CMD_AES128CMAC_VerifyUpdate (0x00023012) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : mac (2 to 16bytes) - */ -#define PTA_CMD_AES128CMAC_VerifyFinal (0x00023013) - -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES256CMAC_GenerateInit (0x00023101) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : message - */ -#define PTA_CMD_AES256CMAC_GenerateUpdate (0x00023102) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in/out] memref[1] : mac (16byte) - */ -#define PTA_CMD_AES256CMAC_GenerateFinal (0x00023103) - -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES256CMAC_VerifyInit (0x00023111) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : message - */ -#define PTA_CMD_AES256CMAC_VerifyUpdate (0x00023112) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : mac (2 to 16bytes) - */ -#define PTA_CMD_AES256CMAC_VerifyFinal (0x00023113) - - -#endif /* __PTA_SCE_AES_H */ diff --git a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_ecc.h b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_ecc.h deleted file mode 100644 index 6845d0df9..000000000 --- a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_ecc.h +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ -#ifndef __PTA_SCE_ECC_H -#define __PTA_SCE_ECC_H - -#include - -#define PTA_SCE_ECC_UUID \ - { 0xa0c74f91, 0xbaac, 0x4ba3, \ - { 0x96, 0xbe, 0x58, 0xe5, 0x1f, 0xb1, 0xd1, 0xba } } - -/* - * [in] memref[0] : Message - * [in/out] memref[1] : Signature (64byte) - * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) - */ -#define PTA_CMD_ECDSA_secp192r1_SignatureGenerate (0x00050000) - -/* - * [in] memref[0] : Signature (64byte) - * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) - */ -#define PTA_CMD_ECDSA_secp192r1_SignatureVerify (0x00050010) - -/* - * [in] memref[0] : Message - * [in/out] memref[1] : Signature (64byte) - * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) - */ -#define PTA_CMD_ECDSA_secp224r1_SignatureGenerate (0x00050100) - -/* - * [in] memref[0] : Signature (64byte) - * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) - */ -#define PTA_CMD_ECDSA_secp224r1_SignatureVerify (0x00050110) - -/* - * [in] memref[0] : Message - * [in/out] memref[1] : Signature (64byte) - * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) - */ -#define PTA_CMD_ECDSA_secp256r1_SignatureGenerate (0x00050200) - -/* - * [in] memref[0] : Signature (64byte) - * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) - */ -#define PTA_CMD_ECDSA_secp256r1_SignatureVerify (0x00050210) - -/* - * [in] memref[0] : Message - * [in/out] memref[1] : Signature (64byte) - * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) - */ -#define PTA_CMD_ECDSA_BrainpoolP512r1_SignatureGenerate (0x00051000) - -/* - * [in] memref[0] : Signature (64byte) - * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) - */ -#define PTA_CMD_ECDSA_BrainpoolP512r1_SignatureVerify (0x00051010) - -#endif /* __PTA_SCE_ECC_H */ diff --git a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_rsa.h b/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_rsa.h deleted file mode 100644 index 3be51d0d4..000000000 --- a/core/arch/arm/plat-rz/v2h/pta/include/pta_sce_rsa.h +++ /dev/null @@ -1,84 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ -#ifndef __PTA_SCE_RSA_H -#define __PTA_SCE_RSA_H - -#include - -#define PTA_SCE_RSA_UUID \ - { 0x5ad57120, 0xc447, 0x4b17, \ - { 0x90, 0x7b, 0x03, 0x1a, 0xd8, 0xd9, 0xb1, 0x7c } } - -/* - * [in] memref[0] : Message - * [in/out] memref[1] : Signature (128byte) - * [in] memref[2] : Wrapped key (sce_rsa1024_private_wrapped_key_t) - */ -#define PTA_CMD_RSASSA_PKCS1024_SignatureGenerate (0x00040000) - -/* - * [in] memref[0] : Signature (128byte) - * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_rsa1024_public_wrapped_key_t) - */ -#define PTA_CMD_RSASSA_PKCS1024_SignatureVerify (0x00040010) - -/* - * [in] memref[0] : Message - * [in/out] memref[1] : Signature (256byte) - * [in] memref[2] : Wrapped key (sce_rsa2048_private_wrapped_key_t) - */ -#define PTA_CMD_RSASSA_PKCS2048_SignatureGenerate (0x00040100) - -/* - * [in] memref[0] : Signature (256byte) - * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_rsa2048_public_wrapped_key_t) - */ -#define PTA_CMD_RSASSA_PKCS2048_SignatureVerify (0x00040110) - -/* - * [in] memref[0] : Signature (512byte) - * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_rsa4096_public_wrapped_key_t) - */ -#define PTA_CMD_RSASSA_PKCS4096_SignatureVerify (0x00040210) - -/* - * [in] memref[0] : plain (size <= public key n size - 11 byte) - * [in/out] memref[1] : cipher (size >= public key n byte) - * [in] memref[2] : Wrapped key (sce_rsa1024_public_wrapped_key_t) - */ -#define PTA_CMD_RSAES_PKCS1024_Encrypt (0x00041000) - -/* - * [in] memref[0] : cipher (size == public key n byte) - * [in/out] memref[1] : plain (size >= public key n - 11 byte) - * [in] memref[2] : Wrapped key (sce_rsa1024_private_wrapped_key_t) - */ -#define PTA_CMD_RSAES_PKCS1024_Decrypt (0x00041010) - -/* - * [in] memref[0] : plain (size <= public key n - 11 byte) - * [in/out] memref[1] : cipher (size >= public key n byte) - * [in] memref[2] : Wrapped key (sce_rsa2048_public_wrapped_key_t) - */ -#define PTA_CMD_RSAES_PKCS2048_Encrypt (0x00041100) - -/* - * [in] memref[0] : cipher (size == public key n byte) - * [in/out] memref[1] : plain (size >= public key n - 11 byte) - * [in] memref[2] : Wrapped key (sce_rsa2048_private_wrapped_key_t) - */ -#define PTA_CMD_RSAES_PKCS2048_Decrypt (0x00041110) - -/* - * [in] memref[0] : plain (size <= public key n - 11 byte) - * [in/out] memref[1] : cipher (size >= public key n byte) - * [in] memref[2] : Wrapped key (sce_rsa4096_public_wrapped_key_t) - */ -#define PTA_CMD_RSAES_PKCS4096_Encrypt (0x00041200) - -#endif /* __PTA_SCE_RSA_H */ diff --git a/core/arch/arm/plat-rz/v2h/pta/pta_sce.c b/core/arch/arm/plat-rz/v2h/pta/pta_sce.c deleted file mode 100644 index 88606bfe0..000000000 --- a/core/arch/arm/plat-rz/v2h/pta/pta_sce.c +++ /dev/null @@ -1,1170 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ - -#include - -#include -#include - -#define PTA_NAME "sce.pta" - -static TEE_Result aes128_wrappedkeygenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128_WrappedKeyGenerate(wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ - return TEE_ERROR_ACCESS_CONFLICT; - } - - params[0].memref.size = sizeof(sce_aes_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256_wrappedkeygenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256_WrappedKeyGenerate(wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ - return TEE_ERROR_ACCESS_CONFLICT; - } - - params[0].memref.size = sizeof(sce_aes_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa1024_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_pair_key = (sce_rsa1024_wrapped_pair_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_pair_key) || (sizeof(sce_rsa1024_wrapped_pair_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA1024_WrappedKeyPairGenerate(wrapped_pair_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_rsa1024_wrapped_pair_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa2048_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_pair_key = (sce_rsa2048_wrapped_pair_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_pair_key) || (sizeof(sce_rsa2048_wrapped_pair_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA2048_WrappedKeyPairGenerate(wrapped_pair_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_rsa2048_wrapped_pair_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp192r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecc_wrapped_pair_key_t * wrapped_pair_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp192r1_WrappedKeyPairGenerate(wrapped_pair_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp224r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecc_wrapped_pair_key_t * wrapped_pair_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp224r1_WrappedKeyPairGenerate(wrapped_pair_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp256r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecc_wrapped_pair_key_t * wrapped_pair_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp256r1_WrappedKeyPairGenerate(wrapped_pair_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_brainpoolp512r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecc_wrapped_pair_key_t * wrapped_pair_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_BrainpoolP512r1_WrappedKeyPairGenerate(wrapped_pair_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result randomnumbergenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint32_t * random; - - const uint32_t random_length = 16; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - random = (uint32_t *)params[0].memref.buffer; - if ((NULL == random) || (random_length > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.randomNumberGenerate(random); - switch (err) - { - case FSP_SUCCESS: - break; - default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ - return TEE_ERROR_ACCESS_CONFLICT; - } - - params[0].memref.size = random_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128_encryptedkeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || ((SCE_OEM_KEY_SIZE_AES128_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128_EncryptedKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_aes_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256_encryptedkeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || ((SCE_OEM_KEY_SIZE_AES256_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256_EncryptedKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_aes_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa1024_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_rsa1024_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_RSA1024_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa1024_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA1024_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_rsa1024_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa1024_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_rsa1024_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_RSA1024_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa1024_private_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_private_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA1024_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_rsa1024_private_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa2048_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_rsa2048_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_RSA2048_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa2048_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA2048_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_rsa2048_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa2048_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_rsa2048_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_RSA2048_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa2048_private_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_private_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA2048_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_rsa2048_private_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa4096_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_rsa4096_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_RSA4096_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa4096_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa4096_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA4096_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_rsa4096_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp192r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP192_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp192r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp192r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP192_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp192r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp224r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP224_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp224r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp224r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP224_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp224r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp256r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP256_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp256r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp256r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP256_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp256r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_brainpoolp512r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP512_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_BrainpoolP512r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_brainpoolp512r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP512_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result invoke_command(void *session __unused, uint32_t cmd, - uint32_t ptypes, - TEE_Param params[TEE_NUM_PARAMS]) -{ - DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); - - switch (cmd) { - case PTA_CMD_AES128_WrappedKeyGenerate : - return aes128_wrappedkeygenerate(ptypes, params); - case PTA_CMD_AES256_WrappedKeyGenerate : - return aes256_wrappedkeygenerate(ptypes, params); - case PTA_CMD_RSA1024_WrappedKeyPairGenerate : - return rsa1024_wrappedkeypairgenerate(ptypes, params); - case PTA_CMD_RSA2048_WrappedKeyPairGenerate : - return rsa2048_wrappedkeypairgenerate(ptypes, params); - case PTA_CMD_ECC_secp192r1_WrappedKeyPairGenerate : - return ecc_secp192r1_wrappedkeypairgenerate(ptypes, params); - case PTA_CMD_ECC_secp224r1_WrappedKeyPairGenerate : - return ecc_secp224r1_wrappedkeypairgenerate(ptypes, params); - case PTA_CMD_ECC_secp256r1_WrappedKeyPairGenerate : - return ecc_secp256r1_wrappedkeypairgenerate(ptypes, params); - case PTA_CMD_ECC_BrainpoolP512r1_WrappedKeyPairGenerate : - return ecc_brainpoolp512r1_wrappedkeypairgenerate(ptypes, params); - case PTA_CMD_RandomNumberGenerate : - return randomnumbergenerate(ptypes, params); - case PTA_CMD_AES128_EncryptedKeyWrap : - return aes128_encryptedkeywrap(ptypes, params); - case PTA_CMD_AES256_EncryptedKeyWrap : - return aes256_encryptedkeywrap(ptypes, params); - case PTA_CMD_RSA1024_EncryptedPublicKeyWrap : - return rsa1024_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_RSA1024_EncryptedPrivateKeyWrap : - return rsa1024_encryptedprivatekeywrap(ptypes, params); - case PTA_CMD_RSA2048_EncryptedPublicKeyWrap : - return rsa2048_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_RSA2048_EncryptedPrivateKeyWrap : - return rsa2048_encryptedprivatekeywrap(ptypes, params); - case PTA_CMD_RSA4096_EncryptedPublicKeyWrap : - return rsa4096_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_ECC_secp192r1_EncryptedPublicKeyWrap : - return ecc_secp192r1_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_ECC_secp224r1_EncryptedPublicKeyWrap : - return ecc_secp224r1_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_ECC_secp256r1_EncryptedPublicKeyWrap : - return ecc_secp256r1_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap : - return ecc_brainpoolp512r1_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_ECC_secp192r1_EncryptedPrivateKeyWrap : - return ecc_secp192r1_encryptedprivatekeywrap(ptypes, params); - case PTA_CMD_ECC_secp224r1_EncryptedPrivateKeyWrap : - return ecc_secp224r1_encryptedprivatekeywrap(ptypes, params); - case PTA_CMD_ECC_secp256r1_EncryptedPrivateKeyWrap : - return ecc_secp256r1_encryptedprivatekeywrap(ptypes, params); - case PTA_CMD_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap : - return ecc_brainpoolp512r1_encryptedprivatekeywrap(ptypes, params); - default: - return TEE_ERROR_NOT_SUPPORTED; - } -} - -pseudo_ta_register(.uuid = PTA_SCE_UUID, .name = PTA_NAME, - .flags = PTA_DEFAULT_FLAGS, - .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/v2h/pta/pta_sce_aes.c b/core/arch/arm/plat-rz/v2h/pta/pta_sce_aes.c deleted file mode 100644 index 7a53c976a..000000000 --- a/core/arch/arm/plat-rz/v2h/pta/pta_sce_aes.c +++ /dev/null @@ -1,2257 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ - -#include - -#include -#include - -#define PTA_NAME "sce_aes.pta" - -static TEE_Result aes128ecb_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128ECB_EncryptInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128ecb_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint8_t * cipher; - uint32_t plain_length; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[1].memref.buffer; - plain_length = (uint32_t)params[1].memref.size; - if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[2].memref.buffer; - cipher_length = (uint32_t)params[2].memref.size; - if ((NULL == cipher) || (cipher_length < plain_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128ECB_EncryptUpdate(handle, plain, cipher, plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = plain_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128ecb_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = NULL; // nothing ever written here - cipher_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES128ECB_EncryptFinal(handle, cipher, &cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128ecb_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128ECB_DecryptInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128ecb_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint8_t * plain; - uint32_t cipher_length; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[1].memref.buffer; - cipher_length = (uint32_t)params[1].memref.size; - if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[2].memref.buffer; - plain_length = (uint32_t)params[2].memref.size; - if ((NULL == plain) || (plain_length < cipher_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128ECB_DecryptUpdate(handle, cipher, plain, cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = cipher_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128ecb_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = NULL; // nothing ever written here - plain_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES128ECB_DecryptFinal(handle, plain, &plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256ecb_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256ECB_EncryptInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256ecb_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint8_t * cipher; - uint32_t plain_length; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[1].memref.buffer; - plain_length = (uint32_t)params[1].memref.size; - if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[2].memref.buffer; - cipher_length = (uint32_t)params[2].memref.size; - if ((NULL == cipher) || (cipher_length < plain_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256ECB_EncryptUpdate(handle, plain, cipher, plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = plain_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes256ecb_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = NULL; // nothing ever written here - cipher_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES256ECB_EncryptFinal(handle, cipher, &cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256ecb_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256ECB_DecryptInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256ecb_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint8_t * plain; - uint32_t cipher_length; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[1].memref.buffer; - cipher_length = (uint32_t)params[1].memref.size; - if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[2].memref.buffer; - plain_length = (uint32_t)params[2].memref.size; - if ((NULL == plain) || (plain_length < cipher_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256ECB_DecryptUpdate(handle, cipher, plain, cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = cipher_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes256ecb_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = NULL; // nothing ever written here - plain_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES256ECB_DecryptFinal(handle, plain, &plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128cbc_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CBC_EncryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128cbc_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint8_t * cipher; - uint32_t plain_length; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[1].memref.buffer; - plain_length = (uint32_t)params[1].memref.size; - if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[2].memref.buffer; - cipher_length = (uint32_t)params[2].memref.size; - if ((NULL == cipher) || (cipher_length < plain_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CBC_EncryptUpdate(handle, plain, cipher, plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = plain_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128cbc_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = NULL; // nothing ever written here - cipher_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES128CBC_EncryptFinal(handle, cipher, &cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128cbc_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CBC_DecryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128cbc_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint8_t * plain; - uint32_t cipher_length; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[1].memref.buffer; - cipher_length = (uint32_t)params[1].memref.size; - if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[2].memref.buffer; - plain_length = (uint32_t)params[2].memref.size; - if ((NULL == plain) || (plain_length < cipher_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CBC_DecryptUpdate(handle, cipher, plain, cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = cipher_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128cbc_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = NULL; // nothing ever written here - plain_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES128CBC_DecryptFinal(handle, plain, &plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256cbc_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CBC_EncryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256cbc_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint8_t * cipher; - uint32_t plain_length; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[1].memref.buffer; - plain_length = (uint32_t)params[1].memref.size; - if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[2].memref.buffer; - cipher_length = (uint32_t)params[2].memref.size; - if ((NULL == cipher) || (cipher_length < plain_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CBC_EncryptUpdate(handle, plain, cipher, plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = plain_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes256cbc_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = NULL; // nothing ever written here - cipher_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES256CBC_EncryptFinal(handle, cipher, &cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256cbc_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CBC_DecryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256cbc_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint8_t * plain; - uint32_t cipher_length; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[1].memref.buffer; - cipher_length = (uint32_t)params[1].memref.size; - if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[2].memref.buffer; - plain_length = (uint32_t)params[2].memref.size; - if ((NULL == plain) || (plain_length < cipher_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CBC_DecryptUpdate(handle, cipher, plain, cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = cipher_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes256cbc_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = NULL; // nothing ever written here - plain_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES256CBC_DecryptFinal(handle, plain, &plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128ctr_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CTR_EncryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128ctr_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint8_t * cipher; - uint32_t plain_length; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[1].memref.buffer; - plain_length = (uint32_t)params[1].memref.size; - if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[2].memref.buffer; - cipher_length = (uint32_t)params[2].memref.size; - if ((NULL == cipher) || (cipher_length < plain_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CTR_EncryptUpdate(handle, plain, cipher, plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = plain_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128ctr_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = NULL; // nothing ever written here - cipher_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES128CTR_EncryptFinal(handle, cipher, &cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128ctr_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CTR_DecryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128ctr_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint8_t * plain; - uint32_t cipher_length; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[1].memref.buffer; - cipher_length = (uint32_t)params[1].memref.size; - if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[2].memref.buffer; - plain_length = (uint32_t)params[2].memref.size; - if ((NULL == plain) || (plain_length < cipher_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CTR_DecryptUpdate(handle, cipher, plain, cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = cipher_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128ctr_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = NULL; // nothing ever written here - plain_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES128CTR_DecryptFinal(handle, plain, &plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256ctr_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CTR_EncryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256ctr_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint8_t * cipher; - uint32_t plain_length; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[1].memref.buffer; - plain_length = (uint32_t)params[1].memref.size; - if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[2].memref.buffer; - cipher_length = (uint32_t)params[2].memref.size; - if ((NULL == cipher) || (cipher_length < plain_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CTR_EncryptUpdate(handle, plain, cipher, plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = plain_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes256ctr_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = NULL; // nothing ever written here - cipher_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES256CTR_EncryptFinal(handle, cipher, &cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256ctr_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CTR_DecryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256ctr_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint8_t * plain; - uint32_t cipher_length; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[1].memref.buffer; - cipher_length = (uint32_t)params[1].memref.size; - if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[2].memref.buffer; - plain_length = (uint32_t)params[2].memref.size; - if ((NULL == plain) || (plain_length < cipher_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CTR_DecryptUpdate(handle, cipher, plain, cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = cipher_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes256ctr_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = NULL; // nothing ever written here - plain_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES256CTR_DecryptFinal(handle, plain, &plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128cmac_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CMAC_GenerateInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_cmac_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128cmac_generateupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * message; - uint32_t message_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message = (uint8_t *)params[1].memref.buffer; - message_length = (uint32_t)params[1].memref.size; - if (NULL == message) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CMAC_GenerateUpdate(handle, message, message_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128cmac_generatefinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * mac; - uint32_t mac_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - mac = (uint8_t *)params[1].memref.buffer; - mac_length = params[1].memref.size; - if ((NULL == mac) || (HW_SCE_AES_BLOCK_BYTE_SIZE > mac_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CMAC_GenerateFinal(handle, mac); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION: - return TEE_ERROR_BAD_STATE; - default: /* FSP_ERR_CRYPTO_SCE_AUTHENTICATION */ - return TEE_ERROR_MAC_INVALID; - } - - params[1].memref.size = HW_SCE_AES_BLOCK_BYTE_SIZE; - - return TEE_SUCCESS; -} - -static TEE_Result aes128cmac_verifyinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CMAC_VerifyInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_cmac_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128cmac_verifyupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * message; - uint32_t message_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message = (uint8_t *)params[1].memref.buffer; - message_length = (uint32_t)params[1].memref.size; - if (NULL == message) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CMAC_VerifyUpdate(handle, message, message_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128cmac_verifyfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * mac; - uint32_t mac_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - mac = (uint8_t *)params[1].memref.buffer; - mac_length = params[1].memref.size; - if ((NULL == mac) || (2 > mac_length) || (HW_SCE_AES_BLOCK_BYTE_SIZE < mac_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CMAC_VerifyFinal(handle, mac, mac_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: - return TEE_ERROR_MAC_INVALID; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256cmac_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CMAC_GenerateInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_cmac_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256cmac_generateupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * message; - uint32_t message_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message = (uint8_t *)params[1].memref.buffer; - message_length = (uint32_t)params[1].memref.size; - if (NULL == message) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CMAC_GenerateUpdate(handle, message, message_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256cmac_generatefinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * mac; - uint32_t mac_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - mac = (uint8_t *)params[1].memref.buffer; - mac_length = params[1].memref.size; - if ((NULL == mac) || (HW_SCE_AES_BLOCK_BYTE_SIZE > mac_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CMAC_GenerateFinal(handle, mac); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION: - return TEE_ERROR_BAD_STATE; - default: /* FSP_ERR_CRYPTO_SCE_AUTHENTICATION */ - return TEE_ERROR_MAC_INVALID; - } - - params[1].memref.size = HW_SCE_AES_BLOCK_BYTE_SIZE; - - return TEE_SUCCESS; -} - -static TEE_Result aes256cmac_verifyinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CMAC_VerifyInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_cmac_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256cmac_verifyupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * message; - uint32_t message_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message = (uint8_t *)params[1].memref.buffer; - message_length = (uint32_t)params[1].memref.size; - if (NULL == message) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CMAC_VerifyUpdate(handle, message, message_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256cmac_verifyfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * mac; - uint32_t mac_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - mac = (uint8_t *)params[1].memref.buffer; - mac_length = params[1].memref.size; - if ((NULL == mac) || (2 > mac_length) || (HW_SCE_AES_BLOCK_BYTE_SIZE < mac_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CMAC_VerifyFinal(handle, mac, mac_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: - return TEE_ERROR_MAC_INVALID; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result invoke_command( - void *session __unused, - uint32_t cmd, - uint32_t ptypes, - TEE_Param params[TEE_NUM_PARAMS] - ) -{ - DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); - - switch (cmd) { - case PTA_CMD_AES128ECB_EncryptInit : - return aes128ecb_encryptinit(ptypes, params); - case PTA_CMD_AES128ECB_EncryptUpdate : - return aes128ecb_encryptupdate(ptypes, params); - case PTA_CMD_AES128ECB_EncryptFinal : - return aes128ecb_encryptfinal(ptypes, params); - case PTA_CMD_AES128ECB_DecryptInit : - return aes128ecb_decryptinit(ptypes, params); - case PTA_CMD_AES128ECB_DecryptUpdate : - return aes128ecb_decryptupdate(ptypes, params); - case PTA_CMD_AES128ECB_DecryptFinal : - return aes128ecb_decryptfinal(ptypes, params); - case PTA_CMD_AES256ECB_EncryptInit : - return aes256ecb_encryptinit(ptypes, params); - case PTA_CMD_AES256ECB_EncryptUpdate : - return aes256ecb_encryptupdate(ptypes, params); - case PTA_CMD_AES256ECB_EncryptFinal : - return aes256ecb_encryptfinal(ptypes, params); - case PTA_CMD_AES256ECB_DecryptInit : - return aes256ecb_decryptinit(ptypes, params); - case PTA_CMD_AES256ECB_DecryptUpdate : - return aes256ecb_decryptupdate(ptypes, params); - case PTA_CMD_AES256ECB_DecryptFinal : - return aes256ecb_decryptfinal(ptypes, params); - case PTA_CMD_AES128CBC_EncryptInit : - return aes128cbc_encryptinit(ptypes, params); - case PTA_CMD_AES128CBC_EncryptUpdate : - return aes128cbc_encryptupdate(ptypes, params); - case PTA_CMD_AES128CBC_EncryptFinal : - return aes128cbc_encryptfinal(ptypes, params); - case PTA_CMD_AES128CBC_DecryptInit : - return aes128cbc_decryptinit(ptypes, params); - case PTA_CMD_AES128CBC_DecryptUpdate : - return aes128cbc_decryptupdate(ptypes, params); - case PTA_CMD_AES128CBC_DecryptFinal : - return aes128cbc_decryptfinal(ptypes, params); - case PTA_CMD_AES256CBC_EncryptInit : - return aes256cbc_encryptinit(ptypes, params); - case PTA_CMD_AES256CBC_EncryptUpdate : - return aes256cbc_encryptupdate(ptypes, params); - case PTA_CMD_AES256CBC_EncryptFinal : - return aes256cbc_encryptfinal(ptypes, params); - case PTA_CMD_AES256CBC_DecryptInit : - return aes256cbc_decryptinit(ptypes, params); - case PTA_CMD_AES256CBC_DecryptUpdate : - return aes256cbc_decryptupdate(ptypes, params); - case PTA_CMD_AES256CBC_DecryptFinal : - return aes256cbc_decryptfinal(ptypes, params); - case PTA_CMD_AES128CTR_EncryptInit : - return aes128ctr_encryptinit(ptypes, params); - case PTA_CMD_AES128CTR_EncryptUpdate : - return aes128ctr_encryptupdate(ptypes, params); - case PTA_CMD_AES128CTR_EncryptFinal : - return aes128ctr_encryptfinal(ptypes, params); - case PTA_CMD_AES128CTR_DecryptInit : - return aes128ctr_decryptinit(ptypes, params); - case PTA_CMD_AES128CTR_DecryptUpdate : - return aes128ctr_decryptupdate(ptypes, params); - case PTA_CMD_AES128CTR_DecryptFinal : - return aes128ctr_decryptfinal(ptypes, params); - case PTA_CMD_AES256CTR_EncryptInit : - return aes256ctr_encryptinit(ptypes, params); - case PTA_CMD_AES256CTR_EncryptUpdate : - return aes256ctr_encryptupdate(ptypes, params); - case PTA_CMD_AES256CTR_EncryptFinal : - return aes256ctr_encryptfinal(ptypes, params); - case PTA_CMD_AES256CTR_DecryptInit : - return aes256ctr_decryptinit(ptypes, params); - case PTA_CMD_AES256CTR_DecryptUpdate : - return aes256ctr_decryptupdate(ptypes, params); - case PTA_CMD_AES256CTR_DecryptFinal : - return aes256ctr_decryptfinal(ptypes, params); - case PTA_CMD_AES128CMAC_GenerateInit : - return aes128cmac_generateinit(ptypes, params); - case PTA_CMD_AES128CMAC_GenerateUpdate : - return aes128cmac_generateupdate(ptypes, params); - case PTA_CMD_AES128CMAC_GenerateFinal : - return aes128cmac_generatefinal(ptypes, params); - case PTA_CMD_AES128CMAC_VerifyInit : - return aes128cmac_verifyinit(ptypes, params); - case PTA_CMD_AES128CMAC_VerifyUpdate : - return aes128cmac_verifyupdate(ptypes, params); - case PTA_CMD_AES128CMAC_VerifyFinal : - return aes128cmac_verifyfinal(ptypes, params); - case PTA_CMD_AES256CMAC_GenerateInit : - return aes256cmac_generateinit(ptypes, params); - case PTA_CMD_AES256CMAC_GenerateUpdate : - return aes256cmac_generateupdate(ptypes, params); - case PTA_CMD_AES256CMAC_GenerateFinal : - return aes256cmac_generatefinal(ptypes, params); - case PTA_CMD_AES256CMAC_VerifyInit : - return aes256cmac_verifyinit(ptypes, params); - case PTA_CMD_AES256CMAC_VerifyUpdate : - return aes256cmac_verifyupdate(ptypes, params); - case PTA_CMD_AES256CMAC_VerifyFinal : - return aes256cmac_verifyfinal(ptypes, params); - default: - return TEE_ERROR_NOT_SUPPORTED; - } -} - -pseudo_ta_register( - .uuid = PTA_SCE_AES_UUID, - .name = PTA_NAME, - .flags = PTA_DEFAULT_FLAGS | TA_FLAG_DEVICE_ENUM, - .invoke_command_entry_point = invoke_command -); diff --git a/core/arch/arm/plat-rz/v2h/pta/pta_sce_ecc.c b/core/arch/arm/plat-rz/v2h/pta/pta_sce_ecc.c deleted file mode 100644 index f431ede56..000000000 --- a/core/arch/arm/plat-rz/v2h/pta/pta_sce_ecc.c +++ /dev/null @@ -1,483 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ - -#include -#include - -#include -#include - -#define PTA_NAME "sce_ecc.pta" - -static uint32_t sha512_hash[HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t)]; - -static TEE_Result ecdsa_secp192r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t message_hash; - sce_ecdsa_byte_data_t signature; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[0].memref.buffer; - message_hash.data_length = params[0].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[1].memref.buffer; - signature.data_length = params[1].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE > signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_secp192r1_SignatureGenerate(&message_hash, &signature, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = signature.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_secp192r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t signature; - sce_ecdsa_byte_data_t message_hash; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[1].memref.buffer; - message_hash.data_length = params[1].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_secp192r1_SignatureVerify(&signature, &message_hash, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_secp224r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t message_hash; - sce_ecdsa_byte_data_t signature; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[0].memref.buffer; - message_hash.data_length = params[0].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[1].memref.buffer; - signature.data_length = params[1].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE > signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_secp224r1_SignatureGenerate(&message_hash, &signature, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = signature.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_secp224r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t signature; - sce_ecdsa_byte_data_t message_hash; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[1].memref.buffer; - message_hash.data_length = params[1].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_secp224r1_SignatureVerify(&signature, &message_hash, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_secp256r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t message_hash; - sce_ecdsa_byte_data_t signature; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[0].memref.buffer; - message_hash.data_length = params[0].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[1].memref.buffer; - signature.data_length = params[1].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE > signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_secp256r1_SignatureGenerate(&message_hash, &signature, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = signature.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_secp256r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t signature; - sce_ecdsa_byte_data_t message_hash; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[1].memref.buffer; - message_hash.data_length = params[1].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_secp256r1_SignatureVerify(&signature, &message_hash, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_brainpoolp512r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t message_hash; - sce_ecdsa_byte_data_t signature; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)sha512_hash; - message_hash.data_length = HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE; - message_hash.data_type = 1; - err = tee_hash_createdigest(TEE_ALG_SHA512, params[0].memref.buffer, params[0].memref.size, - message_hash.pdata, message_hash.data_length); - if (err) { - return err; - } - - signature.pdata = (uint8_t *)params[1].memref.buffer; - signature.data_length = params[1].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_P512_DATA_BYTE_SIZE > signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_BrainpoolP512r1_SignatureGenerate(&message_hash, &signature, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = signature.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_brainpoolp512r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t signature; - sce_ecdsa_byte_data_t message_hash; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_P512_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)sha512_hash; - message_hash.data_length = HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE; - message_hash.data_type = 1; - err = tee_hash_createdigest(TEE_ALG_SHA512, params[1].memref.buffer, params[1].memref.size, - message_hash.pdata, message_hash.data_length); - if (err) { - return err; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_BrainpoolP512r1_SignatureVerify(&signature, &message_hash, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result invoke_command(void *session __unused, uint32_t cmd, - uint32_t ptypes, - TEE_Param params[TEE_NUM_PARAMS]) -{ - DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); - - switch (cmd) - { - case PTA_CMD_ECDSA_secp192r1_SignatureGenerate : - return ecdsa_secp192r1_signaturegenerate(ptypes, params); - case PTA_CMD_ECDSA_secp192r1_SignatureVerify : - return ecdsa_secp192r1_signatureverify(ptypes, params); - case PTA_CMD_ECDSA_secp224r1_SignatureGenerate : - return ecdsa_secp224r1_signaturegenerate(ptypes, params); - case PTA_CMD_ECDSA_secp224r1_SignatureVerify : - return ecdsa_secp224r1_signatureverify(ptypes, params); - case PTA_CMD_ECDSA_secp256r1_SignatureGenerate : - return ecdsa_secp256r1_signaturegenerate(ptypes, params); - case PTA_CMD_ECDSA_secp256r1_SignatureVerify : - return ecdsa_secp256r1_signatureverify(ptypes, params); - case PTA_CMD_ECDSA_BrainpoolP512r1_SignatureGenerate : - return ecdsa_brainpoolp512r1_signaturegenerate(ptypes, params); - case PTA_CMD_ECDSA_BrainpoolP512r1_SignatureVerify : - return ecdsa_brainpoolp512r1_signatureverify(ptypes, params); - default: - return TEE_ERROR_NOT_SUPPORTED; - } -} - -pseudo_ta_register(.uuid = PTA_SCE_ECC_UUID, .name = PTA_NAME, - .flags = PTA_DEFAULT_FLAGS, - .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/v2h/pta/pta_sce_rsa.c b/core/arch/arm/plat-rz/v2h/pta/pta_sce_rsa.c deleted file mode 100644 index 5c6694f62..000000000 --- a/core/arch/arm/plat-rz/v2h/pta/pta_sce_rsa.c +++ /dev/null @@ -1,576 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ - -#include - -#include -#include - -#define PTA_NAME "sce_rsa.pta" - -static TEE_Result rsassa_pkcs1024_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t message_hash; - sce_rsa_byte_data_t signature; - sce_rsa1024_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[0].memref.buffer; - message_hash.data_length = params[0].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[1].memref.buffer; - signature.data_length = params[1].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_RSA_1024_DATA_BYTE_SIZE > signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa1024_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSASSA_PKCS1024_SignatureGenerate(&message_hash, &signature, wrapped_key, HW_SCE_RSA_HASH_SHA256); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = signature.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result rsassa_pkcs1024_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t signature; - sce_rsa_byte_data_t message_hash; - sce_rsa1024_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_RSA_1024_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[1].memref.buffer; - message_hash.data_length = params[1].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa1024_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSASSA_PKCS1024_SignatureVerify(&signature, &message_hash, wrapped_key, HW_SCE_RSA_HASH_SHA256); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: - return TEE_ERROR_SIGNATURE_INVALID; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result rsassa_pkcs2048_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t message_hash; - sce_rsa_byte_data_t signature; - sce_rsa2048_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[0].memref.buffer; - message_hash.data_length = params[0].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[1].memref.buffer; - signature.data_length = params[1].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_RSA_2048_DATA_BYTE_SIZE > signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa2048_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSASSA_PKCS2048_SignatureGenerate(&message_hash, &signature, wrapped_key, HW_SCE_RSA_HASH_SHA256); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = signature.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result rsassa_pkcs2048_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t signature; - sce_rsa_byte_data_t message_hash; - sce_rsa2048_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_RSA_2048_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[1].memref.buffer; - message_hash.data_length = params[1].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa2048_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSASSA_PKCS2048_SignatureVerify(&signature, &message_hash, wrapped_key, HW_SCE_RSA_HASH_SHA256); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: - return TEE_ERROR_SIGNATURE_INVALID; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result rsassa_pkcs4096_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t signature; - sce_rsa_byte_data_t message_hash; - sce_rsa4096_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_RSA_4096_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[1].memref.buffer; - message_hash.data_length = params[1].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa4096_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa4096_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSASSA_PKCS4096_SignatureVerify(&signature, &message_hash, wrapped_key, HW_SCE_RSA_HASH_SHA256); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: - return TEE_ERROR_SIGNATURE_INVALID; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result rsaes_pkcs1024_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t plain; - sce_rsa_byte_data_t cipher; - sce_rsa1024_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain.pdata = (uint8_t *)params[0].memref.buffer; - plain.data_length = params[0].memref.size; - plain.data_type = 0; - if (NULL == plain.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher.pdata = (uint8_t *)params[1].memref.buffer; - cipher.data_length = params[1].memref.size; - cipher.data_type = 0; - if (NULL == cipher.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa1024_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSAES_PKCS1024_Encrypt(&plain, &cipher, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PARAMETER */ - return TEE_ERROR_BAD_PARAMETERS; - } - - params[1].memref.size = cipher.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result rsaes_pkcs1024_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t plain; - sce_rsa_byte_data_t cipher; - sce_rsa1024_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher.pdata = (uint8_t *)params[0].memref.buffer; - cipher.data_length = params[0].memref.size; - cipher.data_type = 0; - if (NULL == cipher.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain.pdata = (uint8_t *)params[1].memref.buffer; - plain.data_length = params[1].memref.size; - plain.data_type = 0; - if (NULL == plain.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa1024_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSAES_PKCS1024_Decrypt(&cipher, &plain, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} -static TEE_Result rsaes_pkcs2048_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t plain; - sce_rsa_byte_data_t cipher; - sce_rsa2048_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain.pdata = (uint8_t *)params[0].memref.buffer; - plain.data_length = params[0].memref.size; - plain.data_type = 0; - if (NULL == plain.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher.pdata = (uint8_t *)params[1].memref.buffer; - cipher.data_length = params[1].memref.size; - cipher.data_type = 0; - if (NULL == cipher.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa2048_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSAES_PKCS2048_Encrypt(&plain, &cipher, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PARAMETER */ - return TEE_ERROR_BAD_PARAMETERS; - } - - params[1].memref.size = cipher.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result rsaes_pkcs2048_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t plain; - sce_rsa_byte_data_t cipher; - sce_rsa2048_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher.pdata = (uint8_t *)params[0].memref.buffer; - cipher.data_length = params[0].memref.size; - cipher.data_type = 0; - if (NULL == cipher.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain.pdata = (uint8_t *)params[1].memref.buffer; - plain.data_length = params[1].memref.size; - plain.data_type = 0; - if (NULL == plain.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa2048_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSAES_PKCS2048_Decrypt(&cipher, &plain, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static TEE_Result rsaes_pkcs4096_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t plain; - sce_rsa_byte_data_t cipher; - sce_rsa4096_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain.pdata = (uint8_t *)params[0].memref.buffer; - plain.data_length = params[0].memref.size; - plain.data_type = 0; - if (NULL == plain.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher.pdata = (uint8_t *)params[1].memref.buffer; - cipher.data_length = params[1].memref.size; - cipher.data_type = 0; - if (NULL == cipher.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa4096_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa4096_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSAES_PKCS4096_Encrypt(&plain, &cipher, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PARAMETER */ - return TEE_ERROR_BAD_PARAMETERS; - } - - params[1].memref.size = cipher.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result invoke_command(void *session __unused, uint32_t cmd, - uint32_t ptypes, - TEE_Param params[TEE_NUM_PARAMS]) -{ - DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); - - switch (cmd) { - case PTA_CMD_RSASSA_PKCS1024_SignatureGenerate : - return rsassa_pkcs1024_signaturegenerate(ptypes, params); - case PTA_CMD_RSASSA_PKCS1024_SignatureVerify : - return rsassa_pkcs1024_signatureverify(ptypes, params); - case PTA_CMD_RSASSA_PKCS2048_SignatureGenerate : - return rsassa_pkcs2048_signaturegenerate(ptypes, params); - case PTA_CMD_RSASSA_PKCS2048_SignatureVerify : - return rsassa_pkcs2048_signatureverify(ptypes, params); - case PTA_CMD_RSASSA_PKCS4096_SignatureVerify : - return rsassa_pkcs4096_signatureverify(ptypes, params); - case PTA_CMD_RSAES_PKCS1024_Encrypt : - return rsaes_pkcs1024_encrypt(ptypes, params); - case PTA_CMD_RSAES_PKCS1024_Decrypt : - return rsaes_pkcs1024_decrypt(ptypes, params); - case PTA_CMD_RSAES_PKCS2048_Encrypt : - return rsaes_pkcs2048_encrypt(ptypes, params); - case PTA_CMD_RSAES_PKCS2048_Decrypt : - return rsaes_pkcs2048_decrypt(ptypes, params); - case PTA_CMD_RSAES_PKCS4096_Encrypt : - return rsaes_pkcs4096_encrypt(ptypes, params); - default: - return TEE_ERROR_NOT_SUPPORTED; - } -} - -pseudo_ta_register(.uuid = PTA_SCE_RSA_UUID, .name = PTA_NAME, - .flags = PTA_DEFAULT_FLAGS, - .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/v2h/pta/pta_sce_sha.c b/core/arch/arm/plat-rz/v2h/pta/pta_sce_sha.c deleted file mode 100644 index d54a75c06..000000000 --- a/core/arch/arm/plat-rz/v2h/pta/pta_sce_sha.c +++ /dev/null @@ -1,269 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ - -#include - -#include -#include - -#define PTA_NAME "sce_sha.pta" - -static TEE_Result sha224_init(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_sha_md5_handle_t * handle; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.SHA224_Init(handle); - switch (err) - { - case FSP_SUCCESS: - break; - default: - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_sha_md5_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result sha224_update(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_sha_md5_handle_t * handle; - uint8_t * message; - uint32_t message_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message = (uint8_t *)params[1].memref.buffer; - message_length = (uint32_t)params[1].memref.size; - - err = g_sce_protected_on_sce.SHA224_Update(handle, message, message_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result sha224_final(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_sha_md5_handle_t * handle; - uint8_t * digest; - uint32_t digest_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - digest = (uint8_t *)params[1].memref.buffer; - digest_length = (uint32_t)params[1].memref.size; - if ((NULL == digest) || (HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE > digest_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.SHA224_Final(handle, digest, &digest_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = digest_length; - - return TEE_SUCCESS; -} - -static TEE_Result sha256_init(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_sha_md5_handle_t * handle; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.SHA256_Init(handle); - switch (err) - { - case FSP_SUCCESS: - break; - default: - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_sha_md5_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result sha256_update(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_sha_md5_handle_t * handle; - uint8_t * message; - uint32_t message_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message = (uint8_t *)params[1].memref.buffer; - message_length = (uint32_t)params[1].memref.size; - - err = g_sce_protected_on_sce.SHA256_Update(handle, message, message_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result sha256_final(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_sha_md5_handle_t * handle; - uint8_t * digest; - uint32_t digest_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - digest = (uint8_t *)params[1].memref.buffer; - digest_length = (uint32_t)params[1].memref.size; - if ((NULL == digest) || (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE > digest_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.SHA256_Final(handle, digest, &digest_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = digest_length; - - return TEE_SUCCESS; -} - -static TEE_Result invoke_command(void *session __unused, uint32_t cmd, - uint32_t ptypes, - TEE_Param params[TEE_NUM_PARAMS]) -{ - DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); - - switch (cmd) { - case PTA_CMD_SHA224_Init : - return sha224_init(ptypes, params); - case PTA_CMD_SHA224_Update : - return sha224_update(ptypes, params); - case PTA_CMD_SHA224_Final : - return sha224_final(ptypes, params); - case PTA_CMD_SHA256_Init : - return sha256_init(ptypes, params); - case PTA_CMD_SHA256_Update : - return sha256_update(ptypes, params); - case PTA_CMD_SHA256_Final : - return sha256_final(ptypes, params); - default: - return TEE_ERROR_NOT_SUPPORTED; - } -} - -pseudo_ta_register(.uuid = PTA_SCE_SHA_UUID, .name = PTA_NAME, - .flags = PTA_DEFAULT_FLAGS, - .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/v2h/pta/sub.mk b/core/arch/arm/plat-rz/v2h/pta/sub.mk deleted file mode 100644 index e51074b6d..000000000 --- a/core/arch/arm/plat-rz/v2h/pta/sub.mk +++ /dev/null @@ -1,3 +0,0 @@ -global-incdirs-y += include - -srcs-$(CFG_RZ_SCE) += pta_sce.c pta_sce_ecc.c pta_sce_rsa.c pta_sce_sha.c pta_sce_aes.c diff --git a/core/arch/arm/plat-rz/v2h/rzv2h_config.h b/core/arch/arm/plat-rz/v2h/rzv2h_config.h index f507b54e8..482d810d8 100644 --- a/core/arch/arm/plat-rz/v2h/rzv2h_config.h +++ b/core/arch/arm/plat-rz/v2h/rzv2h_config.h @@ -29,6 +29,8 @@ #define XSPI_BASE 0x11030000U #define XSPI_REG_SIZE 0x10000 +#define HW_SCE_BASE 0x10440000 + #if defined(PLATFORM_FLAVOR_v2h_evk_1) /* DDR 8Gbyte x1 */ #define NSEC_DDR_0_BASE 0x47E00000U diff --git a/core/arch/arm/plat-rz/v2h/sub.mk b/core/arch/arm/plat-rz/v2h/sub.mk index 86535d4a9..891b4c981 100644 --- a/core/arch/arm/plat-rz/v2h/sub.mk +++ b/core/arch/arm/plat-rz/v2h/sub.mk @@ -2,4 +2,4 @@ global-incdirs-y += . srcs-y += main.c -subdirs-y += drivers pta \ No newline at end of file +subdirs-y += drivers \ No newline at end of file From 54e1371057a7bc4cc8803df0c4c2dd59c4b2b9f0 Mon Sep 17 00:00:00 2001 From: kaiki osakaki Date: Thu, 6 Jun 2024 11:16:08 +0900 Subject: [PATCH 3/7] plat-rz: Fixed copyright for Renesas RZ/V2H. Signed-off-by: kaiki osakaki --- .../arm/plat-rz/common/drivers/r_sce/inc/instances/r_sce.h | 2 +- core/arch/arm/plat-rz/common/drivers/sce.c | 2 +- core/arch/arm/plat-rz/common/pta/sub.mk | 2 +- core/arch/arm/plat-rz/common/sub.mk | 2 +- core/arch/arm/plat-rz/v2h/drivers/sflash.c | 5 +++-- core/arch/arm/plat-rz/v2h/drivers/sflash.h | 2 +- core/arch/arm/plat-rz/v2h/drivers/sub.mk | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/inc/instances/r_sce.h b/core/arch/arm/plat-rz/common/drivers/r_sce/inc/instances/r_sce.h index 580290695..ae46ec99e 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/inc/instances/r_sce.h +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/inc/instances/r_sce.h @@ -14,7 +14,7 @@ * following link: * http://www.renesas.com/disclaimer * - * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + * Copyright (C) 2022-2024 Renesas Electronics Corporation. All rights reserved. *********************************************************************************************************************/ /********************************************************************************************************************** * File Name : r_sce.h diff --git a/core/arch/arm/plat-rz/common/drivers/sce.c b/core/arch/arm/plat-rz/common/drivers/sce.c index c3265bc8c..052f6075e 100644 --- a/core/arch/arm/plat-rz/common/drivers/sce.c +++ b/core/arch/arm/plat-rz/common/drivers/sce.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: BSD-2-Clause /* - * Copyright (c) 2021, Renesas Electronics + * Copyright (c) 2021-2024, Renesas Electronics */ #include #include diff --git a/core/arch/arm/plat-rz/common/pta/sub.mk b/core/arch/arm/plat-rz/common/pta/sub.mk index 596449565..7216692a7 100644 --- a/core/arch/arm/plat-rz/common/pta/sub.mk +++ b/core/arch/arm/plat-rz/common/pta/sub.mk @@ -1,4 +1,4 @@ global-incdirs-y += include -srcs-y += pta_flash.c +srcs-$(CFG_RZ_XSPI) += pta_flash.c srcs-$(CFG_RZ_SCE) += pta_sce.c pta_sce_ecc.c pta_sce_rsa.c pta_sce_sha.c pta_sce_aes.c diff --git a/core/arch/arm/plat-rz/common/sub.mk b/core/arch/arm/plat-rz/common/sub.mk index 9739db44b..ca4d7a7cf 100644 --- a/core/arch/arm/plat-rz/common/sub.mk +++ b/core/arch/arm/plat-rz/common/sub.mk @@ -1,4 +1,4 @@ srcs-$(CFG_RZ_HUK) += huk.c subdirs-y += drivers -subdirs-$(CFG_RZ_XSPI) += pta +subdirs-$-y += pta diff --git a/core/arch/arm/plat-rz/v2h/drivers/sflash.c b/core/arch/arm/plat-rz/v2h/drivers/sflash.c index 603c7d76f..75703b3e7 100644 --- a/core/arch/arm/plat-rz/v2h/drivers/sflash.c +++ b/core/arch/arm/plat-rz/v2h/drivers/sflash.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, Renesas Electronics Corporation. All rights reserved. + * Copyright (c) 2023, Renesas Electronics Corporation. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #include #include @@ -79,6 +79,7 @@ void sflash_write_buffer(uint32_t addr, uintptr_t buff, size_t len) void sflash_open(void) { cpg_xspi_start(); + xspi_setup(); } diff --git a/core/arch/arm/plat-rz/v2h/drivers/sflash.h b/core/arch/arm/plat-rz/v2h/drivers/sflash.h index 266017e53..53d4a5997 100644 --- a/core/arch/arm/plat-rz/v2h/drivers/sflash.h +++ b/core/arch/arm/plat-rz/v2h/drivers/sflash.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, Renesas Electronics Corporation. All rights reserved. + * Copyright (c) 2023, Renesas Electronics Corporation. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ diff --git a/core/arch/arm/plat-rz/v2h/drivers/sub.mk b/core/arch/arm/plat-rz/v2h/drivers/sub.mk index a27ce598b..fc90882e4 100644 --- a/core/arch/arm/plat-rz/v2h/drivers/sub.mk +++ b/core/arch/arm/plat-rz/v2h/drivers/sub.mk @@ -2,4 +2,4 @@ global-incdirs-y += . srcs-y += sflash.c -subdirs-y += cpg \ No newline at end of file +subdirs-y += cpg From f064ad9c1eda594464d57376fbbd77ca9095461c Mon Sep 17 00:00:00 2001 From: kaiki osakaki Date: Tue, 11 Jun 2024 17:37:18 +0900 Subject: [PATCH 4/7] plat-rz: Fixed sub.mk for RZ/V2H. Signed-off-by: kaiki osakaki --- core/arch/arm/plat-rz/common/drivers/sub.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/arch/arm/plat-rz/common/drivers/sub.mk b/core/arch/arm/plat-rz/common/drivers/sub.mk index 8f4d9b049..08c244335 100644 --- a/core/arch/arm/plat-rz/common/drivers/sub.mk +++ b/core/arch/arm/plat-rz/common/drivers/sub.mk @@ -7,6 +7,6 @@ subdirs-$(CFG_RZ_XSPI) += xspi srcs-$(CFG_RZ_SCE) += sce.c hw_rng.c subdirs-$(CFG_RZ_SCE) += r_sce -ifeq ($(PLATFORM_FLAVOR),v2h_evk_1) +ifeq ($(CFG_PLATFORM_GROUP_v2h),y) ldflags-external += $(CFG_RZ_SCE_LIB_DIR)/libr_secure_ip_2_0.a.1.0.0 endif \ No newline at end of file From ea6964c002a015b532a6ab11c3706e33bae07b45 Mon Sep 17 00:00:00 2001 From: kaiki osakaki Date: Thu, 11 Jul 2024 16:30:13 +0900 Subject: [PATCH 5/7] plat-rz : Commonize TSIP driver for RZ/V2H. Signed-off-by: kaiki osakaki --- .../hw_rng.c => common/drivers/hw_rng_rsip.c} | 13 +- .../plat-rz/common/drivers/r_rsip/bsp_api.c | 74 + .../plat-rz/common/drivers/r_rsip/bsp_api.h | 163 + .../r_rsip/doc/html/_c_o_p_y_r_i_g_h_t.html | 114 + .../common/drivers/r_rsip/doc/html/bc_s.png | Bin 0 -> 676 bytes .../common/drivers/r_rsip/doc/html/bdwn.png | Bin 0 -> 147 bytes .../common/drivers/r_rsip/doc/html/closed.png | Bin 0 -> 132 bytes .../drivers/r_rsip/doc/html/customdoxygen.css | 1429 +++++ .../drivers/r_rsip/doc/html/deprecated.html | 206 + .../dir_70f4ae3d95e230caee709338d5cd48f8.html | 112 + .../dir_72482daf12d144eb113f7615a624153c.html | 112 + .../dir_7b11827f91a01532ec10f9e54e954f98.html | 116 + .../dir_7cd603f42365d62e5cba3cdfc864d9f2.html | 112 + .../dir_7da8a3010a4727d5081fba68b4e7fa8d.html | 118 + .../common/drivers/r_rsip/doc/html/doc.png | Bin 0 -> 746 bytes .../drivers/r_rsip/doc/html/doxygen.css | 1771 ++++++ .../drivers/r_rsip/doc/html/doxygen.png | Bin 0 -> 3779 bytes .../drivers/r_rsip/doc/html/dynsections.js | 120 + .../drivers/r_rsip/doc/html/folderclosed.png | Bin 0 -> 616 bytes .../drivers/r_rsip/doc/html/folderopen.png | Bin 0 -> 597 bytes ...__r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.html | 122 + ...p___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.js | 4 + ...group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.html | 134 + .../group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.js | 4 + .../r_rsip/doc/html/group___r_s_i_p.html | 4835 ++++++++++++++++ .../r_rsip/doc/html/group___r_s_i_p.js | 55 + .../doc/html/group___r_s_i_p___a_p_i.html | 973 ++++ .../doc/html/group___r_s_i_p___a_p_i.js | 208 + .../common/drivers/r_rsip/doc/html/index.html | 113 + .../common/drivers/r_rsip/doc/html/jquery.js | 35 + .../drivers/r_rsip/doc/html/logo_scaled.png | Bin 0 -> 7690 bytes .../drivers/r_rsip/doc/html/modules.html | 119 + .../common/drivers/r_rsip/doc/html/modules.js | 5 + .../common/drivers/r_rsip/doc/html/nav_f.png | Bin 0 -> 153 bytes .../common/drivers/r_rsip/doc/html/nav_g.png | Bin 0 -> 95 bytes .../common/drivers/r_rsip/doc/html/nav_h.png | Bin 0 -> 98 bytes .../drivers/r_rsip/doc/html/navtree.css | 146 + .../common/drivers/r_rsip/doc/html/navtree.js | 544 ++ .../drivers/r_rsip/doc/html/navtreedata.js | 40 + .../drivers/r_rsip/doc/html/navtreeindex0.js | 253 + .../drivers/r_rsip/doc/html/navtreeindex1.js | 8 + .../common/drivers/r_rsip/doc/html/open.png | Bin 0 -> 123 bytes .../common/drivers/r_rsip/doc/html/pages.html | 117 + .../common/drivers/r_rsip/doc/html/resize.js | 137 + .../drivers/r_rsip/doc/html/search/all_0.html | 30 + .../drivers/r_rsip/doc/html/search/all_0.js | 4 + .../drivers/r_rsip/doc/html/search/all_1.html | 30 + .../drivers/r_rsip/doc/html/search/all_1.js | 4 + .../drivers/r_rsip/doc/html/search/all_2.html | 30 + .../drivers/r_rsip/doc/html/search/all_2.js | 12 + .../drivers/r_rsip/doc/html/search/all_3.html | 30 + .../drivers/r_rsip/doc/html/search/all_3.js | 25 + .../drivers/r_rsip/doc/html/search/all_4.html | 30 + .../drivers/r_rsip/doc/html/search/all_4.js | 4 + .../drivers/r_rsip/doc/html/search/all_5.html | 30 + .../drivers/r_rsip/doc/html/search/all_5.js | 4 + .../drivers/r_rsip/doc/html/search/all_6.html | 30 + .../drivers/r_rsip/doc/html/search/all_6.js | 6 + .../drivers/r_rsip/doc/html/search/all_7.html | 30 + .../drivers/r_rsip/doc/html/search/all_7.js | 209 + .../drivers/r_rsip/doc/html/search/all_8.html | 30 + .../drivers/r_rsip/doc/html/search/all_8.js | 9 + .../drivers/r_rsip/doc/html/search/all_9.html | 30 + .../drivers/r_rsip/doc/html/search/all_9.js | 4 + .../drivers/r_rsip/doc/html/search/all_a.html | 30 + .../drivers/r_rsip/doc/html/search/all_a.js | 4 + .../r_rsip/doc/html/search/classes_0.html | 30 + .../r_rsip/doc/html/search/classes_0.js | 9 + .../drivers/r_rsip/doc/html/search/close.png | Bin 0 -> 273 bytes .../r_rsip/doc/html/search/enums_0.html | 30 + .../drivers/r_rsip/doc/html/search/enums_0.js | 12 + .../r_rsip/doc/html/search/enumvalues_0.html | 30 + .../r_rsip/doc/html/search/enumvalues_0.js | 151 + .../r_rsip/doc/html/search/functions_0.html | 30 + .../r_rsip/doc/html/search/functions_0.js | 54 + .../r_rsip/doc/html/search/groups_0.html | 30 + .../r_rsip/doc/html/search/groups_0.js | 4 + .../r_rsip/doc/html/search/groups_1.html | 30 + .../r_rsip/doc/html/search/groups_1.js | 4 + .../r_rsip/doc/html/search/groups_2.html | 30 + .../r_rsip/doc/html/search/groups_2.js | 5 + .../r_rsip/doc/html/search/mag_sel.png | Bin 0 -> 465 bytes .../r_rsip/doc/html/search/nomatches.html | 12 + .../r_rsip/doc/html/search/pages_0.html | 30 + .../drivers/r_rsip/doc/html/search/pages_0.js | 4 + .../r_rsip/doc/html/search/pages_1.html | 30 + .../drivers/r_rsip/doc/html/search/pages_1.js | 4 + .../r_rsip/doc/html/search/pages_2.html | 30 + .../drivers/r_rsip/doc/html/search/pages_2.js | 4 + .../drivers/r_rsip/doc/html/search/search.css | 273 + .../drivers/r_rsip/doc/html/search/search.js | 814 +++ .../r_rsip/doc/html/search/search_l.png | Bin 0 -> 567 bytes .../r_rsip/doc/html/search/search_m.png | Bin 0 -> 158 bytes .../r_rsip/doc/html/search/search_r.png | Bin 0 -> 553 bytes .../r_rsip/doc/html/search/searchdata.js | 39 + .../r_rsip/doc/html/search/typedefs_0.html | 30 + .../r_rsip/doc/html/search/typedefs_0.js | 4 + .../r_rsip/doc/html/search/variables_0.html | 30 + .../r_rsip/doc/html/search/variables_0.js | 6 + .../r_rsip/doc/html/search/variables_1.html | 30 + .../r_rsip/doc/html/search/variables_1.js | 4 + .../r_rsip/doc/html/search/variables_2.html | 30 + .../r_rsip/doc/html/search/variables_2.js | 4 + .../drivers/r_rsip/doc/html/splitbar.png | Bin 0 -> 314 bytes .../drivers/r_rsip/doc/html/sync_off.png | Bin 0 -> 853 bytes .../drivers/r_rsip/doc/html/sync_on.png | Bin 0 -> 845 bytes .../common/drivers/r_rsip/doc/html/tab_a.png | Bin 0 -> 142 bytes .../common/drivers/r_rsip/doc/html/tab_b.png | Bin 0 -> 169 bytes .../common/drivers/r_rsip/doc/html/tab_h.png | Bin 0 -> 177 bytes .../common/drivers/r_rsip/doc/html/tab_s.png | Bin 0 -> 184 bytes .../common/drivers/r_rsip/doc/html/tabs.css | 1 + .../plat-rz/common/drivers/r_rsip/manual.md | 1 + .../r_rsip/rsip_common/inc/api/r_rsip_api.h | 521 ++ .../r_rsip/rsip_common/inc/instances/r_rsip.h | 342 ++ .../r_rsip/rsip_common/private/r_rsip_err.h | 48 + .../rsip_common/private/r_rsip_private.h | 325 ++ .../r_rsip/rsip_common/private/r_rsip_reg.h | 2460 ++++++++ .../r_rsip/rsip_common/private/r_rsip_util.h | 95 + .../r_rsip/rsip_common/public/r_rsip.c | 680 +++ .../r_rsip/rsip_common/public/r_rsip_aes.c | 2096 +++++++ .../r_rsip/rsip_common/public/r_rsip_ecc.c | 240 + .../r_rsip/rsip_common/public/r_rsip_public.h | 144 + .../r_rsip/rsip_common/public/r_rsip_rsa.c | 2009 +++++++ .../r_rsip/rsip_common/public/r_rsip_rzg3.c | 332 ++ .../r_rsip/rsip_common/public/r_rsip_sha.c | 1104 ++++ .../r_rsip/rzg3/primitive/r_rsip_primitive.h | 479 ++ .../drivers/r_rsip/rzg3/private/r_rsip_addr.h | 33 + .../drivers/r_rsip/rzg3/private/r_rsip_cfg.h | 280 + .../drivers/r_rsip/rzg3/private/r_rsip_otp.c | 76 + .../drivers/r_rsip/rzg3/private/r_rsip_otp.h | 51 + .../r_rsip/rzg3/private/r_rsip_private.c | 973 ++++ .../r_rsip/rzg3/private/r_rsip_wrapper.c | 716 +++ .../r_rsip/rzg3/private/r_rsip_wrapper.h | 223 + .../arm/plat-rz/common/drivers/r_rsip/sub.mk | 29 + .../plat-rz/common/drivers/r_sce/README.md | 3 +- .../arm/plat-rz/common/drivers/r_sce/sub.mk | 6 + core/arch/arm/plat-rz/common/drivers/rsip.c | 38 + .../spi_multi/AT25QL128A/spi_multi_device.c | 0 .../AT25QL128A/spi_multi_reg_values.h | 0 .../drivers/spi_multi/AT25QL128A/sub.mk | 0 .../spi_multi/MT25QU512ABB/spi_multi_device.c | 0 .../MT25QU512ABB/spi_multi_reg_values.h | 0 .../drivers/spi_multi/MT25QU512ABB/sub.mk | 0 .../drivers/spi_multi/spi_multi.c | 0 .../drivers/spi_multi/spi_multi.h | 0 .../drivers/spi_multi/spi_multi_device.h | 0 .../drivers/spi_multi/spi_multi_regs.h | 0 .../{g2l => common}/drivers/spi_multi/sub.mk | 0 core/arch/arm/plat-rz/common/drivers/sub.mk | 11 +- .../common/pta/rsip/include/pta_rsip.h | 311 + .../common/pta/rsip/include/pta_rsip_aes.h | 361 ++ .../pta/rsip/include/pta_rsip_ecc.h} | 41 +- .../common/pta/rsip/include/pta_rsip_hmac.h | 111 + .../common/pta/rsip/include/pta_rsip_rsa.h | 309 + .../common/pta/rsip/include/pta_rsip_sha.h | 127 + .../common/pta/rsip/include/r_rsip_api.h | 504 ++ .../arm/plat-rz/common/pta/rsip/pta_rsip.c | 704 +++ .../plat-rz/common/pta/rsip/pta_rsip_aes.c | 1203 ++++ .../plat-rz/common/pta/rsip/pta_rsip_ecc.c | 710 +++ .../plat-rz/common/pta/rsip/pta_rsip_hmac.c | 380 ++ .../plat-rz/common/pta/rsip/pta_rsip_rsa.c | 1114 ++++ .../plat-rz/common/pta/rsip/pta_rsip_sha.c | 208 + core/arch/arm/plat-rz/common/pta/rsip/sub.mk | 9 + core/arch/arm/plat-rz/common/pta/sub.mk | 7 +- .../common/pta/{ => tsip}/include/pta_sce.h | 0 .../pta/{ => tsip}/include/pta_sce_aes.h | 0 .../pta/{ => tsip}/include/pta_sce_ecc.h | 0 .../pta/{ => tsip}/include/pta_sce_rsa.h | 0 .../pta/{ => tsip}/include/pta_sce_sha.h | 12 +- .../plat-rz/common/pta/{ => tsip}/pta_sce.c | 0 .../common/pta/{ => tsip}/pta_sce_aes.c | 0 .../common/pta/{ => tsip}/pta_sce_ecc.c | 0 .../common/pta/{ => tsip}/pta_sce_rsa.c | 0 .../common/pta/{ => tsip}/pta_sce_sha.c | 0 core/arch/arm/plat-rz/common/pta/tsip/sub.mk | 8 + core/arch/arm/plat-rz/common/sub.mk | 2 +- .../arm/plat-rz/g2l/drivers/r_sce/README.md | 46 - .../drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst | 4980 ----------------- .../g2l/drivers/r_sce/inc/api/r_sce_api.h | 1501 ----- .../g2l/drivers/r_sce/inc/instances/r_sce.h | 424 -- .../drivers/r_sce/private/inc/r_sce_private.h | 376 -- .../g2l/drivers/r_sce/private/r_sce_private.c | 1346 ----- .../plat-rz/g2l/drivers/r_sce/public/r_sce.c | 1447 ----- .../g2l/drivers/r_sce/public/r_sce_aes.c | 2174 ------- .../g2l/drivers/r_sce/public/r_sce_ecc.c | 685 --- .../g2l/drivers/r_sce/public/r_sce_rsa.c | 1162 ---- .../g2l/drivers/r_sce/public/r_sce_sha.c | 447 -- .../arch/arm/plat-rz/g2l/drivers/r_sce/sub.mk | 11 - core/arch/arm/plat-rz/g2l/drivers/sce.c | 50 - core/arch/arm/plat-rz/g2l/drivers/sub.mk | 4 - .../arm/plat-rz/g2l/pta/include/pta_flash.h | 27 - .../arm/plat-rz/g2l/pta/include/pta_sce.h | 179 - .../arm/plat-rz/g2l/pta/include/pta_sce_aes.h | 279 - .../arm/plat-rz/g2l/pta/include/pta_sce_rsa.h | 84 - .../arm/plat-rz/g2l/pta/include/pta_sce_sha.h | 48 - core/arch/arm/plat-rz/g2l/pta/pta_flash.c | 94 - core/arch/arm/plat-rz/g2l/pta/pta_sce.c | 1170 ---- core/arch/arm/plat-rz/g2l/pta/pta_sce_aes.c | 2257 -------- core/arch/arm/plat-rz/g2l/pta/pta_sce_ecc.c | 483 -- core/arch/arm/plat-rz/g2l/pta/pta_sce_rsa.c | 576 -- core/arch/arm/plat-rz/g2l/pta/pta_sce_sha.c | 269 - core/arch/arm/plat-rz/g2l/pta/sub.mk | 4 - core/arch/arm/plat-rz/g2l/rzg2l_conf.mk | 6 +- core/arch/arm/plat-rz/g2l/rzg2l_config.h | 2 + core/arch/arm/plat-rz/g2l/sub.mk | 4 +- core/arch/arm/plat-rz/g3s/rzg3s_conf.mk | 7 +- core/arch/arm/plat-rz/g3s/rzg3s_config.h | 5 +- core/arch/arm/plat-rz/v2h/rzv2h_conf.mk | 5 +- 208 files changed, 34171 insertions(+), 20172 deletions(-) rename core/arch/arm/plat-rz/{g2l/hw_rng.c => common/drivers/hw_rng_rsip.c} (81%) create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/bsp_api.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/bsp_api.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/_c_o_p_y_r_i_g_h_t.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/bc_s.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/bdwn.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/closed.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/customdoxygen.css create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/deprecated.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_70f4ae3d95e230caee709338d5cd48f8.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_72482daf12d144eb113f7615a624153c.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_7b11827f91a01532ec10f9e54e954f98.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_7cd603f42365d62e5cba3cdfc864d9f2.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_7da8a3010a4727d5081fba68b4e7fa8d.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/doc.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/doxygen.css create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/doxygen.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dynsections.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/folderclosed.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/folderopen.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p___a_p_i.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p___a_p_i.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/index.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/jquery.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/logo_scaled.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/modules.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/modules.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/nav_f.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/nav_g.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/nav_h.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/navtree.css create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/navtree.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/navtreedata.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/navtreeindex0.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/navtreeindex1.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/open.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/pages.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/resize.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_0.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_0.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_1.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_1.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_2.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_2.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_3.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_3.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_4.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_4.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_5.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_5.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_6.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_6.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_7.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_7.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_8.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_8.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_9.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_9.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_a.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_a.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/classes_0.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/classes_0.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/close.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enums_0.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enums_0.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enumvalues_0.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enumvalues_0.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/functions_0.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/functions_0.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_0.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_0.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_1.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_1.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_2.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_2.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/mag_sel.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/nomatches.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_0.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_0.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_1.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_1.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_2.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_2.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search.css create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search_l.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search_m.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search_r.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/searchdata.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/typedefs_0.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/typedefs_0.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_0.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_0.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_1.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_1.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_2.html create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_2.js create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/splitbar.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/sync_off.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/sync_on.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/tab_a.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/tab_b.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/tab_h.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/tab_s.png create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/tabs.css create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/manual.md create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/inc/api/r_rsip_api.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/inc/instances/r_rsip.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_err.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_private.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_reg.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_util.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_aes.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_ecc.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_public.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_rsa.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_rzg3.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_sha.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/primitive/r_rsip_primitive.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_addr.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_cfg.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_otp.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_otp.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_private.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_wrapper.c create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_wrapper.h create mode 100644 core/arch/arm/plat-rz/common/drivers/r_rsip/sub.mk create mode 100644 core/arch/arm/plat-rz/common/drivers/rsip.c rename core/arch/arm/plat-rz/{g2l => common}/drivers/spi_multi/AT25QL128A/spi_multi_device.c (100%) rename core/arch/arm/plat-rz/{g2l => common}/drivers/spi_multi/AT25QL128A/spi_multi_reg_values.h (100%) rename core/arch/arm/plat-rz/{g2l => common}/drivers/spi_multi/AT25QL128A/sub.mk (100%) rename core/arch/arm/plat-rz/{g2l => common}/drivers/spi_multi/MT25QU512ABB/spi_multi_device.c (100%) rename core/arch/arm/plat-rz/{g2l => common}/drivers/spi_multi/MT25QU512ABB/spi_multi_reg_values.h (100%) rename core/arch/arm/plat-rz/{g2l => common}/drivers/spi_multi/MT25QU512ABB/sub.mk (100%) rename core/arch/arm/plat-rz/{g2l => common}/drivers/spi_multi/spi_multi.c (100%) rename core/arch/arm/plat-rz/{g2l => common}/drivers/spi_multi/spi_multi.h (100%) rename core/arch/arm/plat-rz/{g2l => common}/drivers/spi_multi/spi_multi_device.h (100%) rename core/arch/arm/plat-rz/{g2l => common}/drivers/spi_multi/spi_multi_regs.h (100%) rename core/arch/arm/plat-rz/{g2l => common}/drivers/spi_multi/sub.mk (100%) create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip.h create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_aes.h rename core/arch/arm/plat-rz/{g2l/pta/include/pta_sce_ecc.h => common/pta/rsip/include/pta_rsip_ecc.h} (54%) create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_hmac.h create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_rsa.h create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_sha.h create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/include/r_rsip_api.h create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/pta_rsip.c create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_aes.c create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_ecc.c create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_hmac.c create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_rsa.c create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_sha.c create mode 100644 core/arch/arm/plat-rz/common/pta/rsip/sub.mk rename core/arch/arm/plat-rz/common/pta/{ => tsip}/include/pta_sce.h (100%) rename core/arch/arm/plat-rz/common/pta/{ => tsip}/include/pta_sce_aes.h (100%) rename core/arch/arm/plat-rz/common/pta/{ => tsip}/include/pta_sce_ecc.h (100%) rename core/arch/arm/plat-rz/common/pta/{ => tsip}/include/pta_sce_rsa.h (100%) rename core/arch/arm/plat-rz/common/pta/{ => tsip}/include/pta_sce_sha.h (70%) rename core/arch/arm/plat-rz/common/pta/{ => tsip}/pta_sce.c (100%) rename core/arch/arm/plat-rz/common/pta/{ => tsip}/pta_sce_aes.c (100%) rename core/arch/arm/plat-rz/common/pta/{ => tsip}/pta_sce_ecc.c (100%) rename core/arch/arm/plat-rz/common/pta/{ => tsip}/pta_sce_rsa.c (100%) rename core/arch/arm/plat-rz/common/pta/{ => tsip}/pta_sce_sha.c (100%) create mode 100644 core/arch/arm/plat-rz/common/pta/tsip/sub.mk delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/r_sce/README.md delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/r_sce/inc/api/r_sce_api.h delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/r_sce/inc/instances/r_sce.h delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/r_sce/private/inc/r_sce_private.h delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/r_sce/private/r_sce_private.c delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce.c delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_aes.c delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_ecc.c delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_rsa.c delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_sha.c delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/r_sce/sub.mk delete mode 100644 core/arch/arm/plat-rz/g2l/drivers/sce.c delete mode 100644 core/arch/arm/plat-rz/g2l/pta/include/pta_flash.h delete mode 100644 core/arch/arm/plat-rz/g2l/pta/include/pta_sce.h delete mode 100644 core/arch/arm/plat-rz/g2l/pta/include/pta_sce_aes.h delete mode 100644 core/arch/arm/plat-rz/g2l/pta/include/pta_sce_rsa.h delete mode 100644 core/arch/arm/plat-rz/g2l/pta/include/pta_sce_sha.h delete mode 100644 core/arch/arm/plat-rz/g2l/pta/pta_flash.c delete mode 100644 core/arch/arm/plat-rz/g2l/pta/pta_sce.c delete mode 100644 core/arch/arm/plat-rz/g2l/pta/pta_sce_aes.c delete mode 100644 core/arch/arm/plat-rz/g2l/pta/pta_sce_ecc.c delete mode 100644 core/arch/arm/plat-rz/g2l/pta/pta_sce_rsa.c delete mode 100644 core/arch/arm/plat-rz/g2l/pta/pta_sce_sha.c delete mode 100644 core/arch/arm/plat-rz/g2l/pta/sub.mk diff --git a/core/arch/arm/plat-rz/g2l/hw_rng.c b/core/arch/arm/plat-rz/common/drivers/hw_rng_rsip.c similarity index 81% rename from core/arch/arm/plat-rz/g2l/hw_rng.c rename to core/arch/arm/plat-rz/common/drivers/hw_rng_rsip.c index 1efb6ffd4..42d809f57 100644 --- a/core/arch/arm/plat-rz/g2l/hw_rng.c +++ b/core/arch/arm/plat-rz/common/drivers/hw_rng_rsip.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: BSD-2-Clause /* - * Copyright (c) 2021, Renesas Electronics + * Copyright (c) 2024, Renesas Electronics */ #include @@ -11,9 +11,11 @@ #include #include -#include +#include #include +extern rsip_instance_ctrl_t rsip_instance_ctrl; + #define LOCAL_BUFFER_SIZE (16) static uint32_t buffer[LOCAL_BUFFER_SIZE / sizeof(uint32_t)]; @@ -29,12 +31,15 @@ static TEE_Result random_number_generator(uint32_t *rand, size_t size) for (n = 0; n < size; n += rand_sz) { - err = g_sce_protected_on_sce.randomNumberGenerate(&rand[n]); + err = R_RSIP_RandomNumberGenerate( + &rsip_instance_ctrl, + (uint8_t * const)&rand[n] + ); switch (err) { case FSP_SUCCESS: break; - default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ + default: return TEE_ERROR_BUSY; } } diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/bsp_api.c b/core/arch/arm/plat-rz/common/drivers/r_rsip/bsp_api.c new file mode 100644 index 000000000..b1d6c3092 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/bsp_api.c @@ -0,0 +1,74 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "bsp_api.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ +#if defined(__GNUC__) + #define WEAK_ERROR_ATTRIBUTE __attribute__((weak, alias("fsp_error_log_internal"))) +#endif + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ +#if ((1 == BSP_CFG_ERROR_LOG) || (1 == BSP_CFG_ASSERT)) + +/** Prototype of function called before errors are returned in FSP code if BSP_CFG_ERROR_LOG is set to 1. This + * prototype sets the weak association of this function to an internal example implementation. */ +void fsp_error_log(fsp_err_t err, const char * file, int32_t line) WEAK_ERROR_ATTRIBUTE; + +void fsp_error_log_internal(fsp_err_t err, const char * file, int32_t line); /// Default error logger function + +#endif + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Default error logger function, used only if fsp_error_log is not defined in the user application. + * + * @param[in] err The error code encountered. + * @param[in] file The file name in which the error code was encountered. + * @param[in] line The line number at which the error code was encountered. + **********************************************************************************************************************/ +void fsp_error_log_internal (fsp_err_t err, const char * file, int32_t line) +{ + /** Do nothing. Do not generate any 'unused' warnings. */ + (void)err; + (void)file; + (void)line; +} diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/bsp_api.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/bsp_api.h new file mode 100644 index 000000000..0f5b90bc9 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/bsp_api.h @@ -0,0 +1,163 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +#ifndef BSP_API_H +#define BSP_API_H + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include +#include +#include + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ +/** Determine if a C++ compiler is being used. + * If so, ensure that standard C is used to process the API information. */ +/** FSP Header and Footer definitions */ +#define FSP_HEADER +#define FSP_FOOTER + +#define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline +#define __STDC_WANT_LIB_EXT1__ (0) +#define __ARM_BIG_ENDIAN (0) + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV(value) __builtin_bswap32(value) + +/** Specify what to do if FSP_ASSERT fails + * - 0 = Return FSP_ERR_ASSERTION. + * - 1 = Call fsp_error_log, then return FSP_ERR_ASSERTION. Note that fsp_error_log is a weak function and should be + * overridden in user code based on the prototype. + * - 2 = Use standard assert library to halt execution. + */ +#ifndef BSP_CFG_ASSERT + #define BSP_CFG_ASSERT (0) +#endif + +/** Specify what to do when error codes are returned from FSP functions + * - 0 = Return error code. + * - 1 = Call fsp_error_log, then return error code. Note that fsp_error_log is a weak function and should be + * overridden in user code based on the prototype. + */ +#ifndef BSP_CFG_ERROR_LOG + #define BSP_CFG_ERROR_LOG (0) +#endif + +/** This function is called before returning an error code. To stop on a runtime error, define fsp_error_log in + * user code and do required debugging (breakpoints, stack dump, etc) in this function.*/ +#if (1 == BSP_CFG_ERROR_LOG) + #ifndef FSP_ERROR_LOG + #define FSP_ERROR_LOG(err) \ + fsp_error_log((err), __FILE__, __LINE__); + #endif +#else + #define FSP_ERROR_LOG(err) +#endif + +/** Default assertion calls ::FSP_ERROR_RETURN if condition "a" is false. Used to identify incorrect use of API's in FSP + * functions. */ +#if (3 == BSP_CFG_ASSERT) + #define FSP_ASSERT(a) +#elif (2 == BSP_CFG_ASSERT) + #define FSP_ASSERT(a) {assert(a);} +#else + #define FSP_ASSERT(a) FSP_ERROR_RETURN((a), FSP_ERR_ASSERTION) +#endif // ifndef FSP_ASSERT + +/** All FSP error codes are returned using this macro. Calls ::FSP_ERROR_LOG function if condition "a" is false. Used + * to identify runtime errors in FSP functions. */ +#define FSP_ERROR_RETURN(a, err) \ + { \ + if ((a)) \ + { \ + (void) 0; /* Do nothing */ \ + } \ + else \ + { \ + FSP_ERROR_LOG(err); \ + return err; \ + } \ + } + +/* Return error codes fsp */ +typedef enum e_fsp_err +{ + FSP_SUCCESS = 0, + + FSP_ERR_ASSERTION = 1, ///< A critical assertion has failed + FSP_ERR_INVALID_POINTER = 2, ///< Pointer points to invalid memory location + FSP_ERR_INVALID_ARGUMENT = 3, ///< Invalid input parameter + FSP_ERR_INVALID_CHANNEL = 4, ///< Selected channel does not exist + FSP_ERR_INVALID_MODE = 5, ///< Unsupported or incorrect mode + FSP_ERR_UNSUPPORTED = 6, ///< Selected mode not supported by this API + FSP_ERR_NOT_OPEN = 7, ///< Requested channel is not configured or API not open + FSP_ERR_IN_USE = 8, ///< Channel/peripheral is running/busy + FSP_ERR_OUT_OF_MEMORY = 9, ///< Allocate more memory in the driver's cfg.h + FSP_ERR_HW_LOCKED = 10, ///< Hardware is locked + FSP_ERR_IRQ_BSP_DISABLED = 11, ///< IRQ not enabled in BSP + FSP_ERR_OVERFLOW = 12, ///< Hardware overflow + FSP_ERR_UNDERFLOW = 13, ///< Hardware underflow + FSP_ERR_ALREADY_OPEN = 14, ///< Requested channel is already open in a different configuration + FSP_ERR_APPROXIMATION = 15, ///< Could not set value to exact result + FSP_ERR_CLAMPED = 16, ///< Value had to be limited for some reason + FSP_ERR_INVALID_RATE = 17, ///< Selected rate could not be met + FSP_ERR_ABORTED = 18, ///< An operation was aborted + FSP_ERR_NOT_ENABLED = 19, ///< Requested operation is not enabled + FSP_ERR_TIMEOUT = 20, ///< Timeout error + FSP_ERR_INVALID_BLOCKS = 21, ///< Invalid number of blocks supplied + FSP_ERR_INVALID_ADDRESS = 22, ///< Invalid address supplied + FSP_ERR_INVALID_SIZE = 23, ///< Invalid size/length supplied for operation + FSP_ERR_WRITE_FAILED = 24, ///< Write operation failed + FSP_ERR_ERASE_FAILED = 25, ///< Erase operation failed + FSP_ERR_INVALID_CALL = 26, ///< Invalid function call is made + FSP_ERR_INVALID_HW_CONDITION = 27, ///< Detected hardware is in invalid condition + FSP_ERR_INVALID_FACTORY_FLASH = 28, ///< Factory flash is not available on this MCU + FSP_ERR_INVALID_STATE = 30, ///< API or command not valid in the current state + FSP_ERR_NOT_ERASED = 31, ///< Erase verification failed + FSP_ERR_SECTOR_RELEASE_FAILED = 32, ///< Sector release failed + FSP_ERR_NOT_INITIALIZED = 33, ///< Required initialization not complete + FSP_ERR_NOT_FOUND = 34, ///< The requested item could not be found + FSP_ERR_NO_CALLBACK_MEMORY = 35, ///< Non-secure callback memory not provided for non-secure callback + FSP_ERR_BUFFER_EMPTY = 36, ///< No data available in buffer +} fsp_err_t; + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Exported global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Exported global functions (to be accessed by other files) + **********************************************************************************************************************/ + +extern void fsp_error_log (fsp_err_t err, const char * file, int32_t line); + +#endif /* BSP_API_H */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/_c_o_p_y_r_i_g_h_t.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/_c_o_p_y_r_i_g_h_t.html new file mode 100644 index 000000000..4673c939e --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/_c_o_p_y_r_i_g_h_t.html @@ -0,0 +1,114 @@ + + + + + + + +R_RSIP Documentation: Copyright + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
Copyright
+
+
+

Copyright [2020-2024] Renesas Electronics Corporation and/or its affiliates. All Rights Reserved.

+

This software and documentation are supplied by Renesas Electronics Corporation and/or its affiliates. and may only be used with products of Renesas Electronics Corp. and its affiliates ("Renesas"). No other uses are authorized. Renesas products are sold pursuant to Renesas terms and conditions of sale. Purchasers are solely responsible for the selection and use of Renesas products and Renesas assumes no liability. No license, express or implied, to any intellectual property right is granted by Renesas. This software is protected under all applicable laws, including copyright laws. Renesas reserves the right to change or discontinue this software and/or this documentation. THE SOFTWARE AND DOCUMENTATION IS DELIVERED TO YOU "AS IS," AND RENESAS MAKES NO REPRESENTATIONS OR WARRANTIES, AND TO THE FULLEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW, DISCLAIMS ALL WARRANTIES, WHETHER EXPLICITLY OR IMPLICITLY, INCLUDING WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT, WITH RESPECT TO THE SOFTWARE OR DOCUMENTATION. RENESAS SHALL HAVE NO LIABILITY ARISING OUT OF ANY SECURITY VULNERABILITY OR BREACH. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT WILL RENESAS BE LIABLE TO YOU IN CONNECTION WITH THE SOFTWARE OR DOCUMENTATION (OR ANY PERSON OR ENTITY CLAIMING RIGHTS DERIVED FROM YOU) FOR ANY LOSS, DAMAGES, OR CLAIMS WHATSOEVER, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, CONSEQUENTIAL, SPECIAL, INDIRECT, PUNITIVE, OR INCIDENTAL DAMAGES; ANY LOST PROFITS, OTHER ECONOMIC DAMAGE, PROPERTY DAMAGE, OR PERSONAL INJURY; AND EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS, DAMAGES, CLAIMS OR COSTS.

+
+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/bc_s.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/bc_s.png new file mode 100644 index 0000000000000000000000000000000000000000..224b29aa9847d5a4b3902efd602b7ddf7d33e6c2 GIT binary patch literal 676 zcmV;V0$crwP)y__>=_9%My z{n931IS})GlGUF8K#6VIbs%684A^L3@%PlP2>_sk`UWPq@f;rU*V%rPy_ekbhXT&s z(GN{DxFv}*vZp`F>S!r||M`I*nOwwKX+BC~3P5N3-)Y{65c;ywYiAh-1*hZcToLHK ztpl1xomJ+Yb}K(cfbJr2=GNOnT!UFA7Vy~fBz8?J>XHsbZoDad^8PxfSa0GDgENZS zuLCEqzb*xWX2CG*b&5IiO#NzrW*;`VC9455M`o1NBh+(k8~`XCEEoC1Ybwf;vr4K3 zg|EB<07?SOqHp9DhLpS&bzgo70I+ghB_#)K7H%AMU3v}xuyQq9&Bm~++VYhF09a+U zl7>n7Jjm$K#b*FONz~fj;I->Bf;ule1prFN9FovcDGBkpg>)O*-}eLnC{6oZHZ$o% zXKW$;0_{8hxHQ>l;_*HATI(`7t#^{$(zLe}h*mqwOc*nRY9=?Sx4OOeVIfI|0V(V2 zBrW#G7Ss9wvzr@>H*`r>zE z+e8bOBgqIgldUJlG(YUDviMB`9+DH8n-s9SXRLyJHO1!=wY^79WYZMTa(wiZ!zP66 zA~!21vmF3H2{ngD;+`6j#~6j;$*f*G_2ZD1E;9(yaw7d-QnSCpK(cR1zU3qU0000< KMNUMnLSTYoA~SLT literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/bdwn.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/bdwn.png new file mode 100644 index 0000000000000000000000000000000000000000..940a0b950443a0bb1b216ac03c45b8a16c955452 GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)H!3HEvS)PKZC{Gv1kP61Pb5HX&C2wk~_T1|%O$WD@{V-kvUwAr*{o@8{^CZMh(5KoB^r_<4^zF@3)Cp&&t3hdujKf f*?bjBoY!V+E))@{xMcbjXe@)LtDnm{r-UW|*e5JT literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/customdoxygen.css b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/customdoxygen.css new file mode 100644 index 000000000..d3c7e0478 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/customdoxygen.css @@ -0,0 +1,1429 @@ +/* The standard CSS for doxygen 1.8.7 */ +body, table, div, p, dl { + font: 400 14px / 22px calibri; +} + +img { + max-width: 900px; +} + +/* @group Heading Levels */ +h1.groupheader { + font-size: 150%; + border-top-left-radius: 0; + font-weight: bold; +} + +.title { + font: 400 14px / 28px calibri; + font-size: 250%; + font-weight: lighter; + margin: 10px 2px; + border: 0px solid black; + border-top: 0px solid black; + background-image: ; + width: ; + background-color: ; +} + +h2.groupheader { + border-bottom: 1px solid #879ECB; + color: #354C7B; + font-size: 150%; + font-weight: normal; + margin-top: 1.75em; + padding-top: 8px; + padding-bottom: 4px; + width: 100%; +} + +h3.groupheader { + font-size: 100%; +} + +h1, h2, h3, h4, h5, h6 { + -webkit-transition: text-shadow 0.5s linear; + -moz-transition: text-shadow 0.5s linear; + -ms-transition: text-shadow 0.5s linear; + -o-transition: text-shadow 0.5s linear; + transition: text-shadow 0.5s linear; + margin-top: 1em; + margin-right: 15px; + font-weight: lighter; +} + +h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { + text-shadow: 0 0 15px cyan; +} + +dt { + font-weight: bold; +} + +div.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; +} + +p.startli, p.startdd { + margin-top: 2px; +} + +p.starttd { + margin-top: 0px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +/* @end */ +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ +a { + color: #7D99D0; + font-weight: lighter; + text-decoration: none; + /*+border-radius: 0;*/ + -moz-border-radius: 0; + -webkit-border-radius: 0; + -khtml-border-radius: 0; + border-radius: 0; +} + +.contents a:visited { + color: #4665A2; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #9CAFD4; + color: #FFFFFF; + border: 1px double #869DCA; +} + +.contents a.qindexHL:visited { + color: #FFFFFF; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code, a.code:visited, a.line, a.line:visited { + color: #4665A2; +} + +a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { + color: #4665A2; +} + +/* @end */ +dl.el { + margin-left: -1cm; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; + font-family: monospace, fixed; + font-size: 105%; +} + +div.fragment { + padding: 4px 6px; + margin: 4px 8px 4px 2px; + background-color: #FBFCFD; + border: 1px solid #C4CFE5; +} + +div.line { + font-family: monospace, fixed; + font-size: 13px; + min-height: 13px; + line-height: 1.0; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; + /* Moz */ + white-space: -pre-wrap; + /* Opera 4-6 */ + white-space: -o-pre-wrap; + /* Opera 7 */ + white-space: pre-wrap; + /* CSS3 */ + word-wrap: break-word; + /* IE 5.5+ */ + text-indent: -53px; + padding-left: 53px; + padding-bottom: 0px; + margin: 0px; + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +div.line.glow { + background-color: cyan; + box-shadow: 0 0 10px cyan; +} + +span.lineno { + padding-right: 4px; + text-align: right; + border-right: 2px solid #0F0; + background-color: #E8E8E8; + white-space: pre; +} + +span.lineno a { + background-color: #D8D8D8; +} + +span.lineno a:hover { + background-color: #C8C8C8; +} + +div.ah { + background-color: black; + font-weight: bold; + color: #FFFFFF; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + box-shadow: 2px 2px 3px #999; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background-color: white; + color: black; + margin: 0; +} + +div.contents { + margin-top: 10px; + margin-left: 12px; + margin-right: 8px; +} + +td.indexkey { + background-color: #EBEFF6; + font-weight: bold; + border: 1px solid #C4CFE5; + margin: 2px 0px 2px 0; + padding: 2px 10px; + white-space: nowrap; + vertical-align: top; +} + +td.indexvalue { + background-color: #EBEFF6; + border: 1px solid #C4CFE5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #EEF1F7; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { +} + +img.formulaInl { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ +span.keyword { + color: #008000; +} + +span.keywordtype { + color: #604020; +} + +span.keywordflow { + color: #E08000; +} + +span.comment { + color: #800000; +} + +span.preprocessor { + color: #806020; +} + +span.stringliteral { + color: #002080; +} + +span.charliteral { + color: #008080; +} + +span.vhdldigit { + color: #FF00FF; +} + +span.vhdlchar { + color: #000000; +} + +span.vhdlkeyword { + color: #700070; +} + +span.vhdllogic { + color: #FF0000; +} + +blockquote { + background-color: #F7F8FB; + border-left: 2px solid #9CAFD4; + margin: 0 24px 0 4px; + padding: 0 12px 0 16px; +} + +/* @end */ +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #A3B4D7; +} + +th.dirtab { + background: #EBEFF6; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.memberdecls td, .fieldtable tr { + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +.memberdecls td.glow, .fieldtable tr.glow { + background-color: cyan; + box-shadow: 0 0 15px cyan; +} + +.mdescLeft, .mdescRight, .memItemLeft, .memItemRight, .memTemplItemLeft, +.memTemplItemRight, .memTemplParams { + background-color: #F9FAFC; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memSeparator { + border-bottom: 1px solid #DEE4F0; + line-height: 1px; + margin: 0px; + padding: 0px; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memItemRight { + width: 100%; +} + +.memTemplParams { + color: #4665A2; + white-space: nowrap; + font-size: 80%; +} + +/* @end */ +/* @group Member Details */ +/* Styles for detailed member documentation */ +.memtemplate { + font-size: 80%; + color: #4665A2; + font-weight: normal; + margin-left: 9px; +} + +.memnav { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.mempage { + width: 100%; +} + +.memitem { + padding: 0; + margin-bottom: 10px; + margin-right: 5px; + -webkit-transition: box-shadow 0.5s linear; + -moz-transition: box-shadow 0.5s linear; + -ms-transition: box-shadow 0.5s linear; + -o-transition: box-shadow 0.5s linear; + transition: box-shadow 0.5s linear; + display: table !important; + width: 100%; +} + +.memitem.glow { + box-shadow: 0 0 15px cyan; +} + +.memname { + font-weight: bold; + margin-left: 6px; +} + +.memname td { + vertical-align: bottom; +} + +.memproto, dl.reflist dt { + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 0px 6px 0px; + color: #253555; + font-weight: bold; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + background-image: url('nav_f.png'); + background-repeat: repeat-x; + background-color: #E2E8F2; + /* opera specific markup */ + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + border-top-right-radius: 4px; + border-top-left-radius: 4px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + -moz-border-radius-topright: 4px; + -moz-border-radius-topleft: 4px; + /* webkit specific markup */ + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 4px; + -webkit-border-top-left-radius: 4px; +} + +.memdoc, dl.reflist dd { + border-bottom: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 10px 2px 10px; + background-color: #FBFCFD; + border-top-width: 0; + background-image: url('nav_g.png'); + background-repeat: repeat-x; + background-color: #FFFFFF; + /* opera specific markup */ + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + /* firefox specific markup */ + -moz-border-radius-bottomleft: 4px; + -moz-border-radius-bottomright: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); +} + +dl.reflist dt { + padding: 5px; +} + +dl.reflist dd { + margin: 0px 0px 10px 0px; + padding: 5px; +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} + +.paramname em { + font-style: normal; +} + +.paramname code { + line-height: 14px; +} + +.params, .retval, .exception, .tparams { + margin-left: 0px; + padding-left: 0px; +} + +.params .paramname, .retval .paramname { + font-weight: bold; + vertical-align: top; +} + +.params .paramtype { + font-style: italic; + vertical-align: top; +} + +.params .paramdir { + font-family: "courier new", courier, monospace; + vertical-align: top; +} + +table.mlabels { + border-spacing: 0px; +} + +td.mlabels-left { + width: 100%; + padding: 0px; +} + +td.mlabels-right { + vertical-align: bottom; + padding: 0px; + white-space: nowrap; +} + +span.mlabels { + margin-left: 8px; +} + +span.mlabel { + background-color: #728DC1; + border-top: 1px solid #5373B4; + border-left: 1px solid #5373B4; + border-right: 1px solid #C4CFE5; + border-bottom: 1px solid #C4CFE5; + text-shadow: none; + color: white; + margin-right: 4px; + padding: 2px 3px; + border-radius: 3px; + font-size: 7pt; + white-space: nowrap; + vertical-align: middle; +} + +/* @end */ +/* these are for tree view inside a (index) page */ +div.directory { + margin: 10px 0px; + border-top: 1px solid #9CAFD4; + border-bottom: 1px solid #9CAFD4; + width: 100%; +} + +.directory table { + border-collapse: collapse; +} + +.directory td { + margin: 0px; + padding: 0px; + vertical-align: top; +} + +.directory td.entry { + white-space: nowrap; + padding-right: 6px; + padding-top: 3px; +} + +.directory td.entry a { + outline: none; +} + +.directory td.entry a img { + border: none; +} + +.directory td.desc { + width: 100%; + padding-left: 6px; + padding-right: 6px; + padding-top: 3px; + border-left: 1px solid rgba(0, 0, 0, 0.05); +} + +.directory tr.even { + padding-left: 6px; + background-color: #F7F8FB; +} + +.directory img { + vertical-align: -30%; +} + +.directory .levels { + white-space: nowrap; + width: 100%; + text-align: right; + font-size: 9pt; +} + +.directory .levels span { + cursor: pointer; + padding-left: 2px; + padding-right: 2px; + color: #3D578C; +} + +.arrow { + color: #9CAFD4; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + cursor: pointer; + font-size: 80%; + display: inline-block; + width: 16px; + height: 22px; +} + +.icon { + font-family: Arial, Helvetica; + font-weight: bold; + font-size: 12px; + height: 14px; + width: 16px; + display: inline-block; + background-color: #728DC1; + color: white; + text-align: center; + border-radius: 4px; + margin-left: 2px; + margin-right: 2px; +} + +.icona { + width: 24px; + height: 22px; + display: inline-block; +} + +.iconfopen { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image: url('ftv2folderopen.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align: top; + display: inline-block; +} + +.iconfclosed { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image: url('ftv2folderclosed.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align: top; + display: inline-block; +} + +.icondoc { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image: url('ftv2doc.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align: top; + display: inline-block; +} + +table.directory { + font: 400 14px Roboto, sans-serif; +} + +/* @end */ +div.dynheader { + margin-top: 8px; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +address { + font-style: normal; + color: #2A3D61; +} + +table.doxtable, table.markdownTable { + border-collapse: collapse; + margin-top: 4px; + margin-bottom: 4px; + height: ; + width: 90%; +} + +table.doxtable td, table.doxtable th, table.markdownTable td, table.markdownTable th { + border: 1px solid #9098A9; + padding: 3px 7px 2px; +} + +table.doxtable th, table.markdownTable th { + background-color: #CBCED2; + color: #35393F; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +table.fieldtable { + /*width: 100%;*/ + margin-bottom: 10px; + border: 1px solid #A8B8D9; + border-spacing: 0px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); + box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); +} + +.fieldtable td, .fieldtable th { + padding: 3px 7px 2px; +} + +.fieldtable td.fieldtype, .fieldtable td.fieldname { + white-space: nowrap; + border-right: 1px solid #A8B8D9; + border-bottom: 1px solid #A8B8D9; + vertical-align: top; +} + +.fieldtable td.fieldname { + padding-top: 3px; +} + +.fieldtable td.fielddoc { + border-bottom: 1px solid #A8B8D9; + /*width: 100%;*/ +} + +.fieldtable td.fielddoc p:first-child { + margin-top: 0px; +} + +.fieldtable td.fielddoc p:last-child { + margin-bottom: 2px; +} + +.fieldtable tr:last-child td { + border-bottom: none; +} + +.fieldtable th { + background-image: url('nav_f.png'); + background-repeat: repeat-x; + background-color: #E2E8F2; + font-size: 90%; + color: #253555; + padding-bottom: 4px; + padding-top: 5px; + text-align: left; + -moz-border-radius-topleft: 4px; + -moz-border-radius-topright: 4px; + -webkit-border-top-left-radius: 4px; + -webkit-border-top-right-radius: 4px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-bottom: 1px solid #A8B8D9; +} + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul { + font-size: 11px; + background-image: url('tab_b.png'); + background-repeat: repeat-x; + background-position: 0 -5px; + height: 30px; + line-height: 30px; + color: #8AA0CC; + border: solid 1px #C2CDE4; + overflow: hidden; + margin: 0px; + padding: 0px; +} + +.navpath li { + list-style-type: none; + float: left; + padding-left: 10px; + padding-right: 15px; + background-image: url('bc_s.png'); + background-repeat: no-repeat; + background-position: right; + color: #364D7C; +} + +.navpath li.navelem a { + height: 32px; + display: block; + text-decoration: none; + outline: none; + color: #283A5D; + font-family: 'Lucida Grande', Geneva, Helvetica, Arial, sans-serif; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + text-decoration: none; +} + +.navpath li.navelem a:hover { + color: #6884BD; +} + +.navpath li.footer { + list-style-type: none; + float: right; + padding-left: 10px; + padding-right: 15px; + background-image: none; + background-repeat: no-repeat; + background-position: right; + color: #364D7C; + font-size: 8pt; +} + +div.summary { + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a { + white-space: nowrap; +} + +div.ingroups { + font-size: 8pt; + width: 50%; + text-align: left; +} + +div.ingroups a { + white-space: nowrap; +} + +div.header { + background-image: url('nav_h.png'); + background-repeat: repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} + +div.headertitle { + padding: 5px 5px 5px 10px; +} + +dl { + padding: 0 0 0 10px; +} + +/* dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug */ +dl.section { + margin-left: 0px; + padding-left: 0px; +} + +dl.note { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #D0C000; +} + +dl.warning, dl.attention { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #FF0000; +} + +dl.pre, dl.post, dl.invariant { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #00D000; +} + +dl.deprecated { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #505050; +} + +dl.todo { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #00C0E0; +} + +dl.test { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #3030E0; +} + +dl.bug { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #C08050; +} + +dl.section dd { + margin-bottom: 6px; +} + +#projectlogo { + text-align: center; + vertical-align: bottom; + border-collapse: separate; +} + +#projectlogo img { + border: 0px none; +} + +#projectname { + font: 250% Tahoma, Arial, sans-serif; + margin: 0px; + padding: 2px 0px; +} + +#projectbrief { + font: 120% Tahoma, Arial, sans-serif; + margin: 0px; + padding: 0px; +} + +#projectnumber { + font: 50% Tahoma, Arial, sans-serif; + margin: 0px; + padding: 0px; +} + +#titlearea { + padding: 0px; + margin: 0px; + width: 100%; + border-bottom: 1px solid #5373B4; +} + +.image { + text-align: center; + margin-top: 40px; + margin-bottom: 32px; +} + +.dotgraph { + text-align: center; +} + +.mscgraph { + text-align: center; +} + +.diagraph { + text-align: center; +} + +.caption { + font-weight: bold; +} + +div.zoom { + border: 1px solid #90A5CE; +} + +dl.citelist { + margin-bottom: 50px; +} + +dl.citelist dt { + color: #334975; + float: left; + font-weight: bold; + margin-right: 10px; + padding: 5px; +} + +dl.citelist dd { + margin: 2px 0; + padding: 5px 0; +} + +div.toc { + padding: 14px 25px; + background-color: #F4F6FA; + border: 1px solid #D8DFEE; + border-radius: 7px 7px 7px 7px; + float: right; + height: auto; + margin: 0 20px 10px 10px; + width: 200px; +} + +div.toc li { + background: url("bdwn.png") no-repeat scroll 0 5px transparent; + font: 10px / 1.2 Verdana, DejaVu Sans, Geneva, sans-serif; + margin-top: 5px; + padding-left: 10px; + padding-top: 2px; +} + +div.toc h3 { + font: bold 12px / 1.2 Arial, FreeSans, sans-serif; + color: #4665A2; + border-bottom: 0 none; + margin: 0; +} + +div.toc ul { + list-style: none outside none; + border: medium none; + padding: 0px; +} + +div.toc li.level1 { + margin-left: 0px; +} + +div.toc li.level2 { + margin-left: 15px; +} + +div.toc li.level3 { + margin-left: 30px; +} + +div.toc li.level4 { + margin-left: 45px; +} + +.inherit_header { + font-weight: bold; + color: gray; + cursor: pointer; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.inherit_header td { + padding: 6px 0px 2px 5px; +} + +.inherit { + display: none; +} + +tr.heading h2 { + margin-top: 12px; + margin-bottom: 4px; +} + +/* tooltip related style info */ +.ttc { + position: absolute; + display: none; +} + +#powerTip { + cursor: default; + white-space: nowrap; + background-color: white; + border: 1px solid gray; + border-radius: 4px 4px 4px 4px; + box-shadow: 1px 1px 7px gray; + display: none; + font-size: smaller; + max-width: 80%; + opacity: 0.9; + padding: 1ex 1em 1em; + position: absolute; + z-index: 2147483647; +} + +#powerTip div.ttdoc { + color: grey; + font-style: italic; +} + +#powerTip div.ttname a { + font-weight: bold; +} + +#powerTip div.ttname { + font-weight: bold; +} + +#powerTip div.ttdeci { + color: #006318; +} + +#powerTip div { + margin: 0px; + padding: 0px; + font: 12px / 16px Roboto, sans-serif; +} + +#powerTip:before, #powerTip:after { + content: ""; + position: absolute; + margin: 0px; +} + +#powerTip.n:after, #powerTip.n:before, #powerTip.s:after, #powerTip.s:before, +#powerTip.w:after, #powerTip.w:before, #powerTip.e:after, #powerTip.e:before, +#powerTip.ne:after, #powerTip.ne:before, #powerTip.se:after, +#powerTip.se:before, #powerTip.nw:after, #powerTip.nw:before, +#powerTip.sw:after, #powerTip.sw:before { + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; +} + +#powerTip.n:after, #powerTip.s:after, #powerTip.w:after, #powerTip.e:after, +#powerTip.nw:after, #powerTip.ne:after, #powerTip.sw:after, #powerTip.se:after { + border-color: rgba(255, 255, 255, 0); +} + +#powerTip.n:before, #powerTip.s:before, #powerTip.w:before, #powerTip.e:before, +#powerTip.nw:before, #powerTip.ne:before, #powerTip.sw:before, +#powerTip.se:before { + border-color: rgba(128, 128, 128, 0); +} + +#powerTip.n:after, #powerTip.n:before, #powerTip.ne:after, #powerTip.ne:before, +#powerTip.nw:after, #powerTip.nw:before { + top: 100%; +} + +#powerTip.n:after, #powerTip.ne:after, #powerTip.nw:after { + border-top-color: #FFFFFF; + border-width: 10px; + margin: 0px -10px; +} + +#powerTip.n:before { + border-top-color: #808080; + border-width: 11px; + margin: 0px -11px; +} + +#powerTip.n:after, #powerTip.n:before { + left: 50%; +} + +#powerTip.nw:after, #powerTip.nw:before { + right: 14px; +} + +#powerTip.ne:after, #powerTip.ne:before { + left: 14px; +} + +#powerTip.s:after, #powerTip.s:before, #powerTip.se:after, #powerTip.se:before, +#powerTip.sw:after, #powerTip.sw:before { + bottom: 100%; +} + +#powerTip.s:after, #powerTip.se:after, #powerTip.sw:after { + border-bottom-color: #FFFFFF; + border-width: 10px; + margin: 0px -10px; +} + +#powerTip.s:before, #powerTip.se:before, #powerTip.sw:before { + border-bottom-color: #808080; + border-width: 11px; + margin: 0px -11px; +} + +#powerTip.s:after, #powerTip.s:before { + left: 50%; +} + +#powerTip.sw:after, #powerTip.sw:before { + right: 14px; +} + +#powerTip.se:after, #powerTip.se:before { + left: 14px; +} + +#powerTip.e:after, #powerTip.e:before { + left: 100%; +} + +#powerTip.e:after { + border-left-color: #FFFFFF; + border-width: 10px; + top: 50%; + margin-top: -10px; +} + +#powerTip.e:before { + border-left-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +#powerTip.w:after, #powerTip.w:before { + right: 100%; +} + +#powerTip.w:after { + border-right-color: #FFFFFF; + border-width: 10px; + top: 50%; + margin-top: -10px; +} + +#powerTip.w:before { + border-right-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +@media print { + #top { + display: none; + } + + #side-nav { + display: none; + } + + #nav-path { + display: none; + } + + body { + overflow: visible; + } + + h1, h2, h3, h4, h5, h6 { + page-break-after: avoid; + } + + .summary { + display: none; + } + + .memitem { + page-break-inside: avoid; + } + + #doc-content { + margin-left: 0 !important; + height: auto !important; + width: auto !important; + overflow: inherit; + display: inline; + } +} diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/deprecated.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/deprecated.html new file mode 100644 index 000000000..393f8bd2a --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/deprecated.html @@ -0,0 +1,206 @@ + + + + + + + +R_RSIP Documentation: Deprecated List + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
Deprecated List
+
+
+
+
Global e_rsip_byte_size_encrypted_key
+
+
+
Global e_rsip_byte_size_wrapped_key
+
+
+
Global e_rsip_byte_size_wrapped_key_value
+
+
+
Global e_rsip_key_pair_type
+
+
+
Global e_rsip_key_type
+
+
+
+
+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_70f4ae3d95e230caee709338d5cd48f8.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_70f4ae3d95e230caee709338d5cd48f8.html new file mode 100644 index 000000000..1abed6644 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_70f4ae3d95e230caee709338d5cd48f8.html @@ -0,0 +1,112 @@ + + + + + + + +R_RSIP Documentation: instances Directory Reference + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
instances Directory Reference
+
+
+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_72482daf12d144eb113f7615a624153c.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_72482daf12d144eb113f7615a624153c.html new file mode 100644 index 000000000..5d74ae0cf --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_72482daf12d144eb113f7615a624153c.html @@ -0,0 +1,112 @@ + + + + + + + +R_RSIP Documentation: api Directory Reference + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
api Directory Reference
+
+
+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_7b11827f91a01532ec10f9e54e954f98.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_7b11827f91a01532ec10f9e54e954f98.html new file mode 100644 index 000000000..2b07cc9d0 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_7b11827f91a01532ec10f9e54e954f98.html @@ -0,0 +1,116 @@ + + + + + + + +R_RSIP Documentation: inc Directory Reference + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
inc Directory Reference
+
+
+ + +

+Directories

+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_7cd603f42365d62e5cba3cdfc864d9f2.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_7cd603f42365d62e5cba3cdfc864d9f2.html new file mode 100644 index 000000000..7eb9ed582 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_7cd603f42365d62e5cba3cdfc864d9f2.html @@ -0,0 +1,112 @@ + + + + + + + +R_RSIP Documentation: public Directory Reference + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
public Directory Reference
+
+
+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_7da8a3010a4727d5081fba68b4e7fa8d.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_7da8a3010a4727d5081fba68b4e7fa8d.html new file mode 100644 index 000000000..eb8bcaeb9 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dir_7da8a3010a4727d5081fba68b4e7fa8d.html @@ -0,0 +1,118 @@ + + + + + + + +R_RSIP Documentation: rsip_common Directory Reference + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
rsip_common Directory Reference
+
+
+ + + + +

+Directories

directory  inc
 
+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/doc.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/doc.png new file mode 100644 index 0000000000000000000000000000000000000000..17edabff95f7b8da13c9516a04efe05493c29501 GIT binary patch literal 746 zcmV7=@pnbNXRFEm&G8P!&WHG=d)>K?YZ1bzou)2{$)) zumDct!>4SyxL;zgaG>wy`^Hv*+}0kUfCrz~BCOViSb$_*&;{TGGn2^x9K*!Sf0=lV zpP=7O;GA0*Jm*tTYj$IoXvimpnV4S1Z5f$p*f$Db2iq2zrVGQUz~yq`ahn7ck(|CE z7Gz;%OP~J6)tEZWDzjhL9h2hdfoU2)Nd%T<5Kt;Y0XLt&<@6pQx!nw*5`@bq#?l*?3z{Hlzoc=Pr>oB5(9i6~_&-}A(4{Q$>c>%rV&E|a(r&;?i5cQB=} zYSDU5nXG)NS4HEs0it2AHe2>shCyr7`6@4*6{r@8fXRbTA?=IFVWAQJL&H5H{)DpM#{W(GL+Idzf^)uRV@oB8u$ z8v{MfJbTiiRg4bza<41NAzrl{=3fl_D+$t+^!xlQ8S}{UtY`e z;;&9UhyZqQRN%2pot{*Ei0*4~hSF_3AH2@fKU!$NSflS>{@tZpDT4`M2WRTTVH+D? z)GFlEGGHe?koB}i|1w45!BF}N_q&^HJ&-tyR{(afC6H7|aml|tBBbv}55C5DNP8p3 z)~jLEO4Z&2hZmP^i-e%(@d!(E|KRafiU8Q5u(wU((j8un3OR*Hvj+t literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/doxygen.css b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/doxygen.css new file mode 100644 index 000000000..73ecbb2cb --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/doxygen.css @@ -0,0 +1,1771 @@ +/* The standard CSS for doxygen 1.8.17 */ + +body, table, div, p, dl { + font: 400 14px/22px Roboto,sans-serif; +} + +p.reference, p.definition { + font: 400 14px/22px Roboto,sans-serif; +} + +/* @group Heading Levels */ + +h1.groupheader { + font-size: 150%; +} + +.title { + font: 400 14px/28px Roboto,sans-serif; + font-size: 150%; + font-weight: bold; + margin: 10px 2px; +} + +h2.groupheader { + border-bottom: 1px solid #879ECB; + color: #354C7B; + font-size: 150%; + font-weight: normal; + margin-top: 1.75em; + padding-top: 8px; + padding-bottom: 4px; + width: 100%; +} + +h3.groupheader { + font-size: 100%; +} + +h1, h2, h3, h4, h5, h6 { + -webkit-transition: text-shadow 0.5s linear; + -moz-transition: text-shadow 0.5s linear; + -ms-transition: text-shadow 0.5s linear; + -o-transition: text-shadow 0.5s linear; + transition: text-shadow 0.5s linear; + margin-right: 15px; +} + +h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { + text-shadow: 0 0 15px cyan; +} + +dt { + font-weight: bold; +} + +ul.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; + column-count: 3; +} + +p.startli, p.startdd { + margin-top: 2px; +} + +th p.starttd, p.intertd, p.endtd { + font-size: 100%; + font-weight: 700; +} + +p.starttd { + margin-top: 0px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +p.interli { +} + +p.interdd { +} + +p.intertd { +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab{ + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #4665A2; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #9CAFD4; + color: #FFFFFF; + border: 1px double #869DCA; +} + +.contents a.qindexHL:visited { + color: #FFFFFF; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code, a.code:visited, a.line, a.line:visited { + color: #4665A2; +} + +a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { + color: #4665A2; +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +ul { + overflow: hidden; /*Fixed: list item bullets overlap floating elements*/ +} + +#side-nav ul { + overflow: visible; /* reset ul rule for scroll bar in GENERATE_TREEVIEW window */ +} + +#main-nav ul { + overflow: visible; /* reset ul rule for the navigation bar drop down lists */ +} + +.fragment { + text-align: left; + direction: ltr; + overflow-x: auto; /*Fixed: fragment lines overlap floating elements*/ + overflow-y: hidden; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; + font-family: monospace, fixed; + font-size: 105%; +} + +div.fragment { + padding: 0 0 1px 0; /*Fixed: last line underline overlap border*/ + margin: 4px 8px 4px 2px; + background-color: #FBFCFD; + border: 1px solid #C4CFE5; +} + +div.line { + font-family: monospace, fixed; + font-size: 13px; + min-height: 13px; + line-height: 1.0; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; /* Moz */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + white-space: pre-wrap; /* CSS3 */ + word-wrap: break-word; /* IE 5.5+ */ + text-indent: -53px; + padding-left: 53px; + padding-bottom: 0px; + margin: 0px; + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +div.line:after { + content:"\000A"; + white-space: pre; +} + +div.line.glow { + background-color: cyan; + box-shadow: 0 0 10px cyan; +} + + +span.lineno { + padding-right: 4px; + text-align: right; + border-right: 2px solid #0F0; + background-color: #E8E8E8; + white-space: pre; +} +span.lineno a { + background-color: #D8D8D8; +} + +span.lineno a:hover { + background-color: #C8C8C8; +} + +.lineno { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +div.ah, span.ah { + background-color: black; + font-weight: bold; + color: #FFFFFF; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + box-shadow: 2px 2px 3px #999; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000 110%); +} + +div.classindex ul { + list-style: none; + padding-left: 0; +} + +div.classindex span.ai { + display: inline-block; +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background-color: white; + color: black; + margin: 0; +} + +div.contents { + margin-top: 10px; + margin-left: 12px; + margin-right: 8px; +} + +td.indexkey { + background-color: #EBEFF6; + font-weight: bold; + border: 1px solid #C4CFE5; + margin: 2px 0px 2px 0; + padding: 2px 10px; + white-space: nowrap; + vertical-align: top; +} + +td.indexvalue { + background-color: #EBEFF6; + border: 1px solid #C4CFE5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #EEF1F7; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { + +} + +img.formulaInl, img.inline { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ + +span.keyword { + color: #008000 +} + +span.keywordtype { + color: #604020 +} + +span.keywordflow { + color: #e08000 +} + +span.comment { + color: #800000 +} + +span.preprocessor { + color: #806020 +} + +span.stringliteral { + color: #002080 +} + +span.charliteral { + color: #008080 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +blockquote { + background-color: #F7F8FB; + border-left: 2px solid #9CAFD4; + margin: 0 24px 0 4px; + padding: 0 12px 0 16px; +} + +blockquote.DocNodeRTL { + border-left: 0; + border-right: 2px solid #9CAFD4; + margin: 0 4px 0 24px; + padding: 0 16px 0 12px; +} + +/* @end */ + +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #A3B4D7; +} + +th.dirtab { + background: #EBEFF6; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.memberdecls td, .fieldtable tr { + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +.memberdecls td.glow, .fieldtable tr.glow { + background-color: cyan; + box-shadow: 0 0 15px cyan; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #F9FAFC; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memSeparator { + border-bottom: 1px solid #DEE4F0; + line-height: 1px; + margin: 0px; + padding: 0px; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memItemRight, .memTemplItemRight { + width: 100%; +} + +.memTemplParams { + color: #4665A2; + white-space: nowrap; + font-size: 80%; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtitle { + padding: 8px; + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + border-top-right-radius: 4px; + border-top-left-radius: 4px; + margin-bottom: -1px; + background-image: url('nav_f.png'); + background-repeat: repeat-x; + background-color: #E2E8F2; + line-height: 1.25; + font-weight: 300; + float:left; +} + +.permalink +{ + font-size: 65%; + display: inline-block; + vertical-align: middle; +} + +.memtemplate { + font-size: 80%; + color: #4665A2; + font-weight: normal; + margin-left: 9px; +} + +.memnav { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.mempage { + width: 100%; +} + +.memitem { + padding: 0; + margin-bottom: 10px; + margin-right: 5px; + -webkit-transition: box-shadow 0.5s linear; + -moz-transition: box-shadow 0.5s linear; + -ms-transition: box-shadow 0.5s linear; + -o-transition: box-shadow 0.5s linear; + transition: box-shadow 0.5s linear; + display: table !important; + width: 100%; +} + +.memitem.glow { + box-shadow: 0 0 15px cyan; +} + +.memname { + font-weight: 400; + margin-left: 6px; +} + +.memname td { + vertical-align: bottom; +} + +.memproto, dl.reflist dt { + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 0px 6px 0px; + color: #253555; + font-weight: bold; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + background-color: #DFE5F1; + /* opera specific markup */ + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + border-top-right-radius: 4px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + -moz-border-radius-topright: 4px; + /* webkit specific markup */ + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 4px; + +} + +.overload { + font-family: "courier new",courier,monospace; + font-size: 65%; +} + +.memdoc, dl.reflist dd { + border-bottom: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 10px 2px 10px; + background-color: #FBFCFD; + border-top-width: 0; + background-image:url('nav_g.png'); + background-repeat:repeat-x; + background-color: #FFFFFF; + /* opera specific markup */ + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + /* firefox specific markup */ + -moz-border-radius-bottomleft: 4px; + -moz-border-radius-bottomright: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); +} + +dl.reflist dt { + padding: 5px; +} + +dl.reflist dd { + margin: 0px 0px 10px 0px; + padding: 5px; +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} +.paramname code { + line-height: 14px; +} + +.params, .retval, .exception, .tparams { + margin-left: 0px; + padding-left: 0px; +} + +.params .paramname, .retval .paramname, .tparams .paramname, .exception .paramname { + font-weight: bold; + vertical-align: top; +} + +.params .paramtype, .tparams .paramtype { + font-style: italic; + vertical-align: top; +} + +.params .paramdir, .tparams .paramdir { + font-family: "courier new",courier,monospace; + vertical-align: top; +} + +table.mlabels { + border-spacing: 0px; +} + +td.mlabels-left { + width: 100%; + padding: 0px; +} + +td.mlabels-right { + vertical-align: bottom; + padding: 0px; + white-space: nowrap; +} + +span.mlabels { + margin-left: 8px; +} + +span.mlabel { + background-color: #728DC1; + border-top:1px solid #5373B4; + border-left:1px solid #5373B4; + border-right:1px solid #C4CFE5; + border-bottom:1px solid #C4CFE5; + text-shadow: none; + color: white; + margin-right: 4px; + padding: 2px 3px; + border-radius: 3px; + font-size: 7pt; + white-space: nowrap; + vertical-align: middle; +} + + + +/* @end */ + +/* these are for tree view inside a (index) page */ + +div.directory { + margin: 10px 0px; + border-top: 1px solid #9CAFD4; + border-bottom: 1px solid #9CAFD4; + width: 100%; +} + +.directory table { + border-collapse:collapse; +} + +.directory td { + margin: 0px; + padding: 0px; + vertical-align: top; +} + +.directory td.entry { + white-space: nowrap; + padding-right: 6px; + padding-top: 3px; +} + +.directory td.entry a { + outline:none; +} + +.directory td.entry a img { + border: none; +} + +.directory td.desc { + width: 100%; + padding-left: 6px; + padding-right: 6px; + padding-top: 3px; + border-left: 1px solid rgba(0,0,0,0.05); +} + +.directory tr.even { + padding-left: 6px; + background-color: #F7F8FB; +} + +.directory img { + vertical-align: -30%; +} + +.directory .levels { + white-space: nowrap; + width: 100%; + text-align: right; + font-size: 9pt; +} + +.directory .levels span { + cursor: pointer; + padding-left: 2px; + padding-right: 2px; + color: #3D578C; +} + +.arrow { + color: #9CAFD4; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + cursor: pointer; + font-size: 80%; + display: inline-block; + width: 16px; + height: 22px; +} + +.icon { + font-family: Arial, Helvetica; + font-weight: bold; + font-size: 12px; + height: 14px; + width: 16px; + display: inline-block; + background-color: #728DC1; + color: white; + text-align: center; + border-radius: 4px; + margin-left: 2px; + margin-right: 2px; +} + +.icona { + width: 24px; + height: 22px; + display: inline-block; +} + +.iconfopen { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('folderopen.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +.iconfclosed { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('folderclosed.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +.icondoc { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('doc.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +table.directory { + font: 400 14px Roboto,sans-serif; +} + +/* @end */ + +div.dynheader { + margin-top: 8px; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +address { + font-style: normal; + color: #2A3D61; +} + +table.doxtable caption { + caption-side: top; +} + +table.doxtable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +table.fieldtable { + /*width: 100%;*/ + margin-bottom: 10px; + border: 1px solid #A8B8D9; + border-spacing: 0px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); + box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); +} + +.fieldtable td, .fieldtable th { + padding: 3px 7px 2px; +} + +.fieldtable td.fieldtype, .fieldtable td.fieldname { + white-space: nowrap; + border-right: 1px solid #A8B8D9; + border-bottom: 1px solid #A8B8D9; + vertical-align: top; +} + +.fieldtable td.fieldname { + padding-top: 3px; +} + +.fieldtable td.fielddoc { + border-bottom: 1px solid #A8B8D9; + /*width: 100%;*/ +} + +.fieldtable td.fielddoc p:first-child { + margin-top: 0px; +} + +.fieldtable td.fielddoc p:last-child { + margin-bottom: 2px; +} + +.fieldtable tr:last-child td { + border-bottom: none; +} + +.fieldtable th { + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + font-size: 90%; + color: #253555; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; + font-weight: 400; + -moz-border-radius-topleft: 4px; + -moz-border-radius-topright: 4px; + -webkit-border-top-left-radius: 4px; + -webkit-border-top-right-radius: 4px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-bottom: 1px solid #A8B8D9; +} + + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image:url('tab_b.png'); + background-repeat:repeat-x; + background-position: 0 -5px; + height:30px; + line-height:30px; + color:#8AA0CC; + border:solid 1px #C2CDE4; + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right:15px; + background-image:url('bc_s.png'); + background-repeat:no-repeat; + background-position:right; + color:#364D7C; +} + +.navpath li.navelem a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; + color: #283A5D; + font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + text-decoration: none; +} + +.navpath li.navelem a:hover +{ + color:#6884BD; +} + +.navpath li.footer +{ + list-style-type:none; + float:right; + padding-left:10px; + padding-right:15px; + background-image:none; + background-repeat:no-repeat; + background-position:right; + color:#364D7C; + font-size: 8pt; +} + + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +table.classindex +{ + margin: 10px; + white-space: nowrap; + margin-left: 3%; + margin-right: 3%; + width: 94%; + border: 0; + border-spacing: 0; + padding: 0; +} + +div.ingroups +{ + font-size: 8pt; + width: 50%; + text-align: left; +} + +div.ingroups a +{ + white-space: nowrap; +} + +div.header +{ + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} + +div.headertitle +{ + padding: 5px 5px 5px 10px; +} + +.PageDocRTL-title div.headertitle { + text-align: right; + direction: rtl; +} + +dl { + padding: 0 0 0 0; +} + +/* dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug, dl.examples */ +dl.section { + margin-left: 0px; + padding-left: 0px; +} + +dl.section.DocNodeRTL { + margin-right: 0px; + padding-right: 0px; +} + +dl.note { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #D0C000; +} + +dl.note.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #D0C000; +} + +dl.warning, dl.attention { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #FF0000; +} + +dl.warning.DocNodeRTL, dl.attention.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #FF0000; +} + +dl.pre, dl.post, dl.invariant { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #00D000; +} + +dl.pre.DocNodeRTL, dl.post.DocNodeRTL, dl.invariant.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #00D000; +} + +dl.deprecated { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #505050; +} + +dl.deprecated.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #505050; +} + +dl.todo { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #00C0E0; +} + +dl.todo.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #00C0E0; +} + +dl.test { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #3030E0; +} + +dl.test.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #3030E0; +} + +dl.bug { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #C08050; +} + +dl.bug.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #C08050; +} + +dl.section dd { + margin-bottom: 6px; +} + + +#projectlogo +{ + text-align: center; + vertical-align: bottom; + border-collapse: separate; +} + +#projectlogo img +{ + border: 0px none; +} + +#projectalign +{ + vertical-align: middle; +} + +#projectname +{ + font: 300% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 2px 0px; +} + +#projectbrief +{ + font: 120% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#projectnumber +{ + font: 50% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#titlearea +{ + padding: 0px; + margin: 0px; + width: 100%; + border-bottom: 1px solid #5373B4; +} + +.image +{ + text-align: center; +} + +.dotgraph +{ + text-align: center; +} + +.mscgraph +{ + text-align: center; +} + +.plantumlgraph +{ + text-align: center; +} + +.diagraph +{ + text-align: center; +} + +.caption +{ + font-weight: bold; +} + +div.zoom +{ + border: 1px solid #90A5CE; +} + +dl.citelist { + margin-bottom:50px; +} + +dl.citelist dt { + color:#334975; + float:left; + font-weight:bold; + margin-right:10px; + padding:5px; +} + +dl.citelist dd { + margin:2px 0; + padding:5px 0; +} + +div.toc { + padding: 14px 25px; + background-color: #F4F6FA; + border: 1px solid #D8DFEE; + border-radius: 7px 7px 7px 7px; + float: right; + height: auto; + margin: 0 8px 10px 10px; + width: 200px; +} + +.PageDocRTL-title div.toc { + float: left !important; + text-align: right; +} + +div.toc li { + background: url("bdwn.png") no-repeat scroll 0 5px transparent; + font: 10px/1.2 Verdana,DejaVu Sans,Geneva,sans-serif; + margin-top: 5px; + padding-left: 10px; + padding-top: 2px; +} + +.PageDocRTL-title div.toc li { + background-position-x: right !important; + padding-left: 0 !important; + padding-right: 10px; +} + +div.toc h3 { + font: bold 12px/1.2 Arial,FreeSans,sans-serif; + color: #4665A2; + border-bottom: 0 none; + margin: 0; +} + +div.toc ul { + list-style: none outside none; + border: medium none; + padding: 0px; +} + +div.toc li.level1 { + margin-left: 0px; +} + +div.toc li.level2 { + margin-left: 15px; +} + +div.toc li.level3 { + margin-left: 30px; +} + +div.toc li.level4 { + margin-left: 45px; +} + +.PageDocRTL-title div.toc li.level1 { + margin-left: 0 !important; + margin-right: 0; +} + +.PageDocRTL-title div.toc li.level2 { + margin-left: 0 !important; + margin-right: 15px; +} + +.PageDocRTL-title div.toc li.level3 { + margin-left: 0 !important; + margin-right: 30px; +} + +.PageDocRTL-title div.toc li.level4 { + margin-left: 0 !important; + margin-right: 45px; +} + +.inherit_header { + font-weight: bold; + color: gray; + cursor: pointer; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.inherit_header td { + padding: 6px 0px 2px 5px; +} + +.inherit { + display: none; +} + +tr.heading h2 { + margin-top: 12px; + margin-bottom: 4px; +} + +/* tooltip related style info */ + +.ttc { + position: absolute; + display: none; +} + +#powerTip { + cursor: default; + white-space: nowrap; + background-color: white; + border: 1px solid gray; + border-radius: 4px 4px 4px 4px; + box-shadow: 1px 1px 7px gray; + display: none; + font-size: smaller; + max-width: 80%; + opacity: 0.9; + padding: 1ex 1em 1em; + position: absolute; + z-index: 2147483647; +} + +#powerTip div.ttdoc { + color: grey; + font-style: italic; +} + +#powerTip div.ttname a { + font-weight: bold; +} + +#powerTip div.ttname { + font-weight: bold; +} + +#powerTip div.ttdeci { + color: #006318; +} + +#powerTip div { + margin: 0px; + padding: 0px; + font: 12px/16px Roboto,sans-serif; +} + +#powerTip:before, #powerTip:after { + content: ""; + position: absolute; + margin: 0px; +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.s:after, #powerTip.s:before, +#powerTip.w:after, #powerTip.w:before, +#powerTip.e:after, #powerTip.e:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.nw:after, #powerTip.nw:before, +#powerTip.sw:after, #powerTip.sw:before { + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; +} + +#powerTip.n:after, #powerTip.s:after, +#powerTip.w:after, #powerTip.e:after, +#powerTip.nw:after, #powerTip.ne:after, +#powerTip.sw:after, #powerTip.se:after { + border-color: rgba(255, 255, 255, 0); +} + +#powerTip.n:before, #powerTip.s:before, +#powerTip.w:before, #powerTip.e:before, +#powerTip.nw:before, #powerTip.ne:before, +#powerTip.sw:before, #powerTip.se:before { + border-color: rgba(128, 128, 128, 0); +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.nw:after, #powerTip.nw:before { + top: 100%; +} + +#powerTip.n:after, #powerTip.ne:after, #powerTip.nw:after { + border-top-color: #FFFFFF; + border-width: 10px; + margin: 0px -10px; +} +#powerTip.n:before { + border-top-color: #808080; + border-width: 11px; + margin: 0px -11px; +} +#powerTip.n:after, #powerTip.n:before { + left: 50%; +} + +#powerTip.nw:after, #powerTip.nw:before { + right: 14px; +} + +#powerTip.ne:after, #powerTip.ne:before { + left: 14px; +} + +#powerTip.s:after, #powerTip.s:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.sw:after, #powerTip.sw:before { + bottom: 100%; +} + +#powerTip.s:after, #powerTip.se:after, #powerTip.sw:after { + border-bottom-color: #FFFFFF; + border-width: 10px; + margin: 0px -10px; +} + +#powerTip.s:before, #powerTip.se:before, #powerTip.sw:before { + border-bottom-color: #808080; + border-width: 11px; + margin: 0px -11px; +} + +#powerTip.s:after, #powerTip.s:before { + left: 50%; +} + +#powerTip.sw:after, #powerTip.sw:before { + right: 14px; +} + +#powerTip.se:after, #powerTip.se:before { + left: 14px; +} + +#powerTip.e:after, #powerTip.e:before { + left: 100%; +} +#powerTip.e:after { + border-left-color: #FFFFFF; + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.e:before { + border-left-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +#powerTip.w:after, #powerTip.w:before { + right: 100%; +} +#powerTip.w:after { + border-right-color: #FFFFFF; + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.w:before { + border-right-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +@media print +{ + #top { display: none; } + #side-nav { display: none; } + #nav-path { display: none; } + body { overflow:visible; } + h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } + .summary { display: none; } + .memitem { page-break-inside: avoid; } + #doc-content + { + margin-left:0 !important; + height:auto !important; + width:auto !important; + overflow:inherit; + display:inline; + } +} + +/* @group Markdown */ + +/* +table.markdownTable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.markdownTable td, table.markdownTable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.markdownTableHead tr { +} + +table.markdownTableBodyLeft td, table.markdownTable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +th.markdownTableHeadLeft th.markdownTableHeadRight th.markdownTableHeadCenter th.markdownTableHeadNone { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +th.markdownTableHeadLeft { + text-align: left +} + +th.markdownTableHeadRight { + text-align: right +} + +th.markdownTableHeadCenter { + text-align: center +} +*/ + +table.markdownTable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.markdownTable td, table.markdownTable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.markdownTable tr { +} + +th.markdownTableHeadLeft, th.markdownTableHeadRight, th.markdownTableHeadCenter, th.markdownTableHeadNone { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +th.markdownTableHeadLeft, td.markdownTableBodyLeft { + text-align: left +} + +th.markdownTableHeadRight, td.markdownTableBodyRight { + text-align: right +} + +th.markdownTableHeadCenter, td.markdownTableBodyCenter { + text-align: center +} + +.DocNodeRTL { + text-align: right; + direction: rtl; +} + +.DocNodeLTR { + text-align: left; + direction: ltr; +} + +table.DocNodeRTL { + width: auto; + margin-right: 0; + margin-left: auto; +} + +table.DocNodeLTR { + width: auto; + margin-right: auto; + margin-left: 0; +} + +tt, code, kbd, samp +{ + display: inline-block; + direction:ltr; +} +/* @end */ + +u { + text-decoration: underline; +} + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/doxygen.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/doxygen.png new file mode 100644 index 0000000000000000000000000000000000000000..3ff17d807fd8aa003bed8bb2a69e8f0909592fd1 GIT binary patch literal 3779 zcmV;!4m|ORP)tMIv#Q0*~7*`IBSO7_x;@a8#Zk6_PeKR_s92J&)(m+);m9Iz3blw)z#Gi zP!9lj4$%+*>Hz@HCmM9L9|8c+0u=!H$O3?R0Kgx|#WP<6fKfC8fM-CQZT|_r@`>VO zX^Hgb|9cJqpdJA5$MCEK`F_2@2Y@s>^+;pF`~jdI0Pvr|vl4`=C)EH@1IFe7pdJ8F zH(qGi004~QnF)Ggga~8v08kGAs2hKTATxr7pwfNk|4#_AaT>w8P6TV+R2kbS$v==} zAjf`s0g#V8lB+b3)5oEI*q+{Yt$MZDruD2^;$+(_%Qn+%v0X-bJO=;@kiJ^ygLBnC z?1OVv_%aex1M@jKU|Z~$eI?PoF4Vj>fDzyo zAiLfpXY*a^Sj-S5D0S3@#V$sRW)g)_1e#$%8xdM>Jm7?!h zu0P2X=xoN>^!4DoPRgph2(2va07yfpXF+WH7EOg1GY%Zn z7~1A<(z7Q$ktEXhW_?GMpHp9l_UL18F3KOsxu81pqoBiNbFSGsof-W z6~eloMoz=4?OOnl2J268x5rOY`dCk0us(uS#Ud4yqOr@?=Q57a}tit|BhY>}~frH1sP`ScHS_d)oqH^lYy zZ%VP`#10MlE~P?cE(%(#(AUSv_T{+;t@$U}El}(1ig`vZo`Rm;+5&(AYzJ^Ae=h2X z@Re%vHwZU>|f0NI&%$*4eJweC5OROQrpPMA@*w|o z()A==l}(@bv^&>H1Ob3C=<^|hob?0+xJ?QQ3-ueQC}zy&JQNib!OqSO@-=>XzxlSF zAZ^U*1l6EEmg3r};_HY>&Jo_{dOPEFTWPmt=U&F#+0(O59^UIlHbNX+eF8UzyDR*T z(=5X$VF3!gm@RooS-&iiUYGG^`hMR(07zr_xP`d!^BH?uD>Phl8Rdifx3Af^Zr`Ku ztL+~HkVeL#bJ)7;`=>;{KNRvjmc}1}c58Sr#Treq=4{xo!ATy|c>iRSp4`dzMMVd@ zL8?uwXDY}Wqgh4mH`|$BTXpUIu6A1-cSq%hJw;@^Zr8TP=GMh*p(m(tN7@!^D~sl$ zz^tf4II4|};+irE$Fnm4NTc5%p{PRA`%}Zk`CE5?#h3|xcyQsS#iONZ z6H(@^i9td!$z~bZiJLTax$o>r(p}3o@< zyD7%(>ZYvy=6$U3e!F{Z`uSaYy`xQyl?b{}eg|G3&fz*`QH@mDUn)1%#5u`0m$%D} z?;tZ0u(mWeMV0QtzjgN!lT*pNRj;6510Wwx?Yi_=tYw|J#7@(Xe7ifDzXuK;JB;QO z#bg~K$cgm$@{QiL_3yr}y&~wuv=P=#O&Tj=Sr)aCUlYmZMcw?)T?c%0rUe1cS+o!qs_ zQ6Gp)-{)V!;=q}llyK3|^WeLKyjf%y;xHku;9(vM!j|~<7w1c*Mk-;P{T&yG) z@C-8E?QPynNQ<8f01D`2qexcVEIOU?y}MG)TAE6&VT5`rK8s(4PE;uQ92LTXUQ<>^ ztyQ@=@kRdh@ebUG^Z6NWWIL;_IGJ2ST>$t!$m$qvtj0Qmw8moN6GUV^!QKNK zHBXCtUH8)RY9++gH_TUV4^=-j$t}dD3qsN7GclJ^Zc&(j6&a_!$jCf}%c5ey`pm~1)@{yI3 zTdWyB+*X{JFw#z;PwRr5evb2!ueWF;v`B0HoUu4-(~aL=z;OXUUEtG`_$)Oxw6FKg zEzY`CyKaSBK3xt#8gA|r_|Kehn_HYVBMpEwbn9-fI*!u*eTA1ef8Mkl1=!jV4oYwWYM}i`A>_F4nhmlCIC6WLa zY%;4&@AlnaG11ejl61Jev21|r*m+?Kru3;1tFDl}#!OzUp6c>go4{C|^erwpG*&h6bspUPJag}oOkN2912Y3I?(eRc@U9>z#HPBHC?nps7H5!zP``90!Q1n80jo+B3TWXp!8Pe zwuKuLLI6l3Gv@+QH*Y}2wPLPQ1^EZhT#+Ed8q8Wo z1pTmIBxv14-{l&QVKxAyQF#8Q@NeJwWdKk>?cpiJLkJr+aZ!Me+Cfp!?FWSRf^j2k z73BRR{WSKaMkJ>1Nbx5dan5hg^_}O{Tj6u%iV%#QGz0Q@j{R^Ik)Z*+(YvY2ziBG)?AmJa|JV%4UT$k`hcOg5r9R?5>?o~JzK zJCrj&{i#hG>N7!B4kNX(%igb%kDj0fOQThC-8mtfap82PNRXr1D>lbgg)dYTQ(kbx z`Ee5kXG~Bh+BHQBf|kJEy6(ga%WfhvdQNDuOfQoe377l#ht&DrMGeIsI5C<&ai zWG$|hop2@@q5YDa)_-A?B02W;#fH!%k`daQLEItaJJ8Yf1L%8x;kg?)k)00P-lH+w z)5$QNV6r2$YtnV(4o=0^3{kmaXn*Dm0F*fU(@o)yVVjk|ln8ea6BMy%vZAhW9|wvA z8RoDkVoMEz1d>|5(k0Nw>22ZT){V<3$^C-cN+|~hKt2)){+l-?3m@-$c?-dlzQ)q- zZ)j%n^gerV{|+t}9m1_&&Ly!9$rtG4XX|WQ8`xYzGC~U@nYh~g(z9)bdAl#xH)xd5a=@|qql z|FzEil{P5(@gy!4ek05i$>`E^G~{;pnf6ftpLh$h#W?^#4UkPfa;;?bsIe&kz!+40 zI|6`F2n020)-r`pFaZ38F!S-lJM-o&inOw|66=GMeP@xQU5ghQH{~5Uh~TMTd;I9` z>YhVB`e^EVj*S7JF39ZgNf}A-0DwOcTT63ydN$I3b?yBQtUI*_fae~kPvzoD$zjX3 zoqBe#>12im4WzZ=f^4+u=!lA|#r%1`WB0-6*3BL#at`47#ebPpR|D1b)3BjT34nYY z%Ds%d?5$|{LgOIaRO{{oC&RK`O91$fqwM0(C_TALcozu*fWHb%%q&p-q{_8*2Zsi^ zh1ZCnr^UYa;4vQEtHk{~zi>wwMC5o{S=$P0X681y`SXwFH?Ewn{x-MOZynmc)JT5v zuHLwh;tLfxRrr%|k370}GofLl7thg>ACWWY&msqaVu&ry+`7+Ss>NL^%T1|z{IGMA zW-SKl=V-^{(f!Kf^#3(|T2W47d(%JVCI4JgRrT1pNz>+ietmFToNv^`gzC@&O-)+i zPQ~RwK8%C_vf%;%e>NyTp~dM5;!C|N0Q^6|CEb7Bw=Vz~$1#FA;Z*?mKSC)Hl-20s t8QyHj(g6VK0RYbl8UjE)0O0w=e*@m04r>stuEhWV002ovPDHLkV1hl;dM*F} literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dynsections.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dynsections.js new file mode 100644 index 000000000..ea0a7b39a --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/dynsections.js @@ -0,0 +1,120 @@ +/* + @licstart The following is the entire license notice for the + JavaScript code in this file. + + Copyright (C) 1997-2017 by Dimitri van Heesch + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + @licend The above is the entire license notice + for the JavaScript code in this file + */ +function toggleVisibility(linkObj) +{ + var base = $(linkObj).attr('id'); + var summary = $('#'+base+'-summary'); + var content = $('#'+base+'-content'); + var trigger = $('#'+base+'-trigger'); + var src=$(trigger).attr('src'); + if (content.is(':visible')===true) { + content.hide(); + summary.show(); + $(linkObj).addClass('closed').removeClass('opened'); + $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); + } else { + content.show(); + summary.hide(); + $(linkObj).removeClass('closed').addClass('opened'); + $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); + } + return false; +} + +function updateStripes() +{ + $('table.directory tr'). + removeClass('even').filter(':visible:even').addClass('even'); +} + +function toggleLevel(level) +{ + $('table.directory tr').each(function() { + var l = this.id.split('_').length-1; + var i = $('#img'+this.id.substring(3)); + var a = $('#arr'+this.id.substring(3)); + if (la9#ETzayK)T~Jw&MMH>OIr#&;dC}is*2Mqdf&akCc=O@`qC+4i z5Iu3w#1M@KqXCz8TIZd1wli&kkl2HVcAiZ8PUn5z_kG@-y;?yK06=cA0U%H0PH+kU zl6dp}OR(|r8-RG+YLu`zbI}5TlOU6ToR41{9=uz^?dGTNL;wIMf|V3`d1Wj3y!#6` zBLZ?xpKR~^2x}?~zA(_NUu3IaDB$tKma*XUdOZN~c=dLt_h_k!dbxm_*ibDM zlFX`g{k$X}yIe%$N)cn1LNu=q9_CS)*>A zsX_mM4L@`(cSNQKMFc$RtYbx{79#j-J7hk*>*+ZZhM4Hw?I?rsXCi#mRWJ=-0LGV5a-WR0Qgt<|Nqf)C-@80`5gIz45^_20000IqP)X=#(TiCT&PiIIVc55T}TU}EUh*{q$|`3@{d>{Tc9Bo>e= zfmF3!f>fbI9#GoEHh0f`i5)wkLpva0ztf%HpZneK?w-7AK@b4Itw{y|Zd3k!fH?q2 zlhckHd_V2M_X7+)U&_Xcfvtw60l;--DgZmLSw-Y?S>)zIqMyJ1#FwLU*%bl38ok+! zh78H87n`ZTS;uhzAR$M`zZ`bVhq=+%u9^$5jDplgxd44}9;IRqUH1YHH|@6oFe%z( zo4)_>E$F&^P-f(#)>(TrnbE>Pefs9~@iN=|)Rz|V`sGfHNrJ)0gJb8xx+SBmRf@1l zvuzt=vGfI)<-F9!o&3l?>9~0QbUDT(wFdnQPv%xdD)m*g%!20>Bc9iYmGAp<9YAa( z0QgYgTWqf1qN++Gqp z8@AYPTB3E|6s=WLG?xw0tm|U!o=&zd+H0oRYE;Dbx+Na9s^STqX|Gnq%H8s(nGDGJ j8vwW|`Ts`)fSK|Kx=IK@RG@g200000NkvXXu0mjfauFEA literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.html new file mode 100644 index 000000000..ea7c56be9 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.html @@ -0,0 +1,122 @@ + + + + + + + +R_RSIP Documentation: Interfaces + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
Interfaces
+
+
+

Detailed Description

+

The interfaces provide APIs for common functionality. They can be implemented by one or more modules. Modules can use other modules as dependencies using this interface layer.

+ + + + + +

+Modules

 RSIP Interface
 Interface for Renesas Secure IP (RSIP) functions.
 
+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.js new file mode 100644 index 000000000..db989005e --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.js @@ -0,0 +1,4 @@ +var group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s = +[ + [ "RSIP Interface", "group___r_s_i_p___a_p_i.html", "group___r_s_i_p___a_p_i" ] +]; \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.html new file mode 100644 index 000000000..d8006bc2b --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.html @@ -0,0 +1,134 @@ + + + + + + + +R_RSIP Documentation: Modules + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
Modules
+
+
+

Detailed Description

+

Modules are the smallest unit of software available in the Security Package. Each module implements one interface.

+

Organization of Module Sections

+

Each module has a detailed Users' Guide listed below. Each guide typically includes the following content:

+
    +
  • Functions: A list of all the API functions associated with the module
  • +
  • Detailed Description: A short description of the module and the peripherals used
  • +
  • Overview: An operational summary and a list of high level features provided by the module
  • +
  • Configuration: A description of module specific settings available in the configuration tool including clock and pin configurations
  • +
  • Usage Notes: Module specific documentation and limitations
  • +
  • Examples: Illustrative code snippets that help the user better understand API use and operation
  • +
  • Data Structure and Enumeration: Definitions for data structures, enumerations and similar elements used by the module API
  • +
  • Function Documentation: Details on each API function, including the function prototype, a function summary, a simple use example, list of return values and links to documentation for any needed parameter definitions
  • +
+ + + + + +

+Modules

 Renesas Secure IP (r_rsip)
 Driver for the Renesas Secure IP on RZ MPUs. This module implements the RSIP Interface.
 
+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.js new file mode 100644 index 000000000..dc7dcd9b8 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.js @@ -0,0 +1,4 @@ +var group___r_e_n_e_s_a_s___m_o_d_u_l_e_s = +[ + [ "Renesas Secure IP (r_rsip)", "group___r_s_i_p.html", "group___r_s_i_p" ] +]; \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p.html new file mode 100644 index 000000000..7b764aa49 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p.html @@ -0,0 +1,4835 @@ + + + + + + + +R_RSIP Documentation: Renesas Secure IP (r_rsip) + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
Renesas Secure IP (r_rsip)
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Functions

fsp_err_t R_RSIP_Open (rsip_ctrl_t *const p_ctrl, rsip_cfg_t const *const p_cfg)
 
fsp_err_t R_RSIP_Close (rsip_ctrl_t *const p_ctrl)
 
fsp_err_t R_RSIP_RandomNumberGenerate (rsip_ctrl_t *const p_ctrl, uint8_t *const p_random)
 
fsp_err_t R_RSIP_KeyGenerate (rsip_ctrl_t *const p_ctrl, rsip_key_type_t const key_type, rsip_wrapped_key_t *const p_wrapped_key)
 
fsp_err_t R_RSIP_KeyPairGenerate (rsip_ctrl_t *const p_ctrl, rsip_key_pair_type_t const key_pair_type, rsip_wrapped_key_t *const p_wrapped_public_key, rsip_wrapped_key_t *const p_wrapped_private_key)
 
fsp_err_t R_RSIP_KeyImportWithKUK (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_key_update_key, uint8_t const *const p_initial_vector, rsip_key_type_t const key_type, uint8_t const *const p_encrypted_key, rsip_wrapped_key_t *const p_wrapped_key)
 
fsp_err_t R_RSIP_ECCPublicKeyExport (rsip_wrapped_key_t const *const p_wrapped_public_key, uint8_t const **const pp_raw_public_key_qx, uint8_t const **const pp_raw_public_key_qy)
 
fsp_err_t R_RSIP_RSAPublicKeyExport (rsip_wrapped_key_t const *const p_wrapped_public_key, uint8_t const **const pp_raw_public_key_n, uint8_t const **const pp_raw_public_key_e)
 
fsp_err_t R_RSIP_AES_Cipher_EncryptInit (rsip_ctrl_t *const p_ctrl, rsip_aes_mode_t const mode, rsip_wrapped_key_t const *const p_wrapped_key, uint8_t const *const p_initial_vector)
 
fsp_err_t R_RSIP_AES_Cipher_EncryptUpdate (rsip_ctrl_t *const p_ctrl, uint8_t const *const p_plain, uint8_t *const p_cipher, uint32_t const plain_length)
 
fsp_err_t R_RSIP_AES_Cipher_EncryptFinal (rsip_ctrl_t *const p_ctrl, uint8_t *const p_cipher, uint32_t *const p_cipher_length)
 
fsp_err_t R_RSIP_AES_Cipher_DecryptInit (rsip_ctrl_t *const p_ctrl, rsip_aes_mode_t const mode, rsip_wrapped_key_t const *const p_wrapped_key, uint8_t const *const p_initial_vector)
 
fsp_err_t R_RSIP_AES_Cipher_DecryptUpdate (rsip_ctrl_t *const p_ctrl, uint8_t const *const p_cipher, uint8_t *const p_plain, uint32_t const cipher_length)
 
fsp_err_t R_RSIP_AES_Cipher_DecryptFinal (rsip_ctrl_t *const p_ctrl, uint8_t *const p_plain, uint32_t *const p_plain_length)
 
fsp_err_t R_RSIP_AES_GCM_EncryptInit (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_key, uint8_t const *const p_nonce, uint32_t const nonce_length)
 
fsp_err_t R_RSIP_AES_GCM_EncryptUpdate (rsip_ctrl_t *const p_ctrl, uint8_t const *const p_plain, uint8_t *const p_cipher, uint32_t const plain_length, uint8_t const *const p_aad, uint32_t const aad_length)
 
fsp_err_t R_RSIP_AES_GCM_EncryptFinal (rsip_ctrl_t *const p_ctrl, uint8_t *const p_cipher, uint32_t *const p_cipher_length, uint8_t *const p_tag)
 
fsp_err_t R_RSIP_AES_GCM_DecryptInit (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_key, uint8_t const *const p_nonce, uint32_t const nonce_length)
 
fsp_err_t R_RSIP_AES_GCM_DecryptUpdate (rsip_ctrl_t *const p_ctrl, uint8_t const *const p_cipher, uint8_t *const p_plain, uint32_t const cipher_length, uint8_t const *const p_aad, uint32_t const aad_length)
 
fsp_err_t R_RSIP_AES_GCM_DecryptFinal (rsip_ctrl_t *const p_ctrl, uint8_t *const p_plain, uint32_t *const p_plain_length, uint8_t const *const p_tag, uint32_t const tag_length)
 
fsp_err_t R_RSIP_AES_CMAC_GenerateInit (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_key)
 
fsp_err_t R_RSIP_AES_CMAC_GenerateUpdate (rsip_ctrl_t *const p_ctrl, uint8_t const *const p_message, uint32_t const message_length)
 
fsp_err_t R_RSIP_AES_CMAC_GenerateFinal (rsip_ctrl_t *const p_ctrl, uint8_t *const p_mac)
 
fsp_err_t R_RSIP_AES_CMAC_VerifyInit (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_key)
 
fsp_err_t R_RSIP_AES_CMAC_VerifyUpdate (rsip_ctrl_t *const p_ctrl, uint8_t const *const p_message, uint32_t const message_length)
 
fsp_err_t R_RSIP_AES_CMAC_VerifyFinal (rsip_ctrl_t *const p_ctrl, uint8_t const *const p_mac, uint32_t const mac_length)
 
fsp_err_t R_RSIP_ECDSA_Sign (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_private_key, uint8_t const *const p_hash, uint8_t *const p_signature)
 
fsp_err_t R_RSIP_ECDSA_Verify (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_public_key, uint8_t const *const p_hash, uint8_t const *const p_signature)
 
fsp_err_t R_RSIP_RSA_Encrypt (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_public_key, uint8_t const *const p_plain, uint8_t *const p_cipher)
 
fsp_err_t R_RSIP_RSA_Decrypt (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_private_key, uint8_t const *const p_cipher, uint8_t *const p_plain)
 
fsp_err_t R_RSIP_RSAES_PKCS1_V1_5_Encrypt (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_public_key, uint8_t const *const p_plain, uint32_t const plain_length, uint8_t *const p_cipher)
 
fsp_err_t R_RSIP_RSAES_PKCS1_V1_5_Decrypt (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_private_key, uint8_t const *const p_cipher, uint8_t *const p_plain, uint32_t *const p_plain_length, uint32_t const plain_buffer_length)
 
fsp_err_t R_RSIP_RSAES_OAEP_Encrypt (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_public_key, rsip_hash_type_t const hash_function, rsip_mgf_type_t const mask_generation_function, uint8_t const *const p_label, uint32_t const label_length, uint8_t const *const p_plain, uint32_t const plain_length, uint8_t *const p_cipher)
 
fsp_err_t R_RSIP_RSAES_OAEP_Decrypt (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_private_key, rsip_hash_type_t const hash_function, rsip_mgf_type_t const mask_generation_function, uint8_t const *const p_label, uint32_t const label_length, uint8_t const *const p_cipher, uint8_t *const p_plain, uint32_t *const p_plain_length, uint32_t const plain_buffer_length)
 
fsp_err_t R_RSIP_RSASSA_PKCS1_V1_5_Sign (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_private_key, rsip_hash_type_t const hash_function, uint8_t const *const p_hash, uint8_t *const p_signature)
 
fsp_err_t R_RSIP_RSASSA_PKCS1_V1_5_Verify (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_public_key, rsip_hash_type_t const hash_function, uint8_t const *const p_hash, uint8_t const *const p_signature)
 
fsp_err_t R_RSIP_RSASSA_PSS_Sign (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_private_key, rsip_hash_type_t const hash_function, rsip_mgf_type_t const mask_generation_function, int32_t const salt_length, uint8_t const *const p_hash, uint8_t *const p_signature)
 
fsp_err_t R_RSIP_RSASSA_PSS_Verify (rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_public_key, rsip_hash_type_t const hash_function, rsip_mgf_type_t const mask_generation_function, int32_t const salt_length, uint8_t const *const p_hash, uint8_t const *const p_signature)
 
fsp_err_t R_RSIP_SHA_Compute (rsip_ctrl_t *const p_ctrl, rsip_hash_type_t const hash_type, uint8_t const *const p_message, uint32_t const message_length, uint8_t *const p_digest)
 
fsp_err_t R_RSIP_HMAC_Compute (rsip_ctrl_t *const p_ctrl, const rsip_wrapped_key_t *p_wrapped_key, uint8_t const *const p_message, uint32_t const message_length, uint8_t *const p_mac)
 
fsp_err_t R_RSIP_HMAC_Verify (rsip_ctrl_t *const p_ctrl, const rsip_wrapped_key_t *p_wrapped_key, uint8_t const *const p_message, uint32_t const message_length, uint8_t const *const p_mac, uint32_t const mac_length)
 
fsp_err_t R_RSIP_SHA_GenerateInit (rsip_ctrl_t *const p_ctrl, rsip_sha_handle_t *const p_handle, rsip_hash_type_t const hash_type)
 
fsp_err_t R_RSIP_SHA_GenerateUpdate (rsip_ctrl_t *const p_ctrl, rsip_sha_handle_t *const p_handle, uint8_t const *const p_message, uint32_t const message_length)
 
fsp_err_t R_RSIP_SHA_GenerateFinal (rsip_ctrl_t *const p_ctrl, rsip_sha_handle_t *const p_handle, uint8_t *const p_digest)
 
fsp_err_t R_RSIP_HMAC_GenerateInit (rsip_ctrl_t *const p_ctrl, rsip_hmac_handle_t *const p_handle, rsip_wrapped_key_t const *const p_wrapped_key)
 
fsp_err_t R_RSIP_HMAC_GenerateUpdate (rsip_ctrl_t *const p_ctrl, rsip_hmac_handle_t *const p_handle, uint8_t const *const p_message, uint32_t const message_length)
 
fsp_err_t R_RSIP_HMAC_GenerateFinal (rsip_ctrl_t *const p_ctrl, rsip_hmac_handle_t *const p_handle, uint8_t *const p_mac)
 
fsp_err_t R_RSIP_HMAC_VerifyInit (rsip_ctrl_t *const p_ctrl, rsip_hmac_handle_t *const p_handle, rsip_wrapped_key_t const *const p_wrapped_key)
 
fsp_err_t R_RSIP_HMAC_VerifyUpdate (rsip_ctrl_t *const p_ctrl, rsip_hmac_handle_t *const p_handle, uint8_t const *const p_message, uint32_t const message_length)
 
fsp_err_t R_RSIP_HMAC_VerifyFinal (rsip_ctrl_t *const p_ctrl, rsip_hmac_handle_t *const p_handle, uint8_t const *const p_mac, uint32_t const mac_length)
 
fsp_err_t R_RSIP_KeyImportWithUFPK (rsip_ctrl_t *const p_ctrl, uint8_t const *const p_wrapped_user_factory_programming_key, uint8_t const *const p_initial_vector, rsip_key_type_t const key_type, uint8_t const *const p_encrypted_key, rsip_wrapped_key_t *const p_wrapped_key)
 
+

Detailed Description

+

Driver for the Renesas Secure IP on RZ MPUs. This module implements the RSIP Interface.

+

+Overview

+

The cryptographic library for RZ MPUs is a highly secure cryptographic driver using Renesas Secure IP, a peripheral function of RZ MPUs, and is called RSIP driver. The RSIP driver for RZ MPUs provides the following functions:

+
    +
  • Cryptographic accelerator
  • +
  • Random number generator
  • +
  • Secure key management
  • +
+

The keys handled by the RSIP driver (keys to be input and keys to be output) are opaque keys wrapped in device-specific keys that can only be accessed by the Renesas Secure IP. Secure key management in the RSIP driver is achieved by wrapping the keys with device-specific keys, which enables key secrecy and tamper detection capabilities outside of the Renesas Secure IP. Only the Renesas Secure IP can unwrap the key, and the unwrapped key exists only inside the Renesas Secure IP during cryptographic operations. Because the key is wrapped with a device-specific key, even if the key is copied to another device, the key cannot be unwrapped by another device with a different device-specific key. Because keys can be securely managed in this way, a secure storage function can be built into user applications by encrypting data to be kept secret using symmetric cryptography such as AES and storing it in flash.

+

Unauthorized access monitoring by Renesas Secure IP covers all cryptographic operations provided by this driver and is always enabled during cryptographic operation. If the cryptographic operation tampering is detected during using this driver, this driver stops operation.

+

+Features

+

The RSIP module supports for the following features.

+
    +
  • Symmetric Cryptography
      +
    • AES 128/256bit [FIPS197]
        +
      • ECB,CBC,CTR [SP800-38A]
      • +
      • XTS [IEEE-XTS]
      • +
      • GCM [SP800-38D]
      • +
      +
    • +
    • AES-CMAC 128/256bit [SP800-38B]
    • +
    +
  • +
  • Asymmetric Cryptography
      +
    • RSA 1024/2048/3072/4096bit
        +
      • RSAES-PKCS1-v1_5 [RFC8017]
      • +
      • RSAES-OAEP [RFC8017]
      • +
      • RSASSA-PKCS1-v1_5 [RFC8017]
      • +
      • RSASSA-PSS [RFC8017]
      • +
      +
    • +
    • ECC
        +
      • ECDSA NIST [RFC6979]
          +
        • P-192, P-224, P-256, BrainpoolP256r1
        • +
        +
      • +
      +
    • +
    +
  • +
  • Hash Functions
      +
    • SHA
        +
      • SHA-1
      • +
      • SHA-2 [FIPS180-4]
          +
        • SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256
        • +
        +
      • +
      • HMAC [RFC2104]
          +
        • HMAC-SHA1, HMAC-SHA224, HMAC-SHA256
        • +
        +
      • +
      +
    • +
    +
  • +
  • Key Management
      +
    • Key import by Key Wrap Service
        +
      • AES 128/256bit
      • +
      • RSA 1024/2048/3072/4096bit
      • +
      • ECC NIST P-192, P-224, P-256, BrainpoolP256r1
      • +
      • HMAC
      • +
      +
    • +
    • Key import by key update key
        +
      • AES 128/256bit
      • +
      • RSA 1024/2048/3072/4096bit
      • +
      • ECC NIST P-192, P-224, P-256, BrainpoolP256r1
      • +
      • HMAC
      • +
      +
    • +
    • Key generation
        +
      • AES 128/256bit
      • +
      • RSA 1024/2048/3072/4096bit
      • +
      • ECC NIST P-192, P-224, P-256, BrainpoolP256r1
      • +
      +
    • +
    +
  • +
  • Random Number Generation
      +
    • Generate based on CTR-DRBG [SP800-90B]
    • +
    +
  • +
+

+Supported devices

+
    +
  • RZ/G Series
      +
    • RZ/G3S Group
    • +
    +
  • +
+

+Configuration

+

Build Time Configurations for r_rsip

+The following build time configurations are defined in r_rsip_cfg.h:
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ConfigurationOptionsDefaultDescription
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > AES-128
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > AES-256
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > XTS-AES-128
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > XTS-AES-256
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > ECC secp192r1 Public Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > ECC secp192r1 Private Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > ECC secp224r1 Public Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > ECC secp224r1 Private Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > ECC secp256r1 Public Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > ECC secp256r1 Private Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > ECC brainpoolP256r1 Public Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > ECC brainpoolP256r1 Private Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > RSA-1024 Public Key (New format)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > RSA-1024 Private Key (New format)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > RSA-2048 Public Key (New format)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > RSA-2048 Private Key (New format)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > RSA-3072 Public Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > RSA-3072 Private Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > RSA-4096 Public Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > RSA-4096 Private Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > HMAC-SHA1/224/256
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > Key Update Key (KUK)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithUFPK > Image Decryption Key for Secure Boot
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > AES-128
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > AES-256
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > XTS-AES-128
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > XTS-AES-256
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > ECC secp192r1 Public Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > ECC secp192r1 Private Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > ECC secp224r1 Public Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > ECC secp224r1 Private Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > ECC secp256r1 Public Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > ECC secp256r1 Private Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > ECC brainpoolP256r1 Public Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > ECC brainpoolP256r1 Private Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > RSA-1024 Public Key (New format)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > RSA-1024 Private Key (New format)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > RSA-2048 Public Key (New format)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > RSA-2048 Private Key (New format)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > RSA-3072 Public Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > RSA-3072 Private Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > RSA-4096 Public Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > RSA-4096 Private Key
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyImportWithKUK > HMAC-SHA1/224/256
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyGenerate > AES-128
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyGenerate > AES-256
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyGenerate > XTS-AES-128
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyGenerate > XTS-AES-256
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyPairGenerate > ECC secp192r1
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyPairGenerate > ECC secp224r1
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyPairGenerate > ECC secp256r1
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyPairGenerate > ECC brainpoolP256r1
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyPairGenerate > RSA-1024 (New format)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyPairGenerate > RSA-2048 (New format)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyPairGenerate > RSA-3072
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_KeyPairGenerate > RSA-4096
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_AES_Cipher_Encrypt/Decrypt > AES-128-ECB/CBC/CTR (Encrypt/Decrypt)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_AES_Cipher_Encrypt/Decrypt > AES-256-ECB/CBC/CTR (Encrypt/Decrypt)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_AES_Cipher_Encrypt/Decrypt > XTS-AES-128 (Encrypt)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_AES_Cipher_Encrypt/Decrypt > XTS-AES-128 (Decrypt)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_AES_Cipher_Encrypt/Decrypt > XTS-AES-256 (Encrypt)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_AES_Cipher_Encrypt/Decrypt > XTS-AES-256 (Decrypt)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_AES_GCM_Encrypt > AES-128
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_AES_GCM_Encrypt > AES-256
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_AES_GCM_Decrypt > AES-128
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_AES_GCM_Decrypt > AES-256
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_AES_CMAC_Generate/Verify > AES-128
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_AES_CMAC_Generate/Verify > AES-256
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_RSA*Encrypt/Verify > RSA-1024 (for new-format wrapped key)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_RSA*Encrypt/Verify > RSA-2048 (for new-format wrapped key)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_RSA*Encrypt/Verify > RSA-3072
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_RSA*Encrypt/Verify > RSA-4096
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_RSA*Decrypt/Sign > RSA-1024 (for new-format wrapped key)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_RSA*Decrypt/Sign > RSA-2048 (for new-format wrapped key)
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_RSA*Decrypt/Sign > RSA-3072
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_RSA*Decrypt/Sign > RSA-4096
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_HMAC_Compute/Generate/Verify > HMAC-SHA1
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_HMAC_Compute/Generate/Verify > HMAC-SHA224
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Selection of algorithms to enable for each function > R_RSIP_HMAC_Compute/Generate/Verify > HMAC-SHA256
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If the application uses only some of the algorithm in the function, the code size can be reduced by disabling the unused algorithms. This configuration is provided only for the functions for which it works effectively.
Parameter Checking
    +
  • +Enabled
  • +
  • +Disabled
  • +
+
Enabled If selected code for parameter checking is included in the build.
+

+

+Clock Configuration

+

This module does not require a specific clock configuration.

+

+Pin Configuration

+

This module does not use I/O pins.

+

+Usage Notes

+

+Getting Started: Creating a RSIP Project

+

The RSIP driver for RZ MPUs is used in combination with Verified Linux Package (VLP). The RSIP driver is included as sample code in the OP-TEE OS for RZ MPUs provided by VLP. The Security Package used in combination with VLP provides a sample program for using the RSIP driver on OP-TEE OS. For sample programs, please refer to Security Startup Guide provided by the security package.

+

+Key Management

+

The following key management functions are available on each devices.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Key type (rsip_key_type_t) R_RSIP_KeyImportWithKUK() R_RSIP_KeyImportWithUFPK() Generate Export
RSIP_KEY_TYPE_INVALID - - - -
RSIP_KEY_TYPE_AES_128 Y Y R_RSIP_KeyGenerate() -
RSIP_KEY_TYPE_AES_256 Y Y R_RSIP_KeyGenerate() -
RSIP_KEY_TYPE_AES_128_XTS Y Y R_RSIP_KeyGenerate() -
RSIP_KEY_TYPE_AES_256_XTS Y Y R_RSIP_KeyGenerate() -
RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC Y Y R_RSIP_KeyPairGenerate() R_RSIP_ECCPublicKeyExport()
RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE Y Y R_RSIP_KeyPairGenerate() -
RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC Y Y R_RSIP_KeyPairGenerate() R_RSIP_ECCPublicKeyExport()
RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE Y Y R_RSIP_KeyPairGenerate() -
RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC Y Y R_RSIP_KeyPairGenerate() R_RSIP_ECCPublicKeyExport()
RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE Y Y R_RSIP_KeyPairGenerate() -
RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC Y Y R_RSIP_KeyPairGenerate() R_RSIP_ECCPublicKeyExport()
RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE Y Y R_RSIP_KeyPairGenerate() -
RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED Y Y R_RSIP_KeyPairGenerate() R_RSIP_RSAPublicKeyExport()
RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED Y Y R_RSIP_KeyPairGenerate() -
RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED Y Y R_RSIP_KeyPairGenerate() R_RSIP_RSAPublicKeyExport()
RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED Y Y R_RSIP_KeyPairGenerate() -
RSIP_KEY_TYPE_RSA_3072_PUBLIC Y Y R_RSIP_KeyPairGenerate() R_RSIP_RSAPublicKeyExport()
RSIP_KEY_TYPE_RSA_3072_PRIVATE Y Y R_RSIP_KeyPairGenerate() -
RSIP_KEY_TYPE_RSA_4096_PUBLIC Y Y R_RSIP_KeyPairGenerate() R_RSIP_RSAPublicKeyExport()
RSIP_KEY_TYPE_RSA_4096_PRIVATE Y Y R_RSIP_KeyPairGenerate() -
RSIP_KEY_TYPE_HMAC_SHA1 Y Y - -
RSIP_KEY_TYPE_HMAC_SHA224 Y Y - -
RSIP_KEY_TYPE_HMAC_SHA256 Y Y - -
RSIP_KEY_TYPE_KEY_UPDATE_KEY (used to import other keys) Y - -
RSIP_KEY_TYPE_SECURE_BOOT_DECRYPTION - Y - -
+ + + + + + + + + + + + + + + + + + + +
Key pair type (rsip_key_pair_type_t) R_RSIP_KeyPairGenerate() Corresponding public key type Corresponding private key type
RSIP_KEY_PAIR_TYPE_ECC_secp192r1 Y RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE
RSIP_KEY_PAIR_TYPE_ECC_secp224r1 Y RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE
RSIP_KEY_PAIR_TYPE_ECC_secp256r1 Y RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE
RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1 Y RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE
RSIP_KEY_PAIR_TYPE_RSA_1024 Y RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED
RSIP_KEY_PAIR_TYPE_RSA_2048 Y RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED
RSIP_KEY_PAIR_TYPE_RSA_3072 Y RSIP_KEY_TYPE_RSA_3072_PUBLIC RSIP_KEY_TYPE_RSA_3072_PRIVATE
RSIP_KEY_PAIR_TYPE_RSA_4096 Y RSIP_KEY_TYPE_RSA_4096_PUBLIC RSIP_KEY_TYPE_RSA_4096_PRIVATE
+

+Examples

+

+AES cipher Example

+

This is an example of AES-CTR encryption/decryption.

+
#define BLOCK (16)
+
+
void r_rsip_example_aes ()
+
{
+
fsp_err_t err;
+
+
static const uint8_t plain[BLOCK * 2] =
+
{
+
0x52, 0x65, 0x6e, 0x65, 0x73, 0x61, 0x73, 0x20, 0x45, 0x6c, 0x65, 0x63, 0x74, 0x72, 0x6f, 0x6e,
+
0x69, 0x63, 0x73, 0x20, 0x43, 0x6f, 0x72, 0x70, 0x6f, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00
+
};
+
+
uint8_t nonce[BLOCK] = {0};
+
uint8_t cipher_calculated[BLOCK * 2] = {0};
+
uint8_t plain_calculated[BLOCK * 2] = {0};
+
uint32_t dummy = 0;
+
+
/* Prepare wrapped key data area */
+
uint8_t wrapped_key[RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256];
+
rsip_wrapped_key_t * p_wrapped_key = (rsip_wrapped_key_t *) wrapped_key;
+
+
/* Initialize the driver */
+
err = R_RSIP_Open(&rsip_ctrl, &rsip_cfg);
+
assert(FSP_SUCCESS == err);
+
+
/* Generate a aes 256-bit key */
+
err = R_RSIP_KeyGenerate(&rsip_ctrl, RSIP_KEY_TYPE_AES_256, p_wrapped_key);
+
assert(FSP_SUCCESS == err);
+
+
/* Generate a nonce */
+
err = R_RSIP_RandomNumberGenerate(&rsip_ctrl, nonce);
+
assert(FSP_SUCCESS == err);
+
+
/* Encrypt a plaintext */
+
err = R_RSIP_AES_Cipher_EncryptInit(&rsip_ctrl, RSIP_AES_MODE_CTR, p_wrapped_key, nonce);
+
assert(FSP_SUCCESS == err);
+
+
err = R_RSIP_AES_Cipher_EncryptUpdate(&rsip_ctrl, plain, cipher_calculated, BLOCK * 2);
+
assert(FSP_SUCCESS == err);
+
+
err = R_RSIP_AES_Cipher_EncryptFinal(&rsip_ctrl, NULL, &dummy);
+
assert(FSP_SUCCESS == err);
+
+
/* Decrypt a ciphertext using the same key */
+
err = R_RSIP_AES_Cipher_DecryptInit(&rsip_ctrl, RSIP_AES_MODE_CTR, p_wrapped_key, nonce);
+
assert(FSP_SUCCESS == err);
+
+
err = R_RSIP_AES_Cipher_DecryptUpdate(&rsip_ctrl, cipher_calculated, plain_calculated, BLOCK);
+
assert(FSP_SUCCESS == err);
+
+
err = R_RSIP_AES_Cipher_DecryptUpdate(&rsip_ctrl, cipher_calculated + BLOCK, plain_calculated + BLOCK, BLOCK);
+
assert(FSP_SUCCESS == err);
+
+
err = R_RSIP_AES_Cipher_DecryptFinal(&rsip_ctrl, NULL, &dummy);
+
assert(FSP_SUCCESS == err);
+
+
/* Compare plain and plain_calculated */
+
assert(0 == memcmp(plain, plain_calculated, BLOCK * 2));
+
+
/* Close the driver */
+
err = R_RSIP_Close(&rsip_ctrl);
+
assert(FSP_SUCCESS == err);
+
}
+
+

+AES-GCM Example

+

This is an example of AES-GCM encryption/decryption.

+
#define GCM_BLOCK_LEN (16)
+
#define GCM_TEXT_LEN (31)
+
#define GCM_NONCE_LEN (12)
+
#define GCM_AAD_LEN (8)
+
+
void r_rsip_example_gcm ()
+
{
+
fsp_err_t err;
+
+
static const uint8_t plain[GCM_TEXT_LEN] =
+
{
+
0x52, 0x65, 0x6e, 0x65, 0x73, 0x61, 0x73, 0x20, 0x45, 0x6c, 0x65, 0x63, 0x74, 0x72, 0x6f, 0x6e,
+
0x69, 0x63, 0x73, 0x20, 0x43, 0x6f, 0x72, 0x70, 0x6f, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
+
};
+
+
static const uint8_t aad[GCM_AAD_LEN] =
+
{
+
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
+
};
+
+
uint8_t nonce[GCM_BLOCK_LEN] = {0};
+
uint8_t tag[GCM_BLOCK_LEN] = {0};
+
uint8_t cipher_calculated[GCM_BLOCK_LEN * 2] = {0};
+
uint8_t plain_calculated[GCM_BLOCK_LEN * 2] = {0};
+
uint32_t remaining_length = 0;
+
+
/* Prepare wrapped key data area */
+
uint8_t wrapped_key[RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256];
+
rsip_wrapped_key_t * p_wrapped_key = (rsip_wrapped_key_t *) wrapped_key;
+
+
/* Initialize the driver */
+
err = R_RSIP_Open(&rsip_ctrl, &rsip_cfg);
+
assert(FSP_SUCCESS == err);
+
+
/* Generate a aes 256-bit key */
+
err = R_RSIP_KeyGenerate(&rsip_ctrl, RSIP_KEY_TYPE_AES_256, p_wrapped_key);
+
assert(FSP_SUCCESS == err);
+
+
/* Generate a nonce */
+
err = R_RSIP_RandomNumberGenerate(&rsip_ctrl, nonce);
+
assert(FSP_SUCCESS == err);
+
+
/* Encrypt a plaintext */
+
err = R_RSIP_AES_GCM_EncryptInit(&rsip_ctrl, p_wrapped_key, nonce, GCM_NONCE_LEN);
+
assert(FSP_SUCCESS == err);
+
+
/* e.g. Input text and AAD at the same time */
+
err = R_RSIP_AES_GCM_EncryptUpdate(&rsip_ctrl, plain, cipher_calculated, GCM_TEXT_LEN, aad, GCM_AAD_LEN);
+
assert(FSP_SUCCESS == err);
+
+
/* Output remaining text and generate a tag */
+
err = R_RSIP_AES_GCM_EncryptFinal(&rsip_ctrl,
+
cipher_calculated + ((GCM_TEXT_LEN / GCM_BLOCK_LEN) * GCM_BLOCK_LEN),
+
&remaining_length,
+
tag);
+
assert(FSP_SUCCESS == err);
+
+
/* Decrypt a ciphertext using the same key */
+
err = R_RSIP_AES_GCM_DecryptInit(&rsip_ctrl, p_wrapped_key, nonce, GCM_NONCE_LEN);
+
assert(FSP_SUCCESS == err);
+
+
/* e.g. Input text and AAD at different timings. AAD cannot be input after text. */
+
err = R_RSIP_AES_GCM_DecryptUpdate(&rsip_ctrl, NULL, NULL, 0, aad, GCM_AAD_LEN);
+
assert(FSP_SUCCESS == err);
+
+
err = R_RSIP_AES_GCM_DecryptUpdate(&rsip_ctrl, cipher_calculated, plain_calculated, GCM_BLOCK_LEN, NULL, 0);
+
assert(FSP_SUCCESS == err);
+
+
err = R_RSIP_AES_GCM_DecryptUpdate(&rsip_ctrl,
+
cipher_calculated + GCM_BLOCK_LEN,
+
plain_calculated + GCM_BLOCK_LEN,
+
GCM_TEXT_LEN - GCM_BLOCK_LEN,
+
NULL,
+
0);
+
assert(FSP_SUCCESS == err);
+
+
/*
+
* Output remaining text and verify the tag
+
* Attention: Do not use the output plaintext by R_RSIP_AES_Cipher_DecryptUpdate()
+
* before R_RSIP_AES_Cipher_DecryptFinal() returns FSP_SUCCESS.
+
* The integrity is checked in this function.
+
*/
+
err = R_RSIP_AES_GCM_DecryptFinal(&rsip_ctrl,
+
plain_calculated + ((GCM_TEXT_LEN / GCM_BLOCK_LEN) * GCM_BLOCK_LEN),
+
&remaining_length,
+
tag,
+
GCM_BLOCK_LEN);
+
assert(FSP_SUCCESS == err);
+
+
/* Compare plain and plain_calculated */
+
assert(0 == memcmp(plain, plain_calculated, GCM_TEXT_LEN));
+
+
/* Close the driver */
+
err = R_RSIP_Close(&rsip_ctrl);
+
assert(FSP_SUCCESS == err);
+
}
+
+

+ECC Example

+

This is an example of ECDSA signature generation/verification.

+
#define SECP256R1_KEY_SIZE (32)
+
+
void r_rsip_example_ecc ()
+
{
+
fsp_err_t err;
+
+
static const uint8_t message[] = "sample";
+
+
uint8_t hash[SECP256R1_KEY_SIZE] = {0};
+
uint8_t signature[SECP256R1_KEY_SIZE * 2] = {0};
+
+
/* Prepare wrapped key data area */
+ + +
rsip_wrapped_key_t * p_wrapped_public_key = (rsip_wrapped_key_t *) wrapped_public_key;
+
rsip_wrapped_key_t * p_wrapped_private_key = (rsip_wrapped_key_t *) wrapped_private_key;
+
+
/* Initialize the driver */
+
err = R_RSIP_Open(&rsip_ctrl, &rsip_cfg);
+
assert(FSP_SUCCESS == err);
+
+
/* Generate a key pair of secp256r1 */
+
err = R_RSIP_KeyPairGenerate(&rsip_ctrl,
+ +
p_wrapped_public_key,
+
p_wrapped_private_key);
+
assert(FSP_SUCCESS == err);
+
+
/* Generate the message hash */
+
err = R_RSIP_SHA_Compute(&rsip_ctrl, RSIP_HASH_TYPE_SHA256, message, sizeof(message), hash);
+
assert(FSP_SUCCESS == err);
+
+
/* Generate the signature */
+
err = R_RSIP_ECDSA_Sign(&rsip_ctrl, p_wrapped_private_key, hash, signature);
+
assert(FSP_SUCCESS == err);
+
+
/* Verify the signature*/
+
err = R_RSIP_ECDSA_Verify(&rsip_ctrl, p_wrapped_public_key, hash, signature);
+
assert(FSP_SUCCESS == err);
+
+
/* Close the driver */
+
err = R_RSIP_Close(&rsip_ctrl);
+
assert(FSP_SUCCESS == err);
+
}
+
+

+RSA Example

+

This is an example of RSA encryption/decryption (RSAES-OAEP) and RSA signature generation/verification (RSASSA-PSS).

+
#define SHA256_HASH_SIZE (32)
+
#define RSA_2048_KEY_SIZE (256)
+
+
void r_rsip_example_rsa ()
+
{
+
fsp_err_t err;
+
+
static const uint8_t message[] = "sample";
+
static const uint8_t label[] = "label";
+
+
uint8_t cipher_calculated[RSA_2048_KEY_SIZE] = {0};
+
uint8_t plain_calculated[RSA_2048_KEY_SIZE] = {0};
+
uint32_t plain_calculated_length = 0;
+
uint8_t hash[SHA256_HASH_SIZE] = {0};
+
uint8_t signature[RSA_2048_KEY_SIZE] = {0};
+
+
/* Prepare wrapped key data area */
+ + +
rsip_wrapped_key_t * p_wrapped_public_key = (rsip_wrapped_key_t *) wrapped_public_key;
+
rsip_wrapped_key_t * p_wrapped_private_key = (rsip_wrapped_key_t *) wrapped_private_key;
+
+
/* Initialize the driver */
+
err = R_RSIP_Open(&rsip_ctrl, &rsip_cfg);
+
assert(FSP_SUCCESS == err);
+
+
/* Generate a key pair of RSA-2048 */
+
err = R_RSIP_KeyPairGenerate(&rsip_ctrl, RSIP_KEY_PAIR_TYPE_RSA_2048, p_wrapped_public_key, p_wrapped_private_key);
+
assert(FSP_SUCCESS == err);
+
+
/*
+
* RSAES-OAEP
+
*/
+
+
/* Encrypt a plaintext */
+
err = R_RSIP_RSAES_OAEP_Encrypt(&rsip_ctrl,
+
p_wrapped_public_key,
+ + +
label,
+
sizeof(label),
+
message,
+
sizeof(message),
+
cipher_calculated);
+
assert(FSP_SUCCESS == err);
+
+
/* Decrypt a ciphertext using the same key */
+
err = R_RSIP_RSAES_OAEP_Decrypt(&rsip_ctrl,
+
p_wrapped_private_key,
+ + +
label,
+
sizeof(label),
+
cipher_calculated,
+
plain_calculated,
+
&plain_calculated_length,
+
sizeof(plain_calculated));
+
assert(FSP_SUCCESS == err);
+
+
/* Verify calculated plaintext */
+
assert(sizeof(message) == plain_calculated_length);
+
assert(0 == memcmp(message, plain_calculated, plain_calculated_length));
+
+
/*
+
* RSASSA-PSS
+
*/
+
+
/* Generate the message hash */
+
err = R_RSIP_SHA_Compute(&rsip_ctrl, RSIP_HASH_TYPE_SHA256, message, sizeof(message), hash);
+
assert(FSP_SUCCESS == err);
+
+
/* Generate the signature */
+
err = R_RSIP_RSASSA_PSS_Sign(&rsip_ctrl,
+
p_wrapped_private_key,
+ + + +
hash,
+
signature);
+
assert(FSP_SUCCESS == err);
+
+
/* Verify the signature*/
+
err = R_RSIP_RSASSA_PSS_Verify(&rsip_ctrl,
+
p_wrapped_public_key,
+ + + +
hash,
+
signature);
+
assert(FSP_SUCCESS == err);
+
+
/* Close the driver */
+
err = R_RSIP_Close(&rsip_ctrl);
+
assert(FSP_SUCCESS == err);
+
}
+
+

+HASH Example

+

This is an example of calculating the SHA-256 message digest.

+
#define SHA256_HASH_SIZE (32)
+
+
void r_rsip_example_hash ()
+
{
+
fsp_err_t err;
+
rsip_sha_handle_t handle;
+
+
static const uint8_t message[] =
+
{
+
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+
};
+
+
static const uint8_t hash[] =
+
{
+
0x63, 0x0d, 0xcd, 0x29, 0x66, 0xc4, 0x33, 0x66, 0x91, 0x12, 0x54, 0x48, 0xbb, 0xb2, 0x5b, 0x4f,
+
0xf4, 0x12, 0xa4, 0x9c, 0x73, 0x2d, 0xb2, 0xc8, 0xab, 0xc1, 0xb8, 0x58, 0x1b, 0xd7, 0x10, 0xdd
+
};
+
+
uint8_t digest_single[SHA256_HASH_SIZE] = {0};
+
uint8_t digest_multi[SHA256_HASH_SIZE] = {0};
+
+
/* Initialize the driver */
+
err = R_RSIP_Open(&rsip_ctrl, &rsip_cfg);
+
assert(FSP_SUCCESS == err);
+
+
/* (1) Calculate SHA-256 digests with single-part API */
+
err = R_RSIP_SHA_Compute(&rsip_ctrl, RSIP_HASH_TYPE_SHA256, message, sizeof(message), digest_single);
+
assert(FSP_SUCCESS == err);
+
+
/* Compare digest and hash */
+
assert(0 == memcmp(digest_single, hash, SHA256_HASH_SIZE));
+
+
/* (2) Calculate SHA-256 digests with multi-part API */
+
err = R_RSIP_SHA_GenerateInit(&rsip_ctrl, &handle, RSIP_HASH_TYPE_SHA256);
+
assert(FSP_SUCCESS == err);
+
+
err = R_RSIP_SHA_GenerateUpdate(&rsip_ctrl, &handle, message, sizeof(message));
+
assert(FSP_SUCCESS == err);
+
+
err = R_RSIP_SHA_GenerateFinal(&rsip_ctrl, &handle, digest_multi);
+
assert(FSP_SUCCESS == err);
+
+
/* Compare digest and hash */
+
assert(0 == memcmp(digest_multi, hash, SHA256_HASH_SIZE));
+
+
/* Close the driver */
+
err = R_RSIP_Close(&rsip_ctrl);
+
assert(FSP_SUCCESS == err);
+
}
+
+
+ + + +

+Data Structures

struct  st_rsip_instance_ctrl
 
+

Data Structure Documentation

+ +

◆ st_rsip_instance_ctrl

+ +
+
+ + + + +
struct st_rsip_instance_ctrl
+
+

RSIP private control block. DO NOT MODIFY. Initialization occurs when R_RSIP_Open() is called.

+
+
+
+

Function Documentation

+ +

◆ R_RSIP_Open()

+ +
+
+ + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_Open (rsip_ctrl_t *const p_ctrl,
rsip_cfg_t const *const p_cfg 
)
+
+

Opens the RSIP driver module.

+
Parameters
+ + + +
[in,out]p_ctrlPointer to control block. Must be declared by user. Elements are set here.
[in]p_cfgPointer to configuration structure.
+
+
+
Return values
+ + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_ALREADY_OPENModule is already open.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInternal key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILHardware initialization is failed.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption or hardware fault is detected.
+
+
+ +
+
+ +

◆ R_RSIP_Close()

+ +
+
+ + + + + + + + +
fsp_err_t R_RSIP_Close (rsip_ctrl_t *const p_ctrl)
+
+

Closes the RSIP driver module.

+
Parameters
+ + +
[in,out]p_ctrlPointer to control block.
+
+
+
Return values
+ + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_RandomNumberGenerate()

+ +
+
+ + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_RandomNumberGenerate (rsip_ctrl_t *const p_ctrl,
uint8_t *const p_random 
)
+
+

Generates a 128-bit random number.

+
Parameters
+ + + +
[in,out]p_ctrlPointer to control block.
[out]p_randomPointer to destination of random number. The length is 16 bytes.
+
+
+
Return values
+ + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_KeyGenerate()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_KeyGenerate (rsip_ctrl_t *const p_ctrl,
rsip_key_type_t const key_type,
rsip_wrapped_key_t *const p_wrapped_key 
)
+
+

Generates a wrapped symmetric key from a random number. In this API, user key input is unnecessary. By encrypting data using the wrapped key is output by this API, dead copying of data can be prevented.

+
Parameters
+ + + + +
[in,out]p_ctrlPointer to control block.
[in]key_typeOutputs key type.
[out]p_wrapped_keyPointer to destination of wrapped key. The length depends on key type.
+
+
+
Return values
+ + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_UNSUPPORTEDInput key type is unsupported.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+
See also
Section Key Management
+ +
+
+ +

◆ R_RSIP_KeyPairGenerate()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_KeyPairGenerate (rsip_ctrl_t *const p_ctrl,
rsip_key_pair_type_t const key_pair_type,
rsip_wrapped_key_t *const p_wrapped_public_key,
rsip_wrapped_key_t *const p_wrapped_private_key 
)
+
+

Generates a wrapped asymmetric key pair from a random number. In this API, user key input is unnecessary. By encrypting data using the wrapped key is output by this API, dead copying of data can be prevented.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in]key_pair_typeOutput key pair type.
[out]p_wrapped_public_keyPointer to destination of wrapped public key. The length depends on key type.
[out]p_wrapped_private_keyPointer to destination of wrapped private key. The length depends on key type.
+
+
+
Return values
+ + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_UNSUPPORTEDInput key type is unsupported.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+
See also
Section Key Management
+ +
+
+ +

◆ R_RSIP_KeyImportWithKUK()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_KeyImportWithKUK (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_key_update_key,
uint8_t const *const p_initial_vector,
rsip_key_type_t const key_type,
uint8_t const *const p_encrypted_key,
rsip_wrapped_key_t *const p_wrapped_key 
)
+
+

Imports a user key with KUK (Key Update Key) within the user routine.

+
Parameters
+ + + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_key_update_keyPointer to Key Update Key.
[in]p_initial_vectorPointer to initialization vector when generating encrypted_key. The length is 16 bytes.
[in]key_typeInputs/Outputs key type.
[in]p_encrypted_keyPointer to encrypted user key. The length depends on the key type.
[out]p_wrapped_keyPointer to destination of wrapped key. The length depends on the key type.
+
+
+
Return values
+ + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_UNSUPPORTEDInput key type is unsupported.
FSP_ERR_INVALID_ARGUMENTp_key_update_key->type is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInput parameter is invalid.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+
See also
Section Key Management
+ +
+
+ +

◆ R_RSIP_ECCPublicKeyExport()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_ECCPublicKeyExport (rsip_wrapped_key_t const *const p_wrapped_public_key,
uint8_t const **const pp_raw_public_key_qx,
uint8_t const **const pp_raw_public_key_qy 
)
+
+

Exports ECC public key parameters from a wrapped key.

+
Parameters
+ + + + +
[in]p_wrapped_public_keyPointer to wrapped key of ECC public key.
[out]pp_raw_public_key_qxPointer to raw Q_x. The length depends on the key length.
[out]pp_raw_public_key_qyPointer to raw Q_y. The length depends on the key length.
+
+
+
Return values
+ + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_INVALID_ARGUMENTKey type is illegal.
+
+
+
Note
Outputs are only available inside the scope of the wrapped key. If necessary, please copy them.
+
See also
Section Key Management
+ +
+
+ +

◆ R_RSIP_RSAPublicKeyExport()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_RSAPublicKeyExport (rsip_wrapped_key_t const *const p_wrapped_public_key,
uint8_t const **const pp_raw_public_key_n,
uint8_t const **const pp_raw_public_key_e 
)
+
+

Exports RSA public key parameters from a wrapped key.

+
Parameters
+ + + + +
[in]p_wrapped_public_keyPointer to wrapped key of RSA public key.
[out]pp_raw_public_key_nPointer to raw n. The length is as same as the key length.
[out]pp_raw_public_key_ePointer to raw e. The length is 4 bytes.
+
+
+
Return values
+ + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_INVALID_ARGUMENTKey type is illegal.
+
+
+
Note
Outputs are only available inside the scope of the wrapped key. If necessary, please copy them.
+
See also
Section Key Management
+ +
+
+ +

◆ R_RSIP_AES_Cipher_EncryptInit()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_Cipher_EncryptInit (rsip_ctrl_t *const p_ctrl,
rsip_aes_mode_t const mode,
rsip_wrapped_key_t const *const p_wrapped_key,
uint8_t const *const p_initial_vector 
)
+
+

Prepares an AES encryption.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in]modeBlock cipher modes of operation.
[in]p_wrapped_keyPointer to wrapped key of AES or AES-XTS key.
[in]p_initial_vectorPointer to initialization vector (IV) or nonce. The length is 16 bytes.
    +
  • [ECB] Not needed
  • +
  • [CBC] IV
  • +
  • [CTR] Nonce
  • +
  • [XTS] IV
  • +
+
+
+
+
Return values
+ + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type or mode is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_AES_Cipher_EncryptUpdate()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_Cipher_EncryptUpdate (rsip_ctrl_t *const p_ctrl,
uint8_t const *const p_plain,
uint8_t *const p_cipher,
uint32_t const plain_length 
)
+
+

Encrypts plaintext.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_plainPointer to plaintext. The length is plain_length.
[out]p_cipherPointer to destination of ciphertext.
    +
  • [ECB][CBC][CTR][XTS without fractional block] The length is plain_length.
  • +
  • [XTS with fractional block] No outputs. The ciphertext output by R_RSIP_AES_Cipher_EncryptFinal(). After inputs fractional block, updates will not be possible.
  • +
+
[in]plain_lengthByte length of plaintext.
    +
  • [ECB][CBC][CTR][XTS without fractional block] Must be 0 or a multiple of 16.
  • +
  • [XTS with fractional block] Must be 17 to 31.
  • +
+
+
+
+
Return values
+ + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_INVALID_SIZEInput length is illegal.
+
+
+ +
+
+ +

◆ R_RSIP_AES_Cipher_EncryptFinal()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_Cipher_EncryptFinal (rsip_ctrl_t *const p_ctrl,
uint8_t *const p_cipher,
uint32_t *const p_cipher_length 
)
+
+

Finalizes an AES encryption.

+
Parameters
+ + + + +
[in,out]p_ctrlPointer to control block.
[out]p_cipherPointer to destination of ciphertext.
    +
  • [ECB][CBC][CTR] No outputs.
  • +
  • [XTS] Fractional block and the one before block are output.
  • +
+
[out]p_cipher_lengthPointer to destination of ciphertext length.
    +
  • [ECB][CBC][CTR] No outputs.
  • +
  • [XTS] Output length is output.
  • +
+
+
+
+
Return values
+ + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInternal error.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_AES_Cipher_DecryptInit()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_Cipher_DecryptInit (rsip_ctrl_t *const p_ctrl,
rsip_aes_mode_t const mode,
rsip_wrapped_key_t const *const p_wrapped_key,
uint8_t const *const p_initial_vector 
)
+
+

Prepares an AES decryption.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in]modeBlock cipher modes of operation.
[in]p_wrapped_keyPointer to wrapped key of AES or AES-XTS key.
[in]p_initial_vectorPointer to initialization vector (IV) or nonce. The length is 16 bytes.
    +
  • [ECB] Not needed
  • +
  • [CBC] IV
  • +
  • [CTR] Nonce
  • +
  • [XTS] IV
  • +
+
+
+
+
Return values
+ + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type or mode is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_AES_Cipher_DecryptUpdate()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_Cipher_DecryptUpdate (rsip_ctrl_t *const p_ctrl,
uint8_t const *const p_cipher,
uint8_t *const p_plain,
uint32_t const cipher_length 
)
+
+

Decrypts ciphertext.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_cipherPointer to ciphertext. The length is cipher_length.
[out]p_plainPointer to destination of plaintext.
    +
  • [ECB][CBC][CTR][XTS without fractional block] The length is cipher_length.
  • +
  • [XTS with fractional block] No outputs. The plaintext is output by R_RSIP_AES_Cipher_DecryptFinal(). After inputs fractional block, updates will not be possible.
  • +
+
[in]cipher_lengthByte length of ciphertext.
    +
  • [ECB][CBC][CTR][XTS without fractional block] Must be 0 or a multiple of 16.
  • +
  • [XTS with fractional block] Must be 17 to 31.
  • +
+
+
+
+
Return values
+ + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_INVALID_SIZEInput length is illegal.
+
+
+ +
+
+ +

◆ R_RSIP_AES_Cipher_DecryptFinal()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_Cipher_DecryptFinal (rsip_ctrl_t *const p_ctrl,
uint8_t *const p_plain,
uint32_t *const p_plain_length 
)
+
+

Finalizes an AES decryption.

+
Parameters
+ + + + +
[in,out]p_ctrlPointer to control block.
[out]p_plainPointer to destination of plaintext.
    +
  • [ECB][CBC][CTR] No outputs.
  • +
  • [XTS] Fractional block and the one before block are output.
  • +
+
[out]p_plain_lengthPointer to destination of plaintext length.
    +
  • [ECB][CBC][CTR] No outputs.
  • +
  • [XTS] Output length is output.
  • +
+
+
+
+
Return values
+ + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInternal error.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_AES_GCM_EncryptInit()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_GCM_EncryptInit (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_key,
uint8_t const *const p_nonce,
uint32_t const nonce_length 
)
+
+

Prepares an AES-GCM encryption.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_keyPointer to wrapped key of AES key.
[in]p_noncePointer to nonce. The length is nonce_length.
[in]nonce_lengthByte length of nonce. Input 1 or more.
+
+
+
Return values
+ + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_AES_GCM_EncryptUpdate()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_GCM_EncryptUpdate (rsip_ctrl_t *const p_ctrl,
uint8_t const *const p_plain,
uint8_t *const p_cipher,
uint32_t const plain_length,
uint8_t const *const p_aad,
uint32_t const aad_length 
)
+
+

Inputs aad and encrypts plaintext.

+

First process the data that is input from p_aad, and then process the data that is input from p_plain. If p_aad data is input after starting to input p_plain data, an error will occur. If p_aad data and p_plain data are input to this function at the same time, the p_aad data will be processed, and then the function will transition to the p_plain data input state.

+

Inside this function, the data that is input by the user is buffered until the input values of p_aad and p_plain exceed 16 bytes. After the input data from p_plain reaches 16 bytes or more, the encryption result is output to p_cipher. If the input values p_plain and p_aad are not divisible by 16 bytes, they will be padded inside the function.

+
Parameters
+ + + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_plainPointer to ciphertext. The length is plain_length.
[out]p_cipherPointer to destination of ciphertext.
[in]plain_lengthByte length of plaintext (0 or more bytes).
[in]p_aadAdditional authentication data. The length depends on aad_length.
[in]aad_lengthByte length of additional authentication data (0 or more bytes). After starting input of plaintext, this value must always be 0.
+
+
+
Return values
+ + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_INVALID_SIZEInput length is illegal.
+
+
+ +
+
+ +

◆ R_RSIP_AES_GCM_EncryptFinal()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_GCM_EncryptFinal (rsip_ctrl_t *const p_ctrl,
uint8_t *const p_cipher,
uint32_t *const p_cipher_length,
uint8_t *const p_tag 
)
+
+

Finalizes an AES-GCM encryption.

+

If there is 16-byte fractional data indicated by the total data length of the value of p_plain that was input by R_RSIP_AES_GCM_EncryptUpdate(), this API will output the result of encrypting that fractional data to p_cipher. Here, the portion that does not reach 16 bytes will be padded with zeros.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[out]p_cipherPointer to destination of ciphertext. The fractional block is output.
[out]p_cipher_lengthPointer to destination of ciphertext length.
[out]p_tagPointer to destination of tag for authentication. The length is 16 bytes.
+
+
+
Return values
+ + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInternal error.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_AES_GCM_DecryptInit()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_GCM_DecryptInit (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_key,
uint8_t const *const p_nonce,
uint32_t const nonce_length 
)
+
+

Prepares an AES-GCM decryption.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_keyPointer to wrapped key of AES key.
[in]p_noncePointer to nonce. The length is nonce_length.
[in]nonce_lengthByte length of nonce. Input 1 or more.
+
+
+
Return values
+ + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_AES_GCM_DecryptUpdate()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_GCM_DecryptUpdate (rsip_ctrl_t *const p_ctrl,
uint8_t const *const p_cipher,
uint8_t *const p_plain,
uint32_t const cipher_length,
uint8_t const *const p_aad,
uint32_t const aad_length 
)
+
+

Inputs aad and decrypts ciphertext.

+

First process the data that is input from p_aad, and then process the data that is input from p_cipher. If p_aad data is input after starting to input p_cipher data, an error will occur. If p_aad data and p_cipher data are input to this function at the same time, the p_aad data will be processed, and then the function will transition to the p_cipher data input state.

+

Inside this function, the data that is input by the user is buffered until the input values of p_aad and p_cipher exceed 16 bytes. After the input data from p_cipher reaches 16 bytes or more, the decryption result is output to p_cipher. If the input values p_cipher and p_aad are not divisible by 16 bytes, they will be padded inside the function.

+
Parameters
+ + + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_cipherPointer to ciphertext. The length is cipher_length.
[out]p_plainPointer to destination of plaintext.
[in]cipher_lengthByte length of ciphertext (0 or more bytes).
[in]p_aadAdditional authentication data. The length depends on aad_length.
[in]aad_lengthByte length of additional authentication data (0 or more bytes). After starting input of ciphertext, this value must always be 0.
+
+
+
Return values
+ + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_INVALID_SIZEInput length is illegal.
+
+
+ +
+
+ +

◆ R_RSIP_AES_GCM_DecryptFinal()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_GCM_DecryptFinal (rsip_ctrl_t *const p_ctrl,
uint8_t *const p_plain,
uint32_t *const p_plain_length,
uint8_t const *const p_tag,
uint32_t const tag_length 
)
+
+

Finalizes an AES-GCM decryption.

+

If there is 16-byte fractional data indicated by the total data length of the value of p_cipher that was input by R_RSIP_AES_GCM_DecryptUpdate(), this API will output the result of decrypting that fractional data to p_cipher. Here, the portion that does not reach 16 bytes will be padded with zeros.

+
Parameters
+ + + + + + +
[in,out]p_ctrlPointer to control block.
[out]p_plainPointer to destination of plaintext. The fractional block is output.
[out]p_plain_lengthPointer to destination of plaintext length.
[in]p_tagPointer to tag for authentication. The length depends on tag_length.
[in]tag_lengthByte length of tag. Must be 1 to 16.
+
+
+
Return values
+ + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_INVALID_SIZEtag_length is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInternal error.
FSP_ERR_CRYPTO_RSIP_AUTHENTICATIONAuthentication is failed.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_AES_CMAC_GenerateInit()

+ +
+
+ + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_CMAC_GenerateInit (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_key 
)
+
+

Prepares an AES-CMAC generation.

+
Parameters
+ + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_keyPointer to wrapped key of AES key.
+
+
+
Return values
+ + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_AES_CMAC_GenerateUpdate()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_CMAC_GenerateUpdate (rsip_ctrl_t *const p_ctrl,
uint8_t const *const p_message,
uint32_t const message_length 
)
+
+

Inputs message.

+

Inside this function, the data that is input by the user is buffered until the input value of p_message exceeds 16 bytes. If the input value, p_message, is not a multiple of 16 bytes, it will be padded within the function.

+
Parameters
+ + + + +
[in,out]p_ctrlPointer to control block.
[in]p_messagePointer to message. The length is message_length.
[in]message_lengthByte length of message (0 or more bytes).
+
+
+
Return values
+ + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
+
+
+ +
+
+ +

◆ R_RSIP_AES_CMAC_GenerateFinal()

+ +
+
+ + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_CMAC_GenerateFinal (rsip_ctrl_t *const p_ctrl,
uint8_t *const p_mac 
)
+
+

Finalizes an AES-CMAC generation.

+
Parameters
+ + + +
[in,out]p_ctrlPointer to control block.
[out]p_macPointer to destination of MAC. The length is 16 bytes.
+
+
+
Return values
+ + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInternal error.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_AES_CMAC_VerifyInit()

+ +
+
+ + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_CMAC_VerifyInit (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_key 
)
+
+

Prepares an AES-CMAC verification.

+
Parameters
+ + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_keyPointer to wrapped key of AES key.
+
+
+
Return values
+ + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_AES_CMAC_VerifyUpdate()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_CMAC_VerifyUpdate (rsip_ctrl_t *const p_ctrl,
uint8_t const *const p_message,
uint32_t const message_length 
)
+
+

Inputs message.

+

Inside this function, the data that is input by the user is buffered until the input value of p_message exceeds 16 bytes. If the input value, p_message, is not a multiple of 16 bytes, it will be padded within the function.

+
Parameters
+ + + + +
[in,out]p_ctrlPointer to control block.
[in]p_messagePointer to message. The length is message_length.
[in]message_lengthByte length of message (0 or more bytes).
+
+
+
Return values
+ + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
+
+
+ +
+
+ +

◆ R_RSIP_AES_CMAC_VerifyFinal()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_AES_CMAC_VerifyFinal (rsip_ctrl_t *const p_ctrl,
uint8_t const *const p_mac,
uint32_t const mac_length 
)
+
+

Finalizes an AES-CMAC generation.

+
Parameters
+ + + + +
[in,out]p_ctrlPointer to control block.
[in]p_macPointer to MAC. The length depends on mac_length.
[in]mac_lengthByte length of MAC. Must be 2 to 16.
+
+
+
Return values
+ + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_INVALID_SIZEmac_length is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInternal error.
FSP_ERR_CRYPTO_RSIP_AUTHENTICATIONAuthentication is failed.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_ECDSA_Sign()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_ECDSA_Sign (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_private_key,
uint8_t const *const p_hash,
uint8_t *const p_signature 
)
+
+

Signs a hashed message. The message hash should be generated in advance.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_private_keyPointer to wrapped key of ECC private key.
[in]p_hashPointer to hash value. The length is as same as the key length.
[out]p_signaturePointer to destination of signature (r, s). The length is twice as long as the key length.
+
+
+
Return values
+ + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAIL
    +
  • Input parameter is illegal.
  • +
  • Signature generation is failed.
  • +
+
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_ECDSA_Verify()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_ECDSA_Verify (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_public_key,
uint8_t const *const p_hash,
uint8_t const *const p_signature 
)
+
+

Verifies a hashed message. The message hash should be generated in advance.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_public_keyPointer to wrapped key of ECC public key.
[in]p_hashPointer to hash value. The length is as same as the key length.
[in]p_signaturePointer to signature (r, s). The length is twice as long as the key length.
+
+
+
Return values
+ + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAIL
    +
  • Input parameter is illegal.
  • +
  • Signature verification is failed.
  • +
+
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_RSA_Encrypt()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_RSA_Encrypt (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_public_key,
uint8_t const *const p_plain,
uint8_t *const p_cipher 
)
+
+

Encrypts plaintext with raw RSA.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_public_keyPointer to wrapped key of RSA public key.
[in]p_plainPointer to plaintext. The length is as same as the key length.
[out]p_cipherPointer to destination of ciphertext. The length is as same as the key length.
+
+
+
Return values
+ + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInput parameter is invalid.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+
Note
This API provides RSA low-level primitives (RSAEP/RSAVP1). It should be used in conjunction with any padding scheme.
+ +
+
+ +

◆ R_RSIP_RSA_Decrypt()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_RSA_Decrypt (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_private_key,
uint8_t const *const p_cipher,
uint8_t *const p_plain 
)
+
+

Decrypts ciphertext with raw RSA.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_private_keyPointer to wrapped key of RSA private key.
[in]p_cipherPointer to ciphertext. The length is as same as the key length.
[out]p_plainPointer to destination of plaintext. The length is as same as the key length.
+
+
+
Return values
+ + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInput parameter is invalid.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+
Note
This API provides RSA low-level primitives (RSADP/RSASP1). It should be used in conjunction with any padding scheme.
+ +
+
+ +

◆ R_RSIP_RSAES_PKCS1_V1_5_Encrypt()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_RSAES_PKCS1_V1_5_Encrypt (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_public_key,
uint8_t const *const p_plain,
uint32_t const plain_length,
uint8_t *const p_cipher 
)
+
+

Encrypts plaintext with RSAES-PKCS1-v1_5.

+

mLen (plain_length) and k (RSA key length) must meet the following condition.

+

mlen <= k - 11

+
Parameters
+ + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_public_keyPointer to wrapped key of RSA public key.
[in]p_plainPointer to plaintext.
[in]plain_lengthLength of plaintext.
[out]p_cipherPointer to destination of ciphertext. The length is as same as the key length.
+
+
+
Return values
+ + + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInput parameter is invalid.
FSP_ERR_INVALID_SIZEAny length is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_RSAES_PKCS1_V1_5_Decrypt()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_RSAES_PKCS1_V1_5_Decrypt (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_private_key,
uint8_t const *const p_cipher,
uint8_t *const p_plain,
uint32_t *const p_plain_length,
uint32_t const plain_buffer_length 
)
+
+

Decrypts with RSAES-PKCS1-v1_5.

+
Parameters
+ + + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_private_keyPointer to wrapped key of RSA private key.
[in]p_cipherPointer to ciphertext. The length is as same as the key length.
[out]p_plainPointer to destination of plaintext.
[out]p_plain_lengthPointer to destination of actual plaintext length.
[in]plain_buffer_lengthLength of plaintext destination. It must be equal to or greater than *p_plain_length.
+
+
+
Return values
+ + + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInput parameter is invalid.
FSP_ERR_INVALID_SIZEAny length is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+
Note
The stack usage of this function depends on the maximum key length for RSA decryption enabled in configuration. For example, if RSA-2048 is enabled, this function uses at least 256 bytes (2048 bits) of stack. To shrink the stack size, please disable unused key length in configuration.
+
+This API skips the ciphertext length checking at RFC8017 (PKCS#1 v2.2) Section 7.2.2 Step 1.
+ +
+
+ +

◆ R_RSIP_RSAES_OAEP_Encrypt()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_RSAES_OAEP_Encrypt (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_public_key,
rsip_hash_type_t const hash_function,
rsip_mgf_type_t const mask_generation_function,
uint8_t const *const p_label,
uint32_t const label_length,
uint8_t const *const p_plain,
uint32_t const plain_length,
uint8_t *const p_cipher 
)
+
+

Encrypts plaintext with RSAES-OAEP.

+

mLen (plain_length), hLen (output length of hash_function), and k (RSA key length) must meet the following condition.

+

mLen <= k - 2 hLen - 2

+
Parameters
+ + + + + + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_public_keyPointer to wrapped key of RSA public key.
[in]hash_functionHash function for label.
[in]mask_generation_functionMask generation function in EME-OAEP encoding.
[in]p_labelPointer to label. If label_length != 0, p_label must not be NULL.
[in]label_lengthLength of label. Please set 0 or more.
[in]p_plainPointer to plaintext.
[in]plain_lengthLength of plaintext.
[out]p_cipherPointer to destination of ciphertext. The length is as same as the key length.
+
+
+
Return values
+ + + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInput parameter is invalid.
FSP_ERR_INVALID_SIZEAny length is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_RSAES_OAEP_Decrypt()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_RSAES_OAEP_Decrypt (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_private_key,
rsip_hash_type_t const hash_function,
rsip_mgf_type_t const mask_generation_function,
uint8_t const *const p_label,
uint32_t const label_length,
uint8_t const *const p_cipher,
uint8_t *const p_plain,
uint32_t *const p_plain_length,
uint32_t const plain_buffer_length 
)
+
+

Decrypts ciphertext with RSAES-OAEP.

+

hLen (output length of hash_function) and k (RSA key length) must meet the following condition.

+

k >= 2 hLen + 2

+
Parameters
+ + + + + + + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_private_keyPointer to wrapped key of RSA private key.
[in]hash_functionHash function for label.
[in]mask_generation_functionMask generation function in EME-OAEP encoding.
[in]p_labelPointer to label. If label_length != 0, p_label must not be NULL.
[in]label_lengthLength of label. Please set 0 or more.
[in]p_cipherPointer to ciphertext. The length is as same as the key length.
[out]p_plainPointer to destination of plaintext.
[out]p_plain_lengthPointer to destination of actual plaintext length.
[in]plain_buffer_lengthLength of plaintext destination. It must be equal to or greater than *p_plain_length.
+
+
+
Return values
+ + + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInput parameter is invalid.
FSP_ERR_INVALID_SIZEAny length is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+
Note
The stack usage of this function depends on the maximum key length for RSA decryption enabled in configuration. For example, if RSA-2048 is enabled, this function uses at least 256 bytes (2048 bits) of stack. To shrink the stack size, please disable unused key length in configuration.
+
+This API skips the ciphertext length checking at RFC8017 (PKCS#1 v2.2) Section 7.1.2 Step 1.
+ +
+
+ +

◆ R_RSIP_RSASSA_PKCS1_V1_5_Sign()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_RSASSA_PKCS1_V1_5_Sign (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_private_key,
rsip_hash_type_t const hash_function,
uint8_t const *const p_hash,
uint8_t *const p_signature 
)
+
+

Signs message with RSASSA-PKCS1-v1_5.

+
Parameters
+ + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_private_keyPointer to wrapped key of RSA private key.
[in]hash_functionHash function in EMSA-PKCS1-v1_5.
[in]p_hashPointer to input hash.
[out]p_signaturePointer to destination of signature.
+
+
+
Return values
+ + + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInput parameter is invalid.
FSP_ERR_INVALID_SIZEAny length is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_RSASSA_PKCS1_V1_5_Verify()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_RSASSA_PKCS1_V1_5_Verify (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_public_key,
rsip_hash_type_t const hash_function,
uint8_t const *const p_hash,
uint8_t const *const p_signature 
)
+
+

Verifies signature with RSASSA-PKCS1-v1_5.

+
Parameters
+ + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_public_keyPointer to wrapped key of RSA public key.
[in]hash_functionHash function in EMSA-PKCS1-v1_5.
[in]p_hashPointer to input hash.
[in]p_signaturePointer to input signature.
+
+
+
Return values
+ + + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInput parameter is invalid.
FSP_ERR_INVALID_SIZEAny length is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+
Note
The stack usage of this function depends on the maximum key length for RSA decryption enabled in configuration. For example, if RSA-2048 is enabled, this function uses at least 512 bytes (2048 bits * 2) of stack. To shrink the stack size, please disable unused key length in configuration.
+ +
+
+ +

◆ R_RSIP_RSASSA_PSS_Sign()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_RSASSA_PSS_Sign (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_private_key,
rsip_hash_type_t const hash_function,
rsip_mgf_type_t const mask_generation_function,
int32_t const salt_length,
uint8_t const *const p_hash,
uint8_t *const p_signature 
)
+
+

Signs message with RSASSA-PSS.

+
Parameters
+ + + + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_private_keyPointer to wrapped key of RSA private key.
[in]hash_functionHash function in EMSA-PSS-ENCODE.
[in]mask_generation_functionMask generation function in EMSA-PSS-ENCODE.
[in]salt_lengthSalt length. RSIP_RSA_SALT_LENGTH_AUTO, RSIP_RSA_SALT_LENGTH_HASH, RSIP_RSA_SALT_LENGTH_MAX, 0, or positive integers can be set, where salt_length <= emLen - hLen - 2 (emLen is the same as the key length and hLen is the hash length).
[in]p_hashPointer to input hash.
[out]p_signaturePointer to destination of signature.
+
+
+
Return values
+ + + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInput parameter is invalid.
FSP_ERR_INVALID_SIZEAny length is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_RSASSA_PSS_Verify()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_RSASSA_PSS_Verify (rsip_ctrl_t *const p_ctrl,
rsip_wrapped_key_t const *const p_wrapped_public_key,
rsip_hash_type_t const hash_function,
rsip_mgf_type_t const mask_generation_function,
int32_t const salt_length,
uint8_t const *const p_hash,
uint8_t const *const p_signature 
)
+
+

Verifies signature with RSASSA-PSS.

+
Parameters
+ + + + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_public_keyPointer to wrapped key of RSA public key.
[in]hash_functionHash function in EMSA-PSS-VERIFY.
[in]mask_generation_functionMask generation function in EMSA-PSS-VERIFY.
[in]salt_lengthSalt length. RSIP_RSA_SALT_LENGTH_AUTO, RSIP_RSA_SALT_LENGTH_HASH, RSIP_RSA_SALT_LENGTH_MAX, 0, or positive integers can be set, where salt_length <= emLen - hLen - 2 (emLen is the same as the key length and hLen is the hash length).
[in]p_hashPointer to input hash.
[in]p_signaturePointer to input signature.
+
+
+
Return values
+ + + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILInput parameter is invalid.
FSP_ERR_INVALID_SIZEAny length is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+
Note
The stack usage of this function depends on the maximum key length for RSA decryption enabled in configuration. For example, if RSA-2048 is enabled, this function uses at least 512 bytes (2048 bits * 2) of stack. To shrink the stack size, please disable unused key length in configuration.
+ +
+
+ +

◆ R_RSIP_SHA_Compute()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_SHA_Compute (rsip_ctrl_t *const p_ctrl,
rsip_hash_type_t const hash_type,
uint8_t const *const p_message,
uint32_t const message_length,
uint8_t *const p_digest 
)
+
+

Generates SHA message digest.

+
Parameters
+ + + + + + +
[in,out]p_ctrlPointer to control block.
[in]hash_typeGenerating hash type.
[in]p_messagePointer to message. The length is message_length.
[in]message_lengthByte length of message (0 or more bytes).
[out]p_digestPointer to destination of message digest. The length depends on hash type.
+
+
+
Return values
+ + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_HMAC_Compute()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_HMAC_Compute (rsip_ctrl_t *const p_ctrl,
const rsip_wrapped_key_t * p_wrapped_key,
uint8_t const *const p_message,
uint32_t const message_length,
uint8_t *const p_mac 
)
+
+

Generates HMAC.

+
Parameters
+ + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_keyPointer to wrapped key of HMAC key.
[in]p_messagePointer to message. The length is message_length.
[in]message_lengthByte length of message (0 or more bytes).
[out]p_macPointer to destination of message digest. The length depends on MAC type.
+
+
+
Return values
+ + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_HMAC_Verify()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_HMAC_Verify (rsip_ctrl_t *const p_ctrl,
const rsip_wrapped_key_t * p_wrapped_key,
uint8_t const *const p_message,
uint32_t const message_length,
uint8_t const *const p_mac,
uint32_t const mac_length 
)
+
+

Verifies HMAC.

+
Parameters
+ + + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_keyPointer to wrapped key of HMAC key.
[in]p_messagePointer to message. The length is message_length.
[in]message_lengthByte length of message (0 or more bytes).
[in]p_macPointer to MAC. The length depends on mac_length.
[in]mac_lengthByte length of MAC.
    +
  • HMAC-SHA1: 4 to 20
  • +
  • HMAC-SHA224: 4 to 28
  • +
  • HMAC-SHA256 4 to 32
  • +
+
+
+
+
Return values
+ + + + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_INVALID_SIZEmac_length is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILMAC verification is failed.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_SHA_GenerateInit()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_SHA_GenerateInit (rsip_ctrl_t *const p_ctrl,
rsip_sha_handle_t *const p_handle,
rsip_hash_type_t const hash_type 
)
+
+

Prepares a SHA generation.

+
Parameters
+ + + + +
[in,out]p_ctrlPointer to control block.
[in,out]p_handlePointer to SHA control block. Must be declared by user. Elements are set here.
[in]hash_typeGenerating hash type.
+
+
+
Return values
+ + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
+
+
+ +
+
+ +

◆ R_RSIP_SHA_GenerateUpdate()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_SHA_GenerateUpdate (rsip_ctrl_t *const p_ctrl,
rsip_sha_handle_t *const p_handle,
uint8_t const *const p_message,
uint32_t const message_length 
)
+
+

Inputs message.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in,out]p_handlePointer to SHA control block.
[in]p_messagePointer to message. The length is message_length.
[in]message_lengthByte length of message (0 or more bytes).
+
+
+
Return values
+ + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_SHA_GenerateFinal()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_SHA_GenerateFinal (rsip_ctrl_t *const p_ctrl,
rsip_sha_handle_t *const p_handle,
uint8_t *const p_digest 
)
+
+

Finalizes a SHA generation.

+
Parameters
+ + + + +
[in,out]p_ctrlPointer to control block.
[in,out]p_handlePointer to SHA control block.
[out]p_digestPointer to destination of message digest. The length depends on hash type.
+
+
+
Return values
+ + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_HMAC_GenerateInit()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_HMAC_GenerateInit (rsip_ctrl_t *const p_ctrl,
rsip_hmac_handle_t *const p_handle,
rsip_wrapped_key_t const *const p_wrapped_key 
)
+
+

Prepares a HMAC generation.

+
Parameters
+ + + + +
[in,out]p_ctrlPointer to control block.
[in,out]p_handlePointer to HMAC control block. Must be declared by user. Elements are set here.
[in]p_wrapped_keyPointer to wrapped key of HMAC key.
+
+
+
Return values
+ + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
+
+
+ +
+
+ +

◆ R_RSIP_HMAC_GenerateUpdate()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_HMAC_GenerateUpdate (rsip_ctrl_t *const p_ctrl,
rsip_hmac_handle_t *const p_handle,
uint8_t const *const p_message,
uint32_t const message_length 
)
+
+

Inputs message.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in,out]p_handlePointer to HMAC control block.
[in]p_messagePointer to message. The length is message_length.
[in]message_lengthByte length of message (0 or more bytes).
+
+
+
Return values
+ + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_HMAC_GenerateFinal()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_HMAC_GenerateFinal (rsip_ctrl_t *const p_ctrl,
rsip_hmac_handle_t *const p_handle,
uint8_t *const p_mac 
)
+
+

Finalizes a HMAC generation.

+
Parameters
+ + + + +
[in,out]p_ctrlPointer to control block.
[in,out]p_handlePointer to HMAC control block.
[out]p_macPointer to destination of message digest. The length depends on MAC type.
+
+
+
Return values
+ + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_HMAC_VerifyInit()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_HMAC_VerifyInit (rsip_ctrl_t *const p_ctrl,
rsip_hmac_handle_t *const p_handle,
rsip_wrapped_key_t const *const p_wrapped_key 
)
+
+

Prepares a HMAC verification.

+
Parameters
+ + + + +
[in,out]p_ctrlPointer to control block.
[in,out]p_handlePointer to HMAC control block. Must be declared by user. Elements are set here.
[in]p_wrapped_keyPointer to wrapped key of HMAC key.
+
+
+
Return values
+ + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_INVALID_ARGUMENTInput key type is illegal.
+
+
+ +
+
+ +

◆ R_RSIP_HMAC_VerifyUpdate()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_HMAC_VerifyUpdate (rsip_ctrl_t *const p_ctrl,
rsip_hmac_handle_t *const p_handle,
uint8_t const *const p_message,
uint32_t const message_length 
)
+
+

Inputs message.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in,out]p_handlePointer to HMAC control block.
[in]p_messagePointer to message. The length is message_length.
[in]message_lengthByte length of message (0 or more bytes).
+
+
+
Return values
+ + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_HMAC_VerifyFinal()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_HMAC_VerifyFinal (rsip_ctrl_t *const p_ctrl,
rsip_hmac_handle_t *const p_handle,
uint8_t const *const p_mac,
uint32_t const mac_length 
)
+
+

Finalizes a HMAC verification.

+
Parameters
+ + + + + +
[in,out]p_ctrlPointer to control block.
[in,out]p_handlePointer to HMAC control block.
[in]p_macPointer to MAC. The length depends on mac_length.
[in]mac_lengthByte length of MAC.
    +
  • HMAC-SHA1: 4 to 20
  • +
  • HMAC-SHA224: 4 to 28
  • +
  • HMAC-SHA256 4 to 32
  • +
+
+
+
+
Return values
+ + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_INVALID_SIZEmac_length is illegal.
FSP_ERR_CRYPTO_RSIP_KEY_SET_FAILInput key value is illegal.
FSP_ERR_CRYPTO_RSIP_FAILMAC verification is failed.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+ +
+
+ +

◆ R_RSIP_KeyImportWithUFPK()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fsp_err_t R_RSIP_KeyImportWithUFPK (rsip_ctrl_t *const p_ctrl,
uint8_t const *const p_wrapped_user_factory_programming_key,
uint8_t const *const p_initial_vector,
rsip_key_type_t const key_type,
uint8_t const *const p_encrypted_key,
rsip_wrapped_key_t *const p_wrapped_key 
)
+
+

Imports a user key with UFPK (User Factory Programming Key) within the user routine.

+
Parameters
+ + + + + + + +
[in,out]p_ctrlPointer to control block.
[in]p_wrapped_user_factory_programming_keyWrapped User Factory Programming Key (W-UFPK). The length is 32 bytes.
[in]p_initial_vectorInitialization vector when generating encrypted_key. The length is 16 bytes.
[in]key_typeInputs/Outputs key type.
[in]p_encrypted_keyEncrypted user key. The length depends on the key type.
[out]p_wrapped_keyPointer to destination of wrapped key. The length depends on the key type.
+
+
+
Return values
+ + + + + + + + + + +
FSP_SUCCESSNormal termination.
FSP_ERR_ASSERTIONA required parameter is NULL.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_STATEInternal state is illegal.
FSP_ERR_NOT_ENABLEDInput key type is disabled in this function by configuration.
FSP_ERR_UNSUPPORTEDInput key type is unsupported.
FSP_ERR_CRYPTO_RSIP_FAILInput parameter is invalid.
FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICTA resource conflict occurred because a hardware resource required by the processing is in use by other processing.
FSP_ERR_CRYPTO_RSIP_FATALSoftware corruption is detected.
+
+
+
See also
Section Key Management
+ +
+
+
+
+
@ RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE
secp256r1 private key
Definition: r_rsip_api.h:390
+
fsp_err_t R_RSIP_AES_GCM_DecryptFinal(rsip_ctrl_t *const p_ctrl, uint8_t *const p_plain, uint32_t *const p_plain_length, uint8_t const *const p_tag, uint32_t const tag_length)
Definition: r_rsip_aes.c:702
+
@ RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED
RSA-2048 private key.
Definition: r_rsip_api.h:408
+
@ RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC
secp256r1 public key
Definition: r_rsip_api.h:387
+
fsp_err_t R_RSIP_Close(rsip_ctrl_t *const p_ctrl)
Definition: r_rsip.c:154
+
fsp_err_t R_RSIP_AES_GCM_DecryptInit(rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_key, uint8_t const *const p_nonce, uint32_t const nonce_length)
Definition: r_rsip_aes.c:634
+
fsp_err_t R_RSIP_AES_Cipher_DecryptInit(rsip_ctrl_t *const p_ctrl, rsip_aes_mode_t const mode, rsip_wrapped_key_t const *const p_wrapped_key, uint8_t const *const p_initial_vector)
Definition: r_rsip_aes.c:288
+
fsp_err_t R_RSIP_ECDSA_Verify(rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_public_key, uint8_t const *const p_hash, uint8_t const *const p_signature)
Definition: r_rsip_ecc.c:149
+
fsp_err_t R_RSIP_AES_Cipher_EncryptFinal(rsip_ctrl_t *const p_ctrl, uint8_t *const p_cipher, uint32_t *const p_cipher_length)
Definition: r_rsip_aes.c:229
+
fsp_err_t R_RSIP_AES_Cipher_DecryptUpdate(rsip_ctrl_t *const p_ctrl, uint8_t const *const p_cipher, uint8_t *const p_plain, uint32_t const cipher_length)
Definition: r_rsip_aes.c:348
+
fsp_err_t R_RSIP_SHA_Compute(rsip_ctrl_t *const p_ctrl, rsip_hash_type_t const hash_type, uint8_t const *const p_message, uint32_t const message_length, uint8_t *const p_digest)
Definition: r_rsip_sha.c:74
+
@ RSIP_HASH_TYPE_SHA256
SHA-256.
Definition: r_rsip_api.h:178
+
@ RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256
AES-256.
Definition: r_rsip_api.h:366
+
fsp_err_t R_RSIP_RandomNumberGenerate(rsip_ctrl_t *const p_ctrl, uint8_t *const p_random)
Definition: r_rsip.c:203
+
fsp_err_t R_RSIP_AES_Cipher_DecryptFinal(rsip_ctrl_t *const p_ctrl, uint8_t *const p_plain, uint32_t *const p_plain_length)
Definition: r_rsip_aes.c:403
+
fsp_err_t R_RSIP_RSASSA_PSS_Verify(rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_public_key, rsip_hash_type_t const hash_function, rsip_mgf_type_t const mask_generation_function, int32_t const salt_length, uint8_t const *const p_hash, uint8_t const *const p_signature)
Definition: r_rsip_rsa.c:1137
+
@ RSIP_AES_MODE_CTR
CTR (Counter)
Definition: r_rsip_api.h:169
+
fsp_err_t R_RSIP_KeyPairGenerate(rsip_ctrl_t *const p_ctrl, rsip_key_pair_type_t const key_pair_type, rsip_wrapped_key_t *const p_wrapped_public_key, rsip_wrapped_key_t *const p_wrapped_private_key)
Definition: r_rsip.c:313
+
fsp_err_t R_RSIP_RSASSA_PSS_Sign(rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_private_key, rsip_hash_type_t const hash_function, rsip_mgf_type_t const mask_generation_function, int32_t const salt_length, uint8_t const *const p_hash, uint8_t *const p_signature)
Definition: r_rsip_rsa.c:1048
+
fsp_err_t R_RSIP_AES_Cipher_EncryptUpdate(rsip_ctrl_t *const p_ctrl, uint8_t const *const p_plain, uint8_t *const p_cipher, uint32_t const plain_length)
Definition: r_rsip_aes.c:174
+
fsp_err_t R_RSIP_AES_GCM_EncryptFinal(rsip_ctrl_t *const p_ctrl, uint8_t *const p_cipher, uint32_t *const p_cipher_length, uint8_t *const p_tag)
Definition: r_rsip_aes.c:523
+
@ RSIP_MGF_TYPE_MGF1_SHA256
MGF1 with SHA-256.
Definition: r_rsip_api.h:190
+
@ RSIP_KEY_PAIR_TYPE_ECC_secp256r1
secp256r1 key pair (also known as NIST P-256, prime256v1)
Definition: r_rsip_api.h:153
+
fsp_err_t R_RSIP_ECDSA_Sign(rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_private_key, uint8_t const *const p_hash, uint8_t *const p_signature)
Definition: r_rsip_ecc.c:60
+
fsp_err_t R_RSIP_AES_GCM_EncryptUpdate(rsip_ctrl_t *const p_ctrl, uint8_t const *const p_plain, uint8_t *const p_cipher, uint32_t const plain_length, uint8_t const *const p_aad, uint32_t const aad_length)
Definition: r_rsip_aes.c:493
+
fsp_err_t R_RSIP_AES_GCM_DecryptUpdate(rsip_ctrl_t *const p_ctrl, uint8_t const *const p_cipher, uint8_t *const p_plain, uint32_t const cipher_length, uint8_t const *const p_aad, uint32_t const aad_length)
Definition: r_rsip_aes.c:669
+
fsp_err_t R_RSIP_AES_GCM_EncryptInit(rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_key, uint8_t const *const p_nonce, uint32_t const nonce_length)
Definition: r_rsip_aes.c:458
+
fsp_err_t R_RSIP_RSAES_OAEP_Decrypt(rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_private_key, rsip_hash_type_t const hash_function, rsip_mgf_type_t const mask_generation_function, uint8_t const *const p_label, uint32_t const label_length, uint8_t const *const p_cipher, uint8_t *const p_plain, uint32_t *const p_plain_length, uint32_t const plain_buffer_length)
Definition: r_rsip_rsa.c:695
+
fsp_err_t R_RSIP_AES_Cipher_EncryptInit(rsip_ctrl_t *const p_ctrl, rsip_aes_mode_t const mode, rsip_wrapped_key_t const *const p_wrapped_key, uint8_t const *const p_initial_vector)
Definition: r_rsip_aes.c:114
+
@ RSIP_KEY_TYPE_AES_256
AES-256.
Definition: r_rsip_api.h:104
+
fsp_err_t R_RSIP_SHA_GenerateUpdate(rsip_ctrl_t *const p_ctrl, rsip_sha_handle_t *const p_handle, uint8_t const *const p_message, uint32_t const message_length)
Definition: r_rsip_sha.c:376
+
#define RSIP_RSA_SALT_LENGTH_AUTO
Definition: r_rsip_api.h:66
+
fsp_err_t R_RSIP_RSAES_OAEP_Encrypt(rsip_ctrl_t *const p_ctrl, rsip_wrapped_key_t const *const p_wrapped_public_key, rsip_hash_type_t const hash_function, rsip_mgf_type_t const mask_generation_function, uint8_t const *const p_label, uint32_t const label_length, uint8_t const *const p_plain, uint32_t const plain_length, uint8_t *const p_cipher)
Definition: r_rsip_rsa.c:516
+
fsp_err_t R_RSIP_KeyGenerate(rsip_ctrl_t *const p_ctrl, rsip_key_type_t const key_type, rsip_wrapped_key_t *const p_wrapped_key)
Definition: r_rsip.c:237
+
fsp_err_t R_RSIP_Open(rsip_ctrl_t *const p_ctrl, rsip_cfg_t const *const p_cfg)
Definition: r_rsip.c:77
+
@ RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED
RSA-2048 public key.
Definition: r_rsip_api.h:405
+
fsp_err_t R_RSIP_SHA_GenerateInit(rsip_ctrl_t *const p_ctrl, rsip_sha_handle_t *const p_handle, rsip_hash_type_t const hash_type)
Definition: r_rsip_sha.c:344
+
fsp_err_t R_RSIP_SHA_GenerateFinal(rsip_ctrl_t *const p_ctrl, rsip_sha_handle_t *const p_handle, uint8_t *const p_digest)
Definition: r_rsip_sha.c:409
+
@ RSIP_KEY_PAIR_TYPE_RSA_2048
RSA-2048 key pair.
Definition: r_rsip_api.h:157
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p.js new file mode 100644 index 000000000..7f116c271 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p.js @@ -0,0 +1,55 @@ +var group___r_s_i_p = +[ + [ "st_rsip_instance_ctrl", "group___r_s_i_p.html#structst__rsip__instance__ctrl", null ], + [ "R_RSIP_Open", "group___r_s_i_p.html#ga0f3222e34aedf16a9eeba214db0aeeac", null ], + [ "R_RSIP_Close", "group___r_s_i_p.html#gac7848f48d9f8484cb17e156e299046fe", null ], + [ "R_RSIP_RandomNumberGenerate", "group___r_s_i_p.html#ga004e5a8c7361e446809f4cba8fb4a493", null ], + [ "R_RSIP_KeyGenerate", "group___r_s_i_p.html#ga2dc3a8de5422978d001750fa120df176", null ], + [ "R_RSIP_KeyPairGenerate", "group___r_s_i_p.html#gacbc429a31f21d4a409d40ef7c8704c96", null ], + [ "R_RSIP_KeyImportWithKUK", "group___r_s_i_p.html#ga183fb4be47cd4156e16887087d9aa7e7", null ], + [ "R_RSIP_ECCPublicKeyExport", "group___r_s_i_p.html#ga0cfe8c89cee5df215b42d72f56f05fd7", null ], + [ "R_RSIP_RSAPublicKeyExport", "group___r_s_i_p.html#ga2406d2768cd35af5129101eafb6e0f95", null ], + [ "R_RSIP_AES_Cipher_EncryptInit", "group___r_s_i_p.html#gaf7ef1afdfa6e0485ac25b096b7bcf9ce", null ], + [ "R_RSIP_AES_Cipher_EncryptUpdate", "group___r_s_i_p.html#gab4d578ccdc90b571f7ba0a63e009a527", null ], + [ "R_RSIP_AES_Cipher_EncryptFinal", "group___r_s_i_p.html#ga93448d8822300805e51e82e4d740d343", null ], + [ "R_RSIP_AES_Cipher_DecryptInit", "group___r_s_i_p.html#ga2bf24039437c98ec88756fa061e034de", null ], + [ "R_RSIP_AES_Cipher_DecryptUpdate", "group___r_s_i_p.html#gafafae41b7a4bc678044880c7b713ef40", null ], + [ "R_RSIP_AES_Cipher_DecryptFinal", "group___r_s_i_p.html#ga51698d930e957b5582afb6d439988280", null ], + [ "R_RSIP_AES_GCM_EncryptInit", "group___r_s_i_p.html#ga05bb680ea48c54adb50804631a0324a9", null ], + [ "R_RSIP_AES_GCM_EncryptUpdate", "group___r_s_i_p.html#gab43537eaf3eae896e79ecbd34b4c21c6", null ], + [ "R_RSIP_AES_GCM_EncryptFinal", "group___r_s_i_p.html#ga82e9872bf11e0a0bcf4c3e36f327ebbb", null ], + [ "R_RSIP_AES_GCM_DecryptInit", "group___r_s_i_p.html#ga883c34556cb6dd27d9dbd8f32fa0022b", null ], + [ "R_RSIP_AES_GCM_DecryptUpdate", "group___r_s_i_p.html#ga05583899c77d206a9ef09e9d8dd29b78", null ], + [ "R_RSIP_AES_GCM_DecryptFinal", "group___r_s_i_p.html#ga97c42f1430d18f9c1e7e9b1fd0e69de1", null ], + [ "R_RSIP_AES_CMAC_GenerateInit", "group___r_s_i_p.html#ga9f4b6ce398b0b9ccff8826c34512ad33", null ], + [ "R_RSIP_AES_CMAC_GenerateUpdate", "group___r_s_i_p.html#ga40add84d634c86a265a1d5861d8695a1", null ], + [ "R_RSIP_AES_CMAC_GenerateFinal", "group___r_s_i_p.html#ga73e956dc3b778d329a51548ec2d8da44", null ], + [ "R_RSIP_AES_CMAC_VerifyInit", "group___r_s_i_p.html#ga0da0a1ff141aeb28f48d28aa173bcc96", null ], + [ "R_RSIP_AES_CMAC_VerifyUpdate", "group___r_s_i_p.html#ga996cf26b4bd4b2b8bf68ebaaca8ac986", null ], + [ "R_RSIP_AES_CMAC_VerifyFinal", "group___r_s_i_p.html#ga9daea7a9e8c9c595b5d3ba3b6302e339", null ], + [ "R_RSIP_ECDSA_Sign", "group___r_s_i_p.html#ga51b427c5ed2f8d2980d6c29a68951f3c", null ], + [ "R_RSIP_ECDSA_Verify", "group___r_s_i_p.html#ga4001cf997810be799f9873f7f19f515c", null ], + [ "R_RSIP_RSA_Encrypt", "group___r_s_i_p.html#ga5ab165c8834057601821bb486e8e9855", null ], + [ "R_RSIP_RSA_Decrypt", "group___r_s_i_p.html#gaf2afe4d205b51f1c434ac0e4dd24a137", null ], + [ "R_RSIP_RSAES_PKCS1_V1_5_Encrypt", "group___r_s_i_p.html#gaee51f26eb1994439e790cc736ab17eab", null ], + [ "R_RSIP_RSAES_PKCS1_V1_5_Decrypt", "group___r_s_i_p.html#ga83eb46af309c6539abdedc3333859179", null ], + [ "R_RSIP_RSAES_OAEP_Encrypt", "group___r_s_i_p.html#ga1e2bb479037a936aac115f73fcc6788f", null ], + [ "R_RSIP_RSAES_OAEP_Decrypt", "group___r_s_i_p.html#ga212e1d21390f8ea72bd91c844375399f", null ], + [ "R_RSIP_RSASSA_PKCS1_V1_5_Sign", "group___r_s_i_p.html#ga2645bf20337f5746c0e16aa809f33cf4", null ], + [ "R_RSIP_RSASSA_PKCS1_V1_5_Verify", "group___r_s_i_p.html#ga5312c9f027c45ecb2779c99e6c7e72ff", null ], + [ "R_RSIP_RSASSA_PSS_Sign", "group___r_s_i_p.html#ga99f7fd3650b5167e0969e2cb681b763a", null ], + [ "R_RSIP_RSASSA_PSS_Verify", "group___r_s_i_p.html#gac79f1b11849d19e8dfa7f90276e68e77", null ], + [ "R_RSIP_SHA_Compute", "group___r_s_i_p.html#ga8517124a32ed6bea90f2d0c82885eed7", null ], + [ "R_RSIP_HMAC_Compute", "group___r_s_i_p.html#gafd208f1c55bdd1e5c6f6ef8e09f61e3f", null ], + [ "R_RSIP_HMAC_Verify", "group___r_s_i_p.html#ga601bce8a7997bfad866e278d1b0133c4", null ], + [ "R_RSIP_SHA_GenerateInit", "group___r_s_i_p.html#gade4e2469c7b564412b1ff93695e009d1", null ], + [ "R_RSIP_SHA_GenerateUpdate", "group___r_s_i_p.html#gac4e40a3e418dd33ad6d3a062b7820908", null ], + [ "R_RSIP_SHA_GenerateFinal", "group___r_s_i_p.html#ga197111ff5c0da56f545ed60a3ce5271a", null ], + [ "R_RSIP_HMAC_GenerateInit", "group___r_s_i_p.html#ga35ce74c94050adbacbf6a05c2135000f", null ], + [ "R_RSIP_HMAC_GenerateUpdate", "group___r_s_i_p.html#gaa41e41608057985c7a60036b49dd7425", null ], + [ "R_RSIP_HMAC_GenerateFinal", "group___r_s_i_p.html#ga9b4cf45516cbd962c3ddc011a4d6c41b", null ], + [ "R_RSIP_HMAC_VerifyInit", "group___r_s_i_p.html#ga8f8758d50640071cf33c906ac56699c7", null ], + [ "R_RSIP_HMAC_VerifyUpdate", "group___r_s_i_p.html#gad6de1c75e4f7cf9ca361b5fbc1c875d2", null ], + [ "R_RSIP_HMAC_VerifyFinal", "group___r_s_i_p.html#ga8bb6027da5a6113528b82492511e6259", null ], + [ "R_RSIP_KeyImportWithUFPK", "group___r_s_i_p.html#ga0e45064b017808306219d8178ccb4966", null ] +]; \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p___a_p_i.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p___a_p_i.html new file mode 100644 index 000000000..91a255a11 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p___a_p_i.html @@ -0,0 +1,973 @@ + + + + + + + +R_RSIP Documentation: RSIP Interface + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
RSIP Interface
+
+
+

Detailed Description

+

Interface for Renesas Secure IP (RSIP) functions.

+

+Summary

+

The RSIP interface provides RSIP functionality.

+

The RSIP interface can be implemented by:

+ + + + + + + + + + + + +

+Data Structures

struct  st_rsip_wrapped_key
 
struct  st_rsip_sha_handle
 
struct  st_rsip_hmac_handle
 
struct  st_rsip_cfg
 
struct  st_rsip_instance
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Macros

+#define FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT
 Hardware resource is busy.
 
+#define FSP_ERR_CRYPTO_RSIP_FATAL
 Hardware fatal error or unexpected return.
 
+#define FSP_ERR_CRYPTO_RSIP_FAIL
 Internal error.
 
+#define FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL
 Input key type is illegal.
 
+#define FSP_ERR_CRYPTO_RSIP_AUTHENTICATION
 Authentication failed.
 
+#define FSP_ERR_SB_INTERNAL_FAIL
 An internal failure.
 
+#define FSP_ERR_SB_INVALID_ARG
 An invalid argument was entered.
 
+#define FSP_ERR_SB_UNSUPPORTED_FUNCTION
 Unsupported function executed.
 
+#define FSP_ERR_SB_INVALID_ALIGNMENT
 Data entered with incorrect alignment.
 
+#define FSP_ERR_SB_MANI_INVALID_MAGIC
 An invalid magic number is set.
 
+#define FSP_ERR_SB_MANI_UNSUPPORTED_VERSION
 Unsupported version is set.
 
+#define FSP_ERR_SB_MANI_OUT_OF_RANGE_LEN
 Out of range TLV Length is set.
 
+#define FSP_ERR_SB_MANI_TLV_FIELD_ERR
 Missing required TLV field.
 
+#define FSP_ERR_SB_MANI_TLV_INVALID_LEN
 The length exceeding the end of the manifest is specified in length of the TLV field.
 
+#define FSP_ERR_SB_MANI_INVALID_IMAGE_LEN
 An invalid image length is set.
 
+#define FSP_ERR_SB_MANI_MISMATCH_SIGN_ALGORITHM
 There is a wrong combination of signature algorithms.
 
+#define FSP_ERR_SB_MANI_UNSUPPORTED_ALGORITHM
 An algorithm was specified that the manifest does not support.
 
+#define FSP_ERR_SB_CRYPTO_FAIL
 Cryptographic processing failure.
 
+#define FSP_ERR_SB_CRYPTO_AUTH_FAIL
 Verification failed.
 
+#define FSP_ERR_SB_CRYPTO_UNSUPPORTED_ALGORITHM
 Unsupported algorithm.
 
+#define FSP_ERR_SB_CRYPTO_RESOURCE_CONFLICT
 CryptoIP is in use.
 
+#define FSP_ERR_SB_CRYPTO_PARAM_ERR
 Parameter error.
 
#define RSIP_RSA_SALT_LENGTH_AUTO
 
#define RSIP_RSA_SALT_LENGTH_HASH
 
#define RSIP_RSA_SALT_LENGTH_MAX
 
+ + + +

+Typedefs

typedef void rsip_ctrl_t
 
+ + + + + + + + + + + + + + + + + + + +

+Enumerations

enum  e_rsip_key_type
 
enum  e_rsip_key_pair_type
 
enum  e_rsip_aes_mode
 
enum  e_rsip_hash_type
 
enum  e_rsip_mgf_type
 
enum  e_password_type
 
enum  e_rsip_byte_size_encrypted_key
 
enum  e_rsip_byte_size_wrapped_key_value
 
enum  e_rsip_byte_size_wrapped_key
 
+

Data Structure Documentation

+ +

◆ st_rsip_wrapped_key

+ +
+
+ + + + +
struct st_rsip_wrapped_key
+
+

Wrapped key structure for all supported algorithms. The struct length of each algorithm is defined by RSIP_BYTE_SIZE_WRAPPED_KEY macro.

+
+ + + + + + + +
Data Fields
+rsip_key_type_t +type +type of wrapped key
+uint8_t +value[] +variable length array to store the key value
+ +
+
+ +

◆ st_rsip_sha_handle

+ +
+
+ + + + +
struct st_rsip_sha_handle
+
+

Working area for SHA cipher functions. DO NOT MODIFY.

+
+
+
+ +

◆ st_rsip_hmac_handle

+ +
+
+ + + + +
struct st_rsip_hmac_handle
+
+

Working area for HMAC cipher functions. DO NOT MODIFY.

+
+
+
+ +

◆ st_rsip_cfg

+ +
+
+ + + + +
struct st_rsip_cfg
+
+

User configuration structure, used in open function

+
+ + + + +
Data Fields
+const void * +p_extend +Hardware-dependent configuration.
+ +
+
+ +

◆ st_rsip_instance

+ +
+
+ + + + +
struct st_rsip_instance
+
+

This structure encompasses everything that is needed to use an instance of this interface.

+
+ + + + + + + +
Data Fields
+rsip_ctrl_t * +p_ctrl +Pointer to the control structure for this instance.
+const rsip_cfg_t * +p_cfg +Pointer to the configuration structure for this instance.
+ +
+
+

Macro Definition Documentation

+ +

◆ RSIP_RSA_SALT_LENGTH_AUTO

+ +
+
+ + + + +
#define RSIP_RSA_SALT_LENGTH_AUTO
+
+

When signing, the salt length is set to RSIP_RSA_SALT_LENGTH_MAX or RSIP_RSA_SALT_LENGTH_HASH, whichever is shorter. When verifying, the salt length is detected automatically.

+ +
+
+ +

◆ RSIP_RSA_SALT_LENGTH_HASH

+ +
+
+ + + + +
#define RSIP_RSA_SALT_LENGTH_HASH
+
+

The salt length is set to the hash length.

+ +
+
+ +

◆ RSIP_RSA_SALT_LENGTH_MAX

+ +
+
+ + + + +
#define RSIP_RSA_SALT_LENGTH_MAX
+
+

The salt length is set to emLen - hLen - 2, where emLen is the same as the key length and hLen is the hash length.

+ +
+
+

Typedef Documentation

+ +

◆ rsip_ctrl_t

+ +
+
+ + + + +
typedef void rsip_ctrl_t
+
+

RSIP Control block. Allocate an instance specific control block to pass into the API calls.

Implemented as
    +
  • rsip_instance_ctrl_t
  • +
+
+ +
+
+

Enumeration Type Documentation

+ +

◆ e_rsip_key_type

+ +
+
+ + + + +
enum e_rsip_key_type
+
+

Key types

Deprecated:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Enumerator
RSIP_KEY_TYPE_INVALID 

Invalid key.

+
RSIP_KEY_TYPE_AES_128 

AES-128.

+
RSIP_KEY_TYPE_AES_256 

AES-256.

+
RSIP_KEY_TYPE_AES_128_XTS 

AES-128-XTS.

+
RSIP_KEY_TYPE_AES_256_XTS 

AES-256-XTS.

+
RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC 

secp192r1 public key (also known as NIST P-192, prime192v1)

+
RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE 

secp192r1 private key (also known as NIST P-192, prime192v1)

+
RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC 

secp224r1 public key (also known as NIST P-224, prime224v1)

+
RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE 

secp224r1 private key (also known as NIST P-224, prime224v1)

+
RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC 

secp256r1 public key (also known as NIST P-256, prime256v1)

+
RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE 

secp256r1 private key (also known as NIST P-256, prime256v1)

+
RSIP_KEY_TYPE_HMAC_SHA1 

HMAC-SHA1.

+
RSIP_KEY_TYPE_HMAC_SHA224 

HMAC-SHA224.

+
RSIP_KEY_TYPE_HMAC_SHA256 

HMAC-SHA256.

+
RSIP_KEY_TYPE_KEY_UPDATE_KEY 

KUK (Key Update Key)

+
RSIP_KEY_TYPE_SECURE_BOOT_DECRYPTION 

Image decryption key for secure boot (supported devices only)

+
RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED 

RSA-1024 public key.

+
RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED 

RSA-1024 private key.

+
RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED 

RSA-2048 public key.

+
RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED 

RSA-2048 private key.

+
RSIP_KEY_TYPE_RSA_3072_PUBLIC 

RSA-3072 public key.

+
RSIP_KEY_TYPE_RSA_3072_PRIVATE 

RSA-3072 private key.

+
RSIP_KEY_TYPE_RSA_4096_PUBLIC 

RSA-4096 public key.

+
RSIP_KEY_TYPE_RSA_4096_PRIVATE 

RSA-4096 private key.

+
RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC 

brainpoolP256r1 public key

+
RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE 

brainpoolP256r1 private key

+
+ +
+
+ +

◆ e_rsip_key_pair_type

+ +
+
+ + + + +
enum e_rsip_key_pair_type
+
+

Key pair types

Deprecated:
+
+ + + + + + + + + + +
Enumerator
RSIP_KEY_PAIR_TYPE_INVALID 

Invalid key pair type.

+
RSIP_KEY_PAIR_TYPE_ECC_secp192r1 

secp192r1 key pair (also known as NIST P-192, prime192v1)

+
RSIP_KEY_PAIR_TYPE_ECC_secp224r1 

secp224r1 key pair (also known as NIST P-224, prime224v1)

+
RSIP_KEY_PAIR_TYPE_ECC_secp256r1 

secp256r1 key pair (also known as NIST P-256, prime256v1)

+
RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1 

brainpoolP256r1 key pair

+
RSIP_KEY_PAIR_TYPE_RSA_1024 

RSA-1024 key pair.

+
RSIP_KEY_PAIR_TYPE_RSA_2048 

RSA-2048 key pair.

+
RSIP_KEY_PAIR_TYPE_RSA_3072 

RSA-3072 key pair.

+
RSIP_KEY_PAIR_TYPE_RSA_4096 

RSA-4096 key pair.

+
+ +
+
+ +

◆ e_rsip_aes_mode

+ +
+
+ + + + +
enum e_rsip_aes_mode
+
+

Block cipher modes of operation for AES

+ + + + + +
Enumerator
RSIP_AES_MODE_ECB 

ECB (Electronic codebook)

+
RSIP_AES_MODE_CBC 

CBC (Cipher block chaining)

+
RSIP_AES_MODE_CTR 

CTR (Counter)

+
RSIP_AES_MODE_XTS 

XTS (XEX-based tweaked-codebook mode with ciphertext stealing)

+
+ +
+
+ +

◆ e_rsip_hash_type

+ +
+
+ + + + +
enum e_rsip_hash_type
+
+

Hash type

+ + + + + + + + +
Enumerator
RSIP_HASH_TYPE_SHA1 

SHA-1.

+
RSIP_HASH_TYPE_SHA224 

SHA-224.

+
RSIP_HASH_TYPE_SHA256 

SHA-256.

+
RSIP_HASH_TYPE_SHA384 

SHA-384.

+
RSIP_HASH_TYPE_SHA512 

SHA-512.

+
RSIP_HASH_TYPE_SHA512_224 

SHA-512/224.

+
RSIP_HASH_TYPE_SHA512_256 

SHA-512/256.

+
+ +
+
+ +

◆ e_rsip_mgf_type

+ +
+
+ + + + +
enum e_rsip_mgf_type
+
+

MGF type

+ + + + + + + + +
Enumerator
RSIP_MGF_TYPE_MGF1_SHA1 

MGF1 with SHA-1.

+
RSIP_MGF_TYPE_MGF1_SHA224 

MGF1 with SHA-224.

+
RSIP_MGF_TYPE_MGF1_SHA256 

MGF1 with SHA-256.

+
RSIP_MGF_TYPE_MGF1_SHA384 

MGF1 with SHA-384.

+
RSIP_MGF_TYPE_MGF1_SHA512 

MGF1 with SHA-512.

+
RSIP_MGF_TYPE_MGF1_SHA512_224 

MGF1 with SHA-512/224.

+
RSIP_MGF_TYPE_MGF1_SHA512_256 

MGF1 with SHA-512/256.

+
+ +
+
+ +

◆ e_password_type

+ +
+
+ + + + +
enum e_password_type
+
+

Password type. This enumerated type is used only on specific devices.

+ + + +
Enumerator
RSIP_PASSWORD_TYPE_JTAG_DEBUG_AUTHENTICATION_LEVEL1 

JTAG debug authentication level 1.

+
RSIP_PASSWORD_TYPE_JTAG_DEBUG_AUTHENTICATION_LEVEL2 

JTAG debug authentication level 2.

+
+ +
+
+ +

◆ e_rsip_byte_size_encrypted_key

+ +
+
+

Byte size of encrypted key

Deprecated:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Enumerator
RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128 

AES-128.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256 

AES-256.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128_XTS 

AES-128-XTS.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256_XTS 

AES-256-XTS.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PUBLIC 

secp192r1 public key

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PRIVATE 

secp192r1 private key

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PUBLIC 

secp224r1 public key

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PRIVATE 

secp224r1 private key

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PUBLIC 

secp256r1 public key

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PRIVATE 

secp256r1 private key

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PUBLIC 

brainpoolP256r1 public key

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PRIVATE 

brainpoolP256r1 private key

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PUBLIC_ENHANCED 

RSA-1024 public key.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PRIVATE_ENHANCED 

RSA-1024 private key.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PUBLIC_ENHANCED 

RSA-2048 public key.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PRIVATE_ENHANCED 

RSA-2048 private key.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PUBLIC 

RSA-3072 public key.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PRIVATE 

RSA-3072 private key.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PUBLIC 

RSA-4096 public key.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PRIVATE 

RSA-4096 private key.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA1 

HMAC-SHA1 private key.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA224 

HMAC-SHA224 private key.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA256 

HMAC-SHA256 private key.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_KEY_UPDATE_KEY 

Key Update Key (KUK)

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_MAX 

Maximum length in AES keys.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PUBLIC_MAX 

Maximum length in ECC public keys.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PRIVATE_MAX 

Maximum length in ECC private keys.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PUBLIC_MAX 

Maximum length in RSA public keys.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PRIVATE_MAX 

Maximum length in RSA private keys.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_MAX 

Maximum length in HMAC keys.

+
RSIP_BYTE_SIZE_ENCRYPTED_KEY_MAX 

Maximum length in all RSIP keys.

+
+ +
+
+ +

◆ e_rsip_byte_size_wrapped_key_value

+ +
+
+

Byte size of wrapped key (value)

Deprecated:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Enumerator
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128 

AES-128.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256 

AES-256.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128_XTS 

AES-128-XTS.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256_XTS 

AES-256-XTS.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PUBLIC 

secp192r1 public key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PRIVATE 

secp192r1 private key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PUBLIC 

secp224r1 public key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PRIVATE 

secp224r1 private key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PUBLIC 

secp256r1 public key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PRIVATE 

secp256r1 private key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PUBLIC 

brainpoolP256r1 public key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PRIVATE 

brainpoolP256r1 private key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PUBLIC_ENHANCED 

RSA-1024 public key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PRIVATE_ENHANCED 

RSA-1024 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PUBLIC_ENHANCED 

RSA-2048 public key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PRIVATE_ENHANCED 

RSA-2048 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PUBLIC 

RSA-3072 public key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PRIVATE 

RSA-3072 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PUBLIC 

RSA-4096 public key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PRIVATE 

RSA-4096 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA1 

HMAC-SHA1 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA224 

HMAC-SHA224 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA256 

HMAC-SHA256 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_KEY_UPDATE_KEY 

Key Update Key (KUK)

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_MAX 

Maximum length in AES keys.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PUBLIC_MAX 

Maximum length in ECC public keys.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PRIVATE_MAX 

Maximum length in ECC private keys.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PUBLIC_MAX 

Maximum length in RSA public keys.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PRIVATE_MAX 

Maximum length in RSA private keys.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_MAX 

Maximum length in HMAC keys.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_MAX 

Maximum length in all RSIP keys.

+
+ +
+
+ +

◆ e_rsip_byte_size_wrapped_key

+ +
+
+

Byte size of wrapped key (header + value)

Deprecated:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Enumerator
RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128 

AES-128.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256 

AES-256.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128_XTS 

AES-128-XTS.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256_XTS 

AES-256-XTS.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PUBLIC 

secp192r1 public key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PRIVATE 

secp192r1 private key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PUBLIC 

secp224r1 public key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PRIVATE 

secp224r1 private key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC 

secp256r1 public key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE 

secp256r1 private key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PUBLIC 

brainpoolP256r1 public key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PRIVATE 

brainpoolP256r1 private key

+
RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED 

RSA-1024 public key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED 

RSA-1024 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED 

RSA-2048 public key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED 

RSA-2048 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC 

RSA-3072 public key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE 

RSA-3072 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC 

RSA-4096 public key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE 

RSA-4096 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA1 

HMAC-SHA1 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA224 

HMAC-SHA224 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA256 

HMAC-SHA256 private key.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_KEY_UPDATE_KEY 

Key Update Key (KUK)

+
RSIP_BYTE_SIZE_WRAPPED_KEY_AES_MAX 

Maximum length in AES keys.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PUBLIC_MAX 

Maximum length in ECC public keys.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PRIVATE_MAX 

Maximum length in ECC private keys.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PUBLIC_MAX 

Maximum length in RSA public keys.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PRIVATE_MAX 

Maximum length in RSA private keys.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_MAX 

Maximum length in HMAC keys.

+
RSIP_BYTE_SIZE_WRAPPED_KEY_MAX 

Maximum length in all RSIP keys.

+
+ +
+
+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p___a_p_i.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p___a_p_i.js new file mode 100644 index 000000000..8712ead90 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/group___r_s_i_p___a_p_i.js @@ -0,0 +1,208 @@ +var group___r_s_i_p___a_p_i = +[ + [ "st_rsip_wrapped_key", "group___r_s_i_p___a_p_i.html#structst__rsip__wrapped__key", [ + [ "type", "group___r_s_i_p___a_p_i.html#a8bd2f326e4b02652713870b0f0a7be27", null ], + [ "value", "group___r_s_i_p___a_p_i.html#adea2e89755d0cba606102f718b7b63d6", null ] + ] ], + [ "st_rsip_sha_handle", "group___r_s_i_p___a_p_i.html#structst__rsip__sha__handle", null ], + [ "st_rsip_hmac_handle", "group___r_s_i_p___a_p_i.html#structst__rsip__hmac__handle", null ], + [ "st_rsip_cfg", "group___r_s_i_p___a_p_i.html#structst__rsip__cfg", [ + [ "p_extend", "group___r_s_i_p___a_p_i.html#ad275dec7a146f7c5dd92b67dd289df43", null ] + ] ], + [ "st_rsip_instance", "group___r_s_i_p___a_p_i.html#structst__rsip__instance", [ + [ "p_ctrl", "group___r_s_i_p___a_p_i.html#aabb64a2dddc53a5ffa8a6e618d0bf999", null ], + [ "p_cfg", "group___r_s_i_p___a_p_i.html#a1db23440fe44a1681f863478050f4c2f", null ] + ] ], + [ "FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT", "group___r_s_i_p___a_p_i.html#ga8d12b8569feb694fad5e5ab9eb4ac0f1", null ], + [ "FSP_ERR_CRYPTO_RSIP_FATAL", "group___r_s_i_p___a_p_i.html#ga9b36eedb833a5cad351853206c1a3efc", null ], + [ "FSP_ERR_CRYPTO_RSIP_FAIL", "group___r_s_i_p___a_p_i.html#ga1fa0c5f944888c2bb516161b568b3f8b", null ], + [ "FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL", "group___r_s_i_p___a_p_i.html#gaa95d73100dc245594ecb22512820819c", null ], + [ "FSP_ERR_CRYPTO_RSIP_AUTHENTICATION", "group___r_s_i_p___a_p_i.html#ga74eeb2ef3d74984dbf3ffb7c37bf543e", null ], + [ "FSP_ERR_SB_INTERNAL_FAIL", "group___r_s_i_p___a_p_i.html#ga5a3ff940a6dd4274adb2bb743f89cb74", null ], + [ "FSP_ERR_SB_INVALID_ARG", "group___r_s_i_p___a_p_i.html#ga8b60d187d644c7d7bf94f9acc9a52126", null ], + [ "FSP_ERR_SB_UNSUPPORTED_FUNCTION", "group___r_s_i_p___a_p_i.html#ga20b71bf29235caea74fc24c087e8b99c", null ], + [ "FSP_ERR_SB_INVALID_ALIGNMENT", "group___r_s_i_p___a_p_i.html#ga476579ab816d13afeab1221b1eb5cbe3", null ], + [ "FSP_ERR_SB_MANI_INVALID_MAGIC", "group___r_s_i_p___a_p_i.html#gaea2a2a260e5a04d10eb7a4130707151e", null ], + [ "FSP_ERR_SB_MANI_UNSUPPORTED_VERSION", "group___r_s_i_p___a_p_i.html#ga46a72cafbd7e6b57d4d63f00ba7c3e6d", null ], + [ "FSP_ERR_SB_MANI_OUT_OF_RANGE_LEN", "group___r_s_i_p___a_p_i.html#ga332ec419c4f5ba9265cacaddc4874321", null ], + [ "FSP_ERR_SB_MANI_TLV_FIELD_ERR", "group___r_s_i_p___a_p_i.html#gaf5ddd0355b84440506e0866ed7825f8f", null ], + [ "FSP_ERR_SB_MANI_TLV_INVALID_LEN", "group___r_s_i_p___a_p_i.html#ga94870c76aaec736ff9bc880daa556b2d", null ], + [ "FSP_ERR_SB_MANI_INVALID_IMAGE_LEN", "group___r_s_i_p___a_p_i.html#gaab3995110fedc2ca74301ce673f98fa7", null ], + [ "FSP_ERR_SB_MANI_MISMATCH_SIGN_ALGORITHM", "group___r_s_i_p___a_p_i.html#gaf0745ee55b1f2939309de8e05be194ec", null ], + [ "FSP_ERR_SB_MANI_UNSUPPORTED_ALGORITHM", "group___r_s_i_p___a_p_i.html#gac7284516f203a639fe572757d0d8764d", null ], + [ "FSP_ERR_SB_CRYPTO_FAIL", "group___r_s_i_p___a_p_i.html#ga2becc62a266e021dbd40e3d94e5407b7", null ], + [ "FSP_ERR_SB_CRYPTO_AUTH_FAIL", "group___r_s_i_p___a_p_i.html#ga48a79bedac05bb9eaf4f7a548a8afb2a", null ], + [ "FSP_ERR_SB_CRYPTO_UNSUPPORTED_ALGORITHM", "group___r_s_i_p___a_p_i.html#ga41100687f112b08951d71d4f11ca9170", null ], + [ "FSP_ERR_SB_CRYPTO_RESOURCE_CONFLICT", "group___r_s_i_p___a_p_i.html#gaa8e64530bfed122a6d72f9740836da9e", null ], + [ "FSP_ERR_SB_CRYPTO_PARAM_ERR", "group___r_s_i_p___a_p_i.html#gacad0d7d833bedc26c8594ce335700038", null ], + [ "RSIP_RSA_SALT_LENGTH_AUTO", "group___r_s_i_p___a_p_i.html#ga82b6474de04af6fc9d99c1cac82b9415", null ], + [ "RSIP_RSA_SALT_LENGTH_HASH", "group___r_s_i_p___a_p_i.html#ga2c1db9497cde878229e095d907ca3666", null ], + [ "RSIP_RSA_SALT_LENGTH_MAX", "group___r_s_i_p___a_p_i.html#ga2856e1895eab748a16ac87d328058fea", null ], + [ "rsip_ctrl_t", "group___r_s_i_p___a_p_i.html#ga2042507aed5dec71014a96b91aeaa4fa", null ], + [ "e_rsip_key_type", "group___r_s_i_p___a_p_i.html#ga1a940940c082b526361300f166136be0", [ + [ "RSIP_KEY_TYPE_INVALID", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ae95be99956cace7717544ddea792d0e9", null ], + [ "RSIP_KEY_TYPE_AES_128", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a86a9d2eba8d8e913beb35a9ef77719ea", null ], + [ "RSIP_KEY_TYPE_AES_256", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ac73d8d9299a235cdd03315cc8d4cf10c", null ], + [ "RSIP_KEY_TYPE_AES_128_XTS", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a5f636e29ceafce90ea5b4cbe8df24211", null ], + [ "RSIP_KEY_TYPE_AES_256_XTS", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0af5ee03fb23a509757252d4d07aedc17b", null ], + [ "RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ad8ddf883a2b65ea563f8b79c03143f92", null ], + [ "RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa3eee3aadcfb68ffc5f545f2342a6ed9", null ], + [ "RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa9dac8ec3d4329e2bf539b541398f847", null ], + [ "RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a2b82d7ba783f63eeaf81504b1663e994", null ], + [ "RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ad3c283cb6ecf75b790df5f500674f94e", null ], + [ "RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a8c86ca396f98786e5f4775afb699c799", null ], + [ "RSIP_KEY_TYPE_HMAC_SHA1", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a34ac6f0f7727f34302ebe5f433e8679a", null ], + [ "RSIP_KEY_TYPE_HMAC_SHA224", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa0ea2d8e02d46a57d4529a6a823af475", null ], + [ "RSIP_KEY_TYPE_HMAC_SHA256", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ad06544b015f3cb6936a8edb30fd76795", null ], + [ "RSIP_KEY_TYPE_KEY_UPDATE_KEY", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a41528f99f9213d6427f80f920bf41a0c", null ], + [ "RSIP_KEY_TYPE_SECURE_BOOT_DECRYPTION", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a4a929eca26e682e353a462162bee94c9", null ], + [ "RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a05ac77751a82f044778d9cb86c2f44f1", null ], + [ "RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa2a474f523f6c08e3cb59eff333ca946", null ], + [ "RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0abd142cdcce3eb32996644a947f6d8987", null ], + [ "RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a06508f9d0ca5be101fabc0954fbbffd2", null ], + [ "RSIP_KEY_TYPE_RSA_3072_PUBLIC", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a3fb4b7a6660681c87ef8416bc8ef116d", null ], + [ "RSIP_KEY_TYPE_RSA_3072_PRIVATE", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a19f0822cd6c1399de2bc15e8a46913fe", null ], + [ "RSIP_KEY_TYPE_RSA_4096_PUBLIC", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a52e55e5000f62bf6258d188c2c86983d", null ], + [ "RSIP_KEY_TYPE_RSA_4096_PRIVATE", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a58dc7de7d13a8f3b4fa46aac0f637181", null ], + [ "RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a0dab958d7e42944db5ae9d3cc6dbb171", null ], + [ "RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE", "group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa1283a39ddf31e2151a858b9adbe33ba", null ] + ] ], + [ "e_rsip_key_pair_type", "group___r_s_i_p___a_p_i.html#ga78fe2581fc642a646738f81b181c2c8f", [ + [ "RSIP_KEY_PAIR_TYPE_INVALID", "group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fac5500d97824a55149bc601d071204952", null ], + [ "RSIP_KEY_PAIR_TYPE_ECC_secp192r1", "group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa1db73377f01af77ecf1840a9c91d7cd6", null ], + [ "RSIP_KEY_PAIR_TYPE_ECC_secp224r1", "group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa696986229d46e351abc68e49a193583f", null ], + [ "RSIP_KEY_PAIR_TYPE_ECC_secp256r1", "group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa848eec7eab373097f2707df369276697", null ], + [ "RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1", "group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8faf618da4a0cf7b6870423dd88c144c04e", null ], + [ "RSIP_KEY_PAIR_TYPE_RSA_1024", "group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa72612c53f93986bcb9cb92831ce1afd6", null ], + [ "RSIP_KEY_PAIR_TYPE_RSA_2048", "group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8faa0cd2ab30ec0148ad600f992ce927aa3", null ], + [ "RSIP_KEY_PAIR_TYPE_RSA_3072", "group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa4dcc7fec49147dce7515509226eedf6a", null ], + [ "RSIP_KEY_PAIR_TYPE_RSA_4096", "group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa579b04ccf5fa9a785775229ea6860273", null ] + ] ], + [ "e_rsip_aes_mode", "group___r_s_i_p___a_p_i.html#gafd516c15c2cadaf0b76880f4a2b38526", [ + [ "RSIP_AES_MODE_ECB", "group___r_s_i_p___a_p_i.html#ggafd516c15c2cadaf0b76880f4a2b38526ae7b8be04a55e7bb46a3236ef36790d5c", null ], + [ "RSIP_AES_MODE_CBC", "group___r_s_i_p___a_p_i.html#ggafd516c15c2cadaf0b76880f4a2b38526a916e358b41f31dcda1aa88c107affdeb", null ], + [ "RSIP_AES_MODE_CTR", "group___r_s_i_p___a_p_i.html#ggafd516c15c2cadaf0b76880f4a2b38526a05435bd090fafeb359f819d552969260", null ], + [ "RSIP_AES_MODE_XTS", "group___r_s_i_p___a_p_i.html#ggafd516c15c2cadaf0b76880f4a2b38526a5d6bfcb55d82dcf78aed589f68a9687c", null ] + ] ], + [ "e_rsip_hash_type", "group___r_s_i_p___a_p_i.html#ga23ab60f96b3821a218f957ada1bc0d50", [ + [ "RSIP_HASH_TYPE_SHA1", "group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50a1e606044965bcf60e62d360773020b45", null ], + [ "RSIP_HASH_TYPE_SHA224", "group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50af64c98e1df3a92f08a6e68b20216b2d2", null ], + [ "RSIP_HASH_TYPE_SHA256", "group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50aa9b386d1b29869e511efd8d28f95cf06", null ], + [ "RSIP_HASH_TYPE_SHA384", "group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50a5d99501259f33a56446b2e924bce8dff", null ], + [ "RSIP_HASH_TYPE_SHA512", "group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50aa3336966c98485838aef21db86b4c9c4", null ], + [ "RSIP_HASH_TYPE_SHA512_224", "group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50a42459c435a6732056efc9b0026efb69e", null ], + [ "RSIP_HASH_TYPE_SHA512_256", "group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50a42c1bdd5072314a38acd3f128577c1b5", null ] + ] ], + [ "e_rsip_mgf_type", "group___r_s_i_p___a_p_i.html#gab5bfaadcf28c8276e7dda056d874baa9", [ + [ "RSIP_MGF_TYPE_MGF1_SHA1", "group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a467853f1da9a4d991cfa8a5dcd0bac8c", null ], + [ "RSIP_MGF_TYPE_MGF1_SHA224", "group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a3be5880de8b95f51bc3316dab173f26b", null ], + [ "RSIP_MGF_TYPE_MGF1_SHA256", "group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a706f017dd80223a4b21e3344a81b8188", null ], + [ "RSIP_MGF_TYPE_MGF1_SHA384", "group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9ab4928d0237db4c9107c99a07d2d45b55", null ], + [ "RSIP_MGF_TYPE_MGF1_SHA512", "group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a85c5a243de79d7dc9937946c18b53d18", null ], + [ "RSIP_MGF_TYPE_MGF1_SHA512_224", "group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a686e5d6dda2e85fbb1a5b6947242be0c", null ], + [ "RSIP_MGF_TYPE_MGF1_SHA512_256", "group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a97d5cd9aa8b6fa9ce232aea21b79de8f", null ] + ] ], + [ "e_password_type", "group___r_s_i_p___a_p_i.html#gaf9124e401923d473d86b93cd7cc2031d", [ + [ "RSIP_PASSWORD_TYPE_JTAG_DEBUG_AUTHENTICATION_LEVEL1", "group___r_s_i_p___a_p_i.html#ggaf9124e401923d473d86b93cd7cc2031da6541a5167825a8e412d4568b86b3354f", null ], + [ "RSIP_PASSWORD_TYPE_JTAG_DEBUG_AUTHENTICATION_LEVEL2", "group___r_s_i_p___a_p_i.html#ggaf9124e401923d473d86b93cd7cc2031daa29cf2c09763028ba473a10f4fbb8724", null ] + ] ], + [ "e_rsip_byte_size_encrypted_key", "group___r_s_i_p___a_p_i.html#ga09d58045e1e5fc1fc22a72bfda6a2c6b", [ + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6babca41e320abed86dc89a15fe82d0055e", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bae7edcd56e413058751e63a91c08db443", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128_XTS", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba6cc5328433cea8a424cc3dc153c18887", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256_XTS", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba29fe5766d277319857f25095abc87650", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PUBLIC", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba65099b600ac34c55b2f727e8a6727159", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PRIVATE", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baec91c7db4c76e36feb4641cb6217142d", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PUBLIC", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bae05b8f63cc316051503418a2144356f5", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PRIVATE", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bafada6405390b950a13be917836467ed2", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PUBLIC", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bab970177f7019e054287cec3f3c1cdd38", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PRIVATE", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba4c1a8f534b7fd8a75d1becdaf5f4db8d", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PUBLIC", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba93bef067d3dc0ecd5cd701a04df76935", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PRIVATE", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baea48bab25d9ce695fd179e7101cf76fd", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PUBLIC_ENHANCED", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba21caa8ebee33a364073e05854b25f14d", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PRIVATE_ENHANCED", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba00c4a0213dc8078874ee1e31f293d0ba", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PUBLIC_ENHANCED", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bac8535eb6260a31f3c69a4ebee2e74508", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PRIVATE_ENHANCED", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bad1b3ebd64335aab215d9fd3ca52ee692", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PUBLIC", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba0d56717253c1e0323374d67f3595a699", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PRIVATE", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba22eeba8227d1f675e1718088edc0b745", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PUBLIC", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baefdb0d9c6db8e9264064576cd2336430", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PRIVATE", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba03b43a47c22829c840bf465f43599f75", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA1", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba90f1df4ea497c51be41b37771cdc5cf7", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA224", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baf2236851c1d11684fd7334497d4293c2", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA256", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba4cbdce8dc08586f932817e00b6dc123d", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_KEY_UPDATE_KEY", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba1c37e9d8a67a2c87bcacfb2ba4b0cf16", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_MAX", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba095d1a2fc81e012f68355152dcdc05bc", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PUBLIC_MAX", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba785c029de5ee4c328f491772fde45128", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PRIVATE_MAX", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba139a8760ad2c9c6f9e26361f46d8dbda", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PUBLIC_MAX", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba1bf207c0299f4b36fdc92dd4ecf826b6", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PRIVATE_MAX", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baec66e52e0b5dc552f9835b3d1f9119bf", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_MAX", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba650d187c31f0d63691a8b0ea0838d278", null ], + [ "RSIP_BYTE_SIZE_ENCRYPTED_KEY_MAX", "group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bad8fc5807e4d283d58b28ed59307448cd", null ] + ] ], + [ "e_rsip_byte_size_wrapped_key_value", "group___r_s_i_p___a_p_i.html#ga986cec1971f79c094bd27ac6d11b25e2", [ + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a586634b4d139e6f57746a237f5f1a0be", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a1b018a8fa7fd42508b831c634663b3be", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128_XTS", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ac790e39e8b68c6a8f7cc833fb8ca98e4", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256_XTS", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2afdc13695f7f0bf48d17bde9150c2d5d5", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PUBLIC", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a7dddcca7061f44fa3db34915016dbb98", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PRIVATE", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ae9b143cdcb9bde593114b0bacbd84255", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PUBLIC", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a5a35d4d2d09198c47115f3ea34897ce2", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PRIVATE", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a446639af284989b0a0c8dd1e4cc4d167", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PUBLIC", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a7e0d45e2f8b5ad6f7c424860e89ff05b", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PRIVATE", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2af1d315efc0f02f8ffcf537242f6a5c1d", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PUBLIC", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a04727ef451762e283a8ca6f7ac6b7861", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PRIVATE", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a3e6d2558c274d02fc5f66b294411b903", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PUBLIC_ENHANCED", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2acc82841e4a464ce393f46358a34fd896", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PRIVATE_ENHANCED", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a2c203c4e464d9f32009a494c9d60fbf8", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PUBLIC_ENHANCED", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a8be4585da748345938a9b50afd4882bc", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PRIVATE_ENHANCED", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a6eb5d8cea1d9c29cf615b4d8ff4de9fe", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PUBLIC", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a23ce153c49268a13a953340c1a1cdaee", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PRIVATE", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a78ae62e9bdcbad0863feef54bca6d610", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PUBLIC", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a272193dbc8150aa367b016b7f19b448b", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PRIVATE", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2aedb0ff7185a258792305c85e7c6b1408", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA1", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2adbc909a34e27086968337b14b73d41d1", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA224", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a2d1fe8897eea6fe2e8da371145b59aed", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA256", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a622942fa17ea395c2ffc2d10a9953d59", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_KEY_UPDATE_KEY", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ad938901804f0d8d6cf7242197d103203", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_MAX", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a8056769b72932b90227774389cf2667d", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PUBLIC_MAX", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2abf32844af8087563228207b0e92206f8", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PRIVATE_MAX", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a7e058acecc7cfd50519c938fea9a4b2f", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PUBLIC_MAX", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a3f0dffcc6d2d8e865ee04a0d4a0f0eb0", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PRIVATE_MAX", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2af60d086613f2afccd018ffccc9384ddb", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_MAX", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ae91a70d223ec963db0512cd5721b50f4", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_MAX", "group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ad0f5744f10c898d7cd0475cc31ef67fe", null ] + ] ], + [ "e_rsip_byte_size_wrapped_key", "group___r_s_i_p___a_p_i.html#gaf34956ea3649626a41606ee05aef9069", [ + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a5c087988d5082ae00e9703d1980a1f7f", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069acc7cfcba1a5e5944e566276062d4ff54", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128_XTS", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a9f5b9468fbbbe7084a8cd90a9fb3f40a", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256_XTS", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a1de8f70b943e282223c4b93742ffab37", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PUBLIC", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069afee6765f321bf704ed1c105497416e58", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PRIVATE", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ab609f58697d8b22222d558c97b9da0be", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PUBLIC", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069af4ad017c6816e60391e7cd48ec516f54", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PRIVATE", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ae6466928a02a9ea5bfb3a67dbab5f4e0", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a71818cabae02e61719e9c5d34a28a3bd", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a616dcde10261898e926bc7a550bdee87", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PUBLIC", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a18ef67c162ed62273cc9326622ad2164", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PRIVATE", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ac9ba8fb69cc3317264e05cde0249f06f", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a28873d6222775f36065be210540e7f50", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a526a9fd8d458122f6edb59b06013fc41", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a9001350f603fd8057ca0d8ad00f9961a", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a2f9ca50dd2f7e7ff78cb703666727c49", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069acd089ec2a35f7c4086853b3e515272b7", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069aaf8df7e54cd8052e03114852da2ffa31", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a386fcc985ae05b83322cb3944c1fb744", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a5e882c6dc51ad72779ad19e9eb684330", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA1", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069aa0061976fb107bc4a118ff6d79ca8c29", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA224", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a1fae3fdbe5e142cee2b83fd2ee78c3fc", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA256", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ad302f44eb6bb360373f2c52ce0172993", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_KEY_UPDATE_KEY", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a0787873287816db723cf3da18b95e009", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_AES_MAX", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a9f4ea297e8da363157e7f66aa4ecc898", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PUBLIC_MAX", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ae3887b040ebbf43f629ec20b504a3779", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PRIVATE_MAX", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a6ea981937f2151a755290e938ba7c47e", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PUBLIC_MAX", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a46c61543461d737b9be7f26db6b35c11", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PRIVATE_MAX", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069abda559faa8a845f5f8e06d510c082629", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_MAX", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a0d65c6ddc749536e69332f4b5229cb40", null ], + [ "RSIP_BYTE_SIZE_WRAPPED_KEY_MAX", "group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069aeb938665677db84ae6d1da16282b8b1d", null ] + ] ] +]; \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/index.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/index.html new file mode 100644 index 000000000..f70387f6d --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/index.html @@ -0,0 +1,113 @@ + + + + + + + +R_RSIP Documentation: Renesas Secure IP + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
Renesas Secure IP
+
+
+

The user documentation for this module is here: Renesas Secure IP (r_rsip)

+
+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/jquery.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/jquery.js new file mode 100644 index 000000000..103c32d79 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/jquery.js @@ -0,0 +1,35 @@ +/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.4.1",k=function(e,t){return new k.fn.init(e,t)},p=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function d(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp($),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+$),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ne=function(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(m.childNodes),m.childNodes),t[m.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&((e?e.ownerDocument||e:m)!==C&&T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!A[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&U.test(t)){(s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=k),o=(l=h(t)).length;while(o--)l[o]="#"+s+" "+xe(l[o]);c=l.join(","),f=ee.test(t)&&ye(e.parentNode)||e}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){A(t,!0)}finally{s===k&&e.removeAttribute("id")}}}return g(t.replace(B,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[k]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:m;return r!==C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),m!==C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=k,!C.getElementsByName||!C.getElementsByName(k).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+k+"-]").length||v.push("~="),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+k+"+*").length||v.push(".#.+[+~]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",$)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e===C||e.ownerDocument===m&&y(m,e)?-1:t===C||t.ownerDocument===m&&y(m,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===C?-1:t===C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]===m?-1:s[r]===m?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==C&&T(e),d.matchesSelector&&E&&!A[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){A(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=p[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&p(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?k.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?k.grep(e,function(e){return e===n!==r}):"string"!=typeof n?k.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(k.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:L.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof k?t[0]:t,k.merge(this,k.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),D.test(r[1])&&k.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(k):k.makeArray(e,this)}).prototype=k.fn,q=k(E);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}k.fn.extend({has:function(e){var t=k(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?k.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;nx",y.noCloneChecked=!!me.cloneNode(!0).lastChild.defaultValue;var Te=/^key/,Ce=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ee=/^([^.]*)(?:\.(.+)|)/;function ke(){return!0}function Se(){return!1}function Ne(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function Ae(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)Ae(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Se;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return k().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=k.guid++)),e.each(function(){k.event.add(this,t,i,r,n)})}function De(e,i,o){o?(Q.set(e,i,!1),k.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Q.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(k.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Q.set(this,i,r),t=o(this,i),this[i](),r!==(n=Q.get(this,i))||t?Q.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n.value}else r.length&&(Q.set(this,i,{value:k.event.trigger(k.extend(r[0],k.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===Q.get(e,i)&&k.event.add(e,i,ke)}k.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.get(t);if(v){n.handler&&(n=(o=n).handler,i=o.selector),i&&k.find.matchesSelector(ie,i),n.guid||(n.guid=k.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof k&&k.event.triggered!==e.type?k.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(R)||[""]).length;while(l--)d=g=(s=Ee.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=k.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=k.event.special[d]||{},c=k.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&k.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),k.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.hasData(e)&&Q.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(R)||[""]).length;while(l--)if(d=g=(s=Ee.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=k.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||k.removeEvent(e,d,v.handle),delete u[d])}else for(d in u)k.event.remove(e,d+t[l],n,r,!0);k.isEmptyObject(u)&&Q.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=k.event.fix(e),u=new Array(arguments.length),l=(Q.get(this,"events")||{})[s.type]||[],c=k.event.special[s.type]||{};for(u[0]=s,t=1;t\x20\t\r\n\f]*)[^>]*)\/>/gi,qe=/\s*$/g;function Oe(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&k(e).children("tbody")[0]||e}function Pe(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Re(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Me(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(Q.hasData(e)&&(o=Q.access(e),a=Q.set(t,o),l=o.events))for(i in delete a.handle,a.events={},l)for(n=0,r=l[i].length;n")},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=oe(e);if(!(y.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||k.isXMLDoc(e)))for(a=ve(c),r=0,i=(o=ve(e)).length;r").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Vt,Gt=[],Yt=/(=)\?(?=&|$)|\?\?/;k.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Gt.pop()||k.expando+"_"+kt++;return this[e]=!0,e}}),k.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Yt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Yt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Yt,"$1"+r):!1!==e.jsonp&&(e.url+=(St.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||k.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?k(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Gt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((Vt=E.implementation.createHTMLDocument("").body).innerHTML="
",2===Vt.childNodes.length),k.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=D.exec(e))?[t.createElement(i[1])]:(i=we([e],t,o),o&&o.length&&k(o).remove(),k.merge([],i.childNodes)));var r,i,o},k.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(k.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},k.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){k.fn[t]=function(e){return this.on(t,e)}}),k.expr.pseudos.animated=function(t){return k.grep(k.timers,function(e){return t===e.elem}).length},k.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=k.css(e,"position"),c=k(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=k.css(e,"top"),u=k.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,k.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},k.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){k.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===k.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===k.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=k(e).offset()).top+=k.css(e,"borderTopWidth",!0),i.left+=k.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-k.css(r,"marginTop",!0),left:t.left-i.left-k.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===k.css(e,"position"))e=e.offsetParent;return e||ie})}}),k.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;k.fn[t]=function(e){return _(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),k.each(["top","left"],function(e,n){k.cssHooks[n]=ze(y.pixelPosition,function(e,t){if(t)return t=_e(e,n),$e.test(t)?k(e).position()[n]+"px":t})}),k.each({Height:"height",Width:"width"},function(a,s){k.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){k.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return _(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?k.css(e,t,i):k.style(e,t,n,i)},s,n?e:void 0,n)}})}),k.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){k.fn[n]=function(e,t){return 0a;a++)for(i in o[a])n=o[a][i],o[a].hasOwnProperty(i)&&void 0!==n&&(e[i]=t.isPlainObject(n)?t.isPlainObject(e[i])?t.widget.extend({},e[i],n):t.widget.extend({},n):n);return e},t.widget.bridge=function(e,i){var n=i.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,r=s.call(arguments,1),h=this;return a?this.length||"instance"!==o?this.each(function(){var i,s=t.data(this,n);return"instance"===o?(h=s,!1):s?t.isFunction(s[o])&&"_"!==o.charAt(0)?(i=s[o].apply(s,r),i!==s&&void 0!==i?(h=i&&i.jquery?h.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+o+"'")}):h=void 0:(r.length&&(o=t.widget.extend.apply(null,[o].concat(r))),this.each(function(){var e=t.data(this,n);e?(e.option(o||{}),e._init&&e._init()):t.data(this,n,new i(o,this))})),h}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{classes:{},disabled:!1,create:null},_createWidget:function(e,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),this.classesElementLookup={},s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){var e=this;this._destroy(),t.each(this.classesElementLookup,function(t,i){e._removeClass(i,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(e){var i,s,n;for(i in e)n=this.classesElementLookup[i],e[i]!==this.options.classes[i]&&n&&n.length&&(s=t(n.get()),this._removeClass(n,i),s.addClass(this._classes({element:s,keys:i,classes:e,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(e){function i(i,o){var a,r;for(r=0;i.length>r;r++)a=n.classesElementLookup[i[r]]||t(),a=e.add?t(t.unique(a.get().concat(e.element.get()))):t(a.not(e.element).get()),n.classesElementLookup[i[r]]=a,s.push(i[r]),o&&e.classes[i[r]]&&s.push(e.classes[i[r]])}var s=[],n=this;return e=t.extend({element:this.element,classes:this.options.classes||{}},e),this._on(e.element,{remove:"_untrackClassesElement"}),e.keys&&i(e.keys.match(/\S+/g)||[],!0),e.extra&&i(e.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(e){var i=this;t.each(i.classesElementLookup,function(s,n){-1!==t.inArray(e.target,n)&&(i.classesElementLookup[s]=t(n.not(e.target).get()))})},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){s="boolean"==typeof s?s:i;var n="string"==typeof t||null===t,o={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s};return o.element.toggleClass(this._classes(o),s),this},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+o.eventNamespace,c=h[2];c?n.on(l,c,r):i.on(l,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.off(i).off(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){this._addClass(t(e.currentTarget),null,"ui-state-hover")},mouseleave:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){this._addClass(t(e.currentTarget),null,"ui-state-focus")},focusout:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget,function(){function e(t,e,i){return[parseFloat(t[0])*(u.test(t[0])?e/100:1),parseFloat(t[1])*(u.test(t[1])?i/100:1)]}function i(e,i){return parseInt(t.css(e,i),10)||0}function s(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}var n,o=Math.max,a=Math.abs,r=/left|center|right/,h=/top|center|bottom/,l=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,u=/%$/,d=t.fn.position;t.position={scrollbarWidth:function(){if(void 0!==n)return n;var e,i,s=t("
"),o=s.children()[0];return t("body").append(s),e=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,e===i&&(i=s[0].clientWidth),s.remove(),n=e-i},getScrollInfo:function(e){var i=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),s=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.widthi?"left":e>0?"right":"center",vertical:0>r?"top":s>0?"bottom":"middle"};l>p&&p>a(e+i)&&(u.horizontal="center"),c>f&&f>a(s+r)&&(u.vertical="middle"),u.important=o(a(e),a(i))>o(a(s),a(r))?"horizontal":"vertical",n.using.call(this,t,u)}),h.offset(t.extend(D,{using:r}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=t.left-e.collisionPosition.marginLeft,h=n-r,l=r+e.collisionWidth-a-n;e.collisionWidth>a?h>0&&0>=l?(i=t.left+h+e.collisionWidth-a-n,t.left+=h-i):t.left=l>0&&0>=h?n:h>l?n+a-e.collisionWidth:n:h>0?t.left+=h:l>0?t.left-=l:t.left=o(t.left-r,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,h=n-r,l=r+e.collisionHeight-a-n;e.collisionHeight>a?h>0&&0>=l?(i=t.top+h+e.collisionHeight-a-n,t.top+=h-i):t.top=l>0&&0>=h?n:h>l?n+a-e.collisionHeight:n:h>0?t.top+=h:l>0?t.top-=l:t.top=o(t.top-r,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,o=n.offset.left+n.scrollLeft,r=n.width,h=n.isWindow?n.scrollLeft:n.offset.left,l=t.left-e.collisionPosition.marginLeft,c=l-h,u=l+e.collisionWidth-r-h,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];0>c?(i=t.left+d+p+f+e.collisionWidth-r-o,(0>i||a(c)>i)&&(t.left+=d+p+f)):u>0&&(s=t.left-e.collisionPosition.marginLeft+d+p+f-h,(s>0||u>a(s))&&(t.left+=d+p+f))},top:function(t,e){var i,s,n=e.within,o=n.offset.top+n.scrollTop,r=n.height,h=n.isWindow?n.scrollTop:n.offset.top,l=t.top-e.collisionPosition.marginTop,c=l-h,u=l+e.collisionHeight-r-h,d="top"===e.my[1],p=d?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,f="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,m=-2*e.offset[1];0>c?(s=t.top+p+f+m+e.collisionHeight-r-o,(0>s||a(c)>s)&&(t.top+=p+f+m)):u>0&&(i=t.top-e.collisionPosition.marginTop+p+f+m-h,(i>0||u>a(i))&&(t.top+=p+f+m))}},flipfit:{left:function(){t.ui.position.flip.left.apply(this,arguments),t.ui.position.fit.left.apply(this,arguments)},top:function(){t.ui.position.flip.top.apply(this,arguments),t.ui.position.fit.top.apply(this,arguments)}}}}(),t.ui.position,t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,s){return!!t.data(e,s[3])}}),t.fn.extend({disableSelection:function(){var t="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.on(t+".ui-disableSelection",function(t){t.preventDefault()})}}(),enableSelection:function(){return this.off(".ui-disableSelection")}}),t.ui.focusable=function(i,s){var n,o,a,r,h,l=i.nodeName.toLowerCase();return"area"===l?(n=i.parentNode,o=n.name,i.href&&o&&"map"===n.nodeName.toLowerCase()?(a=t("img[usemap='#"+o+"']"),a.length>0&&a.is(":visible")):!1):(/^(input|select|textarea|button|object)$/.test(l)?(r=!i.disabled,r&&(h=t(i).closest("fieldset")[0],h&&(r=!h.disabled))):r="a"===l?i.href||s:s,r&&t(i).is(":visible")&&e(t(i)))},t.extend(t.expr[":"],{focusable:function(e){return t.ui.focusable(e,null!=t.attr(e,"tabindex"))}}),t.ui.focusable,t.fn.form=function(){return"string"==typeof this[0].form?this.closest("form"):t(this[0].form)},t.ui.formResetMixin={_formResetHandler:function(){var e=t(this);setTimeout(function(){var i=e.data("ui-form-reset-instances");t.each(i,function(){this.refresh()})})},_bindFormResetHandler:function(){if(this.form=this.element.form(),this.form.length){var t=this.form.data("ui-form-reset-instances")||[];t.length||this.form.on("reset.ui-form-reset",this._formResetHandler),t.push(this),this.form.data("ui-form-reset-instances",t)}},_unbindFormResetHandler:function(){if(this.form.length){var e=this.form.data("ui-form-reset-instances");e.splice(t.inArray(this,e),1),e.length?this.form.data("ui-form-reset-instances",e):this.form.removeData("ui-form-reset-instances").off("reset.ui-form-reset")}}},"1.7"===t.fn.jquery.substring(0,3)&&(t.each(["Width","Height"],function(e,i){function s(e,i,s,o){return t.each(n,function(){i-=parseFloat(t.css(e,"padding"+this))||0,s&&(i-=parseFloat(t.css(e,"border"+this+"Width"))||0),o&&(i-=parseFloat(t.css(e,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],o=i.toLowerCase(),a={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+i]=function(e){return void 0===e?a["inner"+i].call(this):this.each(function(){t(this).css(o,s(this,e)+"px")})},t.fn["outer"+i]=function(e,n){return"number"!=typeof e?a["outer"+i].call(this,e):this.each(function(){t(this).css(o,s(this,e,!0,n)+"px")})}}),t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},t.ui.escapeSelector=function(){var t=/([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;return function(e){return e.replace(t,"\\$1")}}(),t.fn.labels=function(){var e,i,s,n,o;return this[0].labels&&this[0].labels.length?this.pushStack(this[0].labels):(n=this.eq(0).parents("label"),s=this.attr("id"),s&&(e=this.eq(0).parents().last(),o=e.add(e.length?e.siblings():this.siblings()),i="label[for='"+t.ui.escapeSelector(s)+"']",n=n.add(o.find(i).addBack(i))),this.pushStack(n))},t.fn.scrollParent=function(e){var i=this.css("position"),s="absolute"===i,n=e?/(auto|scroll|hidden)/:/(auto|scroll)/,o=this.parents().filter(function(){var e=t(this);return s&&"static"===e.css("position")?!1:n.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==i&&o.length?o:t(this[0].ownerDocument||document)},t.extend(t.expr[":"],{tabbable:function(e){var i=t.attr(e,"tabindex"),s=null!=i;return(!s||i>=0)&&t.ui.focusable(e,s)}}),t.fn.extend({uniqueId:function(){var t=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++t)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&t(this).removeAttr("id")})}}),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());var n=!1;t(document).on("mouseup",function(){n=!1}),t.widget("ui.mouse",{version:"1.12.1",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.on("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).on("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){if(!n){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var i=this,s=1===e.which,o="string"==typeof this.options.cancel&&e.target.nodeName?t(e.target).closest(this.options.cancel).length:!1;return s&&!o&&this._mouseCapture(e)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(e)!==!1,!this._mouseStarted)?(e.preventDefault(),!0):(!0===t.data(e.target,this.widgetName+".preventClickEvent")&&t.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return i._mouseMove(t)},this._mouseUpDelegate=function(t){return i._mouseUp(t)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),n=!0,!0)):!0}},_mouseMove:function(e){if(this._mouseMoved){if(t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button)return this._mouseUp(e);if(!e.which)if(e.originalEvent.altKey||e.originalEvent.ctrlKey||e.originalEvent.metaKey||e.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,n=!1,e.preventDefault()},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),t.ui.plugin={add:function(e,i,s){var n,o=t.ui[e].prototype;for(n in s)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([i,s[n]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;o.length>n;n++)t.options[o[n][0]]&&o[n][1].apply(t.element,i)}},t.widget("ui.resizable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,classes:{"ui-resizable-se":"ui-icon ui-icon-gripsmall-diagonal-se"},containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(t){return parseFloat(t)||0},_isNumber:function(t){return!isNaN(parseFloat(t))},_hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return e[s]>0?!0:(e[s]=1,n=e[s]>0,e[s]=0,n)},_create:function(){var e,i=this.options,s=this;this._addClass("ui-resizable"),t.extend(this,{_aspectRatio:!!i.aspectRatio,aspectRatio:i.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:i.helper||i.ghost||i.animate?i.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)&&(this.element.wrap(t("
").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,e={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(e),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(e),this._proportionallyResize()),this._setupHandles(),i.autoHide&&t(this.element).on("mouseenter",function(){i.disabled||(s._removeClass("ui-resizable-autohide"),s._handles.show())}).on("mouseleave",function(){i.disabled||s.resizing||(s._addClass("ui-resizable-autohide"),s._handles.hide())}),this._mouseInit()},_destroy:function(){this._mouseDestroy();var e,i=function(e){t(e).removeData("resizable").removeData("ui-resizable").off(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_setOption:function(t,e){switch(this._super(t,e),t){case"handles":this._removeHandles(),this._setupHandles();break;default:}},_setupHandles:function(){var e,i,s,n,o,a=this.options,r=this;if(this.handles=a.handles||(t(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=t(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),s=this.handles.split(","),this.handles={},i=0;s.length>i;i++)e=t.trim(s[i]),n="ui-resizable-"+e,o=t("
"),this._addClass(o,"ui-resizable-handle "+n),o.css({zIndex:a.zIndex}),this.handles[e]=".ui-resizable-"+e,this.element.append(o);this._renderAxis=function(e){var i,s,n,o;e=e||this.element;for(i in this.handles)this.handles[i].constructor===String?this.handles[i]=this.element.children(this.handles[i]).first().show():(this.handles[i].jquery||this.handles[i].nodeType)&&(this.handles[i]=t(this.handles[i]),this._on(this.handles[i],{mousedown:r._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(s=t(this.handles[i],this.element),o=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),e.css(n,o),this._proportionallyResize()),this._handles=this._handles.add(this.handles[i])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",function(){r.resizing||(this.className&&(o=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),r.axis=o&&o[1]?o[1]:"se")}),a.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._handles.remove()},_mouseCapture:function(e){var i,s,n=!1;for(i in this.handles)s=t(this.handles[i])[0],(s===e.target||t.contains(s,e.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(e){var i,s,n,o=this.options,a=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),o.containment&&(i+=t(o.containment).scrollLeft()||0,s+=t(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:a.width(),height:a.height()},this.originalSize=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.sizeDiff={width:a.outerWidth()-a.width(),height:a.outerHeight()-a.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:e.pageX,top:e.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=t(".ui-resizable-"+this.axis).css("cursor"),t("body").css("cursor","auto"===n?this.axis+"-resize":n),this._addClass("ui-resizable-resizing"),this._propagate("start",e),!0},_mouseDrag:function(e){var i,s,n=this.originalMousePosition,o=this.axis,a=e.pageX-n.left||0,r=e.pageY-n.top||0,h=this._change[o];return this._updatePrevProperties(),h?(i=h.apply(this,[e,a,r]),this._updateVirtualBoundaries(e.shiftKey),(this._aspectRatio||e.shiftKey)&&(i=this._updateRatio(i,e)),i=this._respectSize(i,e),this._updateCache(i),this._propagate("resize",e),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),t.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",e,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(e){this.resizing=!1;var i,s,n,o,a,r,h,l=this.options,c=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:c.sizeDiff.height,o=s?0:c.sizeDiff.width,a={width:c.helper.width()-o,height:c.helper.height()-n},r=parseFloat(c.element.css("left"))+(c.position.left-c.originalPosition.left)||null,h=parseFloat(c.element.css("top"))+(c.position.top-c.originalPosition.top)||null,l.animate||this.element.css(t.extend(a,{top:h,left:r})),c.helper.height(c.size.height),c.helper.width(c.size.width),this._helper&&!l.animate&&this._proportionallyResize()),t("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",e),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s,n,o,a=this.options;o={minWidth:this._isNumber(a.minWidth)?a.minWidth:0,maxWidth:this._isNumber(a.maxWidth)?a.maxWidth:1/0,minHeight:this._isNumber(a.minHeight)?a.minHeight:0,maxHeight:this._isNumber(a.maxHeight)?a.maxHeight:1/0},(this._aspectRatio||t)&&(e=o.minHeight*this.aspectRatio,s=o.minWidth/this.aspectRatio,i=o.maxHeight*this.aspectRatio,n=o.maxWidth/this.aspectRatio,e>o.minWidth&&(o.minWidth=e),s>o.minHeight&&(o.minHeight=s),o.maxWidth>i&&(o.maxWidth=i),o.maxHeight>n&&(o.maxHeight=n)),this._vBoundaries=o},_updateCache:function(t){this.offset=this.helper.offset(),this._isNumber(t.left)&&(this.position.left=t.left),this._isNumber(t.top)&&(this.position.top=t.top),this._isNumber(t.height)&&(this.size.height=t.height),this._isNumber(t.width)&&(this.size.width=t.width)},_updateRatio:function(t){var e=this.position,i=this.size,s=this.axis;return this._isNumber(t.height)?t.width=t.height*this.aspectRatio:this._isNumber(t.width)&&(t.height=t.width/this.aspectRatio),"sw"===s&&(t.left=e.left+(i.width-t.width),t.top=null),"nw"===s&&(t.top=e.top+(i.height-t.height),t.left=e.left+(i.width-t.width)),t},_respectSize:function(t){var e=this._vBoundaries,i=this.axis,s=this._isNumber(t.width)&&e.maxWidth&&e.maxWidtht.width,a=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,r=this.originalPosition.left+this.originalSize.width,h=this.originalPosition.top+this.originalSize.height,l=/sw|nw|w/.test(i),c=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),a&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&l&&(t.left=r-e.minWidth),s&&l&&(t.left=r-e.maxWidth),a&&c&&(t.top=h-e.minHeight),n&&c&&(t.top=h-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];4>e;e++)i[e]=parseFloat(s[e])||0,i[e]+=parseFloat(n[e])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;this._proportionallyResizeElements.length>e;e++)t=this._proportionallyResizeElements[e],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(t)),t.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var e=this.element,i=this.options;this.elementOffset=e.offset(),this._helper?(this.helper=this.helper||t("
"),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element +},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize,s=this.originalPosition;return{left:s.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},sw:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,i,s]))},ne:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},nw:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,i,s]))}},_propagate:function(e,i){t.ui.plugin.call(this,e,[i,this.ui()]),"resize"!==e&&this._trigger(e,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),t.ui.plugin.add("resizable","animate",{stop:function(e){var i=t(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,o=n.length&&/textarea/i.test(n[0].nodeName),a=o&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=o?0:i.sizeDiff.width,h={width:i.size.width-r,height:i.size.height-a},l=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,c=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(t.extend(h,c&&l?{top:c,left:l}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};n&&n.length&&t(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",e)}})}}),t.ui.plugin.add("resizable","containment",{start:function(){var e,i,s,n,o,a,r,h=t(this).resizable("instance"),l=h.options,c=h.element,u=l.containment,d=u instanceof t?u.get(0):/parent/.test(u)?c.parent().get(0):u;d&&(h.containerElement=t(d),/document/.test(u)||u===document?(h.containerOffset={left:0,top:0},h.containerPosition={left:0,top:0},h.parentData={element:t(document),left:0,top:0,width:t(document).width(),height:t(document).height()||document.body.parentNode.scrollHeight}):(e=t(d),i=[],t(["Top","Right","Left","Bottom"]).each(function(t,s){i[t]=h._num(e.css("padding"+s))}),h.containerOffset=e.offset(),h.containerPosition=e.position(),h.containerSize={height:e.innerHeight()-i[3],width:e.innerWidth()-i[1]},s=h.containerOffset,n=h.containerSize.height,o=h.containerSize.width,a=h._hasScroll(d,"left")?d.scrollWidth:o,r=h._hasScroll(d)?d.scrollHeight:n,h.parentData={element:d,left:s.left,top:s.top,width:a,height:r}))},resize:function(e){var i,s,n,o,a=t(this).resizable("instance"),r=a.options,h=a.containerOffset,l=a.position,c=a._aspectRatio||e.shiftKey,u={top:0,left:0},d=a.containerElement,p=!0;d[0]!==document&&/static/.test(d.css("position"))&&(u=h),l.left<(a._helper?h.left:0)&&(a.size.width=a.size.width+(a._helper?a.position.left-h.left:a.position.left-u.left),c&&(a.size.height=a.size.width/a.aspectRatio,p=!1),a.position.left=r.helper?h.left:0),l.top<(a._helper?h.top:0)&&(a.size.height=a.size.height+(a._helper?a.position.top-h.top:a.position.top),c&&(a.size.width=a.size.height*a.aspectRatio,p=!1),a.position.top=a._helper?h.top:0),n=a.containerElement.get(0)===a.element.parent().get(0),o=/relative|absolute/.test(a.containerElement.css("position")),n&&o?(a.offset.left=a.parentData.left+a.position.left,a.offset.top=a.parentData.top+a.position.top):(a.offset.left=a.element.offset().left,a.offset.top=a.element.offset().top),i=Math.abs(a.sizeDiff.width+(a._helper?a.offset.left-u.left:a.offset.left-h.left)),s=Math.abs(a.sizeDiff.height+(a._helper?a.offset.top-u.top:a.offset.top-h.top)),i+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-i,c&&(a.size.height=a.size.width/a.aspectRatio,p=!1)),s+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-s,c&&(a.size.width=a.size.height*a.aspectRatio,p=!1)),p||(a.position.left=a.prevPosition.left,a.position.top=a.prevPosition.top,a.size.width=a.prevSize.width,a.size.height=a.prevSize.height)},stop:function(){var e=t(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.containerPosition,o=e.containerElement,a=t(e.helper),r=a.offset(),h=a.outerWidth()-e.sizeDiff.width,l=a.outerHeight()-e.sizeDiff.height;e._helper&&!i.animate&&/relative/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:h,height:l}),e._helper&&!i.animate&&/static/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:h,height:l})}}),t.ui.plugin.add("resizable","alsoResize",{start:function(){var e=t(this).resizable("instance"),i=e.options;t(i.alsoResize).each(function(){var e=t(this);e.data("ui-resizable-alsoresize",{width:parseFloat(e.width()),height:parseFloat(e.height()),left:parseFloat(e.css("left")),top:parseFloat(e.css("top"))})})},resize:function(e,i){var s=t(this).resizable("instance"),n=s.options,o=s.originalSize,a=s.originalPosition,r={height:s.size.height-o.height||0,width:s.size.width-o.width||0,top:s.position.top-a.top||0,left:s.position.left-a.left||0};t(n.alsoResize).each(function(){var e=t(this),s=t(this).data("ui-resizable-alsoresize"),n={},o=e.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];t.each(o,function(t,e){var i=(s[e]||0)+(r[e]||0);i&&i>=0&&(n[e]=i||null)}),e.css(n)})},stop:function(){t(this).removeData("ui-resizable-alsoresize")}}),t.ui.plugin.add("resizable","ghost",{start:function(){var e=t(this).resizable("instance"),i=e.size;e.ghost=e.originalElement.clone(),e.ghost.css({opacity:.25,display:"block",position:"relative",height:i.height,width:i.width,margin:0,left:0,top:0}),e._addClass(e.ghost,"ui-resizable-ghost"),t.uiBackCompat!==!1&&"string"==typeof e.options.ghost&&e.ghost.addClass(this.options.ghost),e.ghost.appendTo(e.helper)},resize:function(){var e=t(this).resizable("instance");e.ghost&&e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})},stop:function(){var e=t(this).resizable("instance");e.ghost&&e.helper&&e.helper.get(0).removeChild(e.ghost.get(0))}}),t.ui.plugin.add("resizable","grid",{resize:function(){var e,i=t(this).resizable("instance"),s=i.options,n=i.size,o=i.originalSize,a=i.originalPosition,r=i.axis,h="number"==typeof s.grid?[s.grid,s.grid]:s.grid,l=h[0]||1,c=h[1]||1,u=Math.round((n.width-o.width)/l)*l,d=Math.round((n.height-o.height)/c)*c,p=o.width+u,f=o.height+d,m=s.maxWidth&&p>s.maxWidth,g=s.maxHeight&&f>s.maxHeight,_=s.minWidth&&s.minWidth>p,v=s.minHeight&&s.minHeight>f;s.grid=h,_&&(p+=l),v&&(f+=c),m&&(p-=l),g&&(f-=c),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=a.top-d):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=a.left-u):((0>=f-c||0>=p-l)&&(e=i._getPaddingPlusBorderDimensions(this)),f-c>0?(i.size.height=f,i.position.top=a.top-d):(f=c-e.height,i.size.height=f,i.position.top=a.top+o.height-f),p-l>0?(i.size.width=p,i.position.left=a.left-u):(p=l-e.width,i.size.width=p,i.position.left=a.left+o.width-p))}}),t.ui.resizable});/** + * Copyright (c) 2007 Ariel Flesler - aflesler ○ gmail • com | https://github.com/flesler + * Licensed under MIT + * @author Ariel Flesler + * @version 2.1.2 + */ +;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1=f[g]?0:Math.min(f[g],n));!a&&1-1){targetElements.on(evt+EVENT_NAMESPACE,function elementToggle(event){$.powerTip.toggle(this,event)})}else{targetElements.on(evt+EVENT_NAMESPACE,function elementOpen(event){$.powerTip.show(this,event)})}});$.each(options.closeEvents,function(idx,evt){if($.inArray(evt,options.openEvents)<0){targetElements.on(evt+EVENT_NAMESPACE,function elementClose(event){$.powerTip.hide(this,!isMouseEvent(event))})}});targetElements.on("keydown"+EVENT_NAMESPACE,function elementKeyDown(event){if(event.keyCode===27){$.powerTip.hide(this,true)}})}return targetElements};$.fn.powerTip.defaults={fadeInTime:200,fadeOutTime:100,followMouse:false,popupId:"powerTip",popupClass:null,intentSensitivity:7,intentPollInterval:100,closeDelay:100,placement:"n",smartPlacement:false,offset:10,mouseOnToPopup:false,manual:false,openEvents:["mouseenter","focus"],closeEvents:["mouseleave","blur"]};$.fn.powerTip.smartPlacementLists={n:["n","ne","nw","s"],e:["e","ne","se","w","nw","sw","n","s","e"],s:["s","se","sw","n"],w:["w","nw","sw","e","ne","se","n","s","w"],nw:["nw","w","sw","n","s","se","nw"],ne:["ne","e","se","n","s","sw","ne"],sw:["sw","w","nw","s","n","ne","sw"],se:["se","e","ne","s","n","nw","se"],"nw-alt":["nw-alt","n","ne-alt","sw-alt","s","se-alt","w","e"],"ne-alt":["ne-alt","n","nw-alt","se-alt","s","sw-alt","e","w"],"sw-alt":["sw-alt","s","se-alt","nw-alt","n","ne-alt","w","e"],"se-alt":["se-alt","s","sw-alt","ne-alt","n","nw-alt","e","w"]};$.powerTip={show:function apiShowTip(element,event){if(isMouseEvent(event)){trackMouse(event);session.previousX=event.pageX;session.previousY=event.pageY;$(element).data(DATA_DISPLAYCONTROLLER).show()}else{$(element).first().data(DATA_DISPLAYCONTROLLER).show(true,true)}return element},reposition:function apiResetPosition(element){$(element).first().data(DATA_DISPLAYCONTROLLER).resetPosition();return element},hide:function apiCloseTip(element,immediate){var displayController;immediate=element?immediate:true;if(element){displayController=$(element).first().data(DATA_DISPLAYCONTROLLER)}else if(session.activeHover){displayController=session.activeHover.data(DATA_DISPLAYCONTROLLER)}if(displayController){displayController.hide(immediate)}return element},toggle:function apiToggle(element,event){if(session.activeHover&&session.activeHover.is(element)){$.powerTip.hide(element,!isMouseEvent(event))}else{$.powerTip.show(element,event)}return element}};$.powerTip.showTip=$.powerTip.show;$.powerTip.closeTip=$.powerTip.hide;function CSSCoordinates(){var me=this;me.top="auto";me.left="auto";me.right="auto";me.bottom="auto";me.set=function(property,value){if($.isNumeric(value)){me[property]=Math.round(value)}}}function DisplayController(element,options,tipController){var hoverTimer=null,myCloseDelay=null;function openTooltip(immediate,forceOpen){cancelTimer();if(!element.data(DATA_HASACTIVEHOVER)){if(!immediate){session.tipOpenImminent=true;hoverTimer=setTimeout(function intentDelay(){hoverTimer=null;checkForIntent()},options.intentPollInterval)}else{if(forceOpen){element.data(DATA_FORCEDOPEN,true)}closeAnyDelayed();tipController.showTip(element)}}else{cancelClose()}}function closeTooltip(disableDelay){if(myCloseDelay){myCloseDelay=session.closeDelayTimeout=clearTimeout(myCloseDelay);session.delayInProgress=false}cancelTimer();session.tipOpenImminent=false;if(element.data(DATA_HASACTIVEHOVER)){element.data(DATA_FORCEDOPEN,false);if(!disableDelay){session.delayInProgress=true;session.closeDelayTimeout=setTimeout(function closeDelay(){session.closeDelayTimeout=null;tipController.hideTip(element);session.delayInProgress=false;myCloseDelay=null},options.closeDelay);myCloseDelay=session.closeDelayTimeout}else{tipController.hideTip(element)}}}function checkForIntent(){var xDifference=Math.abs(session.previousX-session.currentX),yDifference=Math.abs(session.previousY-session.currentY),totalDifference=xDifference+yDifference;if(totalDifference",{id:options.popupId});if($body.length===0){$body=$("body")}$body.append(tipElement);session.tooltips=session.tooltips?session.tooltips.add(tipElement):tipElement}if(options.followMouse){if(!tipElement.data(DATA_HASMOUSEMOVE)){$document.on("mousemove"+EVENT_NAMESPACE,positionTipOnCursor);$window.on("scroll"+EVENT_NAMESPACE,positionTipOnCursor);tipElement.data(DATA_HASMOUSEMOVE,true)}}function beginShowTip(element){element.data(DATA_HASACTIVEHOVER,true);tipElement.queue(function queueTipInit(next){showTip(element);next()})}function showTip(element){var tipContent;if(!element.data(DATA_HASACTIVEHOVER)){return}if(session.isTipOpen){if(!session.isClosing){hideTip(session.activeHover)}tipElement.delay(100).queue(function queueTipAgain(next){showTip(element);next()});return}element.trigger("powerTipPreRender");tipContent=getTooltipContent(element);if(tipContent){tipElement.empty().append(tipContent)}else{return}element.trigger("powerTipRender");session.activeHover=element;session.isTipOpen=true;tipElement.data(DATA_MOUSEONTOTIP,options.mouseOnToPopup);tipElement.addClass(options.popupClass);if(!options.followMouse||element.data(DATA_FORCEDOPEN)){positionTipOnElement(element);session.isFixedTipOpen=true}else{positionTipOnCursor()}if(!element.data(DATA_FORCEDOPEN)&&!options.followMouse){$document.on("click"+EVENT_NAMESPACE,function documentClick(event){var target=event.target;if(target!==element[0]){if(options.mouseOnToPopup){if(target!==tipElement[0]&&!$.contains(tipElement[0],target)){$.powerTip.hide()}}else{$.powerTip.hide()}}})}if(options.mouseOnToPopup&&!options.manual){tipElement.on("mouseenter"+EVENT_NAMESPACE,function tipMouseEnter(){if(session.activeHover){session.activeHover.data(DATA_DISPLAYCONTROLLER).cancel()}});tipElement.on("mouseleave"+EVENT_NAMESPACE,function tipMouseLeave(){if(session.activeHover){session.activeHover.data(DATA_DISPLAYCONTROLLER).hide()}})}tipElement.fadeIn(options.fadeInTime,function fadeInCallback(){if(!session.desyncTimeout){session.desyncTimeout=setInterval(closeDesyncedTip,500)}element.trigger("powerTipOpen")})}function hideTip(element){session.isClosing=true;session.isTipOpen=false;session.desyncTimeout=clearInterval(session.desyncTimeout);element.data(DATA_HASACTIVEHOVER,false);element.data(DATA_FORCEDOPEN,false);$document.off("click"+EVENT_NAMESPACE);tipElement.off(EVENT_NAMESPACE);tipElement.fadeOut(options.fadeOutTime,function fadeOutCallback(){var coords=new CSSCoordinates;session.activeHover=null;session.isClosing=false;session.isFixedTipOpen=false;tipElement.removeClass();coords.set("top",session.currentY+options.offset);coords.set("left",session.currentX+options.offset);tipElement.css(coords);element.trigger("powerTipClose")})}function positionTipOnCursor(){var tipWidth,tipHeight,coords,collisions,collisionCount;if(!session.isFixedTipOpen&&(session.isTipOpen||session.tipOpenImminent&&tipElement.data(DATA_HASMOUSEMOVE))){tipWidth=tipElement.outerWidth();tipHeight=tipElement.outerHeight();coords=new CSSCoordinates;coords.set("top",session.currentY+options.offset);coords.set("left",session.currentX+options.offset);collisions=getViewportCollisions(coords,tipWidth,tipHeight);if(collisions!==Collision.none){collisionCount=countFlags(collisions);if(collisionCount===1){if(collisions===Collision.right){coords.set("left",session.scrollLeft+session.windowWidth-tipWidth)}else if(collisions===Collision.bottom){coords.set("top",session.scrollTop+session.windowHeight-tipHeight)}}else{coords.set("left",session.currentX-tipWidth-options.offset);coords.set("top",session.currentY-tipHeight-options.offset)}}tipElement.css(coords)}}function positionTipOnElement(element){var priorityList,finalPlacement;if(options.smartPlacement||options.followMouse&&element.data(DATA_FORCEDOPEN)){priorityList=$.fn.powerTip.smartPlacementLists[options.placement];$.each(priorityList,function(idx,pos){var collisions=getViewportCollisions(placeTooltip(element,pos),tipElement.outerWidth(),tipElement.outerHeight());finalPlacement=pos;return collisions!==Collision.none})}else{placeTooltip(element,options.placement);finalPlacement=options.placement}tipElement.removeClass("w nw sw e ne se n s w se-alt sw-alt ne-alt nw-alt");tipElement.addClass(finalPlacement)}function placeTooltip(element,placement){var iterationCount=0,tipWidth,tipHeight,coords=new CSSCoordinates;coords.set("top",0);coords.set("left",0);tipElement.css(coords);do{tipWidth=tipElement.outerWidth();tipHeight=tipElement.outerHeight();coords=placementCalculator.compute(element,placement,tipWidth,tipHeight,options.offset);tipElement.css(coords)}while(++iterationCount<=5&&(tipWidth!==tipElement.outerWidth()||tipHeight!==tipElement.outerHeight()));return coords}function closeDesyncedTip(){var isDesynced=false,hasDesyncableCloseEvent=$.grep(["mouseleave","mouseout","blur","focusout"],function(eventType){return $.inArray(eventType,options.closeEvents)!==-1}).length>0;if(session.isTipOpen&&!session.isClosing&&!session.delayInProgress&&hasDesyncableCloseEvent){if(session.activeHover.data(DATA_HASACTIVEHOVER)===false||session.activeHover.is(":disabled")){isDesynced=true}else if(!isMouseOver(session.activeHover)&&!session.activeHover.is(":focus")&&!session.activeHover.data(DATA_FORCEDOPEN)){if(tipElement.data(DATA_MOUSEONTOTIP)){if(!isMouseOver(tipElement)){isDesynced=true}}else{isDesynced=true}}if(isDesynced){hideTip(session.activeHover)}}}this.showTip=beginShowTip;this.hideTip=hideTip;this.resetPosition=positionTipOnElement}function isSvgElement(element){return Boolean(window.SVGElement&&element[0]instanceof SVGElement)}function isMouseEvent(event){return Boolean(event&&$.inArray(event.type,MOUSE_EVENTS)>-1&&typeof event.pageX==="number")}function initTracking(){if(!session.mouseTrackingActive){session.mouseTrackingActive=true;getViewportDimensions();$(getViewportDimensions);$document.on("mousemove"+EVENT_NAMESPACE,trackMouse);$window.on("resize"+EVENT_NAMESPACE,trackResize);$window.on("scroll"+EVENT_NAMESPACE,trackScroll)}}function getViewportDimensions(){session.scrollLeft=$window.scrollLeft();session.scrollTop=$window.scrollTop();session.windowWidth=$window.width();session.windowHeight=$window.height()}function trackResize(){session.windowWidth=$window.width();session.windowHeight=$window.height()}function trackScroll(){var x=$window.scrollLeft(),y=$window.scrollTop();if(x!==session.scrollLeft){session.currentX+=x-session.scrollLeft;session.scrollLeft=x}if(y!==session.scrollTop){session.currentY+=y-session.scrollTop;session.scrollTop=y}}function trackMouse(event){session.currentX=event.pageX;session.currentY=event.pageY}function isMouseOver(element){var elementPosition=element.offset(),elementBox=element[0].getBoundingClientRect(),elementWidth=elementBox.right-elementBox.left,elementHeight=elementBox.bottom-elementBox.top;return session.currentX>=elementPosition.left&&session.currentX<=elementPosition.left+elementWidth&&session.currentY>=elementPosition.top&&session.currentY<=elementPosition.top+elementHeight}function getTooltipContent(element){var tipText=element.data(DATA_POWERTIP),tipObject=element.data(DATA_POWERTIPJQ),tipTarget=element.data(DATA_POWERTIPTARGET),targetElement,content;if(tipText){if($.isFunction(tipText)){tipText=tipText.call(element[0])}content=tipText}else if(tipObject){if($.isFunction(tipObject)){tipObject=tipObject.call(element[0])}if(tipObject.length>0){content=tipObject.clone(true,true)}}else if(tipTarget){targetElement=$("#"+tipTarget);if(targetElement.length>0){content=targetElement.html()}}return content}function getViewportCollisions(coords,elementWidth,elementHeight){var viewportTop=session.scrollTop,viewportLeft=session.scrollLeft,viewportBottom=viewportTop+session.windowHeight,viewportRight=viewportLeft+session.windowWidth,collisions=Collision.none;if(coords.topviewportBottom||Math.abs(coords.bottom-session.windowHeight)>viewportBottom){collisions|=Collision.bottom}if(coords.leftviewportRight){collisions|=Collision.left}if(coords.left+elementWidth>viewportRight||coords.right1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);/*! SmartMenus jQuery Plugin - v1.1.0 - September 17, 2017 + * http://www.smartmenus.org/ + * Copyright Vasil Dinkov, Vadikom Web Ltd. http://vadikom.com; Licensed MIT */(function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&"object"==typeof module.exports?module.exports=t(require("jquery")):t(jQuery)})(function($){function initMouseDetection(t){var e=".smartmenus_mouse";if(mouseDetectionEnabled||t)mouseDetectionEnabled&&t&&($(document).off(e),mouseDetectionEnabled=!1);else{var i=!0,s=null,o={mousemove:function(t){var e={x:t.pageX,y:t.pageY,timeStamp:(new Date).getTime()};if(s){var o=Math.abs(s.x-e.x),a=Math.abs(s.y-e.y);if((o>0||a>0)&&2>=o&&2>=a&&300>=e.timeStamp-s.timeStamp&&(mouse=!0,i)){var n=$(t.target).closest("a");n.is("a")&&$.each(menuTrees,function(){return $.contains(this.$root[0],n[0])?(this.itemEnter({currentTarget:n[0]}),!1):void 0}),i=!1}}s=e}};o[touchEvents?"touchstart":"pointerover pointermove pointerout MSPointerOver MSPointerMove MSPointerOut"]=function(t){isTouchEvent(t.originalEvent)&&(mouse=!1)},$(document).on(getEventsNS(o,e)),mouseDetectionEnabled=!0}}function isTouchEvent(t){return!/^(4|mouse)$/.test(t.pointerType)}function getEventsNS(t,e){e||(e="");var i={};for(var s in t)i[s.split(" ").join(e+" ")+e]=t[s];return i}var menuTrees=[],mouse=!1,touchEvents="ontouchstart"in window,mouseDetectionEnabled=!1,requestAnimationFrame=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},cancelAnimationFrame=window.cancelAnimationFrame||function(t){clearTimeout(t)},canAnimate=!!$.fn.animate;return $.SmartMenus=function(t,e){this.$root=$(t),this.opts=e,this.rootId="",this.accessIdPrefix="",this.$subArrow=null,this.activatedItems=[],this.visibleSubMenus=[],this.showTimeout=0,this.hideTimeout=0,this.scrollTimeout=0,this.clickActivated=!1,this.focusActivated=!1,this.zIndexInc=0,this.idInc=0,this.$firstLink=null,this.$firstSub=null,this.disabled=!1,this.$disableOverlay=null,this.$touchScrollingSub=null,this.cssTransforms3d="perspective"in t.style||"webkitPerspective"in t.style,this.wasCollapsible=!1,this.init()},$.extend($.SmartMenus,{hideAll:function(){$.each(menuTrees,function(){this.menuHideAll()})},destroy:function(){for(;menuTrees.length;)menuTrees[0].destroy();initMouseDetection(!0)},prototype:{init:function(t){var e=this;if(!t){menuTrees.push(this),this.rootId=((new Date).getTime()+Math.random()+"").replace(/\D/g,""),this.accessIdPrefix="sm-"+this.rootId+"-",this.$root.hasClass("sm-rtl")&&(this.opts.rightToLeftSubMenus=!0);var i=".smartmenus";this.$root.data("smartmenus",this).attr("data-smartmenus-id",this.rootId).dataSM("level",1).on(getEventsNS({"mouseover focusin":$.proxy(this.rootOver,this),"mouseout focusout":$.proxy(this.rootOut,this),keydown:$.proxy(this.rootKeyDown,this)},i)).on(getEventsNS({mouseenter:$.proxy(this.itemEnter,this),mouseleave:$.proxy(this.itemLeave,this),mousedown:$.proxy(this.itemDown,this),focus:$.proxy(this.itemFocus,this),blur:$.proxy(this.itemBlur,this),click:$.proxy(this.itemClick,this)},i),"a"),i+=this.rootId,this.opts.hideOnClick&&$(document).on(getEventsNS({touchstart:$.proxy(this.docTouchStart,this),touchmove:$.proxy(this.docTouchMove,this),touchend:$.proxy(this.docTouchEnd,this),click:$.proxy(this.docClick,this)},i)),$(window).on(getEventsNS({"resize orientationchange":$.proxy(this.winResize,this)},i)),this.opts.subIndicators&&(this.$subArrow=$("").addClass("sub-arrow"),this.opts.subIndicatorsText&&this.$subArrow.html(this.opts.subIndicatorsText)),initMouseDetection()}if(this.$firstSub=this.$root.find("ul").each(function(){e.menuInit($(this))}).eq(0),this.$firstLink=this.$root.find("a").eq(0),this.opts.markCurrentItem){var s=/(index|default)\.[^#\?\/]*/i,o=/#.*/,a=window.location.href.replace(s,""),n=a.replace(o,"");this.$root.find("a").each(function(){var t=this.href.replace(s,""),i=$(this);(t==a||t==n)&&(i.addClass("current"),e.opts.markCurrentTree&&i.parentsUntil("[data-smartmenus-id]","ul").each(function(){$(this).dataSM("parent-a").addClass("current")}))})}this.wasCollapsible=this.isCollapsible()},destroy:function(t){if(!t){var e=".smartmenus";this.$root.removeData("smartmenus").removeAttr("data-smartmenus-id").removeDataSM("level").off(e),e+=this.rootId,$(document).off(e),$(window).off(e),this.opts.subIndicators&&(this.$subArrow=null)}this.menuHideAll();var i=this;this.$root.find("ul").each(function(){var t=$(this);t.dataSM("scroll-arrows")&&t.dataSM("scroll-arrows").remove(),t.dataSM("shown-before")&&((i.opts.subMenusMinWidth||i.opts.subMenusMaxWidth)&&t.css({width:"",minWidth:"",maxWidth:""}).removeClass("sm-nowrap"),t.dataSM("scroll-arrows")&&t.dataSM("scroll-arrows").remove(),t.css({zIndex:"",top:"",left:"",marginLeft:"",marginTop:"",display:""})),0==(t.attr("id")||"").indexOf(i.accessIdPrefix)&&t.removeAttr("id")}).removeDataSM("in-mega").removeDataSM("shown-before").removeDataSM("scroll-arrows").removeDataSM("parent-a").removeDataSM("level").removeDataSM("beforefirstshowfired").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeAttr("aria-expanded"),this.$root.find("a.has-submenu").each(function(){var t=$(this);0==t.attr("id").indexOf(i.accessIdPrefix)&&t.removeAttr("id")}).removeClass("has-submenu").removeDataSM("sub").removeAttr("aria-haspopup").removeAttr("aria-controls").removeAttr("aria-expanded").closest("li").removeDataSM("sub"),this.opts.subIndicators&&this.$root.find("span.sub-arrow").remove(),this.opts.markCurrentItem&&this.$root.find("a.current").removeClass("current"),t||(this.$root=null,this.$firstLink=null,this.$firstSub=null,this.$disableOverlay&&(this.$disableOverlay.remove(),this.$disableOverlay=null),menuTrees.splice($.inArray(this,menuTrees),1))},disable:function(t){if(!this.disabled){if(this.menuHideAll(),!t&&!this.opts.isPopup&&this.$root.is(":visible")){var e=this.$root.offset();this.$disableOverlay=$('
').css({position:"absolute",top:e.top,left:e.left,width:this.$root.outerWidth(),height:this.$root.outerHeight(),zIndex:this.getStartZIndex(!0),opacity:0}).appendTo(document.body)}this.disabled=!0}},docClick:function(t){return this.$touchScrollingSub?(this.$touchScrollingSub=null,void 0):((this.visibleSubMenus.length&&!$.contains(this.$root[0],t.target)||$(t.target).closest("a").length)&&this.menuHideAll(),void 0)},docTouchEnd:function(){if(this.lastTouch){if(!(!this.visibleSubMenus.length||void 0!==this.lastTouch.x2&&this.lastTouch.x1!=this.lastTouch.x2||void 0!==this.lastTouch.y2&&this.lastTouch.y1!=this.lastTouch.y2||this.lastTouch.target&&$.contains(this.$root[0],this.lastTouch.target))){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0);var t=this;this.hideTimeout=setTimeout(function(){t.menuHideAll()},350)}this.lastTouch=null}},docTouchMove:function(t){if(this.lastTouch){var e=t.originalEvent.touches[0];this.lastTouch.x2=e.pageX,this.lastTouch.y2=e.pageY}},docTouchStart:function(t){var e=t.originalEvent.touches[0];this.lastTouch={x1:e.pageX,y1:e.pageY,target:e.target}},enable:function(){this.disabled&&(this.$disableOverlay&&(this.$disableOverlay.remove(),this.$disableOverlay=null),this.disabled=!1)},getClosestMenu:function(t){for(var e=$(t).closest("ul");e.dataSM("in-mega");)e=e.parent().closest("ul");return e[0]||null},getHeight:function(t){return this.getOffset(t,!0)},getOffset:function(t,e){var i;"none"==t.css("display")&&(i={position:t[0].style.position,visibility:t[0].style.visibility},t.css({position:"absolute",visibility:"hidden"}).show());var s=t[0].getBoundingClientRect&&t[0].getBoundingClientRect(),o=s&&(e?s.height||s.bottom-s.top:s.width||s.right-s.left);return o||0===o||(o=e?t[0].offsetHeight:t[0].offsetWidth),i&&t.hide().css(i),o},getStartZIndex:function(t){var e=parseInt(this[t?"$root":"$firstSub"].css("z-index"));return!t&&isNaN(e)&&(e=parseInt(this.$root.css("z-index"))),isNaN(e)?1:e},getTouchPoint:function(t){return t.touches&&t.touches[0]||t.changedTouches&&t.changedTouches[0]||t},getViewport:function(t){var e=t?"Height":"Width",i=document.documentElement["client"+e],s=window["inner"+e];return s&&(i=Math.min(i,s)),i},getViewportHeight:function(){return this.getViewport(!0)},getViewportWidth:function(){return this.getViewport()},getWidth:function(t){return this.getOffset(t)},handleEvents:function(){return!this.disabled&&this.isCSSOn()},handleItemEvents:function(t){return this.handleEvents()&&!this.isLinkInMegaMenu(t)},isCollapsible:function(){return"static"==this.$firstSub.css("position")},isCSSOn:function(){return"inline"!=this.$firstLink.css("display")},isFixed:function(){var t="fixed"==this.$root.css("position");return t||this.$root.parentsUntil("body").each(function(){return"fixed"==$(this).css("position")?(t=!0,!1):void 0}),t},isLinkInMegaMenu:function(t){return $(this.getClosestMenu(t[0])).hasClass("mega-menu")},isTouchMode:function(){return!mouse||this.opts.noMouseOver||this.isCollapsible()},itemActivate:function(t,e){var i=t.closest("ul"),s=i.dataSM("level");if(s>1&&(!this.activatedItems[s-2]||this.activatedItems[s-2][0]!=i.dataSM("parent-a")[0])){var o=this;$(i.parentsUntil("[data-smartmenus-id]","ul").get().reverse()).add(i).each(function(){o.itemActivate($(this).dataSM("parent-a"))})}if((!this.isCollapsible()||e)&&this.menuHideSubMenus(this.activatedItems[s-1]&&this.activatedItems[s-1][0]==t[0]?s:s-1),this.activatedItems[s-1]=t,this.$root.triggerHandler("activate.smapi",t[0])!==!1){var a=t.dataSM("sub");a&&(this.isTouchMode()||!this.opts.showOnClick||this.clickActivated)&&this.menuShow(a)}},itemBlur:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&this.$root.triggerHandler("blur.smapi",e[0])},itemClick:function(t){var e=$(t.currentTarget);if(this.handleItemEvents(e)){if(this.$touchScrollingSub&&this.$touchScrollingSub[0]==e.closest("ul")[0])return this.$touchScrollingSub=null,t.stopPropagation(),!1;if(this.$root.triggerHandler("click.smapi",e[0])===!1)return!1;var i=$(t.target).is(".sub-arrow"),s=e.dataSM("sub"),o=s?2==s.dataSM("level"):!1,a=this.isCollapsible(),n=/toggle$/.test(this.opts.collapsibleBehavior),r=/link$/.test(this.opts.collapsibleBehavior),h=/^accordion/.test(this.opts.collapsibleBehavior);if(s&&!s.is(":visible")){if((!r||!a||i)&&(this.opts.showOnClick&&o&&(this.clickActivated=!0),this.itemActivate(e,h),s.is(":visible")))return this.focusActivated=!0,!1}else if(a&&(n||i))return this.itemActivate(e,h),this.menuHide(s),n&&(this.focusActivated=!1),!1;return this.opts.showOnClick&&o||e.hasClass("disabled")||this.$root.triggerHandler("select.smapi",e[0])===!1?!1:void 0}},itemDown:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&e.dataSM("mousedown",!0)},itemEnter:function(t){var e=$(t.currentTarget);if(this.handleItemEvents(e)){if(!this.isTouchMode()){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0);var i=this;this.showTimeout=setTimeout(function(){i.itemActivate(e)},this.opts.showOnClick&&1==e.closest("ul").dataSM("level")?1:this.opts.showTimeout)}this.$root.triggerHandler("mouseenter.smapi",e[0])}},itemFocus:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&(!this.focusActivated||this.isTouchMode()&&e.dataSM("mousedown")||this.activatedItems.length&&this.activatedItems[this.activatedItems.length-1][0]==e[0]||this.itemActivate(e,!0),this.$root.triggerHandler("focus.smapi",e[0]))},itemLeave:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&(this.isTouchMode()||(e[0].blur(),this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0)),e.removeDataSM("mousedown"),this.$root.triggerHandler("mouseleave.smapi",e[0]))},menuHide:function(t){if(this.$root.triggerHandler("beforehide.smapi",t[0])!==!1&&(canAnimate&&t.stop(!0,!0),"none"!=t.css("display"))){var e=function(){t.css("z-index","")};this.isCollapsible()?canAnimate&&this.opts.collapsibleHideFunction?this.opts.collapsibleHideFunction.call(this,t,e):t.hide(this.opts.collapsibleHideDuration,e):canAnimate&&this.opts.hideFunction?this.opts.hideFunction.call(this,t,e):t.hide(this.opts.hideDuration,e),t.dataSM("scroll")&&(this.menuScrollStop(t),t.css({"touch-action":"","-ms-touch-action":"","-webkit-transform":"",transform:""}).off(".smartmenus_scroll").removeDataSM("scroll").dataSM("scroll-arrows").hide()),t.dataSM("parent-a").removeClass("highlighted").attr("aria-expanded","false"),t.attr({"aria-expanded":"false","aria-hidden":"true"});var i=t.dataSM("level");this.activatedItems.splice(i-1,1),this.visibleSubMenus.splice($.inArray(t,this.visibleSubMenus),1),this.$root.triggerHandler("hide.smapi",t[0])}},menuHideAll:function(){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0);for(var t=this.opts.isPopup?1:0,e=this.visibleSubMenus.length-1;e>=t;e--)this.menuHide(this.visibleSubMenus[e]);this.opts.isPopup&&(canAnimate&&this.$root.stop(!0,!0),this.$root.is(":visible")&&(canAnimate&&this.opts.hideFunction?this.opts.hideFunction.call(this,this.$root):this.$root.hide(this.opts.hideDuration))),this.activatedItems=[],this.visibleSubMenus=[],this.clickActivated=!1,this.focusActivated=!1,this.zIndexInc=0,this.$root.triggerHandler("hideAll.smapi")},menuHideSubMenus:function(t){for(var e=this.activatedItems.length-1;e>=t;e--){var i=this.activatedItems[e].dataSM("sub");i&&this.menuHide(i)}},menuInit:function(t){if(!t.dataSM("in-mega")){t.hasClass("mega-menu")&&t.find("ul").dataSM("in-mega",!0);for(var e=2,i=t[0];(i=i.parentNode.parentNode)!=this.$root[0];)e++;var s=t.prevAll("a").eq(-1);s.length||(s=t.prevAll().find("a").eq(-1)),s.addClass("has-submenu").dataSM("sub",t),t.dataSM("parent-a",s).dataSM("level",e).parent().dataSM("sub",t);var o=s.attr("id")||this.accessIdPrefix+ ++this.idInc,a=t.attr("id")||this.accessIdPrefix+ ++this.idInc;s.attr({id:o,"aria-haspopup":"true","aria-controls":a,"aria-expanded":"false"}),t.attr({id:a,role:"group","aria-hidden":"true","aria-labelledby":o,"aria-expanded":"false"}),this.opts.subIndicators&&s[this.opts.subIndicatorsPos](this.$subArrow.clone())}},menuPosition:function(t){var e,i,s=t.dataSM("parent-a"),o=s.closest("li"),a=o.parent(),n=t.dataSM("level"),r=this.getWidth(t),h=this.getHeight(t),u=s.offset(),l=u.left,c=u.top,d=this.getWidth(s),m=this.getHeight(s),p=$(window),f=p.scrollLeft(),v=p.scrollTop(),b=this.getViewportWidth(),S=this.getViewportHeight(),g=a.parent().is("[data-sm-horizontal-sub]")||2==n&&!a.hasClass("sm-vertical"),M=this.opts.rightToLeftSubMenus&&!o.is("[data-sm-reverse]")||!this.opts.rightToLeftSubMenus&&o.is("[data-sm-reverse]"),w=2==n?this.opts.mainMenuSubOffsetX:this.opts.subMenusSubOffsetX,T=2==n?this.opts.mainMenuSubOffsetY:this.opts.subMenusSubOffsetY;if(g?(e=M?d-r-w:w,i=this.opts.bottomToTopSubMenus?-h-T:m+T):(e=M?w-r:d-w,i=this.opts.bottomToTopSubMenus?m-T-h:T),this.opts.keepInViewport){var y=l+e,I=c+i;if(M&&f>y?e=g?f-y+e:d-w:!M&&y+r>f+b&&(e=g?f+b-r-y+e:w-r),g||(S>h&&I+h>v+S?i+=v+S-h-I:(h>=S||v>I)&&(i+=v-I)),g&&(I+h>v+S+.49||v>I)||!g&&h>S+.49){var x=this;t.dataSM("scroll-arrows")||t.dataSM("scroll-arrows",$([$('')[0],$('')[0]]).on({mouseenter:function(){t.dataSM("scroll").up=$(this).hasClass("scroll-up"),x.menuScroll(t)},mouseleave:function(e){x.menuScrollStop(t),x.menuScrollOut(t,e)},"mousewheel DOMMouseScroll":function(t){t.preventDefault()}}).insertAfter(t));var A=".smartmenus_scroll";if(t.dataSM("scroll",{y:this.cssTransforms3d?0:i-m,step:1,itemH:m,subH:h,arrowDownH:this.getHeight(t.dataSM("scroll-arrows").eq(1))}).on(getEventsNS({mouseover:function(e){x.menuScrollOver(t,e)},mouseout:function(e){x.menuScrollOut(t,e)},"mousewheel DOMMouseScroll":function(e){x.menuScrollMousewheel(t,e)}},A)).dataSM("scroll-arrows").css({top:"auto",left:"0",marginLeft:e+(parseInt(t.css("border-left-width"))||0),width:r-(parseInt(t.css("border-left-width"))||0)-(parseInt(t.css("border-right-width"))||0),zIndex:t.css("z-index")}).eq(g&&this.opts.bottomToTopSubMenus?0:1).show(),this.isFixed()){var C={};C[touchEvents?"touchstart touchmove touchend":"pointerdown pointermove pointerup MSPointerDown MSPointerMove MSPointerUp"]=function(e){x.menuScrollTouch(t,e)},t.css({"touch-action":"none","-ms-touch-action":"none"}).on(getEventsNS(C,A))}}}t.css({top:"auto",left:"0",marginLeft:e,marginTop:i-m})},menuScroll:function(t,e,i){var s,o=t.dataSM("scroll"),a=t.dataSM("scroll-arrows"),n=o.up?o.upEnd:o.downEnd;if(!e&&o.momentum){if(o.momentum*=.92,s=o.momentum,.5>s)return this.menuScrollStop(t),void 0}else s=i||(e||!this.opts.scrollAccelerate?this.opts.scrollStep:Math.floor(o.step));var r=t.dataSM("level");if(this.activatedItems[r-1]&&this.activatedItems[r-1].dataSM("sub")&&this.activatedItems[r-1].dataSM("sub").is(":visible")&&this.menuHideSubMenus(r-1),o.y=o.up&&o.y>=n||!o.up&&n>=o.y?o.y:Math.abs(n-o.y)>s?o.y+(o.up?s:-s):n,t.css(this.cssTransforms3d?{"-webkit-transform":"translate3d(0, "+o.y+"px, 0)",transform:"translate3d(0, "+o.y+"px, 0)"}:{marginTop:o.y}),mouse&&(o.up&&o.y>o.downEnd||!o.up&&o.y0;t.dataSM("scroll-arrows").eq(i?0:1).is(":visible")&&(t.dataSM("scroll").up=i,this.menuScroll(t,!0))}e.preventDefault()},menuScrollOut:function(t,e){mouse&&(/^scroll-(up|down)/.test((e.relatedTarget||"").className)||(t[0]==e.relatedTarget||$.contains(t[0],e.relatedTarget))&&this.getClosestMenu(e.relatedTarget)==t[0]||t.dataSM("scroll-arrows").css("visibility","hidden"))},menuScrollOver:function(t,e){if(mouse&&!/^scroll-(up|down)/.test(e.target.className)&&this.getClosestMenu(e.target)==t[0]){this.menuScrollRefreshData(t);var i=t.dataSM("scroll"),s=$(window).scrollTop()-t.dataSM("parent-a").offset().top-i.itemH;t.dataSM("scroll-arrows").eq(0).css("margin-top",s).end().eq(1).css("margin-top",s+this.getViewportHeight()-i.arrowDownH).end().css("visibility","visible")}},menuScrollRefreshData:function(t){var e=t.dataSM("scroll"),i=$(window).scrollTop()-t.dataSM("parent-a").offset().top-e.itemH;this.cssTransforms3d&&(i=-(parseFloat(t.css("margin-top"))-i)),$.extend(e,{upEnd:i,downEnd:i+this.getViewportHeight()-e.subH})},menuScrollStop:function(t){return this.scrollTimeout?(cancelAnimationFrame(this.scrollTimeout),this.scrollTimeout=0,t.dataSM("scroll").step=1,!0):void 0},menuScrollTouch:function(t,e){if(e=e.originalEvent,isTouchEvent(e)){var i=this.getTouchPoint(e);if(this.getClosestMenu(i.target)==t[0]){var s=t.dataSM("scroll");if(/(start|down)$/i.test(e.type))this.menuScrollStop(t)?(e.preventDefault(),this.$touchScrollingSub=t):this.$touchScrollingSub=null,this.menuScrollRefreshData(t),$.extend(s,{touchStartY:i.pageY,touchStartTime:e.timeStamp});else if(/move$/i.test(e.type)){var o=void 0!==s.touchY?s.touchY:s.touchStartY;if(void 0!==o&&o!=i.pageY){this.$touchScrollingSub=t;var a=i.pageY>o;void 0!==s.up&&s.up!=a&&$.extend(s,{touchStartY:i.pageY,touchStartTime:e.timeStamp}),$.extend(s,{up:a,touchY:i.pageY}),this.menuScroll(t,!0,Math.abs(i.pageY-o))}e.preventDefault()}else void 0!==s.touchY&&((s.momentum=15*Math.pow(Math.abs(i.pageY-s.touchStartY)/(e.timeStamp-s.touchStartTime),2))&&(this.menuScrollStop(t),this.menuScroll(t),e.preventDefault()),delete s.touchY)}}},menuShow:function(t){if((t.dataSM("beforefirstshowfired")||(t.dataSM("beforefirstshowfired",!0),this.$root.triggerHandler("beforefirstshow.smapi",t[0])!==!1))&&this.$root.triggerHandler("beforeshow.smapi",t[0])!==!1&&(t.dataSM("shown-before",!0),canAnimate&&t.stop(!0,!0),!t.is(":visible"))){var e=t.dataSM("parent-a"),i=this.isCollapsible();if((this.opts.keepHighlighted||i)&&e.addClass("highlighted"),i)t.removeClass("sm-nowrap").css({zIndex:"",width:"auto",minWidth:"",maxWidth:"",top:"",left:"",marginLeft:"",marginTop:""});else{if(t.css("z-index",this.zIndexInc=(this.zIndexInc||this.getStartZIndex())+1),(this.opts.subMenusMinWidth||this.opts.subMenusMaxWidth)&&(t.css({width:"auto",minWidth:"",maxWidth:""}).addClass("sm-nowrap"),this.opts.subMenusMinWidth&&t.css("min-width",this.opts.subMenusMinWidth),this.opts.subMenusMaxWidth)){var s=this.getWidth(t);t.css("max-width",this.opts.subMenusMaxWidth),s>this.getWidth(t)&&t.removeClass("sm-nowrap").css("width",this.opts.subMenusMaxWidth)}this.menuPosition(t)}var o=function(){t.css("overflow","")};i?canAnimate&&this.opts.collapsibleShowFunction?this.opts.collapsibleShowFunction.call(this,t,o):t.show(this.opts.collapsibleShowDuration,o):canAnimate&&this.opts.showFunction?this.opts.showFunction.call(this,t,o):t.show(this.opts.showDuration,o),e.attr("aria-expanded","true"),t.attr({"aria-expanded":"true","aria-hidden":"false"}),this.visibleSubMenus.push(t),this.$root.triggerHandler("show.smapi",t[0])}},popupHide:function(t){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0);var e=this;this.hideTimeout=setTimeout(function(){e.menuHideAll()},t?1:this.opts.hideTimeout)},popupShow:function(t,e){if(!this.opts.isPopup)return alert('SmartMenus jQuery Error:\n\nIf you want to show this menu via the "popupShow" method, set the isPopup:true option.'),void 0;if(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0),this.$root.dataSM("shown-before",!0),canAnimate&&this.$root.stop(!0,!0),!this.$root.is(":visible")){this.$root.css({left:t,top:e});var i=this,s=function(){i.$root.css("overflow","")};canAnimate&&this.opts.showFunction?this.opts.showFunction.call(this,this.$root,s):this.$root.show(this.opts.showDuration,s),this.visibleSubMenus[0]=this.$root}},refresh:function(){this.destroy(!0),this.init(!0)},rootKeyDown:function(t){if(this.handleEvents())switch(t.keyCode){case 27:var e=this.activatedItems[0];if(e){this.menuHideAll(),e[0].focus();var i=e.dataSM("sub");i&&this.menuHide(i)}break;case 32:var s=$(t.target);if(s.is("a")&&this.handleItemEvents(s)){var i=s.dataSM("sub");i&&!i.is(":visible")&&(this.itemClick({currentTarget:t.target}),t.preventDefault())}}},rootOut:function(t){if(this.handleEvents()&&!this.isTouchMode()&&t.target!=this.$root[0]&&(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0),!this.opts.showOnClick||!this.opts.hideOnClick)){var e=this;this.hideTimeout=setTimeout(function(){e.menuHideAll()},this.opts.hideTimeout)}},rootOver:function(t){this.handleEvents()&&!this.isTouchMode()&&t.target!=this.$root[0]&&this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0)},winResize:function(t){if(this.handleEvents()){if(!("onorientationchange"in window)||"orientationchange"==t.type){var e=this.isCollapsible();this.wasCollapsible&&e||(this.activatedItems.length&&this.activatedItems[this.activatedItems.length-1][0].blur(),this.menuHideAll()),this.wasCollapsible=e}}else if(this.$disableOverlay){var i=this.$root.offset();this.$disableOverlay.css({top:i.top,left:i.left,width:this.$root.outerWidth(),height:this.$root.outerHeight()})}}}}),$.fn.dataSM=function(t,e){return e?this.data(t+"_smartmenus",e):this.data(t+"_smartmenus")},$.fn.removeDataSM=function(t){return this.removeData(t+"_smartmenus")},$.fn.smartmenus=function(options){if("string"==typeof options){var args=arguments,method=options;return Array.prototype.shift.call(args),this.each(function(){var t=$(this).data("smartmenus");t&&t[method]&&t[method].apply(t,args)})}return this.each(function(){var dataOpts=$(this).data("sm-options")||null;if(dataOpts)try{dataOpts=eval("("+dataOpts+")")}catch(e){dataOpts=null,alert('ERROR\n\nSmartMenus jQuery init:\nInvalid "data-sm-options" attribute value syntax.')}new $.SmartMenus(this,$.extend({},$.fn.smartmenus.defaults,options,dataOpts))})},$.fn.smartmenus.defaults={isPopup:!1,mainMenuSubOffsetX:0,mainMenuSubOffsetY:0,subMenusSubOffsetX:0,subMenusSubOffsetY:0,subMenusMinWidth:"10em",subMenusMaxWidth:"20em",subIndicators:!0,subIndicatorsPos:"append",subIndicatorsText:"",scrollStep:30,scrollAccelerate:!0,showTimeout:250,hideTimeout:500,showDuration:0,showFunction:null,hideDuration:0,hideFunction:function(t,e){t.fadeOut(200,e)},collapsibleShowDuration:0,collapsibleShowFunction:function(t,e){t.slideDown(200,e)},collapsibleHideDuration:0,collapsibleHideFunction:function(t,e){t.slideUp(200,e)},showOnClick:!1,hideOnClick:!0,noMouseOver:!1,keepInViewport:!0,keepHighlighted:!0,markCurrentItem:!1,markCurrentTree:!0,rightToLeftSubMenus:!1,bottomToTopSubMenus:!1,collapsibleBehavior:"default"},$}); \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/logo_scaled.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/logo_scaled.png new file mode 100644 index 0000000000000000000000000000000000000000..83ce5ab7159a7c75960013961839b40b8261b21e GIT binary patch literal 7690 zcmd^kg;!M18~4&nNr&{(`=z9F7ldU2k(O?d66tQFV`)?*L`pzOk?vfTrG-U0luk)m z;$434dH;%c&bfEyeC~7SoSAuMp3mo*L|tt)auOyI002O)p$^jr0B|+1?Uz78>^nT1 zHwRl0d#aoI000jL?jM}j0uPw6Ad#L#AA4^XPhS@gcK{7BhzpC8+~X=9o|feqO}zolJzvwXFz_BWw)J** zad!grFmJ?TF{1zbzn{0g1K{i~diVdCsd%`#Ik@`*&QWi=u^8dK*)td4mkxl6gGoLB zfMr?(_V`&~{{CW+&9muFqNBrB@n6R2O2CXTzLyzV1XQ#W(8txT)gg-&6bz@8bcL>l z<92lT^Pg6Xq+bwJh0w)N!f<}6l*HmI13~EpFU5V9*aNzKcuC7%6D{iqr2igWbj&;% zk?r<@tAlwGu;rU7rcx&o+t@N0NQYrdY0v*3)ym!dxVM(Io&eI*0TQ<1d)yoxIH240 zO*jlGe9lcZ;iaQArie?e|72Z!$QU0Gg8-_+p4;nCQ?XufbDxrNSB;rOv_o}Z&uR4I z0u*TUc7wWOcbIW2D&1fXhL8tn0!m;E05G8k<>rNPN%GJqCh8rz;KJF7)PipDO7UaT zlZvGHijX`wTib~`WD|)9hz87Ug$$;Tt2$^nn`xZXaV>W3V=U{>V7R8M3c+>_U)2oc z+C3rW=7E>EI+75c??&qVvV0^bkLTs3cSYFu;?s7;M4_~?67^L%!3v{uR(h(=qYmnV z+1V`EPtNuW5GBxVKhCb|8yI#FpgP;!O{o8bYZ4g1>+Q&$Sa(zsvAg~Hkw)UgWvxb- zXa8%Jj2Tex)`$&h*w-z;`H|}iA3mOSgD6%F7@tfWcQL&>Snrud?BMXr|)be_7Gl5(&fhoDP(DuL4U4a5O(?n-RS;Yt~boxf#TIATO1C&WZLI}bpyCv9}n&?6@6B0m)6%Pf_v}*_Px2fRG z(;-P?GSy}j?XIgE@uLkn2;gXxX#VK5!y*AF;Hj>TVD%B(fXd3QiFPbEsmUog9Uv7_ zFYN!+&-pH%-|jth6gpHnv;Xd=J=6u8%~f0V;;Rxv%?*&5FDdi* zNodpM6X#skQk2K^PAN)PAW)UBs zfu&yl*E`xr!ovSq)z8hIRQ!tbfX-5m&vxeSJwaib=FUW7V#9nw?nL>fhFVymGVuAC zj;j>+_w-GBu%6{qBmpUUJvz<*L%k?4Y#VTxuD`qEj4D2E_h2S>604|sp=5RY*r6mJ z<3?o_;UWI<{XB#CAyaY%zjdb9y!WS;2}6?MdKXqz2qWTsQ%=E$y}&cr)| z^$ZsyL)dSqUD1br113;)G>KHEW|Luj!q}a5C*u+ur%rgfzw+YugV*TQjfd>EPLE|{#`|{Om1ZZT zB`Yh3(iUF}-OY&LAeg7i?qicVd=tV7*(`;L!GxVO|&fDh%`4Ys!+{ z)>@-FJipE-GeIW-9$Lj7jyzM9`-*?m&=6AMQF~r9rU>OD8itO<^GY};U(Y@^;Y&PrDgx@l?kQXYitX@<6kdtAx}b{zecLnu}=%LNB7eU2+~YW5Gto3$&MnT$#jqQor>Z>3?KqW0Vz zDLEZYj3@%V)?X_!wJvEX<$alm59a=;eUR)b%pO(q4t#`JfN=NeMbo-`8~GY!4u)Ru z#V2&~JEa^ZZcC>s!GkmD22xA?Kb5&Lh%BZy?w%J*ZhvX}NaeE;5&ero=b4Ad88Oa@ zwJG~?jw#;cQJ%bx+L(J~LgGZk?`D7X^eq_jm1FUv$(rNH36s3LDWueb^~rVli|UaZ zx49;E@j??eseDHkI%;ZZ3t6&~FX9N~HmQ-YwISe;l7vIFB7*6C_@&_K;Z)IU9O9X9 z)LriSg=-S0*NtdxcRRtM(6Eo?a>ln|k^ZX`O!n%ZuNm(Ge=i+xO+)DP!rP^gjsG=K zMg~D_#V7YDx|a2EVJuC!!tW;8Eyc4|)4qftS;jh`nDHD4U$x@G#YCt>PA$!P#>@>E zT-}>YiZC{N1dmWp&?Dgj%%J*#eX?BG~v3 znKaI;^39swr0LkZNztx(6NGx_f9pfOk~PCOey-kTvs^60c!7U2yJKy?wTgtrcU(sY zUy26o1upIL5Fu2RM$$KIgdPKI3rakz&TmkpuDS;Ev@`bp>(l*5vp4G?iNlwWFzbf* z!-K1Byt|?K({MdKrtzmML1+6T-){UVltG(=vv<$asPvv={ge#~t`49TCG}bCCGy8} zll(a8-Vp@%V43_TZATVPm7XQna+H`8!j3oa)Ia(yyEGg)d@u9($yvczz7N zL3L-1@f{7Ih#4i6EPc3m9-Soqnawp09zgO#JZ09<`kD3|us|;1m<#rye>o9ygi_8bjIAUA)m+{$KPAMI0h@Lc(z4- z&yDRxQCo|E)59=oi4l2MlnkHCbrH)8@}hH38prNBxb@1U87UZ_cqP>wZl+>86(Nah zT`LT;wCwR>=?vJ}zi3`tNbG!6S14ZxSHs*pj29BGu%rt_X+$QRVto3((=hPQSl-c( zyu5K)2-UjIZc^e<<^w%=;O`@*3}&%Rg z&OO<}hHPHbn`BRq|P!QIoc;Zf8@&n@fGPDiD!E1w3qemy=qFz_6G>E+bA+kr|i z?SSHZ)l3Xm8_DlcE~AjBRvnE$xcR43a*_Xg?aObgof2U3~ZN4+0=qL#(D}(SF-7fK6tWlwz6q*gbGSXIaZHT3O-md$F-uI7Rf z9v?nCeFJ99G^uZ+e5LgJjoDOW&tmF31KgIK$==J$Lq$6euf_@cRTBgCC!t4P(9w6} z2FnYA*G3P}FsOSsbl=kU!yi=!9=qb3mg5~;Dh4{*RODPI_tifK3JoOJMZv3gI#o*i z&SQO1OI`L;GdK5(9q7G*-%}1|ut%hLp$UT0Rwb}R9829}EN>S=%QMMhDGMoMUC;&8 zGtqVk0c9Wu2+D-E62bsh)5TaQw49jV7~)ycVI|V#kI!q|^9Wb#`>k0=i!+{8 zL;z_`ryYMyyB+X4eC)?8E>I%&=y!uGkU(W4RgghvI}Hk%|25W0)nI3T)3Uyy*K$~2 z+jo$KUuQEB{FHH?wO}f1C3FG^TDfq|33j)B`fh%!IzJhSE-lxHRDDKtVHtgp~Z#YIOp> z=f7Ayuccp|XX0-UYTsFMUp*Z#+8g^XU98ZYTu-lOyF`1)r9>O9Vh>pM0QdgQSFS=W zrreZCdUj^ioE#19b@gL+rPpe3XuGY*`>;^zOzPtOO^uzysq$Kz8dHc1uF{Jag6>_s z^CpbX0?)~xvY=VH;{Ar&Qh45*b9%N2M>=iP_U0pbAD{SgKPkzzP_i*Gl8bw=6BFXj z9NoeGz%ED|=glVV2TvWI+~izkAU-bjVMjN)D|&zMx_nG!Q(L3Dr5A=|A9d&YJ3cSC zUM*;LNiH`jkJ`mhZK2!o-Ut1DIRL|O&?R$0Fl*AYUpu+i!ck1jegwY5-<3!z7n%(( zN@d>v<)1|HT%l`QLxIBGp6P#C@FS(^J$l{OoY2fZm(t!nm}hF5Ft7768`$7~ehA2+n9Ei(O_fTFyCRzF7UfyeTtk zjMYd?BEn`)VK3RVeo(r1IWo?b4Z#%*v}kff-6SNmj`P)R26vPN$H1`J>Abhj1?(#) z{~iS@F}ZiU&@M%s=?jMcv3uGMWey8zj*nT(WuaIyG+@)CI>fA%%wsJ0dOHe!B5C;!u<^BAS&Gq&oV65&9B~uLk2I`J*7-Fzw z81K3)JUSb3c_uAEm`h;_2c9^7b5zN))4;ju*pCHCYS|n`rncN{=$Tv%IRu_iFsxmF z4@3ANEDRTCApb%Kg;}a98V=6(T0iRm6~sNrKe;l|ULZ{~csV3aE^%`yx28)V?j6B0OSe<1CV#IST6Vq&Ufw9T($jO) z`C)K=|6zANw@6GizUN@dmw>^LlGY|sX3lN5^#1tp7)lwx=e$i2I(fv>sN*fotX6`~iMTuvPb!*tdfVx~qp_+ymNC|XpG6jQU+TXMP+ zg&z;5B}2MkNCB)EG}0&JDU#M5-M;jXKA1HElCfr|qBnF@@1T6GbD|)8k^tkiCJeN< zS0$d+R?VXZb9NAkb0a4cth7f|`|VfCy(s(m@k86O^o~J?fVX+pe$`nH>O?BIAC=_r zC#CN0Ap>))6T2ewJIe)0fsOiHCY6fMuKI;;$&s*H~5yxkP*+Xjgm;c)KA~s=F z5^KfXuHIq!f(6Tsn9m#5*vv4)ll$1L7s+%~-i)J|vPND}B{*hL)i7fW4uG_Ml=8uj zUxePBrZKav;+Lr3@)ki-MwLteldOB^CJid$%EEUq z-6ob^3(s+sF`4=BlJblkR3eR3_z0~!n`B-t(HZks*GhGp>Wfs~>UXRJd;OT`dUFoK z_teJ(qQbnzYPxS!o*B)#@)HAH;f5w6Z)uIRe6y|lqXW_gPce!r21;|TVk8`l*@1iS z3oQjS-PLWWj-(m@k)EmK;D9$1W^KpX>?i(>dlXtil$m8` zAz;{ksH&+F7%cMaqNXzN{J6mj;{jE1bL*kYwz&8qd< zs(IM-$kX;)+Ofgi2ot;zc&EX@xP#PheLHM4T{7_mSy_B#TXyG%`?-~Ly~#Apw1*R& z-7v~3;3YFyM!jy0y_5@}Xu4YmJYZ2kTwO(;Y&*ZQyvxdDNij#LJ}%2Psq-wb+Nv>m z0$Mw$wv~pYzfk6on~V1c*KbX8(Q(B)t>hC!Ccr{eTCXVI2fIr?S7&-mGUQnWLp~sG zx&2{#)tFmLMf`HMgW~hd-UG!ZO8>Hs?1L;CB_K#`Kl{S$`EDHdh#O*40o&>CQpVG* zH%WV-?Hq+7hPHxyyO%%GVSKz@Lc|$wv;Em46Bd+OcG64bDBoGfbK1y;co>B>5c$xD zMnghASNR-aB(aAdq49NSx|37nExa5zMe8wko)7_n9_A|atYskRQY`}mGlYVi9OviE zuS0!y)@l$`_(uz2fJa;qbR)9FXG@e4SkzQQJn3Ua4JzeE_LWx-gZ3rMPj9g4$MJDW zCH~(X=WjIBvBZLs!S#;K#B`BTihl0RDmaXpgLf`|)`T6fN|N5I3!I)#x)M-_sk$Vj zrOkwVL+J9C!NODkXXK9q((>#pw1V75@_o!}kqU~yFyfdN6UCU4dBkV8sl-%J;x`o! zHk2(XRlVDr$eW>$b>Sdm@i?D8|36!;F3!M}&a(OXqcLVZ(`je7M?rQX3Z7^a?uP>G zyXD-A?U4{NS}*#X*3NAI4^)oaE=9FUZNuLeP5X0*(WuTBLZ5qPKkbW!{FxhH$?F8q zY@(JRkP*4Jik^3;G)ZiX?dO_wjC(RdRc!1ytAY9o{cnf-9d#!g$}u|@hu=3l*=-j+ z&!tuszsKs0k9<(^EyW%Zx8$5*=Bl?N3+^4CU73!~G4n^~MDx0OrW7Fjwo<;e2@H}e zMBVAuKLWp0+5yH$3ZXx6n`Oqd$)o3#C}LUu`0n|t=>8Rz`qPA&fDkf?ojb*^M>9M|e6uq0L_GZ^ClZus*N;1krn%2VcPo^&*!lW*2gw z+;HxVqxE`E5%V)HQ%Kjx2;!?r(iurnFcquleJYi&G+V|3o!~J;$K|xoCP5I@a?!1$ z>aG9#0>Bl`)shQ=`!7z`({ZBO#N^TM8ddA!$VTV}W9?t7Z&xL97MDbU5)-t^sM9%1 zMJjCwlG9x$koH-vZz4~ydJU3GmH2#M&71Rovw*!!BSBu(>fYa~DH6wVb7Bj@|0k7V lq*}yI76*33ax>TL?k7zTWNF|A*eg$fhN?EKM%gCn{{Tz+VQ>Hd literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/modules.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/modules.html new file mode 100644 index 000000000..08d1a64ab --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/modules.html @@ -0,0 +1,119 @@ + + + + + + + +R_RSIP Documentation: API Reference + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
API Reference
+
+
+
This section includes the API Reference for the Module and Interface level functions.
+
[detail level 12]
+ + + + +
 ModulesModules are the smallest unit of software available in the Security Package. Each module implements one interface
 Renesas Secure IP (r_rsip)Driver for the Renesas Secure IP on RZ MPUs. This module implements the RSIP Interface
 InterfacesThe interfaces provide APIs for common functionality. They can be implemented by one or more modules. Modules can use other modules as dependencies using this interface layer
 RSIP InterfaceInterface for Renesas Secure IP (RSIP) functions
+
+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/modules.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/modules.js new file mode 100644 index 000000000..40cd17d0a --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/modules.js @@ -0,0 +1,5 @@ +var modules = +[ + [ "Modules", "group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.html", "group___r_e_n_e_s_a_s___m_o_d_u_l_e_s" ], + [ "Interfaces", "group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.html", "group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s" ] +]; \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/nav_f.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/nav_f.png new file mode 100644 index 0000000000000000000000000000000000000000..72a58a529ed3a9ed6aa0c51a79cf207e026deee2 GIT binary patch literal 153 zcmeAS@N?(olHy`uVBq!ia0vp^j6iI`!2~2XGqLUlQVE_ejv*C{Z|{2ZH7M}7UYxc) zn!W8uqtnIQ>_z8U literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/nav_g.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/nav_g.png new file mode 100644 index 0000000000000000000000000000000000000000..2093a237a94f6c83e19ec6e5fd42f7ddabdafa81 GIT binary patch literal 95 zcmeAS@N?(olHy`uVBq!ia0vp^j6lrB!3HFm1ilyoDK$?Q$B+ufw|5PB85lU25BhtE tr?otc=hd~V+ws&_A@j8Fiv!KF$B+ufw|5=67#uj90@pIL wZ=Q8~_Ju`#59=RjDrmm`tMD@M=!-l18IR?&vFVdQ&MBb@0HFXL=0 ? varName.substring(i+1) : varName; + return eval(n.replace(/\-/g,'_')); +} + +function stripPath(uri) +{ + return uri.substring(uri.lastIndexOf('/')+1); +} + +function stripPath2(uri) +{ + var i = uri.lastIndexOf('/'); + var s = uri.substring(i+1); + var m = uri.substring(0,i+1).match(/\/d\w\/d\w\w\/$/); + return m ? uri.substring(i-6) : s; +} + +function hashValue() +{ + return $(location).attr('hash').substring(1).replace(/[^\w\-]/g,''); +} + +function hashUrl() +{ + return '#'+hashValue(); +} + +function pathName() +{ + return $(location).attr('pathname').replace(/[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]/g, ''); +} + +function localStorageSupported() +{ + try { + return 'localStorage' in window && window['localStorage'] !== null && window.localStorage.getItem; + } + catch(e) { + return false; + } +} + +function storeLink(link) +{ + if (!$("#nav-sync").hasClass('sync') && localStorageSupported()) { + window.localStorage.setItem('navpath',link); + } +} + +function deleteLink() +{ + if (localStorageSupported()) { + window.localStorage.setItem('navpath',''); + } +} + +function cachedLink() +{ + if (localStorageSupported()) { + return window.localStorage.getItem('navpath'); + } else { + return ''; + } +} + +function getScript(scriptName,func,show) +{ + var head = document.getElementsByTagName("head")[0]; + var script = document.createElement('script'); + script.id = scriptName; + script.type = 'text/javascript'; + script.onload = func; + script.src = scriptName+'.js'; + head.appendChild(script); +} + +function createIndent(o,domNode,node,level) +{ + var level=-1; + var n = node; + while (n.parentNode) { level++; n=n.parentNode; } + if (node.childrenData) { + var imgNode = document.createElement("span"); + imgNode.className = 'arrow'; + imgNode.style.paddingLeft=(16*level).toString()+'px'; + imgNode.innerHTML=arrowRight; + node.plus_img = imgNode; + node.expandToggle = document.createElement("a"); + node.expandToggle.href = "javascript:void(0)"; + node.expandToggle.onclick = function() { + if (node.expanded) { + $(node.getChildrenUL()).slideUp("fast"); + node.plus_img.innerHTML=arrowRight; + node.expanded = false; + } else { + expandNode(o, node, false, false); + } + } + node.expandToggle.appendChild(imgNode); + domNode.appendChild(node.expandToggle); + } else { + var span = document.createElement("span"); + span.className = 'arrow'; + span.style.width = 16*(level+1)+'px'; + span.innerHTML = ' '; + domNode.appendChild(span); + } +} + +var animationInProgress = false; + +function gotoAnchor(anchor,aname,updateLocation) +{ + var pos, docContent = $('#doc-content'); + var ancParent = $(anchor.parent()); + if (ancParent.hasClass('memItemLeft') || + ancParent.hasClass('memtitle') || + ancParent.hasClass('fieldname') || + ancParent.hasClass('fieldtype') || + ancParent.is(':header')) + { + pos = ancParent.position().top; + } else if (anchor.position()) { + pos = anchor.position().top; + } + if (pos) { + var dist = Math.abs(Math.min( + pos-docContent.offset().top, + docContent[0].scrollHeight- + docContent.height()-docContent.scrollTop())); + animationInProgress=true; + docContent.animate({ + scrollTop: pos + docContent.scrollTop() - docContent.offset().top + },Math.max(50,Math.min(500,dist)),function(){ + if (updateLocation) window.location.href=aname; + animationInProgress=false; + }); + } +} + +function newNode(o, po, text, link, childrenData, lastNode) +{ + var node = new Object(); + node.children = Array(); + node.childrenData = childrenData; + node.depth = po.depth + 1; + node.relpath = po.relpath; + node.isLast = lastNode; + + node.li = document.createElement("li"); + po.getChildrenUL().appendChild(node.li); + node.parentNode = po; + + node.itemDiv = document.createElement("div"); + node.itemDiv.className = "item"; + + node.labelSpan = document.createElement("span"); + node.labelSpan.className = "label"; + + createIndent(o,node.itemDiv,node,0); + node.itemDiv.appendChild(node.labelSpan); + node.li.appendChild(node.itemDiv); + + var a = document.createElement("a"); + node.labelSpan.appendChild(a); + node.label = document.createTextNode(text); + node.expanded = false; + a.appendChild(node.label); + if (link) { + var url; + if (link.substring(0,1)=='^') { + url = link.substring(1); + link = url; + } else { + url = node.relpath+link; + } + a.className = stripPath(link.replace('#',':')); + if (link.indexOf('#')!=-1) { + var aname = '#'+link.split('#')[1]; + var srcPage = stripPath(pathName()); + var targetPage = stripPath(link.split('#')[0]); + a.href = srcPage!=targetPage ? url : "javascript:void(0)"; + a.onclick = function(){ + storeLink(link); + if (!$(a).parent().parent().hasClass('selected')) + { + $('.item').removeClass('selected'); + $('.item').removeAttr('id'); + $(a).parent().parent().addClass('selected'); + $(a).parent().parent().attr('id','selected'); + } + var anchor = $(aname); + gotoAnchor(anchor,aname,true); + }; + } else { + a.href = url; + a.onclick = function() { storeLink(link); } + } + } else { + if (childrenData != null) + { + a.className = "nolink"; + a.href = "javascript:void(0)"; + a.onclick = node.expandToggle.onclick; + } + } + + node.childrenUL = null; + node.getChildrenUL = function() { + if (!node.childrenUL) { + node.childrenUL = document.createElement("ul"); + node.childrenUL.className = "children_ul"; + node.childrenUL.style.display = "none"; + node.li.appendChild(node.childrenUL); + } + return node.childrenUL; + }; + + return node; +} + +function showRoot() +{ + var headerHeight = $("#top").height(); + var footerHeight = $("#nav-path").height(); + var windowHeight = $(window).height() - headerHeight - footerHeight; + (function (){ // retry until we can scroll to the selected item + try { + var navtree=$('#nav-tree'); + navtree.scrollTo('#selected',100,{offset:-windowHeight/2}); + } catch (err) { + setTimeout(arguments.callee, 0); + } + })(); +} + +function expandNode(o, node, imm, showRoot) +{ + if (node.childrenData && !node.expanded) { + if (typeof(node.childrenData)==='string') { + var varName = node.childrenData; + getScript(node.relpath+varName,function(){ + node.childrenData = getData(varName); + expandNode(o, node, imm, showRoot); + }, showRoot); + } else { + if (!node.childrenVisited) { + getNode(o, node); + } + $(node.getChildrenUL()).slideDown("fast"); + node.plus_img.innerHTML = arrowDown; + node.expanded = true; + } + } +} + +function glowEffect(n,duration) +{ + n.addClass('glow').delay(duration).queue(function(next){ + $(this).removeClass('glow');next(); + }); +} + +function highlightAnchor() +{ + var aname = hashUrl(); + var anchor = $(aname); + if (anchor.parent().attr('class')=='memItemLeft'){ + var rows = $('.memberdecls tr[class$="'+hashValue()+'"]'); + glowEffect(rows.children(),300); // member without details + } else if (anchor.parent().attr('class')=='fieldname'){ + glowEffect(anchor.parent().parent(),1000); // enum value + } else if (anchor.parent().attr('class')=='fieldtype'){ + glowEffect(anchor.parent().parent(),1000); // struct field + } else if (anchor.parent().is(":header")) { + glowEffect(anchor.parent(),1000); // section header + } else { + glowEffect(anchor.next(),1000); // normal member + } +} + +function selectAndHighlight(hash,n) +{ + var a; + if (hash) { + var link=stripPath(pathName())+':'+hash.substring(1); + a=$('.item a[class$="'+link+'"]'); + } + if (a && a.length) { + a.parent().parent().addClass('selected'); + a.parent().parent().attr('id','selected'); + highlightAnchor(); + } else if (n) { + $(n.itemDiv).addClass('selected'); + $(n.itemDiv).attr('id','selected'); + } + if ($('#nav-tree-contents .item:first').hasClass('selected')) { + $('#nav-sync').css('top','30px'); + } else { + $('#nav-sync').css('top','5px'); + } + showRoot(); +} + +function showNode(o, node, index, hash) +{ + if (node && node.childrenData) { + if (typeof(node.childrenData)==='string') { + var varName = node.childrenData; + getScript(node.relpath+varName,function(){ + node.childrenData = getData(varName); + showNode(o,node,index,hash); + },true); + } else { + if (!node.childrenVisited) { + getNode(o, node); + } + $(node.getChildrenUL()).css({'display':'block'}); + node.plus_img.innerHTML = arrowDown; + node.expanded = true; + var n = node.children[o.breadcrumbs[index]]; + if (index+11) hash = '#'+parts[1].replace(/[^\w\-]/g,''); + else hash=''; + } + if (hash.match(/^#l\d+$/)) { + var anchor=$('a[name='+hash.substring(1)+']'); + glowEffect(anchor.parent(),1000); // line number + hash=''; // strip line number anchors + } + var url=root+hash; + var i=-1; + while (NAVTREEINDEX[i+1]<=url) i++; + if (i==-1) { i=0; root=NAVTREE[0][1]; } // fallback: show index + if (navTreeSubIndices[i]) { + gotoNode(o,i,root,hash,relpath) + } else { + getScript(relpath+'navtreeindex'+i,function(){ + navTreeSubIndices[i] = eval('NAVTREEINDEX'+i); + if (navTreeSubIndices[i]) { + gotoNode(o,i,root,hash,relpath); + } + },true); + } +} + +function showSyncOff(n,relpath) +{ + n.html(''); +} + +function showSyncOn(n,relpath) +{ + n.html(''); +} + +function toggleSyncButton(relpath) +{ + var navSync = $('#nav-sync'); + if (navSync.hasClass('sync')) { + navSync.removeClass('sync'); + showSyncOff(navSync,relpath); + storeLink(stripPath2(pathName())+hashUrl()); + } else { + navSync.addClass('sync'); + showSyncOn(navSync,relpath); + deleteLink(); + } +} + +var loadTriggered = false; +var readyTriggered = false; +var loadObject,loadToRoot,loadUrl,loadRelPath; + +$(window).on('load',function(){ + if (readyTriggered) { // ready first + navTo(loadObject,loadToRoot,loadUrl,loadRelPath); + showRoot(); + } + loadTriggered=true; +}); + +function initNavTree(toroot,relpath) +{ + var o = new Object(); + o.toroot = toroot; + o.node = new Object(); + o.node.li = document.getElementById("nav-tree-contents"); + o.node.childrenData = NAVTREE; + o.node.children = new Array(); + o.node.childrenUL = document.createElement("ul"); + o.node.getChildrenUL = function() { return o.node.childrenUL; }; + o.node.li.appendChild(o.node.childrenUL); + o.node.depth = 0; + o.node.relpath = relpath; + o.node.expanded = false; + o.node.isLast = true; + o.node.plus_img = document.createElement("span"); + o.node.plus_img.className = 'arrow'; + o.node.plus_img.innerHTML = arrowRight; + + if (localStorageSupported()) { + var navSync = $('#nav-sync'); + if (cachedLink()) { + showSyncOff(navSync,relpath); + navSync.removeClass('sync'); + } else { + showSyncOn(navSync,relpath); + } + navSync.click(function(){ toggleSyncButton(relpath); }); + } + + if (loadTriggered) { // load before ready + navTo(o,toroot,hashUrl(),relpath); + showRoot(); + } else { // ready before load + loadObject = o; + loadToRoot = toroot; + loadUrl = hashUrl(); + loadRelPath = relpath; + readyTriggered=true; + } + + $(window).bind('hashchange', function(){ + if (window.location.hash && window.location.hash.length>1){ + var a; + if ($(location).attr('hash')){ + var clslink=stripPath(pathName())+':'+hashValue(); + a=$('.item a[class$="'+clslink.replace(/1|%O$WD@{VPM$7~Ar*{o?;hlAFyLXmaDC0y znK1_#cQqJWPES%4Uujug^TE?jMft$}Eq^WaR~)%f)vSNs&gek&x%A9X9sM + + + + + + +R_RSIP Documentation: Copyright + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
R_RSIP Documentation +  Release v1.4.0 +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
Copyright
+
+
+
Here is a list of all related documentation pages:
+
+
+ + + + + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/resize.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/resize.js new file mode 100644 index 000000000..a0bb5f45b --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/resize.js @@ -0,0 +1,137 @@ +/* + @licstart The following is the entire license notice for the + JavaScript code in this file. + + Copyright (C) 1997-2017 by Dimitri van Heesch + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + @licend The above is the entire license notice + for the JavaScript code in this file + */ +function initResizable() +{ + var cookie_namespace = 'doxygen'; + var sidenav,navtree,content,header,collapsed,collapsedWidth=0,barWidth=6,desktop_vp=768,titleHeight; + + function readCookie(cookie) + { + var myCookie = cookie_namespace+"_"+cookie+"="; + if (document.cookie) { + var index = document.cookie.indexOf(myCookie); + if (index != -1) { + var valStart = index + myCookie.length; + var valEnd = document.cookie.indexOf(";", valStart); + if (valEnd == -1) { + valEnd = document.cookie.length; + } + var val = document.cookie.substring(valStart, valEnd); + return val; + } + } + return 0; + } + + function writeCookie(cookie, val, expiration) + { + if (val==undefined) return; + if (expiration == null) { + var date = new Date(); + date.setTime(date.getTime()+(10*365*24*60*60*1000)); // default expiration is one week + expiration = date.toGMTString(); + } + document.cookie = cookie_namespace + "_" + cookie + "=" + val + "; expires=" + expiration+"; path=/"; + } + + function resizeWidth() + { + var windowWidth = $(window).width() + "px"; + var sidenavWidth = $(sidenav).outerWidth(); + content.css({marginLeft:parseInt(sidenavWidth)+"px"}); + writeCookie('width',sidenavWidth-barWidth, null); + } + + function restoreWidth(navWidth) + { + var windowWidth = $(window).width() + "px"; + content.css({marginLeft:parseInt(navWidth)+barWidth+"px"}); + sidenav.css({width:navWidth + "px"}); + } + + function resizeHeight() + { + var headerHeight = header.outerHeight(); + var footerHeight = footer.outerHeight(); + var windowHeight = $(window).height() - headerHeight - footerHeight; + content.css({height:windowHeight + "px"}); + navtree.css({height:windowHeight + "px"}); + sidenav.css({height:windowHeight + "px"}); + var width=$(window).width(); + if (width!=collapsedWidth) { + if (width=desktop_vp) { + if (!collapsed) { + collapseExpand(); + } + } else if (width>desktop_vp && collapsedWidth0) { + restoreWidth(0); + collapsed=true; + } + else { + var width = readCookie('width'); + if (width>200 && width<$(window).width()) { restoreWidth(width); } else { restoreWidth(200); } + collapsed=false; + } + } + + header = $("#top"); + sidenav = $("#side-nav"); + content = $("#doc-content"); + navtree = $("#nav-tree"); + footer = $("#nav-path"); + $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } }); + $(sidenav).resizable({ minWidth: 0 }); + $(window).resize(function() { resizeHeight(); }); + var device = navigator.userAgent.toLowerCase(); + var touch_device = device.match(/(iphone|ipod|ipad|android)/); + if (touch_device) { /* wider split bar for touch only devices */ + $(sidenav).css({ paddingRight:'20px' }); + $('.ui-resizable-e').css({ width:'20px' }); + $('#nav-sync').css({ right:'34px' }); + barWidth=20; + } + var width = readCookie('width'); + if (width) { restoreWidth(width); } else { resizeWidth(); } + resizeHeight(); + var url = location.href; + var i=url.indexOf("#"); + if (i>=0) window.location.hash=url.substr(i); + var _preventDefault = function(evt) { evt.preventDefault(); }; + $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault); + $(".ui-resizable-handle").dblclick(collapseExpand); + $(window).on('load',resizeHeight); +} +/* @license-end */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_0.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_0.html new file mode 100644 index 000000000..26dd244fd --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_0.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_0.js new file mode 100644 index 000000000..56d02eb6f --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['copyright_0',['Copyright',['../_c_o_p_y_r_i_g_h_t.html',1,'']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_1.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_1.html new file mode 100644 index 000000000..8eb215b90 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_1.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_1.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_1.js new file mode 100644 index 000000000..b76ad6371 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_1.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['deprecated_20list_1',['Deprecated List',['../deprecated.html',1,'']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_2.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_2.html new file mode 100644 index 000000000..b26d91650 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_2.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_2.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_2.js new file mode 100644 index 000000000..c32559a5b --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_2.js @@ -0,0 +1,12 @@ +var searchData= +[ + ['e_5fpassword_5ftype_2',['e_password_type',['../group___r_s_i_p___a_p_i.html#gaf9124e401923d473d86b93cd7cc2031d',1,'r_rsip_api.h']]], + ['e_5frsip_5faes_5fmode_3',['e_rsip_aes_mode',['../group___r_s_i_p___a_p_i.html#gafd516c15c2cadaf0b76880f4a2b38526',1,'r_rsip_api.h']]], + ['e_5frsip_5fbyte_5fsize_5fencrypted_5fkey_4',['e_rsip_byte_size_encrypted_key',['../group___r_s_i_p___a_p_i.html#ga09d58045e1e5fc1fc22a72bfda6a2c6b',1,'r_rsip_api.h']]], + ['e_5frsip_5fbyte_5fsize_5fwrapped_5fkey_5',['e_rsip_byte_size_wrapped_key',['../group___r_s_i_p___a_p_i.html#gaf34956ea3649626a41606ee05aef9069',1,'r_rsip_api.h']]], + ['e_5frsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_6',['e_rsip_byte_size_wrapped_key_value',['../group___r_s_i_p___a_p_i.html#ga986cec1971f79c094bd27ac6d11b25e2',1,'r_rsip_api.h']]], + ['e_5frsip_5fhash_5ftype_7',['e_rsip_hash_type',['../group___r_s_i_p___a_p_i.html#ga23ab60f96b3821a218f957ada1bc0d50',1,'r_rsip_api.h']]], + ['e_5frsip_5fkey_5fpair_5ftype_8',['e_rsip_key_pair_type',['../group___r_s_i_p___a_p_i.html#ga78fe2581fc642a646738f81b181c2c8f',1,'r_rsip_api.h']]], + ['e_5frsip_5fkey_5ftype_9',['e_rsip_key_type',['../group___r_s_i_p___a_p_i.html#ga1a940940c082b526361300f166136be0',1,'r_rsip_api.h']]], + ['e_5frsip_5fmgf_5ftype_10',['e_rsip_mgf_type',['../group___r_s_i_p___a_p_i.html#gab5bfaadcf28c8276e7dda056d874baa9',1,'r_rsip_api.h']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_3.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_3.html new file mode 100644 index 000000000..b61b96f83 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_3.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_3.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_3.js new file mode 100644 index 000000000..493ba4411 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_3.js @@ -0,0 +1,25 @@ +var searchData= +[ + ['fsp_5ferr_5fcrypto_5frsip_5fauthentication_11',['FSP_ERR_CRYPTO_RSIP_AUTHENTICATION',['../group___r_s_i_p___a_p_i.html#ga74eeb2ef3d74984dbf3ffb7c37bf543e',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fcrypto_5frsip_5ffail_12',['FSP_ERR_CRYPTO_RSIP_FAIL',['../group___r_s_i_p___a_p_i.html#ga1fa0c5f944888c2bb516161b568b3f8b',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fcrypto_5frsip_5ffatal_13',['FSP_ERR_CRYPTO_RSIP_FATAL',['../group___r_s_i_p___a_p_i.html#ga9b36eedb833a5cad351853206c1a3efc',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fcrypto_5frsip_5fkey_5fset_5ffail_14',['FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL',['../group___r_s_i_p___a_p_i.html#gaa95d73100dc245594ecb22512820819c',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fcrypto_5frsip_5fresource_5fconflict_15',['FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT',['../group___r_s_i_p___a_p_i.html#ga8d12b8569feb694fad5e5ab9eb4ac0f1',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fcrypto_5fauth_5ffail_16',['FSP_ERR_SB_CRYPTO_AUTH_FAIL',['../group___r_s_i_p___a_p_i.html#ga48a79bedac05bb9eaf4f7a548a8afb2a',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fcrypto_5ffail_17',['FSP_ERR_SB_CRYPTO_FAIL',['../group___r_s_i_p___a_p_i.html#ga2becc62a266e021dbd40e3d94e5407b7',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fcrypto_5fparam_5ferr_18',['FSP_ERR_SB_CRYPTO_PARAM_ERR',['../group___r_s_i_p___a_p_i.html#gacad0d7d833bedc26c8594ce335700038',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fcrypto_5fresource_5fconflict_19',['FSP_ERR_SB_CRYPTO_RESOURCE_CONFLICT',['../group___r_s_i_p___a_p_i.html#gaa8e64530bfed122a6d72f9740836da9e',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fcrypto_5funsupported_5falgorithm_20',['FSP_ERR_SB_CRYPTO_UNSUPPORTED_ALGORITHM',['../group___r_s_i_p___a_p_i.html#ga41100687f112b08951d71d4f11ca9170',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5finternal_5ffail_21',['FSP_ERR_SB_INTERNAL_FAIL',['../group___r_s_i_p___a_p_i.html#ga5a3ff940a6dd4274adb2bb743f89cb74',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5finvalid_5falignment_22',['FSP_ERR_SB_INVALID_ALIGNMENT',['../group___r_s_i_p___a_p_i.html#ga476579ab816d13afeab1221b1eb5cbe3',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5finvalid_5farg_23',['FSP_ERR_SB_INVALID_ARG',['../group___r_s_i_p___a_p_i.html#ga8b60d187d644c7d7bf94f9acc9a52126',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fmani_5finvalid_5fimage_5flen_24',['FSP_ERR_SB_MANI_INVALID_IMAGE_LEN',['../group___r_s_i_p___a_p_i.html#gaab3995110fedc2ca74301ce673f98fa7',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fmani_5finvalid_5fmagic_25',['FSP_ERR_SB_MANI_INVALID_MAGIC',['../group___r_s_i_p___a_p_i.html#gaea2a2a260e5a04d10eb7a4130707151e',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fmani_5fmismatch_5fsign_5falgorithm_26',['FSP_ERR_SB_MANI_MISMATCH_SIGN_ALGORITHM',['../group___r_s_i_p___a_p_i.html#gaf0745ee55b1f2939309de8e05be194ec',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fmani_5fout_5fof_5frange_5flen_27',['FSP_ERR_SB_MANI_OUT_OF_RANGE_LEN',['../group___r_s_i_p___a_p_i.html#ga332ec419c4f5ba9265cacaddc4874321',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fmani_5ftlv_5ffield_5ferr_28',['FSP_ERR_SB_MANI_TLV_FIELD_ERR',['../group___r_s_i_p___a_p_i.html#gaf5ddd0355b84440506e0866ed7825f8f',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fmani_5ftlv_5finvalid_5flen_29',['FSP_ERR_SB_MANI_TLV_INVALID_LEN',['../group___r_s_i_p___a_p_i.html#ga94870c76aaec736ff9bc880daa556b2d',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fmani_5funsupported_5falgorithm_30',['FSP_ERR_SB_MANI_UNSUPPORTED_ALGORITHM',['../group___r_s_i_p___a_p_i.html#gac7284516f203a639fe572757d0d8764d',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5fmani_5funsupported_5fversion_31',['FSP_ERR_SB_MANI_UNSUPPORTED_VERSION',['../group___r_s_i_p___a_p_i.html#ga46a72cafbd7e6b57d4d63f00ba7c3e6d',1,'r_rsip_api.h']]], + ['fsp_5ferr_5fsb_5funsupported_5ffunction_32',['FSP_ERR_SB_UNSUPPORTED_FUNCTION',['../group___r_s_i_p___a_p_i.html#ga20b71bf29235caea74fc24c087e8b99c',1,'r_rsip_api.h']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_4.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_4.html new file mode 100644 index 000000000..06de1550e --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_4.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_4.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_4.js new file mode 100644 index 000000000..f3b6818b9 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_4.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['interfaces_33',['Interfaces',['../group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.html',1,'']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_5.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_5.html new file mode 100644 index 000000000..2544c4e5b --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_5.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_5.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_5.js new file mode 100644 index 000000000..f42537d2f --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_5.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['modules_34',['Modules',['../group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.html',1,'']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_6.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_6.html new file mode 100644 index 000000000..43f14eab3 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_6.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_6.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_6.js new file mode 100644 index 000000000..eb867b535 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_6.js @@ -0,0 +1,6 @@ +var searchData= +[ + ['p_5fcfg_35',['p_cfg',['../group___r_s_i_p___a_p_i.html#a1db23440fe44a1681f863478050f4c2f',1,'st_rsip_instance']]], + ['p_5fctrl_36',['p_ctrl',['../group___r_s_i_p___a_p_i.html#aabb64a2dddc53a5ffa8a6e618d0bf999',1,'st_rsip_instance']]], + ['p_5fextend_37',['p_extend',['../group___r_s_i_p___a_p_i.html#ad275dec7a146f7c5dd92b67dd289df43',1,'st_rsip_cfg']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_7.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_7.html new file mode 100644 index 000000000..af52f82a4 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_7.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_7.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_7.js new file mode 100644 index 000000000..8b9e9c7ad --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_7.js @@ -0,0 +1,209 @@ +var searchData= +[ + ['renesas_20secure_20ip_38',['Renesas Secure IP',['../index.html',1,'']]], + ['r_5frsip_5faes_5fcipher_5fdecryptfinal_39',['R_RSIP_AES_Cipher_DecryptFinal',['../group___r_s_i_p.html#ga51698d930e957b5582afb6d439988280',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcipher_5fdecryptinit_40',['R_RSIP_AES_Cipher_DecryptInit',['../group___r_s_i_p.html#ga2bf24039437c98ec88756fa061e034de',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcipher_5fdecryptupdate_41',['R_RSIP_AES_Cipher_DecryptUpdate',['../group___r_s_i_p.html#gafafae41b7a4bc678044880c7b713ef40',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcipher_5fencryptfinal_42',['R_RSIP_AES_Cipher_EncryptFinal',['../group___r_s_i_p.html#ga93448d8822300805e51e82e4d740d343',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcipher_5fencryptinit_43',['R_RSIP_AES_Cipher_EncryptInit',['../group___r_s_i_p.html#gaf7ef1afdfa6e0485ac25b096b7bcf9ce',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcipher_5fencryptupdate_44',['R_RSIP_AES_Cipher_EncryptUpdate',['../group___r_s_i_p.html#gab4d578ccdc90b571f7ba0a63e009a527',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcmac_5fgeneratefinal_45',['R_RSIP_AES_CMAC_GenerateFinal',['../group___r_s_i_p.html#ga73e956dc3b778d329a51548ec2d8da44',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcmac_5fgenerateinit_46',['R_RSIP_AES_CMAC_GenerateInit',['../group___r_s_i_p.html#ga9f4b6ce398b0b9ccff8826c34512ad33',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcmac_5fgenerateupdate_47',['R_RSIP_AES_CMAC_GenerateUpdate',['../group___r_s_i_p.html#ga40add84d634c86a265a1d5861d8695a1',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcmac_5fverifyfinal_48',['R_RSIP_AES_CMAC_VerifyFinal',['../group___r_s_i_p.html#ga9daea7a9e8c9c595b5d3ba3b6302e339',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcmac_5fverifyinit_49',['R_RSIP_AES_CMAC_VerifyInit',['../group___r_s_i_p.html#ga0da0a1ff141aeb28f48d28aa173bcc96',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcmac_5fverifyupdate_50',['R_RSIP_AES_CMAC_VerifyUpdate',['../group___r_s_i_p.html#ga996cf26b4bd4b2b8bf68ebaaca8ac986',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fgcm_5fdecryptfinal_51',['R_RSIP_AES_GCM_DecryptFinal',['../group___r_s_i_p.html#ga97c42f1430d18f9c1e7e9b1fd0e69de1',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fgcm_5fdecryptinit_52',['R_RSIP_AES_GCM_DecryptInit',['../group___r_s_i_p.html#ga883c34556cb6dd27d9dbd8f32fa0022b',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fgcm_5fdecryptupdate_53',['R_RSIP_AES_GCM_DecryptUpdate',['../group___r_s_i_p.html#ga05583899c77d206a9ef09e9d8dd29b78',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fgcm_5fencryptfinal_54',['R_RSIP_AES_GCM_EncryptFinal',['../group___r_s_i_p.html#ga82e9872bf11e0a0bcf4c3e36f327ebbb',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fgcm_5fencryptinit_55',['R_RSIP_AES_GCM_EncryptInit',['../group___r_s_i_p.html#ga05bb680ea48c54adb50804631a0324a9',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fgcm_5fencryptupdate_56',['R_RSIP_AES_GCM_EncryptUpdate',['../group___r_s_i_p.html#gab43537eaf3eae896e79ecbd34b4c21c6',1,'r_rsip_aes.c']]], + ['r_5frsip_5fclose_57',['R_RSIP_Close',['../group___r_s_i_p.html#gac7848f48d9f8484cb17e156e299046fe',1,'r_rsip.c']]], + ['r_5frsip_5feccpublickeyexport_58',['R_RSIP_ECCPublicKeyExport',['../group___r_s_i_p.html#ga0cfe8c89cee5df215b42d72f56f05fd7',1,'r_rsip.c']]], + ['r_5frsip_5fecdsa_5fsign_59',['R_RSIP_ECDSA_Sign',['../group___r_s_i_p.html#ga51b427c5ed2f8d2980d6c29a68951f3c',1,'r_rsip_ecc.c']]], + ['r_5frsip_5fecdsa_5fverify_60',['R_RSIP_ECDSA_Verify',['../group___r_s_i_p.html#ga4001cf997810be799f9873f7f19f515c',1,'r_rsip_ecc.c']]], + ['r_5frsip_5fhmac_5fcompute_61',['R_RSIP_HMAC_Compute',['../group___r_s_i_p.html#gafd208f1c55bdd1e5c6f6ef8e09f61e3f',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fgeneratefinal_62',['R_RSIP_HMAC_GenerateFinal',['../group___r_s_i_p.html#ga9b4cf45516cbd962c3ddc011a4d6c41b',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fgenerateinit_63',['R_RSIP_HMAC_GenerateInit',['../group___r_s_i_p.html#ga35ce74c94050adbacbf6a05c2135000f',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fgenerateupdate_64',['R_RSIP_HMAC_GenerateUpdate',['../group___r_s_i_p.html#gaa41e41608057985c7a60036b49dd7425',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fverify_65',['R_RSIP_HMAC_Verify',['../group___r_s_i_p.html#ga601bce8a7997bfad866e278d1b0133c4',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fverifyfinal_66',['R_RSIP_HMAC_VerifyFinal',['../group___r_s_i_p.html#ga8bb6027da5a6113528b82492511e6259',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fverifyinit_67',['R_RSIP_HMAC_VerifyInit',['../group___r_s_i_p.html#ga8f8758d50640071cf33c906ac56699c7',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fverifyupdate_68',['R_RSIP_HMAC_VerifyUpdate',['../group___r_s_i_p.html#gad6de1c75e4f7cf9ca361b5fbc1c875d2',1,'r_rsip_sha.c']]], + ['r_5frsip_5fkeygenerate_69',['R_RSIP_KeyGenerate',['../group___r_s_i_p.html#ga2dc3a8de5422978d001750fa120df176',1,'r_rsip.c']]], + ['r_5frsip_5fkeyimportwithkuk_70',['R_RSIP_KeyImportWithKUK',['../group___r_s_i_p.html#ga183fb4be47cd4156e16887087d9aa7e7',1,'r_rsip.c']]], + ['r_5frsip_5fkeyimportwithufpk_71',['R_RSIP_KeyImportWithUFPK',['../group___r_s_i_p.html#ga0e45064b017808306219d8178ccb4966',1,'r_rsip_rzg3.c']]], + ['r_5frsip_5fkeypairgenerate_72',['R_RSIP_KeyPairGenerate',['../group___r_s_i_p.html#gacbc429a31f21d4a409d40ef7c8704c96',1,'r_rsip.c']]], + ['r_5frsip_5fopen_73',['R_RSIP_Open',['../group___r_s_i_p.html#ga0f3222e34aedf16a9eeba214db0aeeac',1,'r_rsip.c']]], + ['r_5frsip_5frandomnumbergenerate_74',['R_RSIP_RandomNumberGenerate',['../group___r_s_i_p.html#ga004e5a8c7361e446809f4cba8fb4a493',1,'r_rsip.c']]], + ['r_5frsip_5frsa_5fdecrypt_75',['R_RSIP_RSA_Decrypt',['../group___r_s_i_p.html#gaf2afe4d205b51f1c434ac0e4dd24a137',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsa_5fencrypt_76',['R_RSIP_RSA_Encrypt',['../group___r_s_i_p.html#ga5ab165c8834057601821bb486e8e9855',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsaes_5foaep_5fdecrypt_77',['R_RSIP_RSAES_OAEP_Decrypt',['../group___r_s_i_p.html#ga212e1d21390f8ea72bd91c844375399f',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsaes_5foaep_5fencrypt_78',['R_RSIP_RSAES_OAEP_Encrypt',['../group___r_s_i_p.html#ga1e2bb479037a936aac115f73fcc6788f',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsaes_5fpkcs1_5fv1_5f5_5fdecrypt_79',['R_RSIP_RSAES_PKCS1_V1_5_Decrypt',['../group___r_s_i_p.html#ga83eb46af309c6539abdedc3333859179',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsaes_5fpkcs1_5fv1_5f5_5fencrypt_80',['R_RSIP_RSAES_PKCS1_V1_5_Encrypt',['../group___r_s_i_p.html#gaee51f26eb1994439e790cc736ab17eab',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsapublickeyexport_81',['R_RSIP_RSAPublicKeyExport',['../group___r_s_i_p.html#ga2406d2768cd35af5129101eafb6e0f95',1,'r_rsip.c']]], + ['r_5frsip_5frsassa_5fpkcs1_5fv1_5f5_5fsign_82',['R_RSIP_RSASSA_PKCS1_V1_5_Sign',['../group___r_s_i_p.html#ga2645bf20337f5746c0e16aa809f33cf4',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsassa_5fpkcs1_5fv1_5f5_5fverify_83',['R_RSIP_RSASSA_PKCS1_V1_5_Verify',['../group___r_s_i_p.html#ga5312c9f027c45ecb2779c99e6c7e72ff',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsassa_5fpss_5fsign_84',['R_RSIP_RSASSA_PSS_Sign',['../group___r_s_i_p.html#ga99f7fd3650b5167e0969e2cb681b763a',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsassa_5fpss_5fverify_85',['R_RSIP_RSASSA_PSS_Verify',['../group___r_s_i_p.html#gac79f1b11849d19e8dfa7f90276e68e77',1,'r_rsip_rsa.c']]], + ['r_5frsip_5fsha_5fcompute_86',['R_RSIP_SHA_Compute',['../group___r_s_i_p.html#ga8517124a32ed6bea90f2d0c82885eed7',1,'r_rsip_sha.c']]], + ['r_5frsip_5fsha_5fgeneratefinal_87',['R_RSIP_SHA_GenerateFinal',['../group___r_s_i_p.html#ga197111ff5c0da56f545ed60a3ce5271a',1,'r_rsip_sha.c']]], + ['r_5frsip_5fsha_5fgenerateinit_88',['R_RSIP_SHA_GenerateInit',['../group___r_s_i_p.html#gade4e2469c7b564412b1ff93695e009d1',1,'r_rsip_sha.c']]], + ['r_5frsip_5fsha_5fgenerateupdate_89',['R_RSIP_SHA_GenerateUpdate',['../group___r_s_i_p.html#gac4e40a3e418dd33ad6d3a062b7820908',1,'r_rsip_sha.c']]], + ['renesas_20secure_20ip_20_28r_5frsip_29_90',['Renesas Secure IP (r_rsip)',['../group___r_s_i_p.html',1,'']]], + ['rsip_5faes_5fmode_5fcbc_91',['RSIP_AES_MODE_CBC',['../group___r_s_i_p___a_p_i.html#ggafd516c15c2cadaf0b76880f4a2b38526a916e358b41f31dcda1aa88c107affdeb',1,'r_rsip_api.h']]], + ['rsip_5faes_5fmode_5fctr_92',['RSIP_AES_MODE_CTR',['../group___r_s_i_p___a_p_i.html#ggafd516c15c2cadaf0b76880f4a2b38526a05435bd090fafeb359f819d552969260',1,'r_rsip_api.h']]], + ['rsip_5faes_5fmode_5fecb_93',['RSIP_AES_MODE_ECB',['../group___r_s_i_p___a_p_i.html#ggafd516c15c2cadaf0b76880f4a2b38526ae7b8be04a55e7bb46a3236ef36790d5c',1,'r_rsip_api.h']]], + ['rsip_5faes_5fmode_5fxts_94',['RSIP_AES_MODE_XTS',['../group___r_s_i_p___a_p_i.html#ggafd516c15c2cadaf0b76880f4a2b38526a5d6bfcb55d82dcf78aed589f68a9687c',1,'r_rsip_api.h']]], + ['rsip_20interface_95',['RSIP Interface',['../group___r_s_i_p___a_p_i.html',1,'']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5faes_5f128_96',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6babca41e320abed86dc89a15fe82d0055e',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5faes_5f128_5fxts_97',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128_XTS',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba6cc5328433cea8a424cc3dc153c18887',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5faes_5f256_98',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bae7edcd56e413058751e63a91c08db443',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5faes_5f256_5fxts_99',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256_XTS',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba29fe5766d277319857f25095abc87650',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5faes_5fmax_100',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba095d1a2fc81e012f68355152dcdc05bc',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fbrainpoolp256r1_5fprivate_101',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baea48bab25d9ce695fd179e7101cf76fd',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fbrainpoolp256r1_5fpublic_102',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba93bef067d3dc0ecd5cd701a04df76935',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fprivate_5fmax_103',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PRIVATE_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba139a8760ad2c9c6f9e26361f46d8dbda',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fpublic_5fmax_104',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PUBLIC_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba785c029de5ee4c328f491772fde45128',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fsecp192r1_5fprivate_105',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baec91c7db4c76e36feb4641cb6217142d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fsecp192r1_5fpublic_106',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba65099b600ac34c55b2f727e8a6727159',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fsecp224r1_5fprivate_107',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bafada6405390b950a13be917836467ed2',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fsecp224r1_5fpublic_108',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bae05b8f63cc316051503418a2144356f5',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fsecp256r1_5fprivate_109',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba4c1a8f534b7fd8a75d1becdaf5f4db8d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fsecp256r1_5fpublic_110',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bab970177f7019e054287cec3f3c1cdd38',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fhmac_5fmax_111',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba650d187c31f0d63691a8b0ea0838d278',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fhmac_5fsha1_112',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA1',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba90f1df4ea497c51be41b37771cdc5cf7',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fhmac_5fsha224_113',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA224',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baf2236851c1d11684fd7334497d4293c2',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fhmac_5fsha256_114',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA256',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba4cbdce8dc08586f932817e00b6dc123d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fkey_5fupdate_5fkey_115',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_KEY_UPDATE_KEY',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba1c37e9d8a67a2c87bcacfb2ba4b0cf16',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fmax_116',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bad8fc5807e4d283d58b28ed59307448cd',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f1024_5fprivate_5fenhanced_117',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba00c4a0213dc8078874ee1e31f293d0ba',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f1024_5fpublic_5fenhanced_118',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba21caa8ebee33a364073e05854b25f14d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f2048_5fprivate_5fenhanced_119',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bad1b3ebd64335aab215d9fd3ca52ee692',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f2048_5fpublic_5fenhanced_120',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bac8535eb6260a31f3c69a4ebee2e74508',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f3072_5fprivate_121',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba22eeba8227d1f675e1718088edc0b745',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f3072_5fpublic_122',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba0d56717253c1e0323374d67f3595a699',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f4096_5fprivate_123',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba03b43a47c22829c840bf465f43599f75',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f4096_5fpublic_124',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baefdb0d9c6db8e9264064576cd2336430',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5fprivate_5fmax_125',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PRIVATE_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baec66e52e0b5dc552f9835b3d1f9119bf',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5fpublic_5fmax_126',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PUBLIC_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba1bf207c0299f4b36fdc92dd4ecf826b6',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5faes_5f128_127',['RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a5c087988d5082ae00e9703d1980a1f7f',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5faes_5f128_5fxts_128',['RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128_XTS',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a9f5b9468fbbbe7084a8cd90a9fb3f40a',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5faes_5f256_129',['RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069acc7cfcba1a5e5944e566276062d4ff54',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5faes_5f256_5fxts_130',['RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256_XTS',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a1de8f70b943e282223c4b93742ffab37',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5faes_5fmax_131',['RSIP_BYTE_SIZE_WRAPPED_KEY_AES_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a9f4ea297e8da363157e7f66aa4ecc898',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fbrainpoolp256r1_5fprivate_132',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PRIVATE',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ac9ba8fb69cc3317264e05cde0249f06f',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fbrainpoolp256r1_5fpublic_133',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PUBLIC',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a18ef67c162ed62273cc9326622ad2164',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fprivate_5fmax_134',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PRIVATE_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a6ea981937f2151a755290e938ba7c47e',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fpublic_5fmax_135',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PUBLIC_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ae3887b040ebbf43f629ec20b504a3779',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fsecp192r1_5fprivate_136',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ab609f58697d8b22222d558c97b9da0be',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fsecp192r1_5fpublic_137',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069afee6765f321bf704ed1c105497416e58',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fsecp224r1_5fprivate_138',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ae6466928a02a9ea5bfb3a67dbab5f4e0',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fsecp224r1_5fpublic_139',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069af4ad017c6816e60391e7cd48ec516f54',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fsecp256r1_5fprivate_140',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a616dcde10261898e926bc7a550bdee87',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fsecp256r1_5fpublic_141',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a71818cabae02e61719e9c5d34a28a3bd',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fhmac_5fmax_142',['RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a0d65c6ddc749536e69332f4b5229cb40',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fhmac_5fsha1_143',['RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA1',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069aa0061976fb107bc4a118ff6d79ca8c29',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fhmac_5fsha224_144',['RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA224',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a1fae3fdbe5e142cee2b83fd2ee78c3fc',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fhmac_5fsha256_145',['RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA256',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ad302f44eb6bb360373f2c52ce0172993',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fkey_5fupdate_5fkey_146',['RSIP_BYTE_SIZE_WRAPPED_KEY_KEY_UPDATE_KEY',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a0787873287816db723cf3da18b95e009',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fmax_147',['RSIP_BYTE_SIZE_WRAPPED_KEY_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069aeb938665677db84ae6d1da16282b8b1d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f1024_5fprivate_5fenhanced_148',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a526a9fd8d458122f6edb59b06013fc41',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f1024_5fpublic_5fenhanced_149',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a28873d6222775f36065be210540e7f50',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f2048_5fprivate_5fenhanced_150',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a2f9ca50dd2f7e7ff78cb703666727c49',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f2048_5fpublic_5fenhanced_151',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a9001350f603fd8057ca0d8ad00f9961a',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f3072_5fprivate_152',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069aaf8df7e54cd8052e03114852da2ffa31',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f3072_5fpublic_153',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069acd089ec2a35f7c4086853b3e515272b7',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f4096_5fprivate_154',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a5e882c6dc51ad72779ad19e9eb684330',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f4096_5fpublic_155',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a386fcc985ae05b83322cb3944c1fb744',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5fprivate_5fmax_156',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PRIVATE_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069abda559faa8a845f5f8e06d510c082629',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5fpublic_5fmax_157',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PUBLIC_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a46c61543461d737b9be7f26db6b35c11',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5faes_5f128_158',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a586634b4d139e6f57746a237f5f1a0be',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5faes_5f128_5fxts_159',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128_XTS',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ac790e39e8b68c6a8f7cc833fb8ca98e4',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5faes_5f256_160',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a1b018a8fa7fd42508b831c634663b3be',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5faes_5f256_5fxts_161',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256_XTS',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2afdc13695f7f0bf48d17bde9150c2d5d5',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5faes_5fmax_162',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a8056769b72932b90227774389cf2667d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fbrainpoolp256r1_5fprivate_163',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a3e6d2558c274d02fc5f66b294411b903',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fbrainpoolp256r1_5fpublic_164',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a04727ef451762e283a8ca6f7ac6b7861',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fprivate_5fmax_165',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PRIVATE_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a7e058acecc7cfd50519c938fea9a4b2f',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fpublic_5fmax_166',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PUBLIC_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2abf32844af8087563228207b0e92206f8',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fsecp192r1_5fprivate_167',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ae9b143cdcb9bde593114b0bacbd84255',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fsecp192r1_5fpublic_168',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a7dddcca7061f44fa3db34915016dbb98',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fsecp224r1_5fprivate_169',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a446639af284989b0a0c8dd1e4cc4d167',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fsecp224r1_5fpublic_170',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a5a35d4d2d09198c47115f3ea34897ce2',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fsecp256r1_5fprivate_171',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2af1d315efc0f02f8ffcf537242f6a5c1d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fsecp256r1_5fpublic_172',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a7e0d45e2f8b5ad6f7c424860e89ff05b',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fhmac_5fmax_173',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ae91a70d223ec963db0512cd5721b50f4',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fhmac_5fsha1_174',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA1',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2adbc909a34e27086968337b14b73d41d1',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fhmac_5fsha224_175',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA224',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a2d1fe8897eea6fe2e8da371145b59aed',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fhmac_5fsha256_176',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA256',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a622942fa17ea395c2ffc2d10a9953d59',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fkey_5fupdate_5fkey_177',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_KEY_UPDATE_KEY',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ad938901804f0d8d6cf7242197d103203',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fmax_178',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ad0f5744f10c898d7cd0475cc31ef67fe',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f1024_5fprivate_5fenhanced_179',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a2c203c4e464d9f32009a494c9d60fbf8',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f1024_5fpublic_5fenhanced_180',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2acc82841e4a464ce393f46358a34fd896',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f2048_5fprivate_5fenhanced_181',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a6eb5d8cea1d9c29cf615b4d8ff4de9fe',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f2048_5fpublic_5fenhanced_182',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a8be4585da748345938a9b50afd4882bc',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f3072_5fprivate_183',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a78ae62e9bdcbad0863feef54bca6d610',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f3072_5fpublic_184',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a23ce153c49268a13a953340c1a1cdaee',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f4096_5fprivate_185',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2aedb0ff7185a258792305c85e7c6b1408',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f4096_5fpublic_186',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a272193dbc8150aa367b016b7f19b448b',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5fprivate_5fmax_187',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PRIVATE_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2af60d086613f2afccd018ffccc9384ddb',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5fpublic_5fmax_188',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PUBLIC_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a3f0dffcc6d2d8e865ee04a0d4a0f0eb0',1,'r_rsip_api.h']]], + ['rsip_5fctrl_5ft_189',['rsip_ctrl_t',['../group___r_s_i_p___a_p_i.html#ga2042507aed5dec71014a96b91aeaa4fa',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha1_190',['RSIP_HASH_TYPE_SHA1',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50a1e606044965bcf60e62d360773020b45',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha224_191',['RSIP_HASH_TYPE_SHA224',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50af64c98e1df3a92f08a6e68b20216b2d2',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha256_192',['RSIP_HASH_TYPE_SHA256',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50aa9b386d1b29869e511efd8d28f95cf06',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha384_193',['RSIP_HASH_TYPE_SHA384',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50a5d99501259f33a56446b2e924bce8dff',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha512_194',['RSIP_HASH_TYPE_SHA512',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50aa3336966c98485838aef21db86b4c9c4',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha512_5f224_195',['RSIP_HASH_TYPE_SHA512_224',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50a42459c435a6732056efc9b0026efb69e',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha512_5f256_196',['RSIP_HASH_TYPE_SHA512_256',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50a42c1bdd5072314a38acd3f128577c1b5',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5fecc_5fbrainpoolp256r1_197',['RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8faf618da4a0cf7b6870423dd88c144c04e',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5fecc_5fsecp192r1_198',['RSIP_KEY_PAIR_TYPE_ECC_secp192r1',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa1db73377f01af77ecf1840a9c91d7cd6',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5fecc_5fsecp224r1_199',['RSIP_KEY_PAIR_TYPE_ECC_secp224r1',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa696986229d46e351abc68e49a193583f',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5fecc_5fsecp256r1_200',['RSIP_KEY_PAIR_TYPE_ECC_secp256r1',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa848eec7eab373097f2707df369276697',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5finvalid_201',['RSIP_KEY_PAIR_TYPE_INVALID',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fac5500d97824a55149bc601d071204952',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5frsa_5f1024_202',['RSIP_KEY_PAIR_TYPE_RSA_1024',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa72612c53f93986bcb9cb92831ce1afd6',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5frsa_5f2048_203',['RSIP_KEY_PAIR_TYPE_RSA_2048',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8faa0cd2ab30ec0148ad600f992ce927aa3',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5frsa_5f3072_204',['RSIP_KEY_PAIR_TYPE_RSA_3072',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa4dcc7fec49147dce7515509226eedf6a',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5frsa_5f4096_205',['RSIP_KEY_PAIR_TYPE_RSA_4096',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa579b04ccf5fa9a785775229ea6860273',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5faes_5f128_206',['RSIP_KEY_TYPE_AES_128',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a86a9d2eba8d8e913beb35a9ef77719ea',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5faes_5f128_5fxts_207',['RSIP_KEY_TYPE_AES_128_XTS',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a5f636e29ceafce90ea5b4cbe8df24211',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5faes_5f256_208',['RSIP_KEY_TYPE_AES_256',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ac73d8d9299a235cdd03315cc8d4cf10c',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5faes_5f256_5fxts_209',['RSIP_KEY_TYPE_AES_256_XTS',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0af5ee03fb23a509757252d4d07aedc17b',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fbrainpoolp256r1_5fprivate_210',['RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa1283a39ddf31e2151a858b9adbe33ba',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fbrainpoolp256r1_5fpublic_211',['RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a0dab958d7e42944db5ae9d3cc6dbb171',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fsecp192r1_5fprivate_212',['RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa3eee3aadcfb68ffc5f545f2342a6ed9',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fsecp192r1_5fpublic_213',['RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ad8ddf883a2b65ea563f8b79c03143f92',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fsecp224r1_5fprivate_214',['RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a2b82d7ba783f63eeaf81504b1663e994',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fsecp224r1_5fpublic_215',['RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa9dac8ec3d4329e2bf539b541398f847',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fsecp256r1_5fprivate_216',['RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a8c86ca396f98786e5f4775afb699c799',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fsecp256r1_5fpublic_217',['RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ad3c283cb6ecf75b790df5f500674f94e',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fhmac_5fsha1_218',['RSIP_KEY_TYPE_HMAC_SHA1',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a34ac6f0f7727f34302ebe5f433e8679a',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fhmac_5fsha224_219',['RSIP_KEY_TYPE_HMAC_SHA224',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa0ea2d8e02d46a57d4529a6a823af475',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fhmac_5fsha256_220',['RSIP_KEY_TYPE_HMAC_SHA256',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ad06544b015f3cb6936a8edb30fd76795',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5finvalid_221',['RSIP_KEY_TYPE_INVALID',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ae95be99956cace7717544ddea792d0e9',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fkey_5fupdate_5fkey_222',['RSIP_KEY_TYPE_KEY_UPDATE_KEY',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a41528f99f9213d6427f80f920bf41a0c',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f1024_5fprivate_5fenhanced_223',['RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa2a474f523f6c08e3cb59eff333ca946',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f1024_5fpublic_5fenhanced_224',['RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a05ac77751a82f044778d9cb86c2f44f1',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f2048_5fprivate_5fenhanced_225',['RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a06508f9d0ca5be101fabc0954fbbffd2',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f2048_5fpublic_5fenhanced_226',['RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0abd142cdcce3eb32996644a947f6d8987',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f3072_5fprivate_227',['RSIP_KEY_TYPE_RSA_3072_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a19f0822cd6c1399de2bc15e8a46913fe',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f3072_5fpublic_228',['RSIP_KEY_TYPE_RSA_3072_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a3fb4b7a6660681c87ef8416bc8ef116d',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f4096_5fprivate_229',['RSIP_KEY_TYPE_RSA_4096_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a58dc7de7d13a8f3b4fa46aac0f637181',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f4096_5fpublic_230',['RSIP_KEY_TYPE_RSA_4096_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a52e55e5000f62bf6258d188c2c86983d',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fsecure_5fboot_5fdecryption_231',['RSIP_KEY_TYPE_SECURE_BOOT_DECRYPTION',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a4a929eca26e682e353a462162bee94c9',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha1_232',['RSIP_MGF_TYPE_MGF1_SHA1',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a467853f1da9a4d991cfa8a5dcd0bac8c',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha224_233',['RSIP_MGF_TYPE_MGF1_SHA224',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a3be5880de8b95f51bc3316dab173f26b',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha256_234',['RSIP_MGF_TYPE_MGF1_SHA256',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a706f017dd80223a4b21e3344a81b8188',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha384_235',['RSIP_MGF_TYPE_MGF1_SHA384',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9ab4928d0237db4c9107c99a07d2d45b55',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha512_236',['RSIP_MGF_TYPE_MGF1_SHA512',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a85c5a243de79d7dc9937946c18b53d18',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha512_5f224_237',['RSIP_MGF_TYPE_MGF1_SHA512_224',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a686e5d6dda2e85fbb1a5b6947242be0c',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha512_5f256_238',['RSIP_MGF_TYPE_MGF1_SHA512_256',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a97d5cd9aa8b6fa9ce232aea21b79de8f',1,'r_rsip_api.h']]], + ['rsip_5fpassword_5ftype_5fjtag_5fdebug_5fauthentication_5flevel1_239',['RSIP_PASSWORD_TYPE_JTAG_DEBUG_AUTHENTICATION_LEVEL1',['../group___r_s_i_p___a_p_i.html#ggaf9124e401923d473d86b93cd7cc2031da6541a5167825a8e412d4568b86b3354f',1,'r_rsip_api.h']]], + ['rsip_5fpassword_5ftype_5fjtag_5fdebug_5fauthentication_5flevel2_240',['RSIP_PASSWORD_TYPE_JTAG_DEBUG_AUTHENTICATION_LEVEL2',['../group___r_s_i_p___a_p_i.html#ggaf9124e401923d473d86b93cd7cc2031daa29cf2c09763028ba473a10f4fbb8724',1,'r_rsip_api.h']]], + ['rsip_5frsa_5fsalt_5flength_5fauto_241',['RSIP_RSA_SALT_LENGTH_AUTO',['../group___r_s_i_p___a_p_i.html#ga82b6474de04af6fc9d99c1cac82b9415',1,'r_rsip_api.h']]], + ['rsip_5frsa_5fsalt_5flength_5fhash_242',['RSIP_RSA_SALT_LENGTH_HASH',['../group___r_s_i_p___a_p_i.html#ga2c1db9497cde878229e095d907ca3666',1,'r_rsip_api.h']]], + ['rsip_5frsa_5fsalt_5flength_5fmax_243',['RSIP_RSA_SALT_LENGTH_MAX',['../group___r_s_i_p___a_p_i.html#ga2856e1895eab748a16ac87d328058fea',1,'r_rsip_api.h']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_8.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_8.html new file mode 100644 index 000000000..cf2b5df92 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_8.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_8.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_8.js new file mode 100644 index 000000000..b70e415ad --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_8.js @@ -0,0 +1,9 @@ +var searchData= +[ + ['st_5frsip_5fcfg_244',['st_rsip_cfg',['../group___r_s_i_p___a_p_i.html#structst__rsip__cfg',1,'']]], + ['st_5frsip_5fhmac_5fhandle_245',['st_rsip_hmac_handle',['../group___r_s_i_p___a_p_i.html#structst__rsip__hmac__handle',1,'']]], + ['st_5frsip_5finstance_246',['st_rsip_instance',['../group___r_s_i_p___a_p_i.html#structst__rsip__instance',1,'']]], + ['st_5frsip_5finstance_5fctrl_247',['st_rsip_instance_ctrl',['../group___r_s_i_p.html#structst__rsip__instance__ctrl',1,'']]], + ['st_5frsip_5fsha_5fhandle_248',['st_rsip_sha_handle',['../group___r_s_i_p___a_p_i.html#structst__rsip__sha__handle',1,'']]], + ['st_5frsip_5fwrapped_5fkey_249',['st_rsip_wrapped_key',['../group___r_s_i_p___a_p_i.html#structst__rsip__wrapped__key',1,'']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_9.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_9.html new file mode 100644 index 000000000..690785a5d --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_9.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_9.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_9.js new file mode 100644 index 000000000..d01d9e35b --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_9.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['type_250',['type',['../group___r_s_i_p___a_p_i.html#a8bd2f326e4b02652713870b0f0a7be27',1,'st_rsip_wrapped_key']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_a.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_a.html new file mode 100644 index 000000000..f2f3d3a38 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_a.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_a.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_a.js new file mode 100644 index 000000000..11c9e9f26 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/all_a.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['value_251',['value',['../group___r_s_i_p___a_p_i.html#adea2e89755d0cba606102f718b7b63d6',1,'st_rsip_wrapped_key']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/classes_0.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/classes_0.html new file mode 100644 index 000000000..f7e4c14e1 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/classes_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/classes_0.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/classes_0.js new file mode 100644 index 000000000..0e1395073 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/classes_0.js @@ -0,0 +1,9 @@ +var searchData= +[ + ['st_5frsip_5fcfg_252',['st_rsip_cfg',['../group___r_s_i_p___a_p_i.html#structst__rsip__cfg',1,'']]], + ['st_5frsip_5fhmac_5fhandle_253',['st_rsip_hmac_handle',['../group___r_s_i_p___a_p_i.html#structst__rsip__hmac__handle',1,'']]], + ['st_5frsip_5finstance_254',['st_rsip_instance',['../group___r_s_i_p___a_p_i.html#structst__rsip__instance',1,'']]], + ['st_5frsip_5finstance_5fctrl_255',['st_rsip_instance_ctrl',['../group___r_s_i_p.html#structst__rsip__instance__ctrl',1,'']]], + ['st_5frsip_5fsha_5fhandle_256',['st_rsip_sha_handle',['../group___r_s_i_p___a_p_i.html#structst__rsip__sha__handle',1,'']]], + ['st_5frsip_5fwrapped_5fkey_257',['st_rsip_wrapped_key',['../group___r_s_i_p___a_p_i.html#structst__rsip__wrapped__key',1,'']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/close.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/close.png new file mode 100644 index 0000000000000000000000000000000000000000..9342d3dfeea7b7c4ee610987e717804b5a42ceb9 GIT binary patch literal 273 zcmV+s0q*{ZP)4(RlMby96)VwnbG{ zbe&}^BDn7x>$<{ck4zAK-=nT;=hHG)kmplIF${xqm8db3oX6wT3bvp`TE@m0cg;b) zBuSL}5?N7O(iZLdAlz@)b)Rd~DnSsSX&P5qC`XwuFwcAYLC+d2>+1(8on;wpt8QIC X2MT$R4iQDd00000NkvXXu0mjfia~GN literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enums_0.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enums_0.html new file mode 100644 index 000000000..9669700af --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enums_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enums_0.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enums_0.js new file mode 100644 index 000000000..606ee7c58 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enums_0.js @@ -0,0 +1,12 @@ +var searchData= +[ + ['e_5fpassword_5ftype_315',['e_password_type',['../group___r_s_i_p___a_p_i.html#gaf9124e401923d473d86b93cd7cc2031d',1,'r_rsip_api.h']]], + ['e_5frsip_5faes_5fmode_316',['e_rsip_aes_mode',['../group___r_s_i_p___a_p_i.html#gafd516c15c2cadaf0b76880f4a2b38526',1,'r_rsip_api.h']]], + ['e_5frsip_5fbyte_5fsize_5fencrypted_5fkey_317',['e_rsip_byte_size_encrypted_key',['../group___r_s_i_p___a_p_i.html#ga09d58045e1e5fc1fc22a72bfda6a2c6b',1,'r_rsip_api.h']]], + ['e_5frsip_5fbyte_5fsize_5fwrapped_5fkey_318',['e_rsip_byte_size_wrapped_key',['../group___r_s_i_p___a_p_i.html#gaf34956ea3649626a41606ee05aef9069',1,'r_rsip_api.h']]], + ['e_5frsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_319',['e_rsip_byte_size_wrapped_key_value',['../group___r_s_i_p___a_p_i.html#ga986cec1971f79c094bd27ac6d11b25e2',1,'r_rsip_api.h']]], + ['e_5frsip_5fhash_5ftype_320',['e_rsip_hash_type',['../group___r_s_i_p___a_p_i.html#ga23ab60f96b3821a218f957ada1bc0d50',1,'r_rsip_api.h']]], + ['e_5frsip_5fkey_5fpair_5ftype_321',['e_rsip_key_pair_type',['../group___r_s_i_p___a_p_i.html#ga78fe2581fc642a646738f81b181c2c8f',1,'r_rsip_api.h']]], + ['e_5frsip_5fkey_5ftype_322',['e_rsip_key_type',['../group___r_s_i_p___a_p_i.html#ga1a940940c082b526361300f166136be0',1,'r_rsip_api.h']]], + ['e_5frsip_5fmgf_5ftype_323',['e_rsip_mgf_type',['../group___r_s_i_p___a_p_i.html#gab5bfaadcf28c8276e7dda056d874baa9',1,'r_rsip_api.h']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enumvalues_0.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enumvalues_0.html new file mode 100644 index 000000000..928624899 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enumvalues_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enumvalues_0.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enumvalues_0.js new file mode 100644 index 000000000..1dcd3c561 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/enumvalues_0.js @@ -0,0 +1,151 @@ +var searchData= +[ + ['rsip_5faes_5fmode_5fcbc_324',['RSIP_AES_MODE_CBC',['../group___r_s_i_p___a_p_i.html#ggafd516c15c2cadaf0b76880f4a2b38526a916e358b41f31dcda1aa88c107affdeb',1,'r_rsip_api.h']]], + ['rsip_5faes_5fmode_5fctr_325',['RSIP_AES_MODE_CTR',['../group___r_s_i_p___a_p_i.html#ggafd516c15c2cadaf0b76880f4a2b38526a05435bd090fafeb359f819d552969260',1,'r_rsip_api.h']]], + ['rsip_5faes_5fmode_5fecb_326',['RSIP_AES_MODE_ECB',['../group___r_s_i_p___a_p_i.html#ggafd516c15c2cadaf0b76880f4a2b38526ae7b8be04a55e7bb46a3236ef36790d5c',1,'r_rsip_api.h']]], + ['rsip_5faes_5fmode_5fxts_327',['RSIP_AES_MODE_XTS',['../group___r_s_i_p___a_p_i.html#ggafd516c15c2cadaf0b76880f4a2b38526a5d6bfcb55d82dcf78aed589f68a9687c',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5faes_5f128_328',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6babca41e320abed86dc89a15fe82d0055e',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5faes_5f128_5fxts_329',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128_XTS',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba6cc5328433cea8a424cc3dc153c18887',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5faes_5f256_330',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bae7edcd56e413058751e63a91c08db443',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5faes_5f256_5fxts_331',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256_XTS',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba29fe5766d277319857f25095abc87650',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5faes_5fmax_332',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba095d1a2fc81e012f68355152dcdc05bc',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fbrainpoolp256r1_5fprivate_333',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baea48bab25d9ce695fd179e7101cf76fd',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fbrainpoolp256r1_5fpublic_334',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba93bef067d3dc0ecd5cd701a04df76935',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fprivate_5fmax_335',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PRIVATE_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba139a8760ad2c9c6f9e26361f46d8dbda',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fpublic_5fmax_336',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PUBLIC_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba785c029de5ee4c328f491772fde45128',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fsecp192r1_5fprivate_337',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baec91c7db4c76e36feb4641cb6217142d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fsecp192r1_5fpublic_338',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba65099b600ac34c55b2f727e8a6727159',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fsecp224r1_5fprivate_339',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bafada6405390b950a13be917836467ed2',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fsecp224r1_5fpublic_340',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bae05b8f63cc316051503418a2144356f5',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fsecp256r1_5fprivate_341',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba4c1a8f534b7fd8a75d1becdaf5f4db8d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fecc_5fsecp256r1_5fpublic_342',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bab970177f7019e054287cec3f3c1cdd38',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fhmac_5fmax_343',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba650d187c31f0d63691a8b0ea0838d278',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fhmac_5fsha1_344',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA1',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba90f1df4ea497c51be41b37771cdc5cf7',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fhmac_5fsha224_345',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA224',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baf2236851c1d11684fd7334497d4293c2',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fhmac_5fsha256_346',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA256',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba4cbdce8dc08586f932817e00b6dc123d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fkey_5fupdate_5fkey_347',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_KEY_UPDATE_KEY',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba1c37e9d8a67a2c87bcacfb2ba4b0cf16',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5fmax_348',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bad8fc5807e4d283d58b28ed59307448cd',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f1024_5fprivate_5fenhanced_349',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba00c4a0213dc8078874ee1e31f293d0ba',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f1024_5fpublic_5fenhanced_350',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba21caa8ebee33a364073e05854b25f14d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f2048_5fprivate_5fenhanced_351',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bad1b3ebd64335aab215d9fd3ca52ee692',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f2048_5fpublic_5fenhanced_352',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6bac8535eb6260a31f3c69a4ebee2e74508',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f3072_5fprivate_353',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba22eeba8227d1f675e1718088edc0b745',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f3072_5fpublic_354',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba0d56717253c1e0323374d67f3595a699',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f4096_5fprivate_355',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba03b43a47c22829c840bf465f43599f75',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5f4096_5fpublic_356',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baefdb0d9c6db8e9264064576cd2336430',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5fprivate_5fmax_357',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PRIVATE_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6baec66e52e0b5dc552f9835b3d1f9119bf',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fencrypted_5fkey_5frsa_5fpublic_5fmax_358',['RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PUBLIC_MAX',['../group___r_s_i_p___a_p_i.html#gga09d58045e1e5fc1fc22a72bfda6a2c6ba1bf207c0299f4b36fdc92dd4ecf826b6',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5faes_5f128_359',['RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a5c087988d5082ae00e9703d1980a1f7f',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5faes_5f128_5fxts_360',['RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128_XTS',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a9f5b9468fbbbe7084a8cd90a9fb3f40a',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5faes_5f256_361',['RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069acc7cfcba1a5e5944e566276062d4ff54',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5faes_5f256_5fxts_362',['RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256_XTS',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a1de8f70b943e282223c4b93742ffab37',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5faes_5fmax_363',['RSIP_BYTE_SIZE_WRAPPED_KEY_AES_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a9f4ea297e8da363157e7f66aa4ecc898',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fbrainpoolp256r1_5fprivate_364',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PRIVATE',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ac9ba8fb69cc3317264e05cde0249f06f',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fbrainpoolp256r1_5fpublic_365',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PUBLIC',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a18ef67c162ed62273cc9326622ad2164',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fprivate_5fmax_366',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PRIVATE_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a6ea981937f2151a755290e938ba7c47e',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fpublic_5fmax_367',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PUBLIC_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ae3887b040ebbf43f629ec20b504a3779',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fsecp192r1_5fprivate_368',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ab609f58697d8b22222d558c97b9da0be',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fsecp192r1_5fpublic_369',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069afee6765f321bf704ed1c105497416e58',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fsecp224r1_5fprivate_370',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ae6466928a02a9ea5bfb3a67dbab5f4e0',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fsecp224r1_5fpublic_371',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069af4ad017c6816e60391e7cd48ec516f54',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fsecp256r1_5fprivate_372',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a616dcde10261898e926bc7a550bdee87',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fecc_5fsecp256r1_5fpublic_373',['RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a71818cabae02e61719e9c5d34a28a3bd',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fhmac_5fmax_374',['RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a0d65c6ddc749536e69332f4b5229cb40',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fhmac_5fsha1_375',['RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA1',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069aa0061976fb107bc4a118ff6d79ca8c29',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fhmac_5fsha224_376',['RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA224',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a1fae3fdbe5e142cee2b83fd2ee78c3fc',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fhmac_5fsha256_377',['RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA256',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069ad302f44eb6bb360373f2c52ce0172993',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fkey_5fupdate_5fkey_378',['RSIP_BYTE_SIZE_WRAPPED_KEY_KEY_UPDATE_KEY',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a0787873287816db723cf3da18b95e009',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fmax_379',['RSIP_BYTE_SIZE_WRAPPED_KEY_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069aeb938665677db84ae6d1da16282b8b1d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f1024_5fprivate_5fenhanced_380',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a526a9fd8d458122f6edb59b06013fc41',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f1024_5fpublic_5fenhanced_381',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a28873d6222775f36065be210540e7f50',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f2048_5fprivate_5fenhanced_382',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a2f9ca50dd2f7e7ff78cb703666727c49',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f2048_5fpublic_5fenhanced_383',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a9001350f603fd8057ca0d8ad00f9961a',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f3072_5fprivate_384',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069aaf8df7e54cd8052e03114852da2ffa31',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f3072_5fpublic_385',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069acd089ec2a35f7c4086853b3e515272b7',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f4096_5fprivate_386',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a5e882c6dc51ad72779ad19e9eb684330',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5f4096_5fpublic_387',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a386fcc985ae05b83322cb3944c1fb744',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5fprivate_5fmax_388',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PRIVATE_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069abda559faa8a845f5f8e06d510c082629',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5frsa_5fpublic_5fmax_389',['RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PUBLIC_MAX',['../group___r_s_i_p___a_p_i.html#ggaf34956ea3649626a41606ee05aef9069a46c61543461d737b9be7f26db6b35c11',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5faes_5f128_390',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a586634b4d139e6f57746a237f5f1a0be',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5faes_5f128_5fxts_391',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128_XTS',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ac790e39e8b68c6a8f7cc833fb8ca98e4',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5faes_5f256_392',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a1b018a8fa7fd42508b831c634663b3be',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5faes_5f256_5fxts_393',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256_XTS',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2afdc13695f7f0bf48d17bde9150c2d5d5',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5faes_5fmax_394',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a8056769b72932b90227774389cf2667d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fbrainpoolp256r1_5fprivate_395',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a3e6d2558c274d02fc5f66b294411b903',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fbrainpoolp256r1_5fpublic_396',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a04727ef451762e283a8ca6f7ac6b7861',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fprivate_5fmax_397',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PRIVATE_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a7e058acecc7cfd50519c938fea9a4b2f',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fpublic_5fmax_398',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PUBLIC_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2abf32844af8087563228207b0e92206f8',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fsecp192r1_5fprivate_399',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ae9b143cdcb9bde593114b0bacbd84255',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fsecp192r1_5fpublic_400',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a7dddcca7061f44fa3db34915016dbb98',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fsecp224r1_5fprivate_401',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a446639af284989b0a0c8dd1e4cc4d167',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fsecp224r1_5fpublic_402',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a5a35d4d2d09198c47115f3ea34897ce2',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fsecp256r1_5fprivate_403',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2af1d315efc0f02f8ffcf537242f6a5c1d',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fecc_5fsecp256r1_5fpublic_404',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a7e0d45e2f8b5ad6f7c424860e89ff05b',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fhmac_5fmax_405',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ae91a70d223ec963db0512cd5721b50f4',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fhmac_5fsha1_406',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA1',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2adbc909a34e27086968337b14b73d41d1',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fhmac_5fsha224_407',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA224',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a2d1fe8897eea6fe2e8da371145b59aed',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fhmac_5fsha256_408',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA256',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a622942fa17ea395c2ffc2d10a9953d59',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fkey_5fupdate_5fkey_409',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_KEY_UPDATE_KEY',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ad938901804f0d8d6cf7242197d103203',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5fmax_410',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2ad0f5744f10c898d7cd0475cc31ef67fe',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f1024_5fprivate_5fenhanced_411',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a2c203c4e464d9f32009a494c9d60fbf8',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f1024_5fpublic_5fenhanced_412',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2acc82841e4a464ce393f46358a34fd896',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f2048_5fprivate_5fenhanced_413',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a6eb5d8cea1d9c29cf615b4d8ff4de9fe',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f2048_5fpublic_5fenhanced_414',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a8be4585da748345938a9b50afd4882bc',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f3072_5fprivate_415',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a78ae62e9bdcbad0863feef54bca6d610',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f3072_5fpublic_416',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a23ce153c49268a13a953340c1a1cdaee',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f4096_5fprivate_417',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2aedb0ff7185a258792305c85e7c6b1408',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5f4096_5fpublic_418',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a272193dbc8150aa367b016b7f19b448b',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5fprivate_5fmax_419',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PRIVATE_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2af60d086613f2afccd018ffccc9384ddb',1,'r_rsip_api.h']]], + ['rsip_5fbyte_5fsize_5fwrapped_5fkey_5fvalue_5frsa_5fpublic_5fmax_420',['RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PUBLIC_MAX',['../group___r_s_i_p___a_p_i.html#gga986cec1971f79c094bd27ac6d11b25e2a3f0dffcc6d2d8e865ee04a0d4a0f0eb0',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha1_421',['RSIP_HASH_TYPE_SHA1',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50a1e606044965bcf60e62d360773020b45',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha224_422',['RSIP_HASH_TYPE_SHA224',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50af64c98e1df3a92f08a6e68b20216b2d2',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha256_423',['RSIP_HASH_TYPE_SHA256',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50aa9b386d1b29869e511efd8d28f95cf06',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha384_424',['RSIP_HASH_TYPE_SHA384',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50a5d99501259f33a56446b2e924bce8dff',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha512_425',['RSIP_HASH_TYPE_SHA512',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50aa3336966c98485838aef21db86b4c9c4',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha512_5f224_426',['RSIP_HASH_TYPE_SHA512_224',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50a42459c435a6732056efc9b0026efb69e',1,'r_rsip_api.h']]], + ['rsip_5fhash_5ftype_5fsha512_5f256_427',['RSIP_HASH_TYPE_SHA512_256',['../group___r_s_i_p___a_p_i.html#gga23ab60f96b3821a218f957ada1bc0d50a42c1bdd5072314a38acd3f128577c1b5',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5fecc_5fbrainpoolp256r1_428',['RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8faf618da4a0cf7b6870423dd88c144c04e',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5fecc_5fsecp192r1_429',['RSIP_KEY_PAIR_TYPE_ECC_secp192r1',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa1db73377f01af77ecf1840a9c91d7cd6',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5fecc_5fsecp224r1_430',['RSIP_KEY_PAIR_TYPE_ECC_secp224r1',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa696986229d46e351abc68e49a193583f',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5fecc_5fsecp256r1_431',['RSIP_KEY_PAIR_TYPE_ECC_secp256r1',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa848eec7eab373097f2707df369276697',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5finvalid_432',['RSIP_KEY_PAIR_TYPE_INVALID',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fac5500d97824a55149bc601d071204952',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5frsa_5f1024_433',['RSIP_KEY_PAIR_TYPE_RSA_1024',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa72612c53f93986bcb9cb92831ce1afd6',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5frsa_5f2048_434',['RSIP_KEY_PAIR_TYPE_RSA_2048',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8faa0cd2ab30ec0148ad600f992ce927aa3',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5frsa_5f3072_435',['RSIP_KEY_PAIR_TYPE_RSA_3072',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa4dcc7fec49147dce7515509226eedf6a',1,'r_rsip_api.h']]], + ['rsip_5fkey_5fpair_5ftype_5frsa_5f4096_436',['RSIP_KEY_PAIR_TYPE_RSA_4096',['../group___r_s_i_p___a_p_i.html#gga78fe2581fc642a646738f81b181c2c8fa579b04ccf5fa9a785775229ea6860273',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5faes_5f128_437',['RSIP_KEY_TYPE_AES_128',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a86a9d2eba8d8e913beb35a9ef77719ea',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5faes_5f128_5fxts_438',['RSIP_KEY_TYPE_AES_128_XTS',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a5f636e29ceafce90ea5b4cbe8df24211',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5faes_5f256_439',['RSIP_KEY_TYPE_AES_256',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ac73d8d9299a235cdd03315cc8d4cf10c',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5faes_5f256_5fxts_440',['RSIP_KEY_TYPE_AES_256_XTS',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0af5ee03fb23a509757252d4d07aedc17b',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fbrainpoolp256r1_5fprivate_441',['RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa1283a39ddf31e2151a858b9adbe33ba',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fbrainpoolp256r1_5fpublic_442',['RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a0dab958d7e42944db5ae9d3cc6dbb171',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fsecp192r1_5fprivate_443',['RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa3eee3aadcfb68ffc5f545f2342a6ed9',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fsecp192r1_5fpublic_444',['RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ad8ddf883a2b65ea563f8b79c03143f92',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fsecp224r1_5fprivate_445',['RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a2b82d7ba783f63eeaf81504b1663e994',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fsecp224r1_5fpublic_446',['RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa9dac8ec3d4329e2bf539b541398f847',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fsecp256r1_5fprivate_447',['RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a8c86ca396f98786e5f4775afb699c799',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fecc_5fsecp256r1_5fpublic_448',['RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ad3c283cb6ecf75b790df5f500674f94e',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fhmac_5fsha1_449',['RSIP_KEY_TYPE_HMAC_SHA1',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a34ac6f0f7727f34302ebe5f433e8679a',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fhmac_5fsha224_450',['RSIP_KEY_TYPE_HMAC_SHA224',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa0ea2d8e02d46a57d4529a6a823af475',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fhmac_5fsha256_451',['RSIP_KEY_TYPE_HMAC_SHA256',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ad06544b015f3cb6936a8edb30fd76795',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5finvalid_452',['RSIP_KEY_TYPE_INVALID',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0ae95be99956cace7717544ddea792d0e9',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fkey_5fupdate_5fkey_453',['RSIP_KEY_TYPE_KEY_UPDATE_KEY',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a41528f99f9213d6427f80f920bf41a0c',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f1024_5fprivate_5fenhanced_454',['RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0aa2a474f523f6c08e3cb59eff333ca946',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f1024_5fpublic_5fenhanced_455',['RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a05ac77751a82f044778d9cb86c2f44f1',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f2048_5fprivate_5fenhanced_456',['RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a06508f9d0ca5be101fabc0954fbbffd2',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f2048_5fpublic_5fenhanced_457',['RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0abd142cdcce3eb32996644a947f6d8987',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f3072_5fprivate_458',['RSIP_KEY_TYPE_RSA_3072_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a19f0822cd6c1399de2bc15e8a46913fe',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f3072_5fpublic_459',['RSIP_KEY_TYPE_RSA_3072_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a3fb4b7a6660681c87ef8416bc8ef116d',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f4096_5fprivate_460',['RSIP_KEY_TYPE_RSA_4096_PRIVATE',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a58dc7de7d13a8f3b4fa46aac0f637181',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5frsa_5f4096_5fpublic_461',['RSIP_KEY_TYPE_RSA_4096_PUBLIC',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a52e55e5000f62bf6258d188c2c86983d',1,'r_rsip_api.h']]], + ['rsip_5fkey_5ftype_5fsecure_5fboot_5fdecryption_462',['RSIP_KEY_TYPE_SECURE_BOOT_DECRYPTION',['../group___r_s_i_p___a_p_i.html#gga1a940940c082b526361300f166136be0a4a929eca26e682e353a462162bee94c9',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha1_463',['RSIP_MGF_TYPE_MGF1_SHA1',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a467853f1da9a4d991cfa8a5dcd0bac8c',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha224_464',['RSIP_MGF_TYPE_MGF1_SHA224',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a3be5880de8b95f51bc3316dab173f26b',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha256_465',['RSIP_MGF_TYPE_MGF1_SHA256',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a706f017dd80223a4b21e3344a81b8188',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha384_466',['RSIP_MGF_TYPE_MGF1_SHA384',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9ab4928d0237db4c9107c99a07d2d45b55',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha512_467',['RSIP_MGF_TYPE_MGF1_SHA512',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a85c5a243de79d7dc9937946c18b53d18',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha512_5f224_468',['RSIP_MGF_TYPE_MGF1_SHA512_224',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a686e5d6dda2e85fbb1a5b6947242be0c',1,'r_rsip_api.h']]], + ['rsip_5fmgf_5ftype_5fmgf1_5fsha512_5f256_469',['RSIP_MGF_TYPE_MGF1_SHA512_256',['../group___r_s_i_p___a_p_i.html#ggab5bfaadcf28c8276e7dda056d874baa9a97d5cd9aa8b6fa9ce232aea21b79de8f',1,'r_rsip_api.h']]], + ['rsip_5fpassword_5ftype_5fjtag_5fdebug_5fauthentication_5flevel1_470',['RSIP_PASSWORD_TYPE_JTAG_DEBUG_AUTHENTICATION_LEVEL1',['../group___r_s_i_p___a_p_i.html#ggaf9124e401923d473d86b93cd7cc2031da6541a5167825a8e412d4568b86b3354f',1,'r_rsip_api.h']]], + ['rsip_5fpassword_5ftype_5fjtag_5fdebug_5fauthentication_5flevel2_471',['RSIP_PASSWORD_TYPE_JTAG_DEBUG_AUTHENTICATION_LEVEL2',['../group___r_s_i_p___a_p_i.html#ggaf9124e401923d473d86b93cd7cc2031daa29cf2c09763028ba473a10f4fbb8724',1,'r_rsip_api.h']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/functions_0.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/functions_0.html new file mode 100644 index 000000000..e17c71111 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/functions_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/functions_0.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/functions_0.js new file mode 100644 index 000000000..ff6e94e48 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/functions_0.js @@ -0,0 +1,54 @@ +var searchData= +[ + ['r_5frsip_5faes_5fcipher_5fdecryptfinal_258',['R_RSIP_AES_Cipher_DecryptFinal',['../group___r_s_i_p.html#ga51698d930e957b5582afb6d439988280',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcipher_5fdecryptinit_259',['R_RSIP_AES_Cipher_DecryptInit',['../group___r_s_i_p.html#ga2bf24039437c98ec88756fa061e034de',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcipher_5fdecryptupdate_260',['R_RSIP_AES_Cipher_DecryptUpdate',['../group___r_s_i_p.html#gafafae41b7a4bc678044880c7b713ef40',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcipher_5fencryptfinal_261',['R_RSIP_AES_Cipher_EncryptFinal',['../group___r_s_i_p.html#ga93448d8822300805e51e82e4d740d343',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcipher_5fencryptinit_262',['R_RSIP_AES_Cipher_EncryptInit',['../group___r_s_i_p.html#gaf7ef1afdfa6e0485ac25b096b7bcf9ce',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcipher_5fencryptupdate_263',['R_RSIP_AES_Cipher_EncryptUpdate',['../group___r_s_i_p.html#gab4d578ccdc90b571f7ba0a63e009a527',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcmac_5fgeneratefinal_264',['R_RSIP_AES_CMAC_GenerateFinal',['../group___r_s_i_p.html#ga73e956dc3b778d329a51548ec2d8da44',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcmac_5fgenerateinit_265',['R_RSIP_AES_CMAC_GenerateInit',['../group___r_s_i_p.html#ga9f4b6ce398b0b9ccff8826c34512ad33',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcmac_5fgenerateupdate_266',['R_RSIP_AES_CMAC_GenerateUpdate',['../group___r_s_i_p.html#ga40add84d634c86a265a1d5861d8695a1',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcmac_5fverifyfinal_267',['R_RSIP_AES_CMAC_VerifyFinal',['../group___r_s_i_p.html#ga9daea7a9e8c9c595b5d3ba3b6302e339',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcmac_5fverifyinit_268',['R_RSIP_AES_CMAC_VerifyInit',['../group___r_s_i_p.html#ga0da0a1ff141aeb28f48d28aa173bcc96',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fcmac_5fverifyupdate_269',['R_RSIP_AES_CMAC_VerifyUpdate',['../group___r_s_i_p.html#ga996cf26b4bd4b2b8bf68ebaaca8ac986',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fgcm_5fdecryptfinal_270',['R_RSIP_AES_GCM_DecryptFinal',['../group___r_s_i_p.html#ga97c42f1430d18f9c1e7e9b1fd0e69de1',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fgcm_5fdecryptinit_271',['R_RSIP_AES_GCM_DecryptInit',['../group___r_s_i_p.html#ga883c34556cb6dd27d9dbd8f32fa0022b',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fgcm_5fdecryptupdate_272',['R_RSIP_AES_GCM_DecryptUpdate',['../group___r_s_i_p.html#ga05583899c77d206a9ef09e9d8dd29b78',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fgcm_5fencryptfinal_273',['R_RSIP_AES_GCM_EncryptFinal',['../group___r_s_i_p.html#ga82e9872bf11e0a0bcf4c3e36f327ebbb',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fgcm_5fencryptinit_274',['R_RSIP_AES_GCM_EncryptInit',['../group___r_s_i_p.html#ga05bb680ea48c54adb50804631a0324a9',1,'r_rsip_aes.c']]], + ['r_5frsip_5faes_5fgcm_5fencryptupdate_275',['R_RSIP_AES_GCM_EncryptUpdate',['../group___r_s_i_p.html#gab43537eaf3eae896e79ecbd34b4c21c6',1,'r_rsip_aes.c']]], + ['r_5frsip_5fclose_276',['R_RSIP_Close',['../group___r_s_i_p.html#gac7848f48d9f8484cb17e156e299046fe',1,'r_rsip.c']]], + ['r_5frsip_5feccpublickeyexport_277',['R_RSIP_ECCPublicKeyExport',['../group___r_s_i_p.html#ga0cfe8c89cee5df215b42d72f56f05fd7',1,'r_rsip.c']]], + ['r_5frsip_5fecdsa_5fsign_278',['R_RSIP_ECDSA_Sign',['../group___r_s_i_p.html#ga51b427c5ed2f8d2980d6c29a68951f3c',1,'r_rsip_ecc.c']]], + ['r_5frsip_5fecdsa_5fverify_279',['R_RSIP_ECDSA_Verify',['../group___r_s_i_p.html#ga4001cf997810be799f9873f7f19f515c',1,'r_rsip_ecc.c']]], + ['r_5frsip_5fhmac_5fcompute_280',['R_RSIP_HMAC_Compute',['../group___r_s_i_p.html#gafd208f1c55bdd1e5c6f6ef8e09f61e3f',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fgeneratefinal_281',['R_RSIP_HMAC_GenerateFinal',['../group___r_s_i_p.html#ga9b4cf45516cbd962c3ddc011a4d6c41b',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fgenerateinit_282',['R_RSIP_HMAC_GenerateInit',['../group___r_s_i_p.html#ga35ce74c94050adbacbf6a05c2135000f',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fgenerateupdate_283',['R_RSIP_HMAC_GenerateUpdate',['../group___r_s_i_p.html#gaa41e41608057985c7a60036b49dd7425',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fverify_284',['R_RSIP_HMAC_Verify',['../group___r_s_i_p.html#ga601bce8a7997bfad866e278d1b0133c4',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fverifyfinal_285',['R_RSIP_HMAC_VerifyFinal',['../group___r_s_i_p.html#ga8bb6027da5a6113528b82492511e6259',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fverifyinit_286',['R_RSIP_HMAC_VerifyInit',['../group___r_s_i_p.html#ga8f8758d50640071cf33c906ac56699c7',1,'r_rsip_sha.c']]], + ['r_5frsip_5fhmac_5fverifyupdate_287',['R_RSIP_HMAC_VerifyUpdate',['../group___r_s_i_p.html#gad6de1c75e4f7cf9ca361b5fbc1c875d2',1,'r_rsip_sha.c']]], + ['r_5frsip_5fkeygenerate_288',['R_RSIP_KeyGenerate',['../group___r_s_i_p.html#ga2dc3a8de5422978d001750fa120df176',1,'r_rsip.c']]], + ['r_5frsip_5fkeyimportwithkuk_289',['R_RSIP_KeyImportWithKUK',['../group___r_s_i_p.html#ga183fb4be47cd4156e16887087d9aa7e7',1,'r_rsip.c']]], + ['r_5frsip_5fkeyimportwithufpk_290',['R_RSIP_KeyImportWithUFPK',['../group___r_s_i_p.html#ga0e45064b017808306219d8178ccb4966',1,'r_rsip_rzg3.c']]], + ['r_5frsip_5fkeypairgenerate_291',['R_RSIP_KeyPairGenerate',['../group___r_s_i_p.html#gacbc429a31f21d4a409d40ef7c8704c96',1,'r_rsip.c']]], + ['r_5frsip_5fopen_292',['R_RSIP_Open',['../group___r_s_i_p.html#ga0f3222e34aedf16a9eeba214db0aeeac',1,'r_rsip.c']]], + ['r_5frsip_5frandomnumbergenerate_293',['R_RSIP_RandomNumberGenerate',['../group___r_s_i_p.html#ga004e5a8c7361e446809f4cba8fb4a493',1,'r_rsip.c']]], + ['r_5frsip_5frsa_5fdecrypt_294',['R_RSIP_RSA_Decrypt',['../group___r_s_i_p.html#gaf2afe4d205b51f1c434ac0e4dd24a137',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsa_5fencrypt_295',['R_RSIP_RSA_Encrypt',['../group___r_s_i_p.html#ga5ab165c8834057601821bb486e8e9855',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsaes_5foaep_5fdecrypt_296',['R_RSIP_RSAES_OAEP_Decrypt',['../group___r_s_i_p.html#ga212e1d21390f8ea72bd91c844375399f',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsaes_5foaep_5fencrypt_297',['R_RSIP_RSAES_OAEP_Encrypt',['../group___r_s_i_p.html#ga1e2bb479037a936aac115f73fcc6788f',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsaes_5fpkcs1_5fv1_5f5_5fdecrypt_298',['R_RSIP_RSAES_PKCS1_V1_5_Decrypt',['../group___r_s_i_p.html#ga83eb46af309c6539abdedc3333859179',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsaes_5fpkcs1_5fv1_5f5_5fencrypt_299',['R_RSIP_RSAES_PKCS1_V1_5_Encrypt',['../group___r_s_i_p.html#gaee51f26eb1994439e790cc736ab17eab',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsapublickeyexport_300',['R_RSIP_RSAPublicKeyExport',['../group___r_s_i_p.html#ga2406d2768cd35af5129101eafb6e0f95',1,'r_rsip.c']]], + ['r_5frsip_5frsassa_5fpkcs1_5fv1_5f5_5fsign_301',['R_RSIP_RSASSA_PKCS1_V1_5_Sign',['../group___r_s_i_p.html#ga2645bf20337f5746c0e16aa809f33cf4',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsassa_5fpkcs1_5fv1_5f5_5fverify_302',['R_RSIP_RSASSA_PKCS1_V1_5_Verify',['../group___r_s_i_p.html#ga5312c9f027c45ecb2779c99e6c7e72ff',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsassa_5fpss_5fsign_303',['R_RSIP_RSASSA_PSS_Sign',['../group___r_s_i_p.html#ga99f7fd3650b5167e0969e2cb681b763a',1,'r_rsip_rsa.c']]], + ['r_5frsip_5frsassa_5fpss_5fverify_304',['R_RSIP_RSASSA_PSS_Verify',['../group___r_s_i_p.html#gac79f1b11849d19e8dfa7f90276e68e77',1,'r_rsip_rsa.c']]], + ['r_5frsip_5fsha_5fcompute_305',['R_RSIP_SHA_Compute',['../group___r_s_i_p.html#ga8517124a32ed6bea90f2d0c82885eed7',1,'r_rsip_sha.c']]], + ['r_5frsip_5fsha_5fgeneratefinal_306',['R_RSIP_SHA_GenerateFinal',['../group___r_s_i_p.html#ga197111ff5c0da56f545ed60a3ce5271a',1,'r_rsip_sha.c']]], + ['r_5frsip_5fsha_5fgenerateinit_307',['R_RSIP_SHA_GenerateInit',['../group___r_s_i_p.html#gade4e2469c7b564412b1ff93695e009d1',1,'r_rsip_sha.c']]], + ['r_5frsip_5fsha_5fgenerateupdate_308',['R_RSIP_SHA_GenerateUpdate',['../group___r_s_i_p.html#gac4e40a3e418dd33ad6d3a062b7820908',1,'r_rsip_sha.c']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_0.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_0.html new file mode 100644 index 000000000..a2d93357b --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_0.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_0.js new file mode 100644 index 000000000..ce8cd9d4e --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['interfaces_472',['Interfaces',['../group___r_e_n_e_s_a_s___i_n_t_e_r_f_a_c_e_s.html',1,'']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_1.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_1.html new file mode 100644 index 000000000..aa06d658c --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_1.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_1.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_1.js new file mode 100644 index 000000000..0e3d40d82 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_1.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['modules_473',['Modules',['../group___r_e_n_e_s_a_s___m_o_d_u_l_e_s.html',1,'']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_2.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_2.html new file mode 100644 index 000000000..a205d30db --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_2.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_2.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_2.js new file mode 100644 index 000000000..e447e2a32 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/groups_2.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['renesas_20secure_20ip_20_28r_5frsip_29_474',['Renesas Secure IP (r_rsip)',['../group___r_s_i_p.html',1,'']]], + ['rsip_20interface_475',['RSIP Interface',['../group___r_s_i_p___a_p_i.html',1,'']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/mag_sel.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/mag_sel.png new file mode 100644 index 0000000000000000000000000000000000000000..39c0ed52a25dd9d080ee0d42ae6c6042bdfa04d7 GIT binary patch literal 465 zcmeAS@N?(olHy`uVBq!ia0vp^B0wz6!2%?$TA$hhDVB6cUq=Rpjs4tz5?O(Kg=CK) zUj~NU84L`?eGCi_EEpJ?t}-xGu`@87+QPtK?83kxQ`TapwHK(CDaqU2h2ejD|C#+j z9%q3^WHAE+w=f7ZGR&GI0Tg5}@$_|Nf5gMiEhFgvHvB$N=!mC_V~EE2vzPXI9ZnEo zd+1zHor@dYLod2Y{ z@R$7$Z!PXTbY$|@#T!bMzm?`b<(R`cbw(gxJHzu zB$lLFB^RXvDF!10LknF)BV7aY5JN*NBMU1-b8Q0yD+2>vd*|CI8glbfGSez?Ylunu RoetE%;OXk;vd$@?2>>CYplSdB literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/nomatches.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/nomatches.html new file mode 100644 index 000000000..437732089 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/nomatches.html @@ -0,0 +1,12 @@ + + + + + + + +
+
No Matches
+
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_0.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_0.html new file mode 100644 index 000000000..9a6a29ad3 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_0.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_0.js new file mode 100644 index 000000000..56323118e --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['copyright_476',['Copyright',['../_c_o_p_y_r_i_g_h_t.html',1,'']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_1.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_1.html new file mode 100644 index 000000000..132ee038e --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_1.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_1.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_1.js new file mode 100644 index 000000000..73c124014 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_1.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['deprecated_20list_477',['Deprecated List',['../deprecated.html',1,'']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_2.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_2.html new file mode 100644 index 000000000..6109d4704 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_2.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_2.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_2.js new file mode 100644 index 000000000..b828846ae --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/pages_2.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['renesas_20secure_20ip_478',['Renesas Secure IP',['../index.html',1,'']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search.css b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search.css new file mode 100644 index 000000000..a0dba441c --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search.css @@ -0,0 +1,273 @@ +/*---------------- Search Box */ + +#FSearchBox { + float: left; +} + +#MSearchBox { + white-space : nowrap; + float: none; + margin-top: 0px; + right: 0px; + width: 170px; + height: 24px; + z-index: 102; + display: inline; + position: absolute; +} + +#MSearchBox .left +{ + display:block; + position:absolute; + left:10px; + width:20px; + height:19px; + background:url('search_l.png') no-repeat; + background-position:right; +} + +#MSearchSelect { + display:block; + position:absolute; + width:20px; + height:19px; +} + +.left #MSearchSelect { + left:4px; +} + +.right #MSearchSelect { + right:5px; +} + +#MSearchField { + display:block; + position:absolute; + height:19px; + background:url('search_m.png') repeat-x; + border:none; + width:111px; + margin-left:20px; + padding-left:4px; + color: #909090; + outline: none; + font: 9pt Arial, Verdana, sans-serif; + -webkit-border-radius: 0px; +} + +#FSearchBox #MSearchField { + margin-left:15px; +} + +#MSearchBox .right { + display:block; + position:absolute; + right:10px; + top:0px; + width:20px; + height:19px; + background:url('search_r.png') no-repeat; + background-position:left; +} + +#MSearchClose { + display: none; + position: absolute; + top: 4px; + background : none; + border: none; + margin: 0px 4px 0px 0px; + padding: 0px 0px; + outline: none; +} + +.left #MSearchClose { + left: 6px; +} + +.right #MSearchClose { + right: 2px; +} + +.MSearchBoxActive #MSearchField { + color: #000000; +} + +/*---------------- Search filter selection */ + +#MSearchSelectWindow { + display: none; + position: absolute; + left: 0; top: 0; + border: 1px solid #90A5CE; + background-color: #F9FAFC; + z-index: 10001; + padding-top: 4px; + padding-bottom: 4px; + -moz-border-radius: 4px; + -webkit-border-top-left-radius: 4px; + -webkit-border-top-right-radius: 4px; + -webkit-border-bottom-left-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); +} + +.SelectItem { + font: 8pt Arial, Verdana, sans-serif; + padding-left: 2px; + padding-right: 12px; + border: 0px; +} + +span.SelectionMark { + margin-right: 4px; + font-family: monospace; + outline-style: none; + text-decoration: none; +} + +a.SelectItem { + display: block; + outline-style: none; + color: #000000; + text-decoration: none; + padding-left: 6px; + padding-right: 12px; +} + +a.SelectItem:focus, +a.SelectItem:active { + color: #000000; + outline-style: none; + text-decoration: none; +} + +a.SelectItem:hover { + color: #FFFFFF; + background-color: #3D578C; + outline-style: none; + text-decoration: none; + cursor: pointer; + display: block; +} + +/*---------------- Search results window */ + +iframe#MSearchResults { + width: 60ex; + height: 15em; +} + +#MSearchResultsWindow { + display: none; + position: absolute; + left: 0; top: 0; + border: 1px solid #000; + background-color: #EEF1F7; + z-index:10000; +} + +/* ----------------------------------- */ + + +#SRIndex { + clear:both; + padding-bottom: 15px; +} + +.SREntry { + font-size: 10pt; + padding-left: 1ex; +} + +.SRPage .SREntry { + font-size: 8pt; + padding: 1px 5px; +} + +body.SRPage { + margin: 5px 2px; +} + +.SRChildren { + padding-left: 3ex; padding-bottom: .5em +} + +.SRPage .SRChildren { + display: none; +} + +.SRSymbol { + font-weight: bold; + color: #425E97; + font-family: Arial, Verdana, sans-serif; + text-decoration: none; + outline: none; +} + +a.SRScope { + display: block; + color: #425E97; + font-family: Arial, Verdana, sans-serif; + text-decoration: none; + outline: none; +} + +a.SRSymbol:focus, a.SRSymbol:active, +a.SRScope:focus, a.SRScope:active { + text-decoration: underline; +} + +span.SRScope { + padding-left: 4px; +} + +.SRPage .SRStatus { + padding: 2px 5px; + font-size: 8pt; + font-style: italic; +} + +.SRResult { + display: none; +} + +DIV.searchresults { + margin-left: 10px; + margin-right: 10px; +} + +/*---------------- External search page results */ + +.searchresult { + background-color: #F0F3F8; +} + +.pages b { + color: white; + padding: 5px 5px 3px 5px; + background-image: url("../tab_a.png"); + background-repeat: repeat-x; + text-shadow: 0 1px 1px #000000; +} + +.pages { + line-height: 17px; + margin-left: 4px; + text-decoration: none; +} + +.hl { + font-weight: bold; +} + +#searchresults { + margin-bottom: 20px; +} + +.searchpages { + margin-top: 10px; +} + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search.js new file mode 100644 index 000000000..a554ab9cb --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search.js @@ -0,0 +1,814 @@ +/* + @licstart The following is the entire license notice for the + JavaScript code in this file. + + Copyright (C) 1997-2017 by Dimitri van Heesch + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + @licend The above is the entire license notice + for the JavaScript code in this file + */ +function convertToId(search) +{ + var result = ''; + for (i=0;i do a search + { + this.Search(); + } + } + + this.OnSearchSelectKey = function(evt) + { + var e = (evt) ? evt : window.event; // for IE + if (e.keyCode==40 && this.searchIndex0) // Up + { + this.searchIndex--; + this.OnSelectItem(this.searchIndex); + } + else if (e.keyCode==13 || e.keyCode==27) + { + this.OnSelectItem(this.searchIndex); + this.CloseSelectionWindow(); + this.DOMSearchField().focus(); + } + return false; + } + + // --------- Actions + + // Closes the results window. + this.CloseResultsWindow = function() + { + this.DOMPopupSearchResultsWindow().style.display = 'none'; + this.DOMSearchClose().style.display = 'none'; + this.Activate(false); + } + + this.CloseSelectionWindow = function() + { + this.DOMSearchSelectWindow().style.display = 'none'; + } + + // Performs a search. + this.Search = function() + { + this.keyTimeout = 0; + + // strip leading whitespace + var searchValue = this.DOMSearchField().value.replace(/^ +/, ""); + + var code = searchValue.toLowerCase().charCodeAt(0); + var idxChar = searchValue.substr(0, 1).toLowerCase(); + if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair + { + idxChar = searchValue.substr(0, 2); + } + + var resultsPage; + var resultsPageWithSearch; + var hasResultsPage; + + var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar); + if (idx!=-1) + { + var hexCode=idx.toString(16); + resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html'; + resultsPageWithSearch = resultsPage+'?'+escape(searchValue); + hasResultsPage = true; + } + else // nothing available for this search term + { + resultsPage = this.resultsPath + '/nomatches.html'; + resultsPageWithSearch = resultsPage; + hasResultsPage = false; + } + + window.frames.MSearchResults.location = resultsPageWithSearch; + var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow(); + + if (domPopupSearchResultsWindow.style.display!='block') + { + var domSearchBox = this.DOMSearchBox(); + this.DOMSearchClose().style.display = 'inline'; + if (this.insideFrame) + { + var domPopupSearchResults = this.DOMPopupSearchResults(); + domPopupSearchResultsWindow.style.position = 'relative'; + domPopupSearchResultsWindow.style.display = 'block'; + var width = document.body.clientWidth - 8; // the -8 is for IE :-( + domPopupSearchResultsWindow.style.width = width + 'px'; + domPopupSearchResults.style.width = width + 'px'; + } + else + { + var domPopupSearchResults = this.DOMPopupSearchResults(); + var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth; + var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1; + domPopupSearchResultsWindow.style.display = 'block'; + left -= domPopupSearchResults.offsetWidth; + domPopupSearchResultsWindow.style.top = top + 'px'; + domPopupSearchResultsWindow.style.left = left + 'px'; + } + } + + this.lastSearchValue = searchValue; + this.lastResultsPage = resultsPage; + } + + // -------- Activation Functions + + // Activates or deactivates the search panel, resetting things to + // their default values if necessary. + this.Activate = function(isActive) + { + if (isActive || // open it + this.DOMPopupSearchResultsWindow().style.display == 'block' + ) + { + this.DOMSearchBox().className = 'MSearchBoxActive'; + + var searchField = this.DOMSearchField(); + + if (searchField.value == this.searchLabel) // clear "Search" term upon entry + { + searchField.value = ''; + this.searchActive = true; + } + } + else if (!isActive) // directly remove the panel + { + this.DOMSearchBox().className = 'MSearchBoxInactive'; + this.DOMSearchField().value = this.searchLabel; + this.searchActive = false; + this.lastSearchValue = '' + this.lastResultsPage = ''; + } + } +} + +// ----------------------------------------------------------------------- + +// The class that handles everything on the search results page. +function SearchResults(name) +{ + // The number of matches from the last run of . + this.lastMatchCount = 0; + this.lastKey = 0; + this.repeatOn = false; + + // Toggles the visibility of the passed element ID. + this.FindChildElement = function(id) + { + var parentElement = document.getElementById(id); + var element = parentElement.firstChild; + + while (element && element!=parentElement) + { + if (element.nodeName == 'DIV' && element.className == 'SRChildren') + { + return element; + } + + if (element.nodeName == 'DIV' && element.hasChildNodes()) + { + element = element.firstChild; + } + else if (element.nextSibling) + { + element = element.nextSibling; + } + else + { + do + { + element = element.parentNode; + } + while (element && element!=parentElement && !element.nextSibling); + + if (element && element!=parentElement) + { + element = element.nextSibling; + } + } + } + } + + this.Toggle = function(id) + { + var element = this.FindChildElement(id); + if (element) + { + if (element.style.display == 'block') + { + element.style.display = 'none'; + } + else + { + element.style.display = 'block'; + } + } + } + + // Searches for the passed string. If there is no parameter, + // it takes it from the URL query. + // + // Always returns true, since other documents may try to call it + // and that may or may not be possible. + this.Search = function(search) + { + if (!search) // get search word from URL + { + search = window.location.search; + search = search.substring(1); // Remove the leading '?' + search = unescape(search); + } + + search = search.replace(/^ +/, ""); // strip leading spaces + search = search.replace(/ +$/, ""); // strip trailing spaces + search = search.toLowerCase(); + search = convertToId(search); + + var resultRows = document.getElementsByTagName("div"); + var matches = 0; + + var i = 0; + while (i < resultRows.length) + { + var row = resultRows.item(i); + if (row.className == "SRResult") + { + var rowMatchName = row.id.toLowerCase(); + rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_' + + if (search.length<=rowMatchName.length && + rowMatchName.substr(0, search.length)==search) + { + row.style.display = 'block'; + matches++; + } + else + { + row.style.display = 'none'; + } + } + i++; + } + document.getElementById("Searching").style.display='none'; + if (matches == 0) // no results + { + document.getElementById("NoMatches").style.display='block'; + } + else // at least one result + { + document.getElementById("NoMatches").style.display='none'; + } + this.lastMatchCount = matches; + return true; + } + + // return the first item with index index or higher that is visible + this.NavNext = function(index) + { + var focusItem; + while (1) + { + var focusName = 'Item'+index; + focusItem = document.getElementById(focusName); + if (focusItem && focusItem.parentNode.parentNode.style.display=='block') + { + break; + } + else if (!focusItem) // last element + { + break; + } + focusItem=null; + index++; + } + return focusItem; + } + + this.NavPrev = function(index) + { + var focusItem; + while (1) + { + var focusName = 'Item'+index; + focusItem = document.getElementById(focusName); + if (focusItem && focusItem.parentNode.parentNode.style.display=='block') + { + break; + } + else if (!focusItem) // last element + { + break; + } + focusItem=null; + index--; + } + return focusItem; + } + + this.ProcessKeys = function(e) + { + if (e.type == "keydown") + { + this.repeatOn = false; + this.lastKey = e.keyCode; + } + else if (e.type == "keypress") + { + if (!this.repeatOn) + { + if (this.lastKey) this.repeatOn = true; + return false; // ignore first keypress after keydown + } + } + else if (e.type == "keyup") + { + this.lastKey = 0; + this.repeatOn = false; + } + return this.lastKey!=0; + } + + this.Nav = function(evt,itemIndex) + { + var e = (evt) ? evt : window.event; // for IE + if (e.keyCode==13) return true; + if (!this.ProcessKeys(e)) return false; + + if (this.lastKey==38) // Up + { + var newIndex = itemIndex-1; + var focusItem = this.NavPrev(newIndex); + if (focusItem) + { + var child = this.FindChildElement(focusItem.parentNode.parentNode.id); + if (child && child.style.display == 'block') // children visible + { + var n=0; + var tmpElem; + while (1) // search for last child + { + tmpElem = document.getElementById('Item'+newIndex+'_c'+n); + if (tmpElem) + { + focusItem = tmpElem; + } + else // found it! + { + break; + } + n++; + } + } + } + if (focusItem) + { + focusItem.focus(); + } + else // return focus to search field + { + parent.document.getElementById("MSearchField").focus(); + } + } + else if (this.lastKey==40) // Down + { + var newIndex = itemIndex+1; + var focusItem; + var item = document.getElementById('Item'+itemIndex); + var elem = this.FindChildElement(item.parentNode.parentNode.id); + if (elem && elem.style.display == 'block') // children visible + { + focusItem = document.getElementById('Item'+itemIndex+'_c0'); + } + if (!focusItem) focusItem = this.NavNext(newIndex); + if (focusItem) focusItem.focus(); + } + else if (this.lastKey==39) // Right + { + var item = document.getElementById('Item'+itemIndex); + var elem = this.FindChildElement(item.parentNode.parentNode.id); + if (elem) elem.style.display = 'block'; + } + else if (this.lastKey==37) // Left + { + var item = document.getElementById('Item'+itemIndex); + var elem = this.FindChildElement(item.parentNode.parentNode.id); + if (elem) elem.style.display = 'none'; + } + else if (this.lastKey==27) // Escape + { + parent.searchBox.CloseResultsWindow(); + parent.document.getElementById("MSearchField").focus(); + } + else if (this.lastKey==13) // Enter + { + return true; + } + return false; + } + + this.NavChild = function(evt,itemIndex,childIndex) + { + var e = (evt) ? evt : window.event; // for IE + if (e.keyCode==13) return true; + if (!this.ProcessKeys(e)) return false; + + if (this.lastKey==38) // Up + { + if (childIndex>0) + { + var newIndex = childIndex-1; + document.getElementById('Item'+itemIndex+'_c'+newIndex).focus(); + } + else // already at first child, jump to parent + { + document.getElementById('Item'+itemIndex).focus(); + } + } + else if (this.lastKey==40) // Down + { + var newIndex = childIndex+1; + var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex); + if (!elem) // last child, jump to parent next parent + { + elem = this.NavNext(itemIndex+1); + } + if (elem) + { + elem.focus(); + } + } + else if (this.lastKey==27) // Escape + { + parent.searchBox.CloseResultsWindow(); + parent.document.getElementById("MSearchField").focus(); + } + else if (this.lastKey==13) // Enter + { + return true; + } + return false; + } +} + +function setKeyActions(elem,action) +{ + elem.setAttribute('onkeydown',action); + elem.setAttribute('onkeypress',action); + elem.setAttribute('onkeyup',action); +} + +function setClassAttr(elem,attr) +{ + elem.setAttribute('class',attr); + elem.setAttribute('className',attr); +} + +function createResults() +{ + var results = document.getElementById("SRResults"); + for (var e=0; e(R!W8j_r#qQ#gnr4kAxdU#F0+OBry$Z+ z_0PMi;P|#{d%mw(dnw=jM%@$onTJa%@6Nm3`;2S#nwtVFJI#`U@2Q@@JCCctagvF- z8H=anvo~dTmJ2YA%wA6IHRv%{vxvUm|R)kgZeo zmX%Zb;mpflGZdXCTAgit`||AFzkI#z&(3d4(htA?U2FOL4WF6wY&TB#n3n*I4+hl| z*NBpo#FA92vEu822WQ%mvv4FO#qs` BFGc_W literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search_r.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/search_r.png new file mode 100644 index 0000000000000000000000000000000000000000..1af5d21ee13e070d7600f1c4657fde843b953a69 GIT binary patch literal 553 zcmeAS@N?(olHy`uVBq!ia0vp^LO?9c!2%@BXHTsJQY`6?zK#qG8~eHcB(ehe3dtTp zz6=bxGZ+|(`xqD=STHa&U1eaXVrO7DwS|Gf*oA>XrmV$GYcEhOQT(QLuS{~ooZ2P@v=Xc@RKW@Irliv8_;wroU0*)0O?temdsA~70jrdux+`@W7 z-N(<(C)L?hOO?KV{>8(jC{hpKsws)#Fh zvsO>IB+gb@b+rGWaO&!a9Z{!U+fV*s7TS>fdt&j$L%^U@Epd$~Nl7e8wMs5Z1yT$~ z28I^8hDN#u<{^fLRz?<9hUVG^237_Jy7tbuQ8eV{r(~v8;?@w8^gA7>fx*+&&t;uc GLK6VEQpiUD literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/searchdata.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/searchdata.js new file mode 100644 index 000000000..e18a8c525 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/searchdata.js @@ -0,0 +1,39 @@ +var indexSectionsWithContent = +{ + 0: "cdefimprstv", + 1: "s", + 2: "r", + 3: "ptv", + 4: "r", + 5: "e", + 6: "r", + 7: "imr", + 8: "cdr" +}; + +var indexSectionNames = +{ + 0: "all", + 1: "classes", + 2: "functions", + 3: "variables", + 4: "typedefs", + 5: "enums", + 6: "enumvalues", + 7: "groups", + 8: "pages" +}; + +var indexSectionLabels = +{ + 0: "All", + 1: "Data Structures", + 2: "Functions", + 3: "Variables", + 4: "Typedefs", + 5: "Enumerations", + 6: "Enumerator", + 7: "Modules", + 8: "Pages" +}; + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/typedefs_0.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/typedefs_0.html new file mode 100644 index 000000000..376db4791 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/typedefs_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/typedefs_0.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/typedefs_0.js new file mode 100644 index 000000000..69e6a0b24 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/typedefs_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['rsip_5fctrl_5ft_314',['rsip_ctrl_t',['../group___r_s_i_p___a_p_i.html#ga2042507aed5dec71014a96b91aeaa4fa',1,'r_rsip_api.h']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_0.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_0.html new file mode 100644 index 000000000..bf3eba5cc --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_0.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_0.js new file mode 100644 index 000000000..d51873879 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_0.js @@ -0,0 +1,6 @@ +var searchData= +[ + ['p_5fcfg_309',['p_cfg',['../group___r_s_i_p___a_p_i.html#a1db23440fe44a1681f863478050f4c2f',1,'st_rsip_instance']]], + ['p_5fctrl_310',['p_ctrl',['../group___r_s_i_p___a_p_i.html#aabb64a2dddc53a5ffa8a6e618d0bf999',1,'st_rsip_instance']]], + ['p_5fextend_311',['p_extend',['../group___r_s_i_p___a_p_i.html#ad275dec7a146f7c5dd92b67dd289df43',1,'st_rsip_cfg']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_1.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_1.html new file mode 100644 index 000000000..49fe59a12 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_1.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_1.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_1.js new file mode 100644 index 000000000..689c51b6f --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_1.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['type_312',['type',['../group___r_s_i_p___a_p_i.html#a8bd2f326e4b02652713870b0f0a7be27',1,'st_rsip_wrapped_key']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_2.html b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_2.html new file mode 100644 index 000000000..0c8a18cf9 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_2.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_2.js b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_2.js new file mode 100644 index 000000000..5b2196157 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/search/variables_2.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['value_313',['value',['../group___r_s_i_p___a_p_i.html#adea2e89755d0cba606102f718b7b63d6',1,'st_rsip_wrapped_key']]] +]; diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/splitbar.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/splitbar.png new file mode 100644 index 0000000000000000000000000000000000000000..fe895f2c58179b471a22d8320b39a4bd7312ec8e GIT binary patch literal 314 zcmeAS@N?(olHy`uVBq!ia0vp^Yzz!63>-{AmhX=Jf(#6djGiuzAr*{o?=JLmPLyc> z_*`QK&+BH@jWrYJ7>r6%keRM@)Qyv8R=enp0jiI>aWlGyB58O zFVR20d+y`K7vDw(hJF3;>dD*3-?v=<8M)@x|EEGLnJsniYK!2U1 Y!`|5biEc?d1`HDhPgg&ebxsLQ02F6;9RL6T literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/sync_off.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/sync_off.png new file mode 100644 index 0000000000000000000000000000000000000000..3b443fc62892114406e3d399421b2a881b897acc GIT binary patch literal 853 zcmV-b1FHOqP)oT|#XixUYy%lpuf3i8{fX!o zUyDD0jOrAiT^tq>fLSOOABs-#u{dV^F$b{L9&!2=9&RmV;;8s^x&UqB$PCj4FdKbh zoB1WTskPUPu05XzFbA}=KZ-GP1fPpAfSs>6AHb12UlR%-i&uOlTpFNS7{jm@mkU1V zh`nrXr~+^lsV-s1dkZOaI|kYyVj3WBpPCY{n~yd%u%e+d=f%`N0FItMPtdgBb@py; zq@v6NVArhyTC7)ULw-Jy8y42S1~4n(3LkrW8mW(F-4oXUP3E`e#g**YyqI7h-J2zK zK{m9##m4ri!7N>CqQqCcnI3hqo1I;Yh&QLNY4T`*ptiQGozK>FF$!$+84Z`xwmeMh zJ0WT+OH$WYFALEaGj2_l+#DC3t7_S`vHpSivNeFbP6+r50cO8iu)`7i%Z4BTPh@_m3Tk!nAm^)5Bqnr%Ov|Baunj#&RPtRuK& z4RGz|D5HNrW83-#ydk}tVKJrNmyYt-sTxLGlJY5nc&Re zU4SgHNPx8~Yxwr$bsju?4q&%T1874xxzq+_%?h8_ofw~(bld=o3iC)LUNR*BY%c0y zWd_jX{Y8`l%z+ol1$@Qa?Cy!(0CVIEeYpKZ`(9{z>3$CIe;pJDQk$m3p}$>xBm4lb zKo{4S)`wdU9Ba9jJbVJ0C=SOefZe%d$8=2r={nu<_^a3~>c#t_U6dye5)JrR(_a^E f@}b6j1K9lwFJq@>o)+Ry00000NkvXXu0mjfWa5j* literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/sync_on.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/sync_on.png new file mode 100644 index 0000000000000000000000000000000000000000..e08320fb64e6fa33b573005ed6d8fe294e19db76 GIT binary patch literal 845 zcmV-T1G4;yP)Y;xxyHF2B5Wzm| zOOGupOTn@c(JmBOl)e;XMNnZuiTJP>rM8<|Q`7I_))aP?*T)ow&n59{}X4$3Goat zgjs?*aasfbrokzG5cT4K=uG`E14xZl@z)F={P0Y^?$4t z>v!teRnNZym<6h{7sLyF1V0HsfEl+l6TrZpsfr1}luH~F7L}ktXu|*uVX^RG$L0`K zWs3j|0tIvVe(N%_?2{(iCPFGf#B6Hjy6o&}D$A%W%jfO8_W%ZO#-mh}EM$LMn7joJ z05dHr!5Y92g+31l<%i1(=L1a1pXX+OYnalY>31V4K}BjyRe3)9n#;-cCVRD_IG1fT zOKGeNY8q;TL@K{dj@D^scf&VCs*-Jb>8b>|`b*osv52-!A?BpbYtTQBns5EAU**$m zSnVSm(teh>tQi*S*A>#ySc=n;`BHz`DuG4&g4Kf8lLhca+zvZ7t7RflD6-i-mcK=M z!=^P$*u2)bkY5asG4gsss!Hn%u~>}kIW`vMs%lJLH+u*9<4PaV_c6U`KqWXQH%+Nu zTv41O(^ZVi@qhjQdG!fbZw&y+2o!iYymO^?ud3{P*HdoX83YV*Uu_HB=?U&W9%AU# z80}k1SS-CXTU7dcQlsm<^oYLxVSseqY6NO}dc`Nj?8vrhNuCdm@^{a3AQ_>6myOj+ z`1RsLUXF|dm|3k7s2jD(B{rzE>WI2scH8i1;=O5Cc9xB3^aJk%fQjqsu+kH#0=_5a z0nCE8@dbQa-|YIuUVvG0L_IwHMEhOj$Mj4Uq05 X8=0q~qBNan00000NkvXXu0mjfptF>5 literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/tab_a.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/tab_a.png new file mode 100644 index 0000000000000000000000000000000000000000..3b725c41c5a527a3a3e40097077d0e206a681247 GIT binary patch literal 142 zcmeAS@N?(olHy`uVBq!ia0vp^j6kfy!2~3aiye;!QlXwMjv*C{Z|8b*H5dputLHD# z=<0|*y7z(Vor?d;H&?EG&cXR}?!j-Lm&u1OOI7AIF5&c)RFE;&p0MYK>*Kl@eiymD r@|NpwKX@^z+;{u_Z~trSBfrMKa%3`zocFjEXaR$#tDnm{r-UW|TZ1%4 literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/tab_b.png b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/tab_b.png new file mode 100644 index 0000000000000000000000000000000000000000..e2b4a8638cb3496a016eaed9e16ffc12846dea18 GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^j6kfy!2~3aiye;!QU#tajv*C{Z}0l@H7kg?K0Lnr z!j&C6_(~HV9oQ0Pa6x{-v0AGV_E?vLn=ZI-;YrdjIl`U`uzuDWSP?o#Dmo{%SgM#oan kX~E1%D-|#H#QbHoIja2U-MgvsK&LQxy85}Sb4q9e0Efg%P5=M^ literal 0 HcmV?d00001 diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/tabs.css b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/tabs.css new file mode 100644 index 000000000..7d45d36c1 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/doc/html/tabs.css @@ -0,0 +1 @@ +.sm{position:relative;z-index:9999}.sm,.sm ul,.sm li{display:block;list-style:none;margin:0;padding:0;line-height:normal;direction:ltr;text-align:left;-webkit-tap-highlight-color:rgba(0,0,0,0)}.sm-rtl,.sm-rtl ul,.sm-rtl li{direction:rtl;text-align:right}.sm>li>h1,.sm>li>h2,.sm>li>h3,.sm>li>h4,.sm>li>h5,.sm>li>h6{margin:0;padding:0}.sm ul{display:none}.sm li,.sm a{position:relative}.sm a{display:block}.sm a.disabled{cursor:not-allowed}.sm:after{content:"\00a0";display:block;height:0;font:0px/0 serif;clear:both;visibility:hidden;overflow:hidden}.sm,.sm *,.sm *:before,.sm *:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.sm-dox{background-image:url("tab_b.png")}.sm-dox a,.sm-dox a:focus,.sm-dox a:hover,.sm-dox a:active{padding:0px 12px;padding-right:43px;font-family:"Lucida Grande","Geneva","Helvetica",Arial,sans-serif;font-size:13px;font-weight:bold;line-height:36px;text-decoration:none;text-shadow:0px 1px 1px rgba(255,255,255,0.9);color:#283A5D;outline:none}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:#fff;text-shadow:0px 1px 1px #000}.sm-dox a.current{color:#D23600}.sm-dox a.disabled{color:#bbb}.sm-dox a span.sub-arrow{position:absolute;top:50%;margin-top:-14px;left:auto;right:3px;width:28px;height:28px;overflow:hidden;font:bold 12px/28px monospace !important;text-align:center;text-shadow:none;background:rgba(255,255,255,0.5);border-radius:5px}.sm-dox a.highlighted span.sub-arrow:before{display:block;content:'-'}.sm-dox>li:first-child>a,.sm-dox>li:first-child>:not(ul) a{border-radius:5px 5px 0 0}.sm-dox>li:last-child>a,.sm-dox>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul{border-radius:0 0 5px 5px}.sm-dox>li:last-child>a.highlighted,.sm-dox>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted{border-radius:0}.sm-dox ul{background:rgba(162,162,162,0.1)}.sm-dox ul a,.sm-dox ul a:focus,.sm-dox ul a:hover,.sm-dox ul a:active{font-size:12px;border-left:8px solid transparent;line-height:36px;text-shadow:none;background-color:white;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:#fff;text-shadow:0px 1px 1px #000}.sm-dox ul ul a,.sm-dox ul ul a:hover,.sm-dox ul ul a:focus,.sm-dox ul ul a:active{border-left:16px solid transparent}.sm-dox ul ul ul a,.sm-dox ul ul ul a:hover,.sm-dox ul ul ul a:focus,.sm-dox ul ul ul a:active{border-left:24px solid transparent}.sm-dox ul ul ul ul a,.sm-dox ul ul ul ul a:hover,.sm-dox ul ul ul ul a:focus,.sm-dox ul ul ul ul a:active{border-left:32px solid transparent}.sm-dox ul ul ul ul ul a,.sm-dox ul ul ul ul ul a:hover,.sm-dox ul ul ul ul ul a:focus,.sm-dox ul ul ul ul ul a:active{border-left:40px solid transparent}@media (min-width: 768px){.sm-dox ul{position:absolute;width:12em}.sm-dox li{float:left}.sm-dox.sm-rtl li{float:right}.sm-dox ul li,.sm-dox.sm-rtl ul li,.sm-dox.sm-vertical li{float:none}.sm-dox a{white-space:nowrap}.sm-dox ul a,.sm-dox.sm-vertical a{white-space:normal}.sm-dox .sm-nowrap>li>a,.sm-dox .sm-nowrap>li>:not(ul) a{white-space:nowrap}.sm-dox{padding:0 10px;background-image:url("tab_b.png");line-height:36px}.sm-dox a span.sub-arrow{top:50%;margin-top:-2px;right:12px;width:0;height:0;border-width:4px;border-style:solid dashed dashed dashed;border-color:#283A5D transparent transparent transparent;background:transparent;border-radius:0}.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted{padding:0px 12px;background-image:url("tab_s.png");background-repeat:no-repeat;background-position:right;border-radius:0 !important}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:#fff;text-shadow:0px 1px 1px #000}.sm-dox a:hover span.sub-arrow{border-color:#fff transparent transparent transparent}.sm-dox a.has-submenu{padding-right:24px}.sm-dox li{border-top:0}.sm-dox>li>ul:before,.sm-dox>li>ul:after{content:'';position:absolute;top:-18px;left:30px;width:0;height:0;overflow:hidden;border-width:9px;border-style:dashed dashed solid dashed;border-color:transparent transparent #bbb transparent}.sm-dox>li>ul:after{top:-16px;left:31px;border-width:8px;border-color:transparent transparent #fff transparent}.sm-dox ul{border:1px solid #bbb;padding:5px 0;background:#fff;border-radius:5px !important;box-shadow:0 5px 9px rgba(0,0,0,0.2)}.sm-dox ul a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-color:transparent transparent transparent #555;border-style:dashed dashed dashed solid}.sm-dox ul a,.sm-dox ul a:hover,.sm-dox ul a:focus,.sm-dox ul a:active,.sm-dox ul a.highlighted{color:#555;background-image:none;border:0 !important;color:#555;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:#fff;text-shadow:0px 1px 1px #000}.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent #fff}.sm-dox span.scroll-up,.sm-dox span.scroll-down{position:absolute;display:none;visibility:hidden;overflow:hidden;background:#fff;height:36px}.sm-dox span.scroll-up:hover,.sm-dox span.scroll-down:hover{background:#eee}.sm-dox span.scroll-up:hover span.scroll-up-arrow,.sm-dox span.scroll-up:hover span.scroll-down-arrow{border-color:transparent transparent #D23600 transparent}.sm-dox span.scroll-down:hover span.scroll-down-arrow{border-color:#D23600 transparent transparent transparent}.sm-dox span.scroll-up-arrow,.sm-dox span.scroll-down-arrow{position:absolute;top:0;left:50%;margin-left:-6px;width:0;height:0;overflow:hidden;border-width:6px;border-style:dashed dashed solid dashed;border-color:transparent transparent #555 transparent}.sm-dox span.scroll-down-arrow{top:8px;border-style:solid dashed dashed dashed;border-color:#555 transparent transparent transparent}.sm-dox.sm-rtl a.has-submenu{padding-right:12px;padding-left:24px}.sm-dox.sm-rtl a span.sub-arrow{right:auto;left:12px}.sm-dox.sm-rtl.sm-vertical a.has-submenu{padding:10px 20px}.sm-dox.sm-rtl.sm-vertical a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-rtl>li>ul:before{left:auto;right:30px}.sm-dox.sm-rtl>li>ul:after{left:auto;right:31px}.sm-dox.sm-rtl ul a.has-submenu{padding:10px 20px !important}.sm-dox.sm-rtl ul a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-vertical{padding:10px 0;border-radius:5px}.sm-dox.sm-vertical a{padding:10px 20px}.sm-dox.sm-vertical a:hover,.sm-dox.sm-vertical a:focus,.sm-dox.sm-vertical a:active,.sm-dox.sm-vertical a.highlighted{background:#fff}.sm-dox.sm-vertical a.disabled{background-image:url("tab_b.png")}.sm-dox.sm-vertical a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-style:dashed dashed dashed solid;border-color:transparent transparent transparent #555}.sm-dox.sm-vertical>li>ul:before,.sm-dox.sm-vertical>li>ul:after{display:none}.sm-dox.sm-vertical ul a{padding:10px 20px}.sm-dox.sm-vertical ul a:hover,.sm-dox.sm-vertical ul a:focus,.sm-dox.sm-vertical ul a:active,.sm-dox.sm-vertical ul a.highlighted{background:#eee}.sm-dox.sm-vertical ul a.disabled{background:#fff}} diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/manual.md b/core/arch/arm/plat-rz/common/drivers/r_rsip/manual.md new file mode 100644 index 000000000..4fe0308c0 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/manual.md @@ -0,0 +1 @@ +See [R_RSIP Documentation](doc/html/index.html) diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/inc/api/r_rsip_api.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/inc/api/r_rsip_api.h new file mode 100644 index 000000000..8211ddee3 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/inc/api/r_rsip_api.h @@ -0,0 +1,521 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @ingroup RENESAS_INTERFACES + * @defgroup RSIP_API RSIP Interface + * @brief Interface for Renesas Secure IP (RSIP) functions. + * + * @section RSIP_API_Summary Summary + * The RSIP interface provides RSIP functionality. + * + * The RSIP interface can be implemented by: + * - @ref RSIP + * + * @{ + **********************************************************************************************************************/ + +#ifndef R_RSIP_API_H +#define R_RSIP_API_H + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ + +/* Register definitions, common services and error codes. */ +#include "bsp_api.h" + +/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */ +FSP_HEADER + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* Return code */ +#define FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT (0x10100) ///< Hardware resource is busy +#define FSP_ERR_CRYPTO_RSIP_FATAL (0x10101) ///< Hardware fatal error or unexpected return +#define FSP_ERR_CRYPTO_RSIP_FAIL (0x10102) ///< Internal error +#define FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL (0x10103) ///< Input key type is illegal +#define FSP_ERR_CRYPTO_RSIP_AUTHENTICATION (0x10104) ///< Authentication failed + +/* Return code for SB-Lib */ +#define FSP_ERR_SB_INTERNAL_FAIL (0x00030000UL) ///< An internal failure +#define FSP_ERR_SB_INVALID_ARG (0x00030001UL) ///< An invalid argument was entered +#define FSP_ERR_SB_UNSUPPORTED_FUNCTION (0x00030002UL) ///< Unsupported function executed +#define FSP_ERR_SB_INVALID_ALIGNMENT (0x00030003UL) ///< Data entered with incorrect alignment +#define FSP_ERR_SB_MANI_INVALID_MAGIC (0x00031000UL) ///< An invalid magic number is set +#define FSP_ERR_SB_MANI_UNSUPPORTED_VERSION (0x00031001UL) ///< Unsupported version is set +#define FSP_ERR_SB_MANI_OUT_OF_RANGE_LEN (0x00031002UL) ///< Out of range TLV Length is set +#define FSP_ERR_SB_MANI_TLV_FIELD_ERR (0x00031003UL) ///< Missing required TLV field +#define FSP_ERR_SB_MANI_TLV_INVALID_LEN (0x00031004UL) ///< The length exceeding the end of the manifest is specified in length of the TLV field +#define FSP_ERR_SB_MANI_INVALID_IMAGE_LEN (0x00031005UL) ///< An invalid image length is set +#define FSP_ERR_SB_MANI_MISMATCH_SIGN_ALGORITHM (0x00031006UL) ///< There is a wrong combination of signature algorithms +#define FSP_ERR_SB_MANI_UNSUPPORTED_ALGORITHM (0x00031007UL) ///< An algorithm was specified that the manifest does not support +#define FSP_ERR_SB_CRYPTO_FAIL (0x00032000UL) ///< Cryptographic processing failure +#define FSP_ERR_SB_CRYPTO_AUTH_FAIL (0x00032001UL) ///< Verification failed +#define FSP_ERR_SB_CRYPTO_UNSUPPORTED_ALGORITHM (0x00032002UL) ///< Unsupported algorithm +#define FSP_ERR_SB_CRYPTO_RESOURCE_CONFLICT (0x00032003UL) ///< CryptoIP is in use. +#define FSP_ERR_SB_CRYPTO_PARAM_ERR (0x00032004UL) ///< Parameter error + +/* RSA salt length */ + +/** + * When signing, the salt length is set to @ref RSIP_RSA_SALT_LENGTH_MAX or @ref RSIP_RSA_SALT_LENGTH_HASH, + * whichever is shorter. When verifying, the salt length is detected automatically. + */ +#define RSIP_RSA_SALT_LENGTH_AUTO (-1) + +/** + * The salt length is set to the hash length. + */ +#define RSIP_RSA_SALT_LENGTH_HASH (-2) + +/** + * The salt length is set to emLen - hLen - 2, where emLen is the same as the key length and hLen is the hash length. + */ +#define RSIP_RSA_SALT_LENGTH_MAX (-3) + +/* For internal use */ +#define RSIP_BYTE_SIZE_SHA_MESSAGE_BUFFER (128U) // rsip_sha_handle_t, rsip_hmac_handle_t +#define RSIP_WORD_SIZE_SHA_INTERNAL_STATE (20U) // rsip_sha_handle_t, rsip_hmac_handle_t + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/** + * Key types + * @deprecated + * - The following member will be renamed in the next major update. + * - @ref RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC to RSIP_KEY_TYPE_ECC_SECP192R1_PUBLIC + * - @ref RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE to RSIP_KEY_TYPE_ECC_SECP192R1_PRIVATE + * - @ref RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC to RSIP_KEY_TYPE_ECC_SECP224R1_PUBLIC + * - @ref RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE to RSIP_KEY_TYPE_ECC_SECP224R1_PRIVATE + * - @ref RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC to RSIP_KEY_TYPE_ECC_SECP256R1_PUBLIC + * - @ref RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE to RSIP_KEY_TYPE_ECC_SECP256R1_PRIVATE + */ +typedef enum e_rsip_key_type +{ + RSIP_KEY_TYPE_INVALID, ///< Invalid key + + RSIP_KEY_TYPE_AES_128, ///< AES-128 + RSIP_KEY_TYPE_AES_256, ///< AES-256 + + RSIP_KEY_TYPE_AES_128_XTS, ///< AES-128-XTS + RSIP_KEY_TYPE_AES_256_XTS, ///< AES-256-XTS + + RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC, ///< secp192r1 public key (also known as NIST P-192, prime192v1) + RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE, ///< secp192r1 private key (also known as NIST P-192, prime192v1) + RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC, ///< secp224r1 public key (also known as NIST P-224, prime224v1) + RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE, ///< secp224r1 private key (also known as NIST P-224, prime224v1) + RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC, ///< secp256r1 public key (also known as NIST P-256, prime256v1) + RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE, ///< secp256r1 private key (also known as NIST P-256, prime256v1) + + RSIP_KEY_TYPE_HMAC_SHA1, ///< HMAC-SHA1 + RSIP_KEY_TYPE_HMAC_SHA224, ///< HMAC-SHA224 + RSIP_KEY_TYPE_HMAC_SHA256, ///< HMAC-SHA256 + + RSIP_KEY_TYPE_KEY_UPDATE_KEY, ///< KUK (Key Update Key) + + RSIP_KEY_TYPE_SECURE_BOOT_DECRYPTION, ///< Image decryption key for secure boot (supported devices only) + + RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED, ///< RSA-1024 public key + RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED, ///< RSA-1024 private key + RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED, ///< RSA-2048 public key + RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED, ///< RSA-2048 private key + RSIP_KEY_TYPE_RSA_3072_PUBLIC, ///< RSA-3072 public key + RSIP_KEY_TYPE_RSA_3072_PRIVATE, ///< RSA-3072 private key + RSIP_KEY_TYPE_RSA_4096_PUBLIC, ///< RSA-4096 public key + RSIP_KEY_TYPE_RSA_4096_PRIVATE, ///< RSA-4096 private key + + RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC, ///< brainpoolP256r1 public key + RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE, ///< brainpoolP256r1 private key + + RSIP_KEY_TYPE_NUM, // Number of key types + + RSIP_KEY_TYPE_MAKE_ENUM_LONG = 0xFFFFFFFFUL // Make this enum 32-bit data +} rsip_key_type_t; + +/** + * Key pair types + * @deprecated + * - The following member will be renamed in the next major update. + * - @ref RSIP_KEY_PAIR_TYPE_ECC_secp192r1 to RSIP_KEY_PAIR_TYPE_ECC_SECP192R1 + * - @ref RSIP_KEY_PAIR_TYPE_ECC_secp224r1 to RSIP_KEY_PAIR_TYPE_ECC_SECP224R1 + * - @ref RSIP_KEY_PAIR_TYPE_ECC_secp256r1 to RSIP_KEY_PAIR_TYPE_ECC_SECP256R1 + */ +typedef enum e_rsip_key_pair_type +{ + RSIP_KEY_PAIR_TYPE_INVALID, ///< Invalid key pair type + + RSIP_KEY_PAIR_TYPE_ECC_secp192r1, ///< secp192r1 key pair (also known as NIST P-192, prime192v1) + RSIP_KEY_PAIR_TYPE_ECC_secp224r1, ///< secp224r1 key pair (also known as NIST P-224, prime224v1) + RSIP_KEY_PAIR_TYPE_ECC_secp256r1, ///< secp256r1 key pair (also known as NIST P-256, prime256v1) + RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1, ///< brainpoolP256r1 key pair + + RSIP_KEY_PAIR_TYPE_RSA_1024, ///< RSA-1024 key pair + RSIP_KEY_PAIR_TYPE_RSA_2048, ///< RSA-2048 key pair + RSIP_KEY_PAIR_TYPE_RSA_3072, ///< RSA-3072 key pair + RSIP_KEY_PAIR_TYPE_RSA_4096, ///< RSA-4096 key pair + + RSIP_KEY_PAIR_TYPE_NUM // Number of key pair types +} rsip_key_pair_type_t; + +/** Block cipher modes of operation for AES */ +typedef enum e_rsip_aes_mode +{ + RSIP_AES_MODE_ECB, ///< ECB (Electronic codebook) + RSIP_AES_MODE_CBC, ///< CBC (Cipher block chaining) + RSIP_AES_MODE_CTR, ///< CTR (Counter) + RSIP_AES_MODE_XTS ///< XTS (XEX-based tweaked-codebook mode with ciphertext stealing) +} rsip_aes_mode_t; + +/** Hash type */ +typedef enum e_rsip_hash_type +{ + RSIP_HASH_TYPE_SHA1, ///< SHA-1 + RSIP_HASH_TYPE_SHA224, ///< SHA-224 + RSIP_HASH_TYPE_SHA256, ///< SHA-256 + RSIP_HASH_TYPE_SHA384, ///< SHA-384 + RSIP_HASH_TYPE_SHA512, ///< SHA-512 + RSIP_HASH_TYPE_SHA512_224, ///< SHA-512/224 + RSIP_HASH_TYPE_SHA512_256 ///< SHA-512/256 +} rsip_hash_type_t; + +/** MGF type */ +typedef enum e_rsip_mgf_type +{ + RSIP_MGF_TYPE_MGF1_SHA1 = RSIP_HASH_TYPE_SHA1, ///< MGF1 with SHA-1 + RSIP_MGF_TYPE_MGF1_SHA224 = RSIP_HASH_TYPE_SHA224, ///< MGF1 with SHA-224 + RSIP_MGF_TYPE_MGF1_SHA256 = RSIP_HASH_TYPE_SHA256, ///< MGF1 with SHA-256 + RSIP_MGF_TYPE_MGF1_SHA384 = RSIP_HASH_TYPE_SHA384, ///< MGF1 with SHA-384 + RSIP_MGF_TYPE_MGF1_SHA512 = RSIP_HASH_TYPE_SHA512, ///< MGF1 with SHA-512 + RSIP_MGF_TYPE_MGF1_SHA512_224 = RSIP_HASH_TYPE_SHA512_224, ///< MGF1 with SHA-512/224 + RSIP_MGF_TYPE_MGF1_SHA512_256 = RSIP_HASH_TYPE_SHA512_256 ///< MGF1 with SHA-512/256 +} rsip_mgf_type_t; + +/** Password type. This enumerated type is used only on specific devices. */ +typedef enum e_password_type +{ + RSIP_PASSWORD_TYPE_JTAG_DEBUG_AUTHENTICATION_LEVEL1, ///< JTAG debug authentication level 1 + RSIP_PASSWORD_TYPE_JTAG_DEBUG_AUTHENTICATION_LEVEL2, ///< JTAG debug authentication level 2 +} rsip_password_type_t; + +/* State that specifies functions that can be called next. This enum is private. */ +typedef enum e_rsip_user_handle_state +{ + RSIP_USER_HANDLE_STATE_INIT, // Init function can be called. + RSIP_USER_HANDLE_STATE_UPDATE_EMPTY, // Update and Final function can be called. No data has been entered yet. + RSIP_USER_HANDLE_STATE_UPDATE // Update and Final function can be called. Some data has been entered. +} rsip_user_handle_state_t; + +/** Wrapped key structure for all supported algorithms. The struct length of each algorithm is defined by RSIP_BYTE_SIZE_WRAPPED_KEY macro. */ +typedef struct st_rsip_wrapped_key +{ + rsip_key_type_t type; ///< type of wrapped key + uint8_t value[]; ///< variable length array to store the key value +} rsip_wrapped_key_t; + +/** + * Byte size of encrypted key + * @deprecated + * - The following member will be renamed in the next major update. + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PUBLIC to RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_SECP192R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PRIVATE to RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_SECP192R1_PRIVATE + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PUBLIC to RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_SECP224R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PRIVATE to RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_SECP224R1_PRIVATE + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PUBLIC to RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_SECP256R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PRIVATE to RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_SECP256R1_PRIVATE + * - The following member will be obsoleted in the next major update. + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_MAX + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PUBLIC_MAX + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PRIVATE_MAX + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PUBLIC_MAX + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PRIVATE_MAX + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_MAX + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_MAX + */ +typedef enum e_rsip_byte_size_encrypted_key +{ + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128 = 32U, ///< AES-128 + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256 = 48U, ///< AES-256 + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128_XTS = 48U, ///< AES-128-XTS + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256_XTS = 80U, ///< AES-256-XTS + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PUBLIC = 80U, ///< secp192r1 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PRIVATE = 48U, ///< secp192r1 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PUBLIC = 80U, ///< secp224r1 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PRIVATE = 48U, ///< secp224r1 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PUBLIC = 80U, ///< secp256r1 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PRIVATE = 48U, ///< secp256r1 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PUBLIC = 80U, ///< brainpoolP256r1 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PRIVATE = 48U, ///< brainpoolP256r1 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PUBLIC_ENHANCED = 160U, ///< RSA-1024 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PRIVATE_ENHANCED = 272U, ///< RSA-1024 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PUBLIC_ENHANCED = 288U, ///< RSA-2048 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PRIVATE_ENHANCED = 528U, ///< RSA-2048 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PUBLIC = 416U, ///< RSA-3072 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PRIVATE = 784U, ///< RSA-3072 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PUBLIC = 544U, ///< RSA-4096 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PRIVATE = 1040U, ///< RSA-4096 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA1 = 48U, ///< HMAC-SHA1 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA224 = 48U, ///< HMAC-SHA224 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA256 = 48U, ///< HMAC-SHA256 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_KEY_UPDATE_KEY = 48U, ///< Key Update Key (KUK) + + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256_XTS, ///< Maximum length in AES keys + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PUBLIC_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PUBLIC, ///< Maximum length in ECC public keys + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PRIVATE_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PRIVATE, ///< Maximum length in ECC private keys + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PUBLIC_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PUBLIC, ///< Maximum length in RSA public keys + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PRIVATE_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PRIVATE, ///< Maximum length in RSA private keys + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA256, ///< Maximum length in HMAC keys + RSIP_BYTE_SIZE_ENCRYPTED_KEY_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PRIVATE_MAX, ///< Maximum length in all RSIP keys +} rsip_byte_size_encrypted_key_t; + +/** Byte size of wrapped key (value) + * @deprecated + * - The following member will be renamed in the next major update. + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PUBLIC to RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_SECP192R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PRIVATE to RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_SECP192R1_PRIVATE + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PUBLIC to RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_SECP224R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PRIVATE to RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_SECP224R1_PRIVATE + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PUBLIC to RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_SECP256R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PRIVATE to RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_SECP256R1_PRIVATE + * - The following member will be obsoleted in the next major update. + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PUBLIC_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PRIVATE_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PUBLIC_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PRIVATE_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_MAX + */ +typedef enum e_rsip_byte_size_wrapped_key_value +{ + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128 = 48U, ///< AES-128 + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256 = 64U, ///< AES-256 + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128_XTS = 64U, ///< AES-128-XTS + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256_XTS = 96U, ///< AES-256-XTS + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PUBLIC = 96U, ///< secp192r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PRIVATE = 64U, ///< secp192r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PUBLIC = 96U, ///< secp224r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PRIVATE = 64U, ///< secp224r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PUBLIC = 96U, ///< secp256r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PRIVATE = 64U, ///< secp256r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PUBLIC = 96U, ///< brainpoolP256r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PRIVATE = 64U, ///< brainpoolP256r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PUBLIC_ENHANCED = 176U, ///< RSA-1024 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PRIVATE_ENHANCED = 288U, ///< RSA-1024 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PUBLIC_ENHANCED = 304U, ///< RSA-2048 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PRIVATE_ENHANCED = 544U, ///< RSA-2048 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PUBLIC = 432U, ///< RSA-3072 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PRIVATE = 800U, ///< RSA-3072 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PUBLIC = 560U, ///< RSA-4096 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PRIVATE = 1056U, ///< RSA-4096 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA1 = 64U, ///< HMAC-SHA1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA224 = 64U, ///< HMAC-SHA224 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA256 = 64U, ///< HMAC-SHA256 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_KEY_UPDATE_KEY = 64U, ///< Key Update Key (KUK) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256_XTS, ///< Maximum length in AES keys + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PUBLIC_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PUBLIC, ///< Maximum length in ECC public keys + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PRIVATE_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PRIVATE, ///< Maximum length in ECC private keys + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PUBLIC_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PUBLIC, ///< Maximum length in RSA public keys + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PRIVATE_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PRIVATE, ///< Maximum length in RSA private keys + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA256, ///< Maximum length in HMAC keys + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PRIVATE_MAX, ///< Maximum length in all RSIP keys +} rsip_byte_size_wrapped_key_value_t; + +/** + * Byte size of wrapped key (header + value) + * @deprecated + * - The following member will be renamed in the next major update. + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PUBLIC to RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_SECP192R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PRIVATE to RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_SECP192R1_PRIVATE + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PUBLIC to RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_SECP224R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PRIVATE to RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_SECP224R1_PRIVATE + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC to RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_SECP256R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE to RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_SECP256R1_PRIVATE + * - The following member will be obsoleted in the next major update. + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_AES_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PUBLIC_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PRIVATE_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PUBLIC_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PRIVATE_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_MAX + */ +typedef enum e_rsip_byte_size_wrapped_key +{ + RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128 = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128, ///< AES-128 + RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256 = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256, ///< AES-256 + RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128_XTS = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128_XTS, ///< AES-128-XTS + RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256_XTS = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256_XTS, ///< AES-256-XTS + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PUBLIC = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PUBLIC, ///< secp192r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PRIVATE = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PRIVATE, ///< secp192r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PUBLIC = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PUBLIC, ///< secp224r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PRIVATE = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PRIVATE, ///< secp224r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PUBLIC, ///< secp256r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PRIVATE, ///< secp256r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PUBLIC = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PUBLIC, ///< brainpoolP256r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PRIVATE = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PRIVATE, ///< brainpoolP256r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PUBLIC_ENHANCED, ///< RSA-1024 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PRIVATE_ENHANCED, ///< RSA-1024 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PUBLIC_ENHANCED, ///< RSA-2048 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PRIVATE_ENHANCED, ///< RSA-2048 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PUBLIC, ///< RSA-3072 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PRIVATE, ///< RSA-3072 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PUBLIC, ///< RSA-4096 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PRIVATE, ///< RSA-4096 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA1 = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA1, ///< HMAC-SHA1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA224 = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA224, ///< HMAC-SHA224 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA256 = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA256, ///< HMAC-SHA256 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_KEY_UPDATE_KEY = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_KEY_UPDATE_KEY, ///< Key Update Key (KUK) + + RSIP_BYTE_SIZE_WRAPPED_KEY_AES_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256_XTS, ///< Maximum length in AES keys + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PUBLIC_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC, ///< Maximum length in ECC public keys + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PRIVATE_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE, ///< Maximum length in ECC private keys + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PUBLIC_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC, ///< Maximum length in RSA public keys + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PRIVATE_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE, ///< Maximum length in RSA private keys + RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA256, ///< Maximum length in HMAC keys + RSIP_BYTE_SIZE_WRAPPED_KEY_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PRIVATE_MAX, ///< Maximum length in all RSIP keys +} rsip_byte_size_wrapped_key_t; + +/** Working area for SHA cipher functions. DO NOT MODIFY. */ +typedef struct st_rsip_sha_handle +{ + rsip_hash_type_t type; // Hash type + uint8_t buffer[RSIP_BYTE_SIZE_SHA_MESSAGE_BUFFER]; // Stored message + uint32_t buffered_length; // Buffered message length + uint32_t total_length; // Total message length input to primitive + uint32_t block_size; // Block size + rsip_user_handle_state_t state; // Handle state + uint32_t internal_state[RSIP_WORD_SIZE_SHA_INTERNAL_STATE]; // Internal state +} rsip_sha_handle_t; + +/** Working area for HMAC cipher functions. DO NOT MODIFY. */ +typedef struct st_rsip_hmac_handle +{ + const void * p_primitive; // Pointer to primitive functions + uint8_t wrapped_key[RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_MAX]; // Stored wrapped key + uint8_t buffer[RSIP_BYTE_SIZE_SHA_MESSAGE_BUFFER]; // Stored message + uint32_t buffered_length; // Buffered message length + uint32_t total_length; // Total message length input to primitive + uint32_t block_size; // Block size + rsip_user_handle_state_t state; // Handle state + uint32_t internal_state[RSIP_WORD_SIZE_SHA_INTERNAL_STATE]; // Internal state + bool is_generate; // true: generate, false: verify +} rsip_hmac_handle_t; + +/** RSIP Control block. Allocate an instance specific control block to pass into the API calls. + * @par Implemented as + * - rsip_instance_ctrl_t + */ +typedef void rsip_ctrl_t; + +/** User configuration structure, used in open function */ +typedef struct st_rsip_cfg +{ + void const * p_extend; ///< Hardware-dependent configuration +} rsip_cfg_t; + +/** This structure encompasses everything that is needed to use an instance of this interface. */ +typedef struct st_rsip_instance +{ + rsip_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance + rsip_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance +} rsip_instance_t; + +/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */ +FSP_FOOTER + +#endif /* R_RSIP_API_H */ + +/*******************************************************************************************************************//** + * @} (end addtogroup RSIP_API) + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/inc/instances/r_rsip.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/inc/instances/r_rsip.h new file mode 100644 index 000000000..9a22e908f --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/inc/instances/r_rsip.h @@ -0,0 +1,342 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @addtogroup RSIP + * @{ + **********************************************************************************************************************/ + +#ifndef R_RSIP_H +#define R_RSIP_H + +#include "bsp_api.h" +#include "r_rsip_cfg.h" +#include "r_rsip_api.h" + +/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */ +FSP_HEADER + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +#define RSIP_BYTE_SIZE_AES_BLOCK (16U) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/* Handle of algorithms that cannot be suspended. This union is included in private control block. */ +typedef union u_rsip_handle +{ + struct + { + const void * p_primitive; // Pointer to primitive functions + } aes; + struct + { + const void * p_primitive; // Pointer to primitive functions + uint8_t buffer[RSIP_BYTE_SIZE_AES_BLOCK * 2]; // Buffer for computing final partial block + uint32_t buffered_length; // Length of second to last and final partial block + } xts; + struct + { + const void * p_primitive; // Pointer to primitive functions + uint8_t buffer[RSIP_BYTE_SIZE_AES_BLOCK]; // Buffer for AAD or plaintext/ciphertext + uint32_t buffered_length; // Buffered AAD or plaintext/ciphertext length + uint32_t total_length; // Total plaintext/ciphertext length + uint32_t total_aad_length; // Total AAD length + bool has_finished_aad_input; // Whether AAD input has been finished + } gcm; + struct + { + const void * p_primitive; // Pointer to primitive functions + uint8_t buffer[RSIP_BYTE_SIZE_AES_BLOCK]; // Buffer for message + uint32_t buffered_length; // Buffered message length + uint32_t total_length; // Total message length + } cmac; +} rsip_handle_t; + +/* Types of algorithm being execute */ +typedef enum e_rsip_handle_type +{ + RSIP_HANDLE_TYPE_INVALID, // Invalid handle type + RSIP_HANDLE_TYPE_AES_ENCRYPT, // AES-ECB/CBC/CTR encryption + RSIP_HANDLE_TYPE_AES_DECRYPT, // AES-ECB/CBC/CTR decryption + RSIP_HANDLE_TYPE_XTS_ENCRYPT, // AES-XTS encryption + RSIP_HANDLE_TYPE_XTS_DECRYPT, // AES-XTS decryption + RSIP_HANDLE_TYPE_GCM_ENCRYPT, // AES-GCM encryption + RSIP_HANDLE_TYPE_GCM_DECRYPT, // AES-GCM decryption + RSIP_HANDLE_TYPE_CMAC_GENERATE, // AES-CMAC MAC generation + RSIP_HANDLE_TYPE_CMAC_VERIFY // AES-CMAC MAC verification +} rsip_handle_type_t; + +/* State that specifies functions that can be called next */ +typedef enum e_rsip_state +{ + RSIP_STATE_INIT, // All Init function or single-part function can be called + RSIP_STATE_UPDATE, // Update and Final function related to the executing algorithm can be called + RSIP_STATE_FINAL // Final function related to the executing algorithm can be called +} rsip_state_t; + +/** RSIP private control block. DO NOT MODIFY. Initialization occurs when R_RSIP_Open() is called. */ +typedef struct st_rsip_instance_ctrl +{ + uint32_t open; // Indicates whether the open() API has been successfully + rsip_cfg_t const * p_cfg; // Pointer to the configuration block + rsip_handle_t handle; // Handle of algorithms that cannot be suspended + rsip_handle_type_t handle_type; // Current handle type + rsip_state_t state; // Flags to limit the next API to call +} rsip_instance_ctrl_t; + +/********************************************************************************************************************** + * Exported global variables + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Public Function Prototypes + **********************************************************************************************************************/ + +/* r_rsip.c */ +fsp_err_t R_RSIP_Open(rsip_ctrl_t * const p_ctrl, rsip_cfg_t const * const p_cfg); +fsp_err_t R_RSIP_Close(rsip_ctrl_t * const p_ctrl); +fsp_err_t R_RSIP_RandomNumberGenerate(rsip_ctrl_t * const p_ctrl, uint8_t * const p_random); +fsp_err_t R_RSIP_KeyGenerate(rsip_ctrl_t * const p_ctrl, + rsip_key_type_t const key_type, + rsip_wrapped_key_t * const p_wrapped_key); +fsp_err_t R_RSIP_KeyPairGenerate(rsip_ctrl_t * const p_ctrl, + rsip_key_pair_type_t const key_pair_type, + rsip_wrapped_key_t * const p_wrapped_public_key, + rsip_wrapped_key_t * const p_wrapped_private_key); +fsp_err_t R_RSIP_KeyImportWithKUK(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_key_update_key, + uint8_t const * const p_initial_vector, + rsip_key_type_t const key_type, + uint8_t const * const p_encrypted_key, + rsip_wrapped_key_t * const p_wrapped_key); +fsp_err_t R_RSIP_ECCPublicKeyExport(rsip_wrapped_key_t const * const p_wrapped_public_key, + uint8_t const ** const pp_raw_public_key_qx, + uint8_t const ** const pp_raw_public_key_qy); +fsp_err_t R_RSIP_RSAPublicKeyExport(rsip_wrapped_key_t const * const p_wrapped_public_key, + uint8_t const ** const pp_raw_public_key_n, + uint8_t const ** const pp_raw_public_key_e); + +/* r_rsip_aes.c */ +fsp_err_t R_RSIP_AES_Cipher_EncryptInit(rsip_ctrl_t * const p_ctrl, + rsip_aes_mode_t const mode, + rsip_wrapped_key_t const * const p_wrapped_key, + uint8_t const * const p_initial_vector); +fsp_err_t R_RSIP_AES_Cipher_EncryptUpdate(rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_plain, + uint8_t * const p_cipher, + uint32_t const plain_length); +fsp_err_t R_RSIP_AES_Cipher_EncryptFinal(rsip_ctrl_t * const p_ctrl, + uint8_t * const p_cipher, + uint32_t * const p_cipher_length); +fsp_err_t R_RSIP_AES_Cipher_DecryptInit(rsip_ctrl_t * const p_ctrl, + rsip_aes_mode_t const mode, + rsip_wrapped_key_t const * const p_wrapped_key, + uint8_t const * const p_initial_vector); +fsp_err_t R_RSIP_AES_Cipher_DecryptUpdate(rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_cipher, + uint8_t * const p_plain, + uint32_t const cipher_length); +fsp_err_t R_RSIP_AES_Cipher_DecryptFinal(rsip_ctrl_t * const p_ctrl, + uint8_t * const p_plain, + uint32_t * const p_plain_length); +fsp_err_t R_RSIP_AES_GCM_EncryptInit(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_key, + uint8_t const * const p_nonce, + uint32_t const nonce_length); +fsp_err_t R_RSIP_AES_GCM_EncryptUpdate(rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_plain, + uint8_t * const p_cipher, + uint32_t const plain_length, + uint8_t const * const p_aad, + uint32_t const aad_length); +fsp_err_t R_RSIP_AES_GCM_EncryptFinal(rsip_ctrl_t * const p_ctrl, + uint8_t * const p_cipher, + uint32_t * const p_cipher_length, + uint8_t * const p_tag); +fsp_err_t R_RSIP_AES_GCM_DecryptInit(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_key, + uint8_t const * const p_nonce, + uint32_t const nonce_length); +fsp_err_t R_RSIP_AES_GCM_DecryptUpdate(rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_cipher, + uint8_t * const p_plain, + uint32_t const cipher_length, + uint8_t const * const p_aad, + uint32_t const aad_length); +fsp_err_t R_RSIP_AES_GCM_DecryptFinal(rsip_ctrl_t * const p_ctrl, + uint8_t * const p_plain, + uint32_t * const p_plain_length, + uint8_t const * const p_tag, + uint32_t const tag_length); +fsp_err_t R_RSIP_AES_CMAC_GenerateInit(rsip_ctrl_t * const p_ctrl, rsip_wrapped_key_t const * const p_wrapped_key); +fsp_err_t R_RSIP_AES_CMAC_GenerateUpdate(rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_message, + uint32_t const message_length); +fsp_err_t R_RSIP_AES_CMAC_GenerateFinal(rsip_ctrl_t * const p_ctrl, uint8_t * const p_mac); +fsp_err_t R_RSIP_AES_CMAC_VerifyInit(rsip_ctrl_t * const p_ctrl, rsip_wrapped_key_t const * const p_wrapped_key); +fsp_err_t R_RSIP_AES_CMAC_VerifyUpdate(rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_message, + uint32_t const message_length); +fsp_err_t R_RSIP_AES_CMAC_VerifyFinal(rsip_ctrl_t * const p_ctrl, uint8_t const * const p_mac, + uint32_t const mac_length); + +/* r_rsip_ecc.c */ +fsp_err_t R_RSIP_ECDSA_Sign(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_private_key, + uint8_t const * const p_hash, + uint8_t * const p_signature); +fsp_err_t R_RSIP_ECDSA_Verify(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_public_key, + uint8_t const * const p_hash, + uint8_t const * const p_signature); + +/* r_rsip_rsa.c */ +fsp_err_t R_RSIP_RSA_Encrypt(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_public_key, + uint8_t const * const p_plain, + uint8_t * const p_cipher); +fsp_err_t R_RSIP_RSA_Decrypt(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_private_key, + uint8_t const * const p_cipher, + uint8_t * const p_plain); +fsp_err_t R_RSIP_RSAES_PKCS1_V1_5_Encrypt(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_public_key, + uint8_t const * const p_plain, + uint32_t const plain_length, + uint8_t * const p_cipher); +fsp_err_t R_RSIP_RSAES_PKCS1_V1_5_Decrypt(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_private_key, + uint8_t const * const p_cipher, + uint8_t * const p_plain, + uint32_t * const p_plain_length, + uint32_t const plain_buffer_length); +fsp_err_t R_RSIP_RSAES_OAEP_Encrypt(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_public_key, + rsip_hash_type_t const hash_function, + rsip_mgf_type_t const mask_generation_function, + uint8_t const * const p_label, + uint32_t const label_length, + uint8_t const * const p_plain, + uint32_t const plain_length, + uint8_t * const p_cipher); +fsp_err_t R_RSIP_RSAES_OAEP_Decrypt(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_private_key, + rsip_hash_type_t const hash_function, + rsip_mgf_type_t const mask_generation_function, + uint8_t const * const p_label, + uint32_t const label_length, + uint8_t const * const p_cipher, + uint8_t * const p_plain, + uint32_t * const p_plain_length, + uint32_t const plain_buffer_length); +fsp_err_t R_RSIP_RSASSA_PKCS1_V1_5_Sign(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_private_key, + rsip_hash_type_t const hash_function, + uint8_t const * const p_hash, + uint8_t * const p_signature); +fsp_err_t R_RSIP_RSASSA_PKCS1_V1_5_Verify(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_public_key, + rsip_hash_type_t const hash_function, + uint8_t const * const p_hash, + uint8_t const * const p_signature); +fsp_err_t R_RSIP_RSASSA_PSS_Sign(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_private_key, + rsip_hash_type_t const hash_function, + rsip_mgf_type_t const mask_generation_function, + int32_t const salt_length, + uint8_t const * const p_hash, + uint8_t * const p_signature); +fsp_err_t R_RSIP_RSASSA_PSS_Verify(rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_public_key, + rsip_hash_type_t const hash_function, + rsip_mgf_type_t const mask_generation_function, + int32_t const salt_length, + uint8_t const * const p_hash, + uint8_t const * const p_signature); + +/* r_rsip_sha.c */ +fsp_err_t R_RSIP_SHA_Compute(rsip_ctrl_t * const p_ctrl, + rsip_hash_type_t const hash_type, + uint8_t const * const p_message, + uint32_t const message_length, + uint8_t * const p_digest); +fsp_err_t R_RSIP_HMAC_Compute(rsip_ctrl_t * const p_ctrl, + const rsip_wrapped_key_t * p_wrapped_key, + uint8_t const * const p_message, + uint32_t const message_length, + uint8_t * const p_mac); +fsp_err_t R_RSIP_HMAC_Verify(rsip_ctrl_t * const p_ctrl, + const rsip_wrapped_key_t * p_wrapped_key, + uint8_t const * const p_message, + uint32_t const message_length, + uint8_t const * const p_mac, + uint32_t const mac_length); +fsp_err_t R_RSIP_SHA_GenerateInit(rsip_ctrl_t * const p_ctrl, + rsip_sha_handle_t * const p_handle, + rsip_hash_type_t const hash_type); +fsp_err_t R_RSIP_SHA_GenerateUpdate(rsip_ctrl_t * const p_ctrl, + rsip_sha_handle_t * const p_handle, + uint8_t const * const p_message, + uint32_t const message_length); +fsp_err_t R_RSIP_SHA_GenerateFinal(rsip_ctrl_t * const p_ctrl, + rsip_sha_handle_t * const p_handle, + uint8_t * const p_digest); +fsp_err_t R_RSIP_HMAC_GenerateInit(rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + rsip_wrapped_key_t const * const p_wrapped_key); +fsp_err_t R_RSIP_HMAC_GenerateUpdate(rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + uint8_t const * const p_message, + uint32_t const message_length); +fsp_err_t R_RSIP_HMAC_GenerateFinal(rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + uint8_t * const p_mac); +fsp_err_t R_RSIP_HMAC_VerifyInit(rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + rsip_wrapped_key_t const * const p_wrapped_key); +fsp_err_t R_RSIP_HMAC_VerifyUpdate(rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + uint8_t const * const p_message, + uint32_t const message_length); +fsp_err_t R_RSIP_HMAC_VerifyFinal(rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + uint8_t const * const p_mac, + uint32_t const mac_length); + +/* For specific devices */ +fsp_err_t R_RSIP_KeyImportWithUFPK(rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_wrapped_user_factory_programming_key, + uint8_t const * const p_initial_vector, + rsip_key_type_t const key_type, + uint8_t const * const p_encrypted_key, + rsip_wrapped_key_t * const p_wrapped_key); + +/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */ +FSP_FOOTER + +#endif /* R_RSIP_H */ + +/*******************************************************************************************************************//** + * @} (end addtogroup RSIP) + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_err.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_err.h new file mode 100644 index 000000000..cfec13490 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_err.h @@ -0,0 +1,48 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +#ifndef R_RSIP_ERR_H +#define R_RSIP_ERR_H + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/* Return code */ +typedef enum e_rsip_ret +{ + /* Success */ + RSIP_RET_PASS, + + /* Branching */ + RSIP_RET_PASS_0, + RSIP_RET_PASS_1, + + /* Error */ + RSIP_RET_RESOURCE_CONFLICT, + RSIP_RET_RETRY, + RSIP_RET_FAIL, + RSIP_RET_KEY_FAIL, + RSIP_RET_PARAM_FAIL, + RSIP_RET_VERIFICATION_FAIL, + RSIP_RET_AUTH_FAIL, + RSIP_RET_UNKNOWN +} rsip_ret_t; + +#endif /* R_RSIP_ERR_H */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_private.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_private.h new file mode 100644 index 000000000..ce5297497 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_private.h @@ -0,0 +1,325 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +#ifndef R_RSIP_PRIVATE_H +#define R_RSIP_PRIVATE_H + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "r_rsip.h" +#include "r_rsip_err.h" +#include "r_rsip_util.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* Internal handle base number */ +#define RSIP_PRV_XTS_HANDLE_BASE (RSIP_HANDLE_TYPE_XTS_ENCRYPT) +#define RSIP_PRV_GCM_HANDLE_BASE (RSIP_HANDLE_TYPE_GCM_ENCRYPT) + +/* Rebase handle type */ +#define RSIP_PRV_XTS_HANDLE_REBASE(handle_type) ((handle_type) - (RSIP_PRV_XTS_HANDLE_BASE)) +#define RSIP_PRV_GCM_HANDLE_REBASE(handle_type) ((handle_type) - (RSIP_PRV_GCM_HANDLE_BASE)) + +/* Internal key type base number */ +#define RSIP_PRV_AES_BASE (RSIP_KEY_TYPE_AES_128) +#define RSIP_PRV_XTS_BASE (RSIP_KEY_TYPE_AES_128_XTS) +#define RSIP_PRV_ECC_BASE (RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC) +#define RSIP_PRV_RSA_BASE (RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED) +#define RSIP_PRV_HMAC_BASE (RSIP_KEY_TYPE_HMAC_SHA1) + +/* Rebase key type */ +#define RSIP_PRV_AES_REBASE(key_type) ((key_type) - (RSIP_PRV_AES_BASE)) +#define RSIP_PRV_XTS_REBASE(key_type) ((key_type) - (RSIP_PRV_XTS_BASE)) +#define RSIP_PRV_ECC_REBASE(key_type) ((key_type) - (RSIP_PRV_ECC_BASE)) +#define RSIP_PRV_RSA_REBASE(key_type) ((key_type) - (RSIP_PRV_RSA_BASE)) +#define RSIP_PRV_HMAC_REBASE(key_type) ((key_type) - (RSIP_PRV_HMAC_BASE)) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/* Bool tables of key (pair) type */ +typedef bool rsip_key_type_bool_table_t[RSIP_KEY_TYPE_NUM]; +typedef bool rsip_key_pair_type_bool_table_t[RSIP_KEY_PAIR_TYPE_NUM]; + +/* + * Private/Primitive functions + */ + +/* Random number generation */ +typedef rsip_ret_t (* rsip_func_random_number_generate_t)(uint32_t OutData_Text[]); + +/* Key generation */ +typedef rsip_ret_t (* rsip_func_key_generate_t)(uint32_t OutData_KeyIndex[]); + +/* Key pair generation */ +typedef rsip_ret_t (* rsip_func_key_pair_generate_t)(uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); + +/* Key import with KUK */ +typedef rsip_ret_t (* rsip_func_key_import_with_kuk_t)(const uint32_t InData_IV[], const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); + +/* AES-ECB/CBC/CTR */ +typedef rsip_ret_t (* rsip_func_aes_init_t)(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); + +/* AES-GCM */ +typedef rsip_ret_t (* rsip_func_ghash_t)(const uint32_t InData_HV[], const uint32_t InData_IV[], + const uint32_t InData_Text[], uint32_t OutData_DataT[], uint32_t MAX_CNT); + +/* ECC */ +typedef rsip_ret_t (* rsip_func_ecdsa_sign_t)(const uint32_t InData_KeyIndex[], const uint32_t InData_MsgDgst[], + uint32_t OutData_Signature[]); +typedef rsip_ret_t (* rsip_func_ecdsa_verify_t)(const uint32_t InData_KeyIndex[], const uint32_t InData_MsgDgst[], + const uint32_t InData_Signature[]); + +/* RSA */ +typedef rsip_ret_t (* rsip_func_rsa_t)(const uint32_t InData_KeyIndex[], const uint32_t InData_Text[], + uint32_t OutData_Text[]); + +/* HMAC */ +typedef rsip_ret_t (* rsip_func_hmac_single_t)(const uint32_t InData_KeyIndex[], const uint32_t InData_Cmd[], + const uint32_t InData_Msg[], const uint32_t InData_MsgLen[], + const uint32_t InData_MAC[], + const uint32_t InData_length[], uint32_t MAX_CNT, + uint32_t OutData_MAC[]); +typedef rsip_ret_t (* rsip_func_hmac_multi_t)(const uint32_t InData_KeyIndex[], const uint32_t InData_Cmd[], + const uint32_t InData_Msg[], const uint32_t InData_MsgLen[], + const uint32_t InData_MAC[], + const uint32_t InData_length[], const uint32_t InData_State[], + uint32_t MAX_CNT, uint32_t OutData_MAC[], + uint32_t OutData_State[]); + +/* + * Private/Primitive function subsets + */ + +/* AES-ECB/CBC/CTR */ +typedef struct st_rsip_func_subset_aes +{ + rsip_func_aes_init_t p_init[3][2]; + void (* p_update)(const uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); + rsip_ret_t (* p_final)(); +} rsip_func_subset_aes_t; + +/* AES-XTS */ +typedef struct st_rsip_func_subset_xts +{ + rsip_ret_t (* p_init)(const uint32_t * InData_KeyIndex, const uint32_t * InData_IV); + void (* p_update)(const uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); + rsip_ret_t (* p_final)(const uint32_t * InData_TextBitLen, const uint32_t * InData_Text, uint32_t * OutData_Text); +} rsip_func_subset_xts_t; + +/* AES-GCM */ +typedef struct st_rsip_func_subset_gcm +{ + rsip_ret_t (* p_init)(const uint32_t * InData_KeyIndex, const uint32_t * InData_IV); + void (* p_updateAad)(const uint32_t * InData_DataA, uint32_t MAX_CNT); + void (* p_updateTransition)(); + void (* p_update)(const uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); + rsip_ret_t (* p_encryptFinal)(const uint32_t * InData_Text, const uint32_t * InData_DataALen, + const uint32_t * InData_TextLen, uint32_t * OutData_Text, uint32_t * OutData_DataT); + rsip_ret_t (* p_decryptFinal)(const uint32_t * InData_Text, const uint32_t * InData_DataT, + const uint32_t * InData_DataALen, const uint32_t * InData_TextLen, + const uint32_t * InData_DataTLen, + uint32_t * OutData_Text); + const rsip_func_subset_aes_t * p_ecb; +} rsip_func_subset_gcm_t; + +/* AES-CMAC */ +typedef struct st_rsip_func_subset_cmac +{ + rsip_ret_t (* p_init)(const uint32_t * InData_KeyIndex); + void (* p_update)(const uint32_t * InData_Text, uint32_t MAX_CNT); + rsip_ret_t (* p_generateFinal)(const uint32_t * InData_Text, uint32_t * OutData_DataT, const uint32_t all_msg_len); + rsip_ret_t (* p_verifyFinal)(const uint32_t * InData_Text, const uint32_t * InData_DataT, + const uint32_t * InData_DataTLen, const uint32_t all_msg_len); +} rsip_func_subset_cmac_t; + +/********************************************************************************************************************** + * Exported global variables + **********************************************************************************************************************/ + +/* Bool tables of key (pair) type */ +extern const rsip_key_type_bool_table_t g_key_generate_supported_algs; +extern const rsip_key_type_bool_table_t g_key_import_with_kuk_supported_algs; +extern const rsip_key_pair_type_bool_table_t g_key_pair_generate_supported_algs; + +/* Private/Primitive function subset tables */ +extern const rsip_func_subset_aes_t gp_func_aes[]; +extern const rsip_func_subset_xts_t gp_func_xts[][2]; +extern const rsip_func_subset_gcm_t gp_func_gcm[][2]; +extern const rsip_func_subset_cmac_t gp_func_cmac[]; + +/* Private/Primitive function tables */ +extern const rsip_func_key_generate_t gp_func_key_generate[]; +extern const rsip_func_key_pair_generate_t gp_func_key_pair_generate[]; +extern const rsip_func_key_import_with_kuk_t gp_func_key_import_with_kuk[]; +extern const rsip_func_ecdsa_sign_t gp_func_ecdsa_sign[]; +extern const rsip_func_ecdsa_verify_t gp_func_ecdsa_verify[]; +extern const rsip_func_rsa_t gp_func_rsa_public[]; +extern const rsip_func_rsa_t gp_func_rsa_private[]; +extern const rsip_func_hmac_single_t gp_func_hmac_single[]; +extern const rsip_func_hmac_multi_t gp_func_hmac_multi[]; + +/* Discrete private/primitive functions */ +extern const rsip_func_random_number_generate_t gp_func_random_number_generate; +extern const rsip_func_ghash_t gp_func_ghash_compute; + +/********************************************************************************************************************** + * Public Function Prototypes + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Initializes the RSIP engine. + * + * @return The return value of the internally called primitive functions. + **********************************************************************************************************************/ +rsip_ret_t r_rsip_open(void); + +/*******************************************************************************************************************//** + * Finalizes the RSIP engine. + * + * @return The return value of the internally called primitive functions. + **********************************************************************************************************************/ +rsip_ret_t r_rsip_close(void); + +/*******************************************************************************************************************//** + * Stores input Key Update Key (KUK). + * + * @param[in] p_key_update_key_value KUK value. + **********************************************************************************************************************/ +void r_rsip_kuk_store(const uint8_t * p_key_update_key_value); + +/*******************************************************************************************************************//** + * Computes SHA-1 or SHA-2 message digest in single-part operation. + * + * @param[in] InData_Msg Big-endian message. + * @param[out] OutData_MsgDigest Big-endian message digest. + * @param[in] hash_type Generating hash type. + * @param[in] message_length Byte size of message. + * + * @return The return value of the internally called primitive function. + **********************************************************************************************************************/ +rsip_ret_t r_rsip_sha1sha2_compute_single(const uint32_t InData_Msg[], + uint32_t OutData_MsgDigest[], + rsip_hash_type_t hash_type, + uint32_t message_length); + +/*******************************************************************************************************************//** + * Computes HMAC message digest in single-part operation. + * + * @param[in] InData_Msg Big-endian message. + * @param[out] OutData_MAC Big-endian MAC. + * @param[in] p_func Private/Primitive function. + * @param[in] p_wrapped_key Wrapped HMAC key. + * @param[in] message_length Byte size of message. + * + * @return The return value of the internally called primitive function. + **********************************************************************************************************************/ +rsip_ret_t r_rsip_hmac_compute_single(const uint32_t InData_Msg[], + uint32_t OutData_MAC[], + const rsip_func_hmac_single_t p_func, + const rsip_wrapped_key_t * p_wrapped_key, + uint32_t message_length); + +/*******************************************************************************************************************//** + * Verifies HMAC message digest in single-part operation. + * + * @param[in] InData_Msg Big-endian message. + * @param[in] p_mac Big-endian MAC. + * @param[in] p_func Private/Primitive function. + * @param[in] p_wrapped_key Wrapped HMAC key. + * @param[in] message_length Byte size of message. + * @param[in] mac_length Byte size of MAC. + * + * @return The return value of the internally called primitive function. + **********************************************************************************************************************/ +rsip_ret_t r_rsip_hmac_verify_single(const uint32_t InData_Msg[], + const uint8_t * p_mac, + const rsip_func_hmac_single_t p_func, + const rsip_wrapped_key_t * p_wrapped_key, + uint32_t message_length, + uint32_t mac_length); + +/*******************************************************************************************************************//** + * Computes SHA-1 or SHA-2 message digest in multi-part operation. + * + * @param[in,out] p_handle User handle. + * @param[in] p_message Big-endian message. + * @param[in] message_length Byte size of message. + * @param[out] p_digest Big-endian message digest. + * If it is NULL, the calculation will be suspend. + * Otherwise, the calculation is finalized. + * + * @return The return value of the internally called primitive function. + **********************************************************************************************************************/ +rsip_ret_t r_rsip_sha1sha2_calc_multi(rsip_sha_handle_t * p_handle, + const uint8_t * p_message, + uint32_t message_length, + uint8_t * p_digest); + +/*******************************************************************************************************************//** + * Computes or Verifies HMAC in multi-part operation. + * + * @param[in,out] p_handle User handle. + * @param[in] p_message Big-endian message. + * @param[in] message_length Byte size of message. + * @param[in,out] p_mac Big-endian MAC. For computation finalization, it is output data; + * for verification finalization, it is input data. + * @param[in] mac_length Byte size of MAC. This value is input only verification finalization. + * @param[in] is_final If it is false, the calculation will be suspend. + * Otherwise, the calculation is finalized. + * + * @return The return value of the internally called primitive function. + **********************************************************************************************************************/ +rsip_ret_t r_rsip_hmac_calc_multi(rsip_hmac_handle_t * p_handle, + const uint8_t * p_message, + uint32_t message_length, + uint8_t * p_mac, + uint32_t mac_length, + bool is_final); + +/*******************************************************************************************************************//** + * Converts byte data to word (4-byte) and rounds up it. + ***********************************************************************************************************************/ +RSIP_PRV_STATIC_INLINE uint32_t r_rsip_byte_to_word_convert (const uint32_t bytes) +{ + return (bytes + 3) >> 2; +} + +/*******************************************************************************************************************//** + * Converts byte data to bit data. This function returns upper 3 digits. + ***********************************************************************************************************************/ +RSIP_PRV_STATIC_INLINE uint32_t r_rsip_byte_to_bit_convert_upper (const uint64_t bytes) +{ + return (uint32_t) (bytes >> 29); +} + +/*******************************************************************************************************************//** + * Converts byte data to bit data. This function returns lower 32 digits. + ***********************************************************************************************************************/ +RSIP_PRV_STATIC_INLINE uint32_t r_rsip_byte_to_bit_convert_lower (const uint64_t bytes) +{ + return (uint32_t) (bytes << 3); +} + +#endif /* R_RSIP_PRIVATE_H */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_reg.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_reg.h new file mode 100644 index 000000000..d454987de --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_reg.h @@ -0,0 +1,2460 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +#ifndef R_RSIP_REG_H +#define R_RSIP_REG_H + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include "r_rsip_addr.h" +#include "r_rsip_util.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* RSIP register access macro */ +#define RD1_MASK(reg, value) ((reg) & (value)) +#define CHCK_STS(reg, bitPos, value) ((value) == ((reg >> bitPos) & 1)) +#define WAIT_STS(reg, bitPos, value) while (!CHCK_STS((reg), (bitPos), (value))) +#define WR1_ADDR(reg, addr) (reg) = *(addr) +#define WR4_ADDR(reg, addr) \ + { \ + WR1_ADDR((reg), (&(addr))[0]); \ + WR1_ADDR((reg), (&(addr))[1]); \ + WR1_ADDR((reg), (&(addr))[2]); \ + WR1_ADDR((reg), (&(addr))[3]); \ + } +#define WR1_PROG(reg, value) (reg) = (value) +#define WR4_PROG(reg, value0, value1, value2, value3) \ + { \ + WR1_PROG((reg), (value0)); \ + WR1_PROG((reg), (value1)); \ + WR1_PROG((reg), (value2)); \ + WR1_PROG((reg), (value3)); \ + } +#define RD1_ADDR(reg, addr) *(addr) = (reg) +#define RD4_ADDR(reg, addr) \ + { \ + RD1_ADDR((reg), (&(addr))[0]); \ + RD1_ADDR((reg), (&(addr))[1]); \ + RD1_ADDR((reg), (&(addr))[2]); \ + RD1_ADDR((reg), (&(addr))[3]); \ + } + +/* register address */ +#define REG_0000H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x000U)) +#define REG_0004H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x004U)) +#define REG_0008H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x008U)) +#define REG_000CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x00CU)) +#define REG_0010H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x010U)) +#define REG_0014H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x014U)) +#define REG_0018H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x018U)) +#define REG_001CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x01CU)) +#define REG_0020H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x020U)) +#define REG_0024H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x024U)) +#define REG_0028H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x028U)) +#define REG_002CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x02CU)) +#define REG_0030H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x030U)) +#define REG_0034H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x034U)) +#define REG_0038H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x038U)) +#define REG_003CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x03CU)) +#define REG_0040H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x040U)) +#define REG_0044H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x044U)) +#define REG_0048H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x048U)) +#define REG_004CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x04CU)) +#define REG_0050H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x050U)) +#define REG_0054H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x054U)) +#define REG_0058H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x058U)) +#define REG_005CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x05CU)) +#define REG_0060H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x060U)) +#define REG_0064H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x064U)) +#define REG_0068H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x068U)) +#define REG_006CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x06CU)) +#define REG_0070H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x070U)) +#define REG_0074H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x074U)) +#define REG_0078H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x078U)) +#define REG_007CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x07CU)) +#define REG_0080H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x080U)) +#define REG_0084H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x084U)) +#define REG_0088H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x088U)) +#define REG_008CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x08CU)) +#define REG_0090H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x090U)) +#define REG_0094H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x094U)) +#define REG_0098H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x098U)) +#define REG_009CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x09CU)) +#define REG_00A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0A0U)) +#define REG_00A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0A4U)) +#define REG_00A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0A8U)) +#define REG_00ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0ACU)) +#define REG_00B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0B0U)) +#define REG_00B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0B4U)) +#define REG_00B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0B8U)) +#define REG_00BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0BCU)) +#define REG_00C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0C0U)) +#define REG_00C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0C4U)) +#define REG_00C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0C8U)) +#define REG_00CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0CCU)) +#define REG_00D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0D0U)) +#define REG_00D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0D4U)) +#define REG_00D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0D8U)) +#define REG_00DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0DCU)) +#define REG_00E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0E0U)) +#define REG_00E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0E4U)) +#define REG_00E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0E8U)) +#define REG_00ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0ECU)) +#define REG_00F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0F0U)) +#define REG_00F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0F4U)) +#define REG_00F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0F8U)) +#define REG_00FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x0FCU)) +#define REG_0100H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x100U)) +#define REG_0104H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x104U)) +#define REG_0108H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x108U)) +#define REG_010CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x10CU)) +#define REG_0110H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x110U)) +#define REG_0114H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x114U)) +#define REG_0118H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x118U)) +#define REG_011CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x11CU)) +#define REG_0120H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x120U)) +#define REG_0124H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x124U)) +#define REG_0128H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x128U)) +#define REG_012CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x12CU)) +#define REG_0130H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x130U)) +#define REG_0134H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x134U)) +#define REG_0138H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x138U)) +#define REG_013CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x13CU)) +#define REG_0140H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x140U)) +#define REG_0144H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x144U)) +#define REG_0148H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x148U)) +#define REG_014CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x14CU)) +#define REG_0150H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x150U)) +#define REG_0154H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x154U)) +#define REG_0158H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x158U)) +#define REG_015CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x15CU)) +#define REG_0160H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x160U)) +#define REG_0164H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x164U)) +#define REG_0168H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x168U)) +#define REG_016CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x16CU)) +#define REG_0170H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x170U)) +#define REG_0174H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x174U)) +#define REG_0178H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x178U)) +#define REG_017CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x17CU)) +#define REG_0180H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x180U)) +#define REG_0184H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x184U)) +#define REG_0188H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x188U)) +#define REG_018CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x18CU)) +#define REG_0190H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x190U)) +#define REG_0194H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x194U)) +#define REG_0198H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x198U)) +#define REG_019CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x19CU)) +#define REG_01A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1A0U)) +#define REG_01A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1A4U)) +#define REG_01A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1A8U)) +#define REG_01ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1ACU)) +#define REG_01B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1B0U)) +#define REG_01B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1B4U)) +#define REG_01B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1B8U)) +#define REG_01BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1BCU)) +#define REG_01C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1C0U)) +#define REG_01C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1C4U)) +#define REG_01C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1C8U)) +#define REG_01CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1CCU)) +#define REG_01D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1D0U)) +#define REG_01D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1D4U)) +#define REG_01D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1D8U)) +#define REG_01DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1DCU)) +#define REG_01E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1E0U)) +#define REG_01E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1E4U)) +#define REG_01E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1E8U)) +#define REG_01ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1ECU)) +#define REG_01F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1F0U)) +#define REG_01F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1F4U)) +#define REG_01F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1F8U)) +#define REG_01FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x1FCU)) +#define REG_0200H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x200U)) +#define REG_0204H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x204U)) +#define REG_0208H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x208U)) +#define REG_020CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x20CU)) +#define REG_0210H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x210U)) +#define REG_0214H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x214U)) +#define REG_0218H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x218U)) +#define REG_021CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x21CU)) +#define REG_0220H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x220U)) +#define REG_0224H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x224U)) +#define REG_0228H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x228U)) +#define REG_022CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x22CU)) +#define REG_0230H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x230U)) +#define REG_0234H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x234U)) +#define REG_0238H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x238U)) +#define REG_023CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x23CU)) +#define REG_0240H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x240U)) +#define REG_0244H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x244U)) +#define REG_0248H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x248U)) +#define REG_024CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x24CU)) +#define REG_0250H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x250U)) +#define REG_0254H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x254U)) +#define REG_0258H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x258U)) +#define REG_025CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x25CU)) +#define REG_0260H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x260U)) +#define REG_0264H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x264U)) +#define REG_0268H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x268U)) +#define REG_026CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x26CU)) +#define REG_0270H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x270U)) +#define REG_0274H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x274U)) +#define REG_0278H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x278U)) +#define REG_027CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x27CU)) +#define REG_0280H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x280U)) +#define REG_0284H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x284U)) +#define REG_0288H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x288U)) +#define REG_028CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x28CU)) +#define REG_0290H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x290U)) +#define REG_0294H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x294U)) +#define REG_0298H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x298U)) +#define REG_029CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x29CU)) +#define REG_02A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2A0U)) +#define REG_02A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2A4U)) +#define REG_02A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2A8U)) +#define REG_02ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2ACU)) +#define REG_02B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2B0U)) +#define REG_02B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2B4U)) +#define REG_02B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2B8U)) +#define REG_02BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2BCU)) +#define REG_02C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2C0U)) +#define REG_02C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2C4U)) +#define REG_02C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2C8U)) +#define REG_02CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2CCU)) +#define REG_02D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2D0U)) +#define REG_02D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2D4U)) +#define REG_02D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2D8U)) +#define REG_02DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2DCU)) +#define REG_02E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2E0U)) +#define REG_02E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2E4U)) +#define REG_02E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2E8U)) +#define REG_02ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2ECU)) +#define REG_02F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2F0U)) +#define REG_02F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2F4U)) +#define REG_02F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2F8U)) +#define REG_02FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x2FCU)) +#define REG_0300H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x300U)) +#define REG_0304H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x304U)) +#define REG_0308H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x308U)) +#define REG_030CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x30CU)) +#define REG_0310H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x310U)) +#define REG_0314H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x314U)) +#define REG_0318H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x318U)) +#define REG_031CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x31CU)) +#define REG_0320H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x320U)) +#define REG_0324H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x324U)) +#define REG_0328H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x328U)) +#define REG_032CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x32CU)) +#define REG_0330H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x330U)) +#define REG_0334H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x334U)) +#define REG_0338H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x338U)) +#define REG_033CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x33CU)) +#define REG_0340H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x340U)) +#define REG_0344H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x344U)) +#define REG_0348H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x348U)) +#define REG_034CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x34CU)) +#define REG_0350H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x350U)) +#define REG_0354H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x354U)) +#define REG_0358H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x358U)) +#define REG_035CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x35CU)) +#define REG_0360H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x360U)) +#define REG_0364H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x364U)) +#define REG_0368H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x368U)) +#define REG_036CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x36CU)) +#define REG_0370H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x370U)) +#define REG_0374H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x374U)) +#define REG_0378H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x378U)) +#define REG_037CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x37CU)) +#define REG_0380H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x380U)) +#define REG_0384H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x384U)) +#define REG_0388H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x388U)) +#define REG_038CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x38CU)) +#define REG_0390H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x390U)) +#define REG_0394H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x394U)) +#define REG_0398H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x398U)) +#define REG_039CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x39CU)) +#define REG_03A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3A0U)) +#define REG_03A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3A4U)) +#define REG_03A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3A8U)) +#define REG_03ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3ACU)) +#define REG_03B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3B0U)) +#define REG_03B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3B4U)) +#define REG_03B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3B8U)) +#define REG_03BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3BCU)) +#define REG_03C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3C0U)) +#define REG_03C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3C4U)) +#define REG_03C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3C8U)) +#define REG_03CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3CCU)) +#define REG_03D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3D0U)) +#define REG_03D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3D4U)) +#define REG_03D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3D8U)) +#define REG_03DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3DCU)) +#define REG_03E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3E0U)) +#define REG_03E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3E4U)) +#define REG_03E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3E8U)) +#define REG_03ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3ECU)) +#define REG_03F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3F0U)) +#define REG_03F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3F4U)) +#define REG_03F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3F8U)) +#define REG_03FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x3FCU)) +#define REG_0400H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x400U)) +#define REG_0404H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x404U)) +#define REG_0408H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x408U)) +#define REG_040CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x40CU)) +#define REG_0410H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x410U)) +#define REG_0414H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x414U)) +#define REG_0418H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x418U)) +#define REG_041CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x41CU)) +#define REG_0420H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x420U)) +#define REG_0424H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x424U)) +#define REG_0428H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x428U)) +#define REG_042CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x42CU)) +#define REG_0430H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x430U)) +#define REG_0434H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x434U)) +#define REG_0438H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x438U)) +#define REG_043CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x43CU)) +#define REG_0440H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x440U)) +#define REG_0444H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x444U)) +#define REG_0448H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x448U)) +#define REG_044CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x44CU)) +#define REG_0450H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x450U)) +#define REG_0454H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x454U)) +#define REG_0458H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x458U)) +#define REG_045CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x45CU)) +#define REG_0460H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x460U)) +#define REG_0464H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x464U)) +#define REG_0468H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x468U)) +#define REG_046CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x46CU)) +#define REG_0470H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x470U)) +#define REG_0474H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x474U)) +#define REG_0478H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x478U)) +#define REG_047CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x47CU)) +#define REG_0480H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x480U)) +#define REG_0484H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x484U)) +#define REG_0488H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x488U)) +#define REG_048CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x48CU)) +#define REG_0490H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x490U)) +#define REG_0494H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x494U)) +#define REG_0498H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x498U)) +#define REG_049CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x49CU)) +#define REG_04A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4A0U)) +#define REG_04A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4A4U)) +#define REG_04A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4A8U)) +#define REG_04ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4ACU)) +#define REG_04B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4B0U)) +#define REG_04B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4B4U)) +#define REG_04B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4B8U)) +#define REG_04BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4BCU)) +#define REG_04C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4C0U)) +#define REG_04C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4C4U)) +#define REG_04C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4C8U)) +#define REG_04CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4CCU)) +#define REG_04D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4D0U)) +#define REG_04D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4D4U)) +#define REG_04D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4D8U)) +#define REG_04DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4DCU)) +#define REG_04E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4E0U)) +#define REG_04E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4E4U)) +#define REG_04E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4E8U)) +#define REG_04ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4ECU)) +#define REG_04F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4F0U)) +#define REG_04F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4F4U)) +#define REG_04F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4F8U)) +#define REG_04FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x4FCU)) +#define REG_0500H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x500U)) +#define REG_0504H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x504U)) +#define REG_0508H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x508U)) +#define REG_050CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x50CU)) +#define REG_0510H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x510U)) +#define REG_0514H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x514U)) +#define REG_0518H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x518U)) +#define REG_051CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x51CU)) +#define REG_0520H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x520U)) +#define REG_0524H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x524U)) +#define REG_0528H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x528U)) +#define REG_052CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x52CU)) +#define REG_0530H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x530U)) +#define REG_0534H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x534U)) +#define REG_0538H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x538U)) +#define REG_053CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x53CU)) +#define REG_0540H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x540U)) +#define REG_0544H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x544U)) +#define REG_0548H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x548U)) +#define REG_054CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x54CU)) +#define REG_0550H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x550U)) +#define REG_0554H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x554U)) +#define REG_0558H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x558U)) +#define REG_055CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x55CU)) +#define REG_0560H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x560U)) +#define REG_0564H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x564U)) +#define REG_0568H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x568U)) +#define REG_056CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x56CU)) +#define REG_0570H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x570U)) +#define REG_0574H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x574U)) +#define REG_0578H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x578U)) +#define REG_057CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x57CU)) +#define REG_0580H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x580U)) +#define REG_0584H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x584U)) +#define REG_0588H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x588U)) +#define REG_058CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x58CU)) +#define REG_0590H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x590U)) +#define REG_0594H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x594U)) +#define REG_0598H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x598U)) +#define REG_059CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x59CU)) +#define REG_05A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5A0U)) +#define REG_05A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5A4U)) +#define REG_05A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5A8U)) +#define REG_05ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5ACU)) +#define REG_05B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5B0U)) +#define REG_05B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5B4U)) +#define REG_05B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5B8U)) +#define REG_05BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5BCU)) +#define REG_05C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5C0U)) +#define REG_05C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5C4U)) +#define REG_05C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5C8U)) +#define REG_05CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5CCU)) +#define REG_05D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5D0U)) +#define REG_05D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5D4U)) +#define REG_05D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5D8U)) +#define REG_05DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5DCU)) +#define REG_05E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5E0U)) +#define REG_05E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5E4U)) +#define REG_05E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5E8U)) +#define REG_05ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5ECU)) +#define REG_05F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5F0U)) +#define REG_05F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5F4U)) +#define REG_05F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5F8U)) +#define REG_05FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x5FCU)) +#define REG_0600H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x600U)) +#define REG_0604H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x604U)) +#define REG_0608H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x608U)) +#define REG_060CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x60CU)) +#define REG_0610H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x610U)) +#define REG_0614H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x614U)) +#define REG_0618H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x618U)) +#define REG_061CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x61CU)) +#define REG_0620H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x620U)) +#define REG_0624H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x624U)) +#define REG_0628H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x628U)) +#define REG_062CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x62CU)) +#define REG_0630H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x630U)) +#define REG_0634H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x634U)) +#define REG_0638H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x638U)) +#define REG_063CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x63CU)) +#define REG_0640H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x640U)) +#define REG_0644H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x644U)) +#define REG_0648H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x648U)) +#define REG_064CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x64CU)) +#define REG_0650H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x650U)) +#define REG_0654H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x654U)) +#define REG_0658H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x658U)) +#define REG_065CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x65CU)) +#define REG_0660H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x660U)) +#define REG_0664H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x664U)) +#define REG_0668H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x668U)) +#define REG_066CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x66CU)) +#define REG_0670H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x670U)) +#define REG_0674H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x674U)) +#define REG_0678H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x678U)) +#define REG_067CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x67CU)) +#define REG_0680H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x680U)) +#define REG_0684H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x684U)) +#define REG_0688H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x688U)) +#define REG_068CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x68CU)) +#define REG_0690H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x690U)) +#define REG_0694H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x694U)) +#define REG_0698H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x698U)) +#define REG_069CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x69CU)) +#define REG_06A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6A0U)) +#define REG_06A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6A4U)) +#define REG_06A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6A8U)) +#define REG_06ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6ACU)) +#define REG_06B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6B0U)) +#define REG_06B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6B4U)) +#define REG_06B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6B8U)) +#define REG_06BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6BCU)) +#define REG_06C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6C0U)) +#define REG_06C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6C4U)) +#define REG_06C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6C8U)) +#define REG_06CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6CCU)) +#define REG_06D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6D0U)) +#define REG_06D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6D4U)) +#define REG_06D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6D8U)) +#define REG_06DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6DCU)) +#define REG_06E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6E0U)) +#define REG_06E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6E4U)) +#define REG_06E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6E8U)) +#define REG_06ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6ECU)) +#define REG_06F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6F0U)) +#define REG_06F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6F4U)) +#define REG_06F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6F8U)) +#define REG_06FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x6FCU)) +#define REG_0700H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x700U)) +#define REG_0704H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x704U)) +#define REG_0708H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x708U)) +#define REG_070CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x70CU)) +#define REG_0710H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x710U)) +#define REG_0714H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x714U)) +#define REG_0718H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x718U)) +#define REG_071CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x71CU)) +#define REG_0720H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x720U)) +#define REG_0724H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x724U)) +#define REG_0728H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x728U)) +#define REG_072CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x72CU)) +#define REG_0730H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x730U)) +#define REG_0734H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x734U)) +#define REG_0738H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x738U)) +#define REG_073CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x73CU)) +#define REG_0740H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x740U)) +#define REG_0744H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x744U)) +#define REG_0748H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x748U)) +#define REG_074CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x74CU)) +#define REG_0750H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x750U)) +#define REG_0754H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x754U)) +#define REG_0758H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x758U)) +#define REG_075CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x75CU)) +#define REG_0760H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x760U)) +#define REG_0764H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x764U)) +#define REG_0768H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x768U)) +#define REG_076CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x76CU)) +#define REG_0770H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x770U)) +#define REG_0774H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x774U)) +#define REG_0778H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x778U)) +#define REG_077CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x77CU)) +#define REG_0780H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x780U)) +#define REG_0784H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x784U)) +#define REG_0788H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x788U)) +#define REG_078CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x78CU)) +#define REG_0790H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x790U)) +#define REG_0794H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x794U)) +#define REG_0798H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x798U)) +#define REG_079CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x79CU)) +#define REG_07A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7A0U)) +#define REG_07A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7A4U)) +#define REG_07A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7A8U)) +#define REG_07ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7ACU)) +#define REG_07B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7B0U)) +#define REG_07B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7B4U)) +#define REG_07B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7B8U)) +#define REG_07BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7BCU)) +#define REG_07C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7C0U)) +#define REG_07C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7C4U)) +#define REG_07C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7C8U)) +#define REG_07CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7CCU)) +#define REG_07D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7D0U)) +#define REG_07D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7D4U)) +#define REG_07D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7D8U)) +#define REG_07DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7DCU)) +#define REG_07E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7E0U)) +#define REG_07E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7E4U)) +#define REG_07E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7E8U)) +#define REG_07ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7ECU)) +#define REG_07F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7F0U)) +#define REG_07F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7F4U)) +#define REG_07F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7F8U)) +#define REG_07FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x7FCU)) +#define REG_0800H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x800U)) +#define REG_0804H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x804U)) +#define REG_0808H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x808U)) +#define REG_080CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x80CU)) +#define REG_0810H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x810U)) +#define REG_0814H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x814U)) +#define REG_0818H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x818U)) +#define REG_081CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x81CU)) +#define REG_0820H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x820U)) +#define REG_0824H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x824U)) +#define REG_0828H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x828U)) +#define REG_082CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x82CU)) +#define REG_0830H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x830U)) +#define REG_0834H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x834U)) +#define REG_0838H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x838U)) +#define REG_083CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x83CU)) +#define REG_0840H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x840U)) +#define REG_0844H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x844U)) +#define REG_0848H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x848U)) +#define REG_084CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x84CU)) +#define REG_0850H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x850U)) +#define REG_0854H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x854U)) +#define REG_0858H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x858U)) +#define REG_085CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x85CU)) +#define REG_0860H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x860U)) +#define REG_0864H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x864U)) +#define REG_0868H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x868U)) +#define REG_086CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x86CU)) +#define REG_0870H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x870U)) +#define REG_0874H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x874U)) +#define REG_0878H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x878U)) +#define REG_087CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x87CU)) +#define REG_0880H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x880U)) +#define REG_0884H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x884U)) +#define REG_0888H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x888U)) +#define REG_088CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x88CU)) +#define REG_0890H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x890U)) +#define REG_0894H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x894U)) +#define REG_0898H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x898U)) +#define REG_089CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x89CU)) +#define REG_08A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8A0U)) +#define REG_08A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8A4U)) +#define REG_08A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8A8U)) +#define REG_08ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8ACU)) +#define REG_08B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8B0U)) +#define REG_08B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8B4U)) +#define REG_08B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8B8U)) +#define REG_08BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8BCU)) +#define REG_08C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8C0U)) +#define REG_08C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8C4U)) +#define REG_08C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8C8U)) +#define REG_08CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8CCU)) +#define REG_08D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8D0U)) +#define REG_08D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8D4U)) +#define REG_08D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8D8U)) +#define REG_08DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8DCU)) +#define REG_08E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8E0U)) +#define REG_08E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8E4U)) +#define REG_08E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8E8U)) +#define REG_08ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8ECU)) +#define REG_08F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8F0U)) +#define REG_08F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8F4U)) +#define REG_08F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8F8U)) +#define REG_08FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x8FCU)) +#define REG_0900H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x900U)) +#define REG_0904H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x904U)) +#define REG_0908H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x908U)) +#define REG_090CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x90CU)) +#define REG_0910H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x910U)) +#define REG_0914H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x914U)) +#define REG_0918H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x918U)) +#define REG_091CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x91CU)) +#define REG_0920H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x920U)) +#define REG_0924H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x924U)) +#define REG_0928H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x928U)) +#define REG_092CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x92CU)) +#define REG_0930H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x930U)) +#define REG_0934H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x934U)) +#define REG_0938H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x938U)) +#define REG_093CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x93CU)) +#define REG_0940H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x940U)) +#define REG_0944H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x944U)) +#define REG_0948H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x948U)) +#define REG_094CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x94CU)) +#define REG_0950H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x950U)) +#define REG_0954H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x954U)) +#define REG_0958H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x958U)) +#define REG_095CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x95CU)) +#define REG_0960H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x960U)) +#define REG_0964H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x964U)) +#define REG_0968H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x968U)) +#define REG_096CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x96CU)) +#define REG_0970H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x970U)) +#define REG_0974H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x974U)) +#define REG_0978H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x978U)) +#define REG_097CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x97CU)) +#define REG_0980H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x980U)) +#define REG_0984H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x984U)) +#define REG_0988H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x988U)) +#define REG_098CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x98CU)) +#define REG_0990H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x990U)) +#define REG_0994H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x994U)) +#define REG_0998H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x998U)) +#define REG_099CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x99CU)) +#define REG_09A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9A0U)) +#define REG_09A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9A4U)) +#define REG_09A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9A8U)) +#define REG_09ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9ACU)) +#define REG_09B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9B0U)) +#define REG_09B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9B4U)) +#define REG_09B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9B8U)) +#define REG_09BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9BCU)) +#define REG_09C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9C0U)) +#define REG_09C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9C4U)) +#define REG_09C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9C8U)) +#define REG_09CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9CCU)) +#define REG_09D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9D0U)) +#define REG_09D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9D4U)) +#define REG_09D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9D8U)) +#define REG_09DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9DCU)) +#define REG_09E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9E0U)) +#define REG_09E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9E4U)) +#define REG_09E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9E8U)) +#define REG_09ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9ECU)) +#define REG_09F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9F0U)) +#define REG_09F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9F4U)) +#define REG_09F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9F8U)) +#define REG_09FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0x9FCU)) +#define REG_0A00H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA00U)) +#define REG_0A04H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA04U)) +#define REG_0A08H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA08U)) +#define REG_0A0CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA0CU)) +#define REG_0A10H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA10U)) +#define REG_0A14H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA14U)) +#define REG_0A18H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA18U)) +#define REG_0A1CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA1CU)) +#define REG_0A20H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA20U)) +#define REG_0A24H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA24U)) +#define REG_0A28H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA28U)) +#define REG_0A2CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA2CU)) +#define REG_0A30H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA30U)) +#define REG_0A34H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA34U)) +#define REG_0A38H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA38U)) +#define REG_0A3CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA3CU)) +#define REG_0A40H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA40U)) +#define REG_0A44H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA44U)) +#define REG_0A48H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA48U)) +#define REG_0A4CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA4CU)) +#define REG_0A50H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA50U)) +#define REG_0A54H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA54U)) +#define REG_0A58H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA58U)) +#define REG_0A5CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA5CU)) +#define REG_0A60H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA60U)) +#define REG_0A64H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA64U)) +#define REG_0A68H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA68U)) +#define REG_0A6CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA6CU)) +#define REG_0A70H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA70U)) +#define REG_0A74H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA74U)) +#define REG_0A78H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA78U)) +#define REG_0A7CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA7CU)) +#define REG_0A80H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA80U)) +#define REG_0A84H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA84U)) +#define REG_0A88H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA88U)) +#define REG_0A8CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA8CU)) +#define REG_0A90H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA90U)) +#define REG_0A94H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA94U)) +#define REG_0A98H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA98U)) +#define REG_0A9CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xA9CU)) +#define REG_0AA0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAA0U)) +#define REG_0AA4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAA4U)) +#define REG_0AA8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAA8U)) +#define REG_0AACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAACU)) +#define REG_0AB0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAB0U)) +#define REG_0AB4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAB4U)) +#define REG_0AB8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAB8U)) +#define REG_0ABCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xABCU)) +#define REG_0AC0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAC0U)) +#define REG_0AC4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAC4U)) +#define REG_0AC8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAC8U)) +#define REG_0ACCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xACCU)) +#define REG_0AD0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAD0U)) +#define REG_0AD4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAD4U)) +#define REG_0AD8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAD8U)) +#define REG_0ADCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xADCU)) +#define REG_0AE0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAE0U)) +#define REG_0AE4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAE4U)) +#define REG_0AE8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAE8U)) +#define REG_0AECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAECU)) +#define REG_0AF0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAF0U)) +#define REG_0AF4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAF4U)) +#define REG_0AF8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAF8U)) +#define REG_0AFCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xAFCU)) +#define REG_0B00H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB00U)) +#define REG_0B04H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB04U)) +#define REG_0B08H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB08U)) +#define REG_0B0CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB0CU)) +#define REG_0B10H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB10U)) +#define REG_0B14H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB14U)) +#define REG_0B18H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB18U)) +#define REG_0B1CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB1CU)) +#define REG_0B20H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB20U)) +#define REG_0B24H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB24U)) +#define REG_0B28H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB28U)) +#define REG_0B2CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB2CU)) +#define REG_0B30H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB30U)) +#define REG_0B34H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB34U)) +#define REG_0B38H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB38U)) +#define REG_0B3CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB3CU)) +#define REG_0B40H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB40U)) +#define REG_0B44H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB44U)) +#define REG_0B48H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB48U)) +#define REG_0B4CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB4CU)) +#define REG_0B50H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB50U)) +#define REG_0B54H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB54U)) +#define REG_0B58H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB58U)) +#define REG_0B5CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB5CU)) +#define REG_0B60H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB60U)) +#define REG_0B64H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB64U)) +#define REG_0B68H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB68U)) +#define REG_0B6CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB6CU)) +#define REG_0B70H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB70U)) +#define REG_0B74H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB74U)) +#define REG_0B78H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB78U)) +#define REG_0B7CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB7CU)) +#define REG_0B80H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB80U)) +#define REG_0B84H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB84U)) +#define REG_0B88H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB88U)) +#define REG_0B8CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB8CU)) +#define REG_0B90H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB90U)) +#define REG_0B94H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB94U)) +#define REG_0B98H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB98U)) +#define REG_0B9CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xB9CU)) +#define REG_0BA0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBA0U)) +#define REG_0BA4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBA4U)) +#define REG_0BA8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBA8U)) +#define REG_0BACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBACU)) +#define REG_0BB0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBB0U)) +#define REG_0BB4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBB4U)) +#define REG_0BB8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBB8U)) +#define REG_0BBCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBBCU)) +#define REG_0BC0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBC0U)) +#define REG_0BC4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBC4U)) +#define REG_0BC8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBC8U)) +#define REG_0BCCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBCCU)) +#define REG_0BD0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBD0U)) +#define REG_0BD4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBD4U)) +#define REG_0BD8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBD8U)) +#define REG_0BDCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBDCU)) +#define REG_0BE0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBE0U)) +#define REG_0BE4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBE4U)) +#define REG_0BE8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBE8U)) +#define REG_0BECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBECU)) +#define REG_0BF0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBF0U)) +#define REG_0BF4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBF4U)) +#define REG_0BF8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBF8U)) +#define REG_0BFCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xBFCU)) +#define REG_0C00H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC00U)) +#define REG_0C04H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC04U)) +#define REG_0C08H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC08U)) +#define REG_0C0CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC0CU)) +#define REG_0C10H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC10U)) +#define REG_0C14H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC14U)) +#define REG_0C18H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC18U)) +#define REG_0C1CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC1CU)) +#define REG_0C20H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC20U)) +#define REG_0C24H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC24U)) +#define REG_0C28H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC28U)) +#define REG_0C2CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC2CU)) +#define REG_0C30H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC30U)) +#define REG_0C34H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC34U)) +#define REG_0C38H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC38U)) +#define REG_0C3CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC3CU)) +#define REG_0C40H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC40U)) +#define REG_0C44H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC44U)) +#define REG_0C48H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC48U)) +#define REG_0C4CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC4CU)) +#define REG_0C50H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC50U)) +#define REG_0C54H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC54U)) +#define REG_0C58H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC58U)) +#define REG_0C5CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC5CU)) +#define REG_0C60H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC60U)) +#define REG_0C64H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC64U)) +#define REG_0C68H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC68U)) +#define REG_0C6CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC6CU)) +#define REG_0C70H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC70U)) +#define REG_0C74H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC74U)) +#define REG_0C78H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC78U)) +#define REG_0C7CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC7CU)) +#define REG_0C80H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC80U)) +#define REG_0C84H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC84U)) +#define REG_0C88H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC88U)) +#define REG_0C8CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC8CU)) +#define REG_0C90H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC90U)) +#define REG_0C94H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC94U)) +#define REG_0C98H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC98U)) +#define REG_0C9CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xC9CU)) +#define REG_0CA0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCA0U)) +#define REG_0CA4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCA4U)) +#define REG_0CA8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCA8U)) +#define REG_0CACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCACU)) +#define REG_0CB0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCB0U)) +#define REG_0CB4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCB4U)) +#define REG_0CB8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCB8U)) +#define REG_0CBCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCBCU)) +#define REG_0CC0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCC0U)) +#define REG_0CC4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCC4U)) +#define REG_0CC8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCC8U)) +#define REG_0CCCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCCCU)) +#define REG_0CD0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCD0U)) +#define REG_0CD4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCD4U)) +#define REG_0CD8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCD8U)) +#define REG_0CDCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCDCU)) +#define REG_0CE0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCE0U)) +#define REG_0CE4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCE4U)) +#define REG_0CE8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCE8U)) +#define REG_0CECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCECU)) +#define REG_0CF0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCF0U)) +#define REG_0CF4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCF4U)) +#define REG_0CF8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCF8U)) +#define REG_0CFCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xCFCU)) +#define REG_0D00H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD00U)) +#define REG_0D04H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD04U)) +#define REG_0D08H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD08U)) +#define REG_0D0CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD0CU)) +#define REG_0D10H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD10U)) +#define REG_0D14H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD14U)) +#define REG_0D18H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD18U)) +#define REG_0D1CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD1CU)) +#define REG_0D20H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD20U)) +#define REG_0D24H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD24U)) +#define REG_0D28H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD28U)) +#define REG_0D2CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD2CU)) +#define REG_0D30H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD30U)) +#define REG_0D34H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD34U)) +#define REG_0D38H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD38U)) +#define REG_0D3CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD3CU)) +#define REG_0D40H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD40U)) +#define REG_0D44H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD44U)) +#define REG_0D48H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD48U)) +#define REG_0D4CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD4CU)) +#define REG_0D50H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD50U)) +#define REG_0D54H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD54U)) +#define REG_0D58H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD58U)) +#define REG_0D5CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD5CU)) +#define REG_0D60H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD60U)) +#define REG_0D64H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD64U)) +#define REG_0D68H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD68U)) +#define REG_0D6CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD6CU)) +#define REG_0D70H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD70U)) +#define REG_0D74H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD74U)) +#define REG_0D78H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD78U)) +#define REG_0D7CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD7CU)) +#define REG_0D80H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD80U)) +#define REG_0D84H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD84U)) +#define REG_0D88H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD88U)) +#define REG_0D8CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD8CU)) +#define REG_0D90H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD90U)) +#define REG_0D94H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD94U)) +#define REG_0D98H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD98U)) +#define REG_0D9CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xD9CU)) +#define REG_0DA0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDA0U)) +#define REG_0DA4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDA4U)) +#define REG_0DA8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDA8U)) +#define REG_0DACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDACU)) +#define REG_0DB0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDB0U)) +#define REG_0DB4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDB4U)) +#define REG_0DB8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDB8U)) +#define REG_0DBCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDBCU)) +#define REG_0DC0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDC0U)) +#define REG_0DC4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDC4U)) +#define REG_0DC8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDC8U)) +#define REG_0DCCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDCCU)) +#define REG_0DD0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDD0U)) +#define REG_0DD4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDD4U)) +#define REG_0DD8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDD8U)) +#define REG_0DDCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDDCU)) +#define REG_0DE0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDE0U)) +#define REG_0DE4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDE4U)) +#define REG_0DE8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDE8U)) +#define REG_0DECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDECU)) +#define REG_0DF0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDF0U)) +#define REG_0DF4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDF4U)) +#define REG_0DF8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDF8U)) +#define REG_0DFCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xDFCU)) +#define REG_0E00H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE00U)) +#define REG_0E04H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE04U)) +#define REG_0E08H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE08U)) +#define REG_0E0CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE0CU)) +#define REG_0E10H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE10U)) +#define REG_0E14H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE14U)) +#define REG_0E18H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE18U)) +#define REG_0E1CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE1CU)) +#define REG_0E20H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE20U)) +#define REG_0E24H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE24U)) +#define REG_0E28H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE28U)) +#define REG_0E2CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE2CU)) +#define REG_0E30H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE30U)) +#define REG_0E34H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE34U)) +#define REG_0E38H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE38U)) +#define REG_0E3CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE3CU)) +#define REG_0E40H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE40U)) +#define REG_0E44H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE44U)) +#define REG_0E48H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE48U)) +#define REG_0E4CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE4CU)) +#define REG_0E50H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE50U)) +#define REG_0E54H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE54U)) +#define REG_0E58H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE58U)) +#define REG_0E5CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE5CU)) +#define REG_0E60H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE60U)) +#define REG_0E64H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE64U)) +#define REG_0E68H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE68U)) +#define REG_0E6CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE6CU)) +#define REG_0E70H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE70U)) +#define REG_0E74H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE74U)) +#define REG_0E78H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE78U)) +#define REG_0E7CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE7CU)) +#define REG_0E80H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE80U)) +#define REG_0E84H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE84U)) +#define REG_0E88H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE88U)) +#define REG_0E8CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE8CU)) +#define REG_0E90H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE90U)) +#define REG_0E94H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE94U)) +#define REG_0E98H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE98U)) +#define REG_0E9CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xE9CU)) +#define REG_0EA0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEA0U)) +#define REG_0EA4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEA4U)) +#define REG_0EA8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEA8U)) +#define REG_0EACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEACU)) +#define REG_0EB0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEB0U)) +#define REG_0EB4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEB4U)) +#define REG_0EB8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEB8U)) +#define REG_0EBCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEBCU)) +#define REG_0EC0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEC0U)) +#define REG_0EC4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEC4U)) +#define REG_0EC8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEC8U)) +#define REG_0ECCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xECCU)) +#define REG_0ED0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xED0U)) +#define REG_0ED4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xED4U)) +#define REG_0ED8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xED8U)) +#define REG_0EDCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEDCU)) +#define REG_0EE0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEE0U)) +#define REG_0EE4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEE4U)) +#define REG_0EE8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEE8U)) +#define REG_0EECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEECU)) +#define REG_0EF0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEF0U)) +#define REG_0EF4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEF4U)) +#define REG_0EF8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEF8U)) +#define REG_0EFCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xEFCU)) +#define REG_0F00H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF00U)) +#define REG_0F04H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF04U)) +#define REG_0F08H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF08U)) +#define REG_0F0CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF0CU)) +#define REG_0F10H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF10U)) +#define REG_0F14H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF14U)) +#define REG_0F18H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF18U)) +#define REG_0F1CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF1CU)) +#define REG_0F20H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF20U)) +#define REG_0F24H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF24U)) +#define REG_0F28H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF28U)) +#define REG_0F2CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF2CU)) +#define REG_0F30H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF30U)) +#define REG_0F34H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF34U)) +#define REG_0F38H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF38U)) +#define REG_0F3CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF3CU)) +#define REG_0F40H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF40U)) +#define REG_0F44H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF44U)) +#define REG_0F48H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF48U)) +#define REG_0F4CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF4CU)) +#define REG_0F50H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF50U)) +#define REG_0F54H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF54U)) +#define REG_0F58H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF58U)) +#define REG_0F5CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF5CU)) +#define REG_0F60H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF60U)) +#define REG_0F64H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF64U)) +#define REG_0F68H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF68U)) +#define REG_0F6CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF6CU)) +#define REG_0F70H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF70U)) +#define REG_0F74H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF74U)) +#define REG_0F78H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF78U)) +#define REG_0F7CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF7CU)) +#define REG_0F80H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF80U)) +#define REG_0F84H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF84U)) +#define REG_0F88H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF88U)) +#define REG_0F8CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF8CU)) +#define REG_0F90H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF90U)) +#define REG_0F94H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF94U)) +#define REG_0F98H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF98U)) +#define REG_0F9CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xF9CU)) +#define REG_0FA0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFA0U)) +#define REG_0FA4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFA4U)) +#define REG_0FA8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFA8U)) +#define REG_0FACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFACU)) +#define REG_0FB0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFB0U)) +#define REG_0FB4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFB4U)) +#define REG_0FB8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFB8U)) +#define REG_0FBCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFBCU)) +#define REG_0FC0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFC0U)) +#define REG_0FC4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFC4U)) +#define REG_0FC8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFC8U)) +#define REG_0FCCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFCCU)) +#define REG_0FD0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFD0U)) +#define REG_0FD4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFD4U)) +#define REG_0FD8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFD8U)) +#define REG_0FDCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFDCU)) +#define REG_0FE0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFE0U)) +#define REG_0FE4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFE4U)) +#define REG_0FE8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFE8U)) +#define REG_0FECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFECU)) +#define REG_0FF0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFF0U)) +#define REG_0FF4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFF4U)) +#define REG_0FF8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFF8U)) +#define REG_0FFCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_0000H + 0xFFCU)) +#define REG_1000H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x000U)) +#define REG_1004H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x004U)) +#define REG_1008H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x008U)) +#define REG_100CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x00CU)) +#define REG_1010H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x010U)) +#define REG_1014H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x014U)) +#define REG_1018H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x018U)) +#define REG_101CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x01CU)) +#define REG_1020H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x020U)) +#define REG_1024H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x024U)) +#define REG_1028H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x028U)) +#define REG_102CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x02CU)) +#define REG_1030H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x030U)) +#define REG_1034H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x034U)) +#define REG_1038H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x038U)) +#define REG_103CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x03CU)) +#define REG_1040H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x040U)) +#define REG_1044H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x044U)) +#define REG_1048H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x048U)) +#define REG_104CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x04CU)) +#define REG_1050H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x050U)) +#define REG_1054H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x054U)) +#define REG_1058H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x058U)) +#define REG_105CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x05CU)) +#define REG_1060H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x060U)) +#define REG_1064H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x064U)) +#define REG_1068H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x068U)) +#define REG_106CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x06CU)) +#define REG_1070H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x070U)) +#define REG_1074H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x074U)) +#define REG_1078H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x078U)) +#define REG_107CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x07CU)) +#define REG_1080H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x080U)) +#define REG_1084H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x084U)) +#define REG_1088H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x088U)) +#define REG_108CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x08CU)) +#define REG_1090H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x090U)) +#define REG_1094H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x094U)) +#define REG_1098H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x098U)) +#define REG_109CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x09CU)) +#define REG_10A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0A0U)) +#define REG_10A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0A4U)) +#define REG_10A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0A8U)) +#define REG_10ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0ACU)) +#define REG_10B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0B0U)) +#define REG_10B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0B4U)) +#define REG_10B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0B8U)) +#define REG_10BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0BCU)) +#define REG_10C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0C0U)) +#define REG_10C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0C4U)) +#define REG_10C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0C8U)) +#define REG_10CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0CCU)) +#define REG_10D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0D0U)) +#define REG_10D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0D4U)) +#define REG_10D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0D8U)) +#define REG_10DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0DCU)) +#define REG_10E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0E0U)) +#define REG_10E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0E4U)) +#define REG_10E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0E8U)) +#define REG_10ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0ECU)) +#define REG_10F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0F0U)) +#define REG_10F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0F4U)) +#define REG_10F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0F8U)) +#define REG_10FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x0FCU)) +#define REG_1100H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x100U)) +#define REG_1104H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x104U)) +#define REG_1108H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x108U)) +#define REG_110CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x10CU)) +#define REG_1110H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x110U)) +#define REG_1114H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x114U)) +#define REG_1118H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x118U)) +#define REG_111CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x11CU)) +#define REG_1120H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x120U)) +#define REG_1124H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x124U)) +#define REG_1128H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x128U)) +#define REG_112CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x12CU)) +#define REG_1130H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x130U)) +#define REG_1134H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x134U)) +#define REG_1138H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x138U)) +#define REG_113CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x13CU)) +#define REG_1140H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x140U)) +#define REG_1144H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x144U)) +#define REG_1148H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x148U)) +#define REG_114CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x14CU)) +#define REG_1150H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x150U)) +#define REG_1154H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x154U)) +#define REG_1158H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x158U)) +#define REG_115CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x15CU)) +#define REG_1160H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x160U)) +#define REG_1164H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x164U)) +#define REG_1168H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x168U)) +#define REG_116CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x16CU)) +#define REG_1170H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x170U)) +#define REG_1174H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x174U)) +#define REG_1178H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x178U)) +#define REG_117CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x17CU)) +#define REG_1180H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x180U)) +#define REG_1184H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x184U)) +#define REG_1188H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x188U)) +#define REG_118CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x18CU)) +#define REG_1190H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x190U)) +#define REG_1194H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x194U)) +#define REG_1198H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x198U)) +#define REG_119CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x19CU)) +#define REG_11A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1A0U)) +#define REG_11A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1A4U)) +#define REG_11A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1A8U)) +#define REG_11ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1ACU)) +#define REG_11B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1B0U)) +#define REG_11B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1B4U)) +#define REG_11B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1B8U)) +#define REG_11BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1BCU)) +#define REG_11C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1C0U)) +#define REG_11C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1C4U)) +#define REG_11C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1C8U)) +#define REG_11CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1CCU)) +#define REG_11D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1D0U)) +#define REG_11D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1D4U)) +#define REG_11D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1D8U)) +#define REG_11DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1DCU)) +#define REG_11E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1E0U)) +#define REG_11E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1E4U)) +#define REG_11E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1E8U)) +#define REG_11ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1ECU)) +#define REG_11F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1F0U)) +#define REG_11F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1F4U)) +#define REG_11F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1F8U)) +#define REG_11FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x1FCU)) +#define REG_1200H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x200U)) +#define REG_1204H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x204U)) +#define REG_1208H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x208U)) +#define REG_120CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x20CU)) +#define REG_1210H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x210U)) +#define REG_1214H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x214U)) +#define REG_1218H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x218U)) +#define REG_121CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x21CU)) +#define REG_1220H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x220U)) +#define REG_1224H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x224U)) +#define REG_1228H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x228U)) +#define REG_122CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x22CU)) +#define REG_1230H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x230U)) +#define REG_1234H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x234U)) +#define REG_1238H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x238U)) +#define REG_123CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x23CU)) +#define REG_1240H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x240U)) +#define REG_1244H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x244U)) +#define REG_1248H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x248U)) +#define REG_124CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x24CU)) +#define REG_1250H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x250U)) +#define REG_1254H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x254U)) +#define REG_1258H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x258U)) +#define REG_125CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x25CU)) +#define REG_1260H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x260U)) +#define REG_1264H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x264U)) +#define REG_1268H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x268U)) +#define REG_126CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x26CU)) +#define REG_1270H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x270U)) +#define REG_1274H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x274U)) +#define REG_1278H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x278U)) +#define REG_127CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x27CU)) +#define REG_1280H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x280U)) +#define REG_1284H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x284U)) +#define REG_1288H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x288U)) +#define REG_128CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x28CU)) +#define REG_1290H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x290U)) +#define REG_1294H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x294U)) +#define REG_1298H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x298U)) +#define REG_129CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x29CU)) +#define REG_12A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2A0U)) +#define REG_12A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2A4U)) +#define REG_12A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2A8U)) +#define REG_12ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2ACU)) +#define REG_12B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2B0U)) +#define REG_12B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2B4U)) +#define REG_12B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2B8U)) +#define REG_12BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2BCU)) +#define REG_12C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2C0U)) +#define REG_12C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2C4U)) +#define REG_12C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2C8U)) +#define REG_12CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2CCU)) +#define REG_12D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2D0U)) +#define REG_12D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2D4U)) +#define REG_12D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2D8U)) +#define REG_12DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2DCU)) +#define REG_12E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2E0U)) +#define REG_12E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2E4U)) +#define REG_12E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2E8U)) +#define REG_12ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2ECU)) +#define REG_12F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2F0U)) +#define REG_12F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2F4U)) +#define REG_12F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2F8U)) +#define REG_12FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x2FCU)) +#define REG_1300H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x300U)) +#define REG_1304H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x304U)) +#define REG_1308H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x308U)) +#define REG_130CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x30CU)) +#define REG_1310H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x310U)) +#define REG_1314H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x314U)) +#define REG_1318H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x318U)) +#define REG_131CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x31CU)) +#define REG_1320H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x320U)) +#define REG_1324H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x324U)) +#define REG_1328H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x328U)) +#define REG_132CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x32CU)) +#define REG_1330H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x330U)) +#define REG_1334H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x334U)) +#define REG_1338H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x338U)) +#define REG_133CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x33CU)) +#define REG_1340H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x340U)) +#define REG_1344H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x344U)) +#define REG_1348H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x348U)) +#define REG_134CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x34CU)) +#define REG_1350H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x350U)) +#define REG_1354H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x354U)) +#define REG_1358H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x358U)) +#define REG_135CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x35CU)) +#define REG_1360H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x360U)) +#define REG_1364H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x364U)) +#define REG_1368H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x368U)) +#define REG_136CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x36CU)) +#define REG_1370H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x370U)) +#define REG_1374H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x374U)) +#define REG_1378H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x378U)) +#define REG_137CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x37CU)) +#define REG_1380H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x380U)) +#define REG_1384H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x384U)) +#define REG_1388H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x388U)) +#define REG_138CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x38CU)) +#define REG_1390H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x390U)) +#define REG_1394H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x394U)) +#define REG_1398H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x398U)) +#define REG_139CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x39CU)) +#define REG_13A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3A0U)) +#define REG_13A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3A4U)) +#define REG_13A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3A8U)) +#define REG_13ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3ACU)) +#define REG_13B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3B0U)) +#define REG_13B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3B4U)) +#define REG_13B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3B8U)) +#define REG_13BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3BCU)) +#define REG_13C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3C0U)) +#define REG_13C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3C4U)) +#define REG_13C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3C8U)) +#define REG_13CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3CCU)) +#define REG_13D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3D0U)) +#define REG_13D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3D4U)) +#define REG_13D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3D8U)) +#define REG_13DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3DCU)) +#define REG_13E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3E0U)) +#define REG_13E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3E4U)) +#define REG_13E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3E8U)) +#define REG_13ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3ECU)) +#define REG_13F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3F0U)) +#define REG_13F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3F4U)) +#define REG_13F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3F8U)) +#define REG_13FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x3FCU)) +#define REG_1400H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x400U)) +#define REG_1404H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x404U)) +#define REG_1408H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x408U)) +#define REG_140CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x40CU)) +#define REG_1410H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x410U)) +#define REG_1414H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x414U)) +#define REG_1418H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x418U)) +#define REG_141CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x41CU)) +#define REG_1420H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x420U)) +#define REG_1424H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x424U)) +#define REG_1428H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x428U)) +#define REG_142CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x42CU)) +#define REG_1430H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x430U)) +#define REG_1434H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x434U)) +#define REG_1438H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x438U)) +#define REG_143CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x43CU)) +#define REG_1440H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x440U)) +#define REG_1444H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x444U)) +#define REG_1448H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x448U)) +#define REG_144CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x44CU)) +#define REG_1450H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x450U)) +#define REG_1454H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x454U)) +#define REG_1458H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x458U)) +#define REG_145CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x45CU)) +#define REG_1460H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x460U)) +#define REG_1464H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x464U)) +#define REG_1468H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x468U)) +#define REG_146CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x46CU)) +#define REG_1470H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x470U)) +#define REG_1474H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x474U)) +#define REG_1478H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x478U)) +#define REG_147CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x47CU)) +#define REG_1480H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x480U)) +#define REG_1484H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x484U)) +#define REG_1488H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x488U)) +#define REG_148CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x48CU)) +#define REG_1490H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x490U)) +#define REG_1494H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x494U)) +#define REG_1498H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x498U)) +#define REG_149CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x49CU)) +#define REG_14A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4A0U)) +#define REG_14A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4A4U)) +#define REG_14A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4A8U)) +#define REG_14ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4ACU)) +#define REG_14B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4B0U)) +#define REG_14B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4B4U)) +#define REG_14B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4B8U)) +#define REG_14BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4BCU)) +#define REG_14C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4C0U)) +#define REG_14C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4C4U)) +#define REG_14C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4C8U)) +#define REG_14CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4CCU)) +#define REG_14D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4D0U)) +#define REG_14D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4D4U)) +#define REG_14D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4D8U)) +#define REG_14DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4DCU)) +#define REG_14E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4E0U)) +#define REG_14E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4E4U)) +#define REG_14E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4E8U)) +#define REG_14ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4ECU)) +#define REG_14F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4F0U)) +#define REG_14F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4F4U)) +#define REG_14F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4F8U)) +#define REG_14FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x4FCU)) +#define REG_1500H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x500U)) +#define REG_1504H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x504U)) +#define REG_1508H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x508U)) +#define REG_150CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x50CU)) +#define REG_1510H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x510U)) +#define REG_1514H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x514U)) +#define REG_1518H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x518U)) +#define REG_151CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x51CU)) +#define REG_1520H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x520U)) +#define REG_1524H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x524U)) +#define REG_1528H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x528U)) +#define REG_152CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x52CU)) +#define REG_1530H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x530U)) +#define REG_1534H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x534U)) +#define REG_1538H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x538U)) +#define REG_153CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x53CU)) +#define REG_1540H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x540U)) +#define REG_1544H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x544U)) +#define REG_1548H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x548U)) +#define REG_154CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x54CU)) +#define REG_1550H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x550U)) +#define REG_1554H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x554U)) +#define REG_1558H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x558U)) +#define REG_155CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x55CU)) +#define REG_1560H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x560U)) +#define REG_1564H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x564U)) +#define REG_1568H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x568U)) +#define REG_156CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x56CU)) +#define REG_1570H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x570U)) +#define REG_1574H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x574U)) +#define REG_1578H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x578U)) +#define REG_157CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x57CU)) +#define REG_1580H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x580U)) +#define REG_1584H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x584U)) +#define REG_1588H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x588U)) +#define REG_158CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x58CU)) +#define REG_1590H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x590U)) +#define REG_1594H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x594U)) +#define REG_1598H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x598U)) +#define REG_159CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x59CU)) +#define REG_15A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5A0U)) +#define REG_15A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5A4U)) +#define REG_15A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5A8U)) +#define REG_15ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5ACU)) +#define REG_15B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5B0U)) +#define REG_15B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5B4U)) +#define REG_15B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5B8U)) +#define REG_15BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5BCU)) +#define REG_15C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5C0U)) +#define REG_15C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5C4U)) +#define REG_15C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5C8U)) +#define REG_15CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5CCU)) +#define REG_15D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5D0U)) +#define REG_15D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5D4U)) +#define REG_15D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5D8U)) +#define REG_15DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5DCU)) +#define REG_15E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5E0U)) +#define REG_15E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5E4U)) +#define REG_15E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5E8U)) +#define REG_15ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5ECU)) +#define REG_15F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5F0U)) +#define REG_15F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5F4U)) +#define REG_15F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5F8U)) +#define REG_15FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x5FCU)) +#define REG_1600H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x600U)) +#define REG_1604H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x604U)) +#define REG_1608H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x608U)) +#define REG_160CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x60CU)) +#define REG_1610H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x610U)) +#define REG_1614H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x614U)) +#define REG_1618H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x618U)) +#define REG_161CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x61CU)) +#define REG_1620H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x620U)) +#define REG_1624H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x624U)) +#define REG_1628H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x628U)) +#define REG_162CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x62CU)) +#define REG_1630H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x630U)) +#define REG_1634H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x634U)) +#define REG_1638H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x638U)) +#define REG_163CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x63CU)) +#define REG_1640H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x640U)) +#define REG_1644H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x644U)) +#define REG_1648H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x648U)) +#define REG_164CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x64CU)) +#define REG_1650H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x650U)) +#define REG_1654H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x654U)) +#define REG_1658H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x658U)) +#define REG_165CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x65CU)) +#define REG_1660H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x660U)) +#define REG_1664H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x664U)) +#define REG_1668H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x668U)) +#define REG_166CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x66CU)) +#define REG_1670H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x670U)) +#define REG_1674H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x674U)) +#define REG_1678H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x678U)) +#define REG_167CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x67CU)) +#define REG_1680H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x680U)) +#define REG_1684H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x684U)) +#define REG_1688H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x688U)) +#define REG_168CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x68CU)) +#define REG_1690H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x690U)) +#define REG_1694H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x694U)) +#define REG_1698H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x698U)) +#define REG_169CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x69CU)) +#define REG_16A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6A0U)) +#define REG_16A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6A4U)) +#define REG_16A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6A8U)) +#define REG_16ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6ACU)) +#define REG_16B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6B0U)) +#define REG_16B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6B4U)) +#define REG_16B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6B8U)) +#define REG_16BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6BCU)) +#define REG_16C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6C0U)) +#define REG_16C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6C4U)) +#define REG_16C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6C8U)) +#define REG_16CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6CCU)) +#define REG_16D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6D0U)) +#define REG_16D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6D4U)) +#define REG_16D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6D8U)) +#define REG_16DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6DCU)) +#define REG_16E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6E0U)) +#define REG_16E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6E4U)) +#define REG_16E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6E8U)) +#define REG_16ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6ECU)) +#define REG_16F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6F0U)) +#define REG_16F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6F4U)) +#define REG_16F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6F8U)) +#define REG_16FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x6FCU)) +#define REG_1700H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x700U)) +#define REG_1704H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x704U)) +#define REG_1708H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x708U)) +#define REG_170CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x70CU)) +#define REG_1710H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x710U)) +#define REG_1714H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x714U)) +#define REG_1718H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x718U)) +#define REG_171CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x71CU)) +#define REG_1720H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x720U)) +#define REG_1724H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x724U)) +#define REG_1728H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x728U)) +#define REG_172CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x72CU)) +#define REG_1730H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x730U)) +#define REG_1734H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x734U)) +#define REG_1738H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x738U)) +#define REG_173CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x73CU)) +#define REG_1740H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x740U)) +#define REG_1744H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x744U)) +#define REG_1748H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x748U)) +#define REG_174CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x74CU)) +#define REG_1750H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x750U)) +#define REG_1754H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x754U)) +#define REG_1758H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x758U)) +#define REG_175CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x75CU)) +#define REG_1760H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x760U)) +#define REG_1764H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x764U)) +#define REG_1768H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x768U)) +#define REG_176CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x76CU)) +#define REG_1770H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x770U)) +#define REG_1774H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x774U)) +#define REG_1778H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x778U)) +#define REG_177CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x77CU)) +#define REG_1780H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x780U)) +#define REG_1784H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x784U)) +#define REG_1788H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x788U)) +#define REG_178CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x78CU)) +#define REG_1790H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x790U)) +#define REG_1794H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x794U)) +#define REG_1798H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x798U)) +#define REG_179CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x79CU)) +#define REG_17A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7A0U)) +#define REG_17A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7A4U)) +#define REG_17A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7A8U)) +#define REG_17ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7ACU)) +#define REG_17B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7B0U)) +#define REG_17B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7B4U)) +#define REG_17B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7B8U)) +#define REG_17BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7BCU)) +#define REG_17C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7C0U)) +#define REG_17C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7C4U)) +#define REG_17C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7C8U)) +#define REG_17CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7CCU)) +#define REG_17D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7D0U)) +#define REG_17D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7D4U)) +#define REG_17D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7D8U)) +#define REG_17DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7DCU)) +#define REG_17E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7E0U)) +#define REG_17E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7E4U)) +#define REG_17E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7E8U)) +#define REG_17ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7ECU)) +#define REG_17F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7F0U)) +#define REG_17F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7F4U)) +#define REG_17F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7F8U)) +#define REG_17FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x7FCU)) +#define REG_1800H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x800U)) +#define REG_1804H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x804U)) +#define REG_1808H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x808U)) +#define REG_180CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x80CU)) +#define REG_1810H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x810U)) +#define REG_1814H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x814U)) +#define REG_1818H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x818U)) +#define REG_181CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x81CU)) +#define REG_1820H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x820U)) +#define REG_1824H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x824U)) +#define REG_1828H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x828U)) +#define REG_182CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x82CU)) +#define REG_1830H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x830U)) +#define REG_1834H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x834U)) +#define REG_1838H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x838U)) +#define REG_183CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x83CU)) +#define REG_1840H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x840U)) +#define REG_1844H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x844U)) +#define REG_1848H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x848U)) +#define REG_184CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x84CU)) +#define REG_1850H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x850U)) +#define REG_1854H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x854U)) +#define REG_1858H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x858U)) +#define REG_185CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x85CU)) +#define REG_1860H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x860U)) +#define REG_1864H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x864U)) +#define REG_1868H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x868U)) +#define REG_186CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x86CU)) +#define REG_1870H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x870U)) +#define REG_1874H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x874U)) +#define REG_1878H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x878U)) +#define REG_187CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x87CU)) +#define REG_1880H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x880U)) +#define REG_1884H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x884U)) +#define REG_1888H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x888U)) +#define REG_188CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x88CU)) +#define REG_1890H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x890U)) +#define REG_1894H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x894U)) +#define REG_1898H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x898U)) +#define REG_189CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x89CU)) +#define REG_18A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8A0U)) +#define REG_18A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8A4U)) +#define REG_18A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8A8U)) +#define REG_18ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8ACU)) +#define REG_18B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8B0U)) +#define REG_18B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8B4U)) +#define REG_18B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8B8U)) +#define REG_18BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8BCU)) +#define REG_18C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8C0U)) +#define REG_18C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8C4U)) +#define REG_18C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8C8U)) +#define REG_18CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8CCU)) +#define REG_18D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8D0U)) +#define REG_18D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8D4U)) +#define REG_18D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8D8U)) +#define REG_18DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8DCU)) +#define REG_18E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8E0U)) +#define REG_18E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8E4U)) +#define REG_18E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8E8U)) +#define REG_18ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8ECU)) +#define REG_18F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8F0U)) +#define REG_18F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8F4U)) +#define REG_18F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8F8U)) +#define REG_18FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x8FCU)) +#define REG_1900H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x900U)) +#define REG_1904H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x904U)) +#define REG_1908H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x908U)) +#define REG_190CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x90CU)) +#define REG_1910H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x910U)) +#define REG_1914H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x914U)) +#define REG_1918H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x918U)) +#define REG_191CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x91CU)) +#define REG_1920H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x920U)) +#define REG_1924H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x924U)) +#define REG_1928H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x928U)) +#define REG_192CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x92CU)) +#define REG_1930H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x930U)) +#define REG_1934H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x934U)) +#define REG_1938H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x938U)) +#define REG_193CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x93CU)) +#define REG_1940H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x940U)) +#define REG_1944H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x944U)) +#define REG_1948H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x948U)) +#define REG_194CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x94CU)) +#define REG_1950H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x950U)) +#define REG_1954H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x954U)) +#define REG_1958H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x958U)) +#define REG_195CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x95CU)) +#define REG_1960H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x960U)) +#define REG_1964H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x964U)) +#define REG_1968H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x968U)) +#define REG_196CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x96CU)) +#define REG_1970H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x970U)) +#define REG_1974H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x974U)) +#define REG_1978H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x978U)) +#define REG_197CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x97CU)) +#define REG_1980H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x980U)) +#define REG_1984H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x984U)) +#define REG_1988H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x988U)) +#define REG_198CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x98CU)) +#define REG_1990H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x990U)) +#define REG_1994H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x994U)) +#define REG_1998H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x998U)) +#define REG_199CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x99CU)) +#define REG_19A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9A0U)) +#define REG_19A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9A4U)) +#define REG_19A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9A8U)) +#define REG_19ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9ACU)) +#define REG_19B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9B0U)) +#define REG_19B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9B4U)) +#define REG_19B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9B8U)) +#define REG_19BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9BCU)) +#define REG_19C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9C0U)) +#define REG_19C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9C4U)) +#define REG_19C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9C8U)) +#define REG_19CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9CCU)) +#define REG_19D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9D0U)) +#define REG_19D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9D4U)) +#define REG_19D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9D8U)) +#define REG_19DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9DCU)) +#define REG_19E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9E0U)) +#define REG_19E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9E4U)) +#define REG_19E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9E8U)) +#define REG_19ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9ECU)) +#define REG_19F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9F0U)) +#define REG_19F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9F4U)) +#define REG_19F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9F8U)) +#define REG_19FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0x9FCU)) +#define REG_1A00H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA00U)) +#define REG_1A04H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA04U)) +#define REG_1A08H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA08U)) +#define REG_1A0CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA0CU)) +#define REG_1A10H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA10U)) +#define REG_1A14H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA14U)) +#define REG_1A18H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA18U)) +#define REG_1A1CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA1CU)) +#define REG_1A20H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA20U)) +#define REG_1A24H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA24U)) +#define REG_1A28H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA28U)) +#define REG_1A2CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA2CU)) +#define REG_1A30H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA30U)) +#define REG_1A34H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA34U)) +#define REG_1A38H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA38U)) +#define REG_1A3CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA3CU)) +#define REG_1A40H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA40U)) +#define REG_1A44H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA44U)) +#define REG_1A48H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA48U)) +#define REG_1A4CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA4CU)) +#define REG_1A50H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA50U)) +#define REG_1A54H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA54U)) +#define REG_1A58H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA58U)) +#define REG_1A5CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA5CU)) +#define REG_1A60H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA60U)) +#define REG_1A64H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA64U)) +#define REG_1A68H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA68U)) +#define REG_1A6CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA6CU)) +#define REG_1A70H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA70U)) +#define REG_1A74H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA74U)) +#define REG_1A78H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA78U)) +#define REG_1A7CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA7CU)) +#define REG_1A80H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA80U)) +#define REG_1A84H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA84U)) +#define REG_1A88H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA88U)) +#define REG_1A8CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA8CU)) +#define REG_1A90H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA90U)) +#define REG_1A94H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA94U)) +#define REG_1A98H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA98U)) +#define REG_1A9CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xA9CU)) +#define REG_1AA0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAA0U)) +#define REG_1AA4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAA4U)) +#define REG_1AA8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAA8U)) +#define REG_1AACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAACU)) +#define REG_1AB0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAB0U)) +#define REG_1AB4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAB4U)) +#define REG_1AB8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAB8U)) +#define REG_1ABCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xABCU)) +#define REG_1AC0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAC0U)) +#define REG_1AC4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAC4U)) +#define REG_1AC8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAC8U)) +#define REG_1ACCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xACCU)) +#define REG_1AD0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAD0U)) +#define REG_1AD4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAD4U)) +#define REG_1AD8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAD8U)) +#define REG_1ADCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xADCU)) +#define REG_1AE0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAE0U)) +#define REG_1AE4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAE4U)) +#define REG_1AE8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAE8U)) +#define REG_1AECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAECU)) +#define REG_1AF0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAF0U)) +#define REG_1AF4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAF4U)) +#define REG_1AF8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAF8U)) +#define REG_1AFCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xAFCU)) +#define REG_1B00H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB00U)) +#define REG_1B04H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB04U)) +#define REG_1B08H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB08U)) +#define REG_1B0CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB0CU)) +#define REG_1B10H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB10U)) +#define REG_1B14H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB14U)) +#define REG_1B18H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB18U)) +#define REG_1B1CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB1CU)) +#define REG_1B20H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB20U)) +#define REG_1B24H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB24U)) +#define REG_1B28H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB28U)) +#define REG_1B2CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB2CU)) +#define REG_1B30H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB30U)) +#define REG_1B34H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB34U)) +#define REG_1B38H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB38U)) +#define REG_1B3CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB3CU)) +#define REG_1B40H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB40U)) +#define REG_1B44H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB44U)) +#define REG_1B48H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB48U)) +#define REG_1B4CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB4CU)) +#define REG_1B50H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB50U)) +#define REG_1B54H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB54U)) +#define REG_1B58H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB58U)) +#define REG_1B5CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB5CU)) +#define REG_1B60H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB60U)) +#define REG_1B64H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB64U)) +#define REG_1B68H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB68U)) +#define REG_1B6CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB6CU)) +#define REG_1B70H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB70U)) +#define REG_1B74H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB74U)) +#define REG_1B78H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB78U)) +#define REG_1B7CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB7CU)) +#define REG_1B80H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB80U)) +#define REG_1B84H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB84U)) +#define REG_1B88H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB88U)) +#define REG_1B8CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB8CU)) +#define REG_1B90H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB90U)) +#define REG_1B94H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB94U)) +#define REG_1B98H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB98U)) +#define REG_1B9CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xB9CU)) +#define REG_1BA0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBA0U)) +#define REG_1BA4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBA4U)) +#define REG_1BA8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBA8U)) +#define REG_1BACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBACU)) +#define REG_1BB0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBB0U)) +#define REG_1BB4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBB4U)) +#define REG_1BB8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBB8U)) +#define REG_1BBCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBBCU)) +#define REG_1BC0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBC0U)) +#define REG_1BC4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBC4U)) +#define REG_1BC8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBC8U)) +#define REG_1BCCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBCCU)) +#define REG_1BD0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBD0U)) +#define REG_1BD4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBD4U)) +#define REG_1BD8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBD8U)) +#define REG_1BDCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBDCU)) +#define REG_1BE0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBE0U)) +#define REG_1BE4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBE4U)) +#define REG_1BE8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBE8U)) +#define REG_1BECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBECU)) +#define REG_1BF0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBF0U)) +#define REG_1BF4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBF4U)) +#define REG_1BF8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBF8U)) +#define REG_1BFCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xBFCU)) +#define REG_1C00H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC00U)) +#define REG_1C04H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC04U)) +#define REG_1C08H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC08U)) +#define REG_1C0CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC0CU)) +#define REG_1C10H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC10U)) +#define REG_1C14H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC14U)) +#define REG_1C18H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC18U)) +#define REG_1C1CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC1CU)) +#define REG_1C20H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC20U)) +#define REG_1C24H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC24U)) +#define REG_1C28H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC28U)) +#define REG_1C2CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC2CU)) +#define REG_1C30H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC30U)) +#define REG_1C34H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC34U)) +#define REG_1C38H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC38U)) +#define REG_1C3CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC3CU)) +#define REG_1C40H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC40U)) +#define REG_1C44H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC44U)) +#define REG_1C48H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC48U)) +#define REG_1C4CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC4CU)) +#define REG_1C50H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC50U)) +#define REG_1C54H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC54U)) +#define REG_1C58H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC58U)) +#define REG_1C5CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC5CU)) +#define REG_1C60H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC60U)) +#define REG_1C64H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC64U)) +#define REG_1C68H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC68U)) +#define REG_1C6CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC6CU)) +#define REG_1C70H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC70U)) +#define REG_1C74H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC74U)) +#define REG_1C78H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC78U)) +#define REG_1C7CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC7CU)) +#define REG_1C80H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC80U)) +#define REG_1C84H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC84U)) +#define REG_1C88H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC88U)) +#define REG_1C8CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC8CU)) +#define REG_1C90H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC90U)) +#define REG_1C94H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC94U)) +#define REG_1C98H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC98U)) +#define REG_1C9CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xC9CU)) +#define REG_1CA0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCA0U)) +#define REG_1CA4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCA4U)) +#define REG_1CA8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCA8U)) +#define REG_1CACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCACU)) +#define REG_1CB0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCB0U)) +#define REG_1CB4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCB4U)) +#define REG_1CB8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCB8U)) +#define REG_1CBCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCBCU)) +#define REG_1CC0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCC0U)) +#define REG_1CC4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCC4U)) +#define REG_1CC8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCC8U)) +#define REG_1CCCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCCCU)) +#define REG_1CD0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCD0U)) +#define REG_1CD4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCD4U)) +#define REG_1CD8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCD8U)) +#define REG_1CDCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCDCU)) +#define REG_1CE0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCE0U)) +#define REG_1CE4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCE4U)) +#define REG_1CE8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCE8U)) +#define REG_1CECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCECU)) +#define REG_1CF0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCF0U)) +#define REG_1CF4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCF4U)) +#define REG_1CF8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCF8U)) +#define REG_1CFCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xCFCU)) +#define REG_1D00H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD00U)) +#define REG_1D04H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD04U)) +#define REG_1D08H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD08U)) +#define REG_1D0CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD0CU)) +#define REG_1D10H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD10U)) +#define REG_1D14H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD14U)) +#define REG_1D18H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD18U)) +#define REG_1D1CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD1CU)) +#define REG_1D20H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD20U)) +#define REG_1D24H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD24U)) +#define REG_1D28H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD28U)) +#define REG_1D2CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD2CU)) +#define REG_1D30H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD30U)) +#define REG_1D34H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD34U)) +#define REG_1D38H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD38U)) +#define REG_1D3CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD3CU)) +#define REG_1D40H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD40U)) +#define REG_1D44H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD44U)) +#define REG_1D48H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD48U)) +#define REG_1D4CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD4CU)) +#define REG_1D50H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD50U)) +#define REG_1D54H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD54U)) +#define REG_1D58H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD58U)) +#define REG_1D5CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD5CU)) +#define REG_1D60H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD60U)) +#define REG_1D64H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD64U)) +#define REG_1D68H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD68U)) +#define REG_1D6CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD6CU)) +#define REG_1D70H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD70U)) +#define REG_1D74H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD74U)) +#define REG_1D78H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD78U)) +#define REG_1D7CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD7CU)) +#define REG_1D80H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD80U)) +#define REG_1D84H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD84U)) +#define REG_1D88H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD88U)) +#define REG_1D8CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD8CU)) +#define REG_1D90H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD90U)) +#define REG_1D94H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD94U)) +#define REG_1D98H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD98U)) +#define REG_1D9CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xD9CU)) +#define REG_1DA0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDA0U)) +#define REG_1DA4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDA4U)) +#define REG_1DA8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDA8U)) +#define REG_1DACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDACU)) +#define REG_1DB0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDB0U)) +#define REG_1DB4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDB4U)) +#define REG_1DB8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDB8U)) +#define REG_1DBCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDBCU)) +#define REG_1DC0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDC0U)) +#define REG_1DC4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDC4U)) +#define REG_1DC8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDC8U)) +#define REG_1DCCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDCCU)) +#define REG_1DD0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDD0U)) +#define REG_1DD4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDD4U)) +#define REG_1DD8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDD8U)) +#define REG_1DDCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDDCU)) +#define REG_1DE0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDE0U)) +#define REG_1DE4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDE4U)) +#define REG_1DE8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDE8U)) +#define REG_1DECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDECU)) +#define REG_1DF0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDF0U)) +#define REG_1DF4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDF4U)) +#define REG_1DF8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDF8U)) +#define REG_1DFCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xDFCU)) +#define REG_1E00H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE00U)) +#define REG_1E04H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE04U)) +#define REG_1E08H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE08U)) +#define REG_1E0CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE0CU)) +#define REG_1E10H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE10U)) +#define REG_1E14H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE14U)) +#define REG_1E18H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE18U)) +#define REG_1E1CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE1CU)) +#define REG_1E20H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE20U)) +#define REG_1E24H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE24U)) +#define REG_1E28H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE28U)) +#define REG_1E2CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE2CU)) +#define REG_1E30H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE30U)) +#define REG_1E34H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE34U)) +#define REG_1E38H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE38U)) +#define REG_1E3CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE3CU)) +#define REG_1E40H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE40U)) +#define REG_1E44H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE44U)) +#define REG_1E48H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE48U)) +#define REG_1E4CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE4CU)) +#define REG_1E50H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE50U)) +#define REG_1E54H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE54U)) +#define REG_1E58H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE58U)) +#define REG_1E5CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE5CU)) +#define REG_1E60H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE60U)) +#define REG_1E64H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE64U)) +#define REG_1E68H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE68U)) +#define REG_1E6CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE6CU)) +#define REG_1E70H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE70U)) +#define REG_1E74H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE74U)) +#define REG_1E78H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE78U)) +#define REG_1E7CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE7CU)) +#define REG_1E80H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE80U)) +#define REG_1E84H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE84U)) +#define REG_1E88H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE88U)) +#define REG_1E8CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE8CU)) +#define REG_1E90H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE90U)) +#define REG_1E94H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE94U)) +#define REG_1E98H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE98U)) +#define REG_1E9CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xE9CU)) +#define REG_1EA0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEA0U)) +#define REG_1EA4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEA4U)) +#define REG_1EA8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEA8U)) +#define REG_1EACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEACU)) +#define REG_1EB0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEB0U)) +#define REG_1EB4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEB4U)) +#define REG_1EB8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEB8U)) +#define REG_1EBCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEBCU)) +#define REG_1EC0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEC0U)) +#define REG_1EC4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEC4U)) +#define REG_1EC8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEC8U)) +#define REG_1ECCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xECCU)) +#define REG_1ED0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xED0U)) +#define REG_1ED4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xED4U)) +#define REG_1ED8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xED8U)) +#define REG_1EDCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEDCU)) +#define REG_1EE0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEE0U)) +#define REG_1EE4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEE4U)) +#define REG_1EE8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEE8U)) +#define REG_1EECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEECU)) +#define REG_1EF0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEF0U)) +#define REG_1EF4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEF4U)) +#define REG_1EF8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEF8U)) +#define REG_1EFCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xEFCU)) +#define REG_1F00H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF00U)) +#define REG_1F04H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF04U)) +#define REG_1F08H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF08U)) +#define REG_1F0CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF0CU)) +#define REG_1F10H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF10U)) +#define REG_1F14H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF14U)) +#define REG_1F18H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF18U)) +#define REG_1F1CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF1CU)) +#define REG_1F20H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF20U)) +#define REG_1F24H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF24U)) +#define REG_1F28H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF28U)) +#define REG_1F2CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF2CU)) +#define REG_1F30H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF30U)) +#define REG_1F34H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF34U)) +#define REG_1F38H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF38U)) +#define REG_1F3CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF3CU)) +#define REG_1F40H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF40U)) +#define REG_1F44H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF44U)) +#define REG_1F48H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF48U)) +#define REG_1F4CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF4CU)) +#define REG_1F50H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF50U)) +#define REG_1F54H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF54U)) +#define REG_1F58H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF58U)) +#define REG_1F5CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF5CU)) +#define REG_1F60H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF60U)) +#define REG_1F64H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF64U)) +#define REG_1F68H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF68U)) +#define REG_1F6CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF6CU)) +#define REG_1F70H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF70U)) +#define REG_1F74H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF74U)) +#define REG_1F78H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF78U)) +#define REG_1F7CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF7CU)) +#define REG_1F80H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF80U)) +#define REG_1F84H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF84U)) +#define REG_1F88H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF88U)) +#define REG_1F8CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF8CU)) +#define REG_1F90H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF90U)) +#define REG_1F94H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF94U)) +#define REG_1F98H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF98U)) +#define REG_1F9CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xF9CU)) +#define REG_1FA0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFA0U)) +#define REG_1FA4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFA4U)) +#define REG_1FA8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFA8U)) +#define REG_1FACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFACU)) +#define REG_1FB0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFB0U)) +#define REG_1FB4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFB4U)) +#define REG_1FB8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFB8U)) +#define REG_1FBCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFBCU)) +#define REG_1FC0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFC0U)) +#define REG_1FC4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFC4U)) +#define REG_1FC8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFC8U)) +#define REG_1FCCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFCCU)) +#define REG_1FD0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFD0U)) +#define REG_1FD4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFD4U)) +#define REG_1FD8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFD8U)) +#define REG_1FDCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFDCU)) +#define REG_1FE0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFE0U)) +#define REG_1FE4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFE4U)) +#define REG_1FE8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFE8U)) +#define REG_1FECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFECU)) +#define REG_1FF0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFF0U)) +#define REG_1FF4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFF4U)) +#define REG_1FF8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFF8U)) +#define REG_1FFCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_1000H + 0xFFCU)) +#define REG_2000H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x000U)) +#define REG_2004H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x004U)) +#define REG_2008H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x008U)) +#define REG_200CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x00CU)) +#define REG_2010H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x010U)) +#define REG_2014H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x014U)) +#define REG_2018H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x018U)) +#define REG_201CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x01CU)) +#define REG_2020H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x020U)) +#define REG_2024H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x024U)) +#define REG_2028H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x028U)) +#define REG_202CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x02CU)) +#define REG_2030H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x030U)) +#define REG_2034H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x034U)) +#define REG_2038H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x038U)) +#define REG_203CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x03CU)) +#define REG_2040H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x040U)) +#define REG_2044H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x044U)) +#define REG_2048H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x048U)) +#define REG_204CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x04CU)) +#define REG_2050H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x050U)) +#define REG_2054H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x054U)) +#define REG_2058H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x058U)) +#define REG_205CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x05CU)) +#define REG_2060H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x060U)) +#define REG_2064H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x064U)) +#define REG_2068H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x068U)) +#define REG_206CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x06CU)) +#define REG_2070H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x070U)) +#define REG_2074H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x074U)) +#define REG_2078H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x078U)) +#define REG_207CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x07CU)) +#define REG_2080H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x080U)) +#define REG_2084H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x084U)) +#define REG_2088H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x088U)) +#define REG_208CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x08CU)) +#define REG_2090H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x090U)) +#define REG_2094H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x094U)) +#define REG_2098H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x098U)) +#define REG_209CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x09CU)) +#define REG_20A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0A0U)) +#define REG_20A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0A4U)) +#define REG_20A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0A8U)) +#define REG_20ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0ACU)) +#define REG_20B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0B0U)) +#define REG_20B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0B4U)) +#define REG_20B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0B8U)) +#define REG_20BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0BCU)) +#define REG_20C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0C0U)) +#define REG_20C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0C4U)) +#define REG_20C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0C8U)) +#define REG_20CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0CCU)) +#define REG_20D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0D0U)) +#define REG_20D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0D4U)) +#define REG_20D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0D8U)) +#define REG_20DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0DCU)) +#define REG_20E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0E0U)) +#define REG_20E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0E4U)) +#define REG_20E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0E8U)) +#define REG_20ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0ECU)) +#define REG_20F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0F0U)) +#define REG_20F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0F4U)) +#define REG_20F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0F8U)) +#define REG_20FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x0FCU)) +#define REG_2100H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x100U)) +#define REG_2104H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x104U)) +#define REG_2108H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x108U)) +#define REG_210CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x10CU)) +#define REG_2110H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x110U)) +#define REG_2114H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x114U)) +#define REG_2118H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x118U)) +#define REG_211CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x11CU)) +#define REG_2120H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x120U)) +#define REG_2124H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x124U)) +#define REG_2128H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x128U)) +#define REG_212CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x12CU)) +#define REG_2130H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x130U)) +#define REG_2134H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x134U)) +#define REG_2138H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x138U)) +#define REG_213CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x13CU)) +#define REG_2140H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x140U)) +#define REG_2144H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x144U)) +#define REG_2148H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x148U)) +#define REG_214CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x14CU)) +#define REG_2150H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x150U)) +#define REG_2154H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x154U)) +#define REG_2158H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x158U)) +#define REG_215CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x15CU)) +#define REG_2160H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x160U)) +#define REG_2164H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x164U)) +#define REG_2168H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x168U)) +#define REG_216CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x16CU)) +#define REG_2170H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x170U)) +#define REG_2174H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x174U)) +#define REG_2178H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x178U)) +#define REG_217CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x17CU)) +#define REG_2180H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x180U)) +#define REG_2184H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x184U)) +#define REG_2188H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x188U)) +#define REG_218CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x18CU)) +#define REG_2190H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x190U)) +#define REG_2194H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x194U)) +#define REG_2198H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x198U)) +#define REG_219CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x19CU)) +#define REG_21A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1A0U)) +#define REG_21A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1A4U)) +#define REG_21A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1A8U)) +#define REG_21ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1ACU)) +#define REG_21B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1B0U)) +#define REG_21B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1B4U)) +#define REG_21B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1B8U)) +#define REG_21BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1BCU)) +#define REG_21C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1C0U)) +#define REG_21C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1C4U)) +#define REG_21C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1C8U)) +#define REG_21CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1CCU)) +#define REG_21D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1D0U)) +#define REG_21D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1D4U)) +#define REG_21D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1D8U)) +#define REG_21DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1DCU)) +#define REG_21E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1E0U)) +#define REG_21E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1E4U)) +#define REG_21E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1E8U)) +#define REG_21ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1ECU)) +#define REG_21F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1F0U)) +#define REG_21F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1F4U)) +#define REG_21F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1F8U)) +#define REG_21FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x1FCU)) +#define REG_2200H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x200U)) +#define REG_2204H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x204U)) +#define REG_2208H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x208U)) +#define REG_220CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x20CU)) +#define REG_2210H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x210U)) +#define REG_2214H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x214U)) +#define REG_2218H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x218U)) +#define REG_221CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x21CU)) +#define REG_2220H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x220U)) +#define REG_2224H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x224U)) +#define REG_2228H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x228U)) +#define REG_222CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x22CU)) +#define REG_2230H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x230U)) +#define REG_2234H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x234U)) +#define REG_2238H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x238U)) +#define REG_223CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x23CU)) +#define REG_2240H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x240U)) +#define REG_2244H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x244U)) +#define REG_2248H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x248U)) +#define REG_224CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x24CU)) +#define REG_2250H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x250U)) +#define REG_2254H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x254U)) +#define REG_2258H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x258U)) +#define REG_225CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x25CU)) +#define REG_2260H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x260U)) +#define REG_2264H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x264U)) +#define REG_2268H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x268U)) +#define REG_226CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x26CU)) +#define REG_2270H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x270U)) +#define REG_2274H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x274U)) +#define REG_2278H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x278U)) +#define REG_227CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x27CU)) +#define REG_2280H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x280U)) +#define REG_2284H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x284U)) +#define REG_2288H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x288U)) +#define REG_228CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x28CU)) +#define REG_2290H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x290U)) +#define REG_2294H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x294U)) +#define REG_2298H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x298U)) +#define REG_229CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x29CU)) +#define REG_22A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2A0U)) +#define REG_22A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2A4U)) +#define REG_22A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2A8U)) +#define REG_22ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2ACU)) +#define REG_22B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2B0U)) +#define REG_22B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2B4U)) +#define REG_22B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2B8U)) +#define REG_22BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2BCU)) +#define REG_22C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2C0U)) +#define REG_22C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2C4U)) +#define REG_22C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2C8U)) +#define REG_22CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2CCU)) +#define REG_22D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2D0U)) +#define REG_22D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2D4U)) +#define REG_22D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2D8U)) +#define REG_22DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2DCU)) +#define REG_22E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2E0U)) +#define REG_22E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2E4U)) +#define REG_22E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2E8U)) +#define REG_22ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2ECU)) +#define REG_22F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2F0U)) +#define REG_22F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2F4U)) +#define REG_22F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2F8U)) +#define REG_22FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x2FCU)) +#define REG_2300H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x300U)) +#define REG_2304H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x304U)) +#define REG_2308H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x308U)) +#define REG_230CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x30CU)) +#define REG_2310H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x310U)) +#define REG_2314H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x314U)) +#define REG_2318H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x318U)) +#define REG_231CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x31CU)) +#define REG_2320H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x320U)) +#define REG_2324H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x324U)) +#define REG_2328H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x328U)) +#define REG_232CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x32CU)) +#define REG_2330H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x330U)) +#define REG_2334H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x334U)) +#define REG_2338H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x338U)) +#define REG_233CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x33CU)) +#define REG_2340H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x340U)) +#define REG_2344H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x344U)) +#define REG_2348H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x348U)) +#define REG_234CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x34CU)) +#define REG_2350H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x350U)) +#define REG_2354H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x354U)) +#define REG_2358H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x358U)) +#define REG_235CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x35CU)) +#define REG_2360H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x360U)) +#define REG_2364H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x364U)) +#define REG_2368H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x368U)) +#define REG_236CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x36CU)) +#define REG_2370H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x370U)) +#define REG_2374H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x374U)) +#define REG_2378H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x378U)) +#define REG_237CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x37CU)) +#define REG_2380H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x380U)) +#define REG_2384H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x384U)) +#define REG_2388H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x388U)) +#define REG_238CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x38CU)) +#define REG_2390H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x390U)) +#define REG_2394H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x394U)) +#define REG_2398H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x398U)) +#define REG_239CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x39CU)) +#define REG_23A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3A0U)) +#define REG_23A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3A4U)) +#define REG_23A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3A8U)) +#define REG_23ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3ACU)) +#define REG_23B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3B0U)) +#define REG_23B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3B4U)) +#define REG_23B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3B8U)) +#define REG_23BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3BCU)) +#define REG_23C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3C0U)) +#define REG_23C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3C4U)) +#define REG_23C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3C8U)) +#define REG_23CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3CCU)) +#define REG_23D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3D0U)) +#define REG_23D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3D4U)) +#define REG_23D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3D8U)) +#define REG_23DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3DCU)) +#define REG_23E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3E0U)) +#define REG_23E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3E4U)) +#define REG_23E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3E8U)) +#define REG_23ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3ECU)) +#define REG_23F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3F0U)) +#define REG_23F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3F4U)) +#define REG_23F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3F8U)) +#define REG_23FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x3FCU)) +#define REG_2400H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x400U)) +#define REG_2404H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x404U)) +#define REG_2408H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x408U)) +#define REG_240CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x40CU)) +#define REG_2410H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x410U)) +#define REG_2414H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x414U)) +#define REG_2418H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x418U)) +#define REG_241CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x41CU)) +#define REG_2420H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x420U)) +#define REG_2424H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x424U)) +#define REG_2428H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x428U)) +#define REG_242CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x42CU)) +#define REG_2430H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x430U)) +#define REG_2434H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x434U)) +#define REG_2438H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x438U)) +#define REG_243CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x43CU)) +#define REG_2440H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x440U)) +#define REG_2444H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x444U)) +#define REG_2448H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x448U)) +#define REG_244CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x44CU)) +#define REG_2450H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x450U)) +#define REG_2454H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x454U)) +#define REG_2458H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x458U)) +#define REG_245CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x45CU)) +#define REG_2460H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x460U)) +#define REG_2464H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x464U)) +#define REG_2468H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x468U)) +#define REG_246CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x46CU)) +#define REG_2470H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x470U)) +#define REG_2474H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x474U)) +#define REG_2478H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x478U)) +#define REG_247CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x47CU)) +#define REG_2480H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x480U)) +#define REG_2484H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x484U)) +#define REG_2488H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x488U)) +#define REG_248CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x48CU)) +#define REG_2490H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x490U)) +#define REG_2494H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x494U)) +#define REG_2498H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x498U)) +#define REG_249CH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x49CU)) +#define REG_24A0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4A0U)) +#define REG_24A4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4A4U)) +#define REG_24A8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4A8U)) +#define REG_24ACH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4ACU)) +#define REG_24B0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4B0U)) +#define REG_24B4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4B4U)) +#define REG_24B8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4B8U)) +#define REG_24BCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4BCU)) +#define REG_24C0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4C0U)) +#define REG_24C4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4C4U)) +#define REG_24C8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4C8U)) +#define REG_24CCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4CCU)) +#define REG_24D0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4D0U)) +#define REG_24D4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4D4U)) +#define REG_24D8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4D8U)) +#define REG_24DCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4DCU)) +#define REG_24E0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4E0U)) +#define REG_24E4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4E4U)) +#define REG_24E8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4E8U)) +#define REG_24ECH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4ECU)) +#define REG_24F0H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4F0U)) +#define REG_24F4H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4F4U)) +#define REG_24F8H (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4F8U)) +#define REG_24FCH (*(volatile uint32_t *) (RSIP_PRV_ADDR_2000H + 0x4FCU)) + +#define RSIP_PRV_ADDR_VAL_0000H (RSIP_PRV_ADDR_BASE + 0x0000U) +#define RSIP_PRV_ADDR_VAL_1000H (RSIP_PRV_ADDR_BASE + 0x1000U) +#define RSIP_PRV_ADDR_VAL_2000H (RSIP_PRV_ADDR_BASE + 0x2000U) +#define RSIP_PRV_ADDR_VAL_1420H (RSIP_PRV_ADDR_BASE + 0x1420U) +#define RSIP_PRV_ADDR_VAL_1440H (RSIP_PRV_ADDR_BASE + 0x1440U) +#define RSIP_PRV_ADDR_VAL_1600H (RSIP_PRV_ADDR_BASE + 0x1600U) + +#define RSIP_PRV_ADDR_0000H RSIP_PRV_ADDR_VAL_0000H +#define RSIP_PRV_ADDR_1000H RSIP_PRV_ADDR_VAL_1000H +#define RSIP_PRV_ADDR_2000H RSIP_PRV_ADDR_VAL_2000H + +/* Register value */ +#define RSIP_PRV_CMD_REG_1424H (0x00CF00CFU) +#define RSIP_PRV_CMD_REG_1428H (0x00CF00CFU) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Exported global variables + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Public Function Prototypes + **********************************************************************************************************************/ + +#endif /* R_RSIP_REG_H */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_util.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_util.h new file mode 100644 index 000000000..4cd5f38a8 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/private/r_rsip_util.h @@ -0,0 +1,95 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +#ifndef R_RSIP_UTIL_H +#define R_RSIP_UTIL_H + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include "bsp_api.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* + * Set compiler optimization option for primitive functions. + * GNU Toolchain: "Os" + * IAR Embedded Workbench: "size" (enabled only if default optimization level is "high") + * Other toolchains: no change + */ +#if defined(__GNUC__) + #define RSIP_PRV_PRIMITIVE_FUNC __attribute__((optimize("Os"))) +#elif defined(__ICCARM__) + #define RSIP_PRV_PRIMITIVE_FUNC _Pragma("optimize = size") +#else + #define RSIP_PRV_PRIMITIVE_FUNC +#endif + +/* CPU Architecture and endianness */ +#if defined(__ARM_ARCH) + #define RSIP_PRV_ARCH_ARM + #define RSIP_PRV_STATIC_INLINE __STATIC_FORCEINLINE + #define RSIP_PRV_LITTLE_ENDIAN !__ARM_BIG_ENDIAN +#else + #error Unsupported architecture. +#endif + +#if RSIP_PRV_LITTLE_ENDIAN + #define BSWAP_32BIG_C(data) ((((data) & 0xff000000U) >> 24) | (((data) & 0x00ff0000U) >> 8) | \ + (((data) & 0x0000ff00U) << 8) | (((data) & 0x000000ffU) << 24)) +#else + #define BSWAP_32BIG_C(data) (data) +#endif + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Exported global variables + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Public Function Prototypes + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Changes data endianness to big-endian. + * + * bswap_32big(): For other than const variable. This inline function directly uses ISA. + * + * BSWAP_32BIG_C(): For const variable. This macro uses bit shift operation. + * + * @param[in] data 32-bit data + * + * @return big-endian data + **********************************************************************************************************************/ +RSIP_PRV_STATIC_INLINE uint32_t bswap_32big (uint32_t data) +{ +#if RSIP_PRV_LITTLE_ENDIAN && defined(RSIP_PRV_ARCH_ARM) + return __REV(data); +#else + return data; +#endif +} + +#endif /* R_RSIP_UTIL_H */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip.c b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip.c new file mode 100644 index 000000000..bc31e649f --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip.c @@ -0,0 +1,680 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "r_rsip_public.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +static const rsip_key_type_t gs_key_pair_type_to_public_key_type[] = +{ + [RSIP_KEY_PAIR_TYPE_ECC_secp192r1] = RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC, + [RSIP_KEY_PAIR_TYPE_ECC_secp224r1] = RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC, + [RSIP_KEY_PAIR_TYPE_ECC_secp256r1] = RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC, + [RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1] = RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC, + [RSIP_KEY_PAIR_TYPE_RSA_1024] = RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED, + [RSIP_KEY_PAIR_TYPE_RSA_2048] = RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED, + [RSIP_KEY_PAIR_TYPE_RSA_3072] = RSIP_KEY_TYPE_RSA_3072_PUBLIC, + [RSIP_KEY_PAIR_TYPE_RSA_4096] = RSIP_KEY_TYPE_RSA_4096_PUBLIC, +}; + +static const rsip_key_type_t gs_key_pair_type_to_private_key_type[] = +{ + [RSIP_KEY_PAIR_TYPE_ECC_secp192r1] = RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE, + [RSIP_KEY_PAIR_TYPE_ECC_secp224r1] = RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE, + [RSIP_KEY_PAIR_TYPE_ECC_secp256r1] = RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE, + [RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1] = RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE, + [RSIP_KEY_PAIR_TYPE_RSA_1024] = RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED, + [RSIP_KEY_PAIR_TYPE_RSA_2048] = RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED, + [RSIP_KEY_PAIR_TYPE_RSA_3072] = RSIP_KEY_TYPE_RSA_3072_PRIVATE, + [RSIP_KEY_PAIR_TYPE_RSA_4096] = RSIP_KEY_TYPE_RSA_4096_PRIVATE, +}; + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @addtogroup RSIP + * @{ + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Opens the RSIP driver module. + * + * @param[in,out] p_ctrl Pointer to control block. Must be declared by user. Elements are set here. + * @param[in] p_cfg Pointer to configuration structure. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_ALREADY_OPEN Module is already open. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Internal key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Hardware initialization is failed. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption or hardware fault is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_Open (rsip_ctrl_t * const p_ctrl, rsip_cfg_t const * const p_cfg) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_cfg); + FSP_ERROR_RETURN(RSIP_OPEN != p_instance_ctrl->open, FSP_ERR_ALREADY_OPEN); +#endif + + /* Set configuration */ + p_instance_ctrl->p_cfg = p_cfg; + + /* Device-specific sequence */ + rsip_ret_t rsip_ret = r_rsip_open(); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + /* Reset handle */ + r_rsip_handle_reset(&p_instance_ctrl->handle); + + /* State transition */ + r_rsip_state_transit_init(p_instance_ctrl); + + /* Set driver status to open */ + p_instance_ctrl->open = RSIP_OPEN; + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + /* Treat PASS_1 as FAIL */ + case RSIP_RET_FAIL: + case RSIP_RET_PASS_1: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + /* Treat RETRY as FATAL */ + case RSIP_RET_RETRY: + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Closes the RSIP driver module. + * + * @param[in,out] p_ctrl Pointer to control block. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_Close (rsip_ctrl_t * const p_ctrl) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + /* Device-specific sequence */ + rsip_ret_t rsip_ret = r_rsip_close(); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + /* Set driver status to close */ + p_instance_ctrl->open = 0U; + + err = FSP_SUCCESS; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Generates a 128-bit random number. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[out] p_random Pointer to destination of random number. The length is 16 bytes. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_RandomNumberGenerate (rsip_ctrl_t * const p_ctrl, uint8_t * const p_random) +{ +#if RSIP_CFG_PARAM_CHECKING_ENABLE + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_random); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + return r_rsip_random_number_generate(p_ctrl, p_random); +} + +/*******************************************************************************************************************//** + * Generates a wrapped symmetric key from a random number. In this API, user key input is unnecessary. + * By encrypting data using the wrapped key is output by this API, dead copying of data can be prevented. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] key_type Outputs key type. + * @param[out] p_wrapped_key Pointer to destination of wrapped key. The length depends on key type. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_UNSUPPORTED Input key type is unsupported. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + * + * @sa Section @ref r-rsip-key-management "Key Management" + **********************************************************************************************************************/ +fsp_err_t R_RSIP_KeyGenerate (rsip_ctrl_t * const p_ctrl, + rsip_key_type_t const key_type, + rsip_wrapped_key_t * const p_wrapped_key) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + /* Set primitive */ + rsip_func_key_generate_t p_primitive = gp_func_key_generate[key_type]; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_key); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(g_key_generate_supported_algs[key_type], FSP_ERR_UNSUPPORTED); + + /* Check if the key type is enabled on configuration */ + FSP_ERROR_RETURN(p_primitive, FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = p_primitive((uint32_t *) p_wrapped_key->value); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + p_wrapped_key->type = key_type; + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Generates a wrapped asymmetric key pair from a random number. In this API, user key input is unnecessary. + * By encrypting data using the wrapped key is output by this API, dead copying of data can be prevented. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] key_pair_type Output key pair type. + * @param[out] p_wrapped_public_key Pointer to destination of wrapped public key. The length depends on key type. + * @param[out] p_wrapped_private_key Pointer to destination of wrapped private key. The length depends on key type. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_UNSUPPORTED Input key type is unsupported. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + * + * @sa Section @ref r-rsip-key-management "Key Management" + **********************************************************************************************************************/ +fsp_err_t R_RSIP_KeyPairGenerate (rsip_ctrl_t * const p_ctrl, + rsip_key_pair_type_t const key_pair_type, + rsip_wrapped_key_t * const p_wrapped_public_key, + rsip_wrapped_key_t * const p_wrapped_private_key) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + /* Set primitive */ + rsip_func_key_pair_generate_t p_primitive = gp_func_key_pair_generate[key_pair_type]; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_public_key); + FSP_ASSERT(p_wrapped_private_key); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(g_key_pair_generate_supported_algs[key_pair_type], FSP_ERR_UNSUPPORTED); + + /* Check if the key type is enabled on configuration */ + FSP_ERROR_RETURN(p_primitive, FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = p_primitive((uint32_t *) p_wrapped_public_key->value, + (uint32_t *) p_wrapped_private_key->value); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + p_wrapped_public_key->type = gs_key_pair_type_to_public_key_type[key_pair_type]; + p_wrapped_private_key->type = gs_key_pair_type_to_private_key_type[key_pair_type]; + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Imports a user key with KUK (Key Update Key) within the user routine. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_key_update_key Pointer to Key Update Key. + * @param[in] p_initial_vector Pointer to initialization vector when generating encrypted_key. + * The length is 16 bytes. + * @param[in] key_type Inputs/Outputs key type. + * @param[in] p_encrypted_key Pointer to encrypted user key. The length depends on the key type. + * @param[out] p_wrapped_key Pointer to destination of wrapped key. The length depends on the key type. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_UNSUPPORTED Input key type is unsupported. + * @retval FSP_ERR_INVALID_ARGUMENT p_key_update_key->type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + * + * @sa Section @ref r-rsip-key-management "Key Management" + **********************************************************************************************************************/ +fsp_err_t R_RSIP_KeyImportWithKUK (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_key_update_key, + uint8_t const * const p_initial_vector, + rsip_key_type_t const key_type, + uint8_t const * const p_encrypted_key, + rsip_wrapped_key_t * const p_wrapped_key) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + /* Set primitive */ + rsip_func_key_import_with_kuk_t p_primitive = gp_func_key_import_with_kuk[key_type]; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_key_update_key); + FSP_ASSERT(p_initial_vector); + FSP_ASSERT(p_encrypted_key); + FSP_ASSERT(p_wrapped_key); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(g_key_import_with_kuk_supported_algs[key_type], FSP_ERR_UNSUPPORTED); + + /* Check if the key type is enabled on configuration */ + FSP_ERROR_RETURN(p_primitive, FSP_ERR_NOT_ENABLED); + + /* Check key type of KUK */ + FSP_ERROR_RETURN(RSIP_KEY_TYPE_KEY_UPDATE_KEY == p_key_update_key->type, FSP_ERR_INVALID_ARGUMENT); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Store KUK */ + r_rsip_kuk_store(p_key_update_key->value); + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = + p_primitive((uint32_t const *) p_initial_vector, + (uint32_t const *) p_encrypted_key, + (uint32_t *) p_wrapped_key->value); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + p_wrapped_key->type = key_type; + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Exports ECC public key parameters from a wrapped key. + * + * @param[in] p_wrapped_public_key Pointer to wrapped key of ECC public key. + * @param[out] pp_raw_public_key_qx Pointer to raw `Q_x`. The length depends on the key length. + * @param[out] pp_raw_public_key_qy Pointer to raw `Q_y`. The length depends on the key length. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_INVALID_ARGUMENT Key type is illegal. + * + * @note Outputs are only available inside the scope of the wrapped key. If necessary, please copy them. + * @sa Section @ref r-rsip-key-management "Key Management" + **********************************************************************************************************************/ +fsp_err_t R_RSIP_ECCPublicKeyExport (rsip_wrapped_key_t const * const p_wrapped_public_key, + uint8_t const ** const pp_raw_public_key_qx, + uint8_t const ** const pp_raw_public_key_qy) +{ +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_wrapped_public_key); + FSP_ASSERT(pp_raw_public_key_qx); + FSP_ASSERT(pp_raw_public_key_qy); +#endif + + fsp_err_t err = FSP_ERR_INVALID_ARGUMENT; + switch (p_wrapped_public_key->type) + { + /* The parameter positions of the following key types are the same */ + case RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC: + { + *pp_raw_public_key_qx = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_ECC_192_QX; + *pp_raw_public_key_qy = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_ECC_192_QY; + + err = FSP_SUCCESS; + break; + } + case RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC: + { + *pp_raw_public_key_qx = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_ECC_224_QX; + *pp_raw_public_key_qy = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_ECC_224_QY; + + err = FSP_SUCCESS; + break; + } + case RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC: + case RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC: + { + *pp_raw_public_key_qx = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_ECC_256_QX; + *pp_raw_public_key_qy = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_ECC_256_QY; + + err = FSP_SUCCESS; + break; + } + + default: + { + /* Do nothing */ + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Exports RSA public key parameters from a wrapped key. + * + * @param[in] p_wrapped_public_key Pointer to wrapped key of RSA public key. + * @param[out] pp_raw_public_key_n Pointer to raw `n`. The length is as same as the key length. + * @param[out] pp_raw_public_key_e Pointer to raw `e`. The length is 4 bytes. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_INVALID_ARGUMENT Key type is illegal. + * + * @note Outputs are only available inside the scope of the wrapped key. If necessary, please copy them. + * @sa Section @ref r-rsip-key-management "Key Management" + **********************************************************************************************************************/ +fsp_err_t R_RSIP_RSAPublicKeyExport (rsip_wrapped_key_t const * const p_wrapped_public_key, + uint8_t const ** const pp_raw_public_key_n, + uint8_t const ** const pp_raw_public_key_e) +{ +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_wrapped_public_key); + FSP_ASSERT(pp_raw_public_key_n); + FSP_ASSERT(pp_raw_public_key_e); +#endif + + fsp_err_t err = FSP_ERR_INVALID_ARGUMENT; + switch (p_wrapped_public_key->type) + { + /* The parameter positions of the following key types are the same */ + case RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED: + { + *pp_raw_public_key_n = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_1024_N; + *pp_raw_public_key_e = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_1024_E; + + err = FSP_SUCCESS; + break; + } + + /* The parameter positions of the following key types are the same */ + case RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED: + { + *pp_raw_public_key_n = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_2048_N; + *pp_raw_public_key_e = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_2048_E; + + err = FSP_SUCCESS; + break; + } + + case RSIP_KEY_TYPE_RSA_3072_PUBLIC: + { + *pp_raw_public_key_n = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_3072_N; + *pp_raw_public_key_e = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_3072_E; + + err = FSP_SUCCESS; + break; + } + + case RSIP_KEY_TYPE_RSA_4096_PUBLIC: + { + *pp_raw_public_key_n = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_4096_N; + *pp_raw_public_key_e = p_wrapped_public_key->value + RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_4096_E; + + err = FSP_SUCCESS; + break; + } + + default: + { + /* Do nothing */ + } + } + + return err; +} + +/*******************************************************************************************************************//** + * @} (end addtogroup RSIP) + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Generates a 128-bit random number. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[out] p_random Pointer to destination of random number. The length is 16 bytes. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t r_rsip_random_number_generate (rsip_ctrl_t * const p_ctrl, uint8_t * const p_random) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = gp_func_random_number_generate((uint32_t *) p_random); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_aes.c b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_aes.c new file mode 100644 index 000000000..92ca2fabe --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_aes.c @@ -0,0 +1,2096 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "r_rsip_public.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +static fsp_err_t aes_init(rsip_ctrl_t * p_ctrl, + rsip_aes_mode_t mode, + const rsip_wrapped_key_t * p_wrapped_key, + const uint8_t * p_initial_vector, + rsip_handle_type_t handle_type); +static fsp_err_t aes_update(rsip_ctrl_t * p_ctrl, + const uint8_t * p_input, + uint8_t * p_output, + uint32_t input_length, + rsip_handle_type_t handle_type); +static fsp_err_t aes_final(rsip_ctrl_t * p_ctrl, rsip_handle_type_t handle_type); + +static fsp_err_t xts_init(rsip_ctrl_t * p_ctrl, + const rsip_wrapped_key_t * p_wrapped_key, + const uint8_t * p_initial_vector, + rsip_handle_type_t handle_type); +static fsp_err_t xts_update(rsip_ctrl_t * p_ctrl, + const uint8_t * p_input, + uint8_t * p_output, + uint32_t input_length, + rsip_handle_type_t handle_type); +static fsp_err_t xts_final(rsip_ctrl_t * p_ctrl, + uint8_t * p_output, + uint32_t * p_output_length, + rsip_handle_type_t handle_type); + +static fsp_err_t gcm_init(rsip_ctrl_t * p_ctrl, + const rsip_wrapped_key_t * p_wrapped_key, + const uint8_t * p_initial_vector, + uint32_t initial_vector_length, + rsip_handle_type_t handle_type); +static fsp_err_t gcm_update(rsip_ctrl_t * p_ctrl, + const uint8_t * p_input, + uint8_t * p_output, + uint32_t input_length, + const uint8_t * p_aad, + uint32_t aad_length, + rsip_handle_type_t handle_type); +static fsp_err_t gcm_iv_prepare(rsip_instance_ctrl_t * p_instance_ctrl, + const uint8_t * p_initial_vector, + uint32_t initial_vector_length, + const rsip_wrapped_key_t * p_wrapped_key, + uint32_t * p_hashed_ivec); +static void gcm_aad_input_terminate(rsip_instance_ctrl_t * p_instance_ctrl); + +static fsp_err_t cmac_init(rsip_ctrl_t * p_ctrl, + const rsip_wrapped_key_t * p_wrapped_key, + rsip_handle_type_t handle_type); +static fsp_err_t cmac_update(rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_message, + uint32_t const message_length, + rsip_handle_type_t handle_type); + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @addtogroup RSIP + * @{ + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Prepares an AES encryption. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] mode Block cipher modes of operation. + * @param[in] p_wrapped_key Pointer to wrapped key of AES or AES-XTS key. + * @param[in] p_initial_vector Pointer to initialization vector (IV) or nonce. The length is 16 bytes. + * @arg [ECB] Not needed + * @arg [CBC] IV + * @arg [CTR] Nonce + * @arg [XTS] IV + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type or mode is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_Cipher_EncryptInit (rsip_ctrl_t * const p_ctrl, + rsip_aes_mode_t const mode, + rsip_wrapped_key_t const * const p_wrapped_key, + uint8_t const * const p_initial_vector) +{ +#if RSIP_CFG_PARAM_CHECKING_ENABLE + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + FSP_ASSERT(p_instance_ctrl); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + fsp_err_t err = FSP_ERR_INVALID_ARGUMENT; + switch (mode) + { + /* The same function is used if mode is ECB, CBC, or CTR */ + case RSIP_AES_MODE_ECB: + case RSIP_AES_MODE_CBC: + case RSIP_AES_MODE_CTR: + { + err = aes_init(p_ctrl, mode, p_wrapped_key, p_initial_vector, RSIP_HANDLE_TYPE_AES_ENCRYPT); + break; + } + + case RSIP_AES_MODE_XTS: + { + err = xts_init(p_ctrl, p_wrapped_key, p_initial_vector, RSIP_HANDLE_TYPE_XTS_ENCRYPT); + break; + } + + default: + { + /* Invalid argument */ + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Encrypts plaintext. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_plain Pointer to plaintext. The length is plain_length. + * @param[out] p_cipher Pointer to destination of ciphertext. + * @arg [ECB][CBC][CTR][XTS without fractional block] + * The length is plain_length. + * @arg [XTS with fractional block] + * No outputs. The ciphertext output by R_RSIP_AES_Cipher_EncryptFinal(). + * After inputs fractional block, updates will not be possible. + * @param[in] plain_length Byte length of plaintext. + * @arg [ECB][CBC][CTR][XTS without fractional block] Must be 0 or a multiple of 16. + * @arg [XTS with fractional block] Must be 17 to 31. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_INVALID_SIZE Input length is illegal. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_Cipher_EncryptUpdate (rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_plain, + uint8_t * const p_cipher, + uint32_t const plain_length) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + fsp_err_t err = FSP_ERR_INVALID_STATE; + switch (p_instance_ctrl->handle_type) + { + case RSIP_HANDLE_TYPE_AES_ENCRYPT: + { + err = aes_update(p_ctrl, p_plain, p_cipher, plain_length, RSIP_HANDLE_TYPE_AES_ENCRYPT); + break; + } + + case RSIP_HANDLE_TYPE_XTS_ENCRYPT: + { + err = xts_update(p_ctrl, p_plain, p_cipher, plain_length, RSIP_HANDLE_TYPE_XTS_ENCRYPT); + break; + } + + default: + { + /* Invalid state */ + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Finalizes an AES encryption. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[out] p_cipher Pointer to destination of ciphertext. + * @arg [ECB][CBC][CTR] No outputs. + * @arg [XTS] Fractional block and the one before block are output. + * @param[out] p_cipher_length Pointer to destination of ciphertext length. + * @arg [ECB][CBC][CTR] No outputs. + * @arg [XTS] Output length is output. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Internal error. + * + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_Cipher_EncryptFinal (rsip_ctrl_t * const p_ctrl, + uint8_t * const p_cipher, + uint32_t * const p_cipher_length) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + fsp_err_t err = FSP_ERR_INVALID_STATE; + switch (p_instance_ctrl->handle_type) + { + case RSIP_HANDLE_TYPE_AES_ENCRYPT: + { + err = aes_final(p_ctrl, RSIP_HANDLE_TYPE_AES_ENCRYPT); + break; + } + + case RSIP_HANDLE_TYPE_XTS_ENCRYPT: + { + err = xts_final(p_ctrl, p_cipher, p_cipher_length, RSIP_HANDLE_TYPE_XTS_ENCRYPT); + break; + } + + default: + { + /* Invalid state */ + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Prepares an AES decryption. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] mode Block cipher modes of operation. + * @param[in] p_wrapped_key Pointer to wrapped key of AES or AES-XTS key. + * @param[in] p_initial_vector Pointer to initialization vector (IV) or nonce. The length is 16 bytes. + * @arg [ECB] Not needed + * @arg [CBC] IV + * @arg [CTR] Nonce + * @arg [XTS] IV + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type or mode is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_Cipher_DecryptInit (rsip_ctrl_t * const p_ctrl, + rsip_aes_mode_t const mode, + rsip_wrapped_key_t const * const p_wrapped_key, + uint8_t const * const p_initial_vector) +{ +#if RSIP_CFG_PARAM_CHECKING_ENABLE + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + FSP_ASSERT(p_instance_ctrl); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + fsp_err_t err = FSP_ERR_INVALID_ARGUMENT; + switch (mode) + { + /* The same function is used if mode is ECB, CBC, or CTR */ + case RSIP_AES_MODE_ECB: + case RSIP_AES_MODE_CBC: + case RSIP_AES_MODE_CTR: + { + err = aes_init(p_ctrl, mode, p_wrapped_key, p_initial_vector, RSIP_HANDLE_TYPE_AES_DECRYPT); + break; + } + + case RSIP_AES_MODE_XTS: + { + err = xts_init(p_ctrl, p_wrapped_key, p_initial_vector, RSIP_HANDLE_TYPE_XTS_DECRYPT); + break; + } + + default: + { + /* Invalid argument */ + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Decrypts ciphertext. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_cipher Pointer to ciphertext. The length is cipher_length. + * @param[out] p_plain Pointer to destination of plaintext. + * @arg [ECB][CBC][CTR][XTS without fractional block] + * The length is cipher_length. + * @arg [XTS with fractional block] + * No outputs. The plaintext is output by R_RSIP_AES_Cipher_DecryptFinal(). + * After inputs fractional block, updates will not be possible. + * @param[in] cipher_length Byte length of ciphertext. + * @arg [ECB][CBC][CTR][XTS without fractional block] Must be 0 or a multiple of 16. + * @arg [XTS with fractional block] Must be 17 to 31. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_INVALID_SIZE Input length is illegal. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_Cipher_DecryptUpdate (rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_cipher, + uint8_t * const p_plain, + uint32_t const cipher_length) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + fsp_err_t err = FSP_ERR_INVALID_STATE; + switch (p_instance_ctrl->handle_type) + { + case RSIP_HANDLE_TYPE_AES_DECRYPT: + { + err = aes_update(p_ctrl, p_cipher, p_plain, cipher_length, RSIP_HANDLE_TYPE_AES_DECRYPT); + break; + } + + case RSIP_HANDLE_TYPE_XTS_DECRYPT: + { + err = xts_update(p_ctrl, p_cipher, p_plain, cipher_length, RSIP_HANDLE_TYPE_XTS_DECRYPT); + break; + } + + default: + { + /* Invalid state */ + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Finalizes an AES decryption. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[out] p_plain Pointer to destination of plaintext. + * @arg [ECB][CBC][CTR] No outputs. + * @arg [XTS] Fractional block and the one before block are output. + * @param[out] p_plain_length Pointer to destination of plaintext length. + * @arg [ECB][CBC][CTR] No outputs. + * @arg [XTS] Output length is output. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Internal error. + * + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_Cipher_DecryptFinal (rsip_ctrl_t * const p_ctrl, + uint8_t * const p_plain, + uint32_t * const p_plain_length) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + fsp_err_t err = FSP_ERR_INVALID_STATE; + switch (p_instance_ctrl->handle_type) + { + case RSIP_HANDLE_TYPE_AES_DECRYPT: + { + err = aes_final(p_ctrl, RSIP_HANDLE_TYPE_AES_DECRYPT); + break; + } + + case RSIP_HANDLE_TYPE_XTS_DECRYPT: + { + err = xts_final(p_ctrl, p_plain, p_plain_length, RSIP_HANDLE_TYPE_XTS_DECRYPT); + break; + } + + default: + { + /* Invalid state */ + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Prepares an AES-GCM encryption. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_key Pointer to wrapped key of AES key. + * @param[in] p_nonce Pointer to nonce. The length is nonce_length. + * @param[in] nonce_length Byte length of nonce. Input 1 or more. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_GCM_EncryptInit (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_key, + uint8_t const * const p_nonce, + uint32_t const nonce_length) +{ + return gcm_init(p_ctrl, p_wrapped_key, p_nonce, nonce_length, RSIP_HANDLE_TYPE_GCM_ENCRYPT); +} + +/*******************************************************************************************************************//** + * Inputs aad and encrypts plaintext. + * + * First process the data that is input from p_aad, and then process the data that is input from p_plain. + * If p_aad data is input after starting to input p_plain data, an error will occur. If p_aad data and p_plain data + * are input to this function at the same time, the p_aad data will be processed, + * and then the function will transition to the p_plain data input state. + * + * Inside this function, the data that is input by the user is buffered until the input values of p_aad and p_plain + * exceed 16 bytes. + * After the input data from p_plain reaches 16 bytes or more, the encryption result is output to p_cipher. + * If the input values p_plain and p_aad are not divisible by 16 bytes, they will be padded inside the function. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_plain Pointer to ciphertext. The length is plain_length. + * @param[out] p_cipher Pointer to destination of ciphertext. + * @param[in] plain_length Byte length of plaintext (0 or more bytes). + * @param[in] p_aad Additional authentication data. The length depends on aad_length. + * @param[in] aad_length Byte length of additional authentication data (0 or more bytes). + * After starting input of plaintext, this value must always be 0. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_INVALID_SIZE Input length is illegal. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_GCM_EncryptUpdate (rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_plain, + uint8_t * const p_cipher, + uint32_t const plain_length, + uint8_t const * const p_aad, + uint32_t const aad_length) +{ + return gcm_update(p_ctrl, p_plain, p_cipher, plain_length, p_aad, aad_length, RSIP_HANDLE_TYPE_GCM_ENCRYPT); +} + +/*******************************************************************************************************************//** + * Finalizes an AES-GCM encryption. + * + * If there is 16-byte fractional data indicated by the total data length of the value of p_plain that was input by + * R_RSIP_AES_GCM_EncryptUpdate(), this API will output the result of encrypting that fractional data to p_cipher. + * Here, the portion that does not reach 16 bytes will be padded with zeros. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[out] p_cipher Pointer to destination of ciphertext. The fractional block is output. + * @param[out] p_cipher_length Pointer to destination of ciphertext length. + * @param[out] p_tag Pointer to destination of tag for authentication. The length is 16 bytes. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Internal error. + * + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_GCM_EncryptFinal (rsip_ctrl_t * const p_ctrl, + uint8_t * const p_cipher, + uint32_t * const p_cipher_length, + uint8_t * const p_tag) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + rsip_func_subset_gcm_t * p_primitive = ((rsip_func_subset_gcm_t *) (p_instance_ctrl->handle.gcm.p_primitive)); + rsip_handle_type_t handle_type = RSIP_HANDLE_TYPE_GCM_ENCRYPT; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_cipher); + FSP_ASSERT(p_cipher_length); + FSP_ASSERT(p_tag); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_final(p_instance_ctrl, handle_type), FSP_ERR_INVALID_STATE); + + uint32_t aad_bit_size[2] = + { + 0 + }; + uint32_t data_bit_size[2] = + { + 0 + }; + + /* If unprocessed AAD still exists in buffer, input it */ + if (!p_instance_ctrl->handle.gcm.has_finished_aad_input) + { + gcm_aad_input_terminate(p_instance_ctrl); + } + + /* Set remaining data */ + if ((0 != (p_instance_ctrl->handle.gcm.total_length % RSIP_BYTE_SIZE_AES_BLOCK)) || + (0 == p_instance_ctrl->handle.gcm.total_length)) + { + memset(p_instance_ctrl->handle.gcm.buffer + p_instance_ctrl->handle.gcm.buffered_length, 0, + (RSIP_BYTE_SIZE_AES_BLOCK - p_instance_ctrl->handle.gcm.buffered_length)); + } + + /* Set parameters */ + aad_bit_size[0] = + bswap_32big(r_rsip_byte_to_bit_convert_upper(p_instance_ctrl->handle.gcm.total_aad_length)); + aad_bit_size[1] = + bswap_32big(r_rsip_byte_to_bit_convert_lower(p_instance_ctrl->handle.gcm.total_aad_length)); + data_bit_size[0] = + bswap_32big((r_rsip_byte_to_bit_convert_upper(p_instance_ctrl->handle.gcm.total_length))); + data_bit_size[1] = bswap_32big(r_rsip_byte_to_bit_convert_lower(p_instance_ctrl->handle.gcm.total_length)); + *p_cipher_length = p_instance_ctrl->handle.gcm.total_length; + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = p_primitive->p_encryptFinal((uint32_t *) (p_instance_ctrl->handle.gcm.buffer), + aad_bit_size, + data_bit_size, + (uint32_t *) p_cipher, + (uint32_t *) p_tag); + + /* Reset handle */ + r_rsip_handle_reset(&p_instance_ctrl->handle); + + /* State transition*/ + r_rsip_state_transit_init(p_instance_ctrl); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Prepares an AES-GCM decryption. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_key Pointer to wrapped key of AES key. + * @param[in] p_nonce Pointer to nonce. The length is nonce_length. + * @param[in] nonce_length Byte length of nonce. Input 1 or more. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_GCM_DecryptInit (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_key, + uint8_t const * const p_nonce, + uint32_t const nonce_length) +{ + return gcm_init(p_ctrl, p_wrapped_key, p_nonce, nonce_length, RSIP_HANDLE_TYPE_GCM_DECRYPT); +} + +/*******************************************************************************************************************//** + * Inputs aad and decrypts ciphertext. + * + * First process the data that is input from p_aad, and then process the data that is input from p_cipher. + * If p_aad data is input after starting to input p_cipher data, an error will occur. If p_aad data and p_cipher data + * are input to this function at the same time, the p_aad data will be processed, + * and then the function will transition to the p_cipher data input state. + * + * Inside this function, the data that is input by the user is buffered until the input values of p_aad and p_cipher + * exceed 16 bytes. + * After the input data from p_cipher reaches 16 bytes or more, the decryption result is output to p_cipher. + * If the input values p_cipher and p_aad are not divisible by 16 bytes, they will be padded inside the function. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_cipher Pointer to ciphertext. The length is cipher_length. + * @param[out] p_plain Pointer to destination of plaintext. + * @param[in] cipher_length Byte length of ciphertext (0 or more bytes). + * @param[in] p_aad Additional authentication data. The length depends on aad_length. + * @param[in] aad_length Byte length of additional authentication data (0 or more bytes). + * After starting input of ciphertext, this value must always be 0. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_INVALID_SIZE Input length is illegal. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_GCM_DecryptUpdate (rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_cipher, + uint8_t * const p_plain, + uint32_t const cipher_length, + uint8_t const * const p_aad, + uint32_t const aad_length) +{ + return gcm_update(p_ctrl, p_cipher, p_plain, cipher_length, p_aad, aad_length, RSIP_HANDLE_TYPE_GCM_DECRYPT); +} + +/*******************************************************************************************************************//** + * Finalizes an AES-GCM decryption. + * + * If there is 16-byte fractional data indicated by the total data length of the value of p_cipher that was input by + * R_RSIP_AES_GCM_DecryptUpdate(), this API will output the result of decrypting that fractional data to p_cipher. + * Here, the portion that does not reach 16 bytes will be padded with zeros. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[out] p_plain Pointer to destination of plaintext. The fractional block is output. + * @param[out] p_plain_length Pointer to destination of plaintext length. + * @param[in] p_tag Pointer to tag for authentication. The length depends on tag_length. + * @param[in] tag_length Byte length of tag. Must be 1 to 16. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_INVALID_SIZE tag_length is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Internal error. + * @retval FSP_ERR_CRYPTO_RSIP_AUTHENTICATION Authentication is failed. + * + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_GCM_DecryptFinal (rsip_ctrl_t * const p_ctrl, + uint8_t * const p_plain, + uint32_t * const p_plain_length, + uint8_t const * const p_tag, + uint32_t const tag_length) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + rsip_func_subset_gcm_t * p_primitive = ((rsip_func_subset_gcm_t *) (p_instance_ctrl->handle.gcm.p_primitive)); + rsip_handle_type_t handle_type = RSIP_HANDLE_TYPE_GCM_DECRYPT; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_plain); + FSP_ASSERT(p_plain_length); + FSP_ASSERT(p_tag); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + /* tag_length must be from 1 to 16 */ + FSP_ERROR_RETURN((0 < tag_length) && (tag_length <= 16), FSP_ERR_INVALID_SIZE); + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_final(p_instance_ctrl, handle_type), FSP_ERR_INVALID_STATE); + + uint32_t aad_bit_size[2] = + { + 0 + }; + uint32_t data_bit_size[2] = + { + 0 + }; + uint32_t tag_length_tmp[1] = + { + 0 + }; + uint32_t tag_tmp[RSIP_BYTE_SIZE_AES_BLOCK / sizeof(uint32_t)] = + { + 0 + }; + + /* If unprocessed AAD still exists in buffer, input it */ + if (!p_instance_ctrl->handle.gcm.has_finished_aad_input) + { + gcm_aad_input_terminate(p_instance_ctrl); + } + + /* Set remaining data */ + if ((0 != (p_instance_ctrl->handle.gcm.total_length % RSIP_BYTE_SIZE_AES_BLOCK)) || + (0 == p_instance_ctrl->handle.gcm.total_length)) + { + memset(p_instance_ctrl->handle.gcm.buffer + p_instance_ctrl->handle.gcm.buffered_length, 0, + (RSIP_BYTE_SIZE_AES_BLOCK - p_instance_ctrl->handle.gcm.buffered_length)); + } + + /* Copy tag */ + memcpy(tag_tmp, p_tag, tag_length); + + /* Set parameters */ + aad_bit_size[0] = + bswap_32big(r_rsip_byte_to_bit_convert_upper(p_instance_ctrl->handle.gcm.total_aad_length)); + aad_bit_size[1] = + bswap_32big(r_rsip_byte_to_bit_convert_lower(p_instance_ctrl->handle.gcm.total_aad_length)); + data_bit_size[0] = + bswap_32big(r_rsip_byte_to_bit_convert_upper(p_instance_ctrl->handle.gcm.total_length)); + data_bit_size[1] = bswap_32big(r_rsip_byte_to_bit_convert_lower(p_instance_ctrl->handle.gcm.total_length)); + *p_plain_length = p_instance_ctrl->handle.gcm.total_length; + tag_length_tmp[0] = bswap_32big(tag_length); + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = p_primitive->p_decryptFinal((uint32_t *) (p_instance_ctrl->handle.gcm.buffer), + (uint32_t *) tag_tmp, + aad_bit_size, + data_bit_size, + (uint32_t *) tag_length_tmp, + (uint32_t *) p_plain); + + /* Reset handle */ + r_rsip_handle_reset(&p_instance_ctrl->handle); + + /* State transition*/ + r_rsip_state_transit_init(p_instance_ctrl); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + case RSIP_RET_AUTH_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_AUTHENTICATION; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Prepares an AES-CMAC generation. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_key Pointer to wrapped key of AES key. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_CMAC_GenerateInit (rsip_ctrl_t * const p_ctrl, rsip_wrapped_key_t const * const p_wrapped_key) +{ + return cmac_init(p_ctrl, p_wrapped_key, RSIP_HANDLE_TYPE_CMAC_GENERATE); +} + +/*******************************************************************************************************************//** + * Inputs message. + * + * Inside this function, the data that is input by the user is buffered until the input value of p_message + * exceeds 16 bytes. + * If the input value, p_message, is not a multiple of 16 bytes, it will be padded within the function. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_message Pointer to message. The length is message_length. + * @param[in] message_length Byte length of message (0 or more bytes). + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_CMAC_GenerateUpdate (rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_message, + uint32_t const message_length) +{ + return cmac_update(p_ctrl, p_message, message_length, RSIP_HANDLE_TYPE_CMAC_GENERATE); +} + +/*******************************************************************************************************************//** + * Finalizes an AES-CMAC generation. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[out] p_mac Pointer to destination of MAC. The length is 16 bytes. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Internal error. + * + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_CMAC_GenerateFinal (rsip_ctrl_t * const p_ctrl, uint8_t * const p_mac) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + rsip_func_subset_cmac_t * p_primitive = + ((rsip_func_subset_cmac_t *) (p_instance_ctrl->handle.cmac.p_primitive)); + rsip_handle_type_t handle_type = RSIP_HANDLE_TYPE_CMAC_GENERATE; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_mac); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_final(p_instance_ctrl, handle_type), FSP_ERR_INVALID_STATE); + + /* + * Check buffered data + * If the buffered data is not a complete block, fill the blank with 10/ (NIST SP 800-38B 6.2 Step4). + */ + if ((0 != (p_instance_ctrl->handle.cmac.buffered_length % RSIP_BYTE_SIZE_AES_BLOCK)) || + (0 == p_instance_ctrl->handle.cmac.total_length)) + { + p_instance_ctrl->handle.cmac.buffer[p_instance_ctrl->handle.cmac.buffered_length] = 1 << 7; + memset(p_instance_ctrl->handle.cmac.buffer + (p_instance_ctrl->handle.cmac.buffered_length + 1), + 0, + RSIP_BYTE_SIZE_AES_BLOCK - (p_instance_ctrl->handle.cmac.buffered_length + 1)); + } + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = + p_primitive->p_generateFinal((const uint32_t *) p_instance_ctrl->handle.cmac.buffer, + (uint32_t *) p_mac, + p_instance_ctrl->handle.cmac.total_length); + + /* Reset handle */ + r_rsip_handle_reset(&p_instance_ctrl->handle); + + /* State transition*/ + r_rsip_state_transit_init(p_instance_ctrl); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Prepares an AES-CMAC verification. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_key Pointer to wrapped key of AES key. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_CMAC_VerifyInit (rsip_ctrl_t * const p_ctrl, rsip_wrapped_key_t const * const p_wrapped_key) +{ + return cmac_init(p_ctrl, p_wrapped_key, RSIP_HANDLE_TYPE_CMAC_VERIFY); +} + +/*******************************************************************************************************************//** + * Inputs message. + * + * Inside this function, the data that is input by the user is buffered until the input value of p_message + * exceeds 16 bytes. + * If the input value, p_message, is not a multiple of 16 bytes, it will be padded within the function. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_message Pointer to message. The length is message_length. + * @param[in] message_length Byte length of message (0 or more bytes). + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_CMAC_VerifyUpdate (rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_message, + uint32_t const message_length) +{ + return cmac_update(p_ctrl, p_message, message_length, RSIP_HANDLE_TYPE_CMAC_VERIFY); +} + +/*******************************************************************************************************************//** + * Finalizes an AES-CMAC generation. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_mac Pointer to MAC. The length depends on mac_length. + * @param[in] mac_length Byte length of MAC. Must be 2 to 16. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_INVALID_SIZE mac_length is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Internal error. + * @retval FSP_ERR_CRYPTO_RSIP_AUTHENTICATION Authentication is failed. + * + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_AES_CMAC_VerifyFinal (rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_mac, + uint32_t const mac_length) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + rsip_func_subset_cmac_t * p_primitive = + ((rsip_func_subset_cmac_t *) (p_instance_ctrl->handle.cmac.p_primitive)); + rsip_handle_type_t handle_type = RSIP_HANDLE_TYPE_CMAC_VERIFY; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_mac); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_final(p_instance_ctrl, handle_type), FSP_ERR_INVALID_STATE); + + /* mac_length must be 2 to 16 */ + FSP_ERROR_RETURN((2 <= mac_length) && (mac_length <= RSIP_BYTE_SIZE_AES_BLOCK), FSP_ERR_INVALID_SIZE); + + /* Set parameters */ + uint32_t mac_length_bit[1] = + { + bswap_32big(mac_length * 8) + }; + uint32_t mac_tmp[RSIP_BYTE_SIZE_AES_BLOCK / sizeof(uint32_t)] = + { + 0 + }; + memcpy(mac_tmp, p_mac, mac_length); + + /* + * Check buffered data + * If the buffered data is not a complete block, fill the blank with 10/ (NIST SP 800-38B 6.2 Step4). + */ + if ((0 != (p_instance_ctrl->handle.cmac.buffered_length % RSIP_BYTE_SIZE_AES_BLOCK)) || + (0 == p_instance_ctrl->handle.cmac.total_length)) + { + p_instance_ctrl->handle.cmac.buffer[p_instance_ctrl->handle.cmac.buffered_length] = 1 << 7; + memset(p_instance_ctrl->handle.cmac.buffer + (p_instance_ctrl->handle.cmac.buffered_length + 1), + 0, + RSIP_BYTE_SIZE_AES_BLOCK - (p_instance_ctrl->handle.cmac.buffered_length + 1)); + } + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = + p_primitive->p_verifyFinal((const uint32_t *) p_instance_ctrl->handle.cmac.buffer, + (const uint32_t *) mac_tmp, + mac_length_bit, + p_instance_ctrl->handle.cmac.total_length); + + /* Reset handle */ + r_rsip_handle_reset(&p_instance_ctrl->handle); + + /* State transition*/ + r_rsip_state_transit_init(p_instance_ctrl); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + case RSIP_RET_AUTH_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_AUTHENTICATION; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * @} (end addtogroup RSIP) + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Prepares an AES-ECB/CBC/CTR. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type or mode is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +static fsp_err_t aes_init (rsip_ctrl_t * p_ctrl, + rsip_aes_mode_t mode, + const rsip_wrapped_key_t * p_wrapped_key, + const uint8_t * p_initial_vector, + rsip_handle_type_t handle_type) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_wrapped_key); + FSP_ASSERT(p_wrapped_key->value); + FSP_ASSERT(p_initial_vector || (RSIP_AES_MODE_ECB == mode)); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_AES_KEY(p_wrapped_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check if the key type is enabled on configuration */ + FSP_ERROR_RETURN(((RSIP_KEY_TYPE_AES_128 == p_wrapped_key->type) && RSIP_CFG_AES_128_ECB_CBC_CTR_ENABLE) || + ((RSIP_KEY_TYPE_AES_256 == p_wrapped_key->type) && RSIP_CFG_AES_256_ECB_CBC_CTR_ENABLE), + FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Initialize handle */ + r_rsip_handle_reset(&p_instance_ctrl->handle); + + /* Set primitive */ + p_instance_ctrl->handle.aes.p_primitive = &gp_func_aes[RSIP_PRV_AES_REBASE(p_wrapped_key->type)]; + + bool is_decryption = (RSIP_HANDLE_TYPE_AES_DECRYPT == handle_type) ? 1 : 0; + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_func_subset_aes_t * p_primitive = ((rsip_func_subset_aes_t *) (p_instance_ctrl->handle.aes.p_primitive)); + rsip_ret_t rsip_ret = + p_primitive->p_init[mode][is_decryption]((const uint32_t *) p_wrapped_key->value, + (const uint32_t *) p_initial_vector); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + /* State transition*/ + r_rsip_state_transit_update(p_instance_ctrl, handle_type); + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Executes AES-ECB/CBC/CTR encryption and decryption. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_INVALID_SIZE Input length is illegal. + **********************************************************************************************************************/ +static fsp_err_t aes_update (rsip_ctrl_t * p_ctrl, + const uint8_t * p_input, + uint8_t * p_output, + uint32_t input_length, + rsip_handle_type_t handle_type) + +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + rsip_func_subset_aes_t * p_primitive = ((rsip_func_subset_aes_t *) (p_instance_ctrl->handle.aes.p_primitive)); + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_input || (0 == input_length)); + FSP_ASSERT(p_output || (0 == input_length)); +#endif + + /* input_length must be a multiple of AES block length */ + FSP_ERROR_RETURN(0 == (input_length % RSIP_BYTE_SIZE_AES_BLOCK), FSP_ERR_INVALID_SIZE); + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_update(p_instance_ctrl, handle_type), FSP_ERR_INVALID_STATE); + + if (0 != input_length) + { + /* Call primitive (cast to match the argument type with the primitive function) */ + p_primitive->p_update((const uint32_t *) p_input, (uint32_t *) p_output, + r_rsip_byte_to_word_convert(input_length)); + } + else + { + /* Do nothing */ + } + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Finalizes an AES-ECB/CBC/CTR. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +static fsp_err_t aes_final (rsip_ctrl_t * p_ctrl, rsip_handle_type_t handle_type) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + rsip_func_subset_aes_t * p_primitive = ((rsip_func_subset_aes_t *) (p_instance_ctrl->handle.aes.p_primitive)); + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_final(p_instance_ctrl, handle_type), FSP_ERR_INVALID_STATE); + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = p_primitive->p_final(); + + /* Reset handle */ + r_rsip_handle_reset(&p_instance_ctrl->handle); + + /* State transition*/ + r_rsip_state_transit_init(p_instance_ctrl); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Prepares an AES-XTS. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type or mode is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +static fsp_err_t xts_init (rsip_ctrl_t * p_ctrl, + const rsip_wrapped_key_t * p_wrapped_key, + const uint8_t * p_initial_vector, + rsip_handle_type_t handle_type) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_wrapped_key); + FSP_ASSERT(p_wrapped_key->value); + FSP_ASSERT(p_initial_vector); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_XTS_AES_KEY(p_wrapped_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check if the key type is enabled on configuration */ + if (RSIP_KEY_TYPE_AES_128_XTS == p_wrapped_key->type) + { + FSP_ERROR_RETURN(((RSIP_HANDLE_TYPE_XTS_ENCRYPT == handle_type) && RSIP_CFG_AES_128_XTS_ENCRYPT_ENABLE) || + ((RSIP_HANDLE_TYPE_XTS_DECRYPT == handle_type) && RSIP_CFG_AES_128_XTS_DECRYPT_ENABLE), + FSP_ERR_NOT_ENABLED); + } + else /* RSIP_KEY_TYPE_AES_256_XTS */ + { + FSP_ERROR_RETURN(((RSIP_HANDLE_TYPE_XTS_ENCRYPT == handle_type) && RSIP_CFG_AES_256_XTS_ENCRYPT_ENABLE) || + ((RSIP_HANDLE_TYPE_XTS_DECRYPT == handle_type) && RSIP_CFG_AES_256_XTS_DECRYPT_ENABLE), + FSP_ERR_NOT_ENABLED); + } +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Initialize handle */ + r_rsip_handle_reset(&p_instance_ctrl->handle); + + /* Set primitive */ + p_instance_ctrl->handle.xts.p_primitive = + &gp_func_xts[RSIP_PRV_XTS_REBASE(p_wrapped_key->type)][RSIP_PRV_XTS_HANDLE_REBASE(handle_type)]; + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_func_subset_xts_t * p_primitive = ((rsip_func_subset_xts_t *) (p_instance_ctrl->handle.xts.p_primitive)); + rsip_ret_t rsip_ret = + p_primitive->p_init((const uint32_t *) p_wrapped_key->value, (const uint32_t *) p_initial_vector); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + /* State transition*/ + r_rsip_state_transit_update(p_instance_ctrl, handle_type); + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Executes AES-XTS encryption and decryption. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_INVALID_SIZE Input length is illegal. + **********************************************************************************************************************/ +static fsp_err_t xts_update (rsip_ctrl_t * p_ctrl, + const uint8_t * p_input, + uint8_t * p_output, + uint32_t input_length, + rsip_handle_type_t handle_type) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + rsip_func_subset_xts_t * p_primitive = ((rsip_func_subset_xts_t *) (p_instance_ctrl->handle.xts.p_primitive)); + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_input || (0 == input_length)); + FSP_ASSERT(p_output || (0 == input_length)); +#endif + + /* input_length must be 0, 17 to 31 (AES block length < input_length < (AES block length * 2)), or multiple of AES block length */ + FSP_ERROR_RETURN((0 == (input_length % RSIP_BYTE_SIZE_AES_BLOCK)) || (0 == input_length) || + (RSIP_BYTE_SIZE_AES_BLOCK < input_length && (RSIP_BYTE_SIZE_AES_BLOCK * 2) > input_length), + FSP_ERR_INVALID_SIZE); + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_update(p_instance_ctrl, handle_type), FSP_ERR_INVALID_STATE); + + /* If input_length is a value between 17 and 31, p_input is input in final function */ + if (0 != (input_length % RSIP_BYTE_SIZE_AES_BLOCK)) + { + /* If a fraction is input, the value and length are stored in handle */ + memset(p_instance_ctrl->handle.xts.buffer, 0, sizeof(p_instance_ctrl->handle.xts.buffer)); + memcpy(p_instance_ctrl->handle.xts.buffer, p_input, input_length); + p_instance_ctrl->handle.xts.buffered_length = input_length; + + /* After this function returns, final function can be called */ + r_rsip_state_transit_final(p_instance_ctrl); + } + /* If input_length is a multiple of 16, call update */ + else if (0 != input_length) + { + /* Call primitive (cast to match the argument type with the primitive function) */ + p_primitive->p_update((const uint32_t *) p_input, (uint32_t *) p_output, + r_rsip_byte_to_word_convert(input_length)); + } + /* If input_length = 0, do nothing */ + else + { + /* Do nothing */ + } + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Finalizes an AES-XTS. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Internal error. + * + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +static fsp_err_t xts_final (rsip_ctrl_t * p_ctrl, + uint8_t * p_output, + uint32_t * p_output_length, + rsip_handle_type_t handle_type) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + rsip_func_subset_xts_t * p_primitive = ((rsip_func_subset_xts_t *) (p_instance_ctrl->handle.xts.p_primitive)); + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_output); + FSP_ASSERT(p_output_length); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_final(p_instance_ctrl, handle_type), FSP_ERR_INVALID_STATE); + + uint32_t output_length_bit[1] = + { + bswap_32big(r_rsip_byte_to_bit_convert_lower(p_instance_ctrl->handle.xts.buffered_length)) + }; + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = + p_primitive->p_final(output_length_bit, (uint32_t *) p_instance_ctrl->handle.xts.buffer, (uint32_t *) p_output); + + *p_output_length = p_instance_ctrl->handle.xts.buffered_length; + + /* Reset handle */ + r_rsip_handle_reset(&p_instance_ctrl->handle); + + /* State transition*/ + r_rsip_state_transit_init(p_instance_ctrl); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Prepares an AES-GCM. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +static fsp_err_t gcm_init (rsip_ctrl_t * p_ctrl, + const rsip_wrapped_key_t * p_wrapped_key, + const uint8_t * p_initial_vector, + uint32_t initial_vector_length, + rsip_handle_type_t handle_type) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_key); + FSP_ASSERT(p_wrapped_key->value); + FSP_ASSERT(p_initial_vector); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_AES_KEY(p_wrapped_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check if the key type is enabled on configuration */ + if (RSIP_KEY_TYPE_AES_128 == p_wrapped_key->type) + { + FSP_ERROR_RETURN(((RSIP_HANDLE_TYPE_GCM_ENCRYPT == handle_type) && RSIP_CFG_AES_128_GCM_ENCRYPT_ENABLE) || + ((RSIP_HANDLE_TYPE_GCM_DECRYPT == handle_type) && RSIP_CFG_AES_128_GCM_DECRYPT_ENABLE), + FSP_ERR_NOT_ENABLED); + } + else /* RSIP_KEY_TYPE_AES_256 */ + { + FSP_ERROR_RETURN(((RSIP_HANDLE_TYPE_GCM_ENCRYPT == handle_type) && RSIP_CFG_AES_256_GCM_ENCRYPT_ENABLE) || + ((RSIP_HANDLE_TYPE_GCM_DECRYPT == handle_type) && RSIP_CFG_AES_256_GCM_DECRYPT_ENABLE), + FSP_ERR_NOT_ENABLED); + } +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Initialize handle */ + r_rsip_handle_reset(&p_instance_ctrl->handle); + + /* Set primitive */ + p_instance_ctrl->handle.gcm.p_primitive = + &gp_func_gcm[RSIP_PRV_AES_REBASE(p_wrapped_key->type)][RSIP_PRV_GCM_HANDLE_REBASE(handle_type)]; + + /* Generate IV */ + uint32_t hashed_ivec[4] = + { + 0 + }; + + fsp_err_t err = + gcm_iv_prepare(p_instance_ctrl, p_initial_vector, initial_vector_length, p_wrapped_key, hashed_ivec); + + if (FSP_SUCCESS == err) + { + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_func_subset_gcm_t * p_primitive = ((rsip_func_subset_gcm_t *) (p_instance_ctrl->handle.gcm.p_primitive)); + rsip_ret_t rsip_ret = + p_primitive->p_init((const uint32_t *) p_wrapped_key->value, hashed_ivec); + + /* Check error */ + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + /* State transition*/ + r_rsip_state_transit_update(p_instance_ctrl, handle_type); + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + } + else + { + /* Do nothing */ + } + + return err; +} + +/*******************************************************************************************************************//** + * Inputs aad and executes encryption and decryption. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_INVALID_SIZE Input length is illegal. + **********************************************************************************************************************/ +static fsp_err_t gcm_update (rsip_ctrl_t * p_ctrl, + const uint8_t * p_input, + uint8_t * p_output, + uint32_t input_length, + const uint8_t * p_aad, + uint32_t aad_length, + rsip_handle_type_t handle_type) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + rsip_func_subset_gcm_t * p_primitive = ((rsip_func_subset_gcm_t *) (p_instance_ctrl->handle.gcm.p_primitive)); + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_input || (0 == input_length)); + FSP_ASSERT(p_output || (0 == input_length)); + FSP_ASSERT(p_aad || (0 == aad_length)); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_update(p_instance_ctrl, handle_type), FSP_ERR_INVALID_STATE); + + /* If AAD is input, flag_update_input_data must be RSIP_PRV_AES_GCM_INPUT_DATA_AAD */ + /* (AAD must be input before plaintext/ciphertext is input) */ + FSP_ERROR_RETURN((0 == aad_length) || (!p_instance_ctrl->handle.gcm.has_finished_aad_input), FSP_ERR_INVALID_SIZE); + + uint32_t length_rest = 0; + uint32_t length_aad_rest = 0; + + /* Input AAD */ + if (0 != aad_length) + { + p_instance_ctrl->handle.gcm.total_aad_length += aad_length; + + if ((p_instance_ctrl->handle.gcm.buffered_length + aad_length) >= RSIP_BYTE_SIZE_AES_BLOCK) + { + /* Input remaining data in buffer */ + memcpy((&p_instance_ctrl->handle.gcm.buffer[0] + p_instance_ctrl->handle.gcm.buffered_length), + p_aad, + RSIP_BYTE_SIZE_AES_BLOCK - p_instance_ctrl->handle.gcm.buffered_length); + + /* Call primitive (cast to match the argument type with the p_primitive function) */ + p_primitive->p_updateAad((uint32_t *) (p_instance_ctrl->handle.gcm.buffer), + r_rsip_byte_to_word_convert((RSIP_BYTE_SIZE_AES_BLOCK))); + length_aad_rest = aad_length - + (RSIP_BYTE_SIZE_AES_BLOCK - p_instance_ctrl->handle.gcm.buffered_length); + memset(p_instance_ctrl->handle.gcm.buffer, 0, sizeof(p_instance_ctrl->handle.gcm.buffer)); + + /* Input block data */ + if (length_aad_rest >= RSIP_BYTE_SIZE_AES_BLOCK) + { + /* Call primitive (cast to match the argument type with the p_primitive function) */ + p_primitive->p_updateAad((const uint32_t *) (p_aad + + (RSIP_BYTE_SIZE_AES_BLOCK - + p_instance_ctrl->handle.gcm.buffered_length)), + r_rsip_byte_to_word_convert((length_aad_rest / RSIP_BYTE_SIZE_AES_BLOCK) * + RSIP_BYTE_SIZE_AES_BLOCK)); + length_aad_rest -= ((length_aad_rest / RSIP_BYTE_SIZE_AES_BLOCK) * RSIP_BYTE_SIZE_AES_BLOCK); + } + + p_instance_ctrl->handle.gcm.buffered_length = 0; + + /* Store remaining data to buffer */ + memcpy(p_instance_ctrl->handle.gcm.buffer, p_aad + (aad_length - length_aad_rest), length_aad_rest); + p_instance_ctrl->handle.gcm.buffered_length = length_aad_rest; + } + else + { + /* Store remaining data to buffer */ + memcpy(&p_instance_ctrl->handle.gcm.buffer[0] + p_instance_ctrl->handle.gcm.buffered_length, + p_aad, + aad_length); + p_instance_ctrl->handle.gcm.buffered_length += aad_length; + } + } + + /* Input plaintext/ciphertext */ + if (0 != input_length) + { + /* If plaintext/ciphertext is input for the first time, input remaining AAD and prohibit new AAD input */ + if (!p_instance_ctrl->handle.gcm.has_finished_aad_input) + { + gcm_aad_input_terminate(p_instance_ctrl); + } + + p_instance_ctrl->handle.gcm.total_length += input_length; + if ((p_instance_ctrl->handle.gcm.buffered_length + input_length) >= RSIP_BYTE_SIZE_AES_BLOCK) + { + /* Input remaining data in buffer */ + memcpy((&p_instance_ctrl->handle.gcm.buffer[0] + p_instance_ctrl->handle.gcm.buffered_length), + p_input, + RSIP_BYTE_SIZE_AES_BLOCK - p_instance_ctrl->handle.gcm.buffered_length); + + /* Call primitive (cast to match the argument type with the p_primitive function) */ + p_primitive->p_update((uint32_t *) (p_instance_ctrl->handle.gcm.buffer), + (uint32_t *) (p_output), + r_rsip_byte_to_word_convert(RSIP_BYTE_SIZE_AES_BLOCK)); + length_rest = input_length - (RSIP_BYTE_SIZE_AES_BLOCK - p_instance_ctrl->handle.gcm.buffered_length); + memset(p_instance_ctrl->handle.gcm.buffer, 0, sizeof(p_instance_ctrl->handle.gcm.buffer)); + + /* Input block data */ + if (length_rest >= RSIP_BYTE_SIZE_AES_BLOCK) + { + /* Call primitive (cast to match the argument type with the p_primitive function) */ + p_primitive->p_update((const uint32_t *) (p_input + + (RSIP_BYTE_SIZE_AES_BLOCK - + p_instance_ctrl->handle.gcm.buffered_length)), + (uint32_t *) (p_output + RSIP_BYTE_SIZE_AES_BLOCK), + ((length_rest / RSIP_BYTE_SIZE_AES_BLOCK) * + r_rsip_byte_to_word_convert(RSIP_BYTE_SIZE_AES_BLOCK))); + length_rest -= ((length_rest / RSIP_BYTE_SIZE_AES_BLOCK) * RSIP_BYTE_SIZE_AES_BLOCK); + } + + p_instance_ctrl->handle.gcm.buffered_length = 0; + + /* Store remaining data to buffer */ + memcpy(p_instance_ctrl->handle.gcm.buffer, p_input + (input_length - length_rest), length_rest); + p_instance_ctrl->handle.gcm.buffered_length = length_rest; + } + else + { + /* Store remaining data to buffer */ + memcpy(&p_instance_ctrl->handle.gcm.buffer[0] + p_instance_ctrl->handle.gcm.buffered_length, + p_input, + input_length); + p_instance_ctrl->handle.gcm.buffered_length += input_length; + } + } + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Generates of input parameter for AES-GCM functions. + * + * @param[in,out] p_instance_ctrl Pointer to control block. + * @param[in] p_initial_vector Pointer to initialization vector. + * @param[in] initial_vector_length Initial vector byte size. + * @param[in] p_wrapped_key Wrapped key area. + * @param[out] p_hashed_ivec Pointer to destination of initialization vector + * (using length of initial_vector_length as a condition) + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + *********************************************************************************************************************/ +static fsp_err_t gcm_iv_prepare (rsip_instance_ctrl_t * p_instance_ctrl, + const uint8_t * p_initial_vector, + uint32_t initial_vector_length, + const rsip_wrapped_key_t * p_wrapped_key, + uint32_t * p_hashed_ivec) +{ + rsip_func_subset_gcm_t * p_primitive = ((rsip_func_subset_gcm_t *) (p_instance_ctrl->handle.gcm.p_primitive)); + + uint32_t hash_subkey[4] = + { + 0 + }; + uint32_t hashed_ivec_tmp[4] = + { + 0 + }; + uint32_t zero[4] = + { + 0 + }; + uint32_t ivec_length_rest = 0; + uint32_t ivec_bit_len[4] = + { + 0 + }; + uint32_t ivec_tmp[4] = + { + 0 + }; + + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + rsip_ret_t rsip_ret = RSIP_RET_FAIL; + + /* If initial_vector_length is 12 (96 bit), hashed_ivec is (initial_vector || 0^{31} || 1) */ + if (12U == initial_vector_length) + { + memcpy(p_hashed_ivec, p_initial_vector, 12U); + p_hashed_ivec[3] = bswap_32big(0x00000001U); + err = FSP_SUCCESS; + } + /* If iv_len is not 12 (96 bit), calculate GHASH */ + else + { + /* Call primitive (cast to match the argument type with the p_primitive function) */ + rsip_ret = p_primitive->p_ecb->p_init[RSIP_AES_MODE_ECB][0]((const uint32_t *) p_wrapped_key->value, zero); + if (RSIP_RET_PASS == rsip_ret) + { + p_primitive->p_ecb->p_update(zero, hash_subkey, RSIP_BYTE_SIZE_AES_BLOCK / sizeof(uint32_t)); + rsip_ret = p_primitive->p_ecb->p_final(); + } + + if (RSIP_RET_PASS == rsip_ret) + { + if (RSIP_BYTE_SIZE_AES_BLOCK <= initial_vector_length) + { + /* Call primitive (cast to match the argument type with the p_primitive function) */ + rsip_ret = + gp_func_ghash_compute(hash_subkey, zero, (const uint32_t *) p_initial_vector, hashed_ivec_tmp, + (initial_vector_length / RSIP_BYTE_SIZE_AES_BLOCK) * sizeof(uint32_t)); + if (RSIP_RET_PASS == rsip_ret) + { + ivec_length_rest = initial_vector_length % RSIP_BYTE_SIZE_AES_BLOCK; + if (0 != ivec_length_rest) + { + memcpy(ivec_tmp, p_initial_vector + (initial_vector_length - ivec_length_rest), + ivec_length_rest); + + /* Call primitive (cast to match the argument type with the p_primitive function) */ + rsip_ret = gp_func_ghash_compute(hash_subkey, + hashed_ivec_tmp, + ivec_tmp, + hashed_ivec_tmp, + RSIP_BYTE_SIZE_AES_BLOCK / sizeof(uint32_t)); + } + } + } + else + { + memcpy(ivec_tmp, p_initial_vector, initial_vector_length); + + /* Call primitive (cast to match the argument type with the p_primitive function) */ + rsip_ret = gp_func_ghash_compute(hash_subkey, + zero, + ivec_tmp, + hashed_ivec_tmp, + RSIP_BYTE_SIZE_AES_BLOCK / sizeof(uint32_t)); + } + + if (RSIP_RET_PASS == rsip_ret) + { + /* Calculate ivec bit length */ + ivec_bit_len[0] = 0U; + ivec_bit_len[1] = 0U; + ivec_bit_len[2] = bswap_32big(r_rsip_byte_to_bit_convert_upper(initial_vector_length)); + ivec_bit_len[3] = bswap_32big(r_rsip_byte_to_bit_convert_lower(initial_vector_length)); + + /* Call primitive (cast to match the argument type with the p_primitive function) */ + rsip_ret = gp_func_ghash_compute(hash_subkey, + hashed_ivec_tmp, + ivec_bit_len, + p_hashed_ivec, + RSIP_BYTE_SIZE_AES_BLOCK / sizeof(uint32_t)); + } + } + + /* Check error */ + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + } + + return err; +} + +static void gcm_aad_input_terminate (rsip_instance_ctrl_t * p_instance_ctrl) +{ + rsip_func_subset_gcm_t * p_primitive = ((rsip_func_subset_gcm_t *) (p_instance_ctrl->handle.gcm.p_primitive)); + + if (0 != (p_instance_ctrl->handle.gcm.buffered_length % RSIP_BYTE_SIZE_AES_BLOCK)) + { + /* Input remaining AAD */ + memset(&p_instance_ctrl->handle.gcm.buffer[0] + p_instance_ctrl->handle.gcm.buffered_length, + 0, + RSIP_BYTE_SIZE_AES_BLOCK - p_instance_ctrl->handle.gcm.buffered_length); + + /* Call primitive (cast to match the argument type with the p_primitive function) */ + p_primitive->p_updateAad((uint32_t *) (p_instance_ctrl->handle.gcm. + buffer), + r_rsip_byte_to_word_convert(RSIP_BYTE_SIZE_AES_BLOCK)); + } + + /* Reset buffer */ + memset(p_instance_ctrl->handle.gcm.buffer, 0, sizeof(p_instance_ctrl->handle.gcm.buffer)); + p_instance_ctrl->handle.gcm.buffered_length = 0; + + /* Prohibit AAD input and start plaintext/ciphertext input */ + p_instance_ctrl->handle.gcm.has_finished_aad_input = true; + p_primitive->p_updateTransition(); +} + +/*******************************************************************************************************************//** + * Prepares an AES-CMAC. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +static fsp_err_t cmac_init (rsip_ctrl_t * p_ctrl, + const rsip_wrapped_key_t * p_wrapped_key, + rsip_handle_type_t handle_type) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_key); + FSP_ASSERT(p_wrapped_key->value); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_AES_KEY(p_wrapped_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check if the key type is enabled on configuration */ + FSP_ERROR_RETURN(((RSIP_KEY_TYPE_AES_128 == p_wrapped_key->type) && RSIP_CFG_AES_128_CMAC_ENABLE) || + ((RSIP_KEY_TYPE_AES_256 == p_wrapped_key->type) && RSIP_CFG_AES_256_CMAC_ENABLE), + FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Initialize handle */ + r_rsip_handle_reset(&p_instance_ctrl->handle); + + /* Set primitive */ + p_instance_ctrl->handle.cmac.p_primitive = &gp_func_cmac[RSIP_PRV_AES_REBASE(p_wrapped_key->type)]; + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_func_subset_cmac_t * p_primitive = ((rsip_func_subset_cmac_t *) (p_instance_ctrl->handle.cmac.p_primitive)); + rsip_ret_t rsip_ret = p_primitive->p_init((const uint32_t *) p_wrapped_key->value); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + /* State transition*/ + r_rsip_state_transit_update(p_instance_ctrl, handle_type); + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Inputs message. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + **********************************************************************************************************************/ +static fsp_err_t cmac_update (rsip_ctrl_t * p_ctrl, + const uint8_t * p_message, + uint32_t message_length, + rsip_handle_type_t handle_type) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + rsip_func_subset_cmac_t * p_primitive = + ((rsip_func_subset_cmac_t *) (p_instance_ctrl->handle.cmac.p_primitive)); + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_message || (0 == message_length)); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_update(p_instance_ctrl, handle_type), FSP_ERR_INVALID_STATE); + + uint32_t length_rest = 0; + + p_instance_ctrl->handle.cmac.total_length += message_length; + if ((p_instance_ctrl->handle.cmac.buffered_length + message_length) > RSIP_BYTE_SIZE_AES_BLOCK) + { + /* Input remaining data in buffer */ + memcpy((&p_instance_ctrl->handle.cmac.buffer[0] + p_instance_ctrl->handle.cmac.buffered_length), + p_message, + RSIP_BYTE_SIZE_AES_BLOCK - p_instance_ctrl->handle.cmac.buffered_length); + + /* Call primitive (cast to match the argument type with the primitive function) */ + p_primitive->p_update((const uint32_t *) (p_instance_ctrl->handle.cmac.buffer), + r_rsip_byte_to_word_convert(RSIP_BYTE_SIZE_AES_BLOCK)); + length_rest = message_length - (RSIP_BYTE_SIZE_AES_BLOCK - p_instance_ctrl->handle.cmac.buffered_length); + memset(p_instance_ctrl->handle.cmac.buffer, 0, sizeof(p_instance_ctrl->handle.cmac.buffer)); + + /* Input block data */ + if (length_rest > RSIP_BYTE_SIZE_AES_BLOCK) + { + /* Call primitive (cast to match the argument type with the primitive function) */ + p_primitive->p_update((const uint32_t *) (p_message + + (RSIP_BYTE_SIZE_AES_BLOCK - + p_instance_ctrl->handle.cmac.buffered_length)), + r_rsip_byte_to_word_convert(((length_rest - 1) / RSIP_BYTE_SIZE_AES_BLOCK) * + RSIP_BYTE_SIZE_AES_BLOCK)); + length_rest -= (((length_rest - 1) / RSIP_BYTE_SIZE_AES_BLOCK) * RSIP_BYTE_SIZE_AES_BLOCK); + } + + p_instance_ctrl->handle.cmac.buffered_length = 0; + + /* Store remaining data to buffer */ + memcpy(p_instance_ctrl->handle.cmac.buffer, p_message + (message_length - length_rest), length_rest); + p_instance_ctrl->handle.cmac.buffered_length = length_rest; + } + else + { + /* Store remaining data to buffer */ + memcpy(&p_instance_ctrl->handle.cmac.buffer[0] + p_instance_ctrl->handle.cmac.buffered_length, + p_message, + message_length); + p_instance_ctrl->handle.cmac.buffered_length += message_length; + } + + return FSP_SUCCESS; +} diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_ecc.c b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_ecc.c new file mode 100644 index 000000000..b95adccb7 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_ecc.c @@ -0,0 +1,240 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "r_rsip_public.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @addtogroup RSIP + * @{ + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Signs a hashed message. The message hash should be generated in advance. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_private_key Pointer to wrapped key of ECC private key. + * @param[in] p_hash Pointer to hash value. The length is as same as the key length. + * @param[out] p_signature Pointer to destination of signature (r, s). + * The length is twice as long as the key length. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL @arg Input parameter is illegal. + * @arg Signature generation is failed. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_ECDSA_Sign (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_private_key, + uint8_t const * const p_hash, + uint8_t * const p_signature) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_private_key); + FSP_ASSERT(p_hash); + FSP_ASSERT(p_signature); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_ECC_PRIVKEY(p_wrapped_private_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_ecdsa_sign[RSIP_PRV_ECC_REBASE(p_wrapped_private_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = + gp_func_ecdsa_sign[RSIP_PRV_ECC_REBASE(p_wrapped_private_key->type)]((const uint32_t *) p_wrapped_private_key-> + value, (const uint32_t *) p_hash, + (uint32_t *) p_signature); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Verifies a hashed message. The message hash should be generated in advance. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_public_key Pointer to wrapped key of ECC public key. + * @param[in] p_hash Pointer to hash value. The length is as same as the key length. + * @param[in] p_signature Pointer to signature (r, s). The length is twice as long as the key length. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL @arg Input parameter is illegal. + * @arg Signature verification is failed. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_ECDSA_Verify (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_public_key, + uint8_t const * const p_hash, + uint8_t const * const p_signature) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_public_key); + FSP_ASSERT(p_hash); + FSP_ASSERT(p_signature); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_ECC_PUBKEY(p_wrapped_public_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_ecdsa_verify[RSIP_PRV_ECC_REBASE(p_wrapped_public_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = + gp_func_ecdsa_verify[RSIP_PRV_ECC_REBASE(p_wrapped_public_key->type)]((const uint32_t *) p_wrapped_public_key-> + value, + (const uint32_t *) p_hash, + (const uint32_t *) p_signature); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * @} (end addtogroup RSIP) + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_public.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_public.h new file mode 100644 index 000000000..d713d53d9 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_public.h @@ -0,0 +1,144 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +#ifndef R_RSIP_COMMON_H +#define R_RSIP_COMMON_H + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "r_rsip.h" +#include "r_rsip_private.h" +#include "r_rsip_util.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +#define RSIP_PRV_IS_AES_KEY(key_type) \ + ((RSIP_KEY_TYPE_AES_128 == (key_type)) || (RSIP_KEY_TYPE_AES_256 == (key_type))) +#define RSIP_PRV_IS_XTS_AES_KEY(key_type) \ + ((RSIP_KEY_TYPE_AES_128_XTS == (key_type)) || (RSIP_KEY_TYPE_AES_256_XTS == (key_type))) +#define RSIP_PRV_IS_ECC_PUBKEY(key_type) \ + ((RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC == (key_type)) || (RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC == (key_type)) || \ + (RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC == (key_type)) || (RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC == (key_type))) +#define RSIP_PRV_IS_ECC_PRIVKEY(key_type) \ + ((RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE == (key_type)) || (RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE == (key_type)) || \ + (RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE == (key_type)) || (RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE == (key_type))) +#define RSIP_PRV_IS_RSA_PUBKEY(key_type) \ + ((RSIP_KEY_TYPE_RSA_3072_PUBLIC == (key_type)) || (RSIP_KEY_TYPE_RSA_4096_PUBLIC == (key_type)) || \ + (RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED == (key_type)) || (RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED == (key_type))) +#define RSIP_PRV_IS_RSA_PRIVKEY(key_type) \ + ((RSIP_KEY_TYPE_RSA_3072_PRIVATE == (key_type)) || (RSIP_KEY_TYPE_RSA_4096_PRIVATE == (key_type)) || \ + (RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED == (key_type)) || (RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED == (key_type))) +#define RSIP_PRV_IS_HMAC_KEY(key_type) \ + ((RSIP_KEY_TYPE_HMAC_SHA1 == (key_type)) || (RSIP_KEY_TYPE_HMAC_SHA224 == (key_type)) || \ + (RSIP_KEY_TYPE_HMAC_SHA256 == (key_type))) + +/* "RSIP" in ASCII, used to determine if channel is open. */ +#define RSIP_OPEN (0x52534950ULL) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Exported global variables + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Public Function Prototypes + **********************************************************************************************************************/ + +/* Internal public functions */ +fsp_err_t r_rsip_random_number_generate(rsip_ctrl_t * const p_ctrl, uint8_t * const p_random); +fsp_err_t r_rsip_sha_generate_init(rsip_ctrl_t * const p_ctrl, + rsip_sha_handle_t * const p_handle, + rsip_hash_type_t const hash_type); +fsp_err_t r_rsip_sha_generate_update(rsip_ctrl_t * const p_ctrl, + rsip_sha_handle_t * const p_handle, + uint8_t const * const p_message, + uint32_t const message_length); +fsp_err_t r_rsip_sha_generate_final(rsip_ctrl_t * const p_ctrl, + rsip_sha_handle_t * const p_handle, + uint8_t * const p_digest); + +/*******************************************************************************************************************//** + * Clears handle. + ***********************************************************************************************************************/ +RSIP_PRV_STATIC_INLINE void r_rsip_handle_reset (rsip_handle_t * handle) +{ + memset(handle, 0, sizeof(rsip_handle_t)); +} + +/*******************************************************************************************************************//** + * Change state to RSIP_STATE_INIT + ***********************************************************************************************************************/ +RSIP_PRV_STATIC_INLINE void r_rsip_state_transit_init (rsip_instance_ctrl_t * p_instance_ctrl) +{ + p_instance_ctrl->state = RSIP_STATE_INIT; + p_instance_ctrl->handle_type = RSIP_HANDLE_TYPE_INVALID; +} + +/*******************************************************************************************************************//** + * Change state to RSIP_STATE_UPDATE + ***********************************************************************************************************************/ +RSIP_PRV_STATIC_INLINE void r_rsip_state_transit_update (rsip_instance_ctrl_t * p_instance_ctrl, + rsip_handle_type_t handle_type) +{ + p_instance_ctrl->state = RSIP_STATE_UPDATE; + p_instance_ctrl->handle_type = handle_type; +} + +/*******************************************************************************************************************//** + * Change state to RSIP_STATE_FINAL + ***********************************************************************************************************************/ +RSIP_PRV_STATIC_INLINE void r_rsip_state_transit_final (rsip_instance_ctrl_t * p_instance_ctrl) +{ + p_instance_ctrl->state = RSIP_STATE_FINAL; +} + +/*******************************************************************************************************************//** + * Check state (RSIP_STATE_INIT) + ***********************************************************************************************************************/ +RSIP_PRV_STATIC_INLINE bool r_rsip_state_check_init (rsip_instance_ctrl_t * p_instance_ctrl) +{ + return RSIP_STATE_INIT == p_instance_ctrl->state; +} + +/*******************************************************************************************************************//** + * Check state (RSIP_STATE_UPDATE) + ***********************************************************************************************************************/ +RSIP_PRV_STATIC_INLINE bool r_rsip_state_check_update (rsip_instance_ctrl_t * p_instance_ctrl, + const rsip_handle_type_t handle_type) +{ + return (RSIP_STATE_UPDATE == p_instance_ctrl->state) && (handle_type == p_instance_ctrl->handle_type); +} + +/*******************************************************************************************************************//** + * Check state (RSIP_STATE_FINAL) + ***********************************************************************************************************************/ +RSIP_PRV_STATIC_INLINE bool r_rsip_state_check_final (rsip_instance_ctrl_t * p_instance_ctrl, + const rsip_handle_type_t handle_type) +{ + return ((RSIP_STATE_UPDATE == p_instance_ctrl->state) || (RSIP_STATE_FINAL == p_instance_ctrl->state)) && + (handle_type == p_instance_ctrl->handle_type); +} + +#endif /* R_RSIP_COMMON_H */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_rsa.c b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_rsa.c new file mode 100644 index 000000000..28fa64d25 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_rsa.c @@ -0,0 +1,2009 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "r_rsip_public.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* Key, hash and RNG sizes */ +#define RSIP_PRV_BYTE_SIZE_RSA_N_1024 (128U) +#define RSIP_PRV_BYTE_SIZE_RSA_N_2048 (256U) +#define RSIP_PRV_BYTE_SIZE_RSA_N_3072 (384U) +#define RSIP_PRV_BYTE_SIZE_RSA_N_4096 (512U) +#define RSIP_PRV_BYTE_SIZE_DIGEST_SHA1 (20U) +#define RSIP_PRV_BYTE_SIZE_DIGEST_SHA224 (28U) +#define RSIP_PRV_BYTE_SIZE_DIGEST_SHA256 (32U) +#define RSIP_PRV_BYTE_SIZE_DIGEST_SHA384 (48U) +#define RSIP_PRV_BYTE_SIZE_DIGEST_SHA512 (64U) +#define RSIP_PRV_BYTE_SIZE_RNG (16U) + +/* Buffer size of EM */ +#if RSIP_CFG_RSA_4096_DECRYPT_ENABLE || RSIP_CFG_RSA_4096_DECRYPT_ENHANCED_ENABLE + #define RSIP_PRV_BYTE_SIZE_RSA_EM_BUFFER (RSIP_PRV_BYTE_SIZE_RSA_N_4096) +#elif RSIP_CFG_RSA_3072_DECRYPT_ENABLE || RSIP_CFG_RSA_3072_DECRYPT_ENHANCED_ENABLE + #define RSIP_PRV_BYTE_SIZE_RSA_EM_BUFFER (RSIP_PRV_BYTE_SIZE_RSA_N_3072) +#elif RSIP_CFG_RSA_2048_DECRYPT_ENABLE || RSIP_CFG_RSA_2048_DECRYPT_ENHANCED_ENABLE + #define RSIP_PRV_BYTE_SIZE_RSA_EM_BUFFER (RSIP_PRV_BYTE_SIZE_RSA_N_2048) +#else + #define RSIP_PRV_BYTE_SIZE_RSA_EM_BUFFER (RSIP_PRV_BYTE_SIZE_RSA_N_1024) +#endif + +/* Buffer size of hash function */ +#define RSIP_PRV_BYTE_SIZE_HASH_BUFFER (RSIP_PRV_BYTE_SIZE_DIGEST_SHA512) + +/* PS (padding string) of EMSA-PKCS1-v1_5 */ +#define RSIP_PRV_EMSA_PKCS1_V1_5_PS (0xFF) + +/* Mask for EMSA-PSS */ +#define RSIP_PRV_EMSA_PSS_MASK (0xFF) + +/* Trailer field of EMSA-PSS (constant) */ +#define RSIP_PRV_EMSA_PSS_TRAILER_FIELD (0xBC) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +static fsp_err_t r_rsip_rsa_encrypt(rsip_wrapped_key_t const * const p_wrapped_public_key, + uint8_t const * const p_plain, + uint8_t * const p_cipher); +static fsp_err_t r_rsip_rsa_decrypt(rsip_wrapped_key_t const * const p_wrapped_private_key, + uint8_t const * const p_cipher, + uint8_t * const p_plain); +static fsp_err_t eme_pkcs1_v1_5_ps_generate(rsip_ctrl_t * const p_ctrl, uint8_t * p_ps, uint32_t ps_length); +static fsp_err_t emsa_pkcs1_v1_5_encode(rsip_hash_type_t const hash_function, + uint8_t const * const p_hash, + uint8_t * const p_em, + uint32_t const em_length); +static fsp_err_t emsa_pss_encode(rsip_ctrl_t * const p_ctrl, + rsip_hash_type_t const hash_function, + rsip_mgf_type_t const mask_generation_function, + int32_t const salt_length, + uint8_t const * const p_mhash, + uint8_t * const p_em, + uint32_t const em_bit_length); +static fsp_err_t emsa_pss_verify(rsip_ctrl_t * const p_ctrl, + rsip_hash_type_t const hash_function, + rsip_mgf_type_t const mask_generation_function, + int32_t const salt_length, + uint8_t const * const p_mhash, + uint8_t * const p_em, + uint32_t const em_bit_length); +static fsp_err_t emsa_pss_h_generate(rsip_ctrl_t * const p_ctrl, + rsip_hash_type_t const hash_function, + uint8_t const * const p_mhash, + uint32_t const hlen, + uint8_t const * const p_salt, + uint32_t const slen, + uint8_t * const p_h); +static fsp_err_t emsa_pss_salt_generate(rsip_ctrl_t * const p_ctrl, + uint8_t * const p_salt, + uint32_t const salt_length); +fsp_err_t emsa_pss_ps_check(uint8_t const * const p_db, + uint32_t const dblen, + uint8_t const ** const pp_salt, + uint32_t * const p_slen, + bool const salt_auto_detection); +static fsp_err_t mgf1_mask(rsip_ctrl_t * const p_ctrl, + rsip_hash_type_t const hash_function, + uint8_t const * const p_mgf_seed, + uint32_t const mgf_seed_len, + uint8_t * const p_mask, + uint32_t const mask_len); +static uint32_t secure_memcmp(const void * buf1, const void * buf2, uint32_t num); +static void * memxor(void * buf1, void * buf2, uint32_t num); +RSIP_PRV_STATIC_INLINE void stack_clear(void * p_buf, const uint32_t num); + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +static const uint32_t gs_key_length[] = +{ + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED)] = RSIP_PRV_BYTE_SIZE_RSA_N_1024, + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED)] = RSIP_PRV_BYTE_SIZE_RSA_N_1024, + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED)] = RSIP_PRV_BYTE_SIZE_RSA_N_2048, + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED)] = RSIP_PRV_BYTE_SIZE_RSA_N_2048, + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_3072_PUBLIC)] = RSIP_PRV_BYTE_SIZE_RSA_N_3072, + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_3072_PRIVATE)] = RSIP_PRV_BYTE_SIZE_RSA_N_3072, + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_4096_PUBLIC)] = RSIP_PRV_BYTE_SIZE_RSA_N_4096, + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_4096_PRIVATE)] = RSIP_PRV_BYTE_SIZE_RSA_N_4096 +}; + +static const uint32_t gs_digest_size[] = +{ + [RSIP_HASH_TYPE_SHA1] = RSIP_PRV_BYTE_SIZE_DIGEST_SHA1, + [RSIP_HASH_TYPE_SHA224] = RSIP_PRV_BYTE_SIZE_DIGEST_SHA224, + [RSIP_HASH_TYPE_SHA256] = RSIP_PRV_BYTE_SIZE_DIGEST_SHA256, + [RSIP_HASH_TYPE_SHA384] = RSIP_PRV_BYTE_SIZE_DIGEST_SHA384, + [RSIP_HASH_TYPE_SHA512] = RSIP_PRV_BYTE_SIZE_DIGEST_SHA512, + [RSIP_HASH_TYPE_SHA512_224] = RSIP_PRV_BYTE_SIZE_DIGEST_SHA224, + [RSIP_HASH_TYPE_SHA512_256] = RSIP_PRV_BYTE_SIZE_DIGEST_SHA256 +}; + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @addtogroup RSIP + * @{ + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Encrypts plaintext with raw RSA. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_public_key Pointer to wrapped key of RSA public key. + * @param[in] p_plain Pointer to plaintext. The length is as same as the key length. + * @param[out] p_cipher Pointer to destination of ciphertext. The length is as same as the key length. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + * + * @note This API provides RSA low-level primitives (RSAEP/RSAVP1). + * It should be used in conjunction with any padding scheme. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_RSA_Encrypt (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_public_key, + uint8_t const * const p_plain, + uint8_t * const p_cipher) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_public_key); + FSP_ASSERT(p_plain); + FSP_ASSERT(p_cipher); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_RSA_PUBKEY(p_wrapped_public_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_rsa_public[RSIP_PRV_RSA_REBASE(p_wrapped_public_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + return r_rsip_rsa_encrypt(p_wrapped_public_key, p_plain, p_cipher); +} + +/*******************************************************************************************************************//** + * Decrypts ciphertext with raw RSA. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_private_key Pointer to wrapped key of RSA private key. + * @param[in] p_cipher Pointer to ciphertext. The length is as same as the key length. + * @param[out] p_plain Pointer to destination of plaintext. The length is as same as the key length. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + * + * @note This API provides RSA low-level primitives (RSADP/RSASP1). + * It should be used in conjunction with any padding scheme. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_RSA_Decrypt (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_private_key, + uint8_t const * const p_cipher, + uint8_t * const p_plain) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_private_key); + FSP_ASSERT(p_cipher); + FSP_ASSERT(p_plain); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_RSA_PRIVKEY(p_wrapped_private_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_rsa_private[RSIP_PRV_RSA_REBASE(p_wrapped_private_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + return r_rsip_rsa_decrypt(p_wrapped_private_key, p_cipher, p_plain); +} + +/*******************************************************************************************************************//** + * Encrypts plaintext with RSAES-PKCS1-v1_5. + * + * `mLen` (plain_length) and `k` (RSA key length) must meet the following condition. + * + * `mlen <= k - 11` + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_public_key Pointer to wrapped key of RSA public key. + * @param[in] p_plain Pointer to plaintext. + * @param[in] plain_length Length of plaintext. + * @param[out] p_cipher Pointer to destination of ciphertext. The length is as same as the key length. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_INVALID_SIZE Any length is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_RSAES_PKCS1_V1_5_Encrypt (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_public_key, + uint8_t const * const p_plain, + uint32_t const plain_length, + uint8_t * const p_cipher) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_public_key); + FSP_ASSERT(p_plain); + FSP_ASSERT(p_cipher); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_RSA_PUBKEY(p_wrapped_public_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_rsa_public[RSIP_PRV_RSA_REBASE(p_wrapped_public_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + uint32_t klen = gs_key_length[RSIP_PRV_RSA_REBASE(p_wrapped_public_key->type)]; // Actual name on RFC8107 is "k" + uint32_t mlen = plain_length; + + /* Check length */ + FSP_ERROR_RETURN((mlen + 11) <= klen, FSP_ERR_INVALID_SIZE); + + uint8_t * p_em = &p_cipher[0]; + + /* + * EME-PKCS1-v1_5 encoding + * EM = 0x00 || 0x02 || PS || 0x00 || M + * + * cipher = EM + */ + p_em[0] = 0x00; + p_em[1] = 0x02; + fsp_err_t err = eme_pkcs1_v1_5_ps_generate(p_ctrl, &p_em[2], klen - mlen - 3); + p_em[klen - mlen - 1] = 0x00; + memcpy(&p_em[klen - mlen], p_plain, mlen); + + if (FSP_SUCCESS == err) + { + /* + * c = RSAEP ((n, e), m) + * + * cipher = c + */ + err = r_rsip_rsa_encrypt(p_wrapped_public_key, p_em, p_em); + } + + /* Clear plaintext if the operation fails */ + if (FSP_SUCCESS != err) + { + memset(p_em, 0, klen); + } + + return err; +} + +/*******************************************************************************************************************//** + * Decrypts with RSAES-PKCS1-v1_5. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_private_key Pointer to wrapped key of RSA private key. + * @param[in] p_cipher Pointer to ciphertext. The length is as same as the key length. + * @param[out] p_plain Pointer to destination of plaintext. + * @param[out] p_plain_length Pointer to destination of actual plaintext length. + * @param[in] plain_buffer_length Length of plaintext destination. It must be equal to or greater than + * *p_plain_length. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_INVALID_SIZE Any length is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + * + * @note The stack usage of this function depends on the maximum key length for RSA decryption enabled in configuration. + * For example, if RSA-2048 is enabled, this function uses at least 256 bytes (2048 bits) of stack. + * To shrink the stack size, please disable unused key length in configuration. + * @note This API skips the ciphertext length checking at RFC8017 (PKCS#1 v2.2) Section 7.2.2 Step 1. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_RSAES_PKCS1_V1_5_Decrypt (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_private_key, + uint8_t const * const p_cipher, + uint8_t * const p_plain, + uint32_t * const p_plain_length, + uint32_t const plain_buffer_length) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_private_key); + FSP_ASSERT(p_cipher); + FSP_ASSERT(p_plain); + FSP_ASSERT(p_plain_length); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_RSA_PRIVKEY(p_wrapped_private_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_rsa_private[RSIP_PRV_RSA_REBASE(p_wrapped_private_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + uint32_t klen = gs_key_length[RSIP_PRV_RSA_REBASE(p_wrapped_private_key->type)]; // Actual name in RFC 8107 is "k" + uint32_t mlen = 0; + + /* + * Prepare EME-PKCS1-v1_5 decoding input + * EM = 0x00 || 0x02 || PS || 0x00 || M + * + * buffer = EM + */ + uint8_t em_buffer[RSIP_PRV_BYTE_SIZE_RSA_EM_BUFFER] = + { + 0 + }; + uint8_t * p_em = &em_buffer[0]; + + /* m = RSADP (K, c) */ + fsp_err_t err = r_rsip_rsa_decrypt(p_wrapped_private_key, p_cipher, p_em); + + /* + * Verification + * In accordance with PKCS #1 v2.2 7.2.2., error code and timing is unified. + */ + if (FSP_SUCCESS == err) + { + uint32_t ptr = 0; + volatile uint32_t error_detection = 0; + + /* Error: The first octet of EM does not have hexadecimal value 0x00 */ + error_detection |= p_em[ptr]; + ptr++; + + /* Error: The second octet of EM does not have hexadecimal value 0x02 */ + error_detection |= p_em[ptr] ^ 0x02; + ptr++; + + /* Error: The length of PS is less than 8 octets */ + for (uint32_t i = 0; i < 8; i++) + { + error_detection |= !p_em[ptr]; + ptr++; + } + + /* Error: There is no octet with hexadecimal value 0x00 to separate PS from M */ + uint32_t zero_detection = 0; + mlen = klen - ptr; + while (klen > ptr) + { + mlen -= !zero_detection; + + zero_detection |= !p_em[ptr]; + ptr++; + } + + error_detection |= !zero_detection; + + if (error_detection) + { + /* Wipe error_detection */ + error_detection = 0; + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + } + } + + /* Output the message M */ + if (FSP_SUCCESS == err) + { + *p_plain_length = mlen; + + /* Buffer length must be equal or grater than actual plaintext length */ + if (*p_plain_length > plain_buffer_length) + { + err = FSP_ERR_INVALID_SIZE; + } + else + { + memcpy(p_plain, &p_em[klen - mlen], mlen); + } + } + + /* Clear plaintext in stack */ + stack_clear(p_em, klen); + + return err; +} + +/*******************************************************************************************************************//** + * Encrypts plaintext with RSAES-OAEP. + * + * `mLen` (plain_length), `hLen` (output length of hash_function), and `k` (RSA key length) + * must meet the following condition. + * + * `mLen <= k - 2 hLen - 2` + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_public_key Pointer to wrapped key of RSA public key. + * @param[in] hash_function Hash function for label. + * @param[in] mask_generation_function Mask generation function in EME-OAEP encoding. + * @param[in] p_label Pointer to label. If label_length != 0, p_label must not be NULL. + * @param[in] label_length Length of label. Please set 0 or more. + * @param[in] p_plain Pointer to plaintext. + * @param[in] plain_length Length of plaintext. + * @param[out] p_cipher Pointer to destination of ciphertext. The length is as same as + * the key length. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_INVALID_SIZE Any length is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_RSAES_OAEP_Encrypt (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_public_key, + rsip_hash_type_t const hash_function, + rsip_mgf_type_t const mask_generation_function, + uint8_t const * const p_label, + uint32_t const label_length, + uint8_t const * const p_plain, + uint32_t const plain_length, + uint8_t * const p_cipher) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_public_key); + FSP_ASSERT(p_label || (0 == label_length)); + FSP_ASSERT(p_plain); + FSP_ASSERT(p_cipher); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_RSA_PUBKEY(p_wrapped_public_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_rsa_public[RSIP_PRV_RSA_REBASE(p_wrapped_public_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + uint32_t klen = gs_key_length[RSIP_PRV_RSA_REBASE(p_wrapped_public_key->type)]; // Actual name on RFC8107 is "k" + uint32_t hlen = gs_digest_size[hash_function]; + uint32_t mlen = plain_length; + uint32_t dblen = klen - hlen - 1; + + /* Check length */ + FSP_ERROR_RETURN((mlen + 2 * hlen + 2) <= klen, FSP_ERR_INVALID_SIZE); + + /* + * Prepare EME-OAEP encoding input + * 0x00 || seed || DB + * DB = lHash || PS || 0x01 || M + * + * cipher = 0x00 || seed || DB + */ + uint8_t * p_em = &p_cipher[0]; + uint8_t * p_seed = &p_em[1]; + uint8_t * p_db = &p_em[1 + hlen]; + uint8_t * p_lhash = &p_em[1 + hlen]; + uint8_t * p_sentinel = &p_em[klen - mlen - 1]; // Position of 0x01 + uint8_t * p_message = &p_em[klen - mlen]; + + /* Zero filling */ + memset(p_em, 0, klen); + + /* Generate seed (length: hlen) */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + + for (uint32_t i = 0; i * RSIP_PRV_BYTE_SIZE_RNG < hlen; i++) + { + uint8_t seed_buffer[RSIP_PRV_BYTE_SIZE_RNG]; + err = r_rsip_random_number_generate(p_ctrl, seed_buffer); + + if (FSP_SUCCESS == err) + { + memcpy(&p_seed[i * RSIP_PRV_BYTE_SIZE_RNG], + seed_buffer, + ((hlen / RSIP_PRV_BYTE_SIZE_RNG) > i) ? RSIP_PRV_BYTE_SIZE_RNG : (hlen % RSIP_PRV_BYTE_SIZE_RNG)); + } + } + + if (FSP_SUCCESS == err) + { + /* Generate lHash (length: hlen) */ + rsip_sha_handle_t handle; + + err = r_rsip_sha_generate_init(p_ctrl, &handle, hash_function); + + if (FSP_SUCCESS == err) + { + err = r_rsip_sha_generate_update(p_ctrl, &handle, p_label, label_length); + + if (FSP_SUCCESS == err) + { + err = r_rsip_sha_generate_final(p_ctrl, &handle, p_lhash); + } + } + + /* Insert 0x01 */ + *p_sentinel = 0x01; + + /* Copy message */ + memcpy(p_message, p_plain, mlen); + } + + /* + * EME-OAEP encoding + * EM = 0x00 || maskedSeed || maskedDB + * + * cipher = EM + */ + rsip_hash_type_t mgf1_hash = (rsip_hash_type_t) mask_generation_function; + + if (FSP_SUCCESS == err) + { + /* + * dbMask = MGF(seed, k - hLen - 1) + * maskedDB = DB \xor dbMask + */ + err = mgf1_mask(p_ctrl, mgf1_hash, p_seed, hlen, p_db, dblen); + } + + if (FSP_SUCCESS == err) + { + /* + * seedMask = MGF(maskedDB, hLen) + * maskedSeed = seed \xor seedMask + */ + err = mgf1_mask(p_ctrl, mgf1_hash, p_db, dblen, p_seed, hlen); + } + + if (FSP_SUCCESS == err) + { + /* + * c = RSAEP ((n, e), m) + * + * cipher = c + */ + err = r_rsip_rsa_encrypt(p_wrapped_public_key, p_em, p_cipher); + } + + /* Clear plaintext if the operation fails */ + if (FSP_SUCCESS != err) + { + memset(p_em, 0, klen); + } + + return err; +} + +/*******************************************************************************************************************//** + * Decrypts ciphertext with RSAES-OAEP. + * + * `hLen` (output length of hash_function) and `k` (RSA key length) must meet the following condition. + * + * `k >= 2 hLen + 2` + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_private_key Pointer to wrapped key of RSA private key. + * @param[in] hash_function Hash function for label. + * @param[in] mask_generation_function Mask generation function in EME-OAEP encoding. + * @param[in] p_label Pointer to label. If label_length != 0, p_label must not be NULL. + * @param[in] label_length Length of label. Please set 0 or more. + * @param[in] p_cipher Pointer to ciphertext. The length is as same as the key length. + * @param[out] p_plain Pointer to destination of plaintext. + * @param[out] p_plain_length Pointer to destination of actual plaintext length. + * @param[in] plain_buffer_length Length of plaintext destination. It must be equal to or greater than + * *p_plain_length. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_INVALID_SIZE Any length is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + * + * @note The stack usage of this function depends on the maximum key length for RSA decryption enabled in configuration. + * For example, if RSA-2048 is enabled, this function uses at least 256 bytes (2048 bits) of stack. + * To shrink the stack size, please disable unused key length in configuration. + * @note This API skips the ciphertext length checking at RFC8017 (PKCS#1 v2.2) Section 7.1.2 Step 1. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_RSAES_OAEP_Decrypt (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_private_key, + rsip_hash_type_t const hash_function, + rsip_mgf_type_t const mask_generation_function, + uint8_t const * const p_label, + uint32_t const label_length, + uint8_t const * const p_cipher, + uint8_t * const p_plain, + uint32_t * const p_plain_length, + uint32_t const plain_buffer_length) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_private_key); + FSP_ASSERT(p_label || (0 == label_length)); + FSP_ASSERT(p_cipher); + FSP_ASSERT(p_plain); + FSP_ASSERT(p_plain_length); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_RSA_PRIVKEY(p_wrapped_private_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_rsa_private[RSIP_PRV_RSA_REBASE(p_wrapped_private_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + uint32_t klen = gs_key_length[RSIP_PRV_RSA_REBASE(p_wrapped_private_key->type)]; // Actual name in RFC 8107 is "k" + uint32_t hlen = gs_digest_size[hash_function]; + uint32_t mlen = 0; + uint32_t dblen = klen - hlen - 1; + + /* Check length */ + FSP_ERROR_RETURN(klen >= (2 * hlen + 2), FSP_ERR_INVALID_SIZE); + + /* + * Prepare EME-OAEP decoding input + * EM = Y || maskedSeed || maskedDB + * + * buffer = EM + */ + uint8_t em_buffer[RSIP_PRV_BYTE_SIZE_RSA_EM_BUFFER]; + uint8_t hash_buffer[RSIP_PRV_BYTE_SIZE_HASH_BUFFER]; + uint8_t * p_em = &em_buffer[0]; + uint8_t * p_seed = &p_em[1]; + uint8_t * p_db = &p_em[1 + hlen]; + uint8_t * p_lhash = &p_em[1 + hlen]; + uint8_t * p_sentinel = NULL; // Position of 0x01 + uint8_t * p_message = NULL; + + /* m = RSADP (K, c) */ + fsp_err_t err = r_rsip_rsa_decrypt(p_wrapped_private_key, p_cipher, p_em); + + /* + * EME-OAEP decoding + * Y || seed || DB + * DB = lHash' || PS || 0x01 || M + * + * buffer = Y || seed || DB + */ + rsip_hash_type_t mgf1_hash = (rsip_hash_type_t) mask_generation_function; + + if (FSP_SUCCESS == err) + { + /* + * seedMask = MGF(maskedDB, hLen) + * seed = maskedSeed \xor seedMask + */ + err = mgf1_mask(p_ctrl, mgf1_hash, p_db, dblen, p_seed, hlen); + } + + if (FSP_SUCCESS == err) + { + /* + * dbMask = MGF(seed, k - hLen - 1) + * DB = maskedDB \xor dbMask + */ + err = mgf1_mask(p_ctrl, mgf1_hash, p_seed, hlen, p_db, dblen); + } + + if (FSP_SUCCESS == err) + { + /* Generate lHash' (output to p_mask) */ + rsip_sha_handle_t handle; + + err = r_rsip_sha_generate_init(p_ctrl, &handle, hash_function); + + if (FSP_SUCCESS == err) + { + err = r_rsip_sha_generate_update(p_ctrl, &handle, p_label, label_length); + + if (FSP_SUCCESS == err) + { + err = r_rsip_sha_generate_final(p_ctrl, &handle, hash_buffer); + } + } + } + + /* + * Verification + * In accordance with PKCS #1 v2.2 7.1.2., error code and timing is unified. + */ + if (FSP_SUCCESS == err) + { + volatile uint32_t error_detection = 0; + + /* Error: There is no octet with hexadecimal value 0x01 to separate PS from M */ + uint32_t nonzero_detection = 0; + mlen = klen - 2 * hlen - 2; // Maximum length + + for (uint32_t i = mlen; i > 0; i--) + { + nonzero_detection |= p_em[klen - i - 1]; + mlen -= !nonzero_detection; + } + + p_sentinel = &p_em[klen - mlen - 1]; + p_message = &p_em[klen - mlen]; + error_detection |= *p_sentinel ^ 0x01; + + /* Error: lHash does not equal lHash' */ + error_detection |= secure_memcmp(p_lhash, hash_buffer, hlen); + + /* Error: Y is nonzero */ + error_detection |= p_em[0]; + + if (error_detection) + { + /* Wipe error_detection */ + error_detection = 0; + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + } + } + + /* Output the message M */ + if (FSP_SUCCESS == err) + { + *p_plain_length = mlen; + + /* Buffer length must be equal or grater than actual plaintext length */ + if (*p_plain_length > plain_buffer_length) + { + err = FSP_ERR_INVALID_SIZE; + } + else + { + memcpy(p_plain, p_message, mlen); + } + } + + /* Clear stack data */ + stack_clear(p_em, klen); + stack_clear(hash_buffer, hlen); + + return err; +} + +/*******************************************************************************************************************//** + * Signs message with RSASSA-PKCS1-v1_5. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_private_key Pointer to wrapped key of RSA private key. + * @param[in] hash_function Hash function in EMSA-PKCS1-v1_5. + * @param[in] p_hash Pointer to input hash. + * @param[out] p_signature Pointer to destination of signature. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_INVALID_SIZE Any length is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_RSASSA_PKCS1_V1_5_Sign (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_private_key, + rsip_hash_type_t const hash_function, + uint8_t const * const p_hash, + uint8_t * const p_signature) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_private_key); + FSP_ASSERT(p_hash); + FSP_ASSERT(p_signature); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_RSA_PRIVKEY(p_wrapped_private_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_rsa_private[RSIP_PRV_RSA_REBASE(p_wrapped_private_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + uint32_t klen = gs_key_length[RSIP_PRV_RSA_REBASE(p_wrapped_private_key->type)]; // Actual name in RFC 8107 is "k" + + /* + * EMSA-PKCS1-v1_5 encoding + * EM = EMSA-PKCS1-V1_5-ENCODE (M, k) + * + * signature = EM + */ + fsp_err_t err = emsa_pkcs1_v1_5_encode(hash_function, p_hash, p_signature, klen); + + /* + * s = RSASP1 (K, m) + * + * signature = s + */ + if (FSP_SUCCESS == err) + { + err = r_rsip_rsa_decrypt(p_wrapped_private_key, p_signature, p_signature); + } + + return err; +} + +/*******************************************************************************************************************//** + * Verifies signature with RSASSA-PKCS1-v1_5. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_public_key Pointer to wrapped key of RSA public key. + * @param[in] hash_function Hash function in EMSA-PKCS1-v1_5. + * @param[in] p_hash Pointer to input hash. + * @param[in] p_signature Pointer to input signature. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_INVALID_SIZE Any length is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + * + * @note The stack usage of this function depends on the maximum key length for RSA decryption enabled in configuration. + * For example, if RSA-2048 is enabled, this function uses at least 512 bytes (2048 bits * 2) of stack. + * To shrink the stack size, please disable unused key length in configuration. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_RSASSA_PKCS1_V1_5_Verify (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_public_key, + rsip_hash_type_t const hash_function, + uint8_t const * const p_hash, + uint8_t const * const p_signature) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_public_key); + FSP_ASSERT(p_hash); + FSP_ASSERT(p_signature); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_RSA_PUBKEY(p_wrapped_public_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_rsa_public[RSIP_PRV_RSA_REBASE(p_wrapped_public_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + uint32_t klen = gs_key_length[RSIP_PRV_RSA_REBASE(p_wrapped_public_key->type)]; // Actual name in RFC 8107 is "k" + + uint8_t em1_buffer[RSIP_PRV_BYTE_SIZE_RSA_EM_BUFFER]; + uint8_t em2_buffer[RSIP_PRV_BYTE_SIZE_RSA_EM_BUFFER]; + + /* + * s = OS2IP (S) + * m = RSAVP1 ((n, e), s) + * EM = I2OSP (m, k) + * + * em1_buffer = EM + */ + fsp_err_t err = r_rsip_rsa_encrypt(p_wrapped_public_key, p_signature, em1_buffer); + + if (FSP_SUCCESS == err) + { + /* + * EMSA-PKCS1-v1_5 encoding + * EM' = EMSA-PKCS1-V1_5-ENCODE (M, k) + * + * em2_buffer = EM' + */ + err = emsa_pkcs1_v1_5_encode(hash_function, p_hash, em2_buffer, klen); + } + + if (FSP_SUCCESS == err) + { + /* Compare the encoded message EM and the second encoded message EM' */ + if (0 != memcmp(em1_buffer, em2_buffer, klen)) + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Signs message with RSASSA-PSS. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_private_key Pointer to wrapped key of RSA private key. + * @param[in] hash_function Hash function in EMSA-PSS-ENCODE. + * @param[in] mask_generation_function Mask generation function in EMSA-PSS-ENCODE. + * @param[in] salt_length Salt length. @ref RSIP_RSA_SALT_LENGTH_AUTO, @ref RSIP_RSA_SALT_LENGTH_HASH, + * @ref RSIP_RSA_SALT_LENGTH_MAX, 0, or positive integers can be set, + * where salt_length <= emLen - hLen - 2 (emLen is the same as the key length + * and hLen is the hash length). + * @param[in] p_hash Pointer to input hash. + * @param[out] p_signature Pointer to destination of signature. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_INVALID_SIZE Any length is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_RSASSA_PSS_Sign (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_private_key, + rsip_hash_type_t const hash_function, + rsip_mgf_type_t const mask_generation_function, + int32_t const salt_length, + uint8_t const * const p_hash, + uint8_t * const p_signature) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_private_key); + FSP_ASSERT(p_hash); + FSP_ASSERT(p_signature); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_RSA_PRIVKEY(p_wrapped_private_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_rsa_private[RSIP_PRV_RSA_REBASE(p_wrapped_private_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + uint32_t klen = gs_key_length[RSIP_PRV_RSA_REBASE(p_wrapped_private_key->type)]; // Actual name in RFC 8107 is "k" + + fsp_err_t err = emsa_pss_encode(p_ctrl, + hash_function, + mask_generation_function, + salt_length, + p_hash, + p_signature, + klen * 8 - 1); + + /* + * s = RSASP1 (K, m) + * + * signature = s + */ + if (FSP_SUCCESS == err) + { + /* + * EMSA-PSS encoding + * EM = EMSA-PSS-ENCODE (M, modBits - 1) + * + * signature = EM + */ + err = r_rsip_rsa_decrypt(p_wrapped_private_key, p_signature, p_signature); + } + + return err; +} + +/*******************************************************************************************************************//** + * Verifies signature with RSASSA-PSS. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_public_key Pointer to wrapped key of RSA public key. + * @param[in] hash_function Hash function in EMSA-PSS-VERIFY. + * @param[in] mask_generation_function Mask generation function in EMSA-PSS-VERIFY. + * @param[in] salt_length Salt length. @ref RSIP_RSA_SALT_LENGTH_AUTO, @ref RSIP_RSA_SALT_LENGTH_HASH, + * @ref RSIP_RSA_SALT_LENGTH_MAX, 0, or positive integers can be set, + * where salt_length <= emLen - hLen - 2 (emLen is the same as the key length + * and hLen is the hash length). + * @param[in] p_hash Pointer to input hash. + * @param[in] p_signature Pointer to input signature. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_INVALID_SIZE Any length is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + * + * @note The stack usage of this function depends on the maximum key length for RSA decryption enabled in configuration. + * For example, if RSA-2048 is enabled, this function uses at least 512 bytes (2048 bits * 2) of stack. + * To shrink the stack size, please disable unused key length in configuration. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_RSASSA_PSS_Verify (rsip_ctrl_t * const p_ctrl, + rsip_wrapped_key_t const * const p_wrapped_public_key, + rsip_hash_type_t const hash_function, + rsip_mgf_type_t const mask_generation_function, + int32_t const salt_length, + uint8_t const * const p_hash, + uint8_t const * const p_signature) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_public_key); + FSP_ASSERT(p_hash); + FSP_ASSERT(p_signature); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_RSA_PUBKEY(p_wrapped_public_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_rsa_public[RSIP_PRV_RSA_REBASE(p_wrapped_public_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + uint32_t klen = gs_key_length[RSIP_PRV_RSA_REBASE(p_wrapped_public_key->type)]; // Actual name in RFC 8107 is "k" + + uint8_t em_buffer[RSIP_PRV_BYTE_SIZE_RSA_EM_BUFFER]; + + /* + * s = OS2IP (S) + * m = RSAVP1 ((n, e), s) + * EM = I2OSP (m, emLen) + * + * em_buffer = EM + */ + fsp_err_t err = r_rsip_rsa_encrypt(p_wrapped_public_key, p_signature, em_buffer); + + if (FSP_SUCCESS == err) + { + /* + * EMSA-PSS verification + * Result = EMSA-PSS-VERIFY (M, EM, modBits - 1) + */ + err = emsa_pss_verify(p_ctrl, + hash_function, + mask_generation_function, + salt_length, + p_hash, + em_buffer, + klen * 8 - 1); + } + + return err; +} + +/*******************************************************************************************************************//** + * @} (end addtogroup RSIP) + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Encrypts plaintext with raw RSA. + * + * @param[in] p_wrapped_public_key Pointer to wrapped key of RSA public key. + * @param[in] p_plain Pointer to plaintext. The length is as same as the key length. + * @param[out] p_cipher Pointer to destination of ciphertext. The length is as same as the key length. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +static fsp_err_t r_rsip_rsa_encrypt (rsip_wrapped_key_t const * const p_wrapped_public_key, + uint8_t const * const p_plain, + uint8_t * const p_cipher) +{ + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = + gp_func_rsa_public[RSIP_PRV_RSA_REBASE(p_wrapped_public_key->type)]((const uint32_t *) p_wrapped_public_key-> + value, (const uint32_t *) p_plain, + (uint32_t *) p_cipher); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Decrypts ciphertext with raw RSA. + * + * @param[in] p_wrapped_private_key Pointer to wrapped key of RSA private key. + * @param[in] p_cipher Pointer to ciphertext. The length is as same as the key length. + * @param[out] p_plain Pointer to destination of plaintext. The length is as same as the key length. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +static fsp_err_t r_rsip_rsa_decrypt (rsip_wrapped_key_t const * const p_wrapped_private_key, + uint8_t const * const p_cipher, + uint8_t * const p_plain) +{ + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = + gp_func_rsa_private[RSIP_PRV_RSA_REBASE(p_wrapped_private_key->type)]((const uint32_t *) p_wrapped_private_key-> + value, (const uint32_t *) p_cipher, + (uint32_t *) p_plain); + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Generates PS (Padding String) for EME-PKCS1-v1_5 + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[out] p_ps Pointer to PS. + * @param[in] ps_length Length of PS. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + ***********************************************************************************************************************/ +static fsp_err_t eme_pkcs1_v1_5_ps_generate (rsip_ctrl_t * const p_ctrl, uint8_t * const p_ps, uint32_t const ps_length) +{ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + uint32_t rand_ptr = 0; + uint8_t rand_tmp[RSIP_PRV_BYTE_SIZE_RNG]; + + while (ps_length > rand_ptr) + { + err = r_rsip_random_number_generate(p_ctrl, rand_tmp); + if (FSP_SUCCESS != err) + { + break; + } + + for (uint32_t i = 0; i < RSIP_PRV_BYTE_SIZE_RNG; i++) + { + if (0 != rand_tmp[i]) + { + p_ps[rand_ptr] = rand_tmp[i]; + rand_ptr++; + } + + if (ps_length == rand_ptr) + { + break; + } + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Computes EMSA-PKCS1-v1_5-ENCODE. + * + * @param[in] hash_function Hash function in EMSA-PKCS1-v1_5. + * @param[in] p_hash Pointer to input hash. + * @param[out] p_em Pointer to destination of EM (Encoded Message). + * @param[in] em_length Length of EM. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_INVALID_SIZE Key length is too short. + **********************************************************************************************************************/ +static fsp_err_t emsa_pkcs1_v1_5_encode (rsip_hash_type_t const hash_function, + uint8_t const * const p_hash, + uint8_t * const p_em, + uint32_t const em_length) +{ + static const uint8_t digest_info_prefix[][19] = + { + [RSIP_HASH_TYPE_SHA1] = + { + 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 + }, + [RSIP_HASH_TYPE_SHA224] = + { + 0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, + 0x00, 0x04, 0x1c + }, + [RSIP_HASH_TYPE_SHA256] = + { + 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, + 0x00, 0x04, 0x20 + }, + [RSIP_HASH_TYPE_SHA384] = + { + 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, + 0x00, 0x04, 0x30 + }, + [RSIP_HASH_TYPE_SHA512] = + { + 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, + 0x00, 0x04, 0x40 + }, + [RSIP_HASH_TYPE_SHA512_224] = + { + 0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x05, 0x05, + 0x00, 0x04, 0x1c + }, + [RSIP_HASH_TYPE_SHA512_256] = + { + 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x06, 0x05, + 0x00, 0x04, 0x20 + }, + }; + static const uint32_t digest_info_prefix_len[] = + { + [RSIP_HASH_TYPE_SHA1] = 15, + [RSIP_HASH_TYPE_SHA224] = 19, + [RSIP_HASH_TYPE_SHA256] = 19, + [RSIP_HASH_TYPE_SHA384] = 19, + [RSIP_HASH_TYPE_SHA512] = 19, + [RSIP_HASH_TYPE_SHA512_224] = 19, + [RSIP_HASH_TYPE_SHA512_256] = 19 + }; + + uint8_t const * t_prefix = digest_info_prefix[hash_function]; + uint32_t t_prefix_len = digest_info_prefix_len[hash_function]; + uint32_t t_hash_len = gs_digest_size[hash_function]; + + /* Check length */ + FSP_ERROR_RETURN((t_prefix_len + t_hash_len + 11) <= em_length, FSP_ERR_INVALID_SIZE); + + /* Padding */ + p_em[0] = 0x00; + p_em[1] = 0x01; + memset(&p_em[2], RSIP_PRV_EMSA_PKCS1_V1_5_PS, em_length - t_prefix_len - t_hash_len - 3); + p_em[em_length - t_prefix_len - t_hash_len - 1] = 0x00; + + /* Copy the prefix of DER encoding T */ + memcpy(&p_em[em_length - t_prefix_len - t_hash_len], t_prefix, t_prefix_len); + + /* Copy hash */ + memcpy(&p_em[em_length - t_hash_len], p_hash, t_hash_len); + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Computes EMSA-PSS-ENCODE. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] hash_function Hash function in EMSA-PSS-ENCODE. + * @param[in] mask_generation_function Mask generation function in EMSA-PSS-ENCODE. + * @param[in] salt_length Salt length. + * @param[in] p_mhash Pointer to mHash. + * @param[out] p_em Pointer to destination of EM (Encoded Message). + * @param[in] em_bit_length Bit length of EM. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_INVALID_SIZE Key length is too short. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +static fsp_err_t emsa_pss_encode (rsip_ctrl_t * const p_ctrl, + rsip_hash_type_t const hash_function, + rsip_mgf_type_t const mask_generation_function, + int32_t const salt_length, + uint8_t const * const p_mhash, + uint8_t * const p_em, + uint32_t const em_bit_length) +{ + uint32_t slen; + uint32_t hlen = gs_digest_size[hash_function]; + uint32_t emlen = (em_bit_length + 7) / 8; // round up + + /* Set salt length */ + uint32_t slen_max = emlen - hlen - 2; + switch (salt_length) + { + case RSIP_RSA_SALT_LENGTH_AUTO: + { + slen = (slen_max >= hlen) ? hlen : slen_max; + break; + } + + case RSIP_RSA_SALT_LENGTH_HASH: + { + slen = hlen; + break; + } + + case RSIP_RSA_SALT_LENGTH_MAX: + { + slen = slen_max; + break; + } + + default: + { + /* Check sign */ + FSP_ERROR_RETURN(salt_length >= 0, FSP_ERR_INVALID_SIZE); + + slen = (uint32_t) salt_length; + } + } + + uint8_t * p_db = &p_em[0]; + uint8_t * p_salt = &p_em[emlen - slen - hlen - 1]; + uint8_t * p_hash = &p_em[emlen - hlen - 1]; + + /* Check length */ + FSP_ERROR_RETURN(emlen >= hlen + slen + 2, FSP_ERR_INVALID_SIZE); + + /* + * DB = PS ((0x)00 00 ...) || 0x01 || salt + * + * em = DB + */ + memset(p_db, 0x00, emlen - hlen - slen - 2); + p_em[emlen - hlen - slen - 2] = 0x01; + fsp_err_t err = emsa_pss_salt_generate(p_ctrl, p_salt, slen); + + if (FSP_SUCCESS == err) + { + /* + * mHash = Hash(M) + * M' = Padding1 ((0x)00 00 00 00 00 00 00 00) || mHash || salt + * H = Hash(M') + * Set trailer field (0xbc) + * + * em = DB || H || 0xbc + */ + err = emsa_pss_h_generate(p_ctrl, hash_function, p_mhash, hlen, p_salt, slen, p_hash); + p_em[emlen - 1] = RSIP_PRV_EMSA_PSS_TRAILER_FIELD; + } + + if (FSP_SUCCESS == err) + { + /* + * dbMask = MGF(H, emLen - hLen - 1) + * maskedDB = DB \xor dbMask + * + * em = maskedDB || H || 0xbc + */ + rsip_hash_type_t mgf1_hash = (rsip_hash_type_t) mask_generation_function; + err = mgf1_mask(p_ctrl, mgf1_hash, p_hash, hlen, p_db, emlen - hlen - 1); + } + + if (FSP_SUCCESS == err) + { + /* Set the leftmost 8emLen - emBits bits of the leftmost octet in maskedDB to zero */ + p_em[0] &= (uint8_t) (RSIP_PRV_EMSA_PSS_MASK >> (8 * emlen - em_bit_length)); + } + + return err; +} + +/*******************************************************************************************************************//** + * Computes EMSA-PSS-VERIFY. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] hash_function Hash function in EMSA-PSS-VERIFY. + * @param[in] mask_generation_function Mask generation function in EMSA-PSS-VERIFY. + * @param[in] salt_length Salt length. + * @param[in] p_mhash Pointer to mHash. + * @param[in,out] p_em Pointer to EM (Encoded Message). This argument is used as working area. + * Therefore, the value is destroyed after executing this function. + * @param[in] em_bit_length Bit length of EM. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_INVALID_SIZE Key length is too short. + * + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Verification failed. + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +static fsp_err_t emsa_pss_verify (rsip_ctrl_t * const p_ctrl, + rsip_hash_type_t const hash_function, + rsip_mgf_type_t const mask_generation_function, + int32_t const salt_length, + uint8_t const * const p_mhash, + uint8_t * const p_em, + uint32_t const em_bit_length) +{ + uint32_t slen = 0; + uint32_t hlen = gs_digest_size[hash_function]; + uint32_t emlen = (em_bit_length + 7) / 8; // round up + bool salt_auto_detection = false; + + /* Set salt length*/ + uint32_t slen_max = emlen - hlen - 2; + switch (salt_length) + { + case RSIP_RSA_SALT_LENGTH_AUTO: + { + salt_auto_detection = true; + break; + } + + case RSIP_RSA_SALT_LENGTH_HASH: + { + slen = hlen; + break; + } + + case RSIP_RSA_SALT_LENGTH_MAX: + { + slen = slen_max; + break; + } + + default: + { + /* Check sign */ + FSP_ERROR_RETURN(salt_length >= 0, FSP_ERR_INVALID_SIZE); + + slen = (uint32_t) salt_length; + } + } + + uint8_t hash_buffer[RSIP_PRV_BYTE_SIZE_HASH_BUFFER]; + uint8_t * p_db = &p_em[0]; + uint8_t * p_salt = &p_em[emlen - slen - hlen - 1]; + uint8_t * p_hash = &p_em[emlen - hlen - 1]; + + /* Check length */ + FSP_ERROR_RETURN(emlen >= hlen + slen + 2, FSP_ERR_INVALID_SIZE); + + /* Error: the rightmost octet of EM does not have hexadecimal value 0xbc */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + + if (p_em[emlen - 1] != RSIP_PRV_EMSA_PSS_TRAILER_FIELD) + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + } + else + { + err = FSP_SUCCESS; + } + + /* the leftmost 8emLen - emBits bits of the leftmost octet in maskedDB are not all equal to zero */ + if (FSP_SUCCESS == err) + { + if (0x00 != (p_em[0] & ~(RSIP_PRV_EMSA_PSS_MASK >> (8 * emlen - em_bit_length)))) + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + } + } + + /* + * dbMask = MGF(H, emLen - hLen - 1) + * DB = maskedDB \xor dbMask + * + * em = DB || H || 0xbc + */ + if (FSP_SUCCESS == err) + { + rsip_hash_type_t mgf1_hash = (rsip_hash_type_t) mask_generation_function; + err = mgf1_mask(p_ctrl, mgf1_hash, p_hash, hlen, p_db, emlen - hlen - 1); + } + + if (FSP_SUCCESS == err) + { + /* Set the leftmost 8emLen - emBits bits of the leftmost octet in DB to zero */ + p_em[0] &= (uint8_t) (RSIP_PRV_EMSA_PSS_MASK >> (8 * emlen - em_bit_length)); + + /* + * Error: the emLen - hLen - sLen - 2 leftmost octets of DB are not zero or the octet at position + * emLen - hLen - sLen - 1 (the leftmost position is "position 1") does not have hexadecimal value 0x01 + */ + err = emsa_pss_ps_check(p_db, emlen - hlen - 1, (uint8_t const **) &p_salt, &slen, salt_auto_detection); + } + + /* + * mHash = Hash(M) + * M' = Padding1 ((0x)00 00 00 00 00 00 00 00) || mHash || salt + * H' = Hash(M') + * + * hash_buffer = H' + */ + if (FSP_SUCCESS == err) + { + err = emsa_pss_h_generate(p_ctrl, hash_function, p_mhash, hlen, p_salt, slen, hash_buffer); + } + + /* Compare H and H' */ + if (FSP_SUCCESS == err) + { + if (0 != memcmp(p_hash, hash_buffer, hlen)) + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Computes H or H' in EMSA-PSS. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] hash_function Hash function in EMSA-PSS. + * @param[in] p_mhash Pointer to mHash. + * @param[in] hlen hLen. + * @param[in] p_salt Pointer to salt. + * @param[in] slen sLen. + * @param[out] p_h Pointer to destination of H or H'. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +static fsp_err_t emsa_pss_h_generate (rsip_ctrl_t * const p_ctrl, + rsip_hash_type_t const hash_function, + uint8_t const * const p_mhash, + uint32_t const hlen, + uint8_t const * const p_salt, + uint32_t const slen, + uint8_t * const p_h) +{ + /* "Padding1" in EMSA-PSS */ + static const uint8_t padding1[8] = + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + rsip_sha_handle_t handle; + + fsp_err_t err = r_rsip_sha_generate_init(p_ctrl, &handle, hash_function); + + if (FSP_SUCCESS == err) + { + err = r_rsip_sha_generate_update(p_ctrl, &handle, padding1, sizeof(padding1)); + + if (FSP_SUCCESS == err) + { + err = r_rsip_sha_generate_update(p_ctrl, &handle, p_mhash, hlen); + + if (FSP_SUCCESS == err) + { + err = r_rsip_sha_generate_update(p_ctrl, &handle, p_salt, slen); + + if (FSP_SUCCESS == err) + { + err = r_rsip_sha_generate_final(p_ctrl, &handle, p_h); + } + } + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Generates salt for EMSA-PSS-ENCODE + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[out] p_salt Pointer to salt. + * @param[in] salt_length Length of salt. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + ***********************************************************************************************************************/ +static fsp_err_t emsa_pss_salt_generate (rsip_ctrl_t * const p_ctrl, uint8_t * const p_salt, uint32_t const salt_length) +{ + fsp_err_t err = FSP_SUCCESS; + uint32_t rand_ptr = 0; + uint8_t rand_tmp[RSIP_PRV_BYTE_SIZE_RNG]; + + for (uint32_t i = 0; i < salt_length / 16; i++) + { + err = r_rsip_random_number_generate(p_ctrl, &p_salt[rand_ptr]); + rand_ptr += 16; + } + + if (rand_ptr < salt_length) + { + err = r_rsip_random_number_generate(p_ctrl, rand_tmp); + memcpy(&p_salt[rand_ptr], rand_tmp, salt_length - rand_ptr); + } + + return err; +} + +/*******************************************************************************************************************//** + * Check PS for EMSA-PSS-VERIFY + * + * @param[in] p_db Pointer to DB (Data Block). + * @param[in] dblen DB length. + * @param[out] pp_salt Pointer to start address of salt. If salt_auto_detection is true, + * the address is updated in this function. + * @param[in,out] p_slen Pointer to salt length. If salt_auto_detection is true, + * detected salt length is output. Otherwise, the known salt length should be input. + * @param[in] salt_auto_detection If true, salt length is detected automatically. + * Otherwise, this function use input salt length. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL PS is invalid. + **********************************************************************************************************************/ +fsp_err_t emsa_pss_ps_check (uint8_t const * const p_db, + uint32_t const dblen, + uint8_t const ** const pp_salt, + uint32_t * const p_slen, + bool const salt_auto_detection) +{ + fsp_err_t err = FSP_SUCCESS; + uint32_t ps_ptr = 0; + + if (salt_auto_detection) + { + /* Detect salt */ + while ((ps_ptr < dblen) && (0x00 == p_db[ps_ptr])) + { + ps_ptr++; + } + + if (0x01 != p_db[ps_ptr]) + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + } + else + { + *p_slen = dblen - ps_ptr - 1; + *pp_salt = &p_db[dblen - *p_slen]; + } + } + else + { + /* Verify sLen */ + for (ps_ptr = 0; ps_ptr < dblen - *p_slen - 1; ps_ptr++) + { + if (0x00 != p_db[ps_ptr]) + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + } + } + + if (0x01 != p_db[ps_ptr]) + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Computes MGF1 and outputs (input XOR MGF1). + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] hash_function Hash function used in MGF1. + * @param[in] p_mgf_seed Seed used in MGF1. + * @param[in] mgf_seed_len Length of seed. + * @param[in,out] p_mask Pointer to input data and destination of output data. + * @param[in] mask_len Length of mask. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + ***********************************************************************************************************************/ +static fsp_err_t mgf1_mask (rsip_ctrl_t * const p_ctrl, + rsip_hash_type_t const hash_function, + uint8_t const * const p_mgf_seed, + uint32_t const mgf_seed_len, + uint8_t * const p_mask, + uint32_t const mask_len) +{ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + uint32_t hlen = gs_digest_size[hash_function]; + uint8_t buffer[RSIP_PRV_BYTE_SIZE_HASH_BUFFER]; + + for (uint32_t counter = 0; counter * hlen < mask_len; counter++) + { + rsip_sha_handle_t handle; + + /* Generate mask */ + err = r_rsip_sha_generate_init(p_ctrl, &handle, hash_function); + if (FSP_SUCCESS == err) + { + err = r_rsip_sha_generate_update(p_ctrl, &handle, p_mgf_seed, mgf_seed_len); + if (FSP_SUCCESS == err) + { + uint32_t counter_big[1] = {bswap_32big(counter)}; + err = r_rsip_sha_generate_update(p_ctrl, &handle, (uint8_t *) counter_big, 4); + if (FSP_SUCCESS == err) + { + err = r_rsip_sha_generate_final(p_ctrl, &handle, buffer); + } + } + } + + /* Output masked data */ + if (FSP_SUCCESS == err) + { + memxor(&p_mask[counter * hlen], buffer, ((mask_len / hlen) > counter) ? hlen : (mask_len % hlen)); + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Compares buf1 and buf2 while protecting against timing attack. + * + * @param[in] buf1 Pointer to buf1. + * @param[in] buf2 Pointer to buf2. + * @param[in] num Byte size of buf1 and buf2. + * + * @retval 0 buf1 and buf2 are equal. + * @retval 1 buf1 and buf2 are not equal. + **********************************************************************************************************************/ +static uint32_t secure_memcmp (const void * buf1, const void * buf2, uint32_t num) +{ + uint8_t * p_buf1 = (uint8_t *) buf1; + uint8_t * p_buf2 = (uint8_t *) buf2; + uint32_t tmp = 0; + + for (uint32_t i = 0; i < num; i++) + { + tmp |= p_buf1[i] ^ p_buf2[i]; + } + + return tmp > 0; +} + +/*******************************************************************************************************************//** + * Computes buf1 XOR buf2. + * + * @param[in,out] buf1 Pointer to buf1. buf1 XOR buf2 is output. + * @param[in] buf2 Pointer to buf2. + * @param[in] num Byte size of buf1 and buf2. + * + * @return Pointer to buf1. + **********************************************************************************************************************/ +static void * memxor (void * buf1, void * buf2, uint32_t num) +{ + uint8_t * p_buf1 = (uint8_t *) buf1; + uint8_t * p_buf2 = (uint8_t *) buf2; + + for (uint32_t i = 0; i < num; i++) + { + p_buf1[i] ^= p_buf2[i]; + } + + return buf1; +} + +/*******************************************************************************************************************//** + * Clears stack data. + * + * If memset_s is supported, it is guaranteed that this function will not be optimized. + * + * @param[in,out] p_buf Stack data to be cleared. + * @param[in] num Stack data size. + ***********************************************************************************************************************/ +RSIP_PRV_STATIC_INLINE void stack_clear (void * p_buf, const uint32_t num) +{ +#if __STDC_WANT_LIB_EXT1__ + memset_s(p_buf, num, 0, num); +#else + void * (* volatile p_memset)(void *, int, size_t) = memset; + p_memset(p_buf, 0, num); +#endif +} diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_rzg3.c b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_rzg3.c new file mode 100644 index 000000000..a5cc827c2 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_rzg3.c @@ -0,0 +1,332 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "r_rsip_public.h" +#include "r_rsip_wrapper.h" +#include "r_rsip_otp.h" +#include "r_rsip_primitive.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/* Key import with UFPK */ +typedef rsip_ret_t (* rsip_func_key_import_with_ufpk_t)(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], const uint32_t InData_IV[], + const uint32_t InData_InstData[], uint32_t OutData_KeyIndex[]); + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +#if RSIP_CFG_PARAM_CHECKING_ENABLE +static const rsip_key_type_bool_table_t gs_key_import_with_ufpk_supported_algs = +{ + [RSIP_KEY_TYPE_AES_128] = true, + [RSIP_KEY_TYPE_AES_256] = true, + [RSIP_KEY_TYPE_AES_128_XTS] = true, + [RSIP_KEY_TYPE_AES_256_XTS] = true, + [RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC] = true, + [RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE] = true, + [RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC] = true, + [RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE] = true, + [RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC] = true, + [RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE] = true, + [RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC] = true, + [RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE] = true, + [RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED] = true, + [RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED] = true, + [RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED] = true, + [RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED] = true, + [RSIP_KEY_TYPE_RSA_3072_PUBLIC] = true, + [RSIP_KEY_TYPE_RSA_3072_PRIVATE] = true, + [RSIP_KEY_TYPE_RSA_4096_PUBLIC] = true, + [RSIP_KEY_TYPE_RSA_4096_PRIVATE] = true, + [RSIP_KEY_TYPE_HMAC_SHA1] = true, + [RSIP_KEY_TYPE_HMAC_SHA224] = true, + [RSIP_KEY_TYPE_HMAC_SHA256] = true, + [RSIP_KEY_TYPE_KEY_UPDATE_KEY] = true, + [RSIP_KEY_TYPE_SECURE_BOOT_DECRYPTION] = true +}; +#endif + +static const rsip_func_key_import_with_ufpk_t gsp_func_key_import_with_ufpk[] = +{ +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_AES_128_ENABLE + [RSIP_KEY_TYPE_AES_128] = r_rsip_p10, +#else + [RSIP_KEY_TYPE_AES_128] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_AES_256_ENABLE + [RSIP_KEY_TYPE_AES_256] = r_rsip_p04, +#else + [RSIP_KEY_TYPE_AES_256] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_AES_128_XTS_ENABLE + [RSIP_KEY_TYPE_AES_128_XTS] = r_rsip_p18, +#else + [RSIP_KEY_TYPE_AES_128_XTS] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_AES_256_XTS_ENABLE + [RSIP_KEY_TYPE_AES_256_XTS] = r_rsip_p1a, +#else + [RSIP_KEY_TYPE_AES_256_XTS] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp192r1_PUBLIC_ENABLE + [RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC] = r_rsip_wrapper_pfa_secp192r1, +#else + [RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp192r1_PRIVATE_ENABLE + [RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE] = r_rsip_wrapper_pf3_secp192r1, +#else + [RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp224r1_PUBLIC_ENABLE + [RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC] = r_rsip_wrapper_pfa_secp224r1, +#else + [RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp224r1_PRIVATE_ENABLE + [RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE] = r_rsip_wrapper_pf3_secp224r1, +#else + [RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp256r1_PUBLIC_ENABLE + [RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC] = r_rsip_wrapper_pfa_secp256r1, +#else + [RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp256r1_PRIVATE_ENABLE + [RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE] = r_rsip_wrapper_pf3_secp256r1, +#else + [RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_BRAINPOOLP256R1_PUBLIC_ENABLE + [RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC] = r_rsip_wrapper_pfa_brainpoolp256r1, +#else + [RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_BRAINPOOLP256R1_PRIVATE_ENABLE + [RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE] = r_rsip_wrapper_pf3_brainpoolp256r1, +#else + [RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_1024_PUBLIC_ENHANCED_ENABLE + [RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED] = r_rsip_p59, +#else + [RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_1024_PRIVATE_ENHANCED_ENABLE + [RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED] = r_rsip_p60, +#else + [RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_2048_PUBLIC_ENHANCED_ENABLE + [RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED] = r_rsip_p62, +#else + [RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_2048_PRIVATE_ENHANCED_ENABLE + [RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED] = r_rsip_p63, +#else + [RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_3072_PUBLIC_ENABLE + [RSIP_KEY_TYPE_RSA_3072_PUBLIC] = r_rsip_p37, +#else + [RSIP_KEY_TYPE_RSA_3072_PUBLIC] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_3072_PRIVATE_ENABLE + [RSIP_KEY_TYPE_RSA_3072_PRIVATE] = r_rsip_p42, +#else + [RSIP_KEY_TYPE_RSA_3072_PRIVATE] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_4096_PUBLIC_ENABLE + [RSIP_KEY_TYPE_RSA_4096_PUBLIC] = r_rsip_p43, +#else + [RSIP_KEY_TYPE_RSA_4096_PUBLIC] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_4096_PRIVATE_ENABLE + [RSIP_KEY_TYPE_RSA_4096_PRIVATE] = r_rsip_p45, +#else + [RSIP_KEY_TYPE_RSA_4096_PRIVATE] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_HMAC_SHA_ENABLE + [RSIP_KEY_TYPE_HMAC_SHA1] = r_rsip_wrapper_p80_hmac_sha1, + [RSIP_KEY_TYPE_HMAC_SHA224] = r_rsip_wrapper_p80_hmac_sha224, + [RSIP_KEY_TYPE_HMAC_SHA256] = r_rsip_wrapper_p80_hmac_sha256, +#else + [RSIP_KEY_TYPE_HMAC_SHA1] = NULL, + [RSIP_KEY_TYPE_HMAC_SHA224] = NULL, + [RSIP_KEY_TYPE_HMAC_SHA256] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_KUK_ENABLE + [RSIP_KEY_TYPE_KEY_UPDATE_KEY] = r_rsip_p1f, +#else + [RSIP_KEY_TYPE_KEY_UPDATE_KEY] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_UFPK_SECURE_BOOT_DECRYPTION_ENABLE + [RSIP_KEY_TYPE_SECURE_BOOT_DECRYPTION] = r_rsip_p03, +#else + [RSIP_KEY_TYPE_SECURE_BOOT_DECRYPTION] = NULL, +#endif +}; + + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @addtogroup RSIP + * @{ + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Imports a user key with UFPK (User Factory Programming Key) within the user routine. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_user_factory_programming_key Wrapped User Factory Programming Key (W-UFPK). + * The length is 32 bytes. + * @param[in] p_initial_vector Initialization vector when generating encrypted_key. + * The length is 16 bytes. + * @param[in] key_type Inputs/Outputs key type. + * @param[in] p_encrypted_key Encrypted user key. The length depends on the key type. + * @param[out] p_wrapped_key Pointer to destination of wrapped key. + * The length depends on the key type. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_UNSUPPORTED Input key type is unsupported. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL Input parameter is invalid. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + * + * @sa Section @ref r-rsip-key-management "Key Management" + **********************************************************************************************************************/ +fsp_err_t R_RSIP_KeyImportWithUFPK (rsip_ctrl_t * const p_ctrl, + uint8_t const * const p_wrapped_user_factory_programming_key, + uint8_t const * const p_initial_vector, + rsip_key_type_t const key_type, + uint8_t const * const p_encrypted_key, + rsip_wrapped_key_t * const p_wrapped_key) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + /* Set primitive */ + rsip_func_key_import_with_ufpk_t p_primitive = gsp_func_key_import_with_ufpk[key_type]; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_user_factory_programming_key); + FSP_ASSERT(p_initial_vector); + FSP_ASSERT(p_encrypted_key); + FSP_ASSERT(p_wrapped_key); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(gs_key_import_with_ufpk_supported_algs[key_type], FSP_ERR_UNSUPPORTED); + + /* Check if the key type is enabled on configuration */ + FSP_ERROR_RETURN(p_primitive, FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + /* Read W-HRK from S_FLASH */ + uint32_t whrk_num[RSIP_PRV_WORD_SIZE_WRAPPED_HARDWARE_ROOT_KEY_NUM]; + uint32_t whrk[RSIP_PRV_WORD_SIZE_WRAPPED_HARDWARE_ROOT_KEY]; + + memcpy(whrk_num, p_wrapped_user_factory_programming_key, sizeof(whrk_num)); + rsip_ret_t rsip_ret = r_rsip_whrk_read(whrk_num, whrk); + + if (RSIP_RET_PASS == rsip_ret) + { + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret = + p_primitive((uint32_t const *) whrk_num, + (uint32_t const *) whrk, + (uint32_t const *) &p_wrapped_user_factory_programming_key[sizeof(whrk_num)], + (uint32_t const *) p_initial_vector, + (uint32_t const *) p_encrypted_key, + (uint32_t *) p_wrapped_key->value); + } + + /* Check error */ + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + p_wrapped_key->type = key_type; + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * @} (end addtogroup RSIP) + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_sha.c b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_sha.c new file mode 100644 index 000000000..756780713 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rsip_common/public/r_rsip_sha.c @@ -0,0 +1,1104 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "r_rsip_public.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* Block size */ +#define RSIP_PRV_BYTE_SIZE_HASH_BLOCK_SHA1_SHA224_SHA256 (64U) +#define RSIP_PRV_BYTE_SIZE_HASH_BLOCK_SHA384_SHA512 (128U) + +/* MAC length */ +#define RSIP_PRV_BYTE_SIZE_HMAC_SHA1_MAC (20U) +#define RSIP_PRV_BYTE_SIZE_HMAC_SHA224_MAC (28U) +#define RSIP_PRV_BYTE_SIZE_HMAC_SHA256_MAC (32U) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +static fsp_err_t hmac_init(rsip_ctrl_t * p_ctrl, + rsip_hmac_handle_t * p_handle, + const rsip_wrapped_key_t * p_wrapped_key, + bool is_generate); +static fsp_err_t hmac_update(rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + uint8_t const * const p_message, + uint32_t const message_length, + bool is_generate); + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @addtogroup RSIP + * @{ + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Generates SHA message digest. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] hash_type Generating hash type. + * @param[in] p_message Pointer to message. The length is message_length. + * @param[in] message_length Byte length of message (0 or more bytes). + * @param[out] p_digest Pointer to destination of message digest. The length depends on hash type. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_SHA_Compute (rsip_ctrl_t * const p_ctrl, + rsip_hash_type_t const hash_type, + uint8_t const * const p_message, + uint32_t const message_length, + uint8_t * const p_digest) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_message || (0 == message_length)); + FSP_ASSERT(p_digest); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Call function (cast to match the argument type with the function) */ + rsip_ret_t rsip_ret = r_rsip_sha1sha2_compute_single((const uint32_t *) p_message, + (uint32_t *) p_digest, + hash_type, + message_length); + + /* Check error */ + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Generates HMAC. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_key Pointer to wrapped key of HMAC key. + * @param[in] p_message Pointer to message. The length is message_length. + * @param[in] message_length Byte length of message (0 or more bytes). + * @param[out] p_mac Pointer to destination of message digest. The length depends on MAC type. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_HMAC_Compute (rsip_ctrl_t * const p_ctrl, + const rsip_wrapped_key_t * p_wrapped_key, + uint8_t const * const p_message, + uint32_t const message_length, + uint8_t * const p_mac) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_key); + FSP_ASSERT(p_message || (0 == message_length)); + FSP_ASSERT(p_mac); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_HMAC_KEY(p_wrapped_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_hmac_single[RSIP_PRV_HMAC_REBASE(p_wrapped_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Set primitive */ + rsip_func_hmac_single_t p_primitive = gp_func_hmac_single[RSIP_PRV_HMAC_REBASE(p_wrapped_key->type)]; + + /* Call function (cast to match the argument type with the function) */ + rsip_ret_t rsip_ret = r_rsip_hmac_compute_single((const uint32_t *) p_message, + (uint32_t *) p_mac, + p_primitive, + p_wrapped_key, + message_length); + + /* Check error */ + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + /* RSIP_RET_FAIL is not used in this function */ + case RSIP_RET_FAIL: + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Verifies HMAC. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in] p_wrapped_key Pointer to wrapped key of HMAC key. + * @param[in] p_message Pointer to message. The length is message_length. + * @param[in] message_length Byte length of message (0 or more bytes). + * @param[in] p_mac Pointer to MAC. The length depends on mac_length. + * @param[in] mac_length Byte length of MAC. + * @arg HMAC-SHA1: 4 to 20 + * @arg HMAC-SHA224: 4 to 28 + * @arg HMAC-SHA256 4 to 32 + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_INVALID_SIZE mac_length is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL MAC verification is failed. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_HMAC_Verify (rsip_ctrl_t * const p_ctrl, + const rsip_wrapped_key_t * p_wrapped_key, + uint8_t const * const p_message, + uint32_t const message_length, + uint8_t const * const p_mac, + uint32_t const mac_length) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_wrapped_key); + FSP_ASSERT(p_message || (0 == message_length)); + FSP_ASSERT(p_mac); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_HMAC_KEY(p_wrapped_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_hmac_single[RSIP_PRV_HMAC_REBASE(p_wrapped_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* mac_length must be 4 or greater (common) */ + FSP_ERROR_RETURN(4 <= mac_length, FSP_ERR_INVALID_SIZE); + + rsip_key_type_t key_type = p_wrapped_key->type; + + /* mac_length must be 20 or less (SHA-1) */ + FSP_ERROR_RETURN((RSIP_KEY_TYPE_HMAC_SHA1 != key_type) || (mac_length <= RSIP_PRV_BYTE_SIZE_HMAC_SHA1_MAC), + FSP_ERR_INVALID_SIZE); + + /* mac_length must be 28 or less (SHA-224) */ + FSP_ERROR_RETURN((RSIP_KEY_TYPE_HMAC_SHA224 != key_type) || + (mac_length <= RSIP_PRV_BYTE_SIZE_HMAC_SHA224_MAC), + FSP_ERR_INVALID_SIZE); + + /* mac_length must be 32 or less (SHA-256) */ + FSP_ERROR_RETURN((RSIP_KEY_TYPE_HMAC_SHA256 != key_type) || + (mac_length <= RSIP_PRV_BYTE_SIZE_HMAC_SHA256_MAC), + FSP_ERR_INVALID_SIZE); + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Set primitive */ + rsip_func_hmac_single_t p_primitive = gp_func_hmac_single[RSIP_PRV_HMAC_REBASE(p_wrapped_key->type)]; + + /* Call function (cast to match the argument type with the function) */ + rsip_ret_t rsip_ret = r_rsip_hmac_verify_single((const uint32_t *) p_message, + p_mac, + p_primitive, + p_wrapped_key, + message_length, + mac_length); + + /* Check error */ + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Prepares a SHA generation. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in,out] p_handle Pointer to SHA control block. Must be declared by user. Elements are set here. + * @param[in] hash_type Generating hash type. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_SHA_GenerateInit (rsip_ctrl_t * const p_ctrl, + rsip_sha_handle_t * const p_handle, + rsip_hash_type_t const hash_type) +{ +#if RSIP_CFG_PARAM_CHECKING_ENABLE + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_handle); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + return r_rsip_sha_generate_init(p_ctrl, p_handle, hash_type); +} + +/*******************************************************************************************************************//** + * Inputs message. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in,out] p_handle Pointer to SHA control block. + * @param[in] p_message Pointer to message. The length is message_length. + * @param[in] message_length Byte length of message (0 or more bytes). + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_SHA_GenerateUpdate (rsip_ctrl_t * const p_ctrl, + rsip_sha_handle_t * const p_handle, + uint8_t const * const p_message, + uint32_t const message_length) +{ +#if RSIP_CFG_PARAM_CHECKING_ENABLE + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_handle); + FSP_ASSERT(p_message || (0 == message_length)); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + return r_rsip_sha_generate_update(p_ctrl, p_handle, p_message, message_length); +} + +/*******************************************************************************************************************//** + * Finalizes a SHA generation. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in,out] p_handle Pointer to SHA control block. + * @param[out] p_digest Pointer to destination of message digest. The length depends on hash type. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_SHA_GenerateFinal (rsip_ctrl_t * const p_ctrl, + rsip_sha_handle_t * const p_handle, + uint8_t * const p_digest) +{ +#if RSIP_CFG_PARAM_CHECKING_ENABLE + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_handle); + FSP_ASSERT(p_digest); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + return r_rsip_sha_generate_final(p_ctrl, p_handle, p_digest); +} + +/*******************************************************************************************************************//** + * Prepares a HMAC generation. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in,out] p_handle Pointer to HMAC control block. Must be declared by user. Elements are set here. + * @param[in] p_wrapped_key Pointer to wrapped key of HMAC key. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_HMAC_GenerateInit (rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + rsip_wrapped_key_t const * const p_wrapped_key) +{ + return hmac_init(p_ctrl, p_handle, p_wrapped_key, true); +} + +/*******************************************************************************************************************//** + * Inputs message. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in,out] p_handle Pointer to HMAC control block. + * @param[in] p_message Pointer to message. The length is message_length. + * @param[in] message_length Byte length of message (0 or more bytes). + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_HMAC_GenerateUpdate (rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + uint8_t const * const p_message, + uint32_t const message_length) +{ + return hmac_update(p_ctrl, p_handle, p_message, message_length, true); +} + +/*******************************************************************************************************************//** + * Finalizes a HMAC generation. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in,out] p_handle Pointer to HMAC control block. + * @param[out] p_mac Pointer to destination of message digest. The length depends on MAC type. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_HMAC_GenerateFinal (rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + uint8_t * const p_mac) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_handle); + FSP_ASSERT(p_mac); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + FSP_ERROR_RETURN((RSIP_USER_HANDLE_STATE_UPDATE_EMPTY == p_handle->state) || + (RSIP_USER_HANDLE_STATE_UPDATE == p_handle->state), + FSP_ERR_INVALID_STATE); + FSP_ERROR_RETURN(p_handle->is_generate, FSP_ERR_INVALID_STATE); + + /* Call function */ + rsip_ret_t rsip_ret = + r_rsip_hmac_calc_multi(p_handle, p_handle->buffer, p_handle->buffered_length, p_mac, 0, true); + + /* Check error */ + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + /* State transition */ + p_handle->state = RSIP_USER_HANDLE_STATE_INIT; + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + /* RSIP_RET_FAIL is not used in this function */ + case RSIP_RET_FAIL: + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Prepares a HMAC verification. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in,out] p_handle Pointer to HMAC control block. Must be declared by user. Elements are set here. + * @param[in] p_wrapped_key Pointer to wrapped key of HMAC key. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_HMAC_VerifyInit (rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + rsip_wrapped_key_t const * const p_wrapped_key) +{ + return hmac_init(p_ctrl, p_handle, p_wrapped_key, false); +} + +/*******************************************************************************************************************//** + * Inputs message. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in,out] p_handle Pointer to HMAC control block. + * @param[in] p_message Pointer to message. The length is message_length. + * @param[in] message_length Byte length of message (0 or more bytes). + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_HMAC_VerifyUpdate (rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + uint8_t const * const p_message, + uint32_t const message_length) +{ + return hmac_update(p_ctrl, p_handle, p_message, message_length, false); +} + +/*******************************************************************************************************************//** + * Finalizes a HMAC verification. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in,out] p_handle Pointer to HMAC control block. + * @param[in] p_mac Pointer to MAC. The length depends on mac_length. + * @param[in] mac_length Byte length of MAC. + * @arg HMAC-SHA1: 4 to 20 + * @arg HMAC-SHA224: 4 to 28 + * @arg HMAC-SHA256 4 to 32 + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_INVALID_SIZE mac_length is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_FAIL MAC verification is failed. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t R_RSIP_HMAC_VerifyFinal (rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + uint8_t const * const p_mac, + uint32_t const mac_length) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_handle); + FSP_ASSERT(p_mac); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + FSP_ERROR_RETURN((RSIP_USER_HANDLE_STATE_UPDATE_EMPTY == p_handle->state) || + (RSIP_USER_HANDLE_STATE_UPDATE == p_handle->state), + FSP_ERR_INVALID_STATE); + FSP_ERROR_RETURN(!p_handle->is_generate, FSP_ERR_INVALID_STATE); + + /* mac_length must be 4 or greater (common) */ + FSP_ERROR_RETURN(4 <= mac_length, FSP_ERR_INVALID_SIZE); + + rsip_key_type_t key_type = ((rsip_wrapped_key_t *) &(p_handle->wrapped_key))->type; + + /* mac_length must be 20 or less (SHA-1) */ + FSP_ERROR_RETURN((RSIP_KEY_TYPE_HMAC_SHA1 != key_type) || (mac_length <= RSIP_PRV_BYTE_SIZE_HMAC_SHA1_MAC), + FSP_ERR_INVALID_SIZE); + + /* mac_length must be 28 or less (SHA-224) */ + FSP_ERROR_RETURN((RSIP_KEY_TYPE_HMAC_SHA224 != key_type) || + (mac_length <= RSIP_PRV_BYTE_SIZE_HMAC_SHA224_MAC), + FSP_ERR_INVALID_SIZE); + + /* mac_length must be 32 or less (SHA-256) */ + FSP_ERROR_RETURN((RSIP_KEY_TYPE_HMAC_SHA256 != key_type) || + (mac_length <= RSIP_PRV_BYTE_SIZE_HMAC_SHA256_MAC), + FSP_ERR_INVALID_SIZE); + + /* Call function (cast to match the argument type with the function) */ + rsip_ret_t rsip_ret = r_rsip_hmac_calc_multi(p_handle, + p_handle->buffer, + p_handle->buffered_length, + (uint8_t *) p_mac, + mac_length, + true); + + /* Check error */ + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + /* State transition */ + p_handle->state = RSIP_USER_HANDLE_STATE_INIT; + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + case RSIP_RET_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FAIL; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*******************************************************************************************************************//** + * @} (end addtogroup RSIP) + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Prepares a SHA generation. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in,out] p_handle Pointer to SHA control block. Must be declared by user. Elements are set here. + * @param[in] hash_type Generating hash type. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + **********************************************************************************************************************/ +fsp_err_t r_rsip_sha_generate_init (rsip_ctrl_t * const p_ctrl, + rsip_sha_handle_t * const p_handle, + rsip_hash_type_t const hash_type) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Reset handle */ + p_handle->buffered_length = 0; + p_handle->total_length = 0; + + /* Set hash type */ + p_handle->type = hash_type; + + /* Set block size */ + switch (hash_type) + { + /* SHA-1, SHA-224, SHA-256 */ + case RSIP_HASH_TYPE_SHA1: + case RSIP_HASH_TYPE_SHA224: + case RSIP_HASH_TYPE_SHA256: + { + p_handle->block_size = RSIP_PRV_BYTE_SIZE_HASH_BLOCK_SHA1_SHA224_SHA256; + break; + } + + /* SHA-384, SHA-512, SHA-512/224, SHA-512/256 */ + default: + { + p_handle->block_size = RSIP_PRV_BYTE_SIZE_HASH_BLOCK_SHA384_SHA512; + } + } + + /* State transition */ + p_handle->state = RSIP_USER_HANDLE_STATE_UPDATE_EMPTY; + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Inputs message. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in,out] p_handle Pointer to SHA control block. + * @param[in] p_message Pointer to message. The length is message_length. + * @param[in] message_length Byte length of message (0 or more bytes). + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t r_rsip_sha_generate_update (rsip_ctrl_t * const p_ctrl, + rsip_sha_handle_t * const p_handle, + uint8_t const * const p_message, + uint32_t const message_length) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + FSP_ERROR_RETURN((RSIP_USER_HANDLE_STATE_UPDATE_EMPTY == p_handle->state) || + (RSIP_USER_HANDLE_STATE_UPDATE == p_handle->state), + FSP_ERR_INVALID_STATE); + + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + if (0 == message_length) + { + err = FSP_SUCCESS; + } + else + { + rsip_ret_t rsip_ret = RSIP_RET_PASS; + const uint8_t * p_msg_pos = p_message; + uint32_t processed_len = 0; + + /* (1) Remaining message in buffer and head of new input message */ + if ((0 != p_handle->buffered_length) && + (p_handle->block_size < (p_handle->buffered_length + message_length))) + { + uint32_t len = p_handle->block_size - p_handle->buffered_length; + + /* Copy head of new message to buffer */ + memcpy(p_handle->buffer + p_handle->buffered_length, p_msg_pos, len); + + /* Call function */ + rsip_ret = r_rsip_sha1sha2_calc_multi(p_handle, p_handle->buffer, p_handle->block_size, NULL); + + p_handle->buffered_length = 0; + processed_len += len; + } + + /* (2) New input message except last block */ + if ((p_handle->block_size < message_length) && (RSIP_RET_PASS == rsip_ret)) + { + uint32_t len = ((message_length - processed_len - 1) / p_handle->block_size) * + p_handle->block_size; + + /* Call function */ + rsip_ret = r_rsip_sha1sha2_calc_multi(p_handle, p_message + processed_len, len, NULL); + + processed_len += len; + } + + /* Check error */ + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + /* (3) Last block */ + memcpy(p_handle->buffer + p_handle->buffered_length, + p_message + processed_len, + message_length - processed_len); + p_handle->buffered_length += message_length - processed_len; + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + } + + return err; +} + +/*******************************************************************************************************************//** + * Finalizes a SHA generation. + * + * @param[in,out] p_ctrl Pointer to control block. + * @param[in,out] p_handle Pointer to SHA control block. + * @param[out] p_digest Pointer to destination of message digest. The length depends on hash type. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +fsp_err_t r_rsip_sha_generate_final (rsip_ctrl_t * const p_ctrl, + rsip_sha_handle_t * const p_handle, + uint8_t * const p_digest) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + FSP_ERROR_RETURN((RSIP_USER_HANDLE_STATE_UPDATE_EMPTY == p_handle->state) || + (RSIP_USER_HANDLE_STATE_UPDATE == p_handle->state), + FSP_ERR_INVALID_STATE); + + /* Call function */ + rsip_ret_t rsip_ret = r_rsip_sha1sha2_calc_multi(p_handle, p_handle->buffer, p_handle->buffered_length, p_digest); + + /* Check error */ + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + /* State transition */ + p_handle->state = RSIP_USER_HANDLE_STATE_INIT; + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + + return err; +} + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Prepares a HMAC. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_NOT_ENABLED Input key type is disabled in this function by configuration. + * @retval FSP_ERR_INVALID_ARGUMENT Input key type is illegal. + **********************************************************************************************************************/ +static fsp_err_t hmac_init (rsip_ctrl_t * p_ctrl, + rsip_hmac_handle_t * p_handle, + const rsip_wrapped_key_t * p_wrapped_key, + bool is_generate) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_handle); + FSP_ASSERT(p_wrapped_key); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); + + /* Check key type */ + FSP_ERROR_RETURN(RSIP_PRV_IS_HMAC_KEY(p_wrapped_key->type), FSP_ERR_INVALID_ARGUMENT); + + /* Check configuration */ + FSP_ERROR_RETURN(gp_func_hmac_multi[RSIP_PRV_HMAC_REBASE(p_wrapped_key->type)], FSP_ERR_NOT_ENABLED); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + + /* Reset handle */ + p_handle->buffered_length = 0; + p_handle->total_length = 0; + + /* Copy wrapped key */ + memcpy(p_handle->wrapped_key, p_wrapped_key, RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA256); + + /* Set primitive */ + p_handle->p_primitive = (rsip_func_hmac_multi_t *) gp_func_hmac_multi[RSIP_PRV_HMAC_REBASE(p_wrapped_key->type)]; + + /* Set block size */ + p_handle->block_size = RSIP_PRV_BYTE_SIZE_HASH_BLOCK_SHA1_SHA224_SHA256; + + /* State transition */ + p_handle->state = RSIP_USER_HANDLE_STATE_UPDATE_EMPTY; + + /* Set flag */ + p_handle->is_generate = is_generate; + + return FSP_SUCCESS; +} + +/*******************************************************************************************************************//** + * Inputs message. + * + * @retval FSP_SUCCESS Normal termination. + * @retval FSP_ERR_ASSERTION A required parameter is NULL. + * @retval FSP_ERR_NOT_OPEN Module is not open. + * @retval FSP_ERR_INVALID_STATE Internal state is illegal. + * @retval FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL Input key value is illegal. + * + * @retval FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required + * by the processing is in use by other processing. + * @retval FSP_ERR_CRYPTO_RSIP_FATAL Software corruption is detected. + **********************************************************************************************************************/ +static fsp_err_t hmac_update (rsip_ctrl_t * const p_ctrl, + rsip_hmac_handle_t * const p_handle, + uint8_t const * const p_message, + uint32_t const message_length, + bool is_generate) +{ + rsip_instance_ctrl_t * p_instance_ctrl = (rsip_instance_ctrl_t *) p_ctrl; + fsp_err_t err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + +#if RSIP_CFG_PARAM_CHECKING_ENABLE + FSP_ASSERT(p_instance_ctrl); + FSP_ASSERT(p_handle); + FSP_ASSERT(p_message || (0 == message_length)); + FSP_ERROR_RETURN(RSIP_OPEN == p_instance_ctrl->open, FSP_ERR_NOT_OPEN); +#endif + + /* Check state */ + FSP_ERROR_RETURN(r_rsip_state_check_init(p_instance_ctrl), FSP_ERR_INVALID_STATE); + FSP_ERROR_RETURN((RSIP_USER_HANDLE_STATE_UPDATE_EMPTY == p_handle->state) || + (RSIP_USER_HANDLE_STATE_UPDATE == p_handle->state), + FSP_ERR_INVALID_STATE); + FSP_ERROR_RETURN(is_generate == p_handle->is_generate, FSP_ERR_INVALID_STATE); + + if (0 == message_length) + { + err = FSP_SUCCESS; + } + else + { + rsip_ret_t rsip_ret = RSIP_RET_PASS; + const uint8_t * p_msg_pos = p_message; + uint32_t processed_len = 0; + + /* (1) Remaining message in buffer and head of new input message */ + if ((0 != p_handle->buffered_length) && + (p_handle->block_size < (p_handle->buffered_length + message_length))) + { + uint32_t len = p_handle->block_size - p_handle->buffered_length; + + /* Copy head of new message to buffer */ + memcpy(p_handle->buffer + p_handle->buffered_length, p_msg_pos, len); + + /* Call function */ + rsip_ret = r_rsip_hmac_calc_multi(p_handle, p_handle->buffer, p_handle->block_size, NULL, 0, false); + + p_handle->buffered_length = 0; + processed_len += len; + } + + /* (2) New input message except last block */ + if ((p_handle->block_size < message_length) && (RSIP_RET_PASS == rsip_ret)) + { + uint32_t len = ((message_length - processed_len - 1) / p_handle->block_size) * + p_handle->block_size; + + /* Call function */ + rsip_ret = r_rsip_hmac_calc_multi(p_handle, p_message + processed_len, len, NULL, 0, false); + + processed_len += len; + } + + /* Check error */ + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + /* (3) Last block */ + memcpy(p_handle->buffer + p_handle->buffered_length, + p_message + processed_len, + message_length - processed_len); + p_handle->buffered_length += message_length - processed_len; + + err = FSP_SUCCESS; + break; + } + + case RSIP_RET_RESOURCE_CONFLICT: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT; + break; + } + + case RSIP_RET_KEY_FAIL: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL; + break; + } + + /* RSIP_RET_FAIL is not used in this function */ + case RSIP_RET_FAIL: + default: + { + err = (fsp_err_t) FSP_ERR_CRYPTO_RSIP_FATAL; + } + } + } + + return err; +} diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/primitive/r_rsip_primitive.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/primitive/r_rsip_primitive.h new file mode 100644 index 000000000..d83752ced --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/primitive/r_rsip_primitive.h @@ -0,0 +1,479 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +#ifndef R_RSIP_PRIMITIVE_H +#define R_RSIP_PRIMITIVE_H + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include "r_rsip_err.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +#define RSIP_PRV_WORD_SIZE_S_RAM (16U) +#define RSIP_PRV_WORD_SIZE_S_INST (16U) +#define RSIP_PRV_WORD_SIZE_S_INST2 (16U) +#define RSIP_PRV_WORD_SIZE_S_HEAP (940U) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Exported global variables + **********************************************************************************************************************/ + +extern uint32_t S_RAM[RSIP_PRV_WORD_SIZE_S_RAM]; +extern uint32_t S_INST[RSIP_PRV_WORD_SIZE_S_INST]; +extern uint32_t S_INST2[RSIP_PRV_WORD_SIZE_S_INST2]; +extern uint32_t S_HEAP[RSIP_PRV_WORD_SIZE_S_HEAP]; + +extern uint32_t const S_FLASH[]; + +/********************************************************************************************************************** + * Public Function Prototypes + **********************************************************************************************************************/ + +/* Sub functions */ +void r_rsip_func010(void); +void r_rsip_func011(void); +void r_rsip_func012(void); +void r_rsip_func013(void); +void r_rsip_func016(uint32_t ARG1); +void r_rsip_func017(uint32_t ARG1); +void r_rsip_func022(void); +void r_rsip_func023(void); +void r_rsip_func040(void); +void r_rsip_func041(void); +void r_rsip_func043(void); +void r_rsip_func044(void); +void r_rsip_func045(void); +void r_rsip_func046(void); +void r_rsip_func047(void); +void r_rsip_func050(void); +void r_rsip_func051(void); +void r_rsip_func052(void); +void r_rsip_func053(void); +void r_rsip_func054(void); +void r_rsip_func055(void); +void r_rsip_func056(void); +void r_rsip_func057(void); +void r_rsip_func058(void); +void r_rsip_func059(void); +void r_rsip_func061(void); +void r_rsip_func062(void); +void r_rsip_func073(uint32_t ARG1); +void r_rsip_func084(uint32_t ARG1); +void r_rsip_func085(uint32_t ARG1); +void r_rsip_func086(uint32_t ARG1); +void r_rsip_func087(uint32_t ARG1); +void r_rsip_func088(void); +void r_rsip_func100(uint32_t ARG1, uint32_t ARG2, uint32_t ARG3, uint32_t ARG4); +void r_rsip_func101(uint32_t ARG1, uint32_t ARG2, uint32_t ARG3, uint32_t ARG4); +void r_rsip_func102(uint32_t ARG1, uint32_t ARG2, uint32_t ARG3, uint32_t ARG4); +void r_rsip_func103(void); +void r_rsip_func205(void); +void r_rsip_func206(void); +void r_rsip_func300(void); +void r_rsip_func301(void); +void r_rsip_func302(void); +void r_rsip_func303(void); +void r_rsip_func304(void); +void r_rsip_func305(void); +void r_rsip_func306(void); +void r_rsip_func307(void); +void r_rsip_func308(void); +void r_rsip_func309(void); +void r_rsip_func310(void); +void r_rsip_func311(void); +void r_rsip_func400(const uint32_t ARG1[]); + +/* Open */ +void r_rsip_p00(void); +rsip_ret_t r_rsip_p01(void); +rsip_ret_t r_rsip_p02(void); +rsip_ret_t r_rsip_p06(const uint32_t InData_Cmd[]); +rsip_ret_t r_rsip_p25(const uint32_t InData_Cmd[]); +rsip_ret_t r_rsip_p30(uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p40(const uint32_t InData_KeyIndex[]); + +/* Key generation */ +rsip_ret_t r_rsip_p07(uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p08(uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p16(uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p17(uint32_t OutData_KeyIndex[]); + +/* Key pair generation */ +rsip_ret_t r_rsip_pf4(uint32_t const InData_CurveType[], + uint32_t const InData_Cmd[], + uint32_t OutData_PubKeyIndex[], + uint32_t OutData_PrivKeyIndex[]); +rsip_ret_t r_rsip_p2a(uint32_t MAX_CNT, uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); +rsip_ret_t r_rsip_p2b(uint32_t MAX_CNT, uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); +rsip_ret_t r_rsip_p3a(uint32_t MAX_CNT, uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); +rsip_ret_t r_rsip_p3b(uint32_t MAX_CNT, uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); + +/* Key import with UFPK */ +rsip_ret_t r_rsip_p10(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p04(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p18(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p1a(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p59(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p60(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p62(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p63(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p37(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p42(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p43(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p45(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_pfa(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_CurveType[], + const uint32_t InData_Cmd[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_pf3(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_CurveType[], + const uint32_t InData_Cmd[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p80(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_Cmd[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p1f(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); + +/* Key import with KUK */ +rsip_ret_t r_rsip_p19(const uint32_t InData_IV[], const uint32_t InData_InstData[], uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p1c(const uint32_t InData_IV[], const uint32_t InData_InstData[], uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p1b(const uint32_t InData_IV[], const uint32_t InData_InstData[], uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p1d(const uint32_t InData_IV[], const uint32_t InData_InstData[], uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p2c(uint32_t const InData_CurveType[], + uint32_t const InData_Cmd[], + uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p1e(uint32_t const InData_CurveType[], + uint32_t const InData_Cmd[], + uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p0b(uint32_t const InData_IV[], uint32_t const InData_InstData[], uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p0c(uint32_t const InData_IV[], uint32_t const InData_InstData[], uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p0d(uint32_t const InData_IV[], uint32_t const InData_InstData[], uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p0e(uint32_t const InData_IV[], uint32_t const InData_InstData[], uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p38(uint32_t const InData_IV[], uint32_t const InData_InstData[], uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p9e(uint32_t const InData_IV[], uint32_t const InData_InstData[], uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p9d(uint32_t const InData_IV[], uint32_t const InData_InstData[], uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p9f(uint32_t const InData_IV[], uint32_t const InData_InstData[], uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p0f(const uint32_t InData_Cmd[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); + +/* RNG */ +rsip_ret_t r_rsip_p20(uint32_t p_random[]); + +/* AES-ECB/CBC/CTR */ +rsip_ret_t r_rsip_p48i(const uint32_t InData_Cmd[], const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_p50i(const uint32_t InData_Cmd[], const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +void r_rsip_p48u(const uint32_t InData_Text[], uint32_t OutData_Text[], uint32_t MAX_CNT); +void r_rsip_p50u(const uint32_t InData_Text[], uint32_t OutData_Text[], uint32_t MAX_CNT); +rsip_ret_t r_rsip_p48f(void); +rsip_ret_t r_rsip_p50f(void); + +/* AES-XTS */ +rsip_ret_t r_rsip_pb3i(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_pb6i(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_pb9i(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_pc2i(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +void r_rsip_pb3u(const uint32_t InData_Text[], uint32_t OutData_Text[], uint32_t MAX_CNT); +void r_rsip_pb6u(const uint32_t InData_Text[], uint32_t OutData_Text[], uint32_t MAX_CNT); +void r_rsip_pb9u(const uint32_t InData_Text[], uint32_t OutData_Text[], uint32_t MAX_CNT); +void r_rsip_pc2u(const uint32_t InData_Text[], uint32_t OutData_Text[], uint32_t MAX_CNT); +rsip_ret_t r_rsip_pb3f(const uint32_t InData_TextBitLen[], const uint32_t InData_Text[], uint32_t OutData_Text[]); +rsip_ret_t r_rsip_pb6f(const uint32_t InData_TextBitLen[], const uint32_t InData_Text[], uint32_t OutData_Text[]); +rsip_ret_t r_rsip_pb9f(const uint32_t InData_TextBitLen[], const uint32_t InData_Text[], uint32_t OutData_Text[]); +rsip_ret_t r_rsip_pc2f(const uint32_t InData_TextBitLen[], const uint32_t InData_Text[], uint32_t OutData_Text[]); + +/* AES-GCM */ +rsip_ret_t r_rsip_p29i(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_p32i(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_p34i(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_p36i(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +void r_rsip_p29t(void); +void r_rsip_p32t(void); +void r_rsip_p34t(void); +void r_rsip_p36t(void); +void r_rsip_p29a(const uint32_t InData_DataA[], uint32_t MAX_CNT); +void r_rsip_p32a(const uint32_t InData_DataA[], uint32_t MAX_CNT); +void r_rsip_p34a(const uint32_t InData_DataA[], uint32_t MAX_CNT); +void r_rsip_p36a(const uint32_t InData_DataA[], uint32_t MAX_CNT); +void r_rsip_p29u(const uint32_t InData_Text[], uint32_t OutData_Text[], uint32_t MAX_CNT); +void r_rsip_p32u(const uint32_t InData_Text[], uint32_t OutData_Text[], uint32_t MAX_CNT); +void r_rsip_p34u(const uint32_t InData_Text[], uint32_t OutData_Text[], uint32_t MAX_CNT); +void r_rsip_p36u(const uint32_t InData_Text[], uint32_t OutData_Text[], uint32_t MAX_CNT); +rsip_ret_t r_rsip_p29f(const uint32_t InData_Text[], + const uint32_t InData_DataALen[], + const uint32_t InData_TextLen[], + uint32_t OutData_Text[], + uint32_t OutData_DataT[]); +rsip_ret_t r_rsip_p34f(const uint32_t InData_Text[], + const uint32_t InData_DataALen[], + const uint32_t InData_TextLen[], + uint32_t OutData_Text[], + uint32_t OutData_DataT[]); +rsip_ret_t r_rsip_p32f(const uint32_t InData_Text[], + const uint32_t InData_DataT[], + const uint32_t InData_DataALen[], + const uint32_t InData_TextLen[], + const uint32_t InData_DataTLen[], + uint32_t OutData_Text[]); +rsip_ret_t r_rsip_p36f(const uint32_t InData_Text[], + const uint32_t InData_DataT[], + const uint32_t InData_DataALen[], + const uint32_t InData_TextLen[], + const uint32_t InData_DataTLen[], + uint32_t OutData_Text[]); +rsip_ret_t r_rsip_p21(const uint32_t InData_HV[], + const uint32_t InData_IV[], + const uint32_t InData_Text[], + uint32_t OutData_DataT[], + uint32_t MAX_CNT); + +/* AES-CMAC */ +rsip_ret_t r_rsip_p41i(const uint32_t InData_KeyIndex[]); +rsip_ret_t r_rsip_p44i(const uint32_t InData_KeyIndex[]); +void r_rsip_p41u(const uint32_t InData_Text[], uint32_t MAX_CNT); +void r_rsip_p44u(const uint32_t InData_Text[], uint32_t MAX_CNT); +rsip_ret_t r_rsip_p41f(const uint32_t InData_Cmd[], + const uint32_t InData_Text[], + const uint32_t InData_DataT[], + const uint32_t InData_DataTLen[], + uint32_t OutData_DataT[]); +rsip_ret_t r_rsip_p44f(const uint32_t InData_Cmd[], + const uint32_t InData_Text[], + const uint32_t InData_DataT[], + const uint32_t InData_DataTLen[], + uint32_t OutData_DataT[]); + +/* ECDSA */ +rsip_ret_t r_rsip_pf0(const uint32_t InData_CurveType[], + const uint32_t InData_Cmd[], + const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + uint32_t OutData_Signature[]); +rsip_ret_t r_rsip_pf1(const uint32_t InData_CurveType[], + const uint32_t InData_Cmd[], + const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + const uint32_t InData_Signature[]); + +/* RSA */ +rsip_ret_t r_rsip_p53(const uint32_t InData_KeyIndex[], const uint32_t InData_Text[], uint32_t OutData_Text[]); +rsip_ret_t r_rsip_p54(const uint32_t InData_KeyIndex[], const uint32_t InData_Text[], uint32_t OutData_Text[]); +rsip_ret_t r_rsip_p56(const uint32_t InData_KeyIndex[], const uint32_t InData_Text[], uint32_t OutData_Text[]); +rsip_ret_t r_rsip_p57(const uint32_t InData_KeyIndex[], const uint32_t InData_Text[], uint32_t OutData_Text[]); +rsip_ret_t r_rsip_p79(const uint32_t InData_KeyIndex[], const uint32_t InData_Text[], uint32_t OutData_Text[]); +rsip_ret_t r_rsip_p7a(const uint32_t InData_KeyIndex[], const uint32_t InData_Text[], uint32_t OutData_Text[]); +rsip_ret_t r_rsip_p7b(const uint32_t InData_KeyIndex[], const uint32_t InData_Text[], uint32_t OutData_Text[]); +rsip_ret_t r_rsip_p7c(const uint32_t InData_KeyIndex[], const uint32_t InData_Text[], uint32_t OutData_Text[]); + +/* SHA */ +rsip_ret_t r_rsip_p71(const uint32_t InData_HashType[], + const uint32_t InData_Msg[], + const uint32_t InData_MsgLen[], + uint32_t MAX_CNT, + uint32_t OutData_MsgDigest[]); +rsip_ret_t r_rsip_p72(const uint32_t InData_HashType[], + const uint32_t InData_Cmd[], + const uint32_t InData_Msg[], + const uint32_t InData_MsgLen[], + const uint32_t InData_State[], + uint32_t MAX_CNT, + uint32_t OutData_MsgDigest[], + uint32_t OutData_State[]); + +/* HMAC */ +rsip_ret_t r_rsip_p73(const uint32_t InData_KeyIndex[], + const uint32_t InData_Cmd[], + const uint32_t InData_Msg[], + const uint32_t InData_MsgLen[], + const uint32_t InData_MAC[], + const uint32_t InData_length[], + const uint32_t InData_State[], + uint32_t MAX_CNT, + uint32_t OutData_MAC[], + uint32_t OutData_State[]); +rsip_ret_t r_rsip_p76(const uint32_t InData_KeyIndex[], + const uint32_t InData_Cmd[], + const uint32_t InData_Msg[], + const uint32_t InData_MsgLen[], + const uint32_t InData_MAC[], + const uint32_t InData_length[], + const uint32_t InData_State[], + uint32_t MAX_CNT, + uint32_t OutData_MAC[], + uint32_t OutData_State[]); +rsip_ret_t r_rsip_pdc(const uint32_t InData_KeyIndex[], + const uint32_t InData_Cmd[], + const uint32_t InData_Msg[], + const uint32_t InData_MsgLen[], + const uint32_t InData_MAC[], + const uint32_t InData_length[], + const uint32_t InData_State[], + uint32_t MAX_CNT, + uint32_t OutData_MAC[], + uint32_t OutData_State[]); +rsip_ret_t r_rsip_p74(const uint32_t InData_KeyIndex[], + const uint32_t InData_Cmd[], + const uint32_t InData_Msg[], + const uint32_t InData_MsgLen[], + const uint32_t InData_MAC[], + const uint32_t InData_length[], + uint32_t MAX_CNT, + uint32_t OutData_MAC[]); +rsip_ret_t r_rsip_p77(const uint32_t InData_KeyIndex[], + const uint32_t InData_Cmd[], + const uint32_t InData_Msg[], + const uint32_t InData_MsgLen[], + const uint32_t InData_MAC[], + const uint32_t InData_length[], + uint32_t MAX_CNT, + uint32_t OutData_MAC[]); +rsip_ret_t r_rsip_pdd(const uint32_t InData_KeyIndex[], + const uint32_t InData_Cmd[], + const uint32_t InData_Msg[], + const uint32_t InData_MsgLen[], + const uint32_t InData_MAC[], + const uint32_t InData_length[], + uint32_t MAX_CNT, + uint32_t OutData_MAC[]); + +/* Secure boot */ +rsip_ret_t r_rsip_p03(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_p15(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_EncAuthData[], + const uint32_t InData_HashType[], + uint32_t OutData_Hash[]); +rsip_ret_t r_rsip_p24(const uint32_t InData_Cmd[], + const uint32_t InData_KeyCertificate[], + const uint32_t InData_KeyCertificateLength[], + const uint32_t InData_KeyCertificateSignature[], + const uint32_t InData_KeyCertificatePubKey[], + const uint32_t InData_ImgPkHash[], + const uint32_t InData_OemRootPkHash[], + const uint32_t InData_CodeCertificate[], + const uint32_t InData_CodeCertificateLength[], + const uint32_t InData_CodeCertificateSignature[], + const uint32_t InData_CodeCertificatePubKey[], + const uint32_t InData_ImageHash[], + const uint32_t InData_Image[], + uint32_t MAX_CNT); + +rsip_ret_t r_rsip_p47i(const uint32_t InData_Cmd[], const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +void r_rsip_p47u(const uint32_t InData_Text[], uint32_t OutData_Text[], const uint32_t MAX_CNT); +rsip_ret_t r_rsip_p47f(void); + +#endif /* R_RSIP_PRIMITIVE_H */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_addr.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_addr.h new file mode 100644 index 000000000..5db4f2cf7 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_addr.h @@ -0,0 +1,33 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +#ifndef R_RSIP_ADDR_H +#define R_RSIP_ADDR_H + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ +#define RSIP_PRV_ADDR_BASE ((uintptr_t)gp_sce) + +/********************************************************************************************************************** + * Exported global variables + **********************************************************************************************************************/ +extern volatile uint32_t * gp_sce; + +#endif /* R_RSIP_ADDR_H */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_cfg.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_cfg.h new file mode 100644 index 000000000..c3ff74a14 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_cfg.h @@ -0,0 +1,280 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +#ifndef R_RSIP_CFG_H_ +#define R_RSIP_CFG_H_ + +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_ECC_192_QX (24U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_ECC_192_QY (56U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_ECC_224_QX (20U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_ECC_224_QY (52U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_ECC_256_QX (16U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_ECC_256_QY (48U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_1024_N (16U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_1024_E (144U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_2048_N (16U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_2048_E (272U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_3072_N (16U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_3072_E (400U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_4096_N (16U) +#define RSIP_CFG_BYTE_POS_WRAPPED_PUBLIC_KEY_RSA_4096_E (528U) + +#ifndef RSIP_CFG_PARAM_CHECKING_ENABLE +#define RSIP_CFG_PARAM_CHECKING_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_GENERATE_AES_128_ENABLE +#define RSIP_CFG_KEY_GENERATE_AES_128_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_GENERATE_AES_256_ENABLE +#define RSIP_CFG_KEY_GENERATE_AES_256_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_GENERATE_AES_128_XTS_ENABLE +#define RSIP_CFG_KEY_GENERATE_AES_128_XTS_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_GENERATE_AES_256_XTS_ENABLE +#define RSIP_CFG_KEY_GENERATE_AES_256_XTS_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_PAIR_GENERATE_ECC_secp192r1_ENABLE +#define RSIP_CFG_KEY_PAIR_GENERATE_ECC_secp192r1_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_PAIR_GENERATE_ECC_secp224r1_ENABLE +#define RSIP_CFG_KEY_PAIR_GENERATE_ECC_secp224r1_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_PAIR_GENERATE_ECC_secp256r1_ENABLE +#define RSIP_CFG_KEY_PAIR_GENERATE_ECC_secp256r1_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_PAIR_GENERATE_ECC_BRAINPOOLP256R1_ENABLE +#define RSIP_CFG_KEY_PAIR_GENERATE_ECC_BRAINPOOLP256R1_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_PAIR_GENERATE_RSA_1024_ENABLE +#define RSIP_CFG_KEY_PAIR_GENERATE_RSA_1024_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_PAIR_GENERATE_RSA_2048_ENABLE +#define RSIP_CFG_KEY_PAIR_GENERATE_RSA_2048_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_PAIR_GENERATE_RSA_3072_ENABLE +#define RSIP_CFG_KEY_PAIR_GENERATE_RSA_3072_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_PAIR_GENERATE_RSA_4096_ENABLE +#define RSIP_CFG_KEY_PAIR_GENERATE_RSA_4096_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_AES_128_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_AES_128_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_AES_256_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_AES_256_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_AES_128_XTS_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_AES_128_XTS_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_AES_256_XTS_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_AES_256_XTS_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp192r1_PRIVATE_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp192r1_PRIVATE_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp192r1_PUBLIC_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp192r1_PUBLIC_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp224r1_PRIVATE_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp224r1_PRIVATE_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp224r1_PUBLIC_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp224r1_PUBLIC_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp256r1_PUBLIC_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp256r1_PUBLIC_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp256r1_PRIVATE_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_secp256r1_PRIVATE_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_BRAINPOOLP256R1_PUBLIC_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_BRAINPOOLP256R1_PUBLIC_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_BRAINPOOLP256R1_PRIVATE_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_ECC_BRAINPOOLP256R1_PRIVATE_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_1024_PUBLIC_ENHANCED_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_1024_PUBLIC_ENHANCED_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_1024_PRIVATE_ENHANCED_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_1024_PRIVATE_ENHANCED_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_2048_PUBLIC_ENHANCED_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_2048_PUBLIC_ENHANCED_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_2048_PRIVATE_ENHANCED_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_2048_PRIVATE_ENHANCED_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_3072_PUBLIC_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_3072_PUBLIC_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_3072_PRIVATE_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_3072_PRIVATE_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_4096_PUBLIC_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_4096_PUBLIC_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_4096_PRIVATE_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_RSA_4096_PRIVATE_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_HMAC_SHA_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_HMAC_SHA_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_KUK_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_KUK_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_UFPK_SECURE_BOOT_DECRYPTION_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_UFPK_SECURE_BOOT_DECRYPTION_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_AES_128_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_AES_128_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_AES_256_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_AES_256_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_AES_128_XTS_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_AES_128_XTS_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_AES_256_XTS_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_AES_256_XTS_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp192r1_PUBLIC_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp192r1_PUBLIC_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp192r1_PRIVATE_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp192r1_PRIVATE_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp224r1_PUBLIC_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp224r1_PUBLIC_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp224r1_PRIVATE_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp224r1_PRIVATE_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp256r1_PUBLIC_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp256r1_PUBLIC_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp256r1_PRIVATE_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp256r1_PRIVATE_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_BRAINPOOLP256R1_PUBLIC_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_BRAINPOOLP256R1_PUBLIC_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_BRAINPOOLP256R1_PRIVATE_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_BRAINPOOLP256R1_PRIVATE_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_1024_PUBLIC_ENHANCED_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_1024_PUBLIC_ENHANCED_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_1024_PRIVATE_ENHANCED_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_1024_PRIVATE_ENHANCED_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_2048_PUBLIC_ENHANCED_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_2048_PUBLIC_ENHANCED_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_2048_PRIVATE_ENHANCED_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_2048_PRIVATE_ENHANCED_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_3072_PUBLIC_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_3072_PUBLIC_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_3072_PRIVATE_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_3072_PRIVATE_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_4096_PUBLIC_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_4096_PUBLIC_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_4096_PRIVATE_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_4096_PRIVATE_ENABLE (1) +#endif +#ifndef RSIP_CFG_KEY_IMPORT_WITH_KUK_HMAC_SHA_ENABLE +#define RSIP_CFG_KEY_IMPORT_WITH_KUK_HMAC_SHA_ENABLE (1) +#endif +#ifndef RSIP_CFG_AES_128_ECB_CBC_CTR_ENABLE +#define RSIP_CFG_AES_128_ECB_CBC_CTR_ENABLE (1) +#endif +#ifndef RSIP_CFG_AES_256_ECB_CBC_CTR_ENABLE +#define RSIP_CFG_AES_256_ECB_CBC_CTR_ENABLE (1) +#endif +#ifndef RSIP_CFG_AES_128_XTS_ENCRYPT_ENABLE +#define RSIP_CFG_AES_128_XTS_ENCRYPT_ENABLE (1) +#endif +#ifndef RSIP_CFG_AES_128_XTS_DECRYPT_ENABLE +#define RSIP_CFG_AES_128_XTS_DECRYPT_ENABLE (1) +#endif +#ifndef RSIP_CFG_AES_256_XTS_ENCRYPT_ENABLE +#define RSIP_CFG_AES_256_XTS_ENCRYPT_ENABLE (1) +#endif +#ifndef RSIP_CFG_AES_256_XTS_DECRYPT_ENABLE +#define RSIP_CFG_AES_256_XTS_DECRYPT_ENABLE (1) +#endif +#ifndef RSIP_CFG_AES_128_GCM_ENCRYPT_ENABLE +#define RSIP_CFG_AES_128_GCM_ENCRYPT_ENABLE (1) +#endif +#ifndef RSIP_CFG_AES_128_GCM_DECRYPT_ENABLE +#define RSIP_CFG_AES_128_GCM_DECRYPT_ENABLE (1) +#endif +#ifndef RSIP_CFG_AES_256_GCM_ENCRYPT_ENABLE +#define RSIP_CFG_AES_256_GCM_ENCRYPT_ENABLE (1) +#endif +#ifndef RSIP_CFG_AES_256_GCM_DECRYPT_ENABLE +#define RSIP_CFG_AES_256_GCM_DECRYPT_ENABLE (1) +#endif +#ifndef RSIP_CFG_AES_128_CMAC_ENABLE +#define RSIP_CFG_AES_128_CMAC_ENABLE (1) +#endif +#ifndef RSIP_CFG_AES_256_CMAC_ENABLE +#define RSIP_CFG_AES_256_CMAC_ENABLE (1) +#endif +#ifndef RSIP_CFG_RSA_1024_ENCRYPT_ENHANCED_ENABLE +#define RSIP_CFG_RSA_1024_ENCRYPT_ENHANCED_ENABLE (1) +#endif +#ifndef RSIP_CFG_RSA_1024_DECRYPT_ENHANCED_ENABLE +#define RSIP_CFG_RSA_1024_DECRYPT_ENHANCED_ENABLE (1) +#endif +#ifndef RSIP_CFG_RSA_2048_ENCRYPT_ENHANCED_ENABLE +#define RSIP_CFG_RSA_2048_ENCRYPT_ENHANCED_ENABLE (1) +#endif +#ifndef RSIP_CFG_RSA_2048_DECRYPT_ENHANCED_ENABLE +#define RSIP_CFG_RSA_2048_DECRYPT_ENHANCED_ENABLE (1) +#endif +#ifndef RSIP_CFG_RSA_3072_ENCRYPT_ENABLE +#define RSIP_CFG_RSA_3072_ENCRYPT_ENABLE (1) +#endif +#ifndef RSIP_CFG_RSA_3072_DECRYPT_ENABLE +#define RSIP_CFG_RSA_3072_DECRYPT_ENABLE (1) +#endif +#ifndef RSIP_CFG_RSA_4096_ENCRYPT_ENABLE +#define RSIP_CFG_RSA_4096_ENCRYPT_ENABLE (1) +#endif +#ifndef RSIP_CFG_RSA_4096_DECRYPT_ENABLE +#define RSIP_CFG_RSA_4096_DECRYPT_ENABLE (1) +#endif +#ifndef RSIP_CFG_HMAC_SHA1_ENABLE +#define RSIP_CFG_HMAC_SHA1_ENABLE (1) +#endif +#ifndef RSIP_CFG_HMAC_SHA224_ENABLE +#define RSIP_CFG_HMAC_SHA224_ENABLE (1) +#endif +#ifndef RSIP_CFG_HMAC_SHA256_ENABLE +#define RSIP_CFG_HMAC_SHA256_ENABLE (1) +#endif + + +#endif /* R_RSIP_CFG_H_ */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_otp.c b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_otp.c new file mode 100644 index 000000000..0152f7845 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_otp.c @@ -0,0 +1,76 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "bsp_api.h" +#include "r_rsip_otp.h" +#include "r_rsip_primitive.h" +#include "r_rsip_util.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +#define RSIP_PRV_BYTE_SIZE_WRAPPED_HARDWARE_ROOT_KEY (RSIP_PRV_WORD_SIZE_WRAPPED_HARDWARE_ROOT_KEY << 2) +#define RSIP_PRV_BYTE_SIZE_WRAPPED_HARDWARE_ROOT_KEY_NUM (RSIP_PRV_WORD_SIZE_WRAPPED_HARDWARE_ROOT_KEY_NUM << 2) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +rsip_ret_t r_rsip_whrk_read (uint32_t wrapped_hardware_root_key_num[RSIP_PRV_WORD_SIZE_WRAPPED_HARDWARE_ROOT_KEY_NUM], + uint32_t wrapped_hardware_root_key[RSIP_PRV_WORD_SIZE_WRAPPED_HARDWARE_ROOT_KEY]) +{ + uint8_t err = 1U; + + uint32_t key_num = bswap_32big (wrapped_hardware_root_key_num[0]); + + if (key_num <= 15) + { + memcpy ((void*) &wrapped_hardware_root_key[0], + (void*) &S_FLASH[key_num * RSIP_PRV_WORD_SIZE_WRAPPED_HARDWARE_ROOT_KEY], + RSIP_PRV_BYTE_SIZE_WRAPPED_HARDWARE_ROOT_KEY); + err = 0; + } + + /* Check error */ + return (0U == err) ? RSIP_RET_PASS : RSIP_RET_FAIL; +} + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_otp.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_otp.h new file mode 100644 index 000000000..68b9891e2 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_otp.h @@ -0,0 +1,51 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +#ifndef R_RSIP_OTP_H +#define R_RSIP_OTP_H + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include "r_rsip_err.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +#define RSIP_PRV_WORD_SIZE_WRAPPED_HARDWARE_ROOT_KEY (8U) +#define RSIP_PRV_WORD_SIZE_WRAPPED_HARDWARE_ROOT_KEY_NUM (1U) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Exported global variables + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Public Function Prototypes + **********************************************************************************************************************/ + +rsip_ret_t r_rsip_whrk_read(uint32_t wrapped_hardware_root_key_num[RSIP_PRV_WORD_SIZE_WRAPPED_HARDWARE_ROOT_KEY_NUM], + uint32_t wrapped_hardware_root_key[RSIP_PRV_WORD_SIZE_WRAPPED_HARDWARE_ROOT_KEY]); + +#endif /* R_RSIP_OTP_H */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_private.c b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_private.c new file mode 100644 index 000000000..e9cf06b2b --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_private.c @@ -0,0 +1,973 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "r_rsip_private.h" +#include "r_rsip_primitive.h" +#include "r_rsip_wrapper.h" +#include "r_rsip_util.h" +#include "r_rsip_reg.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* For SHA, HMAC-SHA */ +#define RSIP_PRV_SHA_INIT_VAL1 (BSWAP_32BIG_C(0x80000000U)) +#define RSIP_PRV_SHA_INIT_VAL2 (BSWAP_32BIG_C(0x00000000U)) +#define RSIP_PRV_CMD_INIT_TO_FINAL (BSWAP_32BIG_C(0U)) +#define RSIP_PRV_CMD_INIT_TO_SUSPEND (BSWAP_32BIG_C(1U)) +#define RSIP_PRV_CMD_RESUME_TO_SUSPEND (BSWAP_32BIG_C(2U)) +#define RSIP_PRV_CMD_RESUME_TO_FINAL (BSWAP_32BIG_C(3U)) +#define RSIP_PRV_CMD_INIT_TO_COMP_FINAL (BSWAP_32BIG_C(4U)) +#define RSIP_PRV_CMD_RESUME_TO_COMP_FINAL (BSWAP_32BIG_C(5U)) +#define RSIP_PRV_CMD_OUTPUT (BSWAP_32BIG_C(0U)) +#define RSIP_PRV_CMD_COMPARE (BSWAP_32BIG_C(1U)) +#define RSIP_PRV_CMD_SHA_1 (BSWAP_32BIG_C(0U)) +#define RSIP_PRV_CMD_SHA_224 (BSWAP_32BIG_C(1U)) +#define RSIP_PRV_CMD_SHA_256 (BSWAP_32BIG_C(2U)) +#define RSIP_PRV_CMD_SHA_384 (BSWAP_32BIG_C(5U)) +#define RSIP_PRV_CMD_SHA_512 (BSWAP_32BIG_C(6U)) +#define RSIP_PRV_CMD_SHA_512_224 (BSWAP_32BIG_C(3U)) +#define RSIP_PRV_CMD_SHA_512_256 (BSWAP_32BIG_C(4U)) +#define RSIP_PRV_WORD_SIZE_HMAC_MAC_BUFFER (8U) + +/* Register value */ +#define RSIP_PRV_REG_142CH_OPEN (0x00009000U) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +static const uint32_t gs_cmd_hash_type[] = +{ + [RSIP_HASH_TYPE_SHA1] = RSIP_PRV_CMD_SHA_1, + [RSIP_HASH_TYPE_SHA224] = RSIP_PRV_CMD_SHA_224, + [RSIP_HASH_TYPE_SHA256] = RSIP_PRV_CMD_SHA_256, + [RSIP_HASH_TYPE_SHA384] = RSIP_PRV_CMD_SHA_384, + [RSIP_HASH_TYPE_SHA512] = RSIP_PRV_CMD_SHA_512, + [RSIP_HASH_TYPE_SHA512_224] = RSIP_PRV_CMD_SHA_512_224, + [RSIP_HASH_TYPE_SHA512_256] = RSIP_PRV_CMD_SHA_512_256, +}; + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +const rsip_key_type_bool_table_t g_key_generate_supported_algs = +{ + [RSIP_KEY_TYPE_AES_128] = true, + [RSIP_KEY_TYPE_AES_256] = true, + [RSIP_KEY_TYPE_AES_128_XTS] = true, + [RSIP_KEY_TYPE_AES_256_XTS] = true +}; + +const rsip_key_type_bool_table_t g_key_import_with_kuk_supported_algs = +{ + [RSIP_KEY_TYPE_AES_128] = true, + [RSIP_KEY_TYPE_AES_256] = true, + [RSIP_KEY_TYPE_AES_128_XTS] = true, + [RSIP_KEY_TYPE_AES_256_XTS] = true, + [RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC] = true, + [RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE] = true, + [RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC] = true, + [RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE] = true, + [RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC] = true, + [RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE] = true, + [RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC] = true, + [RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE] = true, + [RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED] = true, + [RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED] = true, + [RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED] = true, + [RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED] = true, + [RSIP_KEY_TYPE_RSA_3072_PUBLIC] = true, + [RSIP_KEY_TYPE_RSA_3072_PRIVATE] = true, + [RSIP_KEY_TYPE_RSA_4096_PUBLIC] = true, + [RSIP_KEY_TYPE_RSA_4096_PRIVATE] = true, + [RSIP_KEY_TYPE_HMAC_SHA1] = true, + [RSIP_KEY_TYPE_HMAC_SHA224] = true, + [RSIP_KEY_TYPE_HMAC_SHA256] = true +}; + +const rsip_key_pair_type_bool_table_t g_key_pair_generate_supported_algs = +{ + [RSIP_KEY_PAIR_TYPE_ECC_secp192r1] = true, + [RSIP_KEY_PAIR_TYPE_ECC_secp224r1] = true, + [RSIP_KEY_PAIR_TYPE_ECC_secp256r1] = true, + [RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1] = true, + [RSIP_KEY_PAIR_TYPE_RSA_1024] = true, + [RSIP_KEY_PAIR_TYPE_RSA_2048] = true, + [RSIP_KEY_PAIR_TYPE_RSA_3072] = true, + [RSIP_KEY_PAIR_TYPE_RSA_4096] = true, +}; + +const rsip_func_key_generate_t gp_func_key_generate[] = +{ +#if RSIP_CFG_KEY_GENERATE_AES_128_ENABLE + [RSIP_KEY_TYPE_AES_128] = r_rsip_p07, +#else + [RSIP_KEY_TYPE_AES_128] = NULL, +#endif +#if RSIP_CFG_KEY_GENERATE_AES_256_ENABLE + [RSIP_KEY_TYPE_AES_256] = r_rsip_p08, +#else + [RSIP_KEY_TYPE_AES_256] = NULL, +#endif +#if RSIP_CFG_KEY_GENERATE_AES_128_XTS_ENABLE + [RSIP_KEY_TYPE_AES_128_XTS] = r_rsip_p16, +#else + [RSIP_KEY_TYPE_AES_128_XTS] = NULL, +#endif +#if RSIP_CFG_KEY_GENERATE_AES_256_XTS_ENABLE + [RSIP_KEY_TYPE_AES_256_XTS] = r_rsip_p17, +#else + [RSIP_KEY_TYPE_AES_256_XTS] = NULL, +#endif +}; + +const rsip_func_key_pair_generate_t gp_func_key_pair_generate[] = +{ +#if RSIP_CFG_KEY_PAIR_GENERATE_ECC_secp192r1_ENABLE + [RSIP_KEY_PAIR_TYPE_ECC_secp192r1] = r_rsip_wrapper_pf4_secp192r1, +#else + [RSIP_KEY_PAIR_TYPE_ECC_secp192r1] = NULL, +#endif +#if RSIP_CFG_KEY_PAIR_GENERATE_ECC_secp224r1_ENABLE + [RSIP_KEY_PAIR_TYPE_ECC_secp224r1] = r_rsip_wrapper_pf4_secp224r1, +#else + [RSIP_KEY_PAIR_TYPE_ECC_secp224r1] = NULL, +#endif +#if RSIP_CFG_KEY_PAIR_GENERATE_ECC_secp256r1_ENABLE + [RSIP_KEY_PAIR_TYPE_ECC_secp256r1] = r_rsip_wrapper_pf4_secp256r1, +#else + [RSIP_KEY_PAIR_TYPE_ECC_secp256r1] = NULL, +#endif +#if RSIP_CFG_KEY_PAIR_GENERATE_ECC_BRAINPOOLP256R1_ENABLE + [RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1] = r_rsip_wrapper_pf4_brainpoolp256r1, +#else + [RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1] = NULL, +#endif +#if RSIP_CFG_KEY_PAIR_GENERATE_RSA_1024_ENABLE + [RSIP_KEY_PAIR_TYPE_RSA_1024] = r_rsip_wrapper_p2a, +#else + [RSIP_KEY_PAIR_TYPE_RSA_1024] = NULL, +#endif +#if RSIP_CFG_KEY_PAIR_GENERATE_RSA_2048_ENABLE + [RSIP_KEY_PAIR_TYPE_RSA_2048] = r_rsip_wrapper_p2b, +#else + [RSIP_KEY_PAIR_TYPE_RSA_2048] = NULL, +#endif +#if RSIP_CFG_KEY_PAIR_GENERATE_RSA_3072_ENABLE + [RSIP_KEY_PAIR_TYPE_RSA_3072] = r_rsip_wrapper_p3a, +#else + [RSIP_KEY_PAIR_TYPE_RSA_3072] = NULL, +#endif +#if RSIP_CFG_KEY_PAIR_GENERATE_RSA_4096_ENABLE + [RSIP_KEY_PAIR_TYPE_RSA_4096] = r_rsip_wrapper_p3b, +#else + [RSIP_KEY_PAIR_TYPE_RSA_4096] = NULL, +#endif +}; + +const rsip_func_key_import_with_kuk_t gp_func_key_import_with_kuk[] = +{ +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_AES_128_ENABLE + [RSIP_KEY_TYPE_AES_128] = r_rsip_p19, +#else + [RSIP_KEY_TYPE_AES_128] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_AES_256_ENABLE + [RSIP_KEY_TYPE_AES_256] = r_rsip_p1c, +#else + [RSIP_KEY_TYPE_AES_256] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_AES_128_XTS_ENABLE + [RSIP_KEY_TYPE_AES_128_XTS] = r_rsip_p1b, +#else + [RSIP_KEY_TYPE_AES_128_XTS] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_AES_256_XTS_ENABLE + [RSIP_KEY_TYPE_AES_256_XTS] = r_rsip_p1d, +#else + [RSIP_KEY_TYPE_AES_256_XTS] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp192r1_PUBLIC_ENABLE + [RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC] = r_rsip_wrapper_p2c_secp192r1, +#else + [RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp192r1_PRIVATE_ENABLE + [RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE] = r_rsip_wrapper_p1e_secp192r1, +#else + [RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp224r1_PUBLIC_ENABLE + [RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC] = r_rsip_wrapper_p2c_secp224r1, +#else + [RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp224r1_PRIVATE_ENABLE + [RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE] = r_rsip_wrapper_p1e_secp224r1, +#else + [RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp256r1_PUBLIC_ENABLE + [RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC] = r_rsip_wrapper_p2c_secp256r1, +#else + [RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_secp256r1_PRIVATE_ENABLE + [RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE] = r_rsip_wrapper_p1e_secp256r1, +#else + [RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_BRAINPOOLP256R1_PUBLIC_ENABLE + [RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC] = r_rsip_wrapper_p2c_brainpoolp256r1, +#else + [RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_ECC_BRAINPOOLP256R1_PRIVATE_ENABLE + [RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE] = r_rsip_wrapper_p1e_brainpoolp256r1, +#else + [RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_1024_PUBLIC_ENHANCED_ENABLE + [RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED] = r_rsip_p0b, +#else + [RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_1024_PRIVATE_ENHANCED_ENABLE + [RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED] = r_rsip_p0c, +#else + [RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_2048_PUBLIC_ENHANCED_ENABLE + [RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED] = r_rsip_p0d, +#else + [RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_2048_PRIVATE_ENHANCED_ENABLE + [RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED] = r_rsip_p0e, +#else + [RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_3072_PUBLIC_ENABLE + [RSIP_KEY_TYPE_RSA_3072_PUBLIC] = r_rsip_p38, +#else + [RSIP_KEY_TYPE_RSA_3072_PUBLIC] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_3072_PRIVATE_ENABLE + [RSIP_KEY_TYPE_RSA_3072_PRIVATE] = r_rsip_p9d, +#else + [RSIP_KEY_TYPE_RSA_3072_PRIVATE] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_4096_PUBLIC_ENABLE + [RSIP_KEY_TYPE_RSA_4096_PUBLIC] = r_rsip_p9e, +#else + [RSIP_KEY_TYPE_RSA_4096_PUBLIC] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_RSA_4096_PRIVATE_ENABLE + [RSIP_KEY_TYPE_RSA_4096_PRIVATE] = r_rsip_p9f, +#else + [RSIP_KEY_TYPE_RSA_4096_PRIVATE] = NULL, +#endif +#if RSIP_CFG_KEY_IMPORT_WITH_KUK_HMAC_SHA_ENABLE + [RSIP_KEY_TYPE_HMAC_SHA1] = r_rsip_wrapper_p0f_hmac_sha1, + [RSIP_KEY_TYPE_HMAC_SHA224] = r_rsip_wrapper_p0f_hmac_sha224, + [RSIP_KEY_TYPE_HMAC_SHA256] = r_rsip_wrapper_p0f_hmac_sha256, +#else + [RSIP_KEY_TYPE_HMAC_SHA1] = NULL, + [RSIP_KEY_TYPE_HMAC_SHA224] = NULL, + [RSIP_KEY_TYPE_HMAC_SHA256] = NULL, +#endif +}; + +const rsip_func_subset_aes_t gp_func_aes[] = +{ + [RSIP_PRV_AES_REBASE(RSIP_KEY_TYPE_AES_128)] = + { +#if RSIP_CFG_AES_128_ECB_CBC_CTR_ENABLE + .p_init = + { + [RSIP_AES_MODE_ECB] = + { + r_rsip_wrapper_p48i_ecb_enc, + r_rsip_wrapper_p48i_ecb_dec + }, + [RSIP_AES_MODE_CBC] = + { + r_rsip_wrapper_p48i_cbc_enc, + r_rsip_wrapper_p48i_cbc_dec + }, + [RSIP_AES_MODE_CTR] = + { + r_rsip_wrapper_p48i_ctr, + r_rsip_wrapper_p48i_ctr + } + }, + .p_update = r_rsip_p48u, + .p_final = r_rsip_p48f +#else + .p_init = + { + [RSIP_AES_MODE_ECB] = + { + NULL, + NULL + }, + [RSIP_AES_MODE_CBC] = + { + NULL, + NULL + }, + [RSIP_AES_MODE_CTR] = + { + NULL, + NULL + } + }, + .p_update = NULL, + .p_final = NULL +#endif + }, + [RSIP_PRV_AES_REBASE(RSIP_KEY_TYPE_AES_256)] = + { +#if RSIP_CFG_AES_256_ECB_CBC_CTR_ENABLE + .p_init = + { + [RSIP_AES_MODE_ECB] = + { + r_rsip_wrapper_p50i_ecb_enc, + r_rsip_wrapper_p50i_ecb_dec + }, + [RSIP_AES_MODE_CBC] = + { + r_rsip_wrapper_p50i_cbc_enc, + r_rsip_wrapper_p50i_cbc_dec + }, + [RSIP_AES_MODE_CTR] = + { + r_rsip_wrapper_p50i_ctr, + r_rsip_wrapper_p50i_ctr + } + }, + .p_update = r_rsip_p50u, + .p_final = r_rsip_p50f +#else + .p_init = + { + [RSIP_AES_MODE_ECB] = + { + NULL, + NULL + }, + [RSIP_AES_MODE_CBC] = + { + NULL, + NULL + }, + [RSIP_AES_MODE_CTR] = + { + NULL, + NULL + } + }, + .p_update = NULL, + .p_final = NULL +#endif + }, +}; + +const rsip_func_subset_xts_t gp_func_xts[][2] = +{ + [RSIP_PRV_XTS_REBASE(RSIP_KEY_TYPE_AES_128_XTS)][RSIP_PRV_XTS_HANDLE_REBASE(RSIP_HANDLE_TYPE_XTS_ENCRYPT)] = + { +#if RSIP_CFG_AES_128_XTS_ENCRYPT_ENABLE + .p_init = r_rsip_pb3i, + .p_update = r_rsip_pb3u, + .p_final = r_rsip_pb3f +#else + .p_init = NULL, + .p_update = NULL, + .p_final = NULL +#endif + }, + + [RSIP_PRV_XTS_REBASE(RSIP_KEY_TYPE_AES_128_XTS)][RSIP_PRV_XTS_HANDLE_REBASE(RSIP_HANDLE_TYPE_XTS_DECRYPT)] = + { +#if RSIP_CFG_AES_128_XTS_DECRYPT_ENABLE + .p_init = r_rsip_pb6i, + .p_update = r_rsip_pb6u, + .p_final = r_rsip_pb6f +#else + .p_init = NULL, + .p_update = NULL, + .p_final = NULL +#endif + }, + [RSIP_PRV_XTS_REBASE(RSIP_KEY_TYPE_AES_256_XTS)][RSIP_PRV_XTS_HANDLE_REBASE(RSIP_HANDLE_TYPE_XTS_ENCRYPT)] = + { +#if RSIP_CFG_AES_256_XTS_ENCRYPT_ENABLE + .p_init = r_rsip_pb9i, + .p_update = r_rsip_pb9u, + .p_final = r_rsip_pb9f +#else + .p_init = NULL, + .p_update = NULL, + .p_final = NULL +#endif + }, + [RSIP_PRV_XTS_REBASE(RSIP_KEY_TYPE_AES_256_XTS)][RSIP_PRV_XTS_HANDLE_REBASE(RSIP_HANDLE_TYPE_XTS_DECRYPT)] = + { +#if RSIP_CFG_AES_256_XTS_DECRYPT_ENABLE + .p_init = r_rsip_pc2i, + .p_update = r_rsip_pc2u, + .p_final = r_rsip_pc2f +#else + .p_init = NULL, + .p_update = NULL, + .p_final = NULL +#endif + }, +}; + +const rsip_func_subset_gcm_t gp_func_gcm[][2] = +{ + [RSIP_PRV_AES_REBASE(RSIP_KEY_TYPE_AES_128)][RSIP_PRV_GCM_HANDLE_REBASE(RSIP_HANDLE_TYPE_GCM_ENCRYPT)] = + { +#if RSIP_CFG_AES_128_GCM_ENCRYPT_ENABLE + .p_init = r_rsip_p29i, + .p_updateAad = r_rsip_p29a, + .p_updateTransition = r_rsip_p29t, + .p_update = r_rsip_p29u, + .p_encryptFinal = r_rsip_p29f, + .p_ecb = &gp_func_aes[RSIP_PRV_AES_REBASE(RSIP_KEY_TYPE_AES_128)] +#else + .p_init = NULL, + .p_updateAad = NULL, + .p_updateTransition = NULL, + .p_update = NULL, + .p_encryptFinal = NULL, + .p_ecb = NULL +#endif + }, + [RSIP_PRV_AES_REBASE(RSIP_KEY_TYPE_AES_128)][RSIP_PRV_GCM_HANDLE_REBASE(RSIP_HANDLE_TYPE_GCM_DECRYPT)] = + { +#if RSIP_CFG_AES_128_GCM_DECRYPT_ENABLE + .p_init = r_rsip_p32i, + .p_updateAad = r_rsip_p32a, + .p_updateTransition = r_rsip_p32t, + .p_update = r_rsip_p32u, + .p_decryptFinal = r_rsip_p32f, + .p_ecb = &gp_func_aes[RSIP_PRV_AES_REBASE(RSIP_KEY_TYPE_AES_128)] +#else + .p_init = NULL, + .p_updateAad = NULL, + .p_updateTransition = NULL, + .p_update = NULL, + .p_encryptFinal = NULL, + .p_ecb = NULL +#endif + }, + [RSIP_PRV_AES_REBASE(RSIP_KEY_TYPE_AES_256)][RSIP_PRV_GCM_HANDLE_REBASE(RSIP_HANDLE_TYPE_GCM_ENCRYPT)] = + { +#if RSIP_CFG_AES_256_GCM_ENCRYPT_ENABLE + .p_init = r_rsip_p34i, + .p_updateAad = r_rsip_p34a, + .p_updateTransition = r_rsip_p34t, + .p_update = r_rsip_p34u, + .p_encryptFinal = r_rsip_p34f, + .p_ecb = &gp_func_aes[RSIP_PRV_AES_REBASE(RSIP_KEY_TYPE_AES_256)] +#else + .p_init = NULL, + .p_updateAad = NULL, + .p_updateTransition = NULL, + .p_update = NULL, + .p_encryptFinal = NULL, + .p_ecb = NULL +#endif + }, + + [RSIP_PRV_AES_REBASE(RSIP_KEY_TYPE_AES_256)][RSIP_PRV_GCM_HANDLE_REBASE(RSIP_HANDLE_TYPE_GCM_DECRYPT)] = + { +#if RSIP_CFG_AES_256_GCM_DECRYPT_ENABLE + .p_init = r_rsip_p36i, + .p_updateAad = r_rsip_p36a, + .p_updateTransition = r_rsip_p36t, + .p_update = r_rsip_p36u, + .p_decryptFinal = r_rsip_p36f, + .p_ecb = &gp_func_aes[RSIP_PRV_AES_REBASE(RSIP_KEY_TYPE_AES_256)] +#else + .p_init = NULL, + .p_updateAad = NULL, + .p_updateTransition = NULL, + .p_update = NULL, + .p_encryptFinal = NULL, + .p_ecb = NULL +#endif + }, +}; + +const rsip_func_subset_cmac_t gp_func_cmac[] = +{ + [RSIP_PRV_AES_REBASE(RSIP_KEY_TYPE_AES_128)] = + { +#if RSIP_CFG_AES_128_CMAC_ENABLE + .p_init = r_rsip_p41i, + .p_update = r_rsip_p41u, + .p_generateFinal = r_rsip_wrapper_p41f_gen, + .p_verifyFinal = r_rsip_wrapper_p41f_veri +#else + .p_init = NULL, + .p_update = NULL, + .p_generateFinal = NULL, + .p_verifyFinal = NULL +#endif + }, + [RSIP_PRV_AES_REBASE(RSIP_KEY_TYPE_AES_256)] = + { +#if RSIP_CFG_AES_256_CMAC_ENABLE + .p_init = r_rsip_p44i, + .p_update = r_rsip_p44u, + .p_generateFinal = r_rsip_wrapper_p44f_gen, + .p_verifyFinal = r_rsip_wrapper_p44f_veri +#else + .p_init = NULL, + .p_update = NULL, + .p_generateFinal = NULL, + .p_verifyFinal = NULL +#endif + }, +}; + +const rsip_func_ecdsa_sign_t gp_func_ecdsa_sign[] = +{ + [RSIP_PRV_ECC_REBASE(RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE)] = r_rsip_wrapper_pf0_secp192r1, + [RSIP_PRV_ECC_REBASE(RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE)] = r_rsip_wrapper_pf0_secp224r1, + [RSIP_PRV_ECC_REBASE(RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE)] = r_rsip_wrapper_pf0_secp256r1, + [RSIP_PRV_ECC_REBASE(RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE)] = r_rsip_wrapper_pf0_brainpoolp256r1, +}; + +const rsip_func_ecdsa_verify_t gp_func_ecdsa_verify[] = +{ + [RSIP_PRV_ECC_REBASE(RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC)] = r_rsip_wrapper_pf1_secp192r1, + [RSIP_PRV_ECC_REBASE(RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC)] = r_rsip_wrapper_pf1_secp224r1, + [RSIP_PRV_ECC_REBASE(RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC)] = r_rsip_wrapper_pf1_secp256r1, + [RSIP_PRV_ECC_REBASE(RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC)] = r_rsip_wrapper_pf1_brainpoolp256r1, +}; + +const rsip_func_rsa_t gp_func_rsa_public[] = +{ +#if RSIP_CFG_RSA_1024_ENCRYPT_ENHANCED_ENABLE + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED)] = r_rsip_p53, +#else + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED)] = NULL, +#endif +#if RSIP_CFG_RSA_2048_ENCRYPT_ENHANCED_ENABLE + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED)] = r_rsip_p56, +#else + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED)] = NULL, +#endif +#if RSIP_CFG_RSA_3072_ENCRYPT_ENABLE + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_3072_PUBLIC)] = r_rsip_p79, +#else + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_3072_PUBLIC)] = NULL, +#endif +#if RSIP_CFG_RSA_4096_ENCRYPT_ENABLE + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_4096_PUBLIC)] = r_rsip_p7b, +#else + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_4096_PUBLIC)] = NULL, +#endif +}; + +const rsip_func_rsa_t gp_func_rsa_private[] = +{ +#if RSIP_CFG_RSA_1024_DECRYPT_ENHANCED_ENABLE + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED)] = r_rsip_p54, +#else + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED)] = NULL, +#endif +#if RSIP_CFG_RSA_2048_DECRYPT_ENHANCED_ENABLE + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED)] = r_rsip_p57, +#else + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED)] = NULL, +#endif +#if RSIP_CFG_RSA_3072_DECRYPT_ENABLE + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_3072_PRIVATE)] = r_rsip_p7a, +#else + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_3072_PRIVATE)] = NULL, +#endif +#if RSIP_CFG_RSA_4096_DECRYPT_ENABLE + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_4096_PRIVATE)] = r_rsip_p7c, +#else + [RSIP_PRV_RSA_REBASE(RSIP_KEY_TYPE_RSA_4096_PRIVATE)] = NULL, +#endif +}; + +const rsip_func_hmac_single_t gp_func_hmac_single[] = +{ +#if RSIP_CFG_HMAC_SHA1_ENABLE + [RSIP_PRV_HMAC_REBASE(RSIP_KEY_TYPE_HMAC_SHA1)] = r_rsip_p74, +#else + [RSIP_PRV_HMAC_REBASE(RSIP_KEY_TYPE_HMAC_SHA1)] = NULL, +#endif +#if RSIP_CFG_HMAC_SHA224_ENABLE + [RSIP_PRV_HMAC_REBASE(RSIP_KEY_TYPE_HMAC_SHA224)] = r_rsip_pdd, +#else + [RSIP_PRV_HMAC_REBASE(RSIP_KEY_TYPE_HMAC_SHA224)] = NULL, +#endif +#if RSIP_CFG_HMAC_SHA256_ENABLE + [RSIP_PRV_HMAC_REBASE(RSIP_KEY_TYPE_HMAC_SHA256)] = r_rsip_p77, +#else + [RSIP_PRV_HMAC_REBASE(RSIP_KEY_TYPE_HMAC_SHA256)] = NULL, +#endif +}; + +const rsip_func_hmac_multi_t gp_func_hmac_multi[] = +{ +#if RSIP_CFG_HMAC_SHA1_ENABLE + [RSIP_PRV_HMAC_REBASE(RSIP_KEY_TYPE_HMAC_SHA1)] = r_rsip_p73, +#else + [RSIP_PRV_HMAC_REBASE(RSIP_KEY_TYPE_HMAC_SHA1)] = NULL, +#endif +#if RSIP_CFG_HMAC_SHA224_ENABLE + [RSIP_PRV_HMAC_REBASE(RSIP_KEY_TYPE_HMAC_SHA224)] = r_rsip_pdc, +#else + [RSIP_PRV_HMAC_REBASE(RSIP_KEY_TYPE_HMAC_SHA224)] = NULL, +#endif +#if RSIP_CFG_HMAC_SHA256_ENABLE + [RSIP_PRV_HMAC_REBASE(RSIP_KEY_TYPE_HMAC_SHA256)] = r_rsip_p76, +#else + [RSIP_PRV_HMAC_REBASE(RSIP_KEY_TYPE_HMAC_SHA256)] = NULL, +#endif +}; + +const rsip_func_random_number_generate_t gp_func_random_number_generate = r_rsip_p20; +const rsip_func_ghash_t gp_func_ghash_compute = r_rsip_p21; + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +rsip_ret_t r_rsip_open (void) +{ + uint32_t value; + rsip_ret_t rsip_ret = RSIP_RET_FAIL; + + RD1_ADDR(REG_142CH, &value); + + if (0 == (value & RSIP_PRV_REG_142CH_OPEN)) + { + rsip_ret = RSIP_RET_PASS; + } + + return rsip_ret; +} + +rsip_ret_t r_rsip_close (void) +{ + return RSIP_RET_PASS; +} + +void r_rsip_kuk_store (const uint8_t * p_key_update_key_value) +{ + memcpy(S_INST2, p_key_update_key_value, sizeof(S_INST2)); +} + +rsip_ret_t r_rsip_sha1sha2_compute_single (const uint32_t InData_Msg[], + uint32_t OutData_MsgDigest[], + rsip_hash_type_t hash_type, + uint32_t message_length) +{ + uint32_t InData_HashType[1] = + { + gs_cmd_hash_type[hash_type] + }; + uint32_t InData_MsgLen[2] = + { + InData_MsgLen[0] = bswap_32big(r_rsip_byte_to_bit_convert_upper(message_length)), + InData_MsgLen[1] = bswap_32big(r_rsip_byte_to_bit_convert_lower(message_length)) + }; + + /** MAX_CNT: message length in word order */ + uint32_t MAX_CNT = r_rsip_byte_to_word_convert(message_length); + + /** Call primitive (cast to match the argument type with the primitive function) */ + return r_rsip_p71(InData_HashType, InData_Msg, InData_MsgLen, MAX_CNT, OutData_MsgDigest); +} + +rsip_ret_t r_rsip_hmac_compute_single (const uint32_t InData_Msg[], + uint32_t OutData_MAC[], + const rsip_func_hmac_single_t p_func, + const rsip_wrapped_key_t * p_wrapped_key, + uint32_t message_length) +{ + static const uint32_t InData_Cmd[1] = + { + RSIP_PRV_CMD_OUTPUT + }; + uint32_t InData_MsgLen[2] = + { + bswap_32big(r_rsip_byte_to_bit_convert_upper(message_length)), + bswap_32big(r_rsip_byte_to_bit_convert_lower(message_length)) + }; + + /** MAX_CNT: message length in word order */ + uint32_t MAX_CNT = r_rsip_byte_to_word_convert(message_length); + + /** Call primitive (cast to match the argument type with the primitive function) */ + return p_func((const uint32_t *) p_wrapped_key->value, + InData_Cmd, + InData_Msg, + InData_MsgLen, + NULL, + NULL, + MAX_CNT, + OutData_MAC); +} + +rsip_ret_t r_rsip_hmac_verify_single (const uint32_t InData_Msg[], + const uint8_t * p_mac, + const rsip_func_hmac_single_t p_func, + const rsip_wrapped_key_t * p_wrapped_key, + uint32_t message_length, + uint32_t mac_length) +{ + static const uint32_t InData_Cmd[1] = + { + RSIP_PRV_CMD_COMPARE + }; + uint32_t InData_MsgLen[2] = + { + bswap_32big(r_rsip_byte_to_bit_convert_upper(message_length)), + bswap_32big(r_rsip_byte_to_bit_convert_lower(message_length)) + }; + uint32_t InData_MAC[RSIP_PRV_WORD_SIZE_HMAC_MAC_BUFFER] = + { + 0 + }; + memcpy(InData_MAC, p_mac, mac_length); + uint32_t InData_length[1] = + { + bswap_32big(mac_length) + }; + + /** MAX_CNT: message length in word order */ + uint32_t MAX_CNT = r_rsip_byte_to_word_convert(message_length); + + /** Call primitive (cast to match the argument type with the primitive function) */ + return p_func((const uint32_t *) p_wrapped_key->value, + InData_Cmd, + InData_Msg, + InData_MsgLen, + InData_MAC, + InData_length, + MAX_CNT, + NULL); +} + +rsip_ret_t r_rsip_sha1sha2_calc_multi (rsip_sha_handle_t * p_handle, + const uint8_t * p_message, + uint32_t message_length, + uint8_t * p_digest) +{ + uint32_t hash_type[1] = + { + gs_cmd_hash_type[p_handle->type] + }; + uint32_t cmd[1] = + { + 0 + }; + + /* max_cnt: message length in word order */ + uint32_t max_cnt = r_rsip_byte_to_word_convert(message_length); + + /* Set command and overwrite internal state */ + bool is_init = (RSIP_USER_HANDLE_STATE_UPDATE_EMPTY == p_handle->state); + bool is_final = (NULL != p_digest); + + if (!is_final) + { + /* Update */ + if (is_init) + { + cmd[0] = RSIP_PRV_CMD_INIT_TO_SUSPEND; + p_handle->internal_state[18] = RSIP_PRV_SHA_INIT_VAL1; + p_handle->internal_state[19] = RSIP_PRV_SHA_INIT_VAL2; + } + else + { + cmd[0] = RSIP_PRV_CMD_RESUME_TO_SUSPEND; + } + } + else + { + /* Final */ + cmd[0] = is_init ? RSIP_PRV_CMD_INIT_TO_FINAL : RSIP_PRV_CMD_RESUME_TO_FINAL; + uint64_t len = message_length; + p_handle->internal_state[16] = bswap_32big(r_rsip_byte_to_bit_convert_lower(len + p_handle->total_length)); + p_handle->internal_state[17] = bswap_32big(r_rsip_byte_to_bit_convert_upper(len + p_handle->total_length)); + p_handle->internal_state[18] = bswap_32big(r_rsip_byte_to_bit_convert_upper(len)); + p_handle->internal_state[19] = bswap_32big(r_rsip_byte_to_bit_convert_lower(len)); + } + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = r_rsip_p72(hash_type, + cmd, + (const uint32_t *) p_message, + &p_handle->internal_state[18], + p_handle->internal_state, + max_cnt, + (uint32_t *) p_digest, + p_handle->internal_state); + + /* Check error */ + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + p_handle->state = is_final ? RSIP_USER_HANDLE_STATE_INIT : RSIP_USER_HANDLE_STATE_UPDATE; + p_handle->total_length += message_length; + break; + } + + default: + { + /* Do nothing */ + } + } + + return rsip_ret; +} + +rsip_ret_t r_rsip_hmac_calc_multi (rsip_hmac_handle_t * p_handle, + const uint8_t * p_message, + uint32_t message_length, + uint8_t * p_mac, + uint32_t mac_length, + bool is_final) +{ + uint32_t cmd[1] = + { + 0 + }; + uint32_t InData_MAC[RSIP_PRV_WORD_SIZE_HMAC_MAC_BUFFER] = + { + 0 + }; + + uint32_t input_mac_length[1] = + { + 0 + }; + + /* max_cnt: message length in word order */ + uint32_t max_cnt = r_rsip_byte_to_word_convert(message_length); + + /* Set command and overwrite internal state */ + bool is_init = (RSIP_USER_HANDLE_STATE_UPDATE_EMPTY == p_handle->state); + bool is_generate = p_handle->is_generate; + + if (!is_final) + { + /* GenerateUpdate, VerifyUpdate */ + if (is_init) + { + cmd[0] = RSIP_PRV_CMD_INIT_TO_SUSPEND; + p_handle->internal_state[18] = RSIP_PRV_SHA_INIT_VAL1; + p_handle->internal_state[19] = RSIP_PRV_SHA_INIT_VAL2; + } + else + { + cmd[0] = RSIP_PRV_CMD_RESUME_TO_SUSPEND; + } + } + else + { + if (is_generate) + { + /* GenerateFinal */ + cmd[0] = is_init ? RSIP_PRV_CMD_INIT_TO_FINAL : RSIP_PRV_CMD_RESUME_TO_FINAL; + } + else + { + /* VerifyFinal */ + cmd[0] = is_init ? RSIP_PRV_CMD_INIT_TO_COMP_FINAL : RSIP_PRV_CMD_RESUME_TO_COMP_FINAL; + + /* Set MAC */ + memcpy(InData_MAC, p_mac, mac_length); + input_mac_length[0] = bswap_32big(mac_length); + } + + uint64_t len = message_length; + p_handle->internal_state[16] = bswap_32big(r_rsip_byte_to_bit_convert_lower(len + p_handle->total_length)); + p_handle->internal_state[17] = bswap_32big(r_rsip_byte_to_bit_convert_upper(len + p_handle->total_length)); + p_handle->internal_state[18] = bswap_32big(r_rsip_byte_to_bit_convert_upper(len)); + p_handle->internal_state[19] = bswap_32big(r_rsip_byte_to_bit_convert_lower(len)); + } + + /* Set pointer to primitive functions */ + rsip_func_hmac_multi_t p_primitive = (rsip_func_hmac_multi_t) p_handle->p_primitive; + + /* Call primitive (cast to match the argument type with the primitive function) */ + rsip_ret_t rsip_ret = + p_primitive((uint32_t *) (((rsip_wrapped_key_t *) p_handle->wrapped_key)->value), + cmd, + (uint32_t *) p_message, + &p_handle->internal_state[18], + InData_MAC, + input_mac_length, + p_handle->internal_state, + max_cnt, + (uint32_t *) p_mac, + p_handle->internal_state); + + /* Check error */ + switch (rsip_ret) + { + case RSIP_RET_PASS: + { + p_handle->state = is_final ? RSIP_USER_HANDLE_STATE_INIT : RSIP_USER_HANDLE_STATE_UPDATE; + p_handle->total_length += message_length; + break; + } + + default: + { + /* Do nothing */ + } + } + + return rsip_ret; +} + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_wrapper.c b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_wrapper.c new file mode 100644 index 000000000..99e67ce06 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_wrapper.c @@ -0,0 +1,716 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include "r_rsip_wrapper.h" +#include "r_rsip_primitive.h" +#include "r_rsip_util.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* For AES-ECB/CBC/CTR */ +#define RSIP_PRV_CMD_AES_CIPHER_ECB_ENCRYPT (BSWAP_32BIG_C(0U)) +#define RSIP_PRV_CMD_AES_CIPHER_ECB_DECRYPT (BSWAP_32BIG_C(1U)) +#define RSIP_PRV_CMD_AES_CIPHER_CBC_ENCRYPT (BSWAP_32BIG_C(2U)) +#define RSIP_PRV_CMD_AES_CIPHER_CBC_DECRYPT (BSWAP_32BIG_C(3U)) +#define RSIP_PRV_CMD_AES_CIPHER_CTR_CRYPT (BSWAP_32BIG_C(4U)) + +/* For AES-CMAC */ +#define RSIP_PRV_CMD_AES_CMAC_GENERATE_WITHOUT_REMAINDER (BSWAP_32BIG_C(0U)) +#define RSIP_PRV_CMD_AES_CMAC_GENERATE_WITH_REMAINDER (BSWAP_32BIG_C(1U)) +#define RSIP_PRV_CMD_AES_CMAC_VERIFY_WITHOUT_REMAINDER (BSWAP_32BIG_C(2U)) +#define RSIP_PRV_CMD_AES_CMAC_VERIFY_WITH_REMAINDER (BSWAP_32BIG_C(3U)) + +/* For RSA */ +/* Maximum retry count of RSA key generation derived from FIPS186-4 B.3.3. 4.7 and 5.5 */ +#define RSIP_PRV_MAX_RETRY_COUNT_KEY_GEN_RSA_1024 (2 * (5 * 1024 / 2)) +#define RSIP_PRV_MAX_RETRY_COUNT_KEY_GEN_RSA_2048 (2 * (5 * 2048 / 2)) +#define RSIP_PRV_MAX_RETRY_COUNT_KEY_GEN_RSA_3072 (2 * (5 * 3072 / 2)) +#define RSIP_PRV_MAX_RETRY_COUNT_KEY_GEN_RSA_4096 (15 * 4096) + +/* For ECC */ +#define RSIP_PRV_CMD_ECC_TYPE_NIST (BSWAP_32BIG_C(0U)) +#define RSIP_PRV_CMD_ECC_TYPE_BRAINPOOL (BSWAP_32BIG_C(1U)) +#define RSIP_PRV_CMD_ECC_KEY_LENGTH_192 (BSWAP_32BIG_C(2U)) +#define RSIP_PRV_CMD_ECC_KEY_LENGTH_224 (BSWAP_32BIG_C(1U)) +#define RSIP_PRV_CMD_ECC_KEY_LENGTH_256 (BSWAP_32BIG_C(0U)) + +/* For HMAC */ +#define RSIP_PRV_CMD_HMAC_HASH_TYPE_SHA1 (BSWAP_32BIG_C(0U)) +#define RSIP_PRV_CMD_HMAC_HASH_TYPE_SHA224 (BSWAP_32BIG_C(1U)) +#define RSIP_PRV_CMD_HMAC_HASH_TYPE_SHA256 (BSWAP_32BIG_C(2U)) + +/* For password hash generation */ +#define RSIP_PRV_CMD_PASSWORD_TYPE_JTAG_DEBUG_AUTH_LEVEL1 (BSWAP_32BIG_C(0U)) +#define RSIP_PRV_CMD_PASSWORD_TYPE_JTAG_DEBUG_AUTH_LEVEL2 (BSWAP_32BIG_C(1U)) + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +typedef enum e_rsip_aes_mode_extended +{ + RSIP_AES_MODE_EXTENDED_ECB_ENCRYPT, + RSIP_AES_MODE_EXTENDED_ECB_DECRYPT, + RSIP_AES_MODE_EXTENDED_CBC_ENCRYPT, + RSIP_AES_MODE_EXTENDED_CBC_DECRYPT, + RSIP_AES_MODE_EXTENDED_CTR_CRYPT +} rsip_aes_mode_extended_t; + +typedef enum e_rsip_ecc_type +{ + RSIP_ECC_TYPE_NIST, + RSIP_ECC_TYPE_BRAINPOOL +} rsip_ecc_type_t; + +typedef enum e_rsip_ecc_key_length +{ + RSIP_ECC_KEY_LENGTH_192, + RSIP_ECC_KEY_LENGTH_224, + RSIP_ECC_KEY_LENGTH_256 +} rsip_ecc_key_length_t; + +typedef enum e_hmac_hash_type +{ + HMAC_HASH_TYPE_SHA1, + HMAC_HASH_TYPE_SHA224, + HMAC_HASH_TYPE_SHA256 +} hmac_hash_type_t; + +/*********************************************************************************************************************** + * Private function prototypes + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +static const uint32_t gs_cmd_aes_mode[] = +{ + [RSIP_AES_MODE_EXTENDED_ECB_ENCRYPT] = RSIP_PRV_CMD_AES_CIPHER_ECB_ENCRYPT, + [RSIP_AES_MODE_EXTENDED_ECB_DECRYPT] = RSIP_PRV_CMD_AES_CIPHER_ECB_DECRYPT, + [RSIP_AES_MODE_EXTENDED_CBC_ENCRYPT] = RSIP_PRV_CMD_AES_CIPHER_CBC_ENCRYPT, + [RSIP_AES_MODE_EXTENDED_CBC_DECRYPT] = RSIP_PRV_CMD_AES_CIPHER_CBC_DECRYPT, + [RSIP_AES_MODE_EXTENDED_CTR_CRYPT] = RSIP_PRV_CMD_AES_CIPHER_CTR_CRYPT +}; + +static const uint32_t gs_cmd_ecc_type[] = +{ + [RSIP_ECC_TYPE_NIST] = RSIP_PRV_CMD_ECC_TYPE_NIST, + [RSIP_ECC_TYPE_BRAINPOOL] = RSIP_PRV_CMD_ECC_TYPE_BRAINPOOL +}; + +static const uint32_t gs_cmd_ecc_key_length[] = +{ + [RSIP_ECC_KEY_LENGTH_192] = RSIP_PRV_CMD_ECC_KEY_LENGTH_192, + [RSIP_ECC_KEY_LENGTH_224] = RSIP_PRV_CMD_ECC_KEY_LENGTH_224, + [RSIP_ECC_KEY_LENGTH_256] = RSIP_PRV_CMD_ECC_KEY_LENGTH_256 +}; + +static const uint32_t gs_cmd_hmac_hash_type[] = +{ + [HMAC_HASH_TYPE_SHA1] = RSIP_PRV_CMD_HMAC_HASH_TYPE_SHA1, + [HMAC_HASH_TYPE_SHA224] = RSIP_PRV_CMD_HMAC_HASH_TYPE_SHA224, + [HMAC_HASH_TYPE_SHA256] = RSIP_PRV_CMD_HMAC_HASH_TYPE_SHA256 +}; + +/*********************************************************************************************************************** + * Global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +rsip_ret_t r_rsip_wrapper_pf4_secp192r1 (uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]) +{ + return r_rsip_pf4(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_192], + OutData_PubKeyIndex, + OutData_PrivKeyIndex); +} + +rsip_ret_t r_rsip_wrapper_pf4_secp224r1 (uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]) +{ + return r_rsip_pf4(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_224], + OutData_PubKeyIndex, + OutData_PrivKeyIndex); +} + +rsip_ret_t r_rsip_wrapper_pf4_secp256r1 (uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]) +{ + return r_rsip_pf4(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + OutData_PubKeyIndex, + OutData_PrivKeyIndex); +} + +rsip_ret_t r_rsip_wrapper_pf4_brainpoolp256r1 (uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]) +{ + return r_rsip_pf4(&gs_cmd_ecc_type[RSIP_ECC_TYPE_BRAINPOOL], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + OutData_PubKeyIndex, + OutData_PrivKeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p2a (uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]) +{ + return r_rsip_p2a(RSIP_PRV_MAX_RETRY_COUNT_KEY_GEN_RSA_1024, OutData_PubKeyIndex, OutData_PrivKeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p2b (uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]) +{ + return r_rsip_p2b(RSIP_PRV_MAX_RETRY_COUNT_KEY_GEN_RSA_2048, OutData_PubKeyIndex, OutData_PrivKeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p3a (uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]) +{ + return r_rsip_p3a(RSIP_PRV_MAX_RETRY_COUNT_KEY_GEN_RSA_3072, OutData_PubKeyIndex, OutData_PrivKeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p3b (uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]) +{ + return r_rsip_p3b(RSIP_PRV_MAX_RETRY_COUNT_KEY_GEN_RSA_4096, OutData_PubKeyIndex, OutData_PrivKeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p2c_secp192r1 (uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p2c(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_192], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p1e_secp192r1 (uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p1e(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_192], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p2c_secp224r1 (uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p2c(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_224], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p1e_secp224r1 (uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p1e(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_224], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p2c_secp256r1 (uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p2c(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p1e_secp256r1 (uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p1e(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p2c_brainpoolp256r1 (uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p2c(&gs_cmd_ecc_type[RSIP_ECC_TYPE_BRAINPOOL], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p1e_brainpoolp256r1 (uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p1e(&gs_cmd_ecc_type[RSIP_ECC_TYPE_BRAINPOOL], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p0f_hmac_sha1 (const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p0f(&gs_cmd_hmac_hash_type[HMAC_HASH_TYPE_SHA1], InData_IV, InData_InstData, OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p0f_hmac_sha224 (const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p0f(&gs_cmd_hmac_hash_type[HMAC_HASH_TYPE_SHA224], InData_IV, InData_InstData, OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p0f_hmac_sha256 (const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p0f(&gs_cmd_hmac_hash_type[HMAC_HASH_TYPE_SHA256], InData_IV, InData_InstData, OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p48i_ecb_enc (const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]) +{ + return r_rsip_p48i(&gs_cmd_aes_mode[RSIP_AES_MODE_EXTENDED_ECB_ENCRYPT], InData_KeyIndex, InData_IV); +} + +rsip_ret_t r_rsip_wrapper_p48i_ecb_dec (const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]) +{ + return r_rsip_p48i(&gs_cmd_aes_mode[RSIP_AES_MODE_EXTENDED_ECB_DECRYPT], InData_KeyIndex, InData_IV); +} + +rsip_ret_t r_rsip_wrapper_p48i_cbc_enc (const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]) +{ + return r_rsip_p48i(&gs_cmd_aes_mode[RSIP_AES_MODE_EXTENDED_CBC_ENCRYPT], InData_KeyIndex, InData_IV); +} + +rsip_ret_t r_rsip_wrapper_p48i_cbc_dec (const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]) +{ + return r_rsip_p48i(&gs_cmd_aes_mode[RSIP_AES_MODE_EXTENDED_CBC_DECRYPT], InData_KeyIndex, InData_IV); +} + +rsip_ret_t r_rsip_wrapper_p48i_ctr (const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]) +{ + return r_rsip_p48i(&gs_cmd_aes_mode[RSIP_AES_MODE_EXTENDED_CTR_CRYPT], InData_KeyIndex, InData_IV); +} + +rsip_ret_t r_rsip_wrapper_p50i_ecb_enc (const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]) +{ + return r_rsip_p50i(&gs_cmd_aes_mode[RSIP_AES_MODE_EXTENDED_ECB_ENCRYPT], InData_KeyIndex, InData_IV); +} + +rsip_ret_t r_rsip_wrapper_p50i_ecb_dec (const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]) +{ + return r_rsip_p50i(&gs_cmd_aes_mode[RSIP_AES_MODE_EXTENDED_ECB_DECRYPT], InData_KeyIndex, InData_IV); +} + +rsip_ret_t r_rsip_wrapper_p50i_cbc_enc (const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]) +{ + return r_rsip_p50i(&gs_cmd_aes_mode[RSIP_AES_MODE_EXTENDED_CBC_ENCRYPT], InData_KeyIndex, InData_IV); +} + +rsip_ret_t r_rsip_wrapper_p50i_cbc_dec (const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]) +{ + return r_rsip_p50i(&gs_cmd_aes_mode[RSIP_AES_MODE_EXTENDED_CBC_DECRYPT], InData_KeyIndex, InData_IV); +} + +rsip_ret_t r_rsip_wrapper_p50i_ctr (const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]) +{ + return r_rsip_p50i(&gs_cmd_aes_mode[RSIP_AES_MODE_EXTENDED_CTR_CRYPT], InData_KeyIndex, InData_IV); +} + +rsip_ret_t r_rsip_wrapper_p41f_gen (const uint32_t InData_Text[], uint32_t OutData_DataT[], const uint32_t all_msg_len) +{ + uint32_t cmd[1] = + { + ((0 == (all_msg_len % 16)) && + (0 != + all_msg_len)) ? RSIP_PRV_CMD_AES_CMAC_GENERATE_WITHOUT_REMAINDER : + RSIP_PRV_CMD_AES_CMAC_GENERATE_WITH_REMAINDER + }; + + return r_rsip_p41f(cmd, InData_Text, NULL, NULL, OutData_DataT); +} + +rsip_ret_t r_rsip_wrapper_p44f_gen (const uint32_t InData_Text[], uint32_t OutData_DataT[], const uint32_t all_msg_len) +{ + uint32_t cmd[1] = + { + ((0 == (all_msg_len % 16)) && + (0 != + all_msg_len)) ? RSIP_PRV_CMD_AES_CMAC_GENERATE_WITHOUT_REMAINDER : + RSIP_PRV_CMD_AES_CMAC_GENERATE_WITH_REMAINDER + }; + + return r_rsip_p44f(cmd, InData_Text, NULL, NULL, OutData_DataT); +} + +rsip_ret_t r_rsip_wrapper_p41f_veri (const uint32_t InData_Text[], + const uint32_t InData_DataT[], + const uint32_t InData_DataTLen[], + const uint32_t all_msg_len) +{ + uint32_t cmd[1] = + { + ((0 == (all_msg_len % 16)) && + (0 != + all_msg_len)) ? RSIP_PRV_CMD_AES_CMAC_VERIFY_WITHOUT_REMAINDER : + RSIP_PRV_CMD_AES_CMAC_VERIFY_WITH_REMAINDER + }; + + return r_rsip_p41f(cmd, InData_Text, InData_DataT, InData_DataTLen, NULL); +} + +rsip_ret_t r_rsip_wrapper_p44f_veri (const uint32_t InData_Text[], + const uint32_t InData_DataT[], + const uint32_t InData_DataTLen[], + const uint32_t all_msg_len) +{ + uint32_t cmd[1] = + { + ((0 == (all_msg_len % 16)) && + (0 != + all_msg_len)) ? RSIP_PRV_CMD_AES_CMAC_VERIFY_WITHOUT_REMAINDER : + RSIP_PRV_CMD_AES_CMAC_VERIFY_WITH_REMAINDER + }; + + return r_rsip_p44f(cmd, InData_Text, InData_DataT, InData_DataTLen, NULL); +} + +rsip_ret_t r_rsip_wrapper_pf0_secp192r1 (const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + uint32_t OutData_Signature[]) +{ + return r_rsip_pf0(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_192], + InData_KeyIndex, + InData_MsgDgst, + OutData_Signature); +} + +rsip_ret_t r_rsip_wrapper_pf1_secp192r1 (const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + const uint32_t InData_Signature[]) +{ + return r_rsip_pf1(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_192], + InData_KeyIndex, + InData_MsgDgst, + InData_Signature); +} + +rsip_ret_t r_rsip_wrapper_pf0_secp224r1 (const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + uint32_t OutData_Signature[]) +{ + return r_rsip_pf0(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_224], + InData_KeyIndex, + InData_MsgDgst, + OutData_Signature); +} + +rsip_ret_t r_rsip_wrapper_pf1_secp224r1 (const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + const uint32_t InData_Signature[]) +{ + return r_rsip_pf1(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_224], + InData_KeyIndex, + InData_MsgDgst, + InData_Signature); +} + +rsip_ret_t r_rsip_wrapper_pf0_secp256r1 (const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + uint32_t OutData_Signature[]) +{ + return r_rsip_pf0(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + InData_KeyIndex, + InData_MsgDgst, + OutData_Signature); +} + +rsip_ret_t r_rsip_wrapper_pf1_secp256r1 (const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + const uint32_t InData_Signature[]) +{ + return r_rsip_pf1(&gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + InData_KeyIndex, + InData_MsgDgst, + InData_Signature); +} + +rsip_ret_t r_rsip_wrapper_pf0_brainpoolp256r1 (const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + uint32_t OutData_Signature[]) +{ + return r_rsip_pf0(&gs_cmd_ecc_type[RSIP_ECC_TYPE_BRAINPOOL], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + InData_KeyIndex, + InData_MsgDgst, + OutData_Signature); +} + +rsip_ret_t r_rsip_wrapper_pf1_brainpoolp256r1 (const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + const uint32_t InData_Signature[]) +{ + return r_rsip_pf1(&gs_cmd_ecc_type[RSIP_ECC_TYPE_BRAINPOOL], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + InData_KeyIndex, + InData_MsgDgst, + InData_Signature); +} + +rsip_ret_t r_rsip_wrapper_pfa_secp192r1 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_pfa(InData_SharedKeyNum, + InData_SharedKeyIndex, + InData_SessionKey, + &gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_192], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_pf3_secp192r1 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_pf3(InData_SharedKeyNum, + InData_SharedKeyIndex, + InData_SessionKey, + &gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_192], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_pfa_secp224r1 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_pfa(InData_SharedKeyNum, + InData_SharedKeyIndex, + InData_SessionKey, + &gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_224], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_pf3_secp224r1 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_pf3(InData_SharedKeyNum, + InData_SharedKeyIndex, + InData_SessionKey, + &gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_224], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_pfa_secp256r1 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_pfa(InData_SharedKeyNum, + InData_SharedKeyIndex, + InData_SessionKey, + &gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_pf3_secp256r1 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_pf3(InData_SharedKeyNum, + InData_SharedKeyIndex, + InData_SessionKey, + &gs_cmd_ecc_type[RSIP_ECC_TYPE_NIST], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_pfa_brainpoolp256r1 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_pfa(InData_SharedKeyNum, + InData_SharedKeyIndex, + InData_SessionKey, + &gs_cmd_ecc_type[RSIP_ECC_TYPE_BRAINPOOL], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_pf3_brainpoolp256r1 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_pf3(InData_SharedKeyNum, + InData_SharedKeyIndex, + InData_SessionKey, + &gs_cmd_ecc_type[RSIP_ECC_TYPE_BRAINPOOL], + &gs_cmd_ecc_key_length[RSIP_ECC_KEY_LENGTH_256], + InData_IV, + InData_InstData, + OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p80_hmac_sha1 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p80(InData_SharedKeyNum, InData_SharedKeyIndex, InData_SessionKey, + &gs_cmd_hmac_hash_type[HMAC_HASH_TYPE_SHA1], InData_IV, InData_InstData, OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p80_hmac_sha224 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p80(InData_SharedKeyNum, InData_SharedKeyIndex, InData_SessionKey, + &gs_cmd_hmac_hash_type[HMAC_HASH_TYPE_SHA224], InData_IV, InData_InstData, OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p80_hmac_sha256 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]) +{ + return r_rsip_p80(InData_SharedKeyNum, InData_SharedKeyIndex, InData_SessionKey, + &gs_cmd_hmac_hash_type[HMAC_HASH_TYPE_SHA256], InData_IV, InData_InstData, OutData_KeyIndex); +} + +rsip_ret_t r_rsip_wrapper_p15_jtag_level1 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_EncAuthData[], + uint32_t OutData_Hash[]) +{ + static const uint32_t InData_HashType[1] = + { + RSIP_PRV_CMD_PASSWORD_TYPE_JTAG_DEBUG_AUTH_LEVEL1 + }; + + return r_rsip_p15(InData_SharedKeyNum, + InData_SharedKeyIndex, + InData_SessionKey, + InData_IV, + InData_EncAuthData, + InData_HashType, + OutData_Hash); +} + +rsip_ret_t r_rsip_wrapper_p15_jtag_level2 (const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_EncAuthData[], + uint32_t OutData_Hash[]) +{ + static const uint32_t InData_HashType[1] = + { + RSIP_PRV_CMD_PASSWORD_TYPE_JTAG_DEBUG_AUTH_LEVEL2 + }; + + return r_rsip_p15(InData_SharedKeyNum, + InData_SharedKeyIndex, + InData_SessionKey, + InData_IV, + InData_EncAuthData, + InData_HashType, + OutData_Hash); +} + +/*********************************************************************************************************************** + * Private Functions + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_wrapper.h b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_wrapper.h new file mode 100644 index 000000000..ff1544ac4 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/rzg3/private/r_rsip_wrapper.h @@ -0,0 +1,223 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2024 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ + +#ifndef R_RSIP_WRAPPER_H +#define R_RSIP_WRAPPER_H + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include "r_rsip_err.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Exported global variables + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Public Function Prototypes + **********************************************************************************************************************/ + +/* Key pair generation */ +rsip_ret_t r_rsip_wrapper_pf4_secp192r1(uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); +rsip_ret_t r_rsip_wrapper_pf4_secp224r1(uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); +rsip_ret_t r_rsip_wrapper_pf4_secp256r1(uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); +rsip_ret_t r_rsip_wrapper_pf4_brainpoolp256r1(uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); +rsip_ret_t r_rsip_wrapper_p2a(uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); +rsip_ret_t r_rsip_wrapper_p2b(uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); +rsip_ret_t r_rsip_wrapper_p3a (uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); +rsip_ret_t r_rsip_wrapper_p3b (uint32_t OutData_PubKeyIndex[], uint32_t OutData_PrivKeyIndex[]); + +/* Key import with KUK */ +rsip_ret_t r_rsip_wrapper_p2c_secp192r1(uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p1e_secp192r1(uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p2c_secp224r1(uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p1e_secp224r1(uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p2c_secp256r1(uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p1e_secp256r1(uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p2c_brainpoolp256r1(uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p1e_brainpoolp256r1(uint32_t const InData_IV[], + uint32_t const InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p0f_hmac_sha1(const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p0f_hmac_sha224(const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p0f_hmac_sha256(const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); + +/* AES-ECB/CBC/CTR */ +rsip_ret_t r_rsip_wrapper_p48i_ecb_enc(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_wrapper_p48i_ecb_dec(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_wrapper_p48i_cbc_enc(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_wrapper_p48i_cbc_dec(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_wrapper_p48i_ctr(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_wrapper_p50i_ecb_enc(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_wrapper_p50i_ecb_dec(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_wrapper_p50i_cbc_enc(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_wrapper_p50i_cbc_dec(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); +rsip_ret_t r_rsip_wrapper_p50i_ctr(const uint32_t InData_KeyIndex[], const uint32_t InData_IV[]); + +/* AES-CMAC */ +rsip_ret_t r_rsip_wrapper_p41f_gen(const uint32_t InData_Text[], uint32_t OutData_DataT[], const uint32_t all_msg_len); +rsip_ret_t r_rsip_wrapper_p44f_gen(const uint32_t InData_Text[], uint32_t OutData_DataT[], const uint32_t all_msg_len); +rsip_ret_t r_rsip_wrapper_p41f_veri(const uint32_t InData_Text[], + const uint32_t InData_DataT[], + const uint32_t InData_DataTLen[], + const uint32_t all_msg_len); +rsip_ret_t r_rsip_wrapper_p44f_veri(const uint32_t InData_Text[], + const uint32_t InData_DataT[], + const uint32_t InData_DataTLen[], + const uint32_t all_msg_len); + +/* ECDSA */ +rsip_ret_t r_rsip_wrapper_pf0_secp192r1(const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + uint32_t OutData_Signature[]); +rsip_ret_t r_rsip_wrapper_pf1_secp192r1(const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + const uint32_t InData_Signature[]); +rsip_ret_t r_rsip_wrapper_pf0_secp224r1(const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + uint32_t OutData_Signature[]); +rsip_ret_t r_rsip_wrapper_pf1_secp224r1(const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + const uint32_t InData_Signature[]); +rsip_ret_t r_rsip_wrapper_pf0_secp256r1(const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + uint32_t OutData_Signature[]); +rsip_ret_t r_rsip_wrapper_pf1_secp256r1(const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + const uint32_t InData_Signature[]); +rsip_ret_t r_rsip_wrapper_pf0_brainpoolp256r1(const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + uint32_t OutData_Signature[]); +rsip_ret_t r_rsip_wrapper_pf1_brainpoolp256r1(const uint32_t InData_KeyIndex[], + const uint32_t InData_MsgDgst[], + const uint32_t InData_Signature[]); + +/* Key import with UFPK */ +rsip_ret_t r_rsip_wrapper_pfa_secp192r1(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_pf3_secp192r1(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_pfa_secp224r1(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_pf3_secp224r1(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_pfa_secp256r1(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_pf3_secp256r1(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_pf3_brainpoolp256r1(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_pfa_brainpoolp256r1(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p80_hmac_sha1(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p80_hmac_sha224(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); +rsip_ret_t r_rsip_wrapper_p80_hmac_sha256(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_InstData[], + uint32_t OutData_KeyIndex[]); + +/* Password hash generation */ +rsip_ret_t r_rsip_wrapper_p15_jtag_level1(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_EncAuthData[], + uint32_t OutData_Hash[]); + +rsip_ret_t r_rsip_wrapper_p15_jtag_level2(const uint32_t InData_SharedKeyNum[], + const uint32_t InData_SharedKeyIndex[], + const uint32_t InData_SessionKey[], + const uint32_t InData_IV[], + const uint32_t InData_EncAuthData[], + uint32_t OutData_Hash[]); + +#endif /* R_RSIP_WRAPPER_H */ diff --git a/core/arch/arm/plat-rz/common/drivers/r_rsip/sub.mk b/core/arch/arm/plat-rz/common/drivers/r_rsip/sub.mk new file mode 100644 index 000000000..1e2eabbe4 --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/r_rsip/sub.mk @@ -0,0 +1,29 @@ +srcs-y += \ + bsp_api.c \ + rsip_common/public/r_rsip.c \ + rsip_common/public/r_rsip_aes.c \ + rsip_common/public/r_rsip_ecc.c \ + rsip_common/public/r_rsip_rsa.c \ + rsip_common/public/r_rsip_sha.c + +srcs-$(CFG_PLATFORM_GROUP_g3s) += \ + rsip_common/public/r_rsip_rzg3.c \ + rzg3/private/r_rsip_private.c \ + rzg3/private/r_rsip_wrapper.c \ + rzg3/private/r_rsip_otp.c + +global-incdirs-y += \ + . \ + rsip_common/inc \ + rsip_common/inc/api \ + rsip_common/inc/instances \ + rsip_common/public \ + rsip_common/private + +global-incdirs-$(CFG_PLATFORM_GROUP_g3s) += \ + rzg3/private \ + rzg3/primitive + +ifeq ($(CFG_PLATFORM_GROUP_g3s),y) +ldflags-external += $(CFG_RZ_SCE_LIB_DIR)/libr_secure_ip_3_0.a.1.0.0 +endif \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/README.md b/core/arch/arm/plat-rz/common/drivers/r_sce/README.md index eddad92b7..33e5e7602 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/README.md +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/README.md @@ -13,7 +13,7 @@ The SCE Driver is software for controlling SCE, which is the security IP of RZ M ### 1.1. Requirements - - RZ/G2L Secure Crypto Engine library 1.0.0 (libr_secure_ip_1_0.a.1.0.0) + - RZ Secure Crypto Engine library 1.0.0 (libr_secure_ip_1_0.a.1.0.0) - RZ/V2H Secure Crypto Engine library 1.0.0 (libr_secure_ip_2_0.a.1.0.0) ### 1.2. Notice @@ -33,7 +33,6 @@ The following table shows the document related to this function. | 1 | Renesas | RZ/G2L Security Manual | Rev.1.00 or later | | 2 | Renesas | RZ/V2H Security Manual | Rev.1.00 or later | - ## 2. Driver Specifications See /doc/*.rst diff --git a/core/arch/arm/plat-rz/common/drivers/r_sce/sub.mk b/core/arch/arm/plat-rz/common/drivers/r_sce/sub.mk index a30f4a8e6..400a7e851 100644 --- a/core/arch/arm/plat-rz/common/drivers/r_sce/sub.mk +++ b/core/arch/arm/plat-rz/common/drivers/r_sce/sub.mk @@ -7,3 +7,9 @@ srcs-y += private/r_sce_private.c global-incdirs-y += private/inc global-incdirs-y += inc/api global-incdirs-y += inc/instances + +ifeq ($(CFG_PLATFORM_GROUP_g2l),y) +ldflags-external += $(CFG_RZ_SCE_LIB_DIR)/libr_secure_ip_1_0.a.1.0.0 +else ifeq ($(CFG_PLATFORM_GROUP_v2h),y) +ldflags-external += $(CFG_RZ_SCE_LIB_DIR)/libr_secure_ip_2_0.a.1.0.0 +endif \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/rsip.c b/core/arch/arm/plat-rz/common/drivers/rsip.c new file mode 100644 index 000000000..fa36d6ddb --- /dev/null +++ b/core/arch/arm/plat-rz/common/drivers/rsip.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2024, Renesas Electronics + */ +#include +#include +#include +#include +#include +#include + +#include +#include + +register_phys_mem_pgdir(MEM_AREA_IO_SEC, RSIP_BASE, RSIP_SIZE); + +rsip_cfg_t rsip_cfg; +rsip_instance_ctrl_t rsip_instance_ctrl; + +volatile uint32_t * gp_sce; + +static TEE_Result RSIP_Init(void) +{ + fsp_err_t err; + + gp_sce = (uint32_t *) phys_to_virt_io(RSIP_BASE, RSIP_SIZE); + + err = R_RSIP_Open(&rsip_instance_ctrl, &rsip_cfg); + if (FSP_SUCCESS != err) + { + EMSG("Failed to initialize RSIP (0x%08x).", err); + panic(); + } + + return TEE_SUCCESS; +} + +driver_init(RSIP_Init); diff --git a/core/arch/arm/plat-rz/g2l/drivers/spi_multi/AT25QL128A/spi_multi_device.c b/core/arch/arm/plat-rz/common/drivers/spi_multi/AT25QL128A/spi_multi_device.c similarity index 100% rename from core/arch/arm/plat-rz/g2l/drivers/spi_multi/AT25QL128A/spi_multi_device.c rename to core/arch/arm/plat-rz/common/drivers/spi_multi/AT25QL128A/spi_multi_device.c diff --git a/core/arch/arm/plat-rz/g2l/drivers/spi_multi/AT25QL128A/spi_multi_reg_values.h b/core/arch/arm/plat-rz/common/drivers/spi_multi/AT25QL128A/spi_multi_reg_values.h similarity index 100% rename from core/arch/arm/plat-rz/g2l/drivers/spi_multi/AT25QL128A/spi_multi_reg_values.h rename to core/arch/arm/plat-rz/common/drivers/spi_multi/AT25QL128A/spi_multi_reg_values.h diff --git a/core/arch/arm/plat-rz/g2l/drivers/spi_multi/AT25QL128A/sub.mk b/core/arch/arm/plat-rz/common/drivers/spi_multi/AT25QL128A/sub.mk similarity index 100% rename from core/arch/arm/plat-rz/g2l/drivers/spi_multi/AT25QL128A/sub.mk rename to core/arch/arm/plat-rz/common/drivers/spi_multi/AT25QL128A/sub.mk diff --git a/core/arch/arm/plat-rz/g2l/drivers/spi_multi/MT25QU512ABB/spi_multi_device.c b/core/arch/arm/plat-rz/common/drivers/spi_multi/MT25QU512ABB/spi_multi_device.c similarity index 100% rename from core/arch/arm/plat-rz/g2l/drivers/spi_multi/MT25QU512ABB/spi_multi_device.c rename to core/arch/arm/plat-rz/common/drivers/spi_multi/MT25QU512ABB/spi_multi_device.c diff --git a/core/arch/arm/plat-rz/g2l/drivers/spi_multi/MT25QU512ABB/spi_multi_reg_values.h b/core/arch/arm/plat-rz/common/drivers/spi_multi/MT25QU512ABB/spi_multi_reg_values.h similarity index 100% rename from core/arch/arm/plat-rz/g2l/drivers/spi_multi/MT25QU512ABB/spi_multi_reg_values.h rename to core/arch/arm/plat-rz/common/drivers/spi_multi/MT25QU512ABB/spi_multi_reg_values.h diff --git a/core/arch/arm/plat-rz/g2l/drivers/spi_multi/MT25QU512ABB/sub.mk b/core/arch/arm/plat-rz/common/drivers/spi_multi/MT25QU512ABB/sub.mk similarity index 100% rename from core/arch/arm/plat-rz/g2l/drivers/spi_multi/MT25QU512ABB/sub.mk rename to core/arch/arm/plat-rz/common/drivers/spi_multi/MT25QU512ABB/sub.mk diff --git a/core/arch/arm/plat-rz/g2l/drivers/spi_multi/spi_multi.c b/core/arch/arm/plat-rz/common/drivers/spi_multi/spi_multi.c similarity index 100% rename from core/arch/arm/plat-rz/g2l/drivers/spi_multi/spi_multi.c rename to core/arch/arm/plat-rz/common/drivers/spi_multi/spi_multi.c diff --git a/core/arch/arm/plat-rz/g2l/drivers/spi_multi/spi_multi.h b/core/arch/arm/plat-rz/common/drivers/spi_multi/spi_multi.h similarity index 100% rename from core/arch/arm/plat-rz/g2l/drivers/spi_multi/spi_multi.h rename to core/arch/arm/plat-rz/common/drivers/spi_multi/spi_multi.h diff --git a/core/arch/arm/plat-rz/g2l/drivers/spi_multi/spi_multi_device.h b/core/arch/arm/plat-rz/common/drivers/spi_multi/spi_multi_device.h similarity index 100% rename from core/arch/arm/plat-rz/g2l/drivers/spi_multi/spi_multi_device.h rename to core/arch/arm/plat-rz/common/drivers/spi_multi/spi_multi_device.h diff --git a/core/arch/arm/plat-rz/g2l/drivers/spi_multi/spi_multi_regs.h b/core/arch/arm/plat-rz/common/drivers/spi_multi/spi_multi_regs.h similarity index 100% rename from core/arch/arm/plat-rz/g2l/drivers/spi_multi/spi_multi_regs.h rename to core/arch/arm/plat-rz/common/drivers/spi_multi/spi_multi_regs.h diff --git a/core/arch/arm/plat-rz/g2l/drivers/spi_multi/sub.mk b/core/arch/arm/plat-rz/common/drivers/spi_multi/sub.mk similarity index 100% rename from core/arch/arm/plat-rz/g2l/drivers/spi_multi/sub.mk rename to core/arch/arm/plat-rz/common/drivers/spi_multi/sub.mk diff --git a/core/arch/arm/plat-rz/common/drivers/sub.mk b/core/arch/arm/plat-rz/common/drivers/sub.mk index 08c244335..296de0337 100644 --- a/core/arch/arm/plat-rz/common/drivers/sub.mk +++ b/core/arch/arm/plat-rz/common/drivers/sub.mk @@ -2,11 +2,12 @@ global-incdirs-y += . srcs-$(CFG_RZ_SCIF) += scif.c +subdirs-$(CFG_RZ_SPI_MULTI) += spi_multi + subdirs-$(CFG_RZ_XSPI) += xspi -srcs-$(CFG_RZ_SCE) += sce.c hw_rng.c -subdirs-$(CFG_RZ_SCE) += r_sce +srcs-$(CFG_RZ_TSIP) += sce.c hw_rng.c +subdirs-$(CFG_RZ_TSIP) += r_sce -ifeq ($(CFG_PLATFORM_GROUP_v2h),y) -ldflags-external += $(CFG_RZ_SCE_LIB_DIR)/libr_secure_ip_2_0.a.1.0.0 -endif \ No newline at end of file +srcs-$(CFG_RZ_RSIP) += rsip.c hw_rng_rsip.c +subdirs-$(CFG_RZ_RSIP) += r_rsip \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip.h b/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip.h new file mode 100644 index 000000000..ed2e3936c --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip.h @@ -0,0 +1,311 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2024, Renesas Electronics + */ +#ifndef __PTA_RSIP_H +#define __PTA_RSIP_H + +#include + +#define PTA_RSIP_UUID \ + { 0xc0bcc4d4, 0x5b01, 0x46e7, \ + { 0xa1, 0x11, 0xc2, 0x9b, 0x28, 0xd8, 0x3d, 0xa0 } } + +#define WRAPPED_KEY_BYTE_SIZE_RSA_1024_PUBLIC_N 128U ///< RSA-1024 public key +#define WRAPPED_KEY_BYTE_SIZE_RSA_1024_PUBLIC_E 4U ///< RSA-1024 public key +#define WRAPPED_KEY_BYTE_SIZE_RSA_2048_PUBLIC_N 256U ///< RSA-2048 public key +#define WRAPPED_KEY_BYTE_SIZE_RSA_2048_PUBLIC_E 4U ///< RSA-2048 public key +#define WRAPPED_KEY_BYTE_SIZE_RSA_3072_PUBLIC_N 384U ///< RSA-3072 public key +#define WRAPPED_KEY_BYTE_SIZE_RSA_3072_PUBLIC_E 4U ///< RSA-3072 public key +#define WRAPPED_KEY_BYTE_SIZE_RSA_4096_PUBLIC_N 512U ///< RSA-4096 public key +#define WRAPPED_KEY_BYTE_SIZE_RSA_4096_PUBLIC_E 4U ///< RSA-4096 public key + +#define WRAPPED_KEY_BYTE_SIZE_ECC_secp192r1_PUBLIC_QX 24U ///< secp192r1 public key +#define WRAPPED_KEY_BYTE_SIZE_ECC_secp192r1_PUBLIC_QY 24U ///< secp192r1 public key +#define WRAPPED_KEY_BYTE_SIZE_ECC_secp224r1_PUBLIC_QX 28U ///< secp224r1 public key +#define WRAPPED_KEY_BYTE_SIZE_ECC_secp224r1_PUBLIC_QY 28U ///< secp224r1 public key +#define WRAPPED_KEY_BYTE_SIZE_ECC_secp256r1_PUBLIC_QX 32U ///< secp256r1 public key +#define WRAPPED_KEY_BYTE_SIZE_ECC_secp256r1_PUBLIC_QY 32U ///< secp256r1 public key +#define WRAPPED_KEY_BYTE_SIZE_ECC_BRAINPOOLP256R1_PUBLIC_QX 32U ///< brainpoolP256r1 public key +#define WRAPPED_KEY_BYTE_SIZE_ECC_BRAINPOOLP256R1_PUBLIC_QY 32U ///< brainpoolP256r1 public key + +/* + * [in/out] memref[0] : Wrapped key (rsip_wrapped_key_t:52byte) + */ +#define PTA_CMD_AES128_WrappedKeyGenerate (0x00010000) +/* + * [in/out] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_AES256_WrappedKeyGenerate (0x00010100) +/* + * [in/out] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_AES128_XTS_WrappedKeyGenerate (0x00010200) +/* + * [in/out] memref[0] : Wrapped key (rsip_wrapped_key_t:100byte) + */ +#define PTA_CMD_AES256_XTS_WrappedKeyGenerate (0x00010300) + +/* + * [in/out] memref[0] : Wrapped Public key (rsip_wrapped_key_t:180byte) + * [in/out] memref[1] : Wrapped Private key (rsip_wrapped_key_t:292byte) + */ +#define PTA_CMD_RSA1024_WrappedKeyPairGenerate (0x00011000) +/* + * [in/out] memref[0] : Wrapped Public key (rsip_wrapped_key_t:308byte) + * [in/out] memref[1] : Wrapped Private key (rsip_wrapped_key_t:548byte) + */ +#define PTA_CMD_RSA2048_WrappedKeyPairGenerate (0x00011100) +/* + * [in/out] memref[0] : Wrapped Public key (rsip_wrapped_key_t:436byte) + * [in/out] memref[1] : Wrapped Private key (rsip_wrapped_key_t:804byte) + */ +#define PTA_CMD_RSA3072_WrappedKeyPairGenerate (0x00011200) +/* + * [in/out] memref[0] : Wrapped Public key (rsip_wrapped_key_t:564byte) + * [in/out] memref[1] : Wrapped Private key (rsip_wrapped_key_t:1060byte) + */ +#define PTA_CMD_RSA4096_WrappedKeyPairGenerate (0x00011300) + +/* + * [in/out] memref[0] : Wrapped Public key (rsip_wrapped_key_t:100byte) + * [in/out] memref[1] : Wrapped Private key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_ECC_secp192r1_WrappedKeyPairGenerate (0x00012000) +/* + * [in/out] memref[0] : Wrapped Public key (rsip_wrapped_key_t:100byte) + * [in/out] memref[1] : Wrapped Private key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_ECC_secp224r1_WrappedKeyPairGenerate (0x00012100) +/* + * [in/out] memref[0] : Wrapped Public key (rsip_wrapped_key_t:100byte) + * [in/out] memref[1] : Wrapped Private key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_ECC_secp256r1_WrappedKeyPairGenerate (0x00012200) +/* + * [in/out] memref[0] : Wrapped Public key (rsip_wrapped_key_t:100byte) + * [in/out] memref[1] : Wrapped Private key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_ECC_BrainpoolP256r1_WrappedKeyPairGenerate (0x0001D000) + +/* + * [in/out] memref[0] : random data (16byte) + */ +#define PTA_CMD_RandomNumberGenerate (0x00014000) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (32byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:52byte) + */ +#define PTA_CMD_AES128_EncryptedKeyWrap (0x00015000) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_AES256_EncryptedKeyWrap (0x00015100) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_AES128_XTS_EncryptedKeyWrap (0x00015200) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:100byte) + */ +#define PTA_CMD_AES256_XTS_EncryptedKeyWrap (0x00015300) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (160byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:180byte) + */ +#define PTA_CMD_RSA1024_EncryptedPublicKeyWrap (0x00016000) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (272byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:292byte) + */ +#define PTA_CMD_RSA1024_EncryptedPrivateKeyWrap (0x00016010) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (288byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:308byte) + */ +#define PTA_CMD_RSA2048_EncryptedPublicKeyWrap (0x00016100) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (528byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:548byte) + */ +#define PTA_CMD_RSA2048_EncryptedPrivateKeyWrap (0x00016110) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (416byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:436byte) + */ +#define PTA_CMD_RSA3072_EncryptedPublicKeyWrap (0x00016300) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (784byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:804byte) + */ +#define PTA_CMD_RSA3072_EncryptedPrivateKeyWrap (0x00016310) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (544byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:564byte) + */ +#define PTA_CMD_RSA4096_EncryptedPublicKeyWrap (0x00016200) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (1040byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:1060byte) + */ +#define PTA_CMD_RSA4096_EncryptedPrivateKeyWrap (0x00016210) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:100byte) + */ +#define PTA_CMD_ECC_secp192r1_EncryptedPublicKeyWrap (0x00017000) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_ECC_secp192r1_EncryptedPrivateKeyWrap (0x00017010) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:100byte) + */ +#define PTA_CMD_ECC_secp224r1_EncryptedPublicKeyWrap (0x00017100) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_ECC_secp224r1_EncryptedPrivateKeyWrap (0x00017110) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:100byte) + */ +#define PTA_CMD_ECC_secp256r1_EncryptedPublicKeyWrap (0x00017200) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_ECC_secp256r1_EncryptedPrivateKeyWrap (0x00017210) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (80byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:100byte) + */ +#define PTA_CMD_ECC_BrainpoolP256r1_EncryptedPublicKeyWrap (0x00019000) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_ECC_BrainpoolP256r1_EncryptedPrivateKeyWrap (0x00019010) + +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_HMAC_SHA1_EncryptedKeyWrap (0x0001A000) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_HMAC_SHA224_EncryptedKeyWrap (0x0001A100) +/* + * [in] memref[0] : Initial vector (16byte) + * [in] memref[1] : Encrypted Key (48byte) + * [in] memref[2] : Key Update Key (16byte) + * [in/out] memref[3] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_HMAC_SHA256_EncryptedKeyWrap (0x0001A200) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:180byte) + * [in/out] memref[1] : Raw_N (128byte) + * [in/out] memref[2] : Raw_E (4byte) + */ +#define PTA_CMD_RSA_1024_Public_Key_Export (0x0001B000) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:308byte) + * [in/out] memref[1] : Raw_N (256byte) + * [in/out] memref[2] : Raw_E (4byte) + */ +#define PTA_CMD_RSA_2048_Public_Key_Export (0x0001B100) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:436byte) + * [in/out] memref[1] : Raw_N (384byte) + * [in/out] memref[2] : Raw_E (4byte) + */ +#define PTA_CMD_RSA_3072_Public_Key_Export (0x0001B200) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:564byte) + * [in/out] memref[1] : Raw_N (512byte) + * [in/out] memref[2] : Raw_E (4byte) + */ +#define PTA_CMD_RSA_4096_Public_Key_Export (0x0001B300) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:100byte) + * [in/out] memref[1] : Raw_Qx (32byte) + * [in/out] memref[2] : Raw_Qy (32byte) + */ +#define PTA_CMD_ECC_secp192r1_Public_Key_Export (0x0001C000) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:100byte) + * [in/out] memref[1] : Raw_Qx (32byte) + * [in/out] memref[2] : Raw_Qy (32byte) + */ +#define PTA_CMD_ECC_secp224r1_Public_Key_Export (0x0001C100) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:100byte) + * [in/out] memref[1] : Raw_Qx (32byte) + * [in/out] memref[2] : Raw_Qy (32byte) + */ +#define PTA_CMD_ECC_secp256r1_Public_Key_Export (0x0001C200) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:100byte) + * [in/out] memref[1] : Raw_Qx (32byte) + * [in/out] memref[2] : Raw_Qy (32byte) + */ +#define PTA_CMD_ECC_BrainpoolP256r1_Public_Key_Export (0x0001C300) + +#endif /* __PTA_RSIP_H */ \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_aes.h b/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_aes.h new file mode 100644 index 000000000..7ea15273d --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_aes.h @@ -0,0 +1,361 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2024, Renesas Electronics + */ +#ifndef __PTA_RSIP_AES_H +#define __PTA_RSIP_AES_H + +#include + +#define PTA_RSIP_AES_UUID \ + { 0xa28ddef1, 0xe546, 0x449b, \ + { 0xb0, 0x61, 0xbf, 0xc4, 0x74, 0xb4, 0x9a, 0x4e } } + +#define MAC_BYTE_SIZE (16) +#define AES_BLOCK_LEN (16) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:52byte) + */ +#define PTA_CMD_AES128ECB_EncryptInit (0x00020001) +/* + * [in] memref[0] : Plain (length must be a multiple of 16) + * [in/out] memref[1] : Cipher + */ +#define PTA_CMD_AES128ECB_EncryptUpdate (0x00020002) +/* + * [in/out] memref[0] : Cipher (32byte) + */ +#define PTA_CMD_AES128ECB_EncryptFinal (0x00020003) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:52byte) + */ +#define PTA_CMD_AES128ECB_DecryptInit (0x00020011) +/* + * [in] memref[0] : Cipher (length must be a multiple of 16) + * [in/out] memref[1] : Plain + */ +#define PTA_CMD_AES128ECB_DecryptUpdate (0x00020012) +/* + * [in/out] memref[0] : Plain (32byte) + */ +#define PTA_CMD_AES128ECB_DecryptFinal (0x00020013) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_AES256ECB_EncryptInit (0x00020101) +/* + * [in] memref[0] : Plain (length must be a multiple of 16) + * [in/out] memref[1] : Cipher + */ +#define PTA_CMD_AES256ECB_EncryptUpdate (0x00020102) +/* + * [in/out] memref[0] : Cipher (32byte) + */ +#define PTA_CMD_AES256ECB_EncryptFinal (0x00020103) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_AES256ECB_DecryptInit (0x00020111) +/* + * [in] memref[0] : Cipher (length must be a multiple of 16) + * [in/out] memref[1] : Plain + */ +#define PTA_CMD_AES256ECB_DecryptUpdate (0x00020112) +/* + * [in/out] memref[0] : Plain (32byte) + */ +#define PTA_CMD_AES256ECB_DecryptFinal (0x00020113) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:52byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES128CBC_EncryptInit (0x00021001) +/* + * [in] memref[0] : Plain (length must be a multiple of 16) + * [in/out] memref[1] : Cipher + */ +#define PTA_CMD_AES128CBC_EncryptUpdate (0x00021002) +/* + * [in/out] memref[0] : Cipher (32byte) + */ +#define PTA_CMD_AES128CBC_EncryptFinal (0x00021003) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:52byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES128CBC_DecryptInit (0x00021011) +/* + * [in] memref[0] : Cipher (length must be a multiple of 16) + * [in/out] memref[1] : Plain + */ +#define PTA_CMD_AES128CBC_DecryptUpdate (0x00021012) +/* + * [in/out] memref[0] : Plain (32byte) + */ +#define PTA_CMD_AES128CBC_DecryptFinal (0x00021013) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES256CBC_EncryptInit (0x00021101) +/* + * [in] memref[0] : Plain (length must be a multiple of 16) + * [in/out] memref[1] : Cipher + */ +#define PTA_CMD_AES256CBC_EncryptUpdate (0x00021102) +/* + * [in/out] memref[0] : Cipher (32byte) + */ +#define PTA_CMD_AES256CBC_EncryptFinal (0x00021103) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES256CBC_DecryptInit (0x00021111) +/* + * [in] memref[0] : Cipher (length must be a multiple of 16) + * [in/out] memref[1] : Plain + */ +#define PTA_CMD_AES256CBC_DecryptUpdate (0x00021112) +/* + * [in/out] memref[0] : Plain (32byte) + */ +#define PTA_CMD_AES256CBC_DecryptFinal (0x00021113) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:52byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES128CTR_EncryptInit (0x00022001) +/* + * [in] memref[0] : Plain (length must be a multiple of 16) + * [in/out] memref[1] : Cipher + */ +#define PTA_CMD_AES128CTR_EncryptUpdate (0x00022002) +/* + * [in/out] memref[0] : Cipher (32byte) + */ +#define PTA_CMD_AES128CTR_EncryptFinal (0x00022003) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:52byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES128CTR_DecryptInit (0x00022011) +/* + * [in] memref[0] : Cipher (length must be a multiple of 16) + * [in/out] memref[1] : Plain + */ +#define PTA_CMD_AES128CTR_DecryptUpdate (0x00022012) +/* + * [in/out] memref[0] : Plain (32byte) + */ +#define PTA_CMD_AES128CTR_DecryptFinal (0x00022013) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES256CTR_EncryptInit (0x00022101) +/* + * [in] memref[0] : Plain (length must be a multiple of 16) + * [in/out] memref[1] : Cipher + */ +#define PTA_CMD_AES256CTR_EncryptUpdate (0x00022102) +/* + * [in/out] memref[0] : Cipher (32byte) + */ +#define PTA_CMD_AES256CTR_EncryptFinal (0x00022103) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES256CTR_DecryptInit (0x00022111) +/* + * [in] memref[0] : Cipher (length must be a multiple of 16) + * [in/out] memref[1] : Plain + */ +#define PTA_CMD_AES256CTR_DecryptUpdate (0x00022112) +/* + * [in/out] memref[0] : Plain (32byte) + */ +#define PTA_CMD_AES256CTR_DecryptFinal (0x00022113) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:52byte) + */ +#define PTA_CMD_AES128CMAC_GenerateInit (0x00023001) +/* + * [in] memref[0] : Message + */ +#define PTA_CMD_AES128CMAC_GenerateUpdate (0x00023002) +/* + * [in/out] memref[0] : MAC (16byte) + */ +#define PTA_CMD_AES128CMAC_GenerateFinal (0x00023003) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:52byte) + */ +#define PTA_CMD_AES128CMAC_VerifyInit (0x00023011) +/* + * [in] memref[0] : Message + */ +#define PTA_CMD_AES128CMAC_VerifyUpdate (0x00023012) +/* + * [in] memref[0] : MAC (2 to 16byte) + */ +#define PTA_CMD_AES128CMAC_VerifyFinal (0x00023013) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_AES256CMAC_GenerateInit (0x00023101) +/* + * [in] memref[0] : Message + */ +#define PTA_CMD_AES256CMAC_GenerateUpdate (0x00023102) +/* + * [in/out] memref[0] : MAC (16byte) + */ +#define PTA_CMD_AES256CMAC_GenerateFinal (0x00023103) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_AES256CMAC_VerifyInit (0x00023111) +/* + * [in] memref[0] : Message + */ +#define PTA_CMD_AES256CMAC_VerifyUpdate (0x00023112) +/* + * [in] memref[0] : MAC (2 to 16byte) + */ +#define PTA_CMD_AES256CMAC_VerifyFinal (0x00023113) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES128XTS_EncryptInit (0x00024001) +/* + * [in] memref[0] : Plain + * [in/out] memref[1] : Cipher + */ +#define PTA_CMD_AES128XTS_EncryptUpdate (0x00024002) +/* + * [in/out] memref[0] : Cipher (32byte) + */ +#define PTA_CMD_AES128XTS_EncryptFinal (0x00024003) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES128XTS_DecryptInit (0x00024011) +/* + * [in] memref[0] : Cipher + * [in/out] memref[1] : Plain + */ +#define PTA_CMD_AES128XTS_DecryptUpdate (0x00024012) +/* + * [in/out] memref[0] : Plain (32byte) + */ +#define PTA_CMD_AES128XTS_DecryptFinal (0x00024013) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:100byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES256XTS_EncryptInit (0x00024101) +/* + * [in] memref[0] : Plain + * [in/out] memref[1] : Cipher + */ +#define PTA_CMD_AES256XTS_EncryptUpdate (0x00024102) +/* + * [in/out] memref[0] : Cipher (32byte) + */ +#define PTA_CMD_AES256XTS_EncryptFinal (0x00024103) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:100byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES256XTS_DecryptInit (0x00024111) +/* + * [in] memref[0] : Cipher + * [in/out] memref[1] : Plain + */ +#define PTA_CMD_AES256XTS_DecryptUpdate (0x00024112) +/* + * [in/out] memref[0] : Plain (32byte) + */ +#define PTA_CMD_AES256XTS_DecryptFinal (0x00024113) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:52byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES128GCM_EncryptInit (0x00025001) +/* + * [in] memref[0] : Plain + * [in/out] memref[1] : Cipher + * [in] memref[2] : AAD + */ +#define PTA_CMD_AES128GCM_EncryptUpdate (0x00025002) +/* + * [in/out] memref[0] : Cipher + * [in/out] memref[1] : Tag (16byte) + */ +#define PTA_CMD_AES128GCM_EncryptFinal (0x00025003) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:52byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES128GCM_DecryptInit (0x00025011) +/* + * [in] memref[0] : Cipher + * [in/out] memref[1] : Plain + * [in] memref[2] : AAD + */ +#define PTA_CMD_AES128GCM_DecryptUpdate (0x00025012) +/* + * [in/out] memref[0] : Plain + * [in] memref[1] : Tag (1 to 16byte) + */ +#define PTA_CMD_AES128GCM_DecryptFinal (0x00025013) + +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES256GCM_EncryptInit (0x00025101) +/* + * [in] memref[0] : Plain + * [in/out] memref[1] : Cipher + * [in] memref[2] : AAD + */ +#define PTA_CMD_AES256GCM_EncryptUpdate (0x00025102) +/* + * [in/out] memref[0] : Cipher + * [in/out] memref[1] : Tag (16byte) + */ +#define PTA_CMD_AES256GCM_EncryptFinal (0x00025103) +/* + * [in] memref[0] : Wrapped key (rsip_wrapped_key_t:68byte) + * [in] memref[1] : Initial vector (16byte) + */ +#define PTA_CMD_AES256GCM_DecryptInit (0x00025111) +/* + * [in] memref[0] : Cipher + * [in/out] memref[1] : Plain + * [in] memref[2] : AAD + */ +#define PTA_CMD_AES256GCM_DecryptUpdate (0x00025112) +/* + * [in/out] memref[0] : Plain + * [in] memref[1] : Tag (1 to 16byte) + */ +#define PTA_CMD_AES256GCM_DecryptFinal (0x00025113) + +#endif /* __PTA_RSIP_AES_H */ diff --git a/core/arch/arm/plat-rz/g2l/pta/include/pta_sce_ecc.h b/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_ecc.h similarity index 54% rename from core/arch/arm/plat-rz/g2l/pta/include/pta_sce_ecc.h rename to core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_ecc.h index cf0baf464..286dbb581 100644 --- a/core/arch/arm/plat-rz/g2l/pta/include/pta_sce_ecc.h +++ b/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_ecc.h @@ -1,70 +1,69 @@ // SPDX-License-Identifier: BSD-2-Clause /* - * Copyright (c) 2022, Renesas Electronics + * Copyright (c) 2024, Renesas Electronics */ -#ifndef __PTA_SCE_ECC_H -#define __PTA_SCE_ECC_H +#ifndef __PTA_RSIP_ECC_H +#define __PTA_RSIP_ECC_H -#include +#include -#define PTA_SCE_ECC_UUID \ - { 0xa0c74f91, 0xbaac, 0x4ba3, \ - { 0x96, 0xbe, 0x58, 0xe5, 0x1f, 0xb1, 0xd1, 0xba } } +#define PTA_RSIP_ECC_UUID \ + { 0xf0dd12df, 0x3d26, 0x4bf2, \ + { 0x93, 0x77, 0x4e, 0x2c, 0x31, 0x82, 0xaf, 0x43 } } + +#define SIGNATURE_SIZE (64U) /* * [in] memref[0] : Message * [in/out] memref[1] : Signature (64byte) - * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:68byte) */ #define PTA_CMD_ECDSA_secp192r1_SignatureGenerate (0x00050000) /* * [in] memref[0] : Signature (64byte) * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:100byte) */ #define PTA_CMD_ECDSA_secp192r1_SignatureVerify (0x00050010) /* * [in] memref[0] : Message * [in/out] memref[1] : Signature (64byte) - * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:68byte) */ #define PTA_CMD_ECDSA_secp224r1_SignatureGenerate (0x00050100) - /* * [in] memref[0] : Signature (64byte) * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:100byte) */ #define PTA_CMD_ECDSA_secp224r1_SignatureVerify (0x00050110) /* * [in] memref[0] : Message * [in/out] memref[1] : Signature (64byte) - * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:68byte) */ #define PTA_CMD_ECDSA_secp256r1_SignatureGenerate (0x00050200) - /* * [in] memref[0] : Signature (64byte) * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:100byte) */ #define PTA_CMD_ECDSA_secp256r1_SignatureVerify (0x00050210) /* * [in] memref[0] : Message * [in/out] memref[1] : Signature (64byte) - * [in] memref[2] : Wrapped key (sce_ecc_private_wrapped_key_t) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:68byte) */ -#define PTA_CMD_ECDSA_BrainpoolP512r1_SignatureGenerate (0x00051000) - +#define PTA_CMD_ECDSA_BrainpoolP256r1_SignatureGenerate (0x00052000) /* * [in] memref[0] : Signature (64byte) * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_ecc_public_wrapped_key_t) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:100byte) */ -#define PTA_CMD_ECDSA_BrainpoolP512r1_SignatureVerify (0x00051010) +#define PTA_CMD_ECDSA_BrainpoolP256r1_SignatureVerify (0x00052010) -#endif /* __PTA_SCE_ECC_H */ +#endif /* __PTA_RSIP_ECC_H */ diff --git a/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_hmac.h b/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_hmac.h new file mode 100644 index 000000000..853d9c627 --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_hmac.h @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2024, Renesas Electronics + */ +#ifndef __PTA_RSIP_HMAC_H +#define __PTA_RSIP_HMAC_H + +#include + +#define PTA_RSIP_HMAC_UUID \ + { 0xb528d9ee, 0x98d3, 0x4890, \ + { 0xb0, 0xf2, 0xa7, 0x91, 0xc3, 0xd7, 0x92, 0x08 } } + +#define SHA1_MAC_SIZE (20U) +#define SHA224_MAC_SIZE (28U) +#define SHA256_MAC_SIZE (32U) + +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_HMAC_SHA1_GenerateInit (0x00060000) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_HMAC_SHA1_GenerateUpdate (0x00060001) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in/out] memref[1] : MAC (20byte) + */ +#define PTA_CMD_HMAC_SHA1_GenerateFinal (0x00060002) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_HMAC_SHA1_VerifyInit (0x00060010) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_HMAC_SHA1_VerifyUpdate (0x00060011) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : MAC (4 to 20byte) + */ +#define PTA_CMD_HMAC_SHA1_VerifyFinal (0x00060012) + +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_HMAC_SHA224_GenerateInit (0x00060100) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_HMAC_SHA224_GenerateUpdate (0x00060101) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in/out] memref[1] : MAC (28byte) + */ +#define PTA_CMD_HMAC_SHA224_GenerateFinal (0x00060102) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_HMAC_SHA224_VerifyInit (0x00060110) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_HMAC_SHA224_VerifyUpdate (0x00060111) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : MAC (4 to 28byte) + */ +#define PTA_CMD_HMAC_SHA224_VerifyFinal (0x00060112) + +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_HMAC_SHA256_GenerateInit (0x00060200) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_HMAC_SHA256_GenerateUpdate (0x00060201) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in/out] memref[1] : MAC (32byte) + */ +#define PTA_CMD_HMAC_SHA256_GenerateFinal (0x00060202) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:68byte) + */ +#define PTA_CMD_HMAC_SHA256_VerifyInit (0x00060210) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_HMAC_SHA256_VerifyUpdate (0x00060211) +/* + * [in/out] memref[0] : HMAC handler (rsip_hmac_handle_t) + * [in] memref[1] : MAC (4 to 32byte) + */ +#define PTA_CMD_HMAC_SHA256_VerifyFinal (0x00060212) + +#endif /* __PTA_RSIP_HMAC_H */ diff --git a/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_rsa.h b/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_rsa.h new file mode 100644 index 000000000..a0846e6e0 --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_rsa.h @@ -0,0 +1,309 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2024, Renesas Electronics + */ +#ifndef __PTA_RSIP_RSA_H +#define __PTA_RSIP_RSA_H + +#include + +#define PTA_RSIP_RSA_UUID \ + { 0x38225144, 0xb347, 0x467e, \ + { 0x93, 0x7e, 0x1e, 0xf8, 0xff, 0x7e, 0x5a, 0xe1 } } + +#define SIGNATURE_BYTE_SIZE_RSA_1024 (128U) +#define SIGNATURE_BYTE_SIZE_RSA_2048 (256U) +#define SIGNATURE_BYTE_SIZE_RSA_3072 (384U) +#define SIGNATURE_BYTE_SIZE_RSA_4096 (512U) + +#define CIPHER_BYTE_SIZE_RSA_1024 (128U) +#define CIPHER_BYTE_SIZE_RSA_2048 (256U) +#define CIPHER_BYTE_SIZE_RSA_3072 (384U) +#define CIPHER_BYTE_SIZE_RSA_4096 (512U) + + +/* + * Signs message with RSASSA-PKCS1-v1_5. + * + * Hash function : SHA-256 + */ + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (128byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:292byte) + */ +#define PTA_CMD_RSASSA_PKCS1024_SignatureGenerate (0x00040000) +/* + * [in] memref[0] : Signature (128byte) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:180byte) + */ +#define PTA_CMD_RSASSA_PKCS1024_SignatureVerify (0x00040010) +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (256byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:548byte) + */ +#define PTA_CMD_RSASSA_PKCS2048_SignatureGenerate (0x00040100) +/* + * [in] memref[0] : Signature (256byte) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:308byte) + */ +#define PTA_CMD_RSASSA_PKCS2048_SignatureVerify (0x00040110) +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (384byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:804byte) + */ +#define PTA_CMD_RSASSA_PKCS3072_SignatureGenerate (0x00040300) +/* + * [in] memref[0] : Signature (384byte) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:436byte) + */ +#define PTA_CMD_RSASSA_PKCS3072_SignatureVerify (0x00040310) +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (512byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:1060byte) + */ +#define PTA_CMD_RSASSA_PKCS4096_SignatureGenerate (0x00040200) +/* + * [in] memref[0] : Signature (512byte) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:564byte) + */ +#define PTA_CMD_RSASSA_PKCS4096_SignatureVerify (0x00040210) + + +/* + * Encrypts plaintext with RSAES-PKCS1-v1_5. + * + * mLen (plain_length) and k (RSA key length) must meet the following condition. + * + * mlen <= k - 11 + */ + +/* + * [in] memref[0] : Plain (size <= 117byte) + * [in/out] memref[1] : Cipher (size == 128byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:180byte) + */ +#define PTA_CMD_RSAES_PKCS1024_Encrypt (0x00041000) +/* + * [in] memref[0] : Cipher (size == 128byte) + * [in/out] memref[1] : Plain (size <= 117byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:292byte) + */ +#define PTA_CMD_RSAES_PKCS1024_Decrypt (0x00041010) +/* + * [in] memref[0] : Plain (size <= 245byte) + * [in/out] memref[1] : Cipher (size == 256byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:308byte) + */ +#define PTA_CMD_RSAES_PKCS2048_Encrypt (0x00041100) +/* + * [in] memref[0] : Cipher (size == 256byte) + * [in/out] memref[1] : Plain (size <= 245byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:548byte) + */ +#define PTA_CMD_RSAES_PKCS2048_Decrypt (0x00041110) +/* + * [in] memref[0] : Plain (size <= 373byte) + * [in/out] memref[1] : Cipher (size == 384byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:436byte) + */ +#define PTA_CMD_RSAES_PKCS3072_Encrypt (0x00041300) +/* + * [in] memref[0] : Cipher (size == 384byte) + * [in/out] memref[1] : Plain (size <= 373byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:804byte) + */ +#define PTA_CMD_RSAES_PKCS3072_Decrypt (0x00041310) +/* + * [in] memref[0] : Plain (size <= 501byte) + * [in/out] memref[1] : Cipher (size == 512byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:564byte) + */ +#define PTA_CMD_RSAES_PKCS4096_Encrypt (0x00041200) +/* + * [in] memref[0] : Cipher (size == 512byte) + * [in/out] memref[1] : Plain (size <= 501byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:1060byte) + */ +#define PTA_CMD_RSAES_PKCS4096_Decrypt (0x00041210) + + +/* + * Signs message with RSASSA-PSS. + * + * Hash function : SHA-256 + * Mask generation function : MGF1 with SHA-256 + * Salt length : 32byte (hash length of SHA-256) + */ + +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (128byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:292byte) + */ +#define PTA_CMD_RSASSA_PSS1024_SignatureGenerate (0x00042000) +/* + * [in] memref[0] : Signature (128byte) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:180byte) + */ +#define PTA_CMD_RSASSA_PSS1024_SignatureVerify (0x00042010) +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (256byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:548byte) + */ +#define PTA_CMD_RSASSA_PSS2048_SignatureGenerate (0x00042100) +/* + * [in] memref[0] : Signature (256byte) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:384byte) + */ +#define PTA_CMD_RSASSA_PSS2048_SignatureVerify (0x00042110) +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (384byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:804byte) + */ +#define PTA_CMD_RSASSA_PSS3072_SignatureGenerate (0x00042200) +/* + * [in] memref[0] : Signature (384byte) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:436byte) + */ +#define PTA_CMD_RSASSA_PSS3072_SignatureVerify (0x00042210) +/* + * [in] memref[0] : Message + * [in/out] memref[1] : Signature (512byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:1060byte) + */ +#define PTA_CMD_RSASSA_PSS4096_SignatureGenerate (0x00042300) +/* + * [in] memref[0] : Signature (512byte) + * [in] memref[1] : Wrapped key (rsip_wrapped_key_t:564byte) + */ +#define PTA_CMD_RSASSA_PSS4096_SignatureVerify (0x00042310) + +/* + * [in] memref[0] : Plain (128byte) + * [in/out] memref[1] : Cipher (128byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:180byte) + */ +#define PTA_CMD_RSA_1024_Encrypt (0x00043000) +/* + * [in] memref[0] : Cipher (128byte) + * [in/out] memref[1] : Plain (128byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:292byte) + */ +#define PTA_CMD_RSA_1024_Decrypt (0x00043010) +/* + * [in] memref[0] : Plain (256byte) + * [in/out] memref[1] : Cipher (256byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:308byte) + */ +#define PTA_CMD_RSA_2048_Encrypt (0x00043100) +/* + * [in] memref[0] : Cipher (256byte) + * [in/out] memref[1] : Plain (256byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:548byte) + */ +#define PTA_CMD_RSA_2048_Decrypt (0x00043110) +/* + * [in] memref[0] : Plain (384byte) + * [in/out] memref[1] : Cipher (384byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:436byte) + */ +#define PTA_CMD_RSA_3072_Encrypt (0x00043200) +/* + * [in] memref[0] : Cipher (384byte) + * [in/out] memref[1] : Plain (384byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:804byte) + */ +#define PTA_CMD_RSA_3072_Decrypt (0x00043210) +/* + * [in] memref[0] : Plain (512byte) + * [in/out] memref[1] : Cipher (512byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:564byte) + */ +#define PTA_CMD_RSA_4096_Encrypt (0x00043300) +/* + * [in] memref[0] : Cipher (512byte) + * [in/out] memref[1] : Plain (512byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:1060byte) + */ +#define PTA_CMD_RSA_4096_Decrypt (0x00043310) + + +/* + * Encrypts plaintext with RSAES-OAEP. + * + * Hash function : SHA-256 + * Mask generation function : MGF1 with SHA-256 + * + * mLen (plain_length), hLen (output length of hash_function), and k (RSA key length) + * must meet the following condition. + * + * mLen <= k - 2 hLen - 2 + */ + +/* + * [in] memref[0] : Plain (size <= 62byte) + * [in/out] memref[1] : Cipher (size == 128byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:180byte) + * [in] memref[3] : Label + */ +#define PTA_CMD_RSAES_OAEP1024_Encrypt (0x00044000) +/* + * [in] memref[0] : Cipher (size == 128byte) + * [in/out] memref[1] : Plain (size <= 62byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:292byte) + * [in] memref[3] : Label + */ +#define PTA_CMD_RSAES_OAEP1024_Decrypt (0x00044010) +/* + * [in] memref[0] : Plain (size <= 190byte) + * [in/out] memref[1] : Cipher (size == 256byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:308byte) + * [in] memref[3] : Label + */ +#define PTA_CMD_RSAES_OAEP2048_Encrypt (0x00044100) +/* + * [in] memref[0] : Cipher (size == 256byte) + * [in/out] memref[1] : Plain (size <= 190byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:548byte) + * [in] memref[3] : Label + */ +#define PTA_CMD_RSAES_OAEP2048_Decrypt (0x00044110) +/* + * [in] memref[0] : Plain (size <= 318byte) + * [in/out] memref[1] : Cipher (size == 384byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:436byte) + * [in] memref[3] : Label + */ +#define PTA_CMD_RSAES_OAEP3072_Encrypt (0x00044200) +/* + * [in] memref[0] : Cipher (size == 384byte) + * [in/out] memref[1] : Plain (size <= 318byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:804byte) + * [in] memref[3] : Label + */ +#define PTA_CMD_RSAES_OAEP3072_Decrypt (0x00044210) +/* + * [in] memref[0] : Plain (size <= 446byte) + * [in/out] memref[1] : Cipher (size == 512byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:564byte) + * [in] memref[3] : Label + */ +#define PTA_CMD_RSAES_OAEP4096_Encrypt (0x00044300) +/* + * [in] memref[0] : Cipher (size == 512byte) + * [in/out] memref[1] : Plain (size <= 446byte) + * [in] memref[2] : Wrapped key (rsip_wrapped_key_t:1060byte) + * [in] memref[3] : Label + */ +#define PTA_CMD_RSAES_OAEP4096_Decrypt (0x00044310) + + + +#endif /* __PTA_RSIP_RSA_H */ diff --git a/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_sha.h b/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_sha.h new file mode 100644 index 000000000..c4d5f4c0c --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/include/pta_rsip_sha.h @@ -0,0 +1,127 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2024, Renesas Electronics + */ +#ifndef __PTA_RSIP_SHA_H +#define __PTA_RSIP_SHA_H + +#include + +#define PTA_RSIP_SHA_UUID \ + { 0x8fa6b9c0, 0xb59f, 0x4762, \ + { 0x92, 0x46, 0x38, 0xdc, 0x66, 0x53, 0x57, 0x04 } } + +#define SHA1_HASH_SIZE (20U) +#define SHA224_HASH_SIZE (28U) +#define SHA256_HASH_SIZE (32U) +#define SHA384_HASH_SIZE (48U) +#define SHA512_HASH_SIZE (64U) +#define SHA512_224_HASH_SIZE (28U) +#define SHA512_256_HASH_SIZE (32U) + +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + */ +#define PTA_CMD_SHA1_Init (0x00030200) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_SHA1_Update (0x00030201) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in/out] memref[1] : Digest (20byte) + */ +#define PTA_CMD_SHA1_Final (0x00030202) + +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + */ +#define PTA_CMD_SHA224_Init (0x00030000) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_SHA224_Update (0x00030001) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in/out] memref[1] : Digest (28byte) + */ +#define PTA_CMD_SHA224_Final (0x00030002) + +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + */ +#define PTA_CMD_SHA256_Init (0x00030100) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_SHA256_Update (0x00030101) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in/out] memref[1] : Digest (32byte) + */ +#define PTA_CMD_SHA256_Final (0x00030102) + +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + */ +#define PTA_CMD_SHA384_Init (0x00030300) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_SHA384_Update (0x00030301) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in/out] memref[1] : Digest (48byte) + */ +#define PTA_CMD_SHA384_Final (0x00030302) + +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + */ +#define PTA_CMD_SHA512_Init (0x00030400) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_SHA512_Update (0x00030401) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in/out] memref[1] : Digest (64byte) + */ +#define PTA_CMD_SHA512_Final (0x00030402) + +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + */ +#define PTA_CMD_SHA512_224_Init (0x00030500) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_SHA512_224_Update (0x00030501) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in/out] memref[1] : Digest (28byte) + */ +#define PTA_CMD_SHA512_224_Final (0x00030502) + +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + */ +#define PTA_CMD_SHA512_256_Init (0x00030600) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in] memref[1] : Message + */ +#define PTA_CMD_SHA512_256_Update (0x00030601) +/* + * [in/out] memref[0] : SHA handler (rsip_sha_handle_t) + * [in/out] memref[1] : Digest (32byte) + */ +#define PTA_CMD_SHA512_256_Final (0x00030602) + +#endif /* __PTA_RSIP_SHA_H */ diff --git a/core/arch/arm/plat-rz/common/pta/rsip/include/r_rsip_api.h b/core/arch/arm/plat-rz/common/pta/rsip/include/r_rsip_api.h new file mode 100644 index 000000000..f1c4d6b70 --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/include/r_rsip_api.h @@ -0,0 +1,504 @@ +/* ${REA_DISCLAIMER_PLACEHOLDER} */ + +/*******************************************************************************************************************//** + * @ingroup RENESAS_INTERFACES + * @defgroup RSIP_API RSIP Interface + * @brief Interface for Renesas Secure IP (RSIP) functions. + * + * @section RSIP_API_Summary Summary + * The RSIP interface provides RSIP functionality. + * + * The RSIP interface can be implemented by: + * - @ref RSIP + * + * @{ + **********************************************************************************************************************/ + +#ifndef R_RSIP_API_H +#define R_RSIP_API_H + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ + +/* Register definitions, common services and error codes. */ +//#include "bsp_api.h" + +/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */ +//FSP_HEADER + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/* Return code */ +#define FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT (0x10100) ///< Hardware resource is busy +#define FSP_ERR_CRYPTO_RSIP_FATAL (0x10101) ///< Hardware fatal error or unexpected return +#define FSP_ERR_CRYPTO_RSIP_FAIL (0x10102) ///< Internal error +#define FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL (0x10103) ///< Input key type is illegal +#define FSP_ERR_CRYPTO_RSIP_AUTHENTICATION (0x10104) ///< Authentication failed + +/* Return code for SB-Lib */ +#define FSP_ERR_SB_INTERNAL_FAIL (0x00030000UL) ///< An internal failure +#define FSP_ERR_SB_INVALID_ARG (0x00030001UL) ///< An invalid argument was entered +#define FSP_ERR_SB_UNSUPPORTED_FUNCTION (0x00030002UL) ///< Unsupported function executed +#define FSP_ERR_SB_INVALID_ALIGNMENT (0x00030003UL) ///< Data entered with incorrect alignment +#define FSP_ERR_SB_MANI_INVALID_MAGIC (0x00031000UL) ///< An invalid magic number is set +#define FSP_ERR_SB_MANI_UNSUPPORTED_VERSION (0x00031001UL) ///< Unsupported version is set +#define FSP_ERR_SB_MANI_OUT_OF_RANGE_LEN (0x00031002UL) ///< Out of range TLV Length is set +#define FSP_ERR_SB_MANI_TLV_FIELD_ERR (0x00031003UL) ///< Missing required TLV field +#define FSP_ERR_SB_MANI_TLV_INVALID_LEN (0x00031004UL) ///< The length exceeding the end of the manifest is specified in length of the TLV field +#define FSP_ERR_SB_MANI_INVALID_IMAGE_LEN (0x00031005UL) ///< An invalid image length is set +#define FSP_ERR_SB_MANI_MISMATCH_SIGN_ALGORITHM (0x00031006UL) ///< There is a wrong combination of signature algorithms +#define FSP_ERR_SB_MANI_UNSUPPORTED_ALGORITHM (0x00031007UL) ///< An algorithm was specified that the manifest does not support +#define FSP_ERR_SB_CRYPTO_FAIL (0x00032000UL) ///< Cryptographic processing failure +#define FSP_ERR_SB_CRYPTO_AUTH_FAIL (0x00032001UL) ///< Verification failed +#define FSP_ERR_SB_CRYPTO_UNSUPPORTED_ALGORITHM (0x00032002UL) ///< Unsupported algorithm +#define FSP_ERR_SB_CRYPTO_RESOURCE_CONFLICT (0x00032003UL) ///< CryptoIP is in use. +#define FSP_ERR_SB_CRYPTO_PARAM_ERR (0x00032004UL) ///< Parameter error + +/* RSA salt length */ + +/** + * When signing, the salt length is set to @ref RSIP_RSA_SALT_LENGTH_MAX or @ref RSIP_RSA_SALT_LENGTH_HASH, + * whichever is shorter. When verifying, the salt length is detected automatically. + */ +#define RSIP_RSA_SALT_LENGTH_AUTO (-1) + +/** + * The salt length is set to the hash length. + */ +#define RSIP_RSA_SALT_LENGTH_HASH (-2) + +/** + * The salt length is set to emLen - hLen - 2, where emLen is the same as the key length and hLen is the hash length. + */ +#define RSIP_RSA_SALT_LENGTH_MAX (-3) + +/* For internal use */ +#define RSIP_BYTE_SIZE_SHA_MESSAGE_BUFFER (128U) // rsip_sha_handle_t, rsip_hmac_handle_t +#define RSIP_WORD_SIZE_SHA_INTERNAL_STATE (20U) // rsip_sha_handle_t, rsip_hmac_handle_t + +/*********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/** + * Key types + * @deprecated + * - The following member will be renamed in the next major update. + * - @ref RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC to RSIP_KEY_TYPE_ECC_SECP192R1_PUBLIC + * - @ref RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE to RSIP_KEY_TYPE_ECC_SECP192R1_PRIVATE + * - @ref RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC to RSIP_KEY_TYPE_ECC_SECP224R1_PUBLIC + * - @ref RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE to RSIP_KEY_TYPE_ECC_SECP224R1_PRIVATE + * - @ref RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC to RSIP_KEY_TYPE_ECC_SECP256R1_PUBLIC + * - @ref RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE to RSIP_KEY_TYPE_ECC_SECP256R1_PRIVATE + */ +typedef enum e_rsip_key_type +{ + RSIP_KEY_TYPE_INVALID, ///< Invalid key + + RSIP_KEY_TYPE_AES_128, ///< AES-128 + RSIP_KEY_TYPE_AES_256, ///< AES-256 + + RSIP_KEY_TYPE_AES_128_XTS, ///< AES-128-XTS + RSIP_KEY_TYPE_AES_256_XTS, ///< AES-256-XTS + + RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC, ///< secp192r1 public key (also known as NIST P-192, prime192v1) + RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE, ///< secp192r1 private key (also known as NIST P-192, prime192v1) + RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC, ///< secp224r1 public key (also known as NIST P-224, prime224v1) + RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE, ///< secp224r1 private key (also known as NIST P-224, prime224v1) + RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC, ///< secp256r1 public key (also known as NIST P-256, prime256v1) + RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE, ///< secp256r1 private key (also known as NIST P-256, prime256v1) + + RSIP_KEY_TYPE_HMAC_SHA1, ///< HMAC-SHA1 + RSIP_KEY_TYPE_HMAC_SHA224, ///< HMAC-SHA224 + RSIP_KEY_TYPE_HMAC_SHA256, ///< HMAC-SHA256 + + RSIP_KEY_TYPE_KEY_UPDATE_KEY, ///< KUK (Key Update Key) + + RSIP_KEY_TYPE_SECURE_BOOT_DECRYPTION, ///< Image decryption key for secure boot (supported devices only) + + RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED, ///< RSA-1024 public key + RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED, ///< RSA-1024 private key + RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED, ///< RSA-2048 public key + RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED, ///< RSA-2048 private key + RSIP_KEY_TYPE_RSA_3072_PUBLIC, ///< RSA-3072 public key + RSIP_KEY_TYPE_RSA_3072_PRIVATE, ///< RSA-3072 private key + RSIP_KEY_TYPE_RSA_4096_PUBLIC, ///< RSA-4096 public key + RSIP_KEY_TYPE_RSA_4096_PRIVATE, ///< RSA-4096 private key + + RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC, ///< brainpoolP256r1 public key + RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE, ///< brainpoolP256r1 private key + + RSIP_KEY_TYPE_NUM, // Number of key types + + RSIP_KEY_TYPE_MAKE_ENUM_LONG = 0xFFFFFFFFUL // Make this enum 32-bit data +} rsip_key_type_t; + +/** + * Key pair types + * @deprecated + * - The following member will be renamed in the next major update. + * - @ref RSIP_KEY_PAIR_TYPE_ECC_secp192r1 to RSIP_KEY_PAIR_TYPE_ECC_SECP192R1 + * - @ref RSIP_KEY_PAIR_TYPE_ECC_secp224r1 to RSIP_KEY_PAIR_TYPE_ECC_SECP224R1 + * - @ref RSIP_KEY_PAIR_TYPE_ECC_secp256r1 to RSIP_KEY_PAIR_TYPE_ECC_SECP256R1 + */ +typedef enum e_rsip_key_pair_type +{ + RSIP_KEY_PAIR_TYPE_INVALID, ///< Invalid key pair type + + RSIP_KEY_PAIR_TYPE_ECC_secp192r1, ///< secp192r1 key pair (also known as NIST P-192, prime192v1) + RSIP_KEY_PAIR_TYPE_ECC_secp224r1, ///< secp224r1 key pair (also known as NIST P-224, prime224v1) + RSIP_KEY_PAIR_TYPE_ECC_secp256r1, ///< secp256r1 key pair (also known as NIST P-256, prime256v1) + RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1, ///< brainpoolP256r1 key pair + + RSIP_KEY_PAIR_TYPE_RSA_1024, ///< RSA-1024 key pair + RSIP_KEY_PAIR_TYPE_RSA_2048, ///< RSA-2048 key pair + RSIP_KEY_PAIR_TYPE_RSA_3072, ///< RSA-3072 key pair + RSIP_KEY_PAIR_TYPE_RSA_4096, ///< RSA-4096 key pair + + RSIP_KEY_PAIR_TYPE_NUM // Number of key pair types +} rsip_key_pair_type_t; + +/** Block cipher modes of operation for AES */ +typedef enum e_rsip_aes_mode +{ + RSIP_AES_MODE_ECB, ///< ECB (Electronic codebook) + RSIP_AES_MODE_CBC, ///< CBC (Cipher block chaining) + RSIP_AES_MODE_CTR, ///< CTR (Counter) + RSIP_AES_MODE_XTS ///< XTS (XEX-based tweaked-codebook mode with ciphertext stealing) +} rsip_aes_mode_t; + +/** Hash type */ +typedef enum e_rsip_hash_type +{ + RSIP_HASH_TYPE_SHA1, ///< SHA-1 + RSIP_HASH_TYPE_SHA224, ///< SHA-224 + RSIP_HASH_TYPE_SHA256, ///< SHA-256 + RSIP_HASH_TYPE_SHA384, ///< SHA-384 + RSIP_HASH_TYPE_SHA512, ///< SHA-512 + RSIP_HASH_TYPE_SHA512_224, ///< SHA-512/224 + RSIP_HASH_TYPE_SHA512_256 ///< SHA-512/256 +} rsip_hash_type_t; + +/** MGF type */ +typedef enum e_rsip_mgf_type +{ + RSIP_MGF_TYPE_MGF1_SHA1 = RSIP_HASH_TYPE_SHA1, ///< MGF1 with SHA-1 + RSIP_MGF_TYPE_MGF1_SHA224 = RSIP_HASH_TYPE_SHA224, ///< MGF1 with SHA-224 + RSIP_MGF_TYPE_MGF1_SHA256 = RSIP_HASH_TYPE_SHA256, ///< MGF1 with SHA-256 + RSIP_MGF_TYPE_MGF1_SHA384 = RSIP_HASH_TYPE_SHA384, ///< MGF1 with SHA-384 + RSIP_MGF_TYPE_MGF1_SHA512 = RSIP_HASH_TYPE_SHA512, ///< MGF1 with SHA-512 + RSIP_MGF_TYPE_MGF1_SHA512_224 = RSIP_HASH_TYPE_SHA512_224, ///< MGF1 with SHA-512/224 + RSIP_MGF_TYPE_MGF1_SHA512_256 = RSIP_HASH_TYPE_SHA512_256 ///< MGF1 with SHA-512/256 +} rsip_mgf_type_t; + +/** Password type. This enumerated type is used only on specific devices. */ +typedef enum e_password_type +{ + RSIP_PASSWORD_TYPE_JTAG_DEBUG_AUTHENTICATION_LEVEL1, ///< JTAG debug authentication level 1 + RSIP_PASSWORD_TYPE_JTAG_DEBUG_AUTHENTICATION_LEVEL2, ///< JTAG debug authentication level 2 +} rsip_password_type_t; + +/* State that specifies functions that can be called next. This enum is private. */ +typedef enum e_rsip_user_handle_state +{ + RSIP_USER_HANDLE_STATE_INIT, // Init function can be called. + RSIP_USER_HANDLE_STATE_UPDATE_EMPTY, // Update and Final function can be called. No data has been entered yet. + RSIP_USER_HANDLE_STATE_UPDATE // Update and Final function can be called. Some data has been entered. +} rsip_user_handle_state_t; + +/** Wrapped key structure for all supported algorithms. The struct length of each algorithm is defined by RSIP_BYTE_SIZE_WRAPPED_KEY macro. */ +typedef struct st_rsip_wrapped_key +{ + rsip_key_type_t type; ///< type of wrapped key + uint8_t value[]; ///< variable length array to store the key value +} rsip_wrapped_key_t; + +/** + * Byte size of encrypted key + * @deprecated + * - The following member will be renamed in the next major update. + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PUBLIC to RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_SECP192R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PRIVATE to RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_SECP192R1_PRIVATE + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PUBLIC to RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_SECP224R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PRIVATE to RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_SECP224R1_PRIVATE + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PUBLIC to RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_SECP256R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PRIVATE to RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_SECP256R1_PRIVATE + * - The following member will be obsoleted in the next major update. + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_MAX + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PUBLIC_MAX + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PRIVATE_MAX + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PUBLIC_MAX + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PRIVATE_MAX + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_MAX + * - @ref RSIP_BYTE_SIZE_ENCRYPTED_KEY_MAX + */ +typedef enum e_rsip_byte_size_encrypted_key +{ + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128 = 32U, ///< AES-128 + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256 = 48U, ///< AES-256 + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128_XTS = 48U, ///< AES-128-XTS + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256_XTS = 80U, ///< AES-256-XTS + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PUBLIC = 80U, ///< secp192r1 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PRIVATE = 48U, ///< secp192r1 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PUBLIC = 80U, ///< secp224r1 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PRIVATE = 48U, ///< secp224r1 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PUBLIC = 80U, ///< secp256r1 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PRIVATE = 48U, ///< secp256r1 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PUBLIC = 80U, ///< brainpoolP256r1 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PRIVATE = 48U, ///< brainpoolP256r1 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PUBLIC_ENHANCED = 160U, ///< RSA-1024 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PRIVATE_ENHANCED = 272U, ///< RSA-1024 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PUBLIC_ENHANCED = 288U, ///< RSA-2048 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PRIVATE_ENHANCED = 528U, ///< RSA-2048 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PUBLIC = 416U, ///< RSA-3072 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PRIVATE = 784U, ///< RSA-3072 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PUBLIC = 544U, ///< RSA-4096 public key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PRIVATE = 1040U, ///< RSA-4096 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA1 = 48U, ///< HMAC-SHA1 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA224 = 48U, ///< HMAC-SHA224 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA256 = 48U, ///< HMAC-SHA256 private key + RSIP_BYTE_SIZE_ENCRYPTED_KEY_KEY_UPDATE_KEY = 48U, ///< Key Update Key (KUK) + + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256_XTS, ///< Maximum length in AES keys + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PUBLIC_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PUBLIC, ///< Maximum length in ECC public keys + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_PRIVATE_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PRIVATE, ///< Maximum length in ECC private keys + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PUBLIC_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PUBLIC, ///< Maximum length in RSA public keys + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PRIVATE_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PRIVATE, ///< Maximum length in RSA private keys + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA256, ///< Maximum length in HMAC keys + RSIP_BYTE_SIZE_ENCRYPTED_KEY_MAX = + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_PRIVATE_MAX, ///< Maximum length in all RSIP keys +} rsip_byte_size_encrypted_key_t; + +/** Byte size of wrapped key (value) + * @deprecated + * - The following member will be renamed in the next major update. + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PUBLIC to RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_SECP192R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PRIVATE to RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_SECP192R1_PRIVATE + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PUBLIC to RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_SECP224R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PRIVATE to RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_SECP224R1_PRIVATE + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PUBLIC to RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_SECP256R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PRIVATE to RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_SECP256R1_PRIVATE + * - The following member will be obsoleted in the next major update. + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PUBLIC_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PRIVATE_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PUBLIC_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PRIVATE_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_MAX + */ +typedef enum e_rsip_byte_size_wrapped_key_value +{ + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128 = 48U, ///< AES-128 + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256 = 64U, ///< AES-256 + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128_XTS = 64U, ///< AES-128-XTS + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256_XTS = 96U, ///< AES-256-XTS + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PUBLIC = 96U, ///< secp192r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PRIVATE = 64U, ///< secp192r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PUBLIC = 96U, ///< secp224r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PRIVATE = 64U, ///< secp224r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PUBLIC = 96U, ///< secp256r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PRIVATE = 64U, ///< secp256r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PUBLIC = 96U, ///< brainpoolP256r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PRIVATE = 64U, ///< brainpoolP256r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PUBLIC_ENHANCED = 176U, ///< RSA-1024 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PRIVATE_ENHANCED = 288U, ///< RSA-1024 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PUBLIC_ENHANCED = 304U, ///< RSA-2048 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PRIVATE_ENHANCED = 544U, ///< RSA-2048 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PUBLIC = 432U, ///< RSA-3072 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PRIVATE = 800U, ///< RSA-3072 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PUBLIC = 560U, ///< RSA-4096 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PRIVATE = 1056U, ///< RSA-4096 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA1 = 64U, ///< HMAC-SHA1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA224 = 64U, ///< HMAC-SHA224 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA256 = 64U, ///< HMAC-SHA256 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_KEY_UPDATE_KEY = 64U, ///< Key Update Key (KUK) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256_XTS, ///< Maximum length in AES keys + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PUBLIC_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PUBLIC, ///< Maximum length in ECC public keys + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_PRIVATE_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PRIVATE, ///< Maximum length in ECC private keys + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PUBLIC_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PUBLIC, ///< Maximum length in RSA public keys + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PRIVATE_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PRIVATE, ///< Maximum length in RSA private keys + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA256, ///< Maximum length in HMAC keys + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_PRIVATE_MAX, ///< Maximum length in all RSIP keys +} rsip_byte_size_wrapped_key_value_t; + +/** + * Byte size of wrapped key (header + value) + * @deprecated + * - The following member will be renamed in the next major update. + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PUBLIC to RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_SECP192R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PRIVATE to RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_SECP192R1_PRIVATE + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PUBLIC to RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_SECP224R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PRIVATE to RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_SECP224R1_PRIVATE + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC to RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_SECP256R1_PUBLIC + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE to RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_SECP256R1_PRIVATE + * - The following member will be obsoleted in the next major update. + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_AES_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PUBLIC_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PRIVATE_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PUBLIC_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PRIVATE_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_MAX + * - @ref RSIP_BYTE_SIZE_WRAPPED_KEY_MAX + */ +typedef enum e_rsip_byte_size_wrapped_key +{ + RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128 = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128, ///< AES-128 + RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256 = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256, ///< AES-256 + RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128_XTS = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_128_XTS, ///< AES-128-XTS + RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256_XTS = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_AES_256_XTS, ///< AES-256-XTS + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PUBLIC = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PUBLIC, ///< secp192r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PRIVATE = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp192r1_PRIVATE, ///< secp192r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PUBLIC = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PUBLIC, ///< secp224r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PRIVATE = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp224r1_PRIVATE, ///< secp224r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PUBLIC, ///< secp256r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_secp256r1_PRIVATE, ///< secp256r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PUBLIC = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PUBLIC, ///< brainpoolP256r1 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PRIVATE = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_ECC_BRAINPOOLP256R1_PRIVATE, ///< brainpoolP256r1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PUBLIC_ENHANCED, ///< RSA-1024 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_1024_PRIVATE_ENHANCED, ///< RSA-1024 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PUBLIC_ENHANCED, ///< RSA-2048 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_2048_PRIVATE_ENHANCED, ///< RSA-2048 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PUBLIC, ///< RSA-3072 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_3072_PRIVATE, ///< RSA-3072 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PUBLIC, ///< RSA-4096 public key + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_RSA_4096_PRIVATE, ///< RSA-4096 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA1 = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA1, ///< HMAC-SHA1 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA224 = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA224, ///< HMAC-SHA224 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA256 = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_HMAC_SHA256, ///< HMAC-SHA256 private key + RSIP_BYTE_SIZE_WRAPPED_KEY_KEY_UPDATE_KEY = + sizeof(rsip_wrapped_key_t) + + RSIP_BYTE_SIZE_WRAPPED_KEY_VALUE_KEY_UPDATE_KEY, ///< Key Update Key (KUK) + + RSIP_BYTE_SIZE_WRAPPED_KEY_AES_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256_XTS, ///< Maximum length in AES keys + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PUBLIC_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC, ///< Maximum length in ECC public keys + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_PRIVATE_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE, ///< Maximum length in ECC private keys + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PUBLIC_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC, ///< Maximum length in RSA public keys + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PRIVATE_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE, ///< Maximum length in RSA private keys + RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA256, ///< Maximum length in HMAC keys + RSIP_BYTE_SIZE_WRAPPED_KEY_MAX = + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_PRIVATE_MAX, ///< Maximum length in all RSIP keys +} rsip_byte_size_wrapped_key_t; + +/** Working area for SHA cipher functions. DO NOT MODIFY. */ +typedef struct st_rsip_sha_handle +{ + rsip_hash_type_t type; // Hash type + uint8_t buffer[RSIP_BYTE_SIZE_SHA_MESSAGE_BUFFER]; // Stored message + uint32_t buffered_length; // Buffered message length + uint32_t total_length; // Total message length input to primitive + uint32_t block_size; // Block size + rsip_user_handle_state_t state; // Handle state + uint32_t internal_state[RSIP_WORD_SIZE_SHA_INTERNAL_STATE]; // Internal state +} rsip_sha_handle_t; + +/** Working area for HMAC cipher functions. DO NOT MODIFY. */ +typedef struct st_rsip_hmac_handle +{ + const void * p_primitive; // Pointer to primitive functions + uint8_t wrapped_key[RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_MAX]; // Stored wrapped key + uint8_t buffer[RSIP_BYTE_SIZE_SHA_MESSAGE_BUFFER]; // Stored message + uint32_t buffered_length; // Buffered message length + uint32_t total_length; // Total message length input to primitive + uint32_t block_size; // Block size + rsip_user_handle_state_t state; // Handle state + uint32_t internal_state[RSIP_WORD_SIZE_SHA_INTERNAL_STATE]; // Internal state + bool is_generate; // true: generate, false: verify +} rsip_hmac_handle_t; + +/** RSIP Control block. Allocate an instance specific control block to pass into the API calls. + * @par Implemented as + * - rsip_instance_ctrl_t + */ +typedef void rsip_ctrl_t; + +/** User configuration structure, used in open function */ +typedef struct st_rsip_cfg +{ + void const * p_extend; ///< Hardware-dependent configuration +} rsip_cfg_t; + +/** This structure encompasses everything that is needed to use an instance of this interface. */ +typedef struct st_rsip_instance +{ + rsip_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance + rsip_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance +} rsip_instance_t; + +/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */ +//FSP_FOOTER + +#endif /* R_RSIP_API_H */ + +/*******************************************************************************************************************//** + * @} (end addtogroup RSIP_API) + **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip.c b/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip.c new file mode 100644 index 000000000..c7338c838 --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip.c @@ -0,0 +1,704 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2024, Renesas Electronics + */ + +#include + +#include +#include +#include + +#define PTA_NAME "rsip.pta" + +extern rsip_instance_ctrl_t rsip_instance_ctrl; + +static TEE_Result keygenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_key_type_t key_type, rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[0].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (key_size > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_KeyGenerate(&rsip_instance_ctrl, key_type, wrapped_key); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_UNSUPPORTED: + return TEE_ERROR_NOT_SUPPORTED; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[0].memref.size = key_size; + + return TEE_SUCCESS; +} + + +static TEE_Result keypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_key_pair_type_t key_type, rsip_byte_size_wrapped_key_t pub_key_size, rsip_byte_size_wrapped_key_t pri_key_size) +{ + fsp_err_t err; + + rsip_wrapped_key_t * wrapped_pub_key; + rsip_wrapped_key_t * wrapped_pri_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pri_key = (rsip_wrapped_key_t *)params[0].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (pri_key_size > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_pub_key = (rsip_wrapped_key_t *)params[1].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (pub_key_size > params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_KeyPairGenerate(&rsip_instance_ctrl, key_type, wrapped_pub_key, wrapped_pri_key); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_UNSUPPORTED: + return TEE_ERROR_NOT_SUPPORTED; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[0].memref.size = pri_key_size; + params[1].memref.size = pub_key_size; + + return TEE_SUCCESS; +} + + +static TEE_Result randomnumbergenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * random; + + const uint32_t random_length = 16; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + random = (uint8_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_RandomNumberGenerate(&rsip_instance_ctrl, random); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[0].memref.size = random_length; + + return TEE_SUCCESS; +} + + +static TEE_Result keyimportwithkuk(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_key_type_t key_type, rsip_byte_size_encrypted_key_t enc_key_size, rsip_byte_size_wrapped_key_t wrap_key_size) +{ + fsp_err_t err; + + uint8_t * initial_vector; + uint8_t * encrypted_key; + rsip_wrapped_key_t * key_update_key; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + encrypted_key = (uint8_t *)params[1].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (enc_key_size > params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + key_update_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (RSIP_BYTE_SIZE_WRAPPED_KEY_KEY_UPDATE_KEY != params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[3].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[3].memref.buffer, uint32_t)) || (wrap_key_size > params[3].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_KeyImportWithKUK(&rsip_instance_ctrl, key_update_key, initial_vector, key_type, encrypted_key, wrapped_key); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[3].memref.size = wrap_key_size; + + return TEE_SUCCESS; +} + + +static TEE_Result rsapublickeyexport(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t wrap_key_size, uint32_t key_size_n, uint32_t key_size_e) +{ + fsp_err_t err; + + rsip_wrapped_key_t * wrapped_key; + uint32_t *p_raw_public_key_n; + uint32_t *p_raw_public_key_e; + + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[0].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (wrap_key_size > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (key_size_n > params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (key_size_e > params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_RSAPublicKeyExport(wrapped_key, (uint8_t const ** const)&p_raw_public_key_n, + (uint8_t const ** const)&p_raw_public_key_e); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + default: + return TEE_ERROR_BAD_STATE; + } + + memcpy(params[1].memref.buffer, p_raw_public_key_n, key_size_n); + memcpy(params[2].memref.buffer, p_raw_public_key_e, key_size_e); + params[1].memref.size = key_size_n; + params[2].memref.size = key_size_e; + + return TEE_SUCCESS; +} + +static TEE_Result eccpublickeyexport(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t wrap_key_size, uint32_t key_size_qx, uint32_t key_size_qy) +{ + fsp_err_t err; + + rsip_wrapped_key_t * wrapped_key; + uint32_t *p_raw_public_key_qx; + uint32_t *p_raw_public_key_qy; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[0].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (wrap_key_size > params[0].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (key_size_qx > params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (key_size_qy > params[2].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_ECCPublicKeyExport(wrapped_key,(uint8_t const ** const)&p_raw_public_key_qx, + (uint8_t const ** const)&p_raw_public_key_qy); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + default: + return TEE_ERROR_GENERIC; + } + + memcpy(params[1].memref.buffer, p_raw_public_key_qx, key_size_qx); + memcpy(params[2].memref.buffer, p_raw_public_key_qy, key_size_qy); + params[1].memref.size = key_size_qx; + params[2].memref.size = key_size_qy; + + + return TEE_SUCCESS; +} + +static TEE_Result keygenerate_aes128(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keygenerate(types, params, RSIP_KEY_TYPE_AES_128, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128); +} + +static TEE_Result keygenerate_aes256(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keygenerate(types, params, RSIP_KEY_TYPE_AES_256, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256); +} + +static TEE_Result keygenerate_aes128_xts(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keygenerate(types, params, RSIP_KEY_TYPE_AES_128_XTS, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128_XTS); +} + +static TEE_Result keygenerate_aes256_xts(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keygenerate(types, params, RSIP_KEY_TYPE_AES_256_XTS, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256_XTS); +} + +static TEE_Result keypairgenerate_rsa1024(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keypairgenerate(types, params, RSIP_KEY_PAIR_TYPE_RSA_1024, + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED); +} + +static TEE_Result keypairgenerate_rsa2048(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keypairgenerate(types, params, RSIP_KEY_PAIR_TYPE_RSA_2048, + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED); +} + +static TEE_Result keypairgenerate_rsa3072(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keypairgenerate(types, params, RSIP_KEY_PAIR_TYPE_RSA_3072, + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE); +} + +static TEE_Result keypairgenerate_rsa4096(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keypairgenerate(types, params, RSIP_KEY_PAIR_TYPE_RSA_4096, + RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE); +} + +static TEE_Result keypairgenerate_ecc_secp192r1(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keypairgenerate(types, params, RSIP_KEY_PAIR_TYPE_ECC_secp192r1, + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PUBLIC, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PRIVATE); +} + +static TEE_Result keypairgenerate_ecc_secp224r1(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keypairgenerate(types, params, RSIP_KEY_PAIR_TYPE_ECC_secp224r1, + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PUBLIC, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PRIVATE); +} + +static TEE_Result keypairgenerate_ecc_secp256r1(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keypairgenerate(types, params, RSIP_KEY_PAIR_TYPE_ECC_secp256r1, + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE); +} + +static TEE_Result keypairgenerate_brainpoolp256r1(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keypairgenerate(types, params, RSIP_KEY_PAIR_TYPE_ECC_BRAINPOOLP256R1, + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PUBLIC, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PRIVATE); +} + + +static TEE_Result keyimportwithkuk_aes128(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_AES_128, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128); +} + +static TEE_Result keyimportwithkuk_aes256(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_AES_256, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256); +} + +static TEE_Result keyimportwithkuk_aes128_xts(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_AES_128_XTS, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_128_XTS, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128_XTS); +} + +static TEE_Result keyimportwithkuk_aes256_xts(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_AES_256_XTS, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_AES_256_XTS, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256_XTS); +} + +static TEE_Result keyimportwithkuk_rsa1024_public(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_RSA_1024_PUBLIC_ENHANCED, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PUBLIC_ENHANCED, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED); +} + +static TEE_Result keyimportwithkuk_rsa1024_private(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_RSA_1024_PRIVATE_ENHANCED, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_1024_PRIVATE_ENHANCED, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED); +} + +static TEE_Result keyimportwithkuk_rsa2048_public(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_RSA_2048_PUBLIC_ENHANCED, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PUBLIC_ENHANCED, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED); +} + +static TEE_Result keyimportwithkuk_rsa2048_private(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_RSA_2048_PRIVATE_ENHANCED, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_2048_PRIVATE_ENHANCED, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED); +} + +static TEE_Result keyimportwithkuk_rsa3072_public(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_RSA_3072_PUBLIC, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PUBLIC, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC); +} + +static TEE_Result keyimportwithkuk_rsa3072_private(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_RSA_3072_PRIVATE, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_3072_PRIVATE, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE); +} + +static TEE_Result keyimportwithkuk_rsa4096_public(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_RSA_4096_PUBLIC, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PUBLIC, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC); +} + +static TEE_Result keyimportwithkuk_rsa4096_private(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_RSA_4096_PRIVATE, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_RSA_4096_PRIVATE, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE); +} + +static TEE_Result keyimportwithkuk_secp192r1_public(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_ECC_secp192r1_PUBLIC, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PUBLIC, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PUBLIC); +} + +static TEE_Result keyimportwithkuk_secp192r1_private(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_ECC_secp192r1_PRIVATE, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp192r1_PRIVATE, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PRIVATE); +} + +static TEE_Result keyimportwithkuk_secp224r1_public(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_ECC_secp224r1_PUBLIC, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PUBLIC, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PUBLIC); +} + +static TEE_Result keyimportwithkuk_secp224r1_private(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_ECC_secp224r1_PRIVATE, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp224r1_PRIVATE, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PRIVATE); +} + +static TEE_Result keyimportwithkuk_secp256r1_public(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_ECC_secp256r1_PUBLIC, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PUBLIC, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC); +} + +static TEE_Result keyimportwithkuk_secp256r1_private(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_ECC_secp256r1_PRIVATE, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_secp256r1_PRIVATE, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE); +} + +static TEE_Result keyimportwithkuk_brainpoolp256r1_public(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PUBLIC, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PUBLIC, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PUBLIC); +} + +static TEE_Result keyimportwithkuk_brainpoolp256r1_private(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_ECC_BRAINPOOLP256R1_PRIVATE, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PRIVATE, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PRIVATE); +} + +static TEE_Result keyimportwithkuk_hmac_sha1(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_HMAC_SHA1, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA1, RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA1); +} + +static TEE_Result keyimportwithkuk_hmac_sha224(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_HMAC_SHA224, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA224, RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA224); +} + +static TEE_Result keyimportwithkuk_hmac_sha256(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return keyimportwithkuk(types, params, RSIP_KEY_TYPE_HMAC_SHA256, + RSIP_BYTE_SIZE_ENCRYPTED_KEY_HMAC_SHA256, RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA256); +} + +static TEE_Result rsa1024publickeyexport(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsapublickeyexport(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED, + WRAPPED_KEY_BYTE_SIZE_RSA_1024_PUBLIC_N, WRAPPED_KEY_BYTE_SIZE_RSA_1024_PUBLIC_E); +} + +static TEE_Result rsa2048publickeyexport(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsapublickeyexport(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED, + WRAPPED_KEY_BYTE_SIZE_RSA_2048_PUBLIC_N, WRAPPED_KEY_BYTE_SIZE_RSA_2048_PUBLIC_E); +} + +static TEE_Result rsa3072publickeyexport(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsapublickeyexport(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC, + WRAPPED_KEY_BYTE_SIZE_RSA_3072_PUBLIC_N, WRAPPED_KEY_BYTE_SIZE_RSA_3072_PUBLIC_E); +} + +static TEE_Result rsa4096publickeyexport(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsapublickeyexport(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC, + WRAPPED_KEY_BYTE_SIZE_RSA_4096_PUBLIC_N, WRAPPED_KEY_BYTE_SIZE_RSA_4096_PUBLIC_E); +} + +static TEE_Result eccsecp192r1publickeyexport(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return eccpublickeyexport(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PUBLIC, + WRAPPED_KEY_BYTE_SIZE_ECC_secp192r1_PUBLIC_QX, WRAPPED_KEY_BYTE_SIZE_ECC_secp192r1_PUBLIC_QY); +} + +static TEE_Result eccsecp224r1publickeyexport(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return eccpublickeyexport(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PUBLIC, + WRAPPED_KEY_BYTE_SIZE_ECC_secp224r1_PUBLIC_QX, WRAPPED_KEY_BYTE_SIZE_ECC_secp224r1_PUBLIC_QY); +} + +static TEE_Result eccsecp256r1publickeyexport(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return eccpublickeyexport(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC, + WRAPPED_KEY_BYTE_SIZE_ECC_secp256r1_PUBLIC_QX, WRAPPED_KEY_BYTE_SIZE_ECC_secp256r1_PUBLIC_QY); +} + +static TEE_Result eccbrainpoolp256r1publickeyexport(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return eccpublickeyexport(types, params, RSIP_BYTE_SIZE_ENCRYPTED_KEY_ECC_BRAINPOOLP256R1_PUBLIC, + WRAPPED_KEY_BYTE_SIZE_ECC_BRAINPOOLP256R1_PUBLIC_QX, WRAPPED_KEY_BYTE_SIZE_ECC_BRAINPOOLP256R1_PUBLIC_QY); +} + + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + EMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_AES128_WrappedKeyGenerate : + return keygenerate_aes128(ptypes, params); + case PTA_CMD_AES256_WrappedKeyGenerate : + return keygenerate_aes256(ptypes, params); + case PTA_CMD_AES128_XTS_WrappedKeyGenerate : + return keygenerate_aes128_xts(ptypes, params); + case PTA_CMD_AES256_XTS_WrappedKeyGenerate : + return keygenerate_aes256_xts(ptypes, params); + + case PTA_CMD_RSA1024_WrappedKeyPairGenerate : + return keypairgenerate_rsa1024(ptypes, params); + case PTA_CMD_RSA2048_WrappedKeyPairGenerate : + return keypairgenerate_rsa2048(ptypes, params); + case PTA_CMD_RSA3072_WrappedKeyPairGenerate : + return keypairgenerate_rsa3072(ptypes, params); + case PTA_CMD_RSA4096_WrappedKeyPairGenerate : + return keypairgenerate_rsa4096(ptypes, params); + case PTA_CMD_ECC_secp192r1_WrappedKeyPairGenerate : + return keypairgenerate_ecc_secp192r1(ptypes, params); + case PTA_CMD_ECC_secp224r1_WrappedKeyPairGenerate : + return keypairgenerate_ecc_secp224r1(ptypes, params); + case PTA_CMD_ECC_secp256r1_WrappedKeyPairGenerate : + return keypairgenerate_ecc_secp256r1(ptypes, params); + case PTA_CMD_ECC_BrainpoolP256r1_WrappedKeyPairGenerate : + return keypairgenerate_brainpoolp256r1(ptypes, params); + + case PTA_CMD_RandomNumberGenerate : + return randomnumbergenerate(ptypes, params); + + case PTA_CMD_AES128_EncryptedKeyWrap : + return keyimportwithkuk_aes128(ptypes, params); + case PTA_CMD_AES256_EncryptedKeyWrap : + return keyimportwithkuk_aes256(ptypes, params); + case PTA_CMD_AES128_XTS_EncryptedKeyWrap : + return keyimportwithkuk_aes128_xts(ptypes, params); + case PTA_CMD_AES256_XTS_EncryptedKeyWrap : + return keyimportwithkuk_aes256_xts(ptypes, params); + + case PTA_CMD_RSA1024_EncryptedPublicKeyWrap : + return keyimportwithkuk_rsa1024_public(ptypes, params); + case PTA_CMD_RSA1024_EncryptedPrivateKeyWrap : + return keyimportwithkuk_rsa1024_private(ptypes, params); + case PTA_CMD_RSA2048_EncryptedPublicKeyWrap : + return keyimportwithkuk_rsa2048_public(ptypes, params); + case PTA_CMD_RSA2048_EncryptedPrivateKeyWrap : + return keyimportwithkuk_rsa2048_private(ptypes, params); + case PTA_CMD_RSA3072_EncryptedPublicKeyWrap : + return keyimportwithkuk_rsa3072_public(ptypes, params); + case PTA_CMD_RSA3072_EncryptedPrivateKeyWrap : + return keyimportwithkuk_rsa3072_private(ptypes, params); + case PTA_CMD_RSA4096_EncryptedPublicKeyWrap : + return keyimportwithkuk_rsa4096_public(ptypes, params); + case PTA_CMD_RSA4096_EncryptedPrivateKeyWrap : + return keyimportwithkuk_rsa4096_private(ptypes, params); + + case PTA_CMD_ECC_secp192r1_EncryptedPublicKeyWrap : + return keyimportwithkuk_secp192r1_public(ptypes, params); + case PTA_CMD_ECC_secp224r1_EncryptedPublicKeyWrap : + return keyimportwithkuk_secp224r1_public(ptypes, params); + case PTA_CMD_ECC_secp256r1_EncryptedPublicKeyWrap : + return keyimportwithkuk_secp256r1_public(ptypes, params); + case PTA_CMD_ECC_BrainpoolP256r1_EncryptedPublicKeyWrap : + return keyimportwithkuk_brainpoolp256r1_public(ptypes, params); + + case PTA_CMD_ECC_secp192r1_EncryptedPrivateKeyWrap : + return keyimportwithkuk_secp192r1_private(ptypes, params); + case PTA_CMD_ECC_secp224r1_EncryptedPrivateKeyWrap : + return keyimportwithkuk_secp224r1_private(ptypes, params); + case PTA_CMD_ECC_secp256r1_EncryptedPrivateKeyWrap : + return keyimportwithkuk_secp256r1_private(ptypes, params); + case PTA_CMD_ECC_BrainpoolP256r1_EncryptedPrivateKeyWrap : + return keyimportwithkuk_brainpoolp256r1_private(ptypes, params); + + case PTA_CMD_HMAC_SHA1_EncryptedKeyWrap: + return keyimportwithkuk_hmac_sha1(ptypes, params); + case PTA_CMD_HMAC_SHA224_EncryptedKeyWrap: + return keyimportwithkuk_hmac_sha224(ptypes, params); + case PTA_CMD_HMAC_SHA256_EncryptedKeyWrap: + return keyimportwithkuk_hmac_sha256(ptypes, params); + + case PTA_CMD_RSA_1024_Public_Key_Export : + return rsa1024publickeyexport(ptypes, params); + case PTA_CMD_RSA_2048_Public_Key_Export : + return rsa2048publickeyexport(ptypes, params); + case PTA_CMD_RSA_3072_Public_Key_Export : + return rsa3072publickeyexport(ptypes, params); + case PTA_CMD_RSA_4096_Public_Key_Export : + return rsa4096publickeyexport(ptypes, params); + + case PTA_CMD_ECC_secp192r1_Public_Key_Export : + return eccsecp192r1publickeyexport(ptypes, params); + case PTA_CMD_ECC_secp224r1_Public_Key_Export : + return eccsecp224r1publickeyexport(ptypes, params); + case PTA_CMD_ECC_secp256r1_Public_Key_Export : + return eccsecp256r1publickeyexport(ptypes, params); + case PTA_CMD_ECC_BrainpoolP256r1_Public_Key_Export : + return eccbrainpoolp256r1publickeyexport(ptypes, params); + + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_RSIP_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_aes.c b/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_aes.c new file mode 100644 index 000000000..84794fec9 --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_aes.c @@ -0,0 +1,1203 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2024, Renesas Electronics + */ + +#include + +#include +#include + +#define PTA_NAME "rsip_aes.pta" + +extern rsip_instance_ctrl_t rsip_instance_ctrl; + +static TEE_Result aes_cipher_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_aes_mode_t mode, rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + rsip_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + initial_vector = (uint8_t *)params[1].memref.buffer; + if (mode != RSIP_AES_MODE_ECB) { + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + EMSG("initial_vector err"); + return TEE_ERROR_BAD_PARAMETERS; + } + } else { + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + } + + wrapped_key = (rsip_wrapped_key_t *)params[0].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (key_size > params[0].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_Cipher_EncryptInit(&rsip_instance_ctrl, mode, wrapped_key, initial_vector); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes_cipher_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * plain; + uint8_t * cipher; + uint32_t plain_length; + uint32_t cipher_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[0].memref.buffer; + plain_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("plain err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (cipher_length < plain_length)) { + EMSG("cipher err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_Cipher_EncryptUpdate(&rsip_instance_ctrl, plain, cipher, plain_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes_cipher_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * cipher; + uint32_t cipher_length = 0; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[0].memref.buffer; + cipher_length = (uint32_t)params[0].memref.size; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (AES_BLOCK_LEN > params[0].memref.size)) { + EMSG("cipher err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_Cipher_EncryptFinal(&rsip_instance_ctrl, cipher, &cipher_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[0].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes_cipher_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_aes_mode_t mode, rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + rsip_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + + initial_vector = (uint8_t *)params[1].memref.buffer; + if (mode != RSIP_AES_MODE_ECB) { + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + EMSG("initial_vector err"); + return TEE_ERROR_BAD_PARAMETERS; + } + } else { + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + } + + wrapped_key = (rsip_wrapped_key_t *)params[0].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (key_size > params[0].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_Cipher_DecryptInit(&rsip_instance_ctrl, mode, wrapped_key, initial_vector); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes_cipher_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * cipher; + uint8_t * plain; + uint32_t cipher_length; + uint32_t plain_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[0].memref.buffer; + cipher_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("cipher err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (plain_length < cipher_length)) { + EMSG("plain err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_Cipher_DecryptUpdate(&rsip_instance_ctrl, cipher, plain, cipher_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes_cipher_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * plain; + uint32_t plain_length = 0; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[0].memref.buffer; + plain_length = (uint32_t)params[0].memref.size; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (AES_BLOCK_LEN > params[0].memref.size) ) { + EMSG("plain err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_Cipher_DecryptFinal(&rsip_instance_ctrl, plain, &plain_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[0].memref.size = plain_length; + + return TEE_SUCCESS; +} + + +static TEE_Result aes_cmac_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[0].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (key_size > params[0].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_CMAC_GenerateInit(&rsip_instance_ctrl, wrapped_key); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes_cmac_generateupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[0].memref.buffer; + message_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_CMAC_GenerateUpdate(&rsip_instance_ctrl, message, message_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes_cmac_generatefinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * mac; + uint32_t mac_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + mac = (uint8_t *)params[0].memref.buffer; + mac_length = params[0].memref.size; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (MAC_BYTE_SIZE > mac_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_CMAC_GenerateFinal(&rsip_instance_ctrl, mac); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[0].memref.size = RSIP_BYTE_SIZE_AES_BLOCK; + + return TEE_SUCCESS; +} + +static TEE_Result aes_cmac_verifyinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[0].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (key_size > params[0].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_CMAC_VerifyInit(&rsip_instance_ctrl, wrapped_key); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes_cmac_verifyupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[0].memref.buffer; + message_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_CMAC_VerifyUpdate(&rsip_instance_ctrl, message, message_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes_cmac_verifyfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * mac; + uint32_t mac_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + mac = (uint8_t *)params[0].memref.buffer; + mac_length = params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("mac err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_CMAC_VerifyFinal(&rsip_instance_ctrl, mac, mac_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_AUTHENTICATION: + return TEE_ERROR_MAC_INVALID; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes_gcm_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + rsip_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + uint32_t initial_vector_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[0].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (key_size > params[0].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[1].memref.buffer; + initial_vector_length = params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_GCM_EncryptInit(&rsip_instance_ctrl, wrapped_key, initial_vector, initial_vector_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes_gcm_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * plain; + uint8_t * cipher; + uint8_t * aad; + uint32_t plain_length; + uint32_t cipher_length; + uint32_t aad_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[0].memref.buffer; + plain_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + cipher_length = (uint32_t)params[1].memref.size; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (cipher_length < plain_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + aad = (uint8_t *)params[2].memref.buffer; + aad_length = (uint32_t)params[2].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_GCM_EncryptUpdate(&rsip_instance_ctrl, plain, cipher, plain_length, aad, aad_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes_gcm_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * cipher; + uint8_t * p_tag; + uint32_t remaining_length = 0; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[0].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (AES_BLOCK_LEN > params[0].memref.size)) { + EMSG("cipher err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + p_tag = (uint8_t *)params[1].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (AES_BLOCK_LEN > params[1].memref.size)) { + EMSG("tag err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_GCM_EncryptFinal(&rsip_instance_ctrl, cipher, &remaining_length, p_tag); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[0].memref.size = remaining_length; + params[1].memref.size = RSIP_BYTE_SIZE_AES_BLOCK; // tag size 16byte + + return TEE_SUCCESS; +} + + +static TEE_Result aes_gcm_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + rsip_wrapped_key_t * wrapped_key; + uint8_t * initial_vector; + uint32_t initial_vector_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[0].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (key_size > params[0].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + initial_vector = (uint8_t *)params[1].memref.buffer; + initial_vector_length = params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_GCM_DecryptInit(&rsip_instance_ctrl, wrapped_key, initial_vector, initial_vector_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes_gcm_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * cipher; + uint8_t * plain; + uint8_t * aad; + uint32_t cipher_length; + uint32_t plain_length; + uint32_t aad_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[0].memref.buffer; + cipher_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (plain_length < cipher_length)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + aad = (uint8_t *)params[2].memref.buffer; + aad_length = (uint32_t)params[2].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_GCM_DecryptUpdate(&rsip_instance_ctrl, cipher, plain, cipher_length, aad, aad_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = cipher_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes_gcm_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + uint8_t * plain; + uint8_t * p_tag; + uint32_t p_tag_length; + uint32_t remaining_length = 0; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[0].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) || (AES_BLOCK_LEN > params[0].memref.size)) { + EMSG("plain err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + p_tag = (uint8_t *)params[1].memref.buffer; + p_tag_length = params[1].memref.size; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (AES_BLOCK_LEN > params[1].memref.size)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_AES_GCM_DecryptFinal(&rsip_instance_ctrl, plain, &remaining_length, p_tag, p_tag_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_AUTHENTICATION: + return TEE_ERROR_MAC_INVALID; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[0].memref.size = remaining_length; + + return TEE_SUCCESS; +} + +static TEE_Result aes128ecb_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_encryptinit(types, params, RSIP_AES_MODE_ECB, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128); +} + +static TEE_Result aes256ecb_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_encryptinit(types, params, RSIP_AES_MODE_ECB, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256); +} + +static TEE_Result aes128cbc_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_encryptinit(types, params, RSIP_AES_MODE_CBC, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128); +} + +static TEE_Result aes256cbc_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_encryptinit(types, params, RSIP_AES_MODE_CBC, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256); +} + +static TEE_Result aes128ctr_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_encryptinit(types, params, RSIP_AES_MODE_CTR, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128); +} + +static TEE_Result aes256ctr_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_encryptinit(types, params, RSIP_AES_MODE_CTR, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256); +} + +static TEE_Result aes128xts_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_encryptinit(types, params, RSIP_AES_MODE_XTS, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128_XTS); +} + +static TEE_Result aes256xts_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_encryptinit(types, params, RSIP_AES_MODE_XTS, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256_XTS); +} + +static TEE_Result aes128ecb_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_decryptinit(types, params, RSIP_AES_MODE_ECB, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128); +} + +static TEE_Result aes256ecb_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_decryptinit(types, params, RSIP_AES_MODE_ECB, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256); +} + +static TEE_Result aes128cbc_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_decryptinit(types, params, RSIP_AES_MODE_CBC, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128); +} + +static TEE_Result aes256cbc_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_decryptinit(types, params, RSIP_AES_MODE_CBC, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256); +} + +static TEE_Result aes128ctr_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_decryptinit(types, params, RSIP_AES_MODE_CTR, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128); +} + +static TEE_Result aes256ctr_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_decryptinit(types, params, RSIP_AES_MODE_CTR, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256); +} + +static TEE_Result aes128xts_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_decryptinit(types, params, RSIP_AES_MODE_XTS, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128_XTS); +} + +static TEE_Result aes256xts_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cipher_decryptinit(types, params, RSIP_AES_MODE_XTS, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256_XTS); +} + +static TEE_Result aes128cmac_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cmac_generateinit(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128); +} + +static TEE_Result aes256cmac_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cmac_generateinit(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256); +} + +static TEE_Result aes128cmac_verifyinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cmac_verifyinit(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128); +} + +static TEE_Result aes256cmac_verifyinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_cmac_verifyinit(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256); +} + +static TEE_Result aes128gcm_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_gcm_encryptinit(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128); +} + +static TEE_Result aes256gcm_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_gcm_encryptinit(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256); +} + +static TEE_Result aes128gcm_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_gcm_decryptinit(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128); +} + +static TEE_Result aes256gcm_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return aes_gcm_decryptinit(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256); +} + + +static TEE_Result invoke_command( + void *session __unused, + uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS] + ) +{ + EMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_AES128ECB_EncryptInit : + return aes128ecb_encryptinit(ptypes, params); + case PTA_CMD_AES256ECB_EncryptInit : + return aes256ecb_encryptinit(ptypes, params); + + case PTA_CMD_AES128CBC_EncryptInit : + return aes128cbc_encryptinit(ptypes, params); + case PTA_CMD_AES256CBC_EncryptInit : + return aes256cbc_encryptinit(ptypes, params); + + case PTA_CMD_AES128CTR_EncryptInit : + return aes128ctr_encryptinit(ptypes, params); + case PTA_CMD_AES256CTR_EncryptInit : + return aes256ctr_encryptinit(ptypes, params); + + case PTA_CMD_AES128XTS_EncryptInit : + return aes128xts_encryptinit(ptypes, params); + case PTA_CMD_AES256XTS_EncryptInit : + return aes256xts_encryptinit(ptypes, params); + + case PTA_CMD_AES128ECB_EncryptUpdate : + case PTA_CMD_AES256ECB_EncryptUpdate : + case PTA_CMD_AES128CBC_EncryptUpdate : + case PTA_CMD_AES256CBC_EncryptUpdate : + case PTA_CMD_AES128CTR_EncryptUpdate : + case PTA_CMD_AES256CTR_EncryptUpdate : + case PTA_CMD_AES128XTS_EncryptUpdate : + case PTA_CMD_AES256XTS_EncryptUpdate : + return aes_cipher_encryptupdate(ptypes, params); + + case PTA_CMD_AES128ECB_EncryptFinal : + case PTA_CMD_AES256ECB_EncryptFinal : + case PTA_CMD_AES128CBC_EncryptFinal : + case PTA_CMD_AES256CBC_EncryptFinal : + case PTA_CMD_AES128CTR_EncryptFinal : + case PTA_CMD_AES256CTR_EncryptFinal : + case PTA_CMD_AES128XTS_EncryptFinal : + case PTA_CMD_AES256XTS_EncryptFinal : + return aes_cipher_encryptfinal(ptypes, params); + + case PTA_CMD_AES128ECB_DecryptInit : + return aes128ecb_decryptinit(ptypes, params); + case PTA_CMD_AES256ECB_DecryptInit : + return aes256ecb_decryptinit(ptypes, params); + + case PTA_CMD_AES128CBC_DecryptInit : + return aes128cbc_decryptinit(ptypes, params); + case PTA_CMD_AES256CBC_DecryptInit : + return aes256cbc_decryptinit(ptypes, params); + + case PTA_CMD_AES128CTR_DecryptInit : + return aes128ctr_decryptinit(ptypes, params); + case PTA_CMD_AES256CTR_DecryptInit : + return aes256ctr_decryptinit(ptypes, params); + + case PTA_CMD_AES128XTS_DecryptInit : + return aes128xts_decryptinit(ptypes, params); + case PTA_CMD_AES256XTS_DecryptInit : + return aes256xts_decryptinit(ptypes, params); + + case PTA_CMD_AES128ECB_DecryptUpdate : + case PTA_CMD_AES256ECB_DecryptUpdate : + case PTA_CMD_AES128CBC_DecryptUpdate : + case PTA_CMD_AES256CBC_DecryptUpdate : + case PTA_CMD_AES128CTR_DecryptUpdate : + case PTA_CMD_AES256CTR_DecryptUpdate : + case PTA_CMD_AES128XTS_DecryptUpdate : + case PTA_CMD_AES256XTS_DecryptUpdate : + return aes_cipher_decryptupdate(ptypes, params); + case PTA_CMD_AES128ECB_DecryptFinal : + case PTA_CMD_AES256ECB_DecryptFinal : + case PTA_CMD_AES128CBC_DecryptFinal : + case PTA_CMD_AES256CBC_DecryptFinal : + case PTA_CMD_AES128CTR_DecryptFinal : + case PTA_CMD_AES256CTR_DecryptFinal : + case PTA_CMD_AES128XTS_DecryptFinal : + case PTA_CMD_AES256XTS_DecryptFinal : + return aes_cipher_decryptfinal(ptypes, params); + + case PTA_CMD_AES128CMAC_GenerateInit : + return aes128cmac_generateinit(ptypes, params); + case PTA_CMD_AES256CMAC_GenerateInit : + return aes256cmac_generateinit(ptypes, params); + case PTA_CMD_AES128CMAC_GenerateUpdate : + case PTA_CMD_AES256CMAC_GenerateUpdate : + return aes_cmac_generateupdate(ptypes, params); + case PTA_CMD_AES128CMAC_GenerateFinal : + case PTA_CMD_AES256CMAC_GenerateFinal : + return aes_cmac_generatefinal(ptypes, params); + case PTA_CMD_AES128CMAC_VerifyInit : + return aes128cmac_verifyinit(ptypes, params); + case PTA_CMD_AES256CMAC_VerifyInit : + return aes256cmac_verifyinit(ptypes, params); + case PTA_CMD_AES128CMAC_VerifyUpdate : + case PTA_CMD_AES256CMAC_VerifyUpdate : + return aes_cmac_verifyupdate(ptypes, params); + case PTA_CMD_AES128CMAC_VerifyFinal : + case PTA_CMD_AES256CMAC_VerifyFinal : + return aes_cmac_verifyfinal(ptypes, params); + + case PTA_CMD_AES128GCM_EncryptInit : + return aes128gcm_encryptinit(ptypes, params); + case PTA_CMD_AES256GCM_EncryptInit : + return aes256gcm_encryptinit(ptypes, params); + + case PTA_CMD_AES128GCM_EncryptUpdate: + case PTA_CMD_AES256GCM_EncryptUpdate: + return aes_gcm_encryptupdate(ptypes, params); + + case PTA_CMD_AES128GCM_EncryptFinal : + case PTA_CMD_AES256GCM_EncryptFinal : + return aes_gcm_encryptfinal(ptypes, params); + + case PTA_CMD_AES128GCM_DecryptInit : + return aes128gcm_decryptinit(ptypes, params); + case PTA_CMD_AES256GCM_DecryptInit : + return aes256gcm_decryptinit(ptypes, params); + + case PTA_CMD_AES128GCM_DecryptUpdate: + case PTA_CMD_AES256GCM_DecryptUpdate: + return aes_gcm_decryptupdate(ptypes, params); + + case PTA_CMD_AES128GCM_DecryptFinal : + case PTA_CMD_AES256GCM_DecryptFinal : + return aes_gcm_decryptfinal(ptypes, params); + + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register( + .uuid = PTA_RSIP_AES_UUID, + .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS | TA_FLAG_DEVICE_ENUM, + .invoke_command_entry_point = invoke_command +); diff --git a/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_ecc.c b/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_ecc.c new file mode 100644 index 000000000..82db38272 --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_ecc.c @@ -0,0 +1,710 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2024, Renesas Electronics + */ + +#include +#include + +#include +#include +#include + +#define PTA_NAME "rsip_ecc.pta" + +extern rsip_instance_ctrl_t rsip_instance_ctrl; + + +static TEE_Result generate_hash(uint8_t const *const message, uint32_t const message_length, + rsip_hash_type_t hash_type, uint8_t *digest) +{ + fsp_err_t err; + + err = R_RSIP_SHA_Compute(&rsip_instance_ctrl, hash_type, message, message_length, digest); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp192r1_sign(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + TEE_Result result; + + uint8_t *message; + uint32_t message_length; + uint8_t *signature; + rsip_wrapped_key_t * wrapped_key; + + uint8_t digest[SHA256_HASH_SIZE]; + uint8_t sha1_digest[SHA1_HASH_SIZE]; + memset(digest, 0, SHA256_HASH_SIZE); + memset(sha1_digest, 0, SHA1_HASH_SIZE); + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[0].memref.buffer; + message_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + signature = (uint8_t *)params[1].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t) || (SIGNATURE_SIZE > params[1].memref.size)) { + EMSG("signature err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + result = generate_hash(message, message_length, RSIP_HASH_TYPE_SHA1, sha1_digest); + if (TEE_SUCCESS != result) { + return result; + } + + memcpy(&digest[8], sha1_digest, SHA1_HASH_SIZE); + + err = R_RSIP_ECDSA_Sign(&rsip_instance_ctrl, wrapped_key, digest, signature); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = SIGNATURE_SIZE; + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp224r1_sign(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + TEE_Result result; + + uint8_t *message; + uint32_t message_length; + uint8_t *signature; + rsip_wrapped_key_t * wrapped_key; + + uint8_t digest[SHA256_HASH_SIZE]; + uint8_t sha224_digest[SHA224_HASH_SIZE]; + memset(digest, 0, SHA256_HASH_SIZE); + memset(sha224_digest, 0, SHA224_HASH_SIZE); + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[0].memref.buffer; + message_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + signature = (uint8_t *)params[1].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t) || (SIGNATURE_SIZE > params[1].memref.size)) { + EMSG("signature err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + result = generate_hash(message, message_length, RSIP_HASH_TYPE_SHA224, sha224_digest); + if (TEE_SUCCESS != result) { + return result; + } + + memcpy(&digest[4], sha224_digest, SHA224_HASH_SIZE); + + err = R_RSIP_ECDSA_Sign(&rsip_instance_ctrl, wrapped_key, digest, signature); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = SIGNATURE_SIZE; + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp256r1_sign(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + TEE_Result result; + + uint8_t *message; + uint32_t message_length; + uint8_t *signature; + rsip_wrapped_key_t * wrapped_key; + + uint8_t digest[SHA256_HASH_SIZE]; + memset(digest, 0, SHA256_HASH_SIZE); + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[0].memref.buffer; + message_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + signature = (uint8_t *)params[1].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t) || (SIGNATURE_SIZE > params[1].memref.size)) { + EMSG("signature err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + result = generate_hash(message, message_length, RSIP_HASH_TYPE_SHA256, digest); + if (TEE_SUCCESS != result) { + return result; + } + + err = R_RSIP_ECDSA_Sign(&rsip_instance_ctrl, wrapped_key, digest, signature); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = SIGNATURE_SIZE; + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_brainpoolp256r1_sign(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + TEE_Result result; + + uint8_t *message; + uint32_t message_length; + uint8_t *signature; + rsip_wrapped_key_t * wrapped_key; + + uint8_t digest[SHA256_HASH_SIZE]; + memset(digest, 0, SHA256_HASH_SIZE); + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[0].memref.buffer; + message_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + signature = (uint8_t *)params[1].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t) || (SIGNATURE_SIZE > params[1].memref.size)) { + EMSG("signature err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + result = generate_hash(message, message_length, RSIP_HASH_TYPE_SHA256, digest); + if (TEE_SUCCESS != result) { + return result; + } + + err = R_RSIP_ECDSA_Sign(&rsip_instance_ctrl, wrapped_key, digest, signature); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = SIGNATURE_SIZE; + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp192r1_verify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + TEE_Result result; + + uint8_t *signature; + uint8_t *message; + uint32_t message_length; + rsip_wrapped_key_t * wrapped_key; + + uint8_t digest[SHA256_HASH_SIZE]; + uint8_t sha1_digest[SHA1_HASH_SIZE]; + memset(digest, 0, SHA256_HASH_SIZE); + memset(sha1_digest, 0, SHA1_HASH_SIZE); + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature = (uint8_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("signature err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + result = generate_hash(message, message_length, RSIP_HASH_TYPE_SHA1, sha1_digest); + if (TEE_SUCCESS != result) { + return result; + } + + memcpy(&digest[8], sha1_digest, SHA1_HASH_SIZE); + + err = R_RSIP_ECDSA_Verify(&rsip_instance_ctrl, wrapped_key, digest, signature); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp224r1_verify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + TEE_Result result; + + uint8_t *signature; + uint8_t *message; + uint32_t message_length; + rsip_wrapped_key_t * wrapped_key; + + uint8_t digest[SHA256_HASH_SIZE]; + uint8_t sha224_digest[SHA224_HASH_SIZE]; + memset(digest, 0, SHA256_HASH_SIZE); + memset(sha224_digest, 0, SHA224_HASH_SIZE); + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature = (uint8_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("signature err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + result = generate_hash(message, message_length, RSIP_HASH_TYPE_SHA224, sha224_digest); + if (TEE_SUCCESS != result) { + return result; + } + + memcpy(&digest[4], sha224_digest, SHA224_HASH_SIZE); + + err = R_RSIP_ECDSA_Verify(&rsip_instance_ctrl, wrapped_key, digest, signature); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_secp256r1_verify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + TEE_Result result; + + uint8_t *signature; + uint8_t *message; + uint32_t message_length; + rsip_wrapped_key_t * wrapped_key; + + uint8_t digest[SHA256_HASH_SIZE]; + memset(digest, 0, SHA256_HASH_SIZE); + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature = (uint8_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("signature err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + result = generate_hash(message, message_length, RSIP_HASH_TYPE_SHA256, digest); + if (TEE_SUCCESS != result) { + return result; + } + + err = R_RSIP_ECDSA_Verify(&rsip_instance_ctrl, wrapped_key, digest, signature); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result ecdsa_brainpoolp256r1_verify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + TEE_Result result; + + uint8_t *signature; + uint8_t *message; + uint32_t message_length; + rsip_wrapped_key_t * wrapped_key; + + uint8_t digest[SHA256_HASH_SIZE]; + memset(digest, 0, SHA256_HASH_SIZE); + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature = (uint8_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("signature err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + result = generate_hash(message, message_length, RSIP_HASH_TYPE_SHA256, digest); + if (TEE_SUCCESS != result) { + return result; + } + + err = R_RSIP_ECDSA_Verify(&rsip_instance_ctrl, wrapped_key, digest, signature); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + EMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) + { + case PTA_CMD_ECDSA_secp192r1_SignatureGenerate : + return ecdsa_secp192r1_sign(ptypes, params, + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PRIVATE); + case PTA_CMD_ECDSA_secp224r1_SignatureGenerate : + return ecdsa_secp224r1_sign(ptypes, params, + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PRIVATE); + case PTA_CMD_ECDSA_secp256r1_SignatureGenerate : + return ecdsa_secp256r1_sign(ptypes, params, + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PRIVATE); + case PTA_CMD_ECDSA_BrainpoolP256r1_SignatureGenerate : + return ecdsa_brainpoolp256r1_sign(ptypes, params, + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PRIVATE); + + case PTA_CMD_ECDSA_secp192r1_SignatureVerify : + return ecdsa_secp192r1_verify(ptypes, params, + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp192r1_PUBLIC); + case PTA_CMD_ECDSA_secp224r1_SignatureVerify : + return ecdsa_secp224r1_verify(ptypes, params, + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp224r1_PUBLIC); + case PTA_CMD_ECDSA_secp256r1_SignatureVerify : + return ecdsa_secp256r1_verify(ptypes, params, + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_secp256r1_PUBLIC); + case PTA_CMD_ECDSA_BrainpoolP256r1_SignatureVerify : + return ecdsa_brainpoolp256r1_verify(ptypes, params, + RSIP_BYTE_SIZE_WRAPPED_KEY_ECC_BRAINPOOLP256R1_PUBLIC); + + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_RSIP_ECC_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_hmac.c b/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_hmac.c new file mode 100644 index 000000000..6625494cf --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_hmac.c @@ -0,0 +1,380 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2024, Renesas Electronics + */ + +#include + +#include +#include + +#define PTA_NAME "rsip_hmac.pta" + +extern rsip_instance_ctrl_t rsip_instance_ctrl; + + +static TEE_Result hmac_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + rsip_hmac_handle_t * handle; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (rsip_hmac_handle_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, rsip_hmac_handle_t)) { + EMSG("handle err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[1].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t) || (key_size > params[1].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_HMAC_GenerateInit(&rsip_instance_ctrl, handle, wrapped_key); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + default: + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(rsip_hmac_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result hmac_generateupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + rsip_hmac_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (rsip_hmac_handle_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, rsip_hmac_handle_t)) { + EMSG("handle err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_HMAC_GenerateUpdate(&rsip_instance_ctrl, handle, message, message_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result hmac_generatefinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], uint32_t mac_size) +{ + fsp_err_t err; + + rsip_hmac_handle_t * handle; + uint8_t * mac; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (rsip_hmac_handle_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, rsip_hmac_handle_t)) { + EMSG("handle err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + mac = (uint8_t *)params[1].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (mac_size > params[1].memref.size)) { + EMSG("mac err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_HMAC_GenerateFinal(&rsip_instance_ctrl, handle, mac); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = mac_size; + + return TEE_SUCCESS; +} + +static TEE_Result hmac_verifyinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + rsip_hmac_handle_t * handle; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (rsip_hmac_handle_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("handle err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[1].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t) || (key_size > params[1].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_HMAC_VerifyInit(&rsip_instance_ctrl, handle, wrapped_key); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + default: + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(rsip_hmac_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result hmac_verifyupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + rsip_hmac_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (rsip_hmac_handle_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("handle err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_HMAC_VerifyUpdate(&rsip_instance_ctrl, handle, message, message_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result hmac_verifyfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + + rsip_hmac_handle_t * handle; + uint8_t * mac; + uint32_t mac_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (rsip_hmac_handle_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("handle err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + mac = (uint8_t *)params[1].memref.buffer; + mac_length = (uint32_t)params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + EMSG("mac err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_HMAC_VerifyFinal(&rsip_instance_ctrl, handle, mac, mac_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + EMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_HMAC_SHA1_GenerateInit : + return hmac_generateinit(ptypes, params, RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA1); + case PTA_CMD_HMAC_SHA224_GenerateInit : + return hmac_generateinit(ptypes, params, RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA224); + case PTA_CMD_HMAC_SHA256_GenerateInit : + return hmac_generateinit(ptypes, params, RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA256); + + case PTA_CMD_HMAC_SHA1_GenerateUpdate : + case PTA_CMD_HMAC_SHA224_GenerateUpdate : + case PTA_CMD_HMAC_SHA256_GenerateUpdate : + return hmac_generateupdate(ptypes, params); + + case PTA_CMD_HMAC_SHA1_GenerateFinal : + return hmac_generatefinal(ptypes, params, SHA1_MAC_SIZE); + case PTA_CMD_HMAC_SHA224_GenerateFinal : + return hmac_generatefinal(ptypes, params, SHA224_MAC_SIZE); + case PTA_CMD_HMAC_SHA256_GenerateFinal : + return hmac_generatefinal(ptypes, params, SHA256_MAC_SIZE); + + case PTA_CMD_HMAC_SHA1_VerifyInit : + return hmac_verifyinit(ptypes, params, RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA1); + case PTA_CMD_HMAC_SHA224_VerifyInit : + return hmac_verifyinit(ptypes, params, RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA224); + case PTA_CMD_HMAC_SHA256_VerifyInit : + return hmac_verifyinit(ptypes, params, RSIP_BYTE_SIZE_WRAPPED_KEY_HMAC_SHA256); + + case PTA_CMD_HMAC_SHA1_VerifyUpdate : + case PTA_CMD_HMAC_SHA224_VerifyUpdate : + case PTA_CMD_HMAC_SHA256_VerifyUpdate : + return hmac_verifyupdate(ptypes, params); + + case PTA_CMD_HMAC_SHA1_VerifyFinal : + case PTA_CMD_HMAC_SHA224_VerifyFinal : + case PTA_CMD_HMAC_SHA256_VerifyFinal : + return hmac_verifyfinal(ptypes, params); + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_RSIP_HMAC_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_rsa.c b/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_rsa.c new file mode 100644 index 000000000..0379e8cb3 --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_rsa.c @@ -0,0 +1,1114 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2024, Renesas Electronics + */ + +#include + +#include +#include + +#define PTA_NAME "rsip_rsa.pta" + +extern rsip_instance_ctrl_t rsip_instance_ctrl; + +static const rsip_hash_type_t hash_type = RSIP_HASH_TYPE_SHA256; +static const rsip_mgf_type_t mgf_type = RSIP_MGF_TYPE_MGF1_SHA256; +static const int32_t salt_length = RSIP_RSA_SALT_LENGTH_HASH; + +static TEE_Result generate_hash(uint8_t const *const message, uint32_t const message_length, + rsip_hash_type_t *hash_type, uint8_t *digest) +{ + fsp_err_t err; + *hash_type = RSIP_HASH_TYPE_SHA256; + + err = R_RSIP_SHA_Compute(&rsip_instance_ctrl, *hash_type, message, message_length, digest); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result rsassa_pkcs1_v1_5_sign(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + uint32_t sig_size, rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + TEE_Result result; + + uint8_t *message; + uint32_t message_length; + uint8_t *signature; + uint8_t digest[32]; + rsip_hash_type_t hash_type; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[0].memref.buffer; + message_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + signature = (uint8_t *)params[1].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (sig_size > params[1].memref.size)) { + EMSG("signature err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + result = generate_hash(message, message_length, &hash_type, digest); + if (TEE_SUCCESS != result) { + return result; + } + + err = R_RSIP_RSASSA_PKCS1_V1_5_Sign(&rsip_instance_ctrl, wrapped_key, hash_type, digest, signature); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = sig_size; + + return TEE_SUCCESS; +} + + +static TEE_Result rsassa_pkcs1_v1_5_verify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + TEE_Result result; + + uint8_t *message; + uint32_t message_length; + uint8_t *signature; + uint8_t digest[32]; + rsip_hash_type_t hash_type; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature = (uint8_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("signature err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + result = generate_hash(message, message_length, &hash_type, digest); + if (TEE_SUCCESS != result) { + return result; + } + + err = R_RSIP_RSASSA_PKCS1_V1_5_Verify(&rsip_instance_ctrl, wrapped_key, hash_type, digest, signature); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result rsassa_pss_sign(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + uint32_t sig_size, rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + TEE_Result result; + + uint8_t *message; + uint32_t message_length; + uint8_t *signature; + uint8_t digest[32]; + rsip_hash_type_t hash_type; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[0].memref.buffer; + message_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + signature = (uint8_t *)params[1].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (sig_size > params[1].memref.size)) { + EMSG("signature err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + result = generate_hash(message, message_length, &hash_type, digest); + if (TEE_SUCCESS != result) { + return result; + } + + err = R_RSIP_RSASSA_PSS_Sign(&rsip_instance_ctrl, wrapped_key, hash_type, mgf_type, + salt_length, digest, signature); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = sig_size; + + return TEE_SUCCESS; +} + + +static TEE_Result rsassa_pss_verify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + TEE_Result result; + + uint8_t *signature; + uint8_t *message; + uint32_t message_length; + uint8_t digest[32]; + rsip_hash_type_t hash_type; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + signature = (uint8_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("signature err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + result = generate_hash(message, message_length, &hash_type, digest); + if (TEE_SUCCESS != result) { + return result; + } + + err = R_RSIP_RSASSA_PSS_Verify(&rsip_instance_ctrl, wrapped_key, hash_type, mgf_type, + salt_length, digest, signature); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + + +static TEE_Result rsa_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + uint32_t cipher_size, rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + uint8_t * plain; + uint8_t * cipher; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (cipher_size > params[1].memref.size) ) { + EMSG("cipher err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_RSA_Encrypt(&rsip_instance_ctrl, wrapped_key, plain, cipher); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = cipher_size; + + return TEE_SUCCESS; +} + + +static TEE_Result rsa_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + uint32_t plain_size, rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + uint8_t * cipher; + uint8_t * plain; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("cipher err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (plain_size > params[1].memref.size)) { + EMSG("plain err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_RSA_Decrypt(&rsip_instance_ctrl, wrapped_key, cipher, plain); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = plain_size; + + return TEE_SUCCESS; +} + + +static TEE_Result rsaes_pkcs1_v1_5_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + uint32_t cipher_size, rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + uint8_t *plain; + uint32_t plain_length; + uint8_t *cipher; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[0].memref.buffer; + plain_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("plain err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (cipher_size > params[1].memref.size) ) { + EMSG("cipher err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_RSAES_PKCS1_V1_5_Encrypt(&rsip_instance_ctrl, wrapped_key, plain, plain_length, cipher); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = cipher_size; + + return TEE_SUCCESS; +} + + +static TEE_Result rsaes_pkcs1_v1_5_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + uint8_t *plain; + uint32_t plain_length; + uint32_t plain_buffer_length = 512; + uint8_t *cipher; + uint32_t cipher_length; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[0].memref.buffer; + cipher_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (plain_length < cipher_length)) { + EMSG("plain err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_RSAES_PKCS1_V1_5_Decrypt(&rsip_instance_ctrl, wrapped_key, cipher, plain, + &plain_length, plain_buffer_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = plain_length; + + return TEE_SUCCESS; +} + + +static TEE_Result rsaes_oaep_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], + uint32_t cipher_size, rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + uint8_t *plain; + uint32_t plain_length; + uint8_t *cipher; + uint8_t *label; + uint32_t label_length; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[0].memref.buffer; + plain_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("plain err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[1].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (cipher_size > params[1].memref.size) ) { + EMSG("cipher err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + label = (uint8_t *)params[3].memref.buffer; + label_length = (uint32_t)params[3].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[3].memref.buffer, uint32_t)) { + EMSG("label err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_RSAES_OAEP_Encrypt(&rsip_instance_ctrl, wrapped_key, hash_type, mgf_type, + label, label_length, plain, plain_length, cipher); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = cipher_size; + + return TEE_SUCCESS; +} + + +static TEE_Result rsaes_oaep_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], rsip_byte_size_wrapped_key_t key_size) +{ + fsp_err_t err; + + uint8_t *plain; + uint32_t plain_length; + uint32_t plain_buffer_length = 512; + uint8_t *cipher; + uint32_t cipher_length; + uint8_t *label; + uint32_t label_length; + rsip_wrapped_key_t * wrapped_key; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_MEMREF_INPUT)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + cipher = (uint8_t *)params[0].memref.buffer; + cipher_length = (uint32_t)params[0].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, uint32_t)) { + EMSG("cipher err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + plain = (uint8_t *)params[1].memref.buffer; + plain_length = (uint32_t)params[1].memref.size; + if ((!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) || (plain_length < cipher_length)) { + EMSG("plain err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + wrapped_key = (rsip_wrapped_key_t *)params[2].memref.buffer; + if ((!IS_ALIGNED_WITH_TYPE(params[2].memref.buffer, uint32_t)) || (key_size > params[2].memref.size)) { + EMSG("key err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + label = (uint8_t *)params[3].memref.buffer; + label_length = (uint32_t)params[3].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[3].memref.buffer, uint32_t)) { + EMSG("label err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_RSAES_OAEP_Decrypt(&rsip_instance_ctrl, wrapped_key, hash_type, mgf_type, + label, label_length, cipher, plain, &plain_length, plain_buffer_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_NOT_ENABLED: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_INVALID_ARGUMENT: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_KEY_SET_FAIL: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_FAIL: + return TEE_ERROR_GENERIC; + case FSP_ERR_INVALID_SIZE: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = plain_length; + + return TEE_SUCCESS; +} + +static TEE_Result rsassa_pkcs1024_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pkcs1_v1_5_sign(types, params, SIGNATURE_BYTE_SIZE_RSA_1024, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED); +} + +static TEE_Result rsassa_pkcs2048_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pkcs1_v1_5_sign(types, params, SIGNATURE_BYTE_SIZE_RSA_2048, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED); +} + +static TEE_Result rsassa_pkcs3072_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pkcs1_v1_5_sign(types, params, SIGNATURE_BYTE_SIZE_RSA_3072, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE); +} + +static TEE_Result rsassa_pkcs4096_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pkcs1_v1_5_sign(types, params, SIGNATURE_BYTE_SIZE_RSA_4096, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE); +} + +static TEE_Result rsassa_pkcs1024_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pkcs1_v1_5_verify(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED); +} + +static TEE_Result rsassa_pkcs2048_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pkcs1_v1_5_verify(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED); +} + +static TEE_Result rsassa_pkcs3072_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pkcs1_v1_5_verify(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC); +} + +static TEE_Result rsassa_pkcs4096_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pkcs1_v1_5_verify(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC); +} + +static TEE_Result rsassa_pss1024_signature(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pss_sign(types, params, SIGNATURE_BYTE_SIZE_RSA_1024, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED); +} + +static TEE_Result rsassa_pss2048_signature(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pss_sign(types, params, SIGNATURE_BYTE_SIZE_RSA_2048, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED); +} + +static TEE_Result rsassa_pss3072_signature(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pss_sign(types, params, SIGNATURE_BYTE_SIZE_RSA_3072, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE); +} + +static TEE_Result rsassa_pss4096_signature(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pss_sign(types, params, SIGNATURE_BYTE_SIZE_RSA_4096, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE); +} + +static TEE_Result rsassa_pss1024_verify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pss_verify(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED); +} + +static TEE_Result rsassa_pss2048_verify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pss_verify(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED); +} + +static TEE_Result rsassa_pss3072_verify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pss_verify(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC); +} + +static TEE_Result rsassa_pss4096_verify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsassa_pss_verify(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC); +} + + +static TEE_Result rsa_1024_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsa_encrypt(types, params, CIPHER_BYTE_SIZE_RSA_1024, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED); +} + +static TEE_Result rsa_2048_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsa_encrypt(types, params, CIPHER_BYTE_SIZE_RSA_2048, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED); +} + +static TEE_Result rsa_3072_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsa_encrypt(types, params, CIPHER_BYTE_SIZE_RSA_3072, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC); +} + +static TEE_Result rsa_4096_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsa_encrypt(types, params, CIPHER_BYTE_SIZE_RSA_4096, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC); +} + + +static TEE_Result rsa_1024_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsa_decrypt(types, params, CIPHER_BYTE_SIZE_RSA_1024, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED); +} + +static TEE_Result rsa_2048_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsa_decrypt(types, params, CIPHER_BYTE_SIZE_RSA_2048, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED); +} + +static TEE_Result rsa_3072_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsa_decrypt(types, params, CIPHER_BYTE_SIZE_RSA_3072, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE); +} + +static TEE_Result rsa_4096_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsa_decrypt(types, params, CIPHER_BYTE_SIZE_RSA_4096, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE); +} + +static TEE_Result rsaes_pkcs1024_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsaes_pkcs1_v1_5_encrypt(types, params, CIPHER_BYTE_SIZE_RSA_1024, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED); +} + +static TEE_Result rsaes_pkcs2048_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsaes_pkcs1_v1_5_encrypt(types, params, CIPHER_BYTE_SIZE_RSA_2048, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED); +} + +static TEE_Result rsaes_pkcs3072_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsaes_pkcs1_v1_5_encrypt(types, params, CIPHER_BYTE_SIZE_RSA_3072, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC); +} + +static TEE_Result rsaes_pkcs4096_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsaes_pkcs1_v1_5_encrypt(types, params, CIPHER_BYTE_SIZE_RSA_4096, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC); +} + + +static TEE_Result rsaes_pkcs1024_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS] +) +{ + return rsaes_pkcs1_v1_5_decrypt(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED); +} + +static TEE_Result rsaes_pkcs2048_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS] +) +{ + return rsaes_pkcs1_v1_5_decrypt(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED); +} + +static TEE_Result rsaes_pkcs3072_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS] +) +{ + return rsaes_pkcs1_v1_5_decrypt(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE); +} + +static TEE_Result rsaes_pkcs4096_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS] +) +{ + return rsaes_pkcs1_v1_5_decrypt(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE); +} + + +static TEE_Result rsaes_oaep1024_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsaes_oaep_encrypt(types, params, CIPHER_BYTE_SIZE_RSA_1024, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PUBLIC_ENHANCED); +} + +static TEE_Result rsaes_oaep2048_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsaes_oaep_encrypt(types, params, CIPHER_BYTE_SIZE_RSA_2048, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PUBLIC_ENHANCED); +} + +static TEE_Result rsaes_oaep3072_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsaes_oaep_encrypt(types, params, CIPHER_BYTE_SIZE_RSA_3072, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PUBLIC); +} + +static TEE_Result rsaes_oaep4096_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsaes_oaep_encrypt(types, params, CIPHER_BYTE_SIZE_RSA_4096, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PUBLIC); +} + +static TEE_Result rsaes_oaep1024_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsaes_oaep_decrypt(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_1024_PRIVATE_ENHANCED); +} + +static TEE_Result rsaes_oaep2048_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsaes_oaep_decrypt(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_2048_PRIVATE_ENHANCED); +} + +static TEE_Result rsaes_oaep3072_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsaes_oaep_decrypt(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_3072_PRIVATE); +} + +static TEE_Result rsaes_oaep4096_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + return rsaes_oaep_decrypt(types, params, RSIP_BYTE_SIZE_WRAPPED_KEY_RSA_4096_PRIVATE); +} + + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + EMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_RSASSA_PKCS1024_SignatureGenerate : + return rsassa_pkcs1024_signaturegenerate(ptypes, params); + case PTA_CMD_RSASSA_PKCS2048_SignatureGenerate : + return rsassa_pkcs2048_signaturegenerate(ptypes, params); + case PTA_CMD_RSASSA_PKCS3072_SignatureGenerate : + return rsassa_pkcs3072_signaturegenerate(ptypes, params); + case PTA_CMD_RSASSA_PKCS4096_SignatureGenerate : + return rsassa_pkcs4096_signaturegenerate(ptypes, params); + + case PTA_CMD_RSASSA_PKCS1024_SignatureVerify : + return rsassa_pkcs1024_signatureverify(ptypes, params); + case PTA_CMD_RSASSA_PKCS2048_SignatureVerify : + return rsassa_pkcs2048_signatureverify(ptypes, params); + case PTA_CMD_RSASSA_PKCS3072_SignatureVerify : + return rsassa_pkcs3072_signatureverify(ptypes, params); + case PTA_CMD_RSASSA_PKCS4096_SignatureVerify : + return rsassa_pkcs4096_signatureverify(ptypes, params); + + case PTA_CMD_RSASSA_PSS1024_SignatureGenerate: + return rsassa_pss1024_signature(ptypes, params); + case PTA_CMD_RSASSA_PSS2048_SignatureGenerate: + return rsassa_pss2048_signature(ptypes, params); + case PTA_CMD_RSASSA_PSS3072_SignatureGenerate: + return rsassa_pss3072_signature(ptypes, params); + case PTA_CMD_RSASSA_PSS4096_SignatureGenerate: + return rsassa_pss4096_signature(ptypes, params); + + case PTA_CMD_RSASSA_PSS1024_SignatureVerify : + return rsassa_pss1024_verify(ptypes, params); + case PTA_CMD_RSASSA_PSS2048_SignatureVerify : + return rsassa_pss2048_verify(ptypes, params); + case PTA_CMD_RSASSA_PSS3072_SignatureVerify : + return rsassa_pss3072_verify(ptypes, params); + case PTA_CMD_RSASSA_PSS4096_SignatureVerify : + return rsassa_pss4096_verify(ptypes, params); + + + case PTA_CMD_RSA_1024_Encrypt : + return rsa_1024_encrypt(ptypes, params); + case PTA_CMD_RSA_2048_Encrypt : + return rsa_2048_encrypt(ptypes, params); + case PTA_CMD_RSA_3072_Encrypt : + return rsa_3072_encrypt(ptypes, params); + case PTA_CMD_RSA_4096_Encrypt : + return rsa_4096_encrypt(ptypes, params); + + case PTA_CMD_RSA_1024_Decrypt : + return rsa_1024_decrypt(ptypes, params); + case PTA_CMD_RSA_2048_Decrypt : + return rsa_2048_decrypt(ptypes, params); + case PTA_CMD_RSA_3072_Decrypt : + return rsa_3072_decrypt(ptypes, params); + case PTA_CMD_RSA_4096_Decrypt : + return rsa_4096_decrypt(ptypes, params); + + case PTA_CMD_RSAES_PKCS1024_Encrypt : + return rsaes_pkcs1024_encrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS2048_Encrypt : + return rsaes_pkcs2048_encrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS3072_Encrypt : + return rsaes_pkcs3072_encrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS4096_Encrypt : + return rsaes_pkcs4096_encrypt(ptypes, params); + + case PTA_CMD_RSAES_PKCS1024_Decrypt : + return rsaes_pkcs1024_decrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS2048_Decrypt : + return rsaes_pkcs2048_decrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS3072_Decrypt : + return rsaes_pkcs3072_decrypt(ptypes, params); + case PTA_CMD_RSAES_PKCS4096_Decrypt : + return rsaes_pkcs4096_decrypt(ptypes, params); + + case PTA_CMD_RSAES_OAEP1024_Encrypt : + return rsaes_oaep1024_encrypt(ptypes, params); + case PTA_CMD_RSAES_OAEP2048_Encrypt : + return rsaes_oaep2048_encrypt(ptypes, params); + case PTA_CMD_RSAES_OAEP3072_Encrypt : + return rsaes_oaep3072_encrypt(ptypes, params); + case PTA_CMD_RSAES_OAEP4096_Encrypt : + return rsaes_oaep4096_encrypt(ptypes, params); + + case PTA_CMD_RSAES_OAEP1024_Decrypt : + return rsaes_oaep1024_decrypt(ptypes, params); + case PTA_CMD_RSAES_OAEP2048_Decrypt : + return rsaes_oaep2048_decrypt(ptypes, params); + case PTA_CMD_RSAES_OAEP3072_Decrypt : + return rsaes_oaep3072_decrypt(ptypes, params); + case PTA_CMD_RSAES_OAEP4096_Decrypt : + return rsaes_oaep4096_decrypt(ptypes, params); + + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_RSIP_RSA_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_sha.c b/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_sha.c new file mode 100644 index 000000000..4b98e8042 --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/pta_rsip_sha.c @@ -0,0 +1,208 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2024, Renesas Electronics + */ + +#include + +#include +#include + +#define PTA_NAME "rsip_sha.pta" + +extern rsip_instance_ctrl_t rsip_instance_ctrl; + + +static TEE_Result sha_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], rsip_hash_type_t const hash_type) +{ + fsp_err_t err; + rsip_sha_handle_t * handle; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (rsip_sha_handle_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, rsip_sha_handle_t)) { + EMSG("handle err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_SHA_GenerateInit(&rsip_instance_ctrl, handle, hash_type); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + default: + return TEE_ERROR_GENERIC; + } + + params[0].memref.size = sizeof(rsip_sha_handle_t); + + return TEE_SUCCESS; +} + +static TEE_Result sha_generateupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) +{ + fsp_err_t err; + rsip_sha_handle_t * handle; + uint8_t * message; + uint32_t message_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INPUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (rsip_sha_handle_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, rsip_sha_handle_t)) { + EMSG("handle err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + message = (uint8_t *)params[1].memref.buffer; + message_length = (uint32_t)params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t)) { + EMSG("message err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_SHA_GenerateUpdate(&rsip_instance_ctrl, handle, message, message_length); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + return TEE_SUCCESS; +} + +static TEE_Result sha_generatefinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS], uint32_t hash_size) +{ + fsp_err_t err; + rsip_sha_handle_t * handle; + uint8_t * digest; + uint32_t digest_length; + + if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_MEMREF_INOUT, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE)) { + return TEE_ERROR_BAD_PARAMETERS; + } + + handle = (rsip_sha_handle_t *)params[0].memref.buffer; + if (!IS_ALIGNED_WITH_TYPE(params[0].memref.buffer, rsip_sha_handle_t)) { + EMSG("handle err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + digest = (uint8_t *)params[1].memref.buffer; + digest_length = (uint32_t)params[1].memref.size; + if (!IS_ALIGNED_WITH_TYPE(params[1].memref.buffer, uint32_t) || (hash_size > digest_length)) { + EMSG("digest err"); + return TEE_ERROR_BAD_PARAMETERS; + } + + err = R_RSIP_SHA_GenerateFinal(&rsip_instance_ctrl, handle, digest); + switch ((uint32_t)err) + { + case FSP_SUCCESS: + break; + case FSP_ERR_ASSERTION: + return TEE_ERROR_BAD_PARAMETERS; + case FSP_ERR_NOT_OPEN: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_INVALID_STATE: + return TEE_ERROR_BAD_STATE; + case FSP_ERR_CRYPTO_RSIP_RESOURCE_CONFLICT: + return TEE_ERROR_ACCESS_CONFLICT; + case FSP_ERR_CRYPTO_RSIP_FATAL: + return TEE_ERROR_GENERIC; + default: + return TEE_ERROR_BAD_STATE; + } + + params[1].memref.size = hash_size; + + return TEE_SUCCESS; +} + + +static TEE_Result invoke_command(void *session __unused, uint32_t cmd, + uint32_t ptypes, + TEE_Param params[TEE_NUM_PARAMS]) +{ + EMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); + + switch (cmd) { + case PTA_CMD_SHA1_Init : + return sha_generateinit(ptypes, params, RSIP_HASH_TYPE_SHA1); + case PTA_CMD_SHA224_Init : + return sha_generateinit(ptypes, params, RSIP_HASH_TYPE_SHA224); + case PTA_CMD_SHA256_Init : + return sha_generateinit(ptypes, params, RSIP_HASH_TYPE_SHA256); + case PTA_CMD_SHA384_Init : + return sha_generateinit(ptypes, params, RSIP_HASH_TYPE_SHA384); + case PTA_CMD_SHA512_Init : + return sha_generateinit(ptypes, params, RSIP_HASH_TYPE_SHA512); + case PTA_CMD_SHA512_224_Init : + return sha_generateinit(ptypes, params, RSIP_HASH_TYPE_SHA512_224); + case PTA_CMD_SHA512_256_Init : + return sha_generateinit(ptypes, params, RSIP_HASH_TYPE_SHA512_256); + + case PTA_CMD_SHA1_Update : + case PTA_CMD_SHA224_Update : + case PTA_CMD_SHA256_Update : + case PTA_CMD_SHA384_Update : + case PTA_CMD_SHA512_Update : + case PTA_CMD_SHA512_224_Update : + case PTA_CMD_SHA512_256_Update : + return sha_generateupdate(ptypes, params); + + case PTA_CMD_SHA1_Final : + return sha_generatefinal(ptypes, params, SHA1_HASH_SIZE); + case PTA_CMD_SHA224_Final : + return sha_generatefinal(ptypes, params, SHA224_HASH_SIZE); + case PTA_CMD_SHA256_Final : + return sha_generatefinal(ptypes, params, SHA256_HASH_SIZE); + case PTA_CMD_SHA384_Final : + return sha_generatefinal(ptypes, params, SHA384_HASH_SIZE); + case PTA_CMD_SHA512_Final : + return sha_generatefinal(ptypes, params, SHA512_HASH_SIZE); + case PTA_CMD_SHA512_224_Final : + return sha_generatefinal(ptypes, params, SHA512_224_HASH_SIZE); + case PTA_CMD_SHA512_256_Final : + return sha_generatefinal(ptypes, params, SHA512_256_HASH_SIZE); + + default: + return TEE_ERROR_NOT_SUPPORTED; + } +} + +pseudo_ta_register(.uuid = PTA_RSIP_SHA_UUID, .name = PTA_NAME, + .flags = PTA_DEFAULT_FLAGS, + .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/common/pta/rsip/sub.mk b/core/arch/arm/plat-rz/common/pta/rsip/sub.mk new file mode 100644 index 000000000..d1541eecc --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/rsip/sub.mk @@ -0,0 +1,9 @@ +global-incdirs-y += include + +srcs-$(CFG_RZ_RSIP) += \ + pta_rsip.c \ + pta_rsip_aes.c \ + pta_rsip_rsa.c \ + pta_rsip_sha.c \ + pta_rsip_ecc.c \ + pta_rsip_hmac.c \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/pta/sub.mk b/core/arch/arm/plat-rz/common/pta/sub.mk index 7216692a7..2fc837ea4 100644 --- a/core/arch/arm/plat-rz/common/pta/sub.mk +++ b/core/arch/arm/plat-rz/common/pta/sub.mk @@ -1,4 +1,7 @@ global-incdirs-y += include -srcs-$(CFG_RZ_XSPI) += pta_flash.c -srcs-$(CFG_RZ_SCE) += pta_sce.c pta_sce_ecc.c pta_sce_rsa.c pta_sce_sha.c pta_sce_aes.c +srcs-y += pta_flash.c + +subdirs-$(CFG_RZ_RSIP) += rsip + +subdirs-$(CFG_RZ_TSIP) += tsip \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/pta/include/pta_sce.h b/core/arch/arm/plat-rz/common/pta/tsip/include/pta_sce.h similarity index 100% rename from core/arch/arm/plat-rz/common/pta/include/pta_sce.h rename to core/arch/arm/plat-rz/common/pta/tsip/include/pta_sce.h diff --git a/core/arch/arm/plat-rz/common/pta/include/pta_sce_aes.h b/core/arch/arm/plat-rz/common/pta/tsip/include/pta_sce_aes.h similarity index 100% rename from core/arch/arm/plat-rz/common/pta/include/pta_sce_aes.h rename to core/arch/arm/plat-rz/common/pta/tsip/include/pta_sce_aes.h diff --git a/core/arch/arm/plat-rz/common/pta/include/pta_sce_ecc.h b/core/arch/arm/plat-rz/common/pta/tsip/include/pta_sce_ecc.h similarity index 100% rename from core/arch/arm/plat-rz/common/pta/include/pta_sce_ecc.h rename to core/arch/arm/plat-rz/common/pta/tsip/include/pta_sce_ecc.h diff --git a/core/arch/arm/plat-rz/common/pta/include/pta_sce_rsa.h b/core/arch/arm/plat-rz/common/pta/tsip/include/pta_sce_rsa.h similarity index 100% rename from core/arch/arm/plat-rz/common/pta/include/pta_sce_rsa.h rename to core/arch/arm/plat-rz/common/pta/tsip/include/pta_sce_rsa.h diff --git a/core/arch/arm/plat-rz/common/pta/include/pta_sce_sha.h b/core/arch/arm/plat-rz/common/pta/tsip/include/pta_sce_sha.h similarity index 70% rename from core/arch/arm/plat-rz/common/pta/include/pta_sce_sha.h rename to core/arch/arm/plat-rz/common/pta/tsip/include/pta_sce_sha.h index 414bb53d1..0a2e1a375 100644 --- a/core/arch/arm/plat-rz/common/pta/include/pta_sce_sha.h +++ b/core/arch/arm/plat-rz/common/pta/tsip/include/pta_sce_sha.h @@ -12,35 +12,35 @@ { 0x94, 0xb5, 0xce, 0xcc, 0x5f, 0x48, 0x62, 0xe4 } } /* - * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) + * [in/out] memref[0] : SHA handler (sce_sha_md5_handle_t) */ #define PTA_CMD_SHA224_Init (0x00030000) /* - * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) + * [in/out] memref[0] : SHA handler (sce_sha_md5_handle_t) * [in] memref[1] : Message */ #define PTA_CMD_SHA224_Update (0x00030001) /* - * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) + * [in/out] memref[0] : SHA handler (sce_sha_md5_handle_t) * [in/out] memref[1] : Digest (28byte) */ #define PTA_CMD_SHA224_Final (0x00030002) /* - * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) + * [in/out] memref[0] : SHA handler (sce_sha_md5_handle_t) */ #define PTA_CMD_SHA256_Init (0x00030100) /* - * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) + * [in/out] memref[0] : SHA handler (sce_sha_md5_handle_t) * [in] memref[1] : Message */ #define PTA_CMD_SHA256_Update (0x00030101) /* - * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) + * [in/out] memref[0] : SHA handler (sce_sha_md5_handle_t) * [in/out] memref[1] : Digest (32byte) */ #define PTA_CMD_SHA256_Final (0x00030102) diff --git a/core/arch/arm/plat-rz/common/pta/pta_sce.c b/core/arch/arm/plat-rz/common/pta/tsip/pta_sce.c similarity index 100% rename from core/arch/arm/plat-rz/common/pta/pta_sce.c rename to core/arch/arm/plat-rz/common/pta/tsip/pta_sce.c diff --git a/core/arch/arm/plat-rz/common/pta/pta_sce_aes.c b/core/arch/arm/plat-rz/common/pta/tsip/pta_sce_aes.c similarity index 100% rename from core/arch/arm/plat-rz/common/pta/pta_sce_aes.c rename to core/arch/arm/plat-rz/common/pta/tsip/pta_sce_aes.c diff --git a/core/arch/arm/plat-rz/common/pta/pta_sce_ecc.c b/core/arch/arm/plat-rz/common/pta/tsip/pta_sce_ecc.c similarity index 100% rename from core/arch/arm/plat-rz/common/pta/pta_sce_ecc.c rename to core/arch/arm/plat-rz/common/pta/tsip/pta_sce_ecc.c diff --git a/core/arch/arm/plat-rz/common/pta/pta_sce_rsa.c b/core/arch/arm/plat-rz/common/pta/tsip/pta_sce_rsa.c similarity index 100% rename from core/arch/arm/plat-rz/common/pta/pta_sce_rsa.c rename to core/arch/arm/plat-rz/common/pta/tsip/pta_sce_rsa.c diff --git a/core/arch/arm/plat-rz/common/pta/pta_sce_sha.c b/core/arch/arm/plat-rz/common/pta/tsip/pta_sce_sha.c similarity index 100% rename from core/arch/arm/plat-rz/common/pta/pta_sce_sha.c rename to core/arch/arm/plat-rz/common/pta/tsip/pta_sce_sha.c diff --git a/core/arch/arm/plat-rz/common/pta/tsip/sub.mk b/core/arch/arm/plat-rz/common/pta/tsip/sub.mk new file mode 100644 index 000000000..b157f7b9f --- /dev/null +++ b/core/arch/arm/plat-rz/common/pta/tsip/sub.mk @@ -0,0 +1,8 @@ +global-incdirs-y += include + +srcs-$(CFG_RZ_TSIP) += \ + pta_sce.c \ + pta_sce_ecc.c \ + pta_sce_rsa.c \ + pta_sce_sha.c \ + pta_sce_aes.c diff --git a/core/arch/arm/plat-rz/common/sub.mk b/core/arch/arm/plat-rz/common/sub.mk index ca4d7a7cf..7777b9f92 100644 --- a/core/arch/arm/plat-rz/common/sub.mk +++ b/core/arch/arm/plat-rz/common/sub.mk @@ -1,4 +1,4 @@ srcs-$(CFG_RZ_HUK) += huk.c subdirs-y += drivers -subdirs-$-y += pta +subdirs-y += pta diff --git a/core/arch/arm/plat-rz/g2l/drivers/r_sce/README.md b/core/arch/arm/plat-rz/g2l/drivers/r_sce/README.md deleted file mode 100644 index c73bd6c13..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/r_sce/README.md +++ /dev/null @@ -1,46 +0,0 @@ -RZ MPU SCE Driver -========================================== - -
-Renesas Electronics Corporation - -March-31-2022 -
- -## 1. Overview - -The SCE Driver is software for controlling SCE, which is the security IP of RZ MPU. - -### 1.1. Requirements - - - RZ Secure Crypto Engine library 1.0.0 (libr_secure_ip_1_0.a.1.0.0) - -### 1.2. Notice - -RZ MPU SCE Driver is distributed as a sample software from Renesas without any warranty or support. - -## 1.3. Contributing - -To contribute to this software, you should email patches to renesas-rz@renesas.com. Please send .patch files as email attachments, not embedded in the email body. - -## 1.4. References - -The following table shows the document related to this function. - -| Number | Issuer | Title | Edition | -|--------|---------|----------------------------------------------------------------|-------------------| -| 1 | Renesas | RZ/G2L Security Manual | Rev.1.00 or later | - - -## 2. Driver Specifications - -See /doc/*.rst - -## 3. Revision history - -Describe the revision history of RZ MPU SCE Driver. - -### 3.1. v1.00 - -- First release. - diff --git a/core/arch/arm/plat-rz/g2l/drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst b/core/arch/arm/plat-rz/g2l/drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst deleted file mode 100644 index 28b982e2a..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/r_sce/doc/RZ_SCE_Driver_Usage.rst +++ /dev/null @@ -1,4980 +0,0 @@ -################################################################################### -1.About -################################################################################### - -************************************************************************* -1.1.Overview -************************************************************************* - -This document describes the architecture of the driver for the Secure Crypto Engine (SCE) on RZ MPUs. - -************************************************************************* -1.2.Features -************************************************************************* -The SCE module supports for the following features. - - - Cryptography - - Symmetric Encryption/Decryption - - AES - - ECB 128/256bit - - CBC 128/256bit - - CTR 128/256bit - - Asymmetric Encryption/Decryption - - RSA - - RSAES-PKCS1-V1_5 1024/2048bit - - RSAES-PKCS1-V1_5 4096bit (Encryption only) - - RSASSA-PKCS1-V1_5 1024/2048bit - - RSASSA-PKCS1-V1_5 4096bit (Verification only) - - ECC - - ECDSA secp192r1/secp224r1/secp256r1/BrainpoolP512r1 - - Hash Functions - - SHA-2 - - SHA-256/224 - - Message Authentication Code - - AES-CMAC 128/256bit - - Key Support - - AES 128/256bit - - RSA 1024/2048bit - - RSA 4096bit (public key only) - - ECC secp192r1/secp224r1/secp256r1/BrainpoolP512r1 - - TRNG - -************************************************************************* -1.3.Terminology -************************************************************************* - -************************************************************************* -1.4.Operating Environment -************************************************************************* -------------------------------------------------------- -1.4.1.Hardware Environment -------------------------------------------------------- -The following table lists the hardware needed to use this utility. - -.. csv-table:: Hardware environment - :header: "Name", "Note" - - Target board,"RZ/G2L Device" - -------------------------------------------------------- -1.4.1.Software Environment -------------------------------------------------------- -This driver are designed for use with generic (or no specific) operating systems. - -************************************************************************* -1.5.Requirement -************************************************************************* - - - RZ Secure Crypto Engine library 1.0.0 - -************************************************************************* -1.6.Notice -************************************************************************* - -This driver is distributed as a sample software from Renesas without any warranty or support. - -For inquiries regarding the provision of the RZ Secure Crypto Engine library, please contact Renesas Electronics distributor or contact us. - -################################################################################### -2.SCE Driver API Specifications -################################################################################### - -This chapter presents the API specifications for the RZ SCE driver. - -************************************************************************* -2.1.File Structure -************************************************************************* - -This SCE driver file structure is shown below. - -+------------------------+-------------------+---------------------------------------------------+ -|Folder Name |File Name |Description | -+=====+==================+===================+===================================================+ -|sce |doc |sce_usage_notes.rst|This document. | -| +---------+--------+-------------------+---------------------------------------------------+ -| |inc |api |r_sce_api.h |sce API interface header file | -| | +--------+-------------------+---------------------------------------------------+ -| | |instance|r_sce.h |cryptographic function API header file | -| +---------+--------+-------------------+---------------------------------------------------+ -| |private | |r_sce_private.c |private function API header file | -| | +--------+-------------------+---------------------------------------------------+ -| | |inc |r_sce_private.h |private function API module | -| +---------+--------+-------------------+---------------------------------------------------+ -| |public |r_sce_aes.c |Public AES function API module | -| | +-------------------+---------------------------------------------------+ -| | |r_sce_ecc.c |Public ECC function API module | -| | +-------------------+---------------------------------------------------+ -| | |r_sce_rsa.c |Public RSA function API module | -| | +-------------------+---------------------------------------------------+ -| | |r_sce_sha.c |Public SHA function API module | -| | +-------------------+---------------------------------------------------+ -| | |r_sce.c |Common API module | -+-----+------------------+-------------------+---------------------------------------------------+ - -************************************************************************* -2.2.Functions -************************************************************************* - -+----------------------------------------------------------------------+---------------------------------+ -|Functions |Description | -+=======+==============================================================+=================================+ -|Common |`R_SCE_Open <2.6.1.R_SCE_Open_>`_ |Enables use of SCE functionality.| -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_Close |Stops supply of power to the SCE.| -| |<2.6.2.R_SCE_Close_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_SoftwareReset |Software reset to SCE. | -| |<2.6.3.R_SCE_SoftwareReset_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128_WrappedKeyGenerate |Random AES 128bit wrapped | -| |<2.6.4.R_SCE_AES128_WrappedKeyGenerate_>`_ |Key generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256_WrappedKeyGenerate |Random AES 256bit wrapped | -| |<2.6.5.R_SCE_AES256_WrappedKeyGenerate_>`_ |Key generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA1024_WrappedKeyPairGenerate |Random RSA 1024bit wrapped | -| |<2.6.6.R_SCE_RSA1024_WrappedKeyPairGenerate_>`_ |Key Pair generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA2048_WrappedKeyPairGenerate |Random RSA 2048bit wrapped | -| |<2.6.7.R_SCE_RSA2048_WrappedKeyPairGenerate_>`_ |Key Pair generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp192r1_WrappedKeyPairGenerate |Random ECC 192bit wrapped | -| |<2.6.8.R_SCE_ECC_secp192r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp224r1_WrappedKeyPairGenerate |Random ECC 224bit wrapped | -| |<2.6.9.R_SCE_ECC_secp224r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp256r1_WrappedKeyPairGenerate |Random ECC 256bit wrapped | -| |<2.6.10.R_SCE_ECC_secp256r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate |Random ECC 512bit wrapped | -| |<2.6.11.R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate_>`_ |Key Pair generate | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RandomNumberGenerate |Generate 4 words random number | -| |<2.6.12.R_SCE_RandomNumberGenerate_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128_EncryptedKeyWrap |Update AES 128bit installed Key | -| |<2.6.13.R_SCE_AES128_EncryptedKeyWrap_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256_EncryptedKeyWrap |Update AES 256bit installed Key | -| |<2.6.14.R_SCE_AES256_EncryptedKeyWrap_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA1024_EncryptedPublicKeyWrap |Update installed RSA 1024bit | -| |<2.6.15.R_SCE_RSA1024_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA1024_EncryptedPrivateKeyWrap |Update installed RSA 1024bit | -| |<2.6.16.R_SCE_RSA1024_EncryptedPrivateKeyWrap_>`_ |PrivateKey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA2048_EncryptedPublicKeyWrap |Update installed RSA 2048bit | -| |<2.6.17.R_SCE_RSA2048_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA2048_EncryptedPrivateKeyWrap |Update installed RSA 2048bit | -| |<2.6.18.R_SCE_RSA2048_EncryptedPrivateKeyWrap_>`_ |PrivateKey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSA4096_EncryptedPublicKeyWrap |Update installed RSA 4096bit | -| |<2.6.19.R_SCE_RSA4096_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap |Update installed ECC 192bit | -| |<2.6.20.R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap |Update installed ECC 224bit | -| |<2.6.21.R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap |Update installed ECC 256bit | -| |<2.6.22.R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap |Update installed ECC 512bit | -| |<2.6.23.R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap_>`_ |publickey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap |Update installed ECC 192bit | -| |<2.6.24.R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap |Update installed ECC 224bit | -| |<2.6.25.R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap |Update installed ECC 256bit | -| |<2.6.26.R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap |Update installed ECC 512bit | -| |<2.6.27.R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap_>`_ |PrivateKey | -+-------+--------------------------------------------------------------+---------------------------------+ -|AES |`R_SCE_AES128ECB_EncryptInit |Initialization function | -| |<2.6.28.R_SCE_AES128ECB_EncryptInit_>`_ |(AES-128 ECB encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128ECB_EncryptUpdate |Update function | -| |<2.6.29.R_SCE_AES128ECB_EncryptUpdate_>`_ |(AES-128 ECB encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128ECB_EncryptFinal |Termination function | -| |<2.6.30.R_SCE_AES128ECB_EncryptFinal_>`_ |(AES-128 ECB encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128ECB_DecryptInit |Initialization function | -| |<2.6.31.R_SCE_AES128ECB_DecryptInit_>`_ |(AES-128 ECB decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128ECB_DecryptUpdate |Update function | -| |<2.6.32.R_SCE_AES128ECB_DecryptUpdate_>`_ |(AES-128 ECB decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128ECB_DecryptFinal |Termination function | -| |<2.6.33.R_SCE_AES128ECB_DecryptFinal_>`_ |(AES-256 ECB decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256ECB_EncryptInit |Initialization function | -| |<2.6.34.R_SCE_AES256ECB_EncryptInit_>`_ |(AES-256 ECB encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256ECB_EncryptUpdate |Update function | -| |<2.6.35.R_SCE_AES256ECB_EncryptUpdate_>`_ |(AES-256 ECB encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256ECB_EncryptFinal |Termination function | -| |<2.6.36.R_SCE_AES256ECB_EncryptFinal_>`_ |(AES-256 ECB encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256ECB_DecryptInit |Initialization function | -| |<2.6.37.R_SCE_AES256ECB_DecryptInit_>`_ |(AES-256 ECB decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256ECB_DecryptUpdate |Update function | -| |<2.6.38.R_SCE_AES256ECB_DecryptUpdate_>`_ |(AES-256 ECB decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256ECB_DecryptFinal |Termination function | -| |<2.6.39.R_SCE_AES256ECB_DecryptFinal_>`_ |(AES-256 ECB decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CBC_EncryptInit |Initialization function | -| |<2.6.40.R_SCE_AES128CBC_EncryptInit_>`_ |(AES-128 CBC encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CBC_EncryptUpdate |Update function | -| |<2.6.41.R_SCE_AES128CBC_EncryptUpdate_>`_ |(AES-128 CBC encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CBC_EncryptFinal |Termination function | -| |<2.6.42.R_SCE_AES128CBC_EncryptFinal_>`_ |(AES-128 CBC encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CBC_DecryptInit |Initialization function | -| |<2.6.43.R_SCE_AES128CBC_DecryptInit_>`_ |(AES-128 CBC decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CBC_DecryptUpdate |Update function | -| |<2.6.44.R_SCE_AES128CBC_DecryptUpdate_>`_ |(AES-128 CBC decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CBC_DecryptFinal |Termination function | -| |<2.6.45.R_SCE_AES128CBC_DecryptFinal_>`_ |(AES-128 CBC decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CBC_EncryptInit |Initialization function | -| |<2.6.46.R_SCE_AES256CBC_EncryptInit_>`_ |(AES-256 CBC encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CBC_EncryptUpdate |Update function | -| |<2.6.47.R_SCE_AES256CBC_EncryptUpdate_>`_ |(AES-256 CBC encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CBC_EncryptFinal |Termination function | -| |<2.6.48.R_SCE_AES256CBC_EncryptFinal_>`_ |(AES-256 CBC encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CBC_DecryptInit |Initialization function | -| |<2.6.49.R_SCE_AES256CBC_DecryptInit_>`_ |(AES-256 CBC decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CBC_DecryptUpdate |Update function | -| |<2.6.50.R_SCE_AES256CBC_DecryptUpdate_>`_ |(AES-256 CBC decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CBC_DecryptFinal |Termination function | -| |<2.6.51.R_SCE_AES256CBC_DecryptFinal_>`_ |(AES-256 CBC decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CTR_EncryptInit |Initialization function | -| |<2.6.52.R_SCE_AES128CTR_EncryptInit_>`_ |(AES-128 CTR encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CTR_EncryptUpdate |Update function | -| |<2.6.53.R_SCE_AES128CTR_EncryptUpdate_>`_ |(AES-128 CTR encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CTR_EncryptFinal |Termination function | -| |<2.6.54.R_SCE_AES128CTR_EncryptFinal_>`_ |(AES-128 CTR encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CTR_DecryptInit |Initialization function | -| |<2.6.55.R_SCE_AES128CTR_DecryptInit_>`_ |(AES-128 CTR decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CTR_DecryptUpdate |Update function | -| |<2.6.56.R_SCE_AES128CTR_DecryptUpdate_>`_ |(AES-128 CTR decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CTR_DecryptFinal |Termination function | -| |<2.6.57.R_SCE_AES128CTR_DecryptFinal_>`_ |(AES-128 CTR decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CTR_EncryptInit |Initialization function | -| |<2.6.58.R_SCE_AES256CTR_EncryptInit_>`_ |(AES-256 CTR encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CTR_EncryptUpdate |Update function | -| |<2.6.59.R_SCE_AES256CTR_EncryptUpdate_>`_ |(AES-256 CTR encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CTR_EncryptFinal |Termination function | -| |<2.6.60.R_SCE_AES256CTR_EncryptFinal_>`_ |(AES-256 CTR encryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CTR_DecryptInit |Initialization function | -| |<2.6.61.R_SCE_AES256CTR_DecryptInit_>`_ |(AES-256 CTR decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CTR_DecryptUpdate |Update function | -| |<2.6.62.R_SCE_AES256CTR_DecryptUpdate_>`_ |(AES-256 CTR decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CTR_DecryptFinal |Termination function | -| |<2.6.63.R_SCE_AES256CTR_DecryptFinal_>`_ |(AES-256 CTR decryption) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CMAC_GenerateInit |Initialization function | -| |<2.6.64.R_SCE_AES128CMAC_GenerateInit_>`_ |(AES-128 CMAC generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CMAC_GenerateUpdate |Update function | -| |<2.6.65.R_SCE_AES128CMAC_GenerateUpdate_>`_ |(AES-128 CMAC generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CMAC_GenerateFinal |Termination function | -| |<2.6.66.R_SCE_AES128CMAC_GenerateFinal_>`_ |(AES-128 CMAC generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CMAC_VerifyInit |Initialization function | -| |<2.6.67.R_SCE_AES128CMAC_VerifyInit_>`_ |(AES-128 CMAC verification) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CMAC_VerifyUpdate |Update function | -| |<2.6.68.R_SCE_AES128CMAC_VerifyUpdate_>`_ |(AES-128 CMAC verification) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES128CMAC_VerifyFinal |Termination function | -| |<2.6.69.R_SCE_AES128CMAC_VerifyFinal_>`_ |(AES-128 CMAC verification) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CMAC_GenerateInit |Initialization function | -| |<2.6.70.R_SCE_AES256CMAC_GenerateInit_>`_ |(AES-256 CMAC generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CMAC_GenerateUpdate |Update function | -| |<2.6.71.R_SCE_AES256CMAC_GenerateUpdate_>`_ |(AES-256 CMAC generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CMAC_GenerateFinal |Termination function | -| |<2.6.72.R_SCE_AES256CMAC_GenerateFinal_>`_ |(AES-256 CMAC generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CMAC_VerifyInit |Initialization function | -| |<2.6.73.R_SCE_AES256CMAC_VerifyInit_>`_ |(AES-256 CMAC verification) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CMAC_VerifyUpdate |Update function | -| |<2.6.74.R_SCE_AES256CMAC_VerifyUpdate_>`_ |(AES-256 CMAC verification) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_AES256CMAC_VerifyFinal |Termination function | -| |<2.6.75.R_SCE_AES256CMAC_VerifyFinal_>`_ |(AES-256 CMAC verification) | -+-------+--------------------------------------------------------------+---------------------------------+ -|SHA |`R_SCE_SHA256_Init |Initialization function | -| |<2.6.76.R_SCE_SHA256_Init_>`_ |(SHA-256 hash value generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_SHA256_Update |Update function | -| |<2.6.77.R_SCE_SHA256_Update_>`_ |(SHA-256 hash value generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_SHA256_Final |Termination function | -| |<2.6.78.R_SCE_SHA256_Final_>`_ |(SHA-256 hash value generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_SHA224_Init |Initialization function | -| |<2.6.79.R_SCE_SHA224_Init_>`_ |(SHA-224 hash value generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_SHA224_Update |Update function | -| |<2.6.80.R_SCE_SHA224_Update_>`_ |(SHA-224 hash value generation) | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_SHA224_Final |Termination function | -| |<2.6.81.R_SCE_SHA224_Final_>`_ |(SHA-224 hash value generation) | -+-------+--------------------------------------------------------------+---------------------------------+ -|RSA |`R_SCE_RSASSA_PKCS1024_SignatureGenerate |RSA Signature Generation | -| |<2.6.82.R_SCE_RSASSA_PKCS1024_SignatureGenerate_>`_ |with 1024bit key | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSASSA_PKCS1024_SignatureVerify |RSA Signature verification | -| |<2.6.83.R_SCE_RSASSA_PKCS1024_SignatureVerify_>`_ |with 1024bit key | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSASSA_PKCS2048_SignatureGenerate |RSA Signature Generation | -| |<2.6.84.R_SCE_RSASSA_PKCS2048_SignatureGenerate_>`_ |with 2048bit key | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSASSA_PKCS2048_SignatureVerify |RSA Signature verification | -| |<2.6.85.R_SCE_RSASSA_PKCS2048_SignatureVerify_>`_ |with 2048bit key | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSASSA_PKCS4096_SignatureVerify |RSA Signature verification | -| |<2.6.86.R_SCE_RSASSA_PKCS4096_SignatureVerify_>`_ |with 4096bit key | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSAES_PKCS1024_Encrypt |RSA 1024bit encryption function | -| |<2.6.87.R_SCE_RSAES_PKCS1024_Encrypt_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSAES_PKCS1024_Decrypt |RSA 1024bit decryption function | -| |<2.6.88.R_SCE_RSAES_PKCS1024_Decrypt_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSAES_PKCS2048_Encrypt |RSA 2048bit encryption function | -| |<2.6.89.R_SCE_RSAES_PKCS2048_Encrypt_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSAES_PKCS2048_Decrypt |RSA 1024bit decryption function | -| |<2.6.90.R_SCE_RSAES_PKCS2048_Decrypt_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_RSAES_PKCS4096_Encrypt |RSA 4096bit encryption function | -| |<2.6.91.R_SCE_RSAES_PKCS4096_Encrypt_>`_ | | -+-------+--------------------------------------------------------------+---------------------------------+ -|ECC |`R_SCE_ECDSA_secp192r1_SignatureGenerate |192bit ECC Signature Generation | -| |<2.6.92.R_SCE_ECDSA_secp192r1_SignatureGenerate_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_secp224r1_SignatureGenerate |224bit ECC Signature Generation | -| |<2.6.93.R_SCE_ECDSA_secp224r1_SignatureGenerate_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_secp256r1_SignatureGenerate |256bit ECC Signature Generation | -| |<2.6.94.R_SCE_ECDSA_secp256r1_SignatureGenerate_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate |512bit ECC Signature verification| -| |<2.6.95.R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_secp192r1_SignatureVerify |192bit ECC Signature verification| -| |<2.6.96.R_SCE_ECDSA_secp192r1_SignatureVerify_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_secp224r1_SignatureVerify |224bit ECC Signature verification| -| |<2.6.97.R_SCE_ECDSA_secp224r1_SignatureVerify_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_secp256r1_SignatureVerify |256bit ECC Signature verification| -| |<2.6.98.R_SCE_ECDSA_secp256r1_SignatureVerify_>`_ | | -| +--------------------------------------------------------------+---------------------------------+ -| |`R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify |512bit ECC Signature verification| -| |<2.6.99.R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify_>`_ | | -+-------+--------------------------------------------------------------+---------------------------------+ - - -************************************************************************* -2.3.Return Values and Constants -************************************************************************* -The return values for the SCE driver API functions is shown below. - -.. csv-table:: Return values for the SCE driver API functions - :header: "Return Code", "Value", "Description" - - FSP_SUCCESS,0,"Normal termination" - FSP_ERR_CRYPTO_CONTINUE,0x10000,"Continue executing function" - FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT,0x10001,"Hardware resource busy" - FSP_ERR_CRYPTO_SCE_FAIL,0x10002,"Internal I/O buffer is not empty" - FSP_ERR_CRYPTO_SCE_HRK_INVALID_INDEX,0x10003,"Invalid index" - FSP_ERR_CRYPTO_SCE_RETRY,0x10004,"Retry" - FSP_ERR_CRYPTO_SCE_VERIFY_FAIL,0x10005,"Verify is failed" - FSP_ERR_CRYPTO_SCE_ALREADY_OPEN,0x10006,"HW SCE module is already opened" - FSP_ERR_CRYPTO_NOT_OPEN,0x10007,"Hardware module is not initialized" - FSP_ERR_CRYPTO_UNKNOWN,0x10008,"Some unknown error occurred" - FSP_ERR_CRYPTO_NULL_POINTER,0x10009,"Null pointer input as a parameter" - FSP_ERR_CRYPTO_NOT_IMPLEMENTED,0x1000a,"Algorithm/size not implemented" - FSP_ERR_CRYPTO_RNG_INVALID_PARAM,0x1000b,"An invalid parameter is specified" - FSP_ERR_CRYPTO_RNG_FATAL_ERROR,0x1000c,"A fatal error occurred" - FSP_ERR_CRYPTO_INVALID_SIZE,0x1000d,"Size specified is invalid" - FSP_ERR_CRYPTO_INVALID_STATE,0x1000e,"Function used in an valid state" - FSP_ERR_CRYPTO_ALREADY_OPEN,0x1000f,"control block is already opened" - FSP_ERR_CRYPTO_INSTALL_KEY_FAILED,0x10010,"Specified input key is invalid." - FSP_ERR_CRYPTO_AUTHENTICATION_FAILED,0x10011,"Authentication failed" - FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL,0x10012,"Failure to Init Cipher" - FSP_ERR_CRYPTO_SCE_AUTHENTICATION,0x10013,"Authentication failed" - FSP_ERR_CRYPTO_SCE_PARAMETER,0x10014,"Input date is illegal." - FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION,0x10015,"An invalid function call occurred." - FSP_ERR_CRYPTO_COMMON_NOT_OPENED,0x20000,"Crypto Framework Common is not opened" - FSP_ERR_CRYPTO_HAL_ERROR,0x20001,"Cryoto HAL module returned an error" - FSP_ERR_CRYPTO_KEY_BUF_NOT_ENOUGH,0x20002,"Key buffer size is not enough to generate a key" - FSP_ERR_CRYPTO_BUF_OVERFLOW,0x20003,"Attempt to write data larger than what the buffer can hold" - FSP_ERR_CRYPTO_INVALID_OPERATION_MODE,0x20004,"Invalid operation mode." - FSP_ERR_MESSAGE_TOO_LONG,0x20005,"Message for RSA encryption is too long." - FSP_ERR_RSA_DECRYPTION_ERROR,0x20006,"RSA Decryption error." - -The macro constants defined by the SCE driver is shown below. - -.. csv-table:: Macro define for Common operation - :header: "Macro Code", "Value" - - HW_SCE_SRAM_WORD_SIZE,32U - HW_SCE_SINST_WORD_SIZE,140U - HW_SCE_SINST2_WORD_SIZE,16U - HW_SCE_SHEAP_WORD_SIZE,1504U - HW_SCE_MAC_SIZE,16U - -.. csv-table:: Macro define for AES operation - :header: "Macro Code", "Value" - - HW_SCE_AES128_KEY_INDEX_WORD_SIZE,12U - HW_SCE_AES256_KEY_INDEX_WORD_SIZE,16U - HW_SCE_AES128_KEY_WORD_SIZE,4U - HW_SCE_AES256_KEY_WORD_SIZE,8U - HW_SCE_AES128_KEY_BYTE_SIZE,16U - HW_SCE_AES256_KEY_BYTE_SIZE,32U - HW_SCE_AES_BLOCK_BYTE_SIZE,16U - HW_SCE_AES_BLOCK_BIT_SIZE,128U - HW_SCE_AES_CBC_IV_BYTE_SIZE,16U - HW_SCE_AES_CTR_IV_BYTE_SIZE,16U - -.. csv-table:: Macro define for SHA operation - :header: "Macro Code", "Value" - - HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE,28U - HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE,32U - HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE,64U - -.. csv-table:: Macro define for RSA operation - :header: "Macro Code", "Value" - - HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE,128U - HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE,4U - HW_SCE_RSA_1024_KEY_D_LENGTH_BYTE_SIZE,128U - HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE,256U - HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE,4U - HW_SCE_RSA_2048_KEY_D_LENGTH_BYTE_SIZE,256U - HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE,128*4U - HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE,4U - HW_SCE_RSA_4096_KEY_D_LENGTH_BYTE_SIZE,128*4U - HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U - HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE,36U - HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U - HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE,68U - HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U - HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE,68U - HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U - HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE,132U - HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE,4U - HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE,4U - HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE,12U - HW_SCE_RSA1024_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE,76U - HW_SCE_RSA1024_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE,104U - HW_SCE_RSA2048_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE,140U - HW_SCE_RSA2048_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE,200U - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE,11U - HW_SCE_RSA_1024_DATA_BYTE_SIZE,128U - HW_SCE_RSA_2048_DATA_BYTE_SIZE,256U - HW_SCE_RSA_4096_DATA_BYTE_SIZE,128*4U - HW_SCE_SHARED_SECRET_KEY_INDEX_WORD_SIZE,13U - -.. csv-table:: Macro define for ECC operation - :header: "Macro Code", "Value" - - HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE,144U - HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE,4U - HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE,24U - HW_SCE_ECDSA_DATA_BYTE_SIZE,64U - HW_SCE_ECDSA_P512_DATA_BYTE_SIZE,128U - SCE_ECC_CURVE_TYPE_NIST,0 - SCE_ECC_CURVE_TYPE_BRAINPOOL,1 - SCE_ECC_CURVE_TYPE_KOBLITZ,2 - SCE_ECC_KEY_LENGTH_256,0 - SCE_ECC_KEY_LENGTH_224,1 - SCE_ECC_KEY_LENGTH_192,2 - -.. csv-table:: Macro define for HASH type - :header: "Macro Code", "Value" - - HW_SCE_RSA_HASH_SHA256,0x03 - -.. csv-table:: Macro define for Key update - :header: "Macro Code", "Value" - - HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE,16U - SCE_OEM_KEY_SIZE_DUMMY_INST_DATA_WORD,0 - SCE_OEM_KEY_SIZE_AES128_INST_DATA_WORD,8 - SCE_OEM_KEY_SIZE_AES256_INST_DATA_WORD,12 - SCE_OEM_KEY_SIZE_RSA1024_PUBLIC_KEY_INST_DATA_WORD,40 - SCE_OEM_KEY_SIZE_RSA1024_PRIVATE_KEY_INST_DATA_WORD,68 - SCE_OEM_KEY_SIZE_RSA2048_PUBLIC_KEY_INST_DATA_WORD,72 - SCE_OEM_KEY_SIZE_RSA2048_PRIVATE_KEY_INST_DATA_WORD,132 - SCE_OEM_KEY_SIZE_RSA4096_PUBLIC_KEY_INST_DATA_WORD,136 - SCE_OEM_KEY_SIZE_RSA4096_PRIVATE_KEY_INST_DATA_WORD,260 - SCE_OEM_KEY_SIZE_ECCP192_PUBLIC_KEY_INST_DATA_WORD,20 - SCE_OEM_KEY_SIZE_ECCP192_PRIVATE_KEY_INST_DATA_WORD,12 - SCE_OEM_KEY_SIZE_ECCP224_PUBLIC_KEY_INST_DATA_WORD,20 - SCE_OEM_KEY_SIZE_ECCP224_PRIVATE_KEY_INST_DATA_WORD,12 - SCE_OEM_KEY_SIZE_ECCP256_PUBLIC_KEY_INST_DATA_WORD,20 - SCE_OEM_KEY_SIZE_ECCP256_PRIVATE_KEY_INST_DATA_WORD,12 - SCE_INSTALL_KEY_RING_INDEX,0 - - -************************************************************************* -2.4.Structure and Enumerations -************************************************************************* - -------------------------------------------------------- -SCE_KEY_INDEX_TYPE -------------------------------------------------------- - -.. code:: c - - typedef enum - { - SCE_KEY_INDEX_TYPE_INVALID = 0U, - SCE_KEY_INDEX_TYPE_AES128, - SCE_KEY_INDEX_TYPE_AES256, - SCE_KEY_INDEX_TYPE_TDES, - SCE_KEY_INDEX_TYPE_HMAC_SHA1, - SCE_KEY_INDEX_TYPE_HMAC_SHA256, - SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE, - SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE, - SCE_KEY_INDEX_TYPE_RSA3072_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA3072_PRIVATE, - SCE_KEY_INDEX_TYPE_RSA4096_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA4096_PRIVATE, - SCE_KEY_INDEX_TYPE_AES128_FOR_TLS, - SCE_KEY_INDEX_TYPE_AES192_FOR_TLS, - SCE_KEY_INDEX_TYPE_AES256_FOR_TLS, - SCE_KEY_INDEX_TYPE_HMAC_SHA1_FOR_TLS, - SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_TLS, - SCE_KEY_INDEX_TYPE_UPDATE_KEY_RING, - SCE_KEY_INDEX_TYPE_TLS_CA_CERTIFICATION_PUBLIC_KEY, - SCE_KEY_INDEX_TYPE_TLS_P256_ECC_KEY, - SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P256R1_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P512R1_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P256R1_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P512R1_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PRIVATE, - SCE_KEY_INDEX_TYPE_ECDH_SHARED_SECRET, - SCE_KEY_INDEX_TYPE_AES128_FOR_ECDH, - SCE_KEY_INDEX_TYPE_AES256_FOR_ECDH, - SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_ECDH, - SCE_KEY_INDEX_TYPE_AES128_GCM_FOR_DLMS_COSEM, - SCE_KEY_INDEX_TYPE_AES256_GCM_FOR_DLMS_COSEM, - SCE_KEY_INDEX_TYPE_AES128_KEY_WRAP_FOR_DLMS_COSEM, - SCE_KEY_INDEX_TYPE_AES128_GCM_WITH_IV, - } SCE_KEY_INDEX_TYPE; - -------------------------------------------------------- -sce_oem_cmd -------------------------------------------------------- - -.. code:: c - - typedef enum e_sce_oem_cmd - { - SCE_OEM_CMD_AES128 = 5, - SCE_OEM_CMD_AES256 = 7, - SCE_OEM_CMD_RSA1024_PUBLIC = 10, - SCE_OEM_CMD_RSA1024_PRIVATE, - SCE_OEM_CMD_RSA2048_PUBLIC, - SCE_OEM_CMD_RSA2048_PRIVATE, - SCE_OEM_CMD_RSA3072_PUBLIC, - SCE_OEM_CMD_RSA3072_PRIVATE, - SCE_OEM_CMD_RSA4096_PUBLIC, - SCE_OEM_CMD_RSA4096_PRIVATE, - SCE_OEM_CMD_ECC_P192_PUBLIC, - SCE_OEM_CMD_ECC_P192_PRIVATE, - SCE_OEM_CMD_ECC_P224_PUBLIC, - SCE_OEM_CMD_ECC_P224_PRIVATE, - SCE_OEM_CMD_ECC_P256_PUBLIC, - SCE_OEM_CMD_ECC_P256_PRIVATE, - SCE_OEM_CMD_ECC_P384_PUBLIC, - SCE_OEM_CMD_ECC_P384_PRIVATE, - SCE_OEM_CMD_ECC_P512_PUBLIC, - SCE_OEM_CMD_ECC_P512_PRIVATE, - SCE_OEM_CMD_HMAC_SHA256 = 28, - SCE_OEM_CMD_NUM - } sce_oem_cmd_t; - -------------------------------------------------------- -sce_byte_data -------------------------------------------------------- -Byte data structure - -.. code:: c - - typedef struct sce_byte_data - { - uint8_t * pdata; ///< pointer - uint32_t data_length; ///< data_length - uint32_t data_type; ///< data type - } sce_byte_data_t; - -------------------------------------------------------- -sce_rsa_byte_data_t -------------------------------------------------------- -RSA byte data structure - -.. code:: c - - typedef sce_byte_data_t sce_rsa_byte_data_t; ///< byte data - -------------------------------------------------------- -sce_ecdsa_byte_data_t -------------------------------------------------------- -ECDSA byte data structure - -.. code:: c - - typedef sce_byte_data_t sce_ecdsa_byte_data_t; ///< byte data - -------------------------------------------------------- -sce_aes_wrapped_key_t -------------------------------------------------------- -AES wrapped key data structure. DO NOT MODIFY. - -.. code:: c - - typedef struct sce_aes_wrapped_key - { - uint32_t type; ///< key type - - /* AES128, AES256 are supported */ - uint32_t value[SCE_TLS_AES256_KEY_INDEX_WORD_SIZE]; ///< wrapped key value - } sce_aes_wrapped_key_t; - -------------------------------------------------------- -sce_rsa1024_public_wrapped_key_t -------------------------------------------------------- -RSA 1024bit public wrapped key data structure. DO NOT MODIFY. - -.. code:: c - - typedef struct sce_rsa1024_public_wrapped_key - { - uint32_t type; ///< key type - struct - { - uint32_t key_management_info1[HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information - uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 1024-bit public key n (plaintext) - uint8_t key_e[HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE]; ///< RSA 1024-bit public key e (plaintext) - uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; ///< dummy - uint32_t key_management_info2[HW_SCE_AES256_KEY_INDEX_WORD_SIZE]; ///< key management information - } value; - } sce_rsa1024_public_wrapped_key_t; - -------------------------------------------------------- -sce_rsa1024_private_wrapped_key_t -------------------------------------------------------- -RSA 1024bit private wrapped key data structure. DO NOT MODIFY. - -.. code:: c - - typedef struct sce_rsa1024_private_wrapped_key - { - uint32_t type; ///< key type - struct - { - uint32_t key_management_info1[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information - uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 1024-bit private key n (plaintext) - uint32_t key_management_info2[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information - } value; - } sce_rsa1024_private_wrapped_key_t; - -------------------------------------------------------- -sce_rsa2048_public_wrapped_key_t -------------------------------------------------------- -RSA 2048bit public wrapped key data structure. DO NOT MODIFY. - -.. code:: c - - typedef struct sce_rsa2048_public_wrapped_key - { - uint32_t type; ///< Key type - struct - { - uint32_t key_management_info1[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information - uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 2048-bit public key n (plaintext) - uint8_t key_e[HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE]; ///< RSA 2048-bit public key e (plaintext) - uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; ///< dummy - uint32_t key_management_info2[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information - } value; - } sce_rsa2048_public_wrapped_key_t; - -------------------------------------------------------- -sce_rsa2048_private_wrapped_key_t -------------------------------------------------------- -RSA 2048bit private wrapped key data structure. DO NOT MODIFY. - -.. code:: c - - typedef struct sce_rsa2048_private_wrapped_key - { - uint32_t type; ///< key type - struct - { - uint32_t key_management_info1[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information - uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 2048-bit private key n (plaintext) - uint32_t key_management_info2[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information - } value; - } sce_rsa2048_private_wrapped_key_t; - -------------------------------------------------------- -sce_rsa4096_public_wrapped_key_t -------------------------------------------------------- -RSA 4096bit public wrapped key data structure. DO NOT MODIFY. - -.. code:: c - - typedef struct sce_rsa4096_public_wrapped_key - { - uint32_t type; ///< Key type - struct - { - uint32_t key_management_info1[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; ///< key management information - uint8_t key_n[HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE]; ///< RSA 4096-bit public key n (plaintext) - uint8_t key_e[HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE]; ///< RSA 4096-bit public key e (plaintext) - uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; ///< dummy - uint32_t key_management_info2[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; ///< key management information - } value; - } sce_rsa4096_public_wrapped_key_t; - -------------------------------------------------------- -sce_rsa1024_wrapped_pair_key_t -------------------------------------------------------- -RSA 1024bit wrapped key pair structure. DO NOT MODIFY. - -.. code:: c - - typedef struct sce_rsa1024_wrapped_pair_key - { - sce_rsa1024_private_wrapped_key_t priv_key; ///< RSA 1024-bit private wrapped key - sce_rsa1024_public_wrapped_key_t pub_key; ///< RSA 1024-bit public wrapped key - } sce_rsa1024_wrapped_pair_key_t; - -------------------------------------------------------- -sce_rsa2048_wrapped_pair_key_t -------------------------------------------------------- -RSA 2048bit wrapped key pair structure. DO NOT MODIFY. - -.. code:: c - - typedef struct sce_rsa2048_wrapped_pair_key - { - sce_rsa2048_private_wrapped_key_t priv_key; ///< RSA 2048-bit private wrapped key - sce_rsa2048_public_wrapped_key_t pub_key; ///< RSA 2048-bit public wrapped key - } sce_rsa2048_wrapped_pair_key_t; - -------------------------------------------------------- -sce_ecc_private_wrapped_key_t -------------------------------------------------------- -ECC P-192/224/256/512 private wrapped key data structure. - -.. code:: c - - typedef struct sce_ecc_private_wrapped_key - { - uint32_t type; ///< key type - uint32_t value[HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE]; ///< wrapped key value - } sce_ecc_private_wrapped_key_t; - - -------------------------------------------------------- -sce_ecc_public_wrapped_key_t -------------------------------------------------------- -ECC P-192/224/256/512 public wrapped key data structure. - -.. code:: c - - typedef struct sce_ecc_public_wrapped_key - { - uint32_t type; ///< key type - struct - { - uint32_t key_management_info[HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE]; ///< key management information - uint8_t key_q[HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE]; ///< ECC public key Q (plaintext) - } value; - } sce_ecc_public_wrapped_key_t; - -------------------------------------------------------- -sce_ecc_wrapped_pair_key_t -------------------------------------------------------- -ECC P-192/224/256/512 wrapped key pair structure. - -.. code:: c - - typedef struct sce_ecc_wrapped_pair_key - { - sce_ecc_private_wrapped_key_t priv_key; ///< ECC private wrapped key - sce_ecc_public_wrapped_key_t pub_key; ///< ECC public wrapped key - } sce_ecc_wrapped_pair_key_t; - -------------------------------------------------------- -sce_key_update_key_t -------------------------------------------------------- -Update key ring index data structure. DO NOT MODIFY. - -.. code:: c - - typedef struct sce_key_update_key - { - uint32_t type; ///< key type - uint32_t value[HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE]; ///< wrapped key value - } sce_key_update_key_t; - -------------------------------------------------------- -sce_aes_handle_t -------------------------------------------------------- -The work area for AES. DO NOT MODIFY. - -.. code:: c - - typedef struct sce_aes_handle - { - uint32_t id; ///< serial number of this handle - sce_aes_wrapped_key_t wrapped_key; ///< wrapped key - uint32_t current_input_data_size; ///< text size under encryption / decryption - uint8_t last_1_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE]; ///< text array less than the block long - uint8_t last_2_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE * 2]; ///< reserved - uint8_t current_initial_vector[HW_SCE_AES_CBC_IV_BYTE_SIZE]; ///< current initialization vector used in CBC mode - uint8_t flag_call_init; ///< control flag of calling function - } sce_aes_handle_t; - -------------------------------------------------------- -sce_cmac_handle_t -------------------------------------------------------- -The work area for CMAC. DO NOT MODIFY. - -.. code:: c - - typedef struct sce_cmac_handle - { - uint32_t id; ///< serial number of this handle - sce_aes_wrapped_key_t wrapped_key; ///< wrapped key - uint8_t cmac_buffer[HW_SCE_AES_BLOCK_BYTE_SIZE]; ///< message array less than the block long - uint32_t all_received_length; ///< entire length of message - uint32_t buffering_length; ///< message array length less than the block long - uint8_t flag_call_init; ///< control flag of calling function - } sce_cmac_handle_t; - -------------------------------------------------------- -sce_sha_md5_handle_t -------------------------------------------------------- -The work area for SHA. DO NOT MODIFY. - -.. code:: c - - typedef struct sce_sha_md5_handle - { - uint32_t id; ///< serial number of this handle - uint8_t sha_buffer[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE * 4]; ///< message array length less than the block long - uint32_t all_received_length; ///< entire length of message - uint32_t buffering_length; ///< message array length less than the block long - - /* SHA1(20byte), SHA256(32byte), MD5(16byte) are supported */ - uint8_t current_hash[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE]; ///< last hash value - uint8_t flag_call_init; ///< control flag of calling function - } sce_sha_md5_handle_t; - -------------------------------------------------------- -sce_ctrl_t -------------------------------------------------------- - -.. code:: c - - typedef void sce_ctrl_t; - -------------------------------------------------------- -sce_cfg_t -------------------------------------------------------- - -.. code:: c - - typedef void sce_cfg_t; - - -------------------------------------------------------- -sce_api_t -------------------------------------------------------- -Functions implemented in sce driver. - -.. code:: c - - typedef struct st_sce_api - { - - fsp_err_t (* open)(sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg); - - fsp_err_t (* close)(sce_ctrl_t * const p_ctrl); - - fsp_err_t (* softwareReset)(void); - - fsp_err_t (* randomNumberGenerate)(uint32_t * random); - - fsp_err_t (* AES128_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES256_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES128_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES256_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES128ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES128ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - fsp_err_t (* AES128ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - fsp_err_t (* AES128ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES128ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - fsp_err_t (* AES128ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - fsp_err_t (* AES256ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES256ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - fsp_err_t (* AES256ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - fsp_err_t (* AES256ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES256ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - fsp_err_t (* AES256ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - fsp_err_t (* AES128CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES128CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - fsp_err_t (* AES128CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - fsp_err_t (* AES128CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES128CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - fsp_err_t (* AES128CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - fsp_err_t (* AES256CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES256CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - fsp_err_t (* AES256CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - fsp_err_t (* AES256CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES256CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - fsp_err_t (* AES256CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - fsp_err_t (* AES128CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES128CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - fsp_err_t (* AES128CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - fsp_err_t (* AES128CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES128CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - fsp_err_t (* AES128CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - fsp_err_t (* AES256CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES256CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - fsp_err_t (* AES256CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - fsp_err_t (* AES256CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - fsp_err_t (* AES256CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - fsp_err_t (* AES256CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - fsp_err_t (* AES128CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES128CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - fsp_err_t (* AES128CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); - - fsp_err_t (* AES128CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES128CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - fsp_err_t (* AES128CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); - - fsp_err_t (* AES256CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES256CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - fsp_err_t (* AES256CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); - - fsp_err_t (* AES256CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - fsp_err_t (* AES256CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - fsp_err_t (* AES256CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); - - fsp_err_t (* SHA256_Init)(sce_sha_md5_handle_t * handle); - - fsp_err_t (* SHA256_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); - - fsp_err_t (* SHA256_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); - - fsp_err_t (* SHA224_Init)(sce_sha_md5_handle_t * handle); - - fsp_err_t (* SHA224_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); - - fsp_err_t (* SHA224_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); - - fsp_err_t (* RSA1024_WrappedKeyPairGenerate)(sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key); - - fsp_err_t (* RSA2048_WrappedKeyPairGenerate)(sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key); - - fsp_err_t (* RSA1024_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSA1024_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSA2048_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSA2048_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSA4096_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa4096_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSASSA_PKCS1024_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, sce_rsa_byte_data_t * signature, - sce_rsa1024_private_wrapped_key_t * wrapped_key, uint8_t hash_type); - - fsp_err_t (* RSASSA_PKCS2048_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, sce_rsa_byte_data_t * signature, - sce_rsa2048_private_wrapped_key_t * wrapped_key, uint8_t hash_type); - - fsp_err_t (* RSASSA_PKCS1024_SignatureVerify)(sce_rsa_byte_data_t * signature, sce_rsa_byte_data_t * message_hash, - sce_rsa1024_public_wrapped_key_t * wrapped_key, uint8_t hash_type); - - fsp_err_t (* RSASSA_PKCS2048_SignatureVerify)(sce_rsa_byte_data_t * signature, sce_rsa_byte_data_t * message_hash, - sce_rsa2048_public_wrapped_key_t * wrapped_key, uint8_t hash_type); - - fsp_err_t (* RSASSA_PKCS4096_SignatureVerify)(sce_rsa_byte_data_t * signature, sce_rsa_byte_data_t * message_hash, - sce_rsa4096_public_wrapped_key_t * wrapped_key, uint8_t hash_type); - - fsp_err_t (* RSAES_PKCS1024_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, - sce_rsa1024_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSAES_PKCS2048_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, - sce_rsa2048_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSAES_PKCS4096_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, - sce_rsa4096_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSAES_PKCS1024_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, - sce_rsa1024_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* RSAES_PKCS2048_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, - sce_rsa2048_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_secp192r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - fsp_err_t (* ECC_secp224r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - fsp_err_t (* ECC_secp256r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - fsp_err_t (* ECC_secp192r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_secp224r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_secp256r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_secp192r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_secp224r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_secp256r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_secp192r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_secp224r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_secp256r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_secp192r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_secp224r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_secp256r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - - fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - } sce_api_t; - -------------------------------------------------------- -sce_instance_t -------------------------------------------------------- -This structure encompasses everything that is needed to use an instance of this interface. - -.. code:: c - - typedef struct st_sce_instance - { - sce_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance - sce_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance - sce_api_t const * p_api; ///< Pointer to the API structure for this instance - } sce_instance_t; - -************************************************************************* -2.5.Global Variables -************************************************************************* -There are no global variables that can be used by users. - - -************************************************************************* -2.6.Function Specifications -************************************************************************* - -------------------------------------------------------- -2.6.1.R_SCE_Open -------------------------------------------------------- -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_Open ( sce_ctrl_t const \*\p_ctrl, sce_cfg_t const \*\const p_cfg ) | -+--------------+---------------------------------------------------------------------------------+ -| Description | Enables use of SCE functionality. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |p_ctrl |Pointer to control structure. | -| +---------+--------------------------+--------------------------------------------+ -| |IN |p_cfg |Pointer to pin configuration structure. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |The error-detection self-test failed to | -| | ||br| terminate normally. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RETRY |Indicates that an entropy evaluation failure| -| | ||br| occurred. Run the function again. | -+--------------+------------------------------------+--------------------------------------------+ -| Note | | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.2.R_SCE_Close -------------------------------------------------------- -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_Close ( sce_ctrl_t \*\const p_ctrl) | -+--------------+---------------------------------------------------------------------------------+ -| Description | Stops supply of power to the SCE. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |p_ctrl |Pointer to control structure. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -+--------------+------------------------------------+--------------------------------------------+ -| Note | | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.3.R_SCE_SoftwareReset -------------------------------------------------------- -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SoftwareReset ( void ) | -+--------------+---------------------------------------------------------------------------------+ -| Description | Software reset to SCE. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |none |none |none | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -+--------------+------------------------------------+--------------------------------------------+ -| Note | | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.4.R_SCE_AES128_WrappedKeyGenerate -------------------------------------------------------- -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128_WrappedKeyGenerate ( sce_aes_wrapped_key_t \*\ wrapped_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API outputs 128-bit AES wrapped key from a random number. | -| ||br| This API generates a wrapped key from a random number in the SCE. | -| ||br| Accordingly, user key input is unnecessary. | -| ||br| By encrypting data using the wrapped key is output by this API, | -| ||br| dead copying of data can be prevented. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_key |128-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -+--------------+------------------------------------+--------------------------------------------+ -| Note | | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.5.R_SCE_AES256_WrappedKeyGenerate -------------------------------------------------------- -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256_WrappedKeyGenerate ( sce_aes_wrapped_key_t \*\ wrapped_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API outputs 256-bit AES wrapped key from a random number. | -| ||br| This API generates a wrapped key from a random number in the SCE. | -| ||br| Accordingly, user key input is unnecessary. | -| ||br| By encrypting data using the wrapped key is output by this API, | -| ||br| dead copying of data can be prevented. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_key |256-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -+--------------+------------------------------------+--------------------------------------------+ -| Note | | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.6.R_SCE_RSA1024_WrappedKeyPairGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t | -|R_SCE_RSA1024_WrappedKeyPairGenerate ( sce_rsa1024_wrapped_pair_key_t \*\wrapped_pair_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API outputs a wrapped key pair | -| ||br| for a 1024-bit RSA public key and private key pair.These keys are generated | -| ||br| from a random value produced internally by the SCE. | -| ||br| Consequently, there is no need to input a user key. | -| ||br| Dead copying of data can be prevented by encrypting the data using the | -| ||br| wrapped key output by this API. A public wrapped key is generated by | -| ||br| wrapped_pair_key->pub_key, and a private wrapped key is generated by | -| ||br| wrapped_pair_key->priv_key. | -| ||br| As the public key exponent, only 0x00010001 is generated. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_pair_key |User key index for RSA 1024-bit public key | -| | | ||br| and private key pair | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| Key generation failed. | -+--------------+------------------------------------+--------------------------------------------+ -| Note | | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.7.R_SCE_RSA2048_WrappedKeyPairGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t | -|R_SCE_RSA2048_WrappedKeyPairGenerate ( sce_rsa2048_wrapped_pair_key_t \*\wrapped_pair_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API outputs a wrapped key pair | -| ||br| for a 2048-bit RSA public key and private key pair.These keys are generated | -| ||br| from a random value produced internally by the SCE. | -| ||br| Consequently, there is no need to input a user key. | -| ||br| Dead copying of data can be prevented by encrypting the data using the | -| ||br| wrapped key output by this API. A public wrapped key is generated by | -| ||br| wrapped_pair_key->pub_key, and a private wrapped key is generated by | -| ||br| wrapped_pair_key->priv_key. | -| ||br| As the public key exponent, only 0x00010001 is generated. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_pair_key |User key index for RSA 2048-bit public key | -| | | ||br| and private key pair | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| Key generation failed. | -+--------------+------------------------------------+--------------------------------------------+ -| Note | | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.8.R_SCE_ECC_secp192r1_WrappedKeyPairGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t | -|R_SCE_ECC_secp192r1_WrappedKeyPairGenerate ( sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This is an API for outputting a wrapped key pair for secp192r1 public key | -| ||br| and private key pair. These keys are generated from a random number value | -| ||br| internally within the SCE. There is therefore no need to input user keys. | -| ||br| Consequently, there is no need to input a user key. | -| ||br| It is possible to prevent dead copying of data by using | -| ||br| wrapped key output by this API. A public wrapped key is generated by | -| ||br| the wrapped key output by this API to encrypt the data. | -| ||br| The public key index is generated in wrapped_pair_key->pub_key, | -| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_pair_key |Wrapped pair key forsecp192r1 public key | -| | | ||br| and private key pair | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| Key generation failed. | -+--------------+------------------------------------+--------------------------------------------+ -| Note | | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.9.R_SCE_ECC_secp224r1_WrappedKeyPairGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t | -| R_SCE_ECC_secp224r1_WrappedKeyPairGenerate ( sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This is an API for outputting a wrapped key pair for secp224r1 public key | -| ||br| and private key pair. These keys are generated from a random number value | -| ||br| internally within the SCE. There is therefore no need to input user keys. | -| ||br| Consequently, there is no need to input a user key. | -| ||br| It is possible to prevent dead copying of data by using | -| ||br| wrapped key output by this API. A public wrapped key is generated by | -| ||br| the wrapped key output by this API to encrypt the data. | -| ||br| The public key index is generated in wrapped_pair_key->pub_key, | -| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_pair_key |Wrapped pair key forsecp224r1 public key | -| | | ||br| and private key pair | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| Key generation failed. | -+--------------+------------------------------------+--------------------------------------------+ -| Note | | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.10.R_SCE_ECC_secp256r1_WrappedKeyPairGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t | -|R_SCE_ECC_secp256r1_WrappedKeyPairGenerate ( sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This is an API for outputting a wrapped key pair for secp256r1 public key | -| ||br| and private key pair. These keys are generated from a random number value | -| ||br| internally within the SCE. There is therefore no need to input user keys. | -| ||br| Consequently, there is no need to input a user key. | -| ||br| It is possible to prevent dead copying of data by using | -| ||br| wrapped key output by this API. A public wrapped key is generated by | -| ||br| the wrapped key output by this API to encrypt the data. | -| ||br| The public key index is generated in wrapped_pair_key->pub_key, | -| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_pair_key |Wrapped pair key forsecp256r1 public key | -| | | ||br| and private key pair | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| Key generation failed. | -+--------------+------------------------------------+--------------------------------------------+ -| Note | | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.11.R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t | -|R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t \*\wrapped_pair_key)| -+--------------+---------------------------------------------------------------------------------+ -| Description |This is an API for outputting a wrapped key pair for BrainpoolP512r1 public key | -| ||br| and private key pair. These keys are generated from a random number value | -| ||br| internally within the SCE. There is therefore no need to input user keys. | -| ||br| Consequently, there is no need to input a user key. | -| ||br| It is possible to prevent dead copying of data by using | -| ||br| wrapped key output by this API. A public wrapped key is generated by | -| ||br| the wrapped key output by this API to encrypt the data. | -| ||br| The public key index is generated in wrapped_pair_key->pub_key, | -| ||br| and the private key index is generated in wrapped_pair_key->priv_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |wrapped_pair_key |Wrapped pair key for BrainpoolP512r1 | -| | | ||br| key pair | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| Key generation failed. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.12.R_SCE_RandomNumberGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RandomNumberGenerate ( uint32_t \*\random) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API can generate 4 words random number. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |random |Stores 4words (16 bytes) random data. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.13.R_SCE_AES128_EncryptedKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128_EncryptedKeyWrap ( uint8_t \*\ initial_vector, uint8_t \*\ encrypted_key,| -||br| sce_key_update_key_t \*\ key_update_key, sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 128-bit AES key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encryptedand MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |128-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.14.R_SCE_AES256_EncryptedKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256_EncryptedKeyWrap ( uint8_t \*\ initial_vector, uint8_t \*\ encrypted_key,| -||br| sce_key_update_key_t \*\ key_update_key, sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 256-bit AES key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |256-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.15.R_SCE_RSA1024_EncryptedPublicKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrap ( uint8_t \*\initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_rsa1024_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 1024-bit RSA public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |1024-bit RSA public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.16.R_SCE_RSA1024_EncryptedPrivateKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_rsa1024_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 1024-bit RSA private key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |1024-bit RSA private wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.17.R_SCE_RSA2048_EncryptedPublicKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_rsa2048_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 2048-bit RSA public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |2048-bit RSA public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.18.R_SCE_RSA2048_EncryptedPrivateKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_rsa2048_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 2048-bit RSA private key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |2048-bit RSA private wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.19.R_SCE_RSA4096_EncryptedPublicKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_rsa4096_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps 4096-bit RSA public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |4096-bit RSA public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.20.R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps secp192r1 public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |secp192r1 public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.21.R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps secp224r1 public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |secp224r1 public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.22.R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps secp256r1 public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |secp256r1 public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processingroutine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.23.R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps BrainpoolP512r1 public key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |BrainpoolP512r1 public wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.24.R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps secp192r1 private key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |secp192r1 private wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.25.R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps secp224r1 private key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |secp224r1 private wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.26.R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps secp256r1 private key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |secp256r1 private wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processingroutine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - ----------------------------------------------------------- -2.6.27.R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap ----------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap ( uint8_t \*\ initial_vector, | -||br| uint8_t \*\ encrypted_key, sce_key_update_key_t \*\ key_update_key, | -||br| sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |This API wraps BrainpoolP512r1 private key within the user routine. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |initial_vector |Initialization vector when | -| | | ||br| generating encrypted_key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |encrypted_key |User key encrypted and MAC appended | -| +---------+--------------------------+--------------------------------------------+ -| |IN |key_update_key |Key update keyring | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |wrapped_key |BrainpoolP512r1 private wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - ----------------------------------------------------------- -2.6.27.R_SCE_SelfCheck2Private ----------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SelfCheck2Private (void) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Self check No2. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |none |none |none | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RETRY |self-test2 fail | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|resource conflict | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For information on how to create and update keys, refer to Security Manual | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.28.R_SCE_AES128ECB_EncryptInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128ECB_EncryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128ECB_EncryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128ECB_EncryptUpdate() function and | -| ||br| R_SCE_AES128ECB_EncryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_SUCCESS |Normal termination | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.29.R_SCE_AES128ECB_EncryptUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128ECB_EncryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128ECB_EncryptUpdate function encrypts the second argument, plain, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, cipher. After plaintext input is completed, | -| ||br| call R_SCE_AES128ECB_EncryptFinal(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.30.R_SCE_AES128ECB_EncryptFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128ECB_EncryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES128ECB_EncryptFinal() function writes the calculation result | -| ||br| to the second argument, cipher, and writes the length of the | -| ||br| calculation result to the third argument, cipher_length. | -| ||br| The original intent was for a portion of the encryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to cipher, | -| ||br| and 0 is always written to cipher_length. The arguments cipher | -| ||br| and cipher_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.31.R_SCE_AES128ECB_DecryptInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128ECB_DecryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128ECB_DecryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128ECB_DecryptUpdate() function and | -| ||br| R_SCE_AES128ECB_DecryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_SUCCESS |Normal termination | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.32.R_SCE_AES128ECB_DecryptUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128ECB_DecryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128ECB_DecryptUpdate function encrypts the second argument, cipher, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, plain. After ciphertext input is completed, | -| ||br| call R_SCE_AES128ECB_DecryptFinal. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.33.R_SCE_AES128ECB_DecryptFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128ECB_DecryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES128ECB_DecryptFinal() function writes the calculation result | -| ||br| to the second argument, plain, and writes the length of the | -| ||br| calculation result to the third argument, plain_length. | -| ||br| The original intent was for a portion of the Decryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to plain, | -| ||br| and 0 is always written to plain_length. The arguments plain | -| ||br| and plain_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.34.R_SCE_AES256ECB_EncryptInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256ECB_EncryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256ECB_EncryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256ECB_EncryptUpdate() function and | -| ||br| R_SCE_AES256ECB_EncryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.35.R_SCE_AES256ECB_EncryptUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256ECB_EncryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256ECB_EncryptUpdate function encrypts the second argument, plain, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, cipher. After plaintext input is completed, | -| ||br| call R_SCE_AES256ECB_EncryptFinal(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.36.R_SCE_AES256ECB_EncryptFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256ECB_EncryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES256ECB_EncryptFinal() function writes the calculation result | -| ||br| to the second argument, cipher, and writes the length of the | -| ||br| calculation result to the third argument, cipher_length. | -| ||br| The original intent was for a portion of the encryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to cipher, | -| ||br| and 0 is always written to cipher_length. The arguments cipher | -| ||br| and cipher_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.37.R_SCE_AES256ECB_DecryptInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256ECB_DecryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256ECB_DecryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256ECB_DecryptUpdate() function and | -| ||br| R_SCE_AES256ECB_DecryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.38.R_SCE_AES256ECB_DecryptUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256ECB_DecryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256ECB_DecryptUpdate function encrypts the second argument, cipher, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, plain. After ciphertext input is completed, | -| ||br| call R_SCE_AES256ECB_DecryptFinal. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.39.R_SCE_AES256ECB_DecryptFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256ECB_DecryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES256ECB_DecryptFinal() function writes the calculation result | -| ||br| to the second argument, plain, and writes the length of the | -| ||br| calculation result to the third argument, plain_length. | -| ||br| The original intent was for a portion of the Decryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to plain, | -| ||br| and 0 is always written to plain_length. The arguments plain | -| ||br| and plain_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - - -------------------------------------------------------- -2.6.40.R_SCE_AES128CBC_EncryptInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CBC_EncryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CBC_EncryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128CBC_EncryptUpdate() function and | -| ||br| R_SCE_AES128CBC_EncryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.41.R_SCE_AES128CBC_EncryptUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CBC_EncryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CBC_EncryptUpdate function encrypts the second argument, plain, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, cipher. After plaintext input is completed, | -| ||br| call R_SCE_AES128CBC_EncryptFinal(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.42.R_SCE_AES128CBC_EncryptFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CBC_EncryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES128CBC_EncryptFinal() function writes the calculation result | -| ||br| to the second argument, cipher, and writes the length of the | -| ||br| calculation result to the third argument, cipher_length. | -| ||br| The original intent was for a portion of the encryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to cipher, | -| ||br| and 0 is always written to cipher_length. The arguments cipher | -| ||br| and cipher_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.43.R_SCE_AES128CBC_DecryptInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CBC_DecryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CBC_DecryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128CBC_DecryptUpdate() function and | -| ||br| R_SCE_AES128CBC_DecryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.44.R_SCE_AES128CBC_DecryptUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CBC_DecryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CBC_DecryptUpdate function encrypts the second argument, cipher, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, plain. After ciphertext input is completed, | -| ||br| call R_SCE_AES128CBC_DecryptFinal. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.45.R_SCE_AES128CBC_DecryptFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CBC_DecryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES128CBC_DecryptFinal() function writes the calculation result | -| ||br| to the second argument, plain, and writes the length of the | -| ||br| calculation result to the third argument, plain_length. | -| ||br| The original intent was for a portion of the Decryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to plain, | -| ||br| and 0 is always written to plain_length. The arguments plain | -| ||br| and plain_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.46.R_SCE_AES256CBC_EncryptInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CBC_EncryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CBC_EncryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256CBC_EncryptUpdate() function and | -| ||br| R_SCE_AES256CBC_EncryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.47.R_SCE_AES256CBC_EncryptUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CBC_EncryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CBC_EncryptUpdate function encrypts the second argument, plain, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, cipher. After plaintext input is completed, | -| ||br| call R_SCE_AES256CBC_EncryptFinal(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.48.R_SCE_AES256CBC_EncryptFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CBC_EncryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES256CBC_EncryptFinal() function writes the calculation result | -| ||br| to the second argument, cipher, and writes the length of the | -| ||br| calculation result to the third argument, cipher_length. | -| ||br| The original intent was for a portion of the encryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to cipher, | -| ||br| and 0 is always written to cipher_length. The arguments cipher | -| ||br| and cipher_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.49.R_SCE_AES256CBC_DecryptInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CBC_DecryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CBC_DecryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256CBC_DecryptUpdate() function and | -| ||br| R_SCE_AES256CBC_DecryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.50.R_SCE_AES256CBC_DecryptUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CBC_DecryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CBC_DecryptUpdate function encrypts the second argument, cipher, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, plain. After ciphertext input is completed, | -| ||br| call R_SCE_AES256CBC_DecryptFinal. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.51.R_SCE_AES256CBC_DecryptFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CBC_DecryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES256CBC_DecryptFinal() function writes the calculation result | -| ||br| to the second argument, plain, and writes the length of the | -| ||br| calculation result to the third argument, plain_length. | -| ||br| The original intent was for a portion of the Decryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to plain, | -| ||br| and 0 is always written to plain_length. The arguments plain | -| ||br| and plain_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.52.R_SCE_AES128CTR_EncryptInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CTR_EncryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CTR_EncryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128CTR_EncryptUpdate() function and | -| ||br| R_SCE_AES128CTR_EncryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.53.R_SCE_AES128CTR_EncryptUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CTR_EncryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CTR_EncryptUpdate function encrypts the second argument, plain, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, cipher. After plaintext input is completed, | -| ||br| call R_SCE_AES128CTR_EncryptFinal(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.54.R_SCE_AES128CTR_EncryptFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CTR_EncryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES128CTR_EncryptFinal() function writes the calculation result | -| ||br| to the second argument, cipher, and writes the length of the | -| ||br| calculation result to the third argument, cipher_length. | -| ||br| The original intent was for a portion of the encryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to cipher, | -| ||br| and 0 is always written to cipher_length. The arguments cipher | -| ||br| and cipher_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.55.R_SCE_AES128CTR_DecryptInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CTR_DecryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CTR_DecryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128CTR_DecryptUpdate() function and | -| ||br| R_SCE_AES128CTR_DecryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.56.R_SCE_AES128CTR_DecryptUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CTR_DecryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CTR_DecryptUpdate function encrypts the second argument, cipher, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, plain. After ciphertext input is completed, | -| ||br| call R_SCE_AES128CTR_DecryptFinal. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.57.R_SCE_AES128CTR_DecryptFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CTR_DecryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES128CTR_DecryptFinal() function writes the calculation result | -| ||br| to the second argument, plain, and writes the length of the | -| ||br| calculation result to the third argument, plain_length. | -| ||br| The original intent was for a portion of the Decryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to plain, | -| ||br| and 0 is always written to plain_length. The arguments plain | -| ||br| and plain_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.58.R_SCE_AES256CTR_EncryptInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CTR_EncryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CTR_EncryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256CTR_EncryptUpdate() function and | -| ||br| R_SCE_AES256CTR_EncryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.59.R_SCE_AES256CTR_EncryptUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CTR_EncryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint8_t \*\ cipher, uint32_t plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CTR_EncryptUpdate function encrypts the second argument, plain, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, cipher. After plaintext input is completed, | -| ||br| call R_SCE_AES256CTR_EncryptFinal(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.60.R_SCE_AES256CTR_EncryptFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CTR_EncryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint32_t \*\ cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES256CTR_EncryptFinal() function writes the calculation result | -| ||br| to the second argument, cipher, and writes the length of the | -| ||br| calculation result to the third argument, cipher_length. | -| ||br| The original intent was for a portion of the encryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to cipher, | -| ||br| and 0 is always written to cipher_length. The arguments cipher | -| ||br| and cipher_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.61.R_SCE_AES256CTR_DecryptInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CTR_DecryptInit ( sce_aes_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key, uint8_t \*\ initial_vector ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CTR_DecryptInit() function performs preparations for the | -| ||br| execution of an AES calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256CTR_DecryptUpdate() function and | -| ||br| R_SCE_AES256CTR_DecryptFinal() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -| +---------+--------------------------+--------------------------------------------+ -| |IN |initial_vector |initialization vector area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.62.R_SCE_AES256CTR_DecryptUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CTR_DecryptUpdate ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ cipher, uint8_t \*\ plain, uint32_t cipher_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CTR_DecryptUpdate function encrypts the second argument, cipher, | -| ||br| utilizing the key index stored in the handle specified | -| ||br| in the first argument, handle,and writes the ongoing status | -| ||br| to this first argument. In addition, it writes the encryption result | -| ||br| to the third argument, plain. After ciphertext input is completed, | -| ||br| call R_SCE_AES256CTR_DecryptFinal. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |cipher |ciphertext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher_length |ciphertext data length | -| | | ||br| (must be a multiple of 16) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |Specify areas for plain and cipher that do not overlap. | -| ||br| For plain and cipher, specify RAM addresses that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.63.R_SCE_AES256CTR_DecryptFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CTR_DecryptFinal ( sce_aes_handle_t \*\ handle, | -||br| uint8_t \*\ plain, uint32_t \*\ plain_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, | -| ||br| the R_SCE_AES256CTR_DecryptFinal() function writes the calculation result | -| ||br| to the second argument, plain, and writes the length of the | -| ||br| calculation result to the third argument, plain_length. | -| ||br| The original intent was for a portion of the Decryption result | -| ||br| that was not a multiple of 16 bytes to be written to the second argument. | -| ||br| However, as a result of the restriction that only multiples of 16 | -| ||br| can be input to the Update function, nothing is ever written to plain, | -| ||br| and 0 is always written to plain_length. The arguments plain | -| ||br| and plain_length are provided for compatibility in anticipation of | -| ||br| the time when this restriction is lifted. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext data area | -| | | ||br| (nothing ever written here) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain_length |plaintext data length | -| | | ||br| (0 always written here) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.64.R_SCE_AES128CMAC_GenerateInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CMAC_GenerateInit ( sce_cmac_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CMAC_GenerateInit function performs preparations for the | -| ||br| execution of an CMAC calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128CMAC_GenerateUpdate function and | -| ||br| R_SCE_AES128CMAC_GenerateFinal function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.65.R_SCE_AES128CMAC_GenerateUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CMAC_GenerateUpdate ( sce_cmac_handle_t \*\ handle, | -||br| uint8_t \*\ message, uint32_t message_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CMAC_GenerateUpdate() function performs MAC value generation | -| ||br| based on the message specified in the second argument, message, | -| ||br| using the value specified for wrapped_key in R_SCE_AES128CMAC_GenerateInit. | -| ||br| Inside this function, the data that is input by the user is buffered | -| ||br| until the input value of message exceeds 16 bytes. | -| ||br| The length of the message data to input is specified in the third argument, | -| ||br| message_len. For these, input not the total byte count | -| ||br| for message input data, but rather the message data length to input | -| ||br| when the user calls this function. If the input value, message, | -| ||br| is not a multiple of 16 bytes, it will be padded within the function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message |plaintext data area | -| | | ||br| (message_length byte) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_length |message data length | -| | | ||br| (0 or more bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For message, specify a RAM address that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.66.R_SCE_AES128CMAC_GenerateFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CMAC_GenerateFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CMAC_GenerateFinal() function outputs the MAC value in | -| ||br| the MAC data area specified in the second argument, mac, and ends CMAC mode.| -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |mac |MAC data area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Not used. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.67.R_SCE_AES128CMAC_VerifyInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CMAC_VerifyInit ( sce_cmac_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CMAC_VerifyInit function performs preparations for the | -| ||br| execution of an CMAC calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES128CMAC_VerifyUpdate function and | -| ||br| R_SCE_AES128CMAC_VerifyFinal function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |128-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.68.R_SCE_AES128CMAC_VerifyUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CMAC_VerifyUpdate ( sce_cmac_handle_t \*\ handle, | -||br| uint8_t \*\ message, uint32_t message_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CMAC_VerifyUpdate function performs MAC value generation | -| ||br| based on the message specified in the second argument, message, | -| ||br| using the value specified for wrapped_key in R_SCE_AES128CMAC_VerifyInit. | -| ||br| Inside this function, the data that is input by the user is buffered | -| ||br| until the input value of message exceeds 16 bytes. | -| ||br| The length of the message data to input is specified in the third argument, | -| ||br| message_len. For these, input not the total byte count | -| ||br| for message input data, but rather the message data length to input | -| ||br| when the user calls this function. If the input value, message, | -| ||br| is not a multiple of 16 bytes, it will be padded within the function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message |plaintext data area | -| | | ||br| (message_length byte) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_length |message data length | -| | | ||br| (0 or more bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For message, specify a RAM address that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.69.R_SCE_AES128CMAC_VerifyFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES128CMAC_VerifyFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac, | -||br| uint32_t mac_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES128CMAC_VerifyFinal() function inputs the MAC value in the MAC | -| ||br| data area specified in the second argument, mac, and verifies the MAC value.| -| ||br| If authentication fails, the return value will be TSIP_ERR_AUTHENTICATION. | -| ||br| If the MAC value is less than 16 bytes, | -| ||br| it will be padded with zeros inside the function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |mac |MAC data area (mac_length byte) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |mac_length |MAC data length (2 to 16 bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.70.R_SCE_AES256CMAC_GenerateInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CMAC_GenerateInit ( sce_cmac_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CMAC_GenerateInit function performs preparations for the | -| ||br| execution of an CMAC calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256CMAC_GenerateUpdate function and | -| ||br| R_SCE_AES256CMAC_GenerateFinal function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.71.R_SCE_AES256CMAC_GenerateUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CMAC_GenerateUpdate ( sce_cmac_handle_t \*\ handle, | -||br| uint8_t \*\ message, uint32_t message_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CMAC_GenerateUpdate() function performs MAC value generation | -| ||br| based on the message specified in the second argument, message, | -| ||br| using the value specified for wrapped_key in R_SCE_AES256CMAC_GenerateInit. | -| ||br| Inside this function, the data that is input by the user is buffered | -| ||br| until the input value of message exceeds 16 bytes. | -| ||br| The length of the message data to input is specified in the third argument, | -| ||br| message_len. For these, input not the total byte count | -| ||br| for message input data, but rather the message data length to input | -| ||br| when the user calls this function. If the input value, message, | -| ||br| is not a multiple of 16 bytes, it will be padded within the function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message |plaintext data area | -| | | ||br| (message_length byte) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_length |message data length | -| | | ||br| (0 or more bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For message, specify a RAM address that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.72.R_SCE_AES256CMAC_GenerateFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CMAC_GenerateFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CMAC_GenerateFinal() function outputs the MAC value in | -| ||br| the MAC data area specified in the second argument, mac, and ends CMAC mode.| -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |mac |MAC data area (16byte) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Not used. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.73.R_SCE_AES256CMAC_VerifyInit -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CMAC_VerifyInit ( sce_cmac_handle_t \*\ handle, | -||br| sce_aes_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CMAC_VerifyInit function performs preparations for the | -| ||br| execution of an CMAC calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_AES256CMAC_VerifyUpdate function and | -| ||br| R_SCE_AES256CMAC_VerifyFinal function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |256-bit AES wrapped key | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Input illegal wrapped key. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.74.R_SCE_AES256CMAC_VerifyUpdate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CMAC_VerifyUpdate ( sce_cmac_handle_t \*\ handle, | -||br| uint8_t \*\ message, uint32_t message_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CMAC_VerifyUpdate function performs MAC value generation | -| ||br| based on the message specified in the second argument, message, | -| ||br| using the value specified for wrapped_key in R_SCE_AES256CMAC_VerifyInit. | -| ||br| Inside this function, the data that is input by the user is buffered | -| ||br| until the input value of message exceeds 16 bytes. | -| ||br| The length of the message data to input is specified in the third argument, | -| ||br| message_len. For these, input not the total byte count | -| ||br| for message input data, but rather the message data length to input | -| ||br| when the user calls this function. If the input value, message, | -| ||br| is not a multiple of 16 bytes, it will be padded within the function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES-CMAC handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message |plaintext data area | -| | | ||br| (message_length byte) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_length |message data length | -| | | ||br| (0 or more bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |For message, specify a RAM address that are multiples of 4. | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.75.R_SCE_AES256CMAC_VerifyFinal -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_AES256CMAC_VerifyFinal ( sce_cmac_handle_t \*\ handle, uint8_t \*\ mac, | -||br| uint32_t mac_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_AES256CMAC_VerifyFinal() function inputs the MAC value in the MAC | -| ||br| data area specified in the second argument, mac, and verifies the MAC value.| -| ||br| If authentication fails, the return value will be TSIP_ERR_AUTHENTICATION. | -| ||br| If the MAC value is less than 16 bytes, | -| ||br| it will be padded with zeros inside the function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |AES handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |mac |MAC data area (mac_length byte) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |mac_length |MAC data length (2 to 16 bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.76.R_SCE_SHA256_Init -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SHA256_Init ( sce_sha_md5_handle_t \*\ handle) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_SHA256_Init() function performs preparations for the execution | -| ||br| of an SHA-256 hash calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_SHA256_Update() function | -| ||br| and R_SCE_SHA256_Final() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |SHA handler (work area) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.77.R_SCE_SHA256_Update -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SHA256_Update ( sce_sha_md5_handle_t \*\ handle, | -||br| uint8_t \*\ message, uint32_t message_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_SHA256_Update() function calculates a hash value based on | -| ||br| the second argument, message, and the third argument, message_length, | -| ||br| and writes the ongoing status to the first argument, handle. | -| ||br| After message input is completed, call R_SCE_SHA256_Final(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |SHA handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message |message data area | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_length |message data length | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.78.R_SCE_SHA256_Final -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SHA256_Final ( sce_sha_md5_handle_t \*\ handle, | -||br| uint8_t \*\ digest, uint32_t \*\ digest_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, the R_SCE_SHA256_Final | -| ||br| function writes the calculation result to the second argument, digest, | -| ||br| and writes the length of the calculation result | -| ||br| to the third argument, digest_length. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |SHA handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |digest |hash data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |digest_length |hash data length (32bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.79.R_SCE_SHA224_Init -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SHA224_Init ( sce_sha_md5_handle_t \*\ handle) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_SHA224_Init() function performs preparations for the execution | -| ||br| of an SHA-224 hash calculation, and writes the result | -| ||br| to the first argument, handle. The value of handle is used as an argument | -| ||br| in the subsequent R_SCE_SHA224_Update() function | -| ||br| and R_SCE_SHA224_Final() function. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |SHA handler (work area) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.80.R_SCE_SHA224_Update -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SHA224_Update ( sce_sha_md5_handle_t \*\ handle, | -||br| uint8_t \*\ message, uint32_t message_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_SHA224_Update() function calculates a hash value based on | -| ||br| the second argument, message, and the third argument, message_length, | -| ||br| and writes the ongoing status to the first argument, handle. | -| ||br| After message input is completed, call R_SCE_SHA224_Final(). | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |SHA handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message |message data area | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_length |message data length | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.81.R_SCE_SHA224_Final -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_SHA224_Final ( sce_sha_md5_handle_t \*\ handle, | -||br| uint8_t \*\ digest, uint32_t \*\ digest_length ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |Using the handle specified in the first argument, handle, the R_SCE_SHA224_Final | -| ||br| function writes the calculation result to the second argument, digest, | -| ||br| and writes the length of the calculation result | -| ||br| to the third argument, digest_length. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |INOUT |handle |SHA handler (work area) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |digest |hash data area | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |digest_length |hash data length (32bytes) | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.82.R_SCE_RSASSA_PKCS1024_SignatureGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate ( sce_rsa_byte_data_t \*\ message_hash, | -||br| sce_rsa_byte_data_t \*\ signature, sce_rsa1024_private_wrapped_key_t \*\ wrapped_key, | -||br| uint8_t hash_type ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSASSA_PKCS1024_SignatureGenerate function generates, in accordance | -| ||br| with RSASSA-PKCS1-V1_5, a signature from the message text or hash value | -| ||br| that is input in the first argument, message_hash, using the | -| ||br| private wrapped key input to the third argument, wrapped_key, | -| ||br| and writes the signature text to the second argument, signature. | -| ||br| When a message is specified in the first argument, message_hash->data_type, | -| ||br| a hash value is calculated for the message as specified by | -| ||br| the fourth argument, hash_type. When specifying a hash value, | -| ||br| a hash value calculated with a hash algorithm as specified by | -| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |signature |Signature text storage | -| | | ||br| destination information | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | - signature->data_length : data length | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 1024-bit RSA private wrapped key.| -| +---------+--------------------------+--------------------------------------------+ -| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.83.R_SCE_RSASSA_PKCS1024_SignatureVerify -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureVerify ( sce_rsa_byte_data_t \*\ signature, | -||br| sce_rsa_byte_data_t \*\ message_hash, sce_rsa1024_public_wrapped_key_t \*\ wrapped_key, | -||br| uint8_t hash_type ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSASSA_PKCS1024_SignatureVerify() function verifies, in accordance | -| ||br| with RSASSA-PKCS1-V1_5, the signature text input to the | -| ||br| the first argument signature, and the message text or hash value input | -| ||br| to the second argument, message_hash, using the public wrapped key input | -| ||br| to the third argument, wrapped_key. When a message is specified | -| ||br| in the second argument, message_hash->data_type, a hash value is calculated | -| ||br| using the public wrapped key input to the third argument, wrapped_key, | -| ||br| and as specified by the fourth argument, hash_type. When specifying | -| ||br| a hash value in the second argument, message_hash->data_type, | -| ||br| a hash value calculated with a hash algorithm as specified | -| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to verify | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | - signature->data_length : Specifies | -| | | | |br| effective data length of the array | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_hash |Message text or hash value to verify | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 1024-bit RSA private wrapped key.| -| +---------+--------------------------+--------------------------------------------+ -| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.84.R_SCE_RSASSA_PKCS2048_SignatureGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate ( sce_rsa_byte_data_t \*\ message_hash, | -||br| sce_rsa_byte_data_t \*\ signature, sce_rsa2048_private_wrapped_key_t \*\ wrapped_key, | -||br| uint8_t hash_type ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSASSA_PKCS2048_SignatureGenerate function generates, in accordance | -| ||br| with RSASSA-PKCS1-V1_5, a signature from the message text or hash value | -| ||br| that is input in the first argument, message_hash, using the | -| ||br| private wrapped key input to the third argument, wrapped_key, | -| ||br| and writes the signature text to the second argument, signature. | -| ||br| When a message is specified in the first argument, message_hash->data_type, | -| ||br| a hash value is calculated for the message as specified by | -| ||br| the fourth argument, hash_type. When specifying a hash value, | -| ||br| a hash value calculated with a hash algorithm as specified by | -| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |signature |Signature text storage | -| | | ||br| destination information | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | - signature->data_length : data length | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 2048-bit RSA private wrapped key.| -| +---------+--------------------------+--------------------------------------------+ -| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.85.R_SCE_RSASSA_PKCS2048_SignatureVerify -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify ( sce_rsa_byte_data_t \*\ signature, | -||br| sce_rsa_byte_data_t \*\ message_hash, sce_rsa2048_public_wrapped_key_t \*\ wrapped_key, | -||br| uint8_t hash_type ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSASSA_PKCS2048_SignatureVerify() function verifies, in accordance | -| ||br| with RSASSA-PKCS1-V1_5, the signature text input to the | -| ||br| the first argument signature, and the message text or hash value input | -| ||br| to the second argument, message_hash, using the public wrapped key input | -| ||br| to the third argument, wrapped_key. When a message is specified | -| ||br| in the second argument, message_hash->data_type, a hash value is calculated | -| ||br| using the public wrapped key input to the third argument, wrapped_key, | -| ||br| and as specified by the fourth argument, hash_type. When specifying | -| ||br| a hash value in the second argument, message_hash->data_type, | -| ||br| a hash value calculated with a hash algorithm as specified | -| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to verify | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | - signature->data_length : Specifies | -| | | | |br| effective data length of the array | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_hash |Message text or hash value to verify | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 2048-bit RSA private wrapped key.| -| +---------+--------------------------+--------------------------------------------+ -| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.86.R_SCE_RSASSA_PKCS4096_SignatureVerify -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSASSA_PKCS4096_SignatureVerify ( sce_rsa_byte_data_t \*\ signature, | -||br| sce_rsa_byte_data_t \*\ message_hash, sce_rsa4096_public_wrapped_key_t \*\ wrapped_key, | -||br| uint8_t hash_type ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSASSA_PKCS4096_SignatureVerify() function verifies, in accordance | -| ||br| with RSASSA-PKCS1-V1_5, the signature text input to the | -| ||br| the first argument signature, and the message text or hash value input | -| ||br| to the second argument, message_hash, using the public wrapped key input | -| ||br| to the third argument, wrapped_key. When a message is specified | -| ||br| in the second argument, message_hash->data_type, a hash value is calculated | -| ||br| using the public wrapped key input to the third argument, wrapped_key, | -| ||br| and as specified by the fourth argument, hash_type. When specifying | -| ||br| a hash value in the second argument, message_hash->data_type, | -| ||br| a hash value calculated with a hash algorithm as specified | -| ||br| by the fourth argument, hash_type, must be input to message_hash->pdata. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to verify | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | - signature->data_length : Specifies | -| | | | |br| effective data length of the array | -| +---------+--------------------------+--------------------------------------------+ -| |IN |message_hash |Message text or hash value to verify | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 4096-bit RSA private wrapped key.| -| +---------+--------------------------+--------------------------------------------+ -| |IN |hash_type |Only HW_SCE_RSA_HASH_SHA256 is supported | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_AUTHENTICATION |Authentication failed | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.87.R_SCE_RSAES_PKCS1024_Encrypt -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSAES_PKCS1024_Encrypt ( sce_rsa_byte_data_t \*\ plain, | -||br| sce_rsa_byte_data_t \*\ cipher, sce_rsa1024_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSAES_PKCS1024_Encrypt() function RSA-encrypts the plaintext | -| ||br| input to the first argument, plain, according to RSAES-PKCS1-V1_5. | -| ||br| It writes the encryption result to the second argument, cipher. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |plain |plaintext | -| | | | | -| | | | - plain->pdata : Specifies pointer to | -| | | | |br| array containing plaintext. | -| | | | - plain->data_length : Specifies valid data| -| | | | |br| length of plaintext array. | -| | | | |br| data size <= public key n size - 11 | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext | -| | | | | -| | | | - cipher->pdata : Specifies pointer to | -| | | | |br| array containing ciphertext. | -| | | | - cipher->data_length : Inputs ciphertext | -| | | | |br| buffer size. Outputs valid data | -| | | | |br| length after encryption | -| | | | |br| (public key n size). | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 1024-bit RSA public wrapped key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.88.R_SCE_RSAES_PKCS1024_Decrypt -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt ( sce_rsa_byte_data_t \*\ cipher, | -||br| sce_rsa_byte_data_t \*\ plain, sce_rsa1024_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSAES_PKCS1024_Decrypt() function RSA-decrypts the ciphertext | -| ||br| input to the first argument, cipher, according to RSAES-PKCS1-V1_5. | -| ||br| It writes the encryption result to the second argument, plain. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |cipher |ciphertext | -| | | | | -| | | | - cipher->pdata : Specifies pointer to | -| | | | |br| array containing ciphertext. | -| | | | - cipher->data_length : Inputs ciphertext | -| | | | |br| buffer size. Outputs valid data | -| | | | |br| length after encryption | -| | | | |br| (public key n size). | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext | -| | | | | -| | | | - plain->pdata : Specifies pointer to | -| | | | |br| array containing plaintext. | -| | | | - plain->data_length : Inputs plaintext | -| | | | |br| buffer size. The following size | -| | | | |br| is required. | -| | | | |br| Plaintext buffer size >= | -| | | | |br| publickey n size - 11. | -| | | | |br| Outputs valid data length after | -| | | | |br| decryption (publickey n size). | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 1024-bit RSA private wrapped key.| -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.89.R_SCE_RSAES_PKCS2048_Encrypt -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSAES_PKCS2048_Encrypt ( sce_rsa_byte_data_t \*\ plain, | -||br| sce_rsa_byte_data_t \*\ cipher, sce_rsa2048_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSAES_PKCS2048_Encrypt() function RSA-encrypts the plaintext | -| ||br| input to the first argument, plain, according to RSAES-PKCS1-V1_5. | -| ||br| It writes the encryption result to the second argument, cipher. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |plain |plaintext | -| | | | | -| | | | - plain->pdata : Specifies pointer to | -| | | | |br| array containing plaintext. | -| | | | - plain->data_length : Specifies valid data| -| | | | |br| length of plaintext array. | -| | | | |br| data size <= public key n size - 11 | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext | -| | | | | -| | | | - cipher->pdata : Specifies pointer to | -| | | | |br| array containing ciphertext. | -| | | | - cipher->data_length : Inputs ciphertext | -| | | | |br| buffer size. Outputs valid data | -| | | | |br| length after encryption | -| | | | |br| (public key n size). | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 2048-bit RSA public wrapped key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.90.R_SCE_RSAES_PKCS2048_Decrypt -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSAES_PKCS2048_Decrypt ( sce_rsa_byte_data_t \*\ cipher, | -||br| sce_rsa_byte_data_t \*\ plain, sce_rsa2048_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSAES_PKCS2048_Decrypt() function RSA-decrypts the ciphertext | -| ||br| input to the first argument, cipher, according to RSAES-PKCS1-V1_5. | -| ||br| It writes the encryption result to the second argument, plain. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |cipher |ciphertext | -| | | | | -| | | | - cipher->pdata : Specifies pointer to | -| | | | |br| array containing ciphertext. | -| | | | - cipher->data_length : Inputs ciphertext | -| | | | |br| buffer size. Outputs valid data | -| | | | |br| length after encryption | -| | | | |br| (public key n size). | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |plain |plaintext | -| | | | | -| | | | - plain->pdata : Specifies pointer to | -| | | | |br| array containing plaintext. | -| | | | - plain->data_length : Inputs plaintext | -| | | | |br| buffer size. The following size | -| | | | |br| is required. | -| | | | |br| Plaintext buffer size >= | -| | | | |br| publickey n size - 11. | -| | | | |br| Outputs valid data length after | -| | | | |br| decryption (publickey n size). | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 2048-bit RSA private wrapped key.| -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.91.R_SCE_RSAES_PKCS4096_Encrypt -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt ( sce_rsa_byte_data_t \*\ plain, | -||br| sce_rsa_byte_data_t \*\ cipher, sce_rsa4096_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |The R_SCE_RSAES_PKCS4096_Encrypt() function RSA-encrypts the plaintext | -| ||br| input to the first argument, plain, according to RSAES-PKCS1-V1_5. | -| ||br| It writes the encryption result to the second argument, cipher. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |plain |plaintext | -| | | | | -| | | | - plain->pdata : Specifies pointer to | -| | | | |br| array containing plaintext. | -| | | | - plain->data_length : Specifies valid data| -| | | | |br| length of plaintext array. | -| | | | |br| data size <= public key n size - 11 | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |cipher |ciphertext | -| | | | | -| | | | - cipher->pdata : Specifies pointer to | -| | | | |br| array containing ciphertext. | -| | | | - cipher->data_length : Inputs ciphertext | -| | | | |br| buffer size. Outputs valid data | -| | | | |br| length after encryption | -| | | | |br| (public key n size). | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Inputs the 4096-bit RSA public wrapped key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.92.R_SCE_ECDSA_secp192r1_SignatureGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate ( sce_ecdsa_byte_data_t \*\ message_hash, | -||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a message is specified in the first argument, message_hash->data_type, | -| ||br| a SHA-256 hash of the message text input as the first argument, | -| ||br| message_hash->pdata, is calculated, and the signature text is written to | -| ||br| the second argument, signature, in accordance with secp192r1 using | -| ||br| the private wrapped key input as the third argument, wrapped_key. | -| ||br| When a hash value is specified in the first argument, | -| ||br| message_hash->data_type, the signature text for the first 24 bytes | -| ||br| of the SHA-256 hash value input to the first argument, message_hash->pdata, | -| ||br| is written to the second argument, signature, in accordance with secp192r1 | -| ||br| using the private wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |signature |Signature text storage | -| | | ||br| destination information | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "0 padding (64 bits) | -| | | | |br| || signature r (192bits) | -| | | | |br| || 0 padding (64 bits) | -| | | | |br| || signature s (192 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Input wrapped key of secp192r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.93.R_SCE_ECDSA_secp224r1_SignatureGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate ( sce_ecdsa_byte_data_t \*\ message_hash, | -||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a message is specified in the first argument, message_hash->data_type, | -| ||br| a SHA-256 hash of the message text input as the first argument, | -| ||br| message_hash->pdata, is calculated, and the signature text is written to | -| ||br| the second argument, signature, in accordance with secp224r1 using | -| ||br| the private wrapped key input as the third argument, wrapped_key. | -| ||br| When a hash value is specified in the first argument, | -| ||br| message_hash->data_type, the signature text for the first 28 bytes | -| ||br| of the SHA-256 hash value input to the first argument, message_hash->pdata, | -| ||br| is written to the second argument, signature, in accordance with secp224r1 | -| ||br| using the private wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |signature |Signature text storage | -| | | ||br| destination information | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "0 padding (32 bits) | -| | | | |br| || signature r (224bits) | -| | | | |br| || 0 padding (32 bits) | -| | | | |br| || signature s (224 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Input wrapped key of secp224r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.94.R_SCE_ECDSA_secp256r1_SignatureGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate ( sce_ecdsa_byte_data_t \*\ message_hash, | -||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a message is specified in the first argument, message_hash->data_type, | -| ||br| a SHA-256 hash of the message text input as the first argument, | -| ||br| message_hash->pdata, is calculated, and the signature text is written to | -| ||br| the second argument, signature, in accordance with secp256r1 using | -| ||br| the private wrapped key input as the third argument, wrapped_key. | -| ||br| When a hash value is specified in the first argument, | -| ||br| message_hash->data_type, the signature text for the first 32 bytes | -| ||br| of the SHA-256 hash value input to the first argument, message_hash->pdata, | -| ||br| is written to the second argument, signature, in accordance with secp256r1 | -| ||br| using the private wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |signature |Signature text storage | -| | | ||br| destination information | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "signature r (256bits) | -| | | | |br| || signature s (256 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Input wrapped key of secp256r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.95.R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate( sce_ecdsa_byte_data_t \*\ message_hash,| -||br| sce_ecdsa_byte_data_t \*\ signature, sce_ecc_private_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a hash value is specified in the first argument, | -| ||br| message_hash->data_type, the signature text for the first 64 bytes | -| ||br| of the SHA-512 hash value input to the first argument, message_hash->pdata, | -| ||br| is written to the second argument, in accordance with BrainpoolP512r1 | -| ||br| using the private wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (only Hash value(1) is support) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |signature |Signature text storage | -| | | ||br| destination information | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "signature r (512bits) | -| | | | |br| || signature s (512 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |wrapped key of BrainpoolP512r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.96.R_SCE_ECDSA_secp192r1_SignatureVerify -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | -||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a message is specified in the second argument, message_hash->data_type, | -| ||br| a SHA-256 hash of the message text input as the second argument, | -| ||br| message_hash->pdata, is calculated, and the signature text input to the | -| ||br| first argument, signature, is validated in accordance with secp192r1 using | -| ||br| the public wrapped key input as the third argument, wrapped_key. | -| ||br| When a hash value is specified in the second argument, | -| ||br| message_hash->data_type, the signature text for the first 24 bytes | -| ||br| of the SHA-256 hash value input to the second argument, message_hash->pdata,| -| ||br| is written to the first argument, signature, | -| ||br| is validated in accordance with secp192r1 | -| ||br| using the public wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to be verified | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "0 padding (64 bits) | -| | | | |br| || signature r (192bits) | -| | | | |br| || 0 padding (64 bits) | -| | | | |br| || signature s (192 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) (nonuse) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Input wrapped key of secp192r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| or signature verification failed. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.97.R_SCE_ECDSA_secp224r1_SignatureVerify -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | -||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a message is specified in the second argument, message_hash->data_type, | -| ||br| a SHA-224 hash of the message text input as the second argument, | -| ||br| message_hash->pdata, is calculated, and the signature text input to the | -| ||br| first argument, signature, is validated in accordance with secp224r1 using | -| ||br| the public wrapped key input as the third argument, wrapped_key. | -| ||br| When a hash value is specified in the second argument, | -| ||br| message_hash->data_type, the signature text for the first 28 bytes | -| ||br| of the SHA-224 hash value input to the second argument, message_hash->pdata,| -| ||br| is written to the first argument, signature, | -| ||br| is validated in accordance with secp224r1 | -| ||br| using the public wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to be verified | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "0 padding (32 bits) | -| | | | |br| || signature r (224bits) | -| | | | |br| || 0 padding (32 bits) | -| | | | |br| || signature s (224 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) (nonuse) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Input wrapped key of secp224r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| or signature verification failed. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.98.R_SCE_ECDSA_secp256r1_SignatureVerify -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | -||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a message is specified in the second argument, message_hash->data_type, | -| ||br| a SHA-256 hash of the message text input as the second argument, | -| ||br| message_hash->pdata, is calculated, and the signature text input to the | -| ||br| first argument, signature, is validated in accordance with secp256r1 using | -| ||br| the public wrapped key input as the third argument, wrapped_key. | -| ||br| When a hash value is specified in the second argument, | -| ||br| message_hash->data_type, the signature text for the first 32 bytes | -| ||br| of the SHA-256 hash value input to the second argument, message_hash->pdata,| -| ||br| is written to the first argument, signature, | -| ||br| is validated in accordance with secp256r1 | -| ||br| using the public wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to be verified | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "signature r (256bits) | -| | | | |br| || signature s (256 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) (nonuse) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (Message: 0 Hash value: 1) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |Input wrapped key of secp256r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| or signature verification failed. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - -------------------------------------------------------- -2.6.99.R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify -------------------------------------------------------- - -+------------------------------------------------------------------------------------------------+ -|fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify ( sce_ecdsa_byte_data_t \*\ signature, | -||br| sce_ecdsa_byte_data_t \*\ message_hash, sce_ecc_public_wrapped_key_t \*\ wrapped_key ) | -+--------------+---------------------------------------------------------------------------------+ -| Description |When a hash value is specified in the second argument, | -| ||br| message_hash->data_type, the signature text for the first 64 bytes | -| ||br| of the SHA-512 hash value input to the second argument, message_hash->pdata,| -| ||br| is written to the first argument, signature, | -| ||br| is validated in accordance with BrainpoolP512r1 | -| ||br| using the public wrapped key input as the third argument, wrapped_key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Arguments |IN |signature |Signature text information to be verified | -| | | | | -| | | | - signature->pdata : Specifies pointer | -| | | | |br| to array storing the signature text | -| | | | |br| The signature format is | -| | | | |br| "signature r (512bits) | -| | | | |br| || signature s (512 bits)". | -| | | | - signature->data_length : data length | -| | | | |br| || (byte units) (nonuse) | -| +---------+--------------------------+--------------------------------------------+ -| |INOUT |message_hash |Message or hash value to | -| | | ||br| which to attach signature | -| | | | | -| | | | - message_hash->pdata : Specifies pointer | -| | | | |br| to array storing the message or | -| | | | |br| hash value | -| | | | - message_hash->data_length : Specifies | -| | | | |br| effective data length of the array | -| | | | |br| (Specify when Message is selected) | -| | | | - message_hash->data_type : Selects the | -| | | | |br| data type of message_hash | -| | | | |br| (only Hash value(1) is support) | -| +---------+--------------------------+--------------------------------------------+ -| |IN |wrapped_key |wrapped key of BrainpoolP512r1 private key. | -+--------------+---------+--------------------------+--------------------------------------------+ -| Return value |FSP_SUCCESS |Normal termination | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT|A resource conflict occurred because a | -| | ||br| hardware resource needed by the | -| | ||br| processing routine was in use | -| | ||br| by another processing routine. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL |Invalid wrapped key was input. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_FAIL |An internal error occurred. | -| | ||br| or signature verification failed. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PARAMETER |Input data is illegal. | -| +------------------------------------+--------------------------------------------+ -| |FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION|An invalid function was called. | -+--------------+------------------------------------+--------------------------------------------+ -| Note |none | -+--------------+---------------------------------------------------------------------------------+ - - - -.. |br| raw:: html - -
\ No newline at end of file diff --git a/core/arch/arm/plat-rz/g2l/drivers/r_sce/inc/api/r_sce_api.h b/core/arch/arm/plat-rz/g2l/drivers/r_sce/inc/api/r_sce_api.h deleted file mode 100644 index 17e267782..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/r_sce/inc/api/r_sce_api.h +++ /dev/null @@ -1,1501 +0,0 @@ -/********************************************************************************************************************** - * DISCLAIMER - * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No - * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all - * applicable laws, including copyright laws. - * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING - * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM - * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES - * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO - * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of - * this software. By using this software, you agree to the additional terms and conditions found by accessing the - * following link: - * http://www.renesas.com/disclaimer - * - * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. - *********************************************************************************************************************/ -/********************************************************************************************************************** - * File Name : r_sce_api.h - * Version : 1.0 - * Description : SCE API header file - *********************************************************************************************************************/ -/********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release - *********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * @ingroup RENESAS_INTERFACES - * @defgroup SCE_PROTECTED_API SCE Interface - * @brief Interface for Secure Crypto Engine (SCE) functions. - * - * @section SCE_PROTECTED_API_Summary Summary - * The SCE interface provides SCE functionality. - * - * The SCE interface can be implemented by: - * - @ref SCE_PROTECTED - * - * @{ - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Includes - **********************************************************************************************************************/ -#include - -#ifndef R_SCE_API_H -#define R_SCE_API_H - - - -/********************************************************************************************************************** - * Macro definitions - **********************************************************************************************************************/ -#define FSP_PARAMETER_NOT_USED(p) ((void) ((p))) - -/* For AES operation. */ -#define HW_SCE_AES128_KEY_INDEX_WORD_SIZE (12U) -#define HW_SCE_AES256_KEY_INDEX_WORD_SIZE (16U) -#define HW_SCE_AES128_KEY_WORD_SIZE (4U) -#define HW_SCE_AES256_KEY_WORD_SIZE (8U) -#define HW_SCE_AES128_KEY_BYTE_SIZE (16U) -#define HW_SCE_AES256_KEY_BYTE_SIZE (32U) -#define HW_SCE_AES_BLOCK_BYTE_SIZE (16U) -#define HW_SCE_AES_BLOCK_BIT_SIZE (128U) -#define HW_SCE_AES_CBC_IV_BYTE_SIZE (16U) - -/* For SHA operation. */ -#define HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE (28U) -#define HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE (32U) -#define HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE (64U) - -/* For RSA operation. */ -#define HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE (128U) -#define HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE (4U) -#define HW_SCE_RSA_1024_KEY_D_LENGTH_BYTE_SIZE (128U) -#define HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE (256U) -#define HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE (4U) -#define HW_SCE_RSA_2048_KEY_D_LENGTH_BYTE_SIZE (256U) -#define HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE (128 * 4U) -#define HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE (4U) -#define HW_SCE_RSA_4096_KEY_D_LENGTH_BYTE_SIZE (128 * 4U) -#define HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) -#define HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE (36U) -#define HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) -#define HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE (68U) -#define HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) -#define HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE (68U) -#define HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) -#define HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE (132U) -#define HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE (4U) -#define HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE (4U) -#define HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE (12U) -#define HW_SCE_RSA1024_NE_KEY_BYTE_SIZE (144U) -#define HW_SCE_RSA1024_ND_KEY_BYTE_SIZE (256U) -#define HW_SCE_RSA2048_NE_KEY_BYTE_SIZE (272U) -#define HW_SCE_RSA2048_ND_KEY_BYTE_SIZE (512U) -#define HW_SCE_RSA4096_NE_KEY_BYTE_SIZE (128 * 4 + 16U) -#define HW_SCE_RSA4096_ND_KEY_BYTE_SIZE (256 * 4U) -#define HW_SCE_RSA1024_NE_KEY_INDEX_WORD_SIZE (76U) -#define HW_SCE_RSA1024_ND_KEY_INDEX_WORD_SIZE (104U) -#define HW_SCE_RSA2048_NE_KEY_INDEX_WORD_SIZE (140U) -#define HW_SCE_RSA2048_ND_KEY_INDEX_WORD_SIZE (200U) -#define HW_SCE_RSA4096_NE_KEY_INDEX_WORD_SIZE (140U) -#define HW_SCE_RSA4096_ND_KEY_INDEX_WORD_SIZE (261U) -#define HW_SCE_RSA1024_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE (76U) -#define HW_SCE_RSA1024_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE (104U) -#define HW_SCE_RSA2048_RANDOM_PUBLIC_KEY_INDEX_WORD_SIZE (140U) -#define HW_SCE_RSA2048_RANDOM_PRIVATE_KEY_INDEX_WORD_SIZE (200U) - -#define HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE (11U) -#define HW_SCE_RSA_1024_DATA_BYTE_SIZE (128U) -#define HW_SCE_RSA_2048_DATA_BYTE_SIZE (256U) -#define HW_SCE_RSA_4096_DATA_BYTE_SIZE (128 * 4U) - -/* RSA HASH type. */ -#define HW_SCE_RSA_HASH_SHA256 (0x03) /* SHA-256 */ - -/* For ECC operation. */ -#define HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE (144U) -#define HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE (4U) -#define HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE (24U) -#define HW_SCE_ECC_PUBLIC_KEY_BYTE_SIZE (64U) -#define HW_SCE_ECC_PRIVATE_KEY_BYTE_SIZE (32U) -#define HW_SCE_ECDSA_DATA_BYTE_SIZE (64U) -#define HW_SCE_ECDSA_P512_DATA_BYTE_SIZE (128U) -#define HW_SCE_SHARED_SECRET_KEY_INDEX_WORD_SIZE (13U) - -/* Key update. */ -#define HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE (16U) - -#define SCE_OEM_KEY_SIZE_DUMMY_INST_DATA_WORD (0) -#define SCE_OEM_KEY_SIZE_AES128_INST_DATA_WORD (8) -#define SCE_OEM_KEY_SIZE_AES256_INST_DATA_WORD (12) - -#define SCE_OEM_KEY_SIZE_RSA1024_PUBLIC_KEY_INST_DATA_WORD (40) -#define SCE_OEM_KEY_SIZE_RSA1024_PRIVATE_KEY_INST_DATA_WORD (68) -#define SCE_OEM_KEY_SIZE_RSA2048_PUBLIC_KEY_INST_DATA_WORD (72) -#define SCE_OEM_KEY_SIZE_RSA2048_PRIVATE_KEY_INST_DATA_WORD (132) -#define SCE_OEM_KEY_SIZE_RSA4096_PUBLIC_KEY_INST_DATA_WORD (136) -#define SCE_OEM_KEY_SIZE_RSA4096_PRIVATE_KEY_INST_DATA_WORD (260) - -#define SCE_OEM_KEY_SIZE_ECCP192_PUBLIC_KEY_INST_DATA_WORD (20) -#define SCE_OEM_KEY_SIZE_ECCP192_PRIVATE_KEY_INST_DATA_WORD (12) -#define SCE_OEM_KEY_SIZE_ECCP224_PUBLIC_KEY_INST_DATA_WORD (20) -#define SCE_OEM_KEY_SIZE_ECCP224_PRIVATE_KEY_INST_DATA_WORD (12) -#define SCE_OEM_KEY_SIZE_ECCP256_PUBLIC_KEY_INST_DATA_WORD (20) -#define SCE_OEM_KEY_SIZE_ECCP256_PRIVATE_KEY_INST_DATA_WORD (12) -#define SCE_OEM_KEY_SIZE_ECCP512_PUBLIC_KEY_INST_DATA_WORD (36) -#define SCE_OEM_KEY_SIZE_ECCP512_PRIVATE_KEY_INST_DATA_WORD (20) - -#define SCE_INSTALL_KEY_RING_INDEX (0) /* 0-15 */ - -/********************************************************************************************************************** - * Typedef definitions - **********************************************************************************************************************/ -/* Return error codes fsp */ -typedef enum e_fsp_err -{ - FSP_SUCCESS = 0, - - /* Start of Crypto specific (0x10000) @note Refer to sf_cryoto_err.h for Crypto error code. */ - FSP_ERR_CRYPTO_CONTINUE = 0x10000, ///< Continue executing function - FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT = 0x10001, ///< Hardware resource busy - FSP_ERR_CRYPTO_SCE_FAIL = 0x10002, ///< Internal I/O buffer is not empty - FSP_ERR_CRYPTO_SCE_HRK_INVALID_INDEX = 0x10003, ///< Invalid index - FSP_ERR_CRYPTO_SCE_RETRY = 0x10004, ///< Retry - FSP_ERR_CRYPTO_SCE_VERIFY_FAIL = 0x10005, ///< Verify is failed - FSP_ERR_CRYPTO_SCE_ALREADY_OPEN = 0x10006, ///< HW SCE module is already opened - FSP_ERR_CRYPTO_NOT_OPEN = 0x10007, ///< Hardware module is not initialized - FSP_ERR_CRYPTO_UNKNOWN = 0x10008, ///< Some unknown error occurred - FSP_ERR_CRYPTO_NULL_POINTER = 0x10009, ///< Null pointer input as a parameter - FSP_ERR_CRYPTO_NOT_IMPLEMENTED = 0x1000a, ///< Algorithm/size not implemented - FSP_ERR_CRYPTO_RNG_INVALID_PARAM = 0x1000b, ///< An invalid parameter is specified - FSP_ERR_CRYPTO_RNG_FATAL_ERROR = 0x1000c, ///< A fatal error occurred - FSP_ERR_CRYPTO_INVALID_SIZE = 0x1000d, ///< Size specified is invalid - FSP_ERR_CRYPTO_INVALID_STATE = 0x1000e, ///< Function used in an valid state - FSP_ERR_CRYPTO_ALREADY_OPEN = 0x1000f, ///< control block is already opened - FSP_ERR_CRYPTO_INSTALL_KEY_FAILED = 0x10010, ///< Specified input key is invalid. - FSP_ERR_CRYPTO_AUTHENTICATION_FAILED = 0x10011, ///< Authentication failed - FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL = 0x10012, ///< Failure to Init Cipher - FSP_ERR_CRYPTO_SCE_AUTHENTICATION = 0x10013, ///< Authentication failed - FSP_ERR_CRYPTO_SCE_PARAMETER = 0x10014, ///< Input date is illegal. - FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION = 0x10015, ///< An invalid function call occurred. - - /* Start of SF_CRYPTO specific */ - FSP_ERR_CRYPTO_COMMON_NOT_OPENED = 0x20000, ///< Crypto Framework Common is not opened - FSP_ERR_CRYPTO_HAL_ERROR = 0x20001, ///< Cryoto HAL module returned an error - FSP_ERR_CRYPTO_KEY_BUF_NOT_ENOUGH = 0x20002, ///< Key buffer size is not enough to generate a key - FSP_ERR_CRYPTO_BUF_OVERFLOW = 0x20003, ///< Attempt to write data larger than what the buffer can hold - FSP_ERR_CRYPTO_INVALID_OPERATION_MODE = 0x20004, ///< Invalid operation mode. - FSP_ERR_MESSAGE_TOO_LONG = 0x20005, ///< Message for RSA encryption is too long. - FSP_ERR_RSA_DECRYPTION_ERROR = 0x20006, ///< RSA Decryption error. -} fsp_err_t; - -/** Data lifecycle */ -typedef enum -{ - SCE_CM = 1, - SCE_SSD, - SCE_NSECSD, - SCE_DPL, - SCE_LCK_DBG, - SCE_LCK_BOOT, - SCE_RMA_REQ, - SCE_RMA_ACK, -} lifecycle_t; - -/** Byte data structure */ -typedef struct sce_byte_data -{ - uint8_t * pdata; ///< pointer - uint32_t data_length; ///< data_length - uint32_t data_type; ///< data type -} sce_byte_data_t; - -/** RSA byte data structure */ -typedef sce_byte_data_t sce_rsa_byte_data_t; ///< byte data - -/** ECDSA byte data structure */ -typedef sce_byte_data_t sce_ecdsa_byte_data_t; ///< byte data - -/** AES wrapped key data structure. DO NOT MODIFY. */ -typedef struct sce_aes_wrapped_key -{ - uint32_t type; ///< key type - - /* AES128, AES256 are supported */ - uint32_t value[HW_SCE_AES256_KEY_INDEX_WORD_SIZE]; ///< wrapped key value -} sce_aes_wrapped_key_t; - -/** RSA 1024bit public wrapped key data structure. DO NOT MODIFY. */ -typedef struct sce_rsa1024_public_wrapped_key -{ - uint32_t type; ///< key type - struct - { - /* key management information */ - uint32_t key_management_info1[HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; - /* RSA 1024-bit public key n (plaintext) */ - uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; - /* RSA 1024-bit public key e (plaintext) */ - uint8_t key_e[HW_SCE_RSA_1024_KEY_E_LENGTH_BYTE_SIZE]; - /* dummy */ - uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; - /* key management information */ - uint32_t key_management_info2[HW_SCE_RSA_1024_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; - } value; -} sce_rsa1024_public_wrapped_key_t; - -/** RSA 1024bit private wrapped key data structure. DO NOT MODIFY. */ -typedef struct sce_rsa1024_private_wrapped_key -{ - uint32_t type; ///< key type - struct - { - /* key management information */ - uint32_t key_management_info1[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; - /* RSA 1024-bit private key n (plaintext) */ - uint8_t key_n[HW_SCE_RSA_1024_KEY_N_LENGTH_BYTE_SIZE]; - /* key management information */ - uint32_t key_management_info2[HW_SCE_RSA_1024_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; - } value; -} sce_rsa1024_private_wrapped_key_t; - -/** RSA 2048bit public wrapped key data structure. DO NOT MODIFY. */ -typedef struct sce_rsa2048_public_wrapped_key -{ - uint32_t type; ///< Key type - struct - { - /* key management information */ - uint32_t key_management_info1[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; - /* RSA 2048-bit public key n (plaintext) */ - uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; - /* RSA 2048-bit public key e (plaintext) */ - uint8_t key_e[HW_SCE_RSA_2048_KEY_E_LENGTH_BYTE_SIZE]; - /* dummy */ - uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; - /* key management information */ - uint32_t key_management_info2[HW_SCE_RSA_2048_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; - } value; -} sce_rsa2048_public_wrapped_key_t; - -/** RSA 2048bit private wrapped key data structure. DO NOT MODIFY. */ -typedef struct sce_rsa2048_private_wrapped_key -{ - uint32_t type; ///< key type - struct - { - /* key management information */ - uint32_t key_management_info1[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO1_WORD_SIZE]; - /* RSA 2048-bit private key n (plaintext) */ - uint8_t key_n[HW_SCE_RSA_2048_KEY_N_LENGTH_BYTE_SIZE]; - /* key management information */ - uint32_t key_management_info2[HW_SCE_RSA_2048_PRIVATE_KEY_MANAGEMENT_INFO2_WORD_SIZE]; - } value; -} sce_rsa2048_private_wrapped_key_t; - -/** RSA 4096bit public wrapped key data structure. DO NOT MODIFY. */ -typedef struct sce_rsa4096_public_wrapped_key -{ - uint32_t type; ///< Key type - struct - { - /* key management information */ - uint32_t key_management_info1[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO1_WORD_SIZE]; - /* RSA 4096-bit public key n (plaintext) */ - uint8_t key_n[HW_SCE_RSA_4096_KEY_N_LENGTH_BYTE_SIZE]; - /* RSA 4096-bit public key e (plaintext) */ - uint8_t key_e[HW_SCE_RSA_4096_KEY_E_LENGTH_BYTE_SIZE]; - /* dummy */ - uint8_t dummy[HW_SCE_RSA_KEY_GENERATION_DUMMY_BYTE_SIZE]; - /* key management information */ - uint32_t key_management_info2[HW_SCE_RSA_4096_PUBLIC_KEY_MANAGEMENT_INFO2_WORD_SIZE]; - } value; -} sce_rsa4096_public_wrapped_key_t; - -/** RSA 1024bit wrapped key pair structure. DO NOT MODIFY. */ -typedef struct sce_rsa1024_wrapped_pair_key -{ - sce_rsa1024_private_wrapped_key_t priv_key; ///< RSA 1024-bit private wrapped key - sce_rsa1024_public_wrapped_key_t pub_key; ///< RSA 1024-bit public wrapped key -} sce_rsa1024_wrapped_pair_key_t; - -/** RSA 2048bit wrapped key pair structure. DO NOT MODIFY. */ -typedef struct sce_rsa2048_wrapped_pair_key -{ - sce_rsa2048_private_wrapped_key_t priv_key; ///< RSA 2048-bit private wrapped key - sce_rsa2048_public_wrapped_key_t pub_key; ///< RSA 2048-bit public wrapped key -} sce_rsa2048_wrapped_pair_key_t; - -/** ECC P-192/224/256/512 public wrapped key data structure */ -typedef struct sce_ecc_public_wrapped_key -{ - uint32_t type; ///< key type - struct - { - /* key management information */ - uint32_t key_management_info[HW_SCE_ECC_PUBLIC_KEY_MANAGEMENT_INFO_WORD_SIZE]; - /* ECC public key Q (plaintext) */ - uint8_t key_q[HW_SCE_ECC_KEY_LENGTH_BYTE_SIZE]; - } value; -} sce_ecc_public_wrapped_key_t; - -/** ECC P-192/224/256/512 private wrapped key data structure */ -typedef struct sce_ecc_private_wrapped_key -{ - uint32_t type; ///< key type - uint32_t value[HW_SCE_ECC_PRIVATE_KEY_MANAGEMENT_INFO_WORD_SIZE]; ///< wrapped key value -} sce_ecc_private_wrapped_key_t; - -/** ECC P-192/224/256 wrapped key pair structure */ -typedef struct sce_ecc_wrapped_pair_key -{ - sce_ecc_private_wrapped_key_t priv_key; ///< ECC private wrapped key - sce_ecc_public_wrapped_key_t pub_key; ///< ECC public wrapped key -} sce_ecc_wrapped_pair_key_t; - -/** Update key ring index data structure. DO NOT MODIFY. */ -typedef struct sce_key_update_key -{ - uint32_t type; ///< key type - uint32_t value[HW_SCE_UPDATE_KEY_RING_INDEX_WORD_SIZE]; ///< wrapped key value -} sce_key_update_key_t; - -/** The work area for AES. DO NOT MODIFY. */ -typedef struct sce_aes_handle -{ - /* serial number of this handle */ - uint32_t id; - /* wrapped key */ - sce_aes_wrapped_key_t wrapped_key; - /* text size under encryption / decryption */ - uint32_t current_input_data_size; - /* text array less than the block long */ - uint8_t last_1_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE]; - /* reserved */ - uint8_t last_2_block_as_fraction[HW_SCE_AES_BLOCK_BYTE_SIZE * 2]; - /* current initialization vector used in CBC/CTR mode */ - uint8_t current_initial_vector[HW_SCE_AES_CBC_IV_BYTE_SIZE]; - /* control flag of calling function */ - uint8_t flag_call_init; -} sce_aes_handle_t; - -/** The work area for CMAC. DO NOT MODIFY. */ -typedef struct sce_cmac_handle -{ - uint32_t id; ///< serial number of this handle - sce_aes_wrapped_key_t wrapped_key; ///< wrapped key - uint8_t cmac_buffer[HW_SCE_AES_BLOCK_BYTE_SIZE]; ///< message array less than the block long - uint32_t all_received_length; ///< entire length of message - /* message array length less than the block long */ - uint32_t buffering_length; - uint8_t flag_call_init; ///< control flag of calling function -} sce_cmac_handle_t; - -/** The work area for SHA. DO NOT MODIFY. */ -typedef struct sce_sha_md5_handle -{ - uint32_t id; ///< serial number of this handle - uint8_t sha_buffer[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE * 4];///< message array length less than the block long - uint32_t all_received_length; ///< entire length of message - uint32_t buffering_length; ///< message array length less than the block long - - /* SHA1(20byte), SHA256(32byte), MD5(16byte) are supported */ - uint8_t current_hash[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE]; ///< last hash value - uint8_t flag_call_init; ///< control flag of calling function -} sce_sha_md5_handle_t; - -/** SCE Control block. Allocate an instance specific control block to pass into the API calls. - * @par Implemented as - * - sce_instance_ctrl_t - */ -typedef void sce_ctrl_t; - -/** User configuration structure, used in open function */ -typedef struct st_sce_cfg -{ - lifecycle_t lifecycle; ///< Data lifecycle -} sce_cfg_t; - -/** Functions implemented at the HAL layer will follow this API. */ -typedef struct st_sce_api -{ - /** Enables use of SCE functionality. - * @par Implemented as - * - @ref R_SCE_Open() - * - * @param[in] p_ctrl Pointer to control structure. - * @param[in] p_cfg Pointer to pin configuration structure. - */ - - /***** TODO: Replace "struct st_sce_ctrl" to "void" *****/ - fsp_err_t (* open)(sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg); - - /** Stops supply of power to the SCE. - * @par Implemented as - * - @ref R_SCE_Close() - * - * @param[in] p_ctrl Pointer to control structure. - */ - fsp_err_t (* close)(sce_ctrl_t * const p_ctrl); - - /** Software reset to SCE. - * @par Implemented as - * - @ref R_SCE_SoftwareReset() - * - */ - fsp_err_t (* softwareReset)(void); - - /** Generates 4 words random number. - * @par Implemented as - * - @ref R_SCE_RandomNumberGenerate() - * - * @param[in,out] random Stores 4words (16 bytes) random data. - */ - fsp_err_t (* randomNumberGenerate)(uint32_t * random); - - /** This API outputs 128-bit AES wrapped key. - * @par Implemented as - * - @ref R_SCE_AES128_WrappedKeyGenerate() - * - * @param[in,out] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* AES128_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); - - /** This API outputs 256-bit AES wrapped key. - * @par Implemented as - * - @ref R_SCE_AES256_WrappedKeyGenerate() - * - * @param[in,out] wrapped_key 256-bit AES wrapped key - */ - fsp_err_t (* AES256_WrappedKeyGenerate)(sce_aes_wrapped_key_t * wrapped_key); - - /** This API outputs 128-bit AES wrapped key. - * @par Implemented as - * - @ref R_SCE_AES128_EncryptedKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* AES128_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); - - /** This API outputs 256-bit AES wrapped key. - * @par Implemented as - * - @ref R_SCE_AES256_EncryptedKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 256-bit AES wrapped key - */ - fsp_err_t (* AES256_EncryptedKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, sce_aes_wrapped_key_t * wrapped_key); - - /** Initialize AES128ECB encryption. - * @par Implemented as - * - @ref R_SCE_AES128ECB_EncryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* AES128ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES128ECB encryption. - * @par Implemented as - * - @ref R_SCE_AES128ECB_EncryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - */ - fsp_err_t (* AES128ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - /** Finalize AES128ECB encryption. - * @par Implemented as - * - @ref R_SCE_AES128ECB_EncryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - */ - fsp_err_t (* AES128ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - /** Initialize AES128ECB decryption. - * @par Implemented as - * - @ref R_SCE_AES128ECB_DecryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* AES128ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES128ECB decryption. - * @par Implemented as - * - @ref R_SCE_AES128ECB_DecryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - */ - fsp_err_t (* AES128ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - /** Finalize AES128ECB decryption. - * @par Implemented as - * - @ref R_SCE_AES128ECB_DecryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - */ - fsp_err_t (* AES128ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - /** Initialize AES256ECB encryption. - * @par Implemented as - * - @ref R_SCE_AES256ECB_EncryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - */ - fsp_err_t (* AES256ECB_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES256ECB encryption. - * @par Implemented as - * - @ref R_SCE_AES256ECB_EncryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - */ - fsp_err_t (* AES256ECB_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - /** Finalize AES256ECB encryption. - * @par Implemented as - * - @ref R_SCE_AES256ECB_EncryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - */ - fsp_err_t (* AES256ECB_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - /** Initialize AES256ECB decryption. - * @par Implemented as - * - @ref R_SCE_AES256ECB_DecryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - */ - fsp_err_t (* AES256ECB_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES256ECB decryption. - * @par Implemented as - * - @ref R_SCE_AES256ECB_DecryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - */ - fsp_err_t (* AES256ECB_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - /** Finalize AES256ECB decryption. - * @par Implemented as - * - @ref R_SCE_AES256ECB_DecryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - */ - fsp_err_t (* AES256ECB_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - /** Initialize AES128CBC encryption. - * @par Implemented as - * - @ref R_SCE_AES128CBC_EncryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES128CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES128CBC encryption. - * @par Implemented as - * - @ref R_SCE_AES128CBC_EncryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - */ - fsp_err_t (* AES128CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - /** Finalize AES128CBC encryption. - * @par Implemented as - * - @ref R_SCE_AES128CBC_EncryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - */ - fsp_err_t (* AES128CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - /** Initialize AES128CBC decryption. - * @par Implemented as - * - @ref R_SCE_AES128CBC_DecryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES128CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES128CBC decryption. - * @par Implemented as - * - @ref R_SCE_AES128CBC_DecryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - */ - fsp_err_t (* AES128CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - /** Finalize AES128CBC decryption. - * @par Implemented as - * - @ref R_SCE_AES128CBC_DecryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - */ - fsp_err_t (* AES128CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - /** Initialize AES256CBC encryption. - * @par Implemented as - * - @ref R_SCE_AES256CBC_EncryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES256CBC_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES256CBC encryption. - * @par Implemented as - * - @ref R_SCE_AES256CBC_EncryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - */ - fsp_err_t (* AES256CBC_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - /** Finalize AES256CBC encryption. - * @par Implemented as - * - @ref R_SCE_AES256CBC_EncryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - */ - fsp_err_t (* AES256CBC_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - /** Initialize AES256CBC decryption. - * @par Implemented as - * - @ref R_SCE_AES256CBC_DecryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES256CBC_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES256CBC decryption. - * @par Implemented as - * - @ref R_SCE_AES256CBC_DecryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - */ - fsp_err_t (* AES256CBC_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - /** Finalize AES256CBC decryption. - * @par Implemented as - * - @ref R_SCE_AES256CBC_DecryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - */ - fsp_err_t (* AES256CBC_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - /** Initialize AES128CTR encryption. - * @par Implemented as - * - @ref R_SCE_AES128CTR_EncryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES128CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES128CTR encryption. - * @par Implemented as - * - @ref R_SCE_AES128CTR_EncryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - */ - fsp_err_t (* AES128CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - /** Finalize AES128CTR encryption. - * @par Implemented as - * - @ref R_SCE_AES128CTR_EncryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - */ - fsp_err_t (* AES128CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - /** Initialize AES128CTR decryption. - * @par Implemented as - * - @ref R_SCE_AES128CTR_DecryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES128CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES128CTR decryption. - * @par Implemented as - * - @ref R_SCE_AES128CTR_DecryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - */ - fsp_err_t (* AES128CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - /** Finalize AES128CTR decryption. - * @par Implemented as - * - @ref R_SCE_AES128CTR_DecryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - */ - fsp_err_t (* AES128CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - /** Initialize AES256CTR encryption. - * @par Implemented as - * - @ref R_SCE_AES256CTR_EncryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES256CTR_EncryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES256CTR encryption. - * @par Implemented as - * - @ref R_SCE_AES256CTR_EncryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - */ - fsp_err_t (* AES256CTR_EncryptUpdate)(sce_aes_handle_t * handle, uint8_t * plain, uint8_t * cipher, - uint32_t plain_length); - - /** Finalize AES256CTR encryption. - * @par Implemented as - * - @ref R_SCE_AES256CTR_EncryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - */ - fsp_err_t (* AES256CTR_EncryptFinal)(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); - - /** Initialize AES256CTR decryption. - * @par Implemented as - * - @ref R_SCE_AES256CTR_DecryptInit() - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - */ - fsp_err_t (* AES256CTR_DecryptInit)(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); - - /** Update AES256CTR decryption. - * @par Implemented as - * - @ref R_SCE_AES256CTR_DecryptUpdate() - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - */ - fsp_err_t (* AES256CTR_DecryptUpdate)(sce_aes_handle_t * handle, uint8_t * cipher, uint8_t * plain, - uint32_t cipher_length); - - /** Finalize AES256CTR decryption. - * @par Implemented as - * - @ref R_SCE_AES256CTR_DecryptFinal() - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - */ - fsp_err_t (* AES256CTR_DecryptFinal)(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - - /** Initialize AES128CMAC generation. - * @par Implemented as - * - @ref R_SCE_AES128CMAC_GenerateInit() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* AES128CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES128CMAC generation. - * @par Implemented as - * - @ref R_SCE_AES128CMAC_GenerateUpdate() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) - */ - fsp_err_t (* AES128CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - /** Finalize AES128CMAC generation. - * @par Implemented as - * - @ref R_SCE_AES128CMAC_GenerateFinal() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (16byte) - */ - fsp_err_t (* AES128CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); - - /** Initialize AES128CMAC verification. - * @par Implemented as - * - @ref R_SCE_AES128CMAC_VerifyInit() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* AES128CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES128CMAC verification. - * @par Implemented as - * - @ref R_SCE_AES128CMAC_VerifyUpdate() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) - */ - fsp_err_t (* AES128CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - /** Finalize AES128CMAC verification. - * @par Implemented as - * - @ref R_SCE_AES128CMAC_VerifyFinal() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (mac_length byte) - * @param[in,out] mac_length MAC data length (2 to 16 bytes) - */ - fsp_err_t (* AES128CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); - - /** Initialize AES256CMAC generation. - * @par Implemented as - * - @ref R_SCE_AES256CMAC_GenerateInit() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - */ - fsp_err_t (* AES256CMAC_GenerateInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES256CMAC generation. - * @par Implemented as - * - @ref R_SCE_AES256CMAC_GenerateUpdate() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) - */ - fsp_err_t (* AES256CMAC_GenerateUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - /** Finalize AES256CMAC generation. - * @par Implemented as - * - @ref R_SCE_AES256CMAC_GenerateFinal() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (16byte) - */ - fsp_err_t (* AES256CMAC_GenerateFinal)(sce_cmac_handle_t * handle, uint8_t * mac); - - /** Initialize AES256CMAC verification. - * @par Implemented as - * - @ref R_SCE_AES256CMAC_VerifyInit() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - */ - fsp_err_t (* AES256CMAC_VerifyInit)(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); - - /** Update AES256CMAC verification. - * @par Implemented as - * - @ref R_SCE_AES256CMAC_VerifyUpdate() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) - */ - fsp_err_t (* AES256CMAC_VerifyUpdate)(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); - - /** Finalize AES256CMAC verification. - * @par Implemented as - * - @ref R_SCE_AES256CMAC_VerifyFinal() - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (mac_length byte) - * @param[in,out] mac_length MAC data length (2 to 16 bytes) - */ - fsp_err_t (* AES256CMAC_VerifyFinal)(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); - - /** Initialize SHA-256 Calculation. - * @par Implemented as - * - @ref R_SCE_SHA256_Init() - * - * @param[in,out] handle SHA handler (work area) - */ - fsp_err_t (* SHA256_Init)(sce_sha_md5_handle_t * handle); - - /** Update SHA-256 Calculation. - * @par Implemented as - * - @ref R_SCE_SHA256_Update() - * - * @param[in,out] handle SHA handler (work area) - * @param[in] message message data area - * @param[in] message_length message data length - */ - fsp_err_t (* SHA256_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); - - /** Finalize SHA-256 Calculation. - * @par Implemented as - * - @ref R_SCE_SHA256_Final() - * - * @param[in,out] handle SHA handler (work area) - * @param[in,out] digest hasha data area - * @param[in,out] digest_length hash data length (32bytes) - */ - fsp_err_t (* SHA256_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); - - /** Initialize SHA-224 Calculation. - * @par Implemented as - * - @ref R_SCE_SHA224_Init() - * - * @param[in,out] handle SHA handler (work area) - */ - fsp_err_t (* SHA224_Init)(sce_sha_md5_handle_t * handle); - - /** Update SHA-224 Calculation. - * @par Implemented as - * - @ref R_SCE_SHA224_Update() - * - * @param[in,out] handle SHA handler (work area) - * @param[in] message message data area - * @param[in] message_length message data length - */ - fsp_err_t (* SHA224_Update)(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); - - /** Finalize SHA-224 Calculation. - * @par Implemented as - * - @ref R_SCE_SHA224_Final() - * - * @param[in,out] handle SHA handler (work area) - * @param[in,out] digest hasha data area - * @param[in,out] digest_length hash data length (32bytes) - */ - fsp_err_t (* SHA224_Final)(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); - - /** This API outputs 1024-bit RSA wrapped pair key. - * @par Implemented as - * - @ref R_SCE_RSA1024_WrappedKeyPairGenerate() - * - * @param[in,out] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* RSA1024_WrappedKeyPairGenerate)(sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key); - - /** This API outputs 2048-bit RSA wrapped pair key. - * @par Implemented as - * - @ref R_SCE_RSA2048_WrappedKeyPairGenerate() - * - * @param[in,out] wrapped_key 128-bit AES wrapped key - */ - fsp_err_t (* RSA2048_WrappedKeyPairGenerate)(sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key); - - /** This API outputs 1024-bit RSA public wrapped key. - * @par Implemented as - * - @ref R_SCE_RSA1024_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 1024-bit RSA public wrapped key - */ - fsp_err_t (* RSA1024_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_public_wrapped_key_t * wrapped_key); - - /** This API outputs 1024-bit RSA private wrapped key. - * @par Implemented as - * - @ref R_SCE_RSA1024_EncryptedPrivateKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 1024-bit RSA private wrapped key - */ - fsp_err_t (* RSA1024_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_private_wrapped_key_t * wrapped_key); - - /** This API outputs 2048-bit RSA public wrapped key. - * @par Implemented as - * - @ref R_SCE_RSA2048_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 2048-bit RSA public wrapped key - */ - fsp_err_t (* RSA2048_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_public_wrapped_key_t * wrapped_key); - - /** This API outputs 2048-bit RSA private wrapped key. - * @par Implemented as - * - @ref R_SCE_RSA2048_EncryptedPrivateKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 2048-bit RSA private wrapped key - */ - fsp_err_t (* RSA2048_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_private_wrapped_key_t * wrapped_key); - - /** This API outputs 4096-bit RSA public wrapped key. - * @par Implemented as - * - @ref R_SCE_RSA4096_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 4096-bit RSA public wrapped key - */ - fsp_err_t (* RSA4096_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa4096_public_wrapped_key_t * wrapped_key); - - /** RSASSA-PKCS1-V1_5 signature generation. - * @par Implemented as - * - @ref R_SCE_RSASSA_PKCS1024_SignatureGenerate() - * - * @param[in] message_hash Message or hash value to which to attach signature - * @param[in,out] signature Signature text storage destination information - * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - */ - fsp_err_t (* RSASSA_PKCS1024_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, - sce_rsa_byte_data_t * signature, sce_rsa1024_private_wrapped_key_t * wrapped_key, uint8_t hash_type); - - /** RSASSA-PKCS1-V1_5 signature generation. - * @par Implemented as - * - @ref R_SCE_RSASSA_PKCS2048_SignatureGenerate() - * - * @param[in] message_hash Message or hash value to which to attach signature - * @param[in,out] signature Signature text storage destination information - * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - */ - fsp_err_t (* RSASSA_PKCS2048_SignatureGenerate)(sce_rsa_byte_data_t * message_hash, - sce_rsa_byte_data_t * signature, sce_rsa2048_private_wrapped_key_t * wrapped_key, uint8_t hash_type); - - /** RSASSA-PKCS1-V1_5 signature verification. - * @par Implemented as - * - @ref R_SCE_RSASSA_PKCS1024_SignatureVerify() - * - * @param[in] signature Signature text information to verify - * @param[in] message_hash Message text or hash value to verify - * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - */ - fsp_err_t (* RSASSA_PKCS1024_SignatureVerify)(sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, sce_rsa1024_public_wrapped_key_t * wrapped_key, uint8_t hash_type); - - /** RSASSA-PKCS1-V1_5 signature verification. - * @par Implemented as - * - @ref R_SCE_RSASSA_PKCS2048_SignatureVerify() - * - * @param[in] signature Signature text information to verify - * @param[in] message_hash Message text or hash value to verify - * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - */ - fsp_err_t (* RSASSA_PKCS2048_SignatureVerify)(sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, sce_rsa2048_public_wrapped_key_t * wrapped_key, uint8_t hash_type); - - /** RSASSA-PKCS1-V1_5 signature verification. - * @par Implemented as - * - @ref R_SCE_RSASSA_PKCS4096_SignatureVerify() - * - * @param[in] signature Signature text information to verify - * @param[in] message_hash Message text or hash value to verify - * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - */ - fsp_err_t (* RSASSA_PKCS4096_SignatureVerify)(sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, sce_rsa4096_public_wrapped_key_t * wrapped_key, uint8_t hash_type); - - /** RSAES-PKCS1-V1_5 encryption. - * @par Implemented as - * - @ref R_SCE_RSAES_PKCS1024_Encrypt() - * - * @param[in] plain plaintext - * @param[in,out] cipher ciphertext - * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. - */ - fsp_err_t (* RSAES_PKCS1024_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, - sce_rsa1024_public_wrapped_key_t * wrapped_key); - - /** RSAES-PKCS1-V1_5 encryption. - * @par Implemented as - * - @ref R_SCE_RSAES_PKCS2048_Encrypt() - * - * @param[in] plain plaintext - * @param[in,out] cipher ciphertext - * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. - */ - fsp_err_t (* RSAES_PKCS2048_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, - sce_rsa2048_public_wrapped_key_t * wrapped_key); - - /** RSAES-PKCS1-V1_5 encryption. - * @par Implemented as - * - @ref R_SCE_RSAES_PKCS4096_Encrypt() - * - * @param[in] plain plaintext - * @param[in,out] cipher ciphertext - * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. - */ - fsp_err_t (* RSAES_PKCS4096_Encrypt)(sce_rsa_byte_data_t * plain, sce_rsa_byte_data_t * cipher, - sce_rsa4096_public_wrapped_key_t * wrapped_key); - - /** RSAES-PKCS1-V1_5 decryption. - * @par Implemented as - * - @ref R_SCE_RSAES_PKCS1024_Decrypt() - * - * @param[in] cipher ciphertext - * @param[in,out] plain plaintext - * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. - */ - fsp_err_t (* RSAES_PKCS1024_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, - sce_rsa1024_private_wrapped_key_t * wrapped_key); - - /** RSAES-PKCS1-V1_5 decryption. - * @par Implemented as - * - @ref R_SCE_RSAES_PKCS2048_Decrypt() - * - * @param[in] cipher ciphertext - * @param[in,out] plain plaintext - * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. - */ - fsp_err_t (* RSAES_PKCS2048_Decrypt)(sce_rsa_byte_data_t * cipher, sce_rsa_byte_data_t * plain, - sce_rsa2048_private_wrapped_key_t * wrapped_key); - - /** This API outputs secp192r1 wrapped pair key. - * @par Implemented as - * - @ref R_SCE_ECC_secp192r1_WrappedKeyPairGenerate() - * - * @param[in,out] wrapped_pair_key Wrapped pair key for secp192r1 public key and private key pair - */ - fsp_err_t (* ECC_secp192r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - /** This API outputs secp224r1 wrapped pair key. - * @par Implemented as - * - @ref R_SCE_ECC_secp224r1_WrappedKeyPairGenerate() - * - * @param[in,out] wrapped_pair_key Wrapped pair key for secp224r1 public key and private key pair - */ - fsp_err_t (* ECC_secp224r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - /** This API outputs secp256r1 wrapped pair key. - * @par Implemented as - * - @ref R_SCE_ECC_secp256r1_WrappedKeyPairGenerate() - * - * @param[in,out] wrapped_pair_key Wrapped pair key for secp256r1 public key and private key pair - */ - fsp_err_t (* ECC_secp256r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - /** This API outputs BrainpoolP512r1 wrapped pair key. - * @par Implemented as - * - @ref R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate() - * - * @param[in,out] wrapped_pair_key Wrapped pair key for BrainpoolP512r1 public key and private key pair - */ - fsp_err_t (* ECC_BrainpoolP512r1_WrappedKeyPairGenerate)(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); - - /** This API outputs secp192r1 public wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp192r1 public wrapped key - */ - fsp_err_t (* ECC_secp192r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** This API outputs secp224r1 public wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp224r1 public wrapped key - */ - fsp_err_t (* ECC_secp224r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** This API outputs secp256r1 public wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp256r1 public wrapped key - */ - fsp_err_t (* ECC_secp256r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** This API outputs BrainpoolP512r1 public wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key BrainpoolP512r1 public wrapped key - */ - fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPublicKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** This API outputs secp192r1 private wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp192r1 private wrapped key - */ - fsp_err_t (* ECC_secp192r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** This API outputs secp224r1 private wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp224r1 private wrapped key - */ - fsp_err_t (* ECC_secp224r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** This API outputs secp256r1 private wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp256r1 private wrapped key - */ - fsp_err_t (* ECC_secp256r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** This API outputs BrainpoolP512r1 private wrapped key. - * @par Implemented as - * - @ref R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap() - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key BrainpoolP512r1 private wrapped key - */ - fsp_err_t (* ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap)(uint8_t * initial_vector, uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** ECDSA signature generation. - * @par Implemented as - * - @ref R_SCE_ECDSA_secp192r1_SignatureGenerate() - * - * @param[in] message_hash Message or hash value to which to attach signature - * @param[in,out] signature Signature text storage destination information - * @param[in] wrapped_key Input wrapped key of secp192r1 private key. - */ - fsp_err_t (* ECDSA_secp192r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** ECDSA signature generation. - * @par Implemented as - * - @ref R_SCE_ECDSA_secp224r1_SignatureGenerate() - * - * @param[in] message_hash Message or hash value to which to attach signature - * @param[in,out] signature Signature text storage destination information - * @param[in] wrapped_key Input wrapped key of secp224r1 private key. - */ - fsp_err_t (* ECDSA_secp224r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** ECDSA signature generation. - * @par Implemented as - * - @ref R_SCE_ECDSA_secp256r1_SignatureGenerate() - * - * @param[in] message_hash Message or hash value to which to attach signature - * @param[in,out] signature Signature text storage destination information - * @param[in] wrapped_key Input wrapped key of secp256r1 private key. - */ - fsp_err_t (* ECDSA_secp256r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** ECDSA signature generation. - * @par Implemented as - * - @ref R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate() - * - * @param[in] message_hash Message or hash value to which to attach signature - * @param[in,out] signature Signature text storage destination information - * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 private key. - */ - fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureGenerate)(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); - - /** ECDSA signature verification. - * @par Implemented as - * - @ref R_SCE_ECDSA_secp192r1_SignatureVerify() - * - * @param[in] signature Signature text information to be verified - * @param[in,out] message_hash Message or hash value to be verified - * @param[in] wrapped_key Input wrapped key of secp192r1 public key. - */ - fsp_err_t (* ECDSA_secp192r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** ECDSA signature verification. - * @par Implemented as - * - @ref R_SCE_ECDSA_secp224r1_SignatureVerify() - * - * @param[in] signature Signature text information to be verified - * @param[in,out] message_hash Message or hash value to be verified - * @param[in] wrapped_key Input wrapped key of secp224r1 public key. - */ - fsp_err_t (* ECDSA_secp224r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** ECDSA signature verification. - * @par Implemented as - * - @ref R_SCE_ECDSA_secp256r1_SignatureVerify() - * - * @param[in] signature Signature text information to be verified - * @param[in,out] message_hash Message or hash value to be verified - * @param[in] wrapped_key Input wrapped key of secp256r1 public key. - */ - fsp_err_t (* ECDSA_secp256r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - - /** ECDSA signature verification. - * @par Implemented as - * - @ref R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify() - * - * @param[in] signature Signature text information to be verified - * @param[in,out] message_hash Message or hash value to be verified - * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 public key. - */ - fsp_err_t (* ECDSA_BrainpoolP512r1_SignatureVerify)(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - -} sce_api_t; - -/** This structure encompasses everything that is needed to use an instance of this interface. */ -typedef struct st_sce_instance -{ - sce_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance - sce_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance - sce_api_t const * p_api; ///< Pointer to the API structure for this instance -} sce_instance_t; - -#endif /* R_SCE_API_H */ - -/*******************************************************************************************************************//** - * @} (end addtogroup SCE_PROTECTED_API) - **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/g2l/drivers/r_sce/inc/instances/r_sce.h b/core/arch/arm/plat-rz/g2l/drivers/r_sce/inc/instances/r_sce.h deleted file mode 100644 index 23e3b19b6..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/r_sce/inc/instances/r_sce.h +++ /dev/null @@ -1,424 +0,0 @@ -/********************************************************************************************************************** - * DISCLAIMER - * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No - * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all - * applicable laws, including copyright laws. - * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING - * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM - * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES - * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO - * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of - * this software. By using this software, you agree to the additional terms and conditions found by accessing the - * following link: - * http://www.renesas.com/disclaimer - * - * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. - *********************************************************************************************************************/ -/********************************************************************************************************************** - * File Name : r_sce.h - * Version : 1.0 - * Description : SCE API header file - *********************************************************************************************************************/ -/********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release - *********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * @addtogroup SCE_PROTECTED - * @{ - **********************************************************************************************************************/ - -#include -#include "r_sce_api.h" - -#ifndef R_SCE_H -#define R_SCE_H - - -/*********************************************************************************************************************** - * Macro definitions - **********************************************************************************************************************/ - -/* Various information. */ -#define HW_SCE_BASE (0x11850000) -#define HW_SCE_SIZE (0x10000) -#define HW_SCE_SRAM_WORD_SIZE (20U) -#define HW_SCE_SINST_WORD_SIZE (140U) -#define HW_SCE_SINST2_WORD_SIZE (16U) -#define HW_SCE_SHEAP_WORD_SIZE (1496U) -#define HW_SCE_MAC_SIZE (16U) - -/* ECC curve types. */ -#define SCE_ECC_CURVE_TYPE_NIST (0) -#define SCE_ECC_CURVE_TYPE_BRAINPOOL (1) -#define SCE_ECC_CURVE_TYPE_KOBLITZ (2) - -/* ECC curve size */ -#define SCE_ECC_KEY_LENGTH_256 (0) -#define SCE_ECC_KEY_LENGTH_224 (1) -#define SCE_ECC_KEY_LENGTH_192 (2) - -/*********************************************************************************************************************** - * Typedef definitions - **********************************************************************************************************************/ - -/* key index type */ -typedef enum -{ - SCE_KEY_INDEX_TYPE_INVALID = 0U, - SCE_KEY_INDEX_TYPE_AES128, - SCE_KEY_INDEX_TYPE_AES256, - SCE_KEY_INDEX_TYPE_TDES, - SCE_KEY_INDEX_TYPE_HMAC_SHA1, - SCE_KEY_INDEX_TYPE_HMAC_SHA256, - SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE, - SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE, - SCE_KEY_INDEX_TYPE_RSA3072_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA3072_PRIVATE, - SCE_KEY_INDEX_TYPE_RSA4096_PUBLIC, - SCE_KEY_INDEX_TYPE_RSA4096_PRIVATE, - SCE_KEY_INDEX_TYPE_AES128_FOR_TLS, - SCE_KEY_INDEX_TYPE_AES192_FOR_TLS, - SCE_KEY_INDEX_TYPE_AES256_FOR_TLS, - SCE_KEY_INDEX_TYPE_HMAC_SHA1_FOR_TLS, - SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_TLS, - SCE_KEY_INDEX_TYPE_UPDATE_KEY_RING, - SCE_KEY_INDEX_TYPE_TLS_CA_CERTIFICATION_PUBLIC_KEY, - SCE_KEY_INDEX_TYPE_TLS_P256_ECC_KEY, - SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P384_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P384_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P256R1_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P384R1_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_P256R1_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_P384R1_PRIVATE, - SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PUBLIC, - SCE_KEY_INDEX_TYPE_ECC_SECP256K1_PRIVATE, - SCE_KEY_INDEX_TYPE_ECDH_SHARED_SECRET, - SCE_KEY_INDEX_TYPE_AES128_FOR_ECDH, - SCE_KEY_INDEX_TYPE_AES256_FOR_ECDH, - SCE_KEY_INDEX_TYPE_HMAC_SHA256_FOR_ECDH, - SCE_KEY_INDEX_TYPE_AES128_GCM_FOR_DLMS_COSEM, - SCE_KEY_INDEX_TYPE_AES256_GCM_FOR_DLMS_COSEM, - SCE_KEY_INDEX_TYPE_AES128_KEY_WRAP_FOR_DLMS_COSEM, - SCE_KEY_INDEX_TYPE_AES128_GCM_WITH_IV, -} SCE_KEY_INDEX_TYPE; - -/* OEM Command */ -typedef enum e_sce_oem_cmd -{ - SCE_OEM_CMD_AES128 = 5, - SCE_OEM_CMD_AES256 = 7, - SCE_OEM_CMD_RSA1024_PUBLIC = 10, - SCE_OEM_CMD_RSA1024_PRIVATE, - SCE_OEM_CMD_RSA2048_PUBLIC, - SCE_OEM_CMD_RSA2048_PRIVATE, - SCE_OEM_CMD_RSA3072_PUBLIC, - SCE_OEM_CMD_RSA3072_PRIVATE, - SCE_OEM_CMD_RSA4096_PUBLIC, - SCE_OEM_CMD_RSA4096_PRIVATE, - SCE_OEM_CMD_ECC_P192_PUBLIC, - SCE_OEM_CMD_ECC_P192_PRIVATE, - SCE_OEM_CMD_ECC_P224_PUBLIC, - SCE_OEM_CMD_ECC_P224_PRIVATE, - SCE_OEM_CMD_ECC_P256_PUBLIC, - SCE_OEM_CMD_ECC_P256_PRIVATE, - SCE_OEM_CMD_ECC_P384_PUBLIC, - SCE_OEM_CMD_ECC_P384_PRIVATE, - SCE_OEM_CMD_ECC_P512_PUBLIC, - SCE_OEM_CMD_ECC_P512_PRIVATE, - SCE_OEM_CMD_HMAC_SHA256 = 28, - SCE_OEM_CMD_NUM -} sce_oem_cmd_t; - -/** SCE private control block. DO NOT MODIFY. Initialization occurs when R_SCE_Open() is called. */ -typedef struct st_sce_instance_ctrl -{ - uint32_t open; // Indicates whether the open() API has been successfully -} sce_instance_ctrl_t; - -/********************************************************************************************************************** - * Exported global variables - **********************************************************************************************************************/ -/********************************************************************************************************************** - External global variables - *********************************************************************************************************************/ -/* memory area for SCE procedure */ -extern volatile uint32_t * gp_sce; - -/** @cond INC_HEADER_DEFS_SEC */ -/** Filled in Interface API structure for this Instance. */ -extern const sce_api_t g_sce_protected_on_sce; - -/** @endcond */ - -/********************************************************************************************************************** - * Public Function Prototypes - **********************************************************************************************************************/ -fsp_err_t R_SCE_Open(sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg); -fsp_err_t R_SCE_Close(sce_ctrl_t * const p_ctrl); -fsp_err_t R_SCE_SoftwareReset(void); - -fsp_err_t R_SCE_AES128_WrappedKeyGenerate(sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES256_WrappedKeyGenerate(sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSA1024_WrappedKeyPairGenerate(sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key); -fsp_err_t R_SCE_RSA2048_WrappedKeyPairGenerate(sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key); -fsp_err_t R_SCE_ECC_secp192r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); -fsp_err_t R_SCE_ECC_secp224r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); -fsp_err_t R_SCE_ECC_secp256r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); -fsp_err_t R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate(sce_ecc_wrapped_pair_key_t * wrapped_pair_key); -fsp_err_t R_SCE_RandomNumberGenerate(uint32_t * random); - -fsp_err_t R_SCE_AES128_EncryptedKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES256_EncryptedKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_aes_wrapped_key_t * wrapped_key); - -fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa4096_public_wrapped_key_t * wrapped_key); - -fsp_err_t R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap(uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key); - -fsp_err_t R_SCE_AES128ECB_EncryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES128ECB_EncryptUpdate(sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length); -fsp_err_t R_SCE_AES128ECB_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); -fsp_err_t R_SCE_AES128ECB_DecryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES128ECB_DecryptUpdate(sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length); -fsp_err_t R_SCE_AES128ECB_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); -fsp_err_t R_SCE_AES256ECB_EncryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES256ECB_EncryptUpdate(sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length); -fsp_err_t R_SCE_AES256ECB_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); -fsp_err_t R_SCE_AES256ECB_DecryptInit(sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES256ECB_DecryptUpdate(sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length); -fsp_err_t R_SCE_AES256ECB_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - -fsp_err_t R_SCE_AES128CBC_EncryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES128CBC_EncryptUpdate(sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length); -fsp_err_t R_SCE_AES128CBC_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); -fsp_err_t R_SCE_AES128CBC_DecryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES128CBC_DecryptUpdate(sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length); -fsp_err_t R_SCE_AES128CBC_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); -fsp_err_t R_SCE_AES256CBC_EncryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES256CBC_EncryptUpdate(sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length); -fsp_err_t R_SCE_AES256CBC_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); -fsp_err_t R_SCE_AES256CBC_DecryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES256CBC_DecryptUpdate(sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length); -fsp_err_t R_SCE_AES256CBC_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - -fsp_err_t R_SCE_AES128CTR_EncryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES128CTR_EncryptUpdate(sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length); -fsp_err_t R_SCE_AES128CTR_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); -fsp_err_t R_SCE_AES128CTR_DecryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES128CTR_DecryptUpdate(sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length); -fsp_err_t R_SCE_AES128CTR_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); -fsp_err_t R_SCE_AES256CTR_EncryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES256CTR_EncryptUpdate(sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length); -fsp_err_t R_SCE_AES256CTR_EncryptFinal(sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length); -fsp_err_t R_SCE_AES256CTR_DecryptInit(sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector); -fsp_err_t R_SCE_AES256CTR_DecryptUpdate(sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length); -fsp_err_t R_SCE_AES256CTR_DecryptFinal(sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length); - -fsp_err_t R_SCE_AES128CMAC_GenerateInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES128CMAC_GenerateUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); -fsp_err_t R_SCE_AES128CMAC_GenerateFinal(sce_cmac_handle_t * handle, uint8_t * mac); -fsp_err_t R_SCE_AES128CMAC_VerifyInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES128CMAC_VerifyUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); -fsp_err_t R_SCE_AES128CMAC_VerifyFinal(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); -fsp_err_t R_SCE_AES256CMAC_GenerateInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES256CMAC_GenerateUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); -fsp_err_t R_SCE_AES256CMAC_GenerateFinal(sce_cmac_handle_t * handle, uint8_t * mac); -fsp_err_t R_SCE_AES256CMAC_VerifyInit(sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_AES256CMAC_VerifyUpdate(sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length); -fsp_err_t R_SCE_AES256CMAC_VerifyFinal(sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length); - -fsp_err_t R_SCE_SHA224_Init(sce_sha_md5_handle_t * handle); -fsp_err_t R_SCE_SHA224_Update(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); -fsp_err_t R_SCE_SHA224_Final(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); -fsp_err_t R_SCE_SHA256_Init(sce_sha_md5_handle_t * handle); -fsp_err_t R_SCE_SHA256_Update(sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length); -fsp_err_t R_SCE_SHA256_Final(sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length); - -fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate(sce_rsa_byte_data_t * message_hash, - sce_rsa_byte_data_t * signature, - sce_rsa1024_private_wrapped_key_t * wrapped_key, - uint8_t hash_type); -fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureVerify(sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, - sce_rsa1024_public_wrapped_key_t * wrapped_key, - uint8_t hash_type); -fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate(sce_rsa_byte_data_t * message_hash, - sce_rsa_byte_data_t * signature, - sce_rsa2048_private_wrapped_key_t * wrapped_key, - uint8_t hash_type); -fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify(sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, - sce_rsa2048_public_wrapped_key_t * wrapped_key, - uint8_t hash_type); -fsp_err_t R_SCE_RSASSA_PKCS4096_SignatureVerify(sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, - sce_rsa4096_public_wrapped_key_t * wrapped_key, - uint8_t hash_type); - -fsp_err_t R_SCE_RSAES_PKCS1024_Encrypt(sce_rsa_byte_data_t * plain, - sce_rsa_byte_data_t * cipher, - sce_rsa1024_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt(sce_rsa_byte_data_t * cipher, - sce_rsa_byte_data_t * plain, - sce_rsa1024_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSAES_PKCS2048_Encrypt(sce_rsa_byte_data_t * plain, - sce_rsa_byte_data_t * cipher, - sce_rsa2048_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSAES_PKCS2048_Decrypt(sce_rsa_byte_data_t * cipher, - sce_rsa_byte_data_t * plain, - sce_rsa2048_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt(sce_rsa_byte_data_t * plain, - sce_rsa_byte_data_t * cipher, - sce_rsa4096_public_wrapped_key_t * wrapped_key); - -fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate(sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); -fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify(sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key); - -#endif /* R_SCE_H */ - -/*******************************************************************************************************************//** - * @} (end addtogroup SCE_PROTECTED) - **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/g2l/drivers/r_sce/private/inc/r_sce_private.h b/core/arch/arm/plat-rz/g2l/drivers/r_sce/private/inc/r_sce_private.h deleted file mode 100644 index 583b47834..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/r_sce/private/inc/r_sce_private.h +++ /dev/null @@ -1,376 +0,0 @@ -/********************************************************************************************************************** - * DISCLAIMER - * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No - * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all - * applicable laws, including copyright laws. - * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING - * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM - * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES - * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO - * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of - * this software. By using this software, you agree to the additional terms and conditions found by accessing the - * following link: - * http://www.renesas.com/disclaimer - * - * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. - *********************************************************************************************************************/ -/********************************************************************************************************************** - * File Name : r_sce_private.h - * Version : 1.0 - * Description : SCE Private API header file - *********************************************************************************************************************/ -/********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release - *********************************************************************************************************************/ -/*********************************************************************************************************************** - * Includes - **********************************************************************************************************************/ -#include "r_sce.h" - -#ifndef R_SCE_PRIVATE_HEADER_FILE -#define R_SCE_PRIVATE_HEADER_FILE - -/*********************************************************************************************************************** - * Macro definitions - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Typedef definitions - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private function prototypes - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private global variables - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Global variables - **********************************************************************************************************************/ -extern uint32_t const S_FLASH2[]; -extern uint32_t S_RAM[HW_SCE_SRAM_WORD_SIZE]; -extern uint32_t S_HEAP[HW_SCE_SHEAP_WORD_SIZE]; -extern uint32_t S_INST2[HW_SCE_SINST2_WORD_SIZE]; - -/*********************************************************************************************************************** - * Functions - **********************************************************************************************************************/ - -/* --------------------- SCE driver wrapper layer ---------------------- */ - -fsp_err_t R_SCE_SelfCheck1Private(void); -fsp_err_t R_SCE_SelfCheck2Private(void); -fsp_err_t R_SCE_SelfCheck3Private(void); -fsp_err_t R_SCE_LoadHukPrivate(lifecycle_t lifecycle); -fsp_err_t R_SCE_FwIntegrityCheckPrivate(void); - -fsp_err_t R_SCE_UpdateOemKeyIndexPrivate(lifecycle_t lifecycle, - sce_oem_cmd_t key_type, - uint8_t * iv, - uint8_t * encrypted_oem_key, - uint32_t * key_index); - -fsp_err_t R_SCE_Aes128EcbEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); -fsp_err_t R_SCE_Aes128EcbEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes128EcbEncryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); -fsp_err_t R_SCE_Aes128EcbDecryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); -fsp_err_t R_SCE_Aes128EcbDecryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes128EcbDecryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); -fsp_err_t R_SCE_Aes128CbcEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); -fsp_err_t R_SCE_Aes128CbcEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes128CbcEncryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); -fsp_err_t R_SCE_Aes128CbcDecryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); -fsp_err_t R_SCE_Aes128CbcDecryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes128CbcDecryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); -fsp_err_t R_SCE_Aes128CtrEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); -fsp_err_t R_SCE_Aes128CtrEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes128CtrEncryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); -fsp_err_t R_SCE_Aes128CtrDecryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); -fsp_err_t R_SCE_Aes128CtrDecryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes128CtrDecryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); - -fsp_err_t R_SCE_Aes256EcbEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); -fsp_err_t R_SCE_Aes256EcbEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes256EcbEncryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); -fsp_err_t R_SCE_Aes256EcbDecryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); -fsp_err_t R_SCE_Aes256EcbDecryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes256EcbDecryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); -fsp_err_t R_SCE_Aes256CbcEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); -fsp_err_t R_SCE_Aes256CbcEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes256CbcEncryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); -fsp_err_t R_SCE_Aes256CbcDecryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); -fsp_err_t R_SCE_Aes256CbcDecryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes256CbcDecryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); -fsp_err_t R_SCE_Aes256CtrEncryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); -fsp_err_t R_SCE_Aes256CtrEncryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes256CtrEncryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); -fsp_err_t R_SCE_Aes256CtrDecryptInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV); -fsp_err_t R_SCE_Aes256CtrDecryptUpdatePrivate(uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes256CtrDecryptFinalPrivate(uint32_t * OutData_Text, uint32_t * OutData_length); - -fsp_err_t R_SCE_Aes128CmacGenerateInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); -fsp_err_t R_SCE_Aes128CmacGenerateUpdatePrivate(uint32_t * InData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes128CmacGenerateFinalPrivate(uint32_t All_Msg_Len, uint32_t * InData_Text, uint32_t * OutData_DataT); -fsp_err_t R_SCE_Aes128CmacVerifyInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); -fsp_err_t R_SCE_Aes128CmacVerifyUpdatePrivate(uint32_t * InData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes128CmacVerifyFinalPrivate(uint32_t All_Msg_Len, - uint32_t * InData_Text, - uint32_t * InData_DataT, - uint32_t * InData_DataTLen); - -fsp_err_t R_SCE_Aes256CmacGenerateInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); -fsp_err_t R_SCE_Aes256CmacGenerateUpdatePrivate(uint32_t * InData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes256CmacGenerateFinalPrivate(uint32_t All_Msg_Len, uint32_t * InData_Text, uint32_t * OutData_DataT); -fsp_err_t R_SCE_Aes256CmacVerifyInitPrivate(sce_aes_wrapped_key_t * InData_KeyIndex); -fsp_err_t R_SCE_Aes256CmacVerifyUpdatePrivate(uint32_t * InData_Text, uint32_t MAX_CNT); -fsp_err_t R_SCE_Aes256CmacVerifyFinalPrivate(uint32_t All_Msg_Len, - uint32_t * InData_Text, - uint32_t * InData_DataT, - uint32_t * InData_DataTLen); - -fsp_err_t R_SCE_Sha224InitPrivate(sce_sha_md5_handle_t * handle); -fsp_err_t R_SCE_Sha224UpdatePrivate(sce_sha_md5_handle_t * handle, uint32_t * InData_PaddedMsg, uint32_t MAX_CNT); -fsp_err_t R_SCE_Sha224FinalPrivate(sce_sha_md5_handle_t * handle, - uint32_t * InData_PaddedMsg, - uint32_t MAX_CNT, - uint32_t * OutData_MsgDigest, - uint32_t * OutData_Length); -fsp_err_t R_SCE_Sha256InitPrivate(sce_sha_md5_handle_t * handle); -fsp_err_t R_SCE_Sha256UpdatePrivate(sce_sha_md5_handle_t * handle, uint32_t * InData_PaddedMsg, uint32_t MAX_CNT); -fsp_err_t R_SCE_Sha256FinalPrivate(sce_sha_md5_handle_t * handle, - uint32_t * InData_PaddedMsg, - uint32_t MAX_CNT, - uint32_t * OutData_MsgDigest, - uint32_t * OutData_Length); - -fsp_err_t R_SCE_Rsa1024ModularExponentEncryptPrivate(uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text); -fsp_err_t R_SCE_Rsa1024ModularExponentDecryptPrivate(uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text); -fsp_err_t R_SCE_Rsa2048ModularExponentEncryptPrivate(uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text); -fsp_err_t R_SCE_Rsa2048ModularExponentDecryptPrivate(uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text); -fsp_err_t R_SCE_Rsa4096ModularExponentEncryptPrivate(uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text); - -/* --------------------- SCE control procedure related ---------------------- */ - -void R_SCE_SoftwareResetSub(void); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_RETRY **/ -fsp_err_t R_SCE_SelfCheck2Sub(void); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_StateCheckSub(uint32_t *fsm2_number); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_AES128_EncryptedKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_AES256_EncryptedKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(uint32_t *InData_CurveType, - uint32_t *InData_Cmd, - uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(uint32_t *InData_CurveType, - uint32_t *InData_Cmd, - uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrapSub(uint32_t *InData_IV, - uint32_t *InData_InstData, - uint32_t *OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT **/ -fsp_err_t R_SCE_GenerateAes128RandomKeyIndexSub(uint32_t * OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT **/ -fsp_err_t R_SCE_GenerateAes256RandomKeyIndexSub(uint32_t * OutData_KeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_GenerateRsa1024RandomKeyIndexSub(uint32_t MAX_CNT, - uint32_t * OutData_PubKeyIndex, - uint32_t * OutData_PrivKeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_GenerateRsa2048RandomKeyIndexSub(uint32_t MAX_CNT, - uint32_t * OutData_PubKeyIndex, - uint32_t * OutData_PrivKeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_GenerateEccRandomKeyIndexSub(uint32_t * InData_CurveType, - uint32_t * InData_Cmd, - uint32_t * OutData_PubKeyIndex, - uint32_t * OutData_PrivKeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_GenerateEccP512RandomKeyIndexSub (uint32_t *OutData_PubKeyIndex, - uint32_t *OutData_PrivKeyIndex); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT **/ -fsp_err_t R_SCE_GenerateRandomNumberSub(uint32_t * OutData_Text); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL - * @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_Aes128EncryptDecryptInitSub(const uint32_t * InData_Cmd, - const uint32_t * InData_KeyIndex, - const uint32_t * InData_IV); -void R_SCE_Aes128EncryptDecryptUpdateSub(const uint32_t * InData_Text, - uint32_t * OutData_Text, - const uint32_t MAX_CNT); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_Aes128EncryptDecryptFinalSub(void); - - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL - * @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_Aes256EncryptDecryptInitSub(const uint32_t * InData_Cmd, - const uint32_t * InData_KeyIndex, - const uint32_t * InData_IV); -void R_SCE_Aes256EncryptDecryptUpdateSub(const uint32_t * InData_Text, - uint32_t * OutData_Text, - const uint32_t MAX_CNT); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_Aes256EncryptDecryptFinalSub(void); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL - * @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_Aes128CmacInitSub(uint32_t * InData_KeyIndex); -void R_SCE_Aes128CmacUpdateSub(uint32_t * InData_Text, uint32_t MAX_CNT); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION **/ -fsp_err_t R_SCE_Aes128CmacFinalSub(uint32_t * InData_Cmd, - uint32_t * InData_Text, - uint32_t * InData_DataT, - uint32_t * InData_DataTLen, - uint32_t * OutData_DataT); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL - * @retval FSP_ERR_CRYPTO_SCE_FAIL **/ -fsp_err_t R_SCE_Aes256CmacInitSub(uint32_t * InData_KeyIndex); -void R_SCE_Aes256CmacUpdateSub(uint32_t * InData_Text, uint32_t MAX_CNT); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION **/ -fsp_err_t R_SCE_Aes256CmacFinalSub(uint32_t * InData_Cmd, - uint32_t * InData_Text, - uint32_t * InData_DataT, - uint32_t * InData_DataTLen, - uint32_t * OutData_DataT); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT **/ -fsp_err_t R_SCE_Sha224256GenerateMessageDigestSub(const uint32_t * InData_InitVal, - const uint32_t * InData_PaddedMsg, - const uint32_t MAX_CNT, - uint32_t * OutData_MsgDigest); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ -fsp_err_t R_SCE_Rsa1024ModularExponentEncryptSub(const uint32_t * InData_KeyIndex, - const uint32_t * InData_Text, - uint32_t * OutData_Text); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ -fsp_err_t R_SCE_Rsa1024ModularExponentDecryptSub(uint32_t * InData_KeyIndex, - const uint32_t * InData_Text, - uint32_t * OutData_Text); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ -fsp_err_t R_SCE_Rsa2048ModularExponentEncryptSub(const uint32_t * InData_KeyIndex, - const uint32_t * InData_Text, - uint32_t * OutData_Text); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ -fsp_err_t R_SCE_Rsa2048ModularExponentDecryptSub(uint32_t * InData_KeyIndex, - const uint32_t * InData_Text, - uint32_t * OutData_Text); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ -fsp_err_t R_SCE_Rsa4096ModularExponentEncryptSub(const uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ -fsp_err_t R_SCE_EcdsaSignatureGenerateSub(uint32_t * InData_CurveType, - uint32_t * InData_Cmd, - uint32_t * InData_KeyIndex, - uint32_t * InData_MsgDgst, - uint32_t * OutData_Signature); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ -fsp_err_t R_SCE_EcdsaSignatureVerificationSub(uint32_t * InData_CurveType, - uint32_t * InData_Cmd, - uint32_t * InData_KeyIndex, - uint32_t * InData_MsgDgst, - uint32_t * InData_Signature); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ -fsp_err_t R_SCE_EcdsaP512SignatureVerificationSub (uint32_t *InData_KeyIndex, - uint32_t *InData_MsgDgst, - uint32_t *InData_Signature); - -/** @retval FSP_SUCCESS @retval FSP_ERR_CRYPTO_SCE_FAIL @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL **/ -fsp_err_t R_SCE_EcdsaP512SignatureGenerateSub (uint32_t *InData_KeyIndex, - uint32_t *InData_MsgDgst, - uint32_t *OutData_Signature); - -uint32_t change_endian_long (volatile uint32_t value); - -#endif /* R_SCE_PRIVATE_HEADER_FILE */ diff --git a/core/arch/arm/plat-rz/g2l/drivers/r_sce/private/r_sce_private.c b/core/arch/arm/plat-rz/g2l/drivers/r_sce/private/r_sce_private.c deleted file mode 100644 index b2c498159..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/r_sce/private/r_sce_private.c +++ /dev/null @@ -1,1346 +0,0 @@ -/********************************************************************************************************************** - * DISCLAIMER - * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No - * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all - * applicable laws, including copyright laws. - * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING - * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM - * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES - * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO - * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of - * this software. By using this software, you agree to the additional terms and conditions found by accessing the - * following link: - * http://www.renesas.com/disclaimer - * - * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. - *********************************************************************************************************************/ -/********************************************************************************************************************** - * File Name : r_sce_private.c - * Version : 1.0 - * Description : SCE Private API source file - *********************************************************************************************************************/ -/********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release - *********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Includes - **********************************************************************************************************************/ -#include -#include "r_sce_private.h" - -/*********************************************************************************************************************** - * Macro definitions - **********************************************************************************************************************/ -#ifndef SCE_HEX_6A09E667 -#define SCE_HEX_6A09E667 (0x6a09e667UL) -#endif -#ifndef SCE_HEX_BB67AE85 -#define SCE_HEX_BB67AE85 (0xbb67ae85UL) -#endif -#ifndef SCE_HEX_3C6EF372 -#define SCE_HEX_3C6EF372 (0x3c6ef372UL) -#endif -#ifndef SCE_HEX_A54FF53A -#define SCE_HEX_A54FF53A (0xa54ff53aUL) -#endif -#ifndef SCE_HEX_510E527F -#define SCE_HEX_510E527F (0x510e527fUL) -#endif -#ifndef SCE_HEX_9B05688C -#define SCE_HEX_9B05688C (0x9b05688cUL) -#endif -#ifndef SCE_HEX_1F83D9AB -#define SCE_HEX_1F83D9AB (0x1f83d9abUL) -#endif -#ifndef SCE_HEX_5BE0CD19 -#define SCE_HEX_5BE0CD19 (0x5be0cd19UL) -#endif -#ifndef SCE_HEX_C1059ED8 -#define SCE_HEX_C1059ED8 (0xc1059ed8UL) -#endif -#ifndef SCE_HEX_367CD507 -#define SCE_HEX_367CD507 (0x367cd507UL) -#endif -#ifndef SCE_HEX_3070DD17 -#define SCE_HEX_3070DD17 (0x3070dd17UL) -#endif -#ifndef SCE_HEX_F70E5939 -#define SCE_HEX_F70E5939 (0xf70e5939UL) -#endif -#ifndef SCE_HEX_FFC00B31 -#define SCE_HEX_FFC00B31 (0xffc00b31UL) -#endif -#ifndef SCE_HEX_68581511 -#define SCE_HEX_68581511 (0x68581511UL) -#endif -#ifndef SCE_HEX_64F98FA7 -#define SCE_HEX_64F98FA7 (0x64f98fa7UL) -#endif -#ifndef SCE_HEX_BEFA4FA4 -#define SCE_HEX_BEFA4FA4 (0xbefa4fa4UL) -#endif - -/*********************************************************************************************************************** - * Typedef definitions - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private function prototypes - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private global variables - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Global variables - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Functions - **********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES ECB mode algorithm with AES 128 key. - * - * @param InData_KeyIndex User key generation information area. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128EcbEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) -{ - uint32_t indata_cmd = 0; - uint32_t indata_iv[4] = /* dummy */ - { - 0 - }; - - if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(0); /* ECB-Encrypt command */ - - return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES ECB mode algorithm with AES 128 key. - * - * @param InData_Text Input plain text. - * @param OutData_Text Output cipher text. - * @param MAX_CNT Input byte size of plain. - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128EcbEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES ECB mode algorithm with AES 128 key. - * - * @param OutData_Text Output cipher text. - * @param OutData_length Output byte size of cipher. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128EcbEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) -{ - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); - - return R_SCE_Aes128EncryptDecryptFinalSub(); -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES ECB mode algorithm with AES 128 key. - * - * @param InData_KeyIndex User key generation information area. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128EcbDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) -{ - uint32_t indata_cmd = 0; - uint32_t indata_iv[4] = /* dummy */ - { - 0 - }; - - if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(1); /* ECB-Decrypt command */ - - return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES ECB mode algorithm with AES 128 key. - * - * @param InData_Text Input cipher text. - * @param OutData_Text Output plain text. - * @param MAX_CNT Input byte size of cipher. - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128EcbDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES ECB mode algorithm with AES 128 key. - * - * @param OutData_Text Output plain text. - * @param OutData_length Output byte size of plain. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128EcbDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) -{ - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); - - return R_SCE_Aes128EncryptDecryptFinalSub(); -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES ECB mode algorithm with AES 256 key. - * - * @param InData_KeyIndex User key generation information area. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256EcbEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) -{ - uint32_t indata_cmd = 0; - uint32_t indata_iv[4] = /* dummy */ - { - 0 - }; - - if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(0); /* ECB-Encrypt command */ - - return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES ECB mode algorithm with AES 256 key. - * - * @param InData_Text Input plain text. - * @param OutData_Text Output cipher text. - * @param MAX_CNT Input byte size of plain. - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256EcbEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES ECB mode algorithm with AES 256 key. - * - * @param OutData_Text Output cipher text. - * @param OutData_length Output byte size of cipher. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256EcbEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) -{ - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); - - return R_SCE_Aes256EncryptDecryptFinalSub(); -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES ECB mode algorithm with AES 256 key. - * - * @param InData_KeyIndex User key generation information area. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256EcbDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) -{ - uint32_t indata_cmd = 0; - uint32_t indata_iv[4] = /* dummy */ - { - 0 - }; - - if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(1); /* ECB-Decrypt command */ - - return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, indata_iv); -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES ECB mode algorithm with AES 256 key. - * - * @param InData_Text Input cipher text. - * @param OutData_Text Output plain text. - * @param MAX_CNT Input byte size of cipher. - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256EcbDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES ECB mode algorithm with AES 256 key. - * - * @param OutData_Text Output plain text. - * @param OutData_length Output byte size of plain. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256EcbDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) -{ - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); - - return R_SCE_Aes256EncryptDecryptFinalSub(); -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES CBC mode algorithm with AES 128 key. - * - * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CbcEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) -{ - uint32_t indata_cmd = 0; - - if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(2); /* CBC-Encrypt command */ - - return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES CBC mode algorithm with AES 128 key. - * - * @param InData_Text Input plain text. - * @param OutData_Text Output cipher text. - * @param MAX_CNT Input byte size of plain. - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CbcEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES CBC mode algorithm with AES 128 key. - * - * @param OutData_Text Output cipher text. - * @param OutData_length Output byte size of cipher. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CbcEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) -{ - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); - - return R_SCE_Aes128EncryptDecryptFinalSub(); -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES CBC mode algorithm with AES 128 key. - * - * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CbcDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) -{ - uint32_t indata_cmd = 0; - - if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(3); /* CBC-Decrypt command */ - - return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES CBC mode algorithm with AES 128 key. - * - * @param InData_Text Input cipher text. - * @param OutData_Text Output plain text. - * @param MAX_CNT Input byte size of cipher. - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CbcDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES CBC mode algorithm with AES 128 key. - * - * @param OutData_Text Output plain text. - * @param OutData_length Output byte size of plain. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CbcDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) -{ - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); - - return R_SCE_Aes128EncryptDecryptFinalSub(); -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES CBC mode algorithm with AES 256 key. - * - * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CbcEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) -{ - uint32_t indata_cmd = 0; - - if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(2); /* CBC-Encrypt command */ - - return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES CBC mode algorithm with AES 256 key. - * - * @param InData_Text Input plain text. - * @param OutData_Text Output cipher text. - * @param MAX_CNT Input byte size of plain. - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CbcEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES CBC mode algorithm with AES 256 key. - * - * @param OutData_Text Output cipher text. - * @param OutData_length Output byte size of cipher. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CbcEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) -{ - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); - - return R_SCE_Aes256EncryptDecryptFinalSub(); -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES CBC mode algorithm with AES 256 key. - * - * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CbcDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) -{ - uint32_t indata_cmd = 0; - - if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(3); /* CBC-Decrypt command */ - - return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES CBC mode algorithm with AES 256 key. - * - * @param InData_Text Input cipher text. - * @param OutData_Text Output plain text. - * @param MAX_CNT Input byte size of cipher. - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CbcDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES CBC mode algorithm with AES 256 key. - * - * @param OutData_Text Output plain text. - * @param OutData_length Output byte size of plain. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CbcDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) -{ - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); - - return R_SCE_Aes256EncryptDecryptFinalSub(); -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES CTR mode algorithm with AES 128 key. - * - * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CtrEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) -{ - uint32_t indata_cmd = 0; - - if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(4); /* CTR-Encrypt command */ - - return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES CTR mode algorithm with AES 128 key. - * - * @param InData_Text Input plain text. - * @param OutData_Text Output cipher text. - * @param MAX_CNT Input byte size of plain. - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CtrEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES CTR mode algorithm with AES 128 key. - * - * @param OutData_Text Output cipher text. - * @param OutData_length Output byte size of cipher. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CtrEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) -{ - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); - - return R_SCE_Aes128EncryptDecryptFinalSub(); -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES CTR mode algorithm with AES 128 key. - * - * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CtrDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) -{ - uint32_t indata_cmd = 0; - - if (SCE_KEY_INDEX_TYPE_AES128 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(4); /* CTR-Decrypt command */ - - return R_SCE_Aes128EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES CTR mode algorithm with AES 128 key. - * - * @param InData_Text Input cipher text. - * @param OutData_Text Output plain text. - * @param MAX_CNT Input byte size of cipher. - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CtrDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes128EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES CTR mode algorithm with AES 128 key. - * - * @param OutData_Text Output plain text. - * @param OutData_length Output byte size of plain. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CtrDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) -{ - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); - - return R_SCE_Aes128EncryptDecryptFinalSub(); -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES CTR mode algorithm with AES 256 key. - * - * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CtrEncryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) -{ - uint32_t indata_cmd = 0; - - if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(4); /* CTR-Encrypt command */ - - return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES CTR mode algorithm with AES 256 key. - * - * @param InData_Text Input plain text. - * @param OutData_Text Output cipher text. - * @param MAX_CNT Input byte size of plain. - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CtrEncryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Encrypt data to cipher using AES CTR mode algorithm with AES 256 key. - * - * @param OutData_Text Output cipher text. - * @param OutData_length Output byte size of cipher. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CtrEncryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) -{ - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); - - return R_SCE_Aes256EncryptDecryptFinalSub(); -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES CTR mode algorithm with AES 256 key. - * - * @param InData_KeyIndex User key generation information area. - * @param InData_IV Input initial vector. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CtrDecryptInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex, uint32_t * InData_IV) -{ - uint32_t indata_cmd = 0; - - if (SCE_KEY_INDEX_TYPE_AES256 != InData_KeyIndex->type) - { - return FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL; - } - indata_cmd = change_endian_long(4); /* CTR-Decrypt command */ - - return R_SCE_Aes256EncryptDecryptInitSub(&indata_cmd, InData_KeyIndex->value, InData_IV); -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES CTR mode algorithm with AES 256 key. - * - * @param InData_Text Input cipher text. - * @param OutData_Text Output plain text. - * @param MAX_CNT Input byte size of cipher. - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CtrDecryptUpdatePrivate (uint32_t * InData_Text, uint32_t * OutData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes256EncryptDecryptUpdateSub(InData_Text, OutData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Decrypt data to plain using AES CTR mode algorithm with AES 256 key. - * - * @param OutData_Text Output plain text. - * @param OutData_length Output byte size of plain. - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CtrDecryptFinalPrivate (uint32_t * OutData_Text, uint32_t * OutData_length) -{ - FSP_PARAMETER_NOT_USED(OutData_Text); - FSP_PARAMETER_NOT_USED(OutData_length); - - return R_SCE_Aes256EncryptDecryptFinalSub(); -} - -/*******************************************************************************************************************//** - * Prepare to execute AES calculation. - * - * @param InData_KeyIndex User key generation information area - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CmacGenerateInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) -{ - return R_SCE_Aes128CmacInitSub(InData_KeyIndex->value); -} - -/*******************************************************************************************************************//** - * Generates a MAC value from the message specified. - * - * @param InData_Text Message data area (data_len byte) - * @param MAX_CNT Message data length (0 to arbitrary byte) - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CmacGenerateUpdatePrivate (uint32_t * InData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes128CmacUpdateSub(InData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Outputs the Mac value. - * - * @param All_Msg_Len Input byte size of message data. - * @param InData_Text Input message data. - * @param OutData_DataT MAC data area (data_len byte) - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Reserved. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CmacGenerateFinalPrivate (uint32_t All_Msg_Len, uint32_t * InData_Text, uint32_t * OutData_DataT) -{ - uint32_t indata_cmd = 0; - uint32_t indata_datat[4] = /* dummy */ - { - 0 - }; - uint32_t indata_datat_len = 0; /* dummy */ - - if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) - { - indata_cmd = 0; - } - else - { - indata_cmd = 1; - } - - return R_SCE_Aes128CmacFinalSub(&indata_cmd, InData_Text, indata_datat, &indata_datat_len, OutData_DataT); -} - -/*******************************************************************************************************************//** - * Prepare to execute CMAC calculation. - * - * @param InData_KeyIndex User key generation information area - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CmacVerifyInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) -{ - return R_SCE_Aes128CmacInitSub(InData_KeyIndex->value); -} - -/*******************************************************************************************************************//** - * Verifies the MAC value. - * - * @param InData_Text Message data area (data_len byte) - * @param MAX_CNT Message data length (0 to arbitrary byte) - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CmacVerifyUpdatePrivate (uint32_t * InData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes128CmacUpdateSub(InData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Validates the Mac value. - * - * @param All_Msg_Len Input byte size of message data. - * @param InData_Text Input message data. - * @param InData_DataT MAC data area (data_len byte) - * @param InData_DataTLen MAC data length - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication NG - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes128CmacVerifyFinalPrivate (uint32_t All_Msg_Len, - uint32_t * InData_Text, - uint32_t * InData_DataT, - uint32_t * InData_DataTLen) -{ - uint32_t indata_cmd = 0; - uint32_t out_data[4] = - { - 0 - }; - - if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) - { - indata_cmd = 2; - } - else - { - indata_cmd = 3; - } - - return R_SCE_Aes128CmacFinalSub(&indata_cmd, InData_Text, InData_DataT, InData_DataTLen, out_data); -} - -/*******************************************************************************************************************//** - * Prepare to execute AES calculation. - * - * @param InData_KeyIndex User key generation information area - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CmacGenerateInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) -{ - return R_SCE_Aes256CmacInitSub(InData_KeyIndex->value); -} - -/*******************************************************************************************************************//** - * Generates a MAC value from the message specified. - * - * @param InData_Text Message data area (data_len byte) - * @param MAX_CNT Message data length (0 to arbitrary byte) - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CmacGenerateUpdatePrivate (uint32_t * InData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes256CmacUpdateSub(InData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Outputs the Mac value. - * - * @param All_Msg_Len Input byte size of message data. - * @param InData_Text Input message data. - * @param OutData_DataT MAC data area (data_len byte) - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Reserved. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CmacGenerateFinalPrivate (uint32_t All_Msg_Len, uint32_t * InData_Text, uint32_t * OutData_DataT) -{ - uint32_t indata_cmd = 0; - uint32_t indata_datat[4] = /* dummy */ - { - 0 - }; - uint32_t indata_datat_len = 0; /* dummy */ - - if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) - { - indata_cmd = 0; - } - else - { - indata_cmd = 1; - } - - return R_SCE_Aes256CmacFinalSub(&indata_cmd, InData_Text, indata_datat, &indata_datat_len, OutData_DataT); -} - -/*******************************************************************************************************************//** - * Prepare to execute CMAC calculation. - * - * @param InData_KeyIndex User key generation information area - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CmacVerifyInitPrivate (sce_aes_wrapped_key_t * InData_KeyIndex) -{ - return R_SCE_Aes256CmacInitSub(InData_KeyIndex->value); -} - -/*******************************************************************************************************************//** - * Verifies the MAC value. - * - * @param InData_Text Message data area (data_len byte) - * @param MAX_CNT Message data length (0 to arbitrary byte) - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CmacVerifyUpdatePrivate (uint32_t * InData_Text, uint32_t MAX_CNT) -{ - R_SCE_Aes256CmacUpdateSub(InData_Text, MAX_CNT); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Validates the Mac value. - * - * @param All_Msg_Len Input byte size of message data. - * @param InData_Text Input message data. - * @param InData_DataT MAC data area (data_len byte) - * @param InData_DataTLen MAC data length - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication NG - **********************************************************************************************************************/ -fsp_err_t R_SCE_Aes256CmacVerifyFinalPrivate (uint32_t All_Msg_Len, - uint32_t * InData_Text, - uint32_t * InData_DataT, - uint32_t * InData_DataTLen) -{ - uint32_t indata_cmd = 0; - uint32_t out_data[4] = - { - 0 - }; - - if ((0 == (All_Msg_Len % 16)) && (0 != All_Msg_Len)) - { - indata_cmd = 2; - } - else - { - indata_cmd = 3; - } - - return R_SCE_Aes256CmacFinalSub(&indata_cmd, InData_Text, InData_DataT, InData_DataTLen, out_data); -} - -/*******************************************************************************************************************//** - * prepares to execute the SHA256 hash operation - * - * @param handle SHA256 handler (work area) - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Sha256InitPrivate (sce_sha_md5_handle_t * handle) -{ - uint32_t indata_sha256initval[8] = - { - 0 - }; - - FSP_PARAMETER_NOT_USED(handle); - - indata_sha256initval[0] = change_endian_long(SCE_HEX_6A09E667); - indata_sha256initval[1] = change_endian_long(SCE_HEX_BB67AE85); - indata_sha256initval[2] = change_endian_long(SCE_HEX_3C6EF372); - indata_sha256initval[3] = change_endian_long(SCE_HEX_A54FF53A); - indata_sha256initval[4] = change_endian_long(SCE_HEX_510E527F); - indata_sha256initval[5] = change_endian_long(SCE_HEX_9B05688C); - indata_sha256initval[6] = change_endian_long(SCE_HEX_1F83D9AB); - indata_sha256initval[7] = change_endian_long(SCE_HEX_5BE0CD19); - - memcpy(handle->current_hash, indata_sha256initval, HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * calculate a hash value - * - * @param handle SHA256 handler (work area) - * @param InData_PaddedMsg Input message. - * @param MAX_CNT Input message length - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - **********************************************************************************************************************/ -fsp_err_t R_SCE_Sha256UpdatePrivate (sce_sha_md5_handle_t * handle, uint32_t * InData_PaddedMsg, uint32_t MAX_CNT) -{ - uint32_t out_data[8] = - { - 0 - }; - fsp_err_t ercd = FSP_SUCCESS; - - FSP_PARAMETER_NOT_USED(handle); - - /*Casting uint32_t pointer is used for address.*/ - ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, - InData_PaddedMsg, - MAX_CNT, - out_data); - memcpy(handle->current_hash, out_data, HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE); - - return ercd; -} - -/*******************************************************************************************************************//** - * calculate a hash value - * - * @param handle SHA256 handler (work area). - * @param InData_PaddedMsg Input Message data - * @param MAX_CNT Input message length - * @param OutData_MsgDigest Output Hash data - * @param OutData_Length Output Hash length - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - **********************************************************************************************************************/ -fsp_err_t R_SCE_Sha256FinalPrivate (sce_sha_md5_handle_t * handle, - uint32_t * InData_PaddedMsg, - uint32_t MAX_CNT, - uint32_t * OutData_MsgDigest, - uint32_t * OutData_Length) -{ - fsp_err_t ercd = FSP_SUCCESS; - - FSP_PARAMETER_NOT_USED(handle); - - /*Casting uint32_t pointer is used for address.*/ - ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, - InData_PaddedMsg, - MAX_CNT, - OutData_MsgDigest); - memcpy(handle->current_hash, OutData_MsgDigest, HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE); - *OutData_Length = HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE; - - return ercd; -} - -/*******************************************************************************************************************//** - * prepares to execute the SHA224 hash operation - * - * @param handle SHA224 handler (work area) - * - * @retval FSP_SUCCESS Normal termination. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Sha224InitPrivate (sce_sha_md5_handle_t * handle) -{ - uint32_t indata_sha224initval[8] = - { - 0 - }; - - FSP_PARAMETER_NOT_USED(handle); - - indata_sha224initval[0] = change_endian_long(SCE_HEX_C1059ED8); - indata_sha224initval[1] = change_endian_long(SCE_HEX_367CD507); - indata_sha224initval[2] = change_endian_long(SCE_HEX_3070DD17); - indata_sha224initval[3] = change_endian_long(SCE_HEX_F70E5939); - indata_sha224initval[4] = change_endian_long(SCE_HEX_FFC00B31); - indata_sha224initval[5] = change_endian_long(SCE_HEX_68581511); - indata_sha224initval[6] = change_endian_long(SCE_HEX_64F98FA7); - indata_sha224initval[7] = change_endian_long(SCE_HEX_BEFA4FA4); - - memcpy(handle->current_hash, indata_sha224initval, HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE + 4); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * calculate a hash value - * - * @param handle SHA224 handler (work area) - * @param InData_PaddedMsg Input message. - * @param MAX_CNT Input message length - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - **********************************************************************************************************************/ -fsp_err_t R_SCE_Sha224UpdatePrivate (sce_sha_md5_handle_t * handle, uint32_t * InData_PaddedMsg, uint32_t MAX_CNT) -{ - uint32_t out_data[8] = - { - 0 - }; - fsp_err_t ercd = FSP_SUCCESS; - - FSP_PARAMETER_NOT_USED(handle); - - /*Casting uint32_t pointer is used for address.*/ - ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, - InData_PaddedMsg, - MAX_CNT, - out_data); - memcpy(handle->current_hash, out_data, HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE + 4); - - return ercd; -} - -/*******************************************************************************************************************//** - * calculate a hash value - * - * @param handle SHA224 handler (work area). - * @param InData_PaddedMsg Input Message data - * @param MAX_CNT Input message length - * @param OutData_MsgDigest Output Hash data - * @param OutData_Length Output Hash length - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - **********************************************************************************************************************/ -fsp_err_t R_SCE_Sha224FinalPrivate (sce_sha_md5_handle_t * handle, - uint32_t * InData_PaddedMsg, - uint32_t MAX_CNT, - uint32_t * OutData_MsgDigest, - uint32_t * OutData_Length) -{ - fsp_err_t ercd = FSP_SUCCESS; - - FSP_PARAMETER_NOT_USED(handle); - - /*Casting uint32_t pointer is used for address.*/ - ercd = R_SCE_Sha224256GenerateMessageDigestSub((uint32_t *) handle->current_hash, - InData_PaddedMsg, - MAX_CNT, - (uint32_t *) handle->current_hash); - memcpy(OutData_MsgDigest, handle->current_hash, HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE); - *OutData_Length = HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE; - - return ercd; -} - -/*******************************************************************************************************************//** - * Modular exponentiation operation with RSA 1024bit public key - * - * @param InData_KeyIndex the public key index information - * @param InData_Text input data - * @param OutData_Text output data - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - **********************************************************************************************************************/ -fsp_err_t R_SCE_Rsa1024ModularExponentEncryptPrivate (uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text) -{ - return R_SCE_Rsa1024ModularExponentEncryptSub(InData_KeyIndex, InData_Text, OutData_Text); -} - -/*******************************************************************************************************************//** - * Modular exponentiation operation with RSA 1024bit private key - * - * @param InData_KeyIndex the private key index information - * @param InData_Text input data - * @param OutData_Text output data - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - **********************************************************************************************************************/ -fsp_err_t R_SCE_Rsa1024ModularExponentDecryptPrivate (uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text) -{ - return R_SCE_Rsa1024ModularExponentDecryptSub(InData_KeyIndex, InData_Text, OutData_Text); -} - -/*******************************************************************************************************************//** - * Modular exponentiation operation with RSA 2048bit public key - * - * @param InData_KeyIndex the public key index information - * @param InData_Text input data - * @param OutData_Text output data - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - **********************************************************************************************************************/ -fsp_err_t R_SCE_Rsa2048ModularExponentEncryptPrivate (uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text) -{ - return R_SCE_Rsa2048ModularExponentEncryptSub(InData_KeyIndex, InData_Text, OutData_Text); -} - -/*******************************************************************************************************************//** - * Modular exponentiation operation with RSA 2048bit private key - * - * @param InData_KeyIndex the private key index information - * @param InData_Text input data - * @param OutData_Text output data - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - **********************************************************************************************************************/ -fsp_err_t R_SCE_Rsa2048ModularExponentDecryptPrivate (uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text) -{ - return R_SCE_Rsa2048ModularExponentDecryptSub(InData_KeyIndex, InData_Text, OutData_Text); -} - -/*******************************************************************************************************************//** - * Modular exponentiation operation with RSA 4096bit public key - * - * @param InData_KeyIndex the public key index information - * @param InData_Text input data - * @param OutData_Text output data - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal user Key Generation Information - **********************************************************************************************************************/ -fsp_err_t R_SCE_Rsa4096ModularExponentEncryptPrivate (uint32_t * InData_KeyIndex, - uint32_t * InData_Text, - uint32_t * OutData_Text) -{ - return R_SCE_Rsa4096ModularExponentEncryptSub(InData_KeyIndex, InData_Text, OutData_Text); -} - -/*******************************************************************************************************************//** - * change endian - * - * @param data input data - * - * @return the data changing endian - **********************************************************************************************************************/ - -uint32_t change_endian_long (volatile uint32_t data) -{ - return ((((data) & 0xFF000000) >> 24) | (((data) & 0x00FF0000) >> 8) | (((data) & 0x0000FF00) << 8) | - (((data) & 0x000000FF) << 24)); -} \ No newline at end of file diff --git a/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce.c b/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce.c deleted file mode 100644 index c9f3f9308..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce.c +++ /dev/null @@ -1,1447 +0,0 @@ -/********************************************************************************************************************** - * DISCLAIMER - * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No - * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all - * applicable laws, including copyright laws. - * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING - * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM - * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES - * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO - * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of - * this software. By using this software, you agree to the additional terms and conditions found by accessing the - * following link: - * http://www.renesas.com/disclaimer - * - * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. - *********************************************************************************************************************/ -/********************************************************************************************************************** - * File Name : r_sce.c - * Version : 1.0 - * Description : SCE Common Public API source file - *********************************************************************************************************************/ -/********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release - *********************************************************************************************************************/ - - -/*********************************************************************************************************************** - * Includes - **********************************************************************************************************************/ -#include -#include "r_sce_private.h" - -/*********************************************************************************************************************** - * Macro definitions - **********************************************************************************************************************/ -#define HW_STATE_UNAVAILABLE (1) -#define HW_STATE_AVAILABLE (2) - -/* 5*(key_length/2)*2 is recommended by NIST FIPS186-4 */ -#define SCE_RSA_RETRY_COUNT_FOR_RSA1024_KEY_GENERATION (5*(1024/2)*2) -#define SCE_RSA_RETRY_COUNT_FOR_RSA2048_KEY_GENERATION (5*(2048/2)*2) - - -/*********************************************************************************************************************** - * Typedef definitions - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private function prototypes - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private global variables - **********************************************************************************************************************/ -static lifecycle_t gs_lifecycle; - -/********************************************************************************************************************** - Global variables - *********************************************************************************************************************/ -uint32_t S_RAM[HW_SCE_SRAM_WORD_SIZE]; -uint32_t S_HEAP[HW_SCE_SHEAP_WORD_SIZE]; -uint32_t S_INST2[HW_SCE_SINST2_WORD_SIZE]; - -uint32_t g_private_id_counter; -extern uint32_t g_aes128ecbenc_private_id; -extern uint32_t g_aes128ecbdec_private_id; -extern uint32_t g_aes256ecbenc_private_id; -extern uint32_t g_aes256ecbdec_private_id; -extern uint32_t g_aes128cbcenc_private_id; -extern uint32_t g_aes128cbcdec_private_id; -extern uint32_t g_aes256cbcenc_private_id; -extern uint32_t g_aes256cbcdec_private_id; -extern uint32_t g_aes128ctrenc_private_id; -extern uint32_t g_aes128ctrdec_private_id; -extern uint32_t g_aes256ctrenc_private_id; -extern uint32_t g_aes256ctrdec_private_id; -extern uint32_t g_aes128cmacgen_private_id; -extern uint32_t g_aes128cmacver_private_id; -extern uint32_t g_aes256cmacgen_private_id; -extern uint32_t g_aes256cmacver_private_id; -extern uint32_t g_sha224_private_id; -extern uint32_t g_sha256_private_id; - -const sce_api_t g_sce_protected_on_sce = -{ - .open = R_SCE_Open, - .close = R_SCE_Close, - .softwareReset = R_SCE_SoftwareReset, - .randomNumberGenerate = R_SCE_RandomNumberGenerate, - .AES128_WrappedKeyGenerate = R_SCE_AES128_WrappedKeyGenerate, - .AES256_WrappedKeyGenerate = R_SCE_AES256_WrappedKeyGenerate, - .AES128_EncryptedKeyWrap = R_SCE_AES128_EncryptedKeyWrap, - .AES256_EncryptedKeyWrap = R_SCE_AES256_EncryptedKeyWrap, - .AES128ECB_EncryptInit = R_SCE_AES128ECB_EncryptInit, - .AES128ECB_EncryptUpdate = R_SCE_AES128ECB_EncryptUpdate, - .AES128ECB_EncryptFinal = R_SCE_AES128ECB_EncryptFinal, - .AES128ECB_DecryptInit = R_SCE_AES128ECB_DecryptInit, - .AES128ECB_DecryptUpdate = R_SCE_AES128ECB_DecryptUpdate, - .AES128ECB_DecryptFinal = R_SCE_AES128ECB_DecryptFinal, - .AES256ECB_EncryptInit = R_SCE_AES256ECB_EncryptInit, - .AES256ECB_EncryptUpdate = R_SCE_AES256ECB_EncryptUpdate, - .AES256ECB_EncryptFinal = R_SCE_AES256ECB_EncryptFinal, - .AES256ECB_DecryptInit = R_SCE_AES256ECB_DecryptInit, - .AES256ECB_DecryptUpdate = R_SCE_AES256ECB_DecryptUpdate, - .AES256ECB_DecryptFinal = R_SCE_AES256ECB_DecryptFinal, - .AES128CBC_EncryptInit = R_SCE_AES128CBC_EncryptInit, - .AES128CBC_EncryptUpdate = R_SCE_AES128CBC_EncryptUpdate, - .AES128CBC_EncryptFinal = R_SCE_AES128CBC_EncryptFinal, - .AES128CBC_DecryptInit = R_SCE_AES128CBC_DecryptInit, - .AES128CBC_DecryptUpdate = R_SCE_AES128CBC_DecryptUpdate, - .AES128CBC_DecryptFinal = R_SCE_AES128CBC_DecryptFinal, - .AES256CBC_EncryptInit = R_SCE_AES256CBC_EncryptInit, - .AES256CBC_EncryptUpdate = R_SCE_AES256CBC_EncryptUpdate, - .AES256CBC_EncryptFinal = R_SCE_AES256CBC_EncryptFinal, - .AES256CBC_DecryptInit = R_SCE_AES256CBC_DecryptInit, - .AES256CBC_DecryptUpdate = R_SCE_AES256CBC_DecryptUpdate, - .AES256CBC_DecryptFinal = R_SCE_AES256CBC_DecryptFinal, - .AES128CTR_EncryptInit = R_SCE_AES128CTR_EncryptInit, - .AES128CTR_EncryptUpdate = R_SCE_AES128CTR_EncryptUpdate, - .AES128CTR_EncryptFinal = R_SCE_AES128CTR_EncryptFinal, - .AES128CTR_DecryptInit = R_SCE_AES128CTR_DecryptInit, - .AES128CTR_DecryptUpdate = R_SCE_AES128CTR_DecryptUpdate, - .AES128CTR_DecryptFinal = R_SCE_AES128CTR_DecryptFinal, - .AES256CTR_EncryptInit = R_SCE_AES256CTR_EncryptInit, - .AES256CTR_EncryptUpdate = R_SCE_AES256CTR_EncryptUpdate, - .AES256CTR_EncryptFinal = R_SCE_AES256CTR_EncryptFinal, - .AES256CTR_DecryptInit = R_SCE_AES256CTR_DecryptInit, - .AES256CTR_DecryptUpdate = R_SCE_AES256CTR_DecryptUpdate, - .AES256CTR_DecryptFinal = R_SCE_AES256CTR_DecryptFinal, - .AES128CMAC_GenerateInit = R_SCE_AES128CMAC_GenerateInit, - .AES128CMAC_GenerateUpdate = R_SCE_AES128CMAC_GenerateUpdate, - .AES128CMAC_GenerateFinal = R_SCE_AES128CMAC_GenerateFinal, - .AES128CMAC_VerifyInit = R_SCE_AES128CMAC_VerifyInit, - .AES128CMAC_VerifyUpdate = R_SCE_AES128CMAC_VerifyUpdate, - .AES128CMAC_VerifyFinal = R_SCE_AES128CMAC_VerifyFinal, - .AES256CMAC_GenerateInit = R_SCE_AES256CMAC_GenerateInit, - .AES256CMAC_GenerateUpdate = R_SCE_AES256CMAC_GenerateUpdate, - .AES256CMAC_GenerateFinal = R_SCE_AES256CMAC_GenerateFinal, - .AES256CMAC_VerifyInit = R_SCE_AES256CMAC_VerifyInit, - .AES256CMAC_VerifyUpdate = R_SCE_AES256CMAC_VerifyUpdate, - .AES256CMAC_VerifyFinal = R_SCE_AES256CMAC_VerifyFinal, - .SHA224_Init = R_SCE_SHA224_Init, - .SHA224_Update = R_SCE_SHA224_Update, - .SHA224_Final = R_SCE_SHA224_Final, - .SHA256_Init = R_SCE_SHA256_Init, - .SHA256_Update = R_SCE_SHA256_Update, - .SHA256_Final = R_SCE_SHA256_Final, - .RSA1024_WrappedKeyPairGenerate = R_SCE_RSA1024_WrappedKeyPairGenerate, - .RSA2048_WrappedKeyPairGenerate = R_SCE_RSA2048_WrappedKeyPairGenerate, - .RSA1024_EncryptedPublicKeyWrap = R_SCE_RSA1024_EncryptedPublicKeyWrap, - .RSA1024_EncryptedPrivateKeyWrap = R_SCE_RSA1024_EncryptedPrivateKeyWrap, - .RSA2048_EncryptedPublicKeyWrap = R_SCE_RSA2048_EncryptedPublicKeyWrap, - .RSA2048_EncryptedPrivateKeyWrap = R_SCE_RSA2048_EncryptedPrivateKeyWrap, - .RSA4096_EncryptedPublicKeyWrap = R_SCE_RSA4096_EncryptedPublicKeyWrap, - .RSASSA_PKCS1024_SignatureGenerate = R_SCE_RSASSA_PKCS1024_SignatureGenerate, - .RSASSA_PKCS2048_SignatureGenerate = R_SCE_RSASSA_PKCS2048_SignatureGenerate, - .RSASSA_PKCS1024_SignatureVerify = R_SCE_RSASSA_PKCS1024_SignatureVerify, - .RSASSA_PKCS2048_SignatureVerify = R_SCE_RSASSA_PKCS2048_SignatureVerify, - .RSASSA_PKCS4096_SignatureVerify = R_SCE_RSASSA_PKCS4096_SignatureVerify, - .RSAES_PKCS1024_Encrypt = R_SCE_RSAES_PKCS1024_Encrypt, - .RSAES_PKCS2048_Encrypt = R_SCE_RSAES_PKCS2048_Encrypt, - .RSAES_PKCS4096_Encrypt = R_SCE_RSAES_PKCS4096_Encrypt, - .RSAES_PKCS1024_Decrypt = R_SCE_RSAES_PKCS1024_Decrypt, - .RSAES_PKCS2048_Decrypt = R_SCE_RSAES_PKCS2048_Decrypt, - .ECC_secp192r1_WrappedKeyPairGenerate = R_SCE_ECC_secp192r1_WrappedKeyPairGenerate, - .ECC_secp224r1_WrappedKeyPairGenerate = R_SCE_ECC_secp224r1_WrappedKeyPairGenerate, - .ECC_secp256r1_WrappedKeyPairGenerate = R_SCE_ECC_secp256r1_WrappedKeyPairGenerate, - .ECC_BrainpoolP512r1_WrappedKeyPairGenerate = R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate, - .ECC_secp192r1_EncryptedPublicKeyWrap = R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap, - .ECC_secp224r1_EncryptedPublicKeyWrap = R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap, - .ECC_secp256r1_EncryptedPublicKeyWrap = R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap, - .ECC_BrainpoolP512r1_EncryptedPublicKeyWrap = R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap, - .ECC_secp192r1_EncryptedPrivateKeyWrap = R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap, - .ECC_secp224r1_EncryptedPrivateKeyWrap = R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap, - .ECC_secp256r1_EncryptedPrivateKeyWrap = R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap, - .ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap = R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap, - .ECDSA_secp192r1_SignatureGenerate = R_SCE_ECDSA_secp192r1_SignatureGenerate, - .ECDSA_secp224r1_SignatureGenerate = R_SCE_ECDSA_secp224r1_SignatureGenerate, - .ECDSA_secp256r1_SignatureGenerate = R_SCE_ECDSA_secp256r1_SignatureGenerate, - .ECDSA_BrainpoolP512r1_SignatureGenerate = R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate, - .ECDSA_secp192r1_SignatureVerify = R_SCE_ECDSA_secp192r1_SignatureVerify, - .ECDSA_secp224r1_SignatureVerify = R_SCE_ECDSA_secp224r1_SignatureVerify, - .ECDSA_secp256r1_SignatureVerify = R_SCE_ECDSA_secp256r1_SignatureVerify, - .ECDSA_BrainpoolP512r1_SignatureVerify = R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify, -}; - -/*******************************************************************************************************************//** - * @addtogroup SCE_PROTECTED - * @{ - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Functions - **********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * Enables use of SCE functionality. - * - * @param[in] p_ctrl Pointer to control structure. - * @param[in] p_cfg Pointer to pin configuration structure. - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL The error-detection self-test failed to terminate normally. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_RETRY Indicates that an entropy evaluation failure occurred. - * Run the function again. - * - * @return See @ref RENESAS_ERROR_CODES or functions called by this function for other possible return codes. - * - * @note The valid pre-run state is SCE disabled. - * The pre-run state is SCE Disabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Open (sce_ctrl_t * const p_ctrl, sce_cfg_t const * const p_cfg) -{ - fsp_err_t error_code = FSP_SUCCESS; - uint32_t state; - - sce_instance_ctrl_t * p_instance_ctrl = (sce_instance_ctrl_t *) p_ctrl; - p_instance_ctrl->open = 1; - gs_lifecycle = p_cfg->lifecycle; - - /* Check for need to do self-test */ - error_code = R_SCE_StateCheckSub(&state); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - if (HW_STATE_UNAVAILABLE == state) - { - error_code = R_SCE_SelfCheck2Private(); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - } - - g_private_id_counter = 0; - g_aes128ecbenc_private_id = 0; - g_aes128ecbdec_private_id = 0; - g_aes256ecbenc_private_id = 0; - g_aes256ecbdec_private_id = 0; - g_aes128cbcenc_private_id = 0; - g_aes128cbcdec_private_id = 0; - g_aes256cbcenc_private_id = 0; - g_aes256cbcdec_private_id = 0; - g_aes128ctrenc_private_id = 0; - g_aes128ctrdec_private_id = 0; - g_aes256ctrenc_private_id = 0; - g_aes256ctrdec_private_id = 0; - g_aes128cmacgen_private_id = 0; - g_aes128cmacver_private_id = 0; - g_aes256cmacgen_private_id = 0; - g_aes256cmacver_private_id = 0; - g_sha224_private_id = 0; - g_sha256_private_id = 0; - - return error_code; -} - -/*******************************************************************************************************************//** - * Stops supply of power to the SCE. - * - * @param[in] p_ctrl Pointer to control structure. - * - * @retval FSP_SUCCESS Normal termination - * - * @note The pre-run state is any state. - * After the function runs the state transitions to SCE Disabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_Close (sce_ctrl_t * const p_ctrl) -{ - sce_instance_ctrl_t * p_instance_ctrl = (sce_instance_ctrl_t *) p_ctrl; - p_instance_ctrl->open = 0; - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Software reset to SCE. - * - * Reverts the state to the SCE initial state. - * - * @retval FSP_SUCCESS Normal termination - * - * @note The pre-run state is any state. - * After the function runs the state transitions to SCE Disabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_SoftwareReset (void) -{ - R_SCE_SoftwareResetSub(); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * This API can generate 4 words random number. - * - * @param[in,out] random Stores 4words (16 bytes) random data. - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RandomNumberGenerate (uint32_t * random) -{ - return R_SCE_GenerateRandomNumberSub(random); -} - -/*******************************************************************************************************************//** - * This API outputs 128-bit AES wrapped key from a random number. - * - * This API generates a wrapped key from a random number in the SCE. Accordingly, user key input is unnecessary. - * By encrypting data using the wrapped key is output by this API, dead copying of data can be prevented. - * - * @param[in,out] wrapped_key 128-bit AES wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Disabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128_WrappedKeyGenerate (sce_aes_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - error_code = R_SCE_GenerateAes128RandomKeyIndexSub(wrapped_key->value); - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_AES128; - } - else if (FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - else - { - /* not used */ - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API outputs 256-bit AES wrapped key from a random number. - * - * This API generates a wrapped key from a random number in the SCE. Accordingly, user key input is unnecessary. - * By encrypting data using the wrapped key is output by this API, dead copying of data can be prevented. - * - * @param[in,out] wrapped_key 256-bit AES wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Disabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256_WrappedKeyGenerate (sce_aes_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - error_code = R_SCE_GenerateAes256RandomKeyIndexSub(wrapped_key->value); - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_AES256; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps 128-bit AES key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 128-bit AES wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128_EncryptedKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_aes_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_AES128; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_AES128; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps 256-bit AES key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 256-bit AES wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256_EncryptedKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_aes_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_AES256; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_AES256; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API outputs a wrapped key pair for a 1024-bit RSA public key and private key pair. These keys are generated - * from a random value produced internally by the SCE. Consequently, there is no need to input a user key. - * Dead copying of data can be prevented by encrypting the data using the wrapped key output by this API. - * A public wrapped key is generated by wrapped_pair_key->pub_key, and a private wrapped key is generated by - * wrapped_pair_key->priv_key. As the public key exponent, only 0x00010001 is generated. - * - * @param [in,out] wrapped_pair_key User key index for RSA 1024-bit public key and private key pair - * - * @retval FSP_SUCCESS Normal end - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. Key generation failed. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSA1024_WrappedKeyPairGenerate (sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - error_code = R_SCE_GenerateRsa1024RandomKeyIndexSub(SCE_RSA_RETRY_COUNT_FOR_RSA1024_KEY_GENERATION, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_pair_key->pub_key.value, - (uint32_t *) &wrapped_pair_key->priv_key.value); - if (FSP_SUCCESS == error_code) - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE; - } - else - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API outputs a wrapped key pair for a 2048-bit RSA public key and private key pair. These keys are generated - * from a random value produced internally by the SCE. Consequently, there is no need to input a user key. - * Dead copying of data can be prevented by encrypting the data using the wrapped key output by this API. - * A public wrapped key is generated by wrapped_pair_key->pub_key, and a private wrapped key is generated by - * wrapped_pair_key->priv_key. As the public key exponent, only 0x00010001 is generated. - * - * @param [in,out] wrapped_pair_key User key index for RSA 2048-bit public key and private key pair - * - * @retval FSP_SUCCESS Normal end - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. Key generation failed. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSA2048_WrappedKeyPairGenerate (sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - error_code = R_SCE_GenerateRsa2048RandomKeyIndexSub(SCE_RSA_RETRY_COUNT_FOR_RSA2048_KEY_GENERATION, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_pair_key->pub_key.value, - (uint32_t *) &wrapped_pair_key->priv_key.value); - if (FSP_SUCCESS == error_code) - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE; - } - else - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps 1024-bit RSA public key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 1024-bit RSA public wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSA1024_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_public_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA1024_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA1024_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps 1024-bit RSA private key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 1024-bit RSA private wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSA1024_EncryptedPrivateKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa1024_private_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA1024_PRIVATE; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA1024_PRIVATE; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps 2048-bit RSA public key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 1024-bit RSA public wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSA2048_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_public_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA2048_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA2048_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps 2048-bit RSA private key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 2048-bit RSA private wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSA2048_EncryptedPrivateKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa2048_private_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA2048_PRIVATE; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA2048_PRIVATE; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps 4096-bit RSA public key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key 1024-bit RSA public wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSA4096_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_rsa4096_public_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_RSA4096_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_RSA4096_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This is an API for outputting a wrapped key pair for secp192r1 public key and private key pair. - * These keys are generated from a random number value internally within the SCE. - * There is therefore no need to input user keys. It is possible to prevent dead copying of data by using the - * wrapped key output by this API to encrypt the data. The public key index is generated in wrapped_pair_key->pub_key, - * and the private key index is generated in wrapped_pair_key->priv_key. - * - * @param[in,out] wrapped_pair_key Wrapped pair key for secp192r1 public key and private key pair - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp192r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * wrapped_pair_key) -{ - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_GenerateEccRandomKeyIndexSub(&curvetype, - /* Casting uint32_t pointer is used for address. */ - &indata_cmd, - (uint32_t *) &wrapped_pair_key->pub_key.value, - (uint32_t *) &wrapped_pair_key->priv_key.value); - if (FSP_SUCCESS == error_code) - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE; - } - else - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This is an API for outputting a wrapped key pair for secp224r1 public key and private key pair. - * These keys are generated from a random number value internally within the SCE. - * There is therefore no need to input user keys. It is possible to prevent dead copying of data by using the - * wrapped key output by this API to encrypt the data. The public key index is generated in wrapped_pair_key->pub_key, - * and the private key index is generated in wrapped_pair_key->priv_key. - * - * @param[in,out] wrapped_pair_key Wrapped pair key for secp224r1 public key and private key pair - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp224r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * wrapped_pair_key) -{ - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_GenerateEccRandomKeyIndexSub(&curvetype, - /* Casting uint32_t pointer is used for address. */ - &indata_cmd, - (uint32_t *) &wrapped_pair_key->pub_key.value, - (uint32_t *) &wrapped_pair_key->priv_key.value); - if (FSP_SUCCESS == error_code) - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE; - } - else - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This is an API for outputting a wrapped key pair for secp256r1 public key and private key pair. - * These keys are generated from a random number value internally within the SCE. - * There is therefore no need to input user keys. It is possible to prevent dead copying of data by using the - * wrapped key output by this API to encrypt the data. The public key index is generated in wrapped_pair_key->pub_key, - * and the private key index is generated in wrapped_pair_key->priv_key. - * - * @param[in,out] wrapped_pair_key Wrapped pair key for secp256r1 public key and private key pair - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp256r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * wrapped_pair_key) -{ - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_GenerateEccRandomKeyIndexSub(&curvetype, - /* Casting uint32_t pointer is used for address. */ - &indata_cmd, - (uint32_t *) &wrapped_pair_key->pub_key.value, - (uint32_t *) &wrapped_pair_key->priv_key.value); - if (FSP_SUCCESS == error_code) - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE; - } - else - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This is an API for outputting a wrapped key pair for BrainpoolP512r1 public key and private key pair. - * These keys are generated from a random number value internally within the SCE. - * There is therefore no need to input user keys. It is possible to prevent dead copying of data by using the - * wrapped key output by this API to encrypt the data. The public key index is generated in wrapped_pair_key->pub_key, - * and the private key index is generated in wrapped_pair_key->priv_key. - * - * @param[in,out] wrapped_pair_key Wrapped pair key for BrainpoolP512r1 public key and private key pair - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_BrainpoolP512r1_WrappedKeyPairGenerate (sce_ecc_wrapped_pair_key_t * wrapped_pair_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - - error_code = R_SCE_GenerateEccP512RandomKeyIndexSub( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_pair_key->pub_key.value, - (uint32_t *) &wrapped_pair_key->priv_key.value); - if (FSP_SUCCESS == error_code) - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE; - } - else - { - wrapped_pair_key->pub_key.type = SCE_KEY_INDEX_TYPE_INVALID; - wrapped_pair_key->priv_key.type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps secp192r1 public key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp192r1 public wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp192r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P192_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P192_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps secp224r1 public key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp224r1 public wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp224r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P224_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P224_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps secp256r1 public key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp256r1 public wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp256r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P256_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P256_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps BrainpoolP512r1 public key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key BrainpoolP512r1 public wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_public_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P512_PUBLIC; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P512_PUBLIC; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps secp192r1 private key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp192r1 private wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp192r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P192_PRIVATE; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P192_PRIVATE; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps secp224r1 private key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp224r1 private wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp224r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P224_PRIVATE; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P224_PRIVATE; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps secp256r1 private key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key secp256r1 private wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_secp256r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P256_PRIVATE; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P256_PRIVATE; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * This API wraps BrainpoolP512r1 private key within the user routine. - * - * @param[in] initial_vector Initialization vector when generating encrypted_key - * @param[in] encrypted_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key BrainpoolP512r1 private wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap (uint8_t * initial_vector, - uint8_t * encrypted_key, - sce_key_update_key_t * key_update_key, - sce_ecc_private_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - lifecycle_t lifecycle = gs_lifecycle; - sce_oem_cmd_t key_type = SCE_OEM_CMD_ECC_P512_PRIVATE; - - memcpy(S_INST2, key_update_key->value, (HW_SCE_SINST2_WORD_SIZE * 4)); - - error_code = R_SCE_UpdateOemKeyIndexPrivate(lifecycle, - key_type, - initial_vector, - encrypted_key, - (uint32_t *) &wrapped_key->value); - - if (FSP_SUCCESS == error_code) - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_ECC_P512_PRIVATE; - } - else - { - wrapped_key->type = SCE_KEY_INDEX_TYPE_INVALID; - } - - return error_code; -} - -/*******************************************************************************************************************//** - * @} (end addtogroup SCE_PROTECTED) - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private Functions - **********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * Self check No2 - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RETRY self-test2 fail - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - **********************************************************************************************************************/ -fsp_err_t R_SCE_SelfCheck2Private (void) -{ - return R_SCE_SelfCheck2Sub(); -} - -/*******************************************************************************************************************//** - * This API Updates OEM key index (wrapped key). - * - * @param[in] lifecycle (no use) - * @param[in] key_type User key type define in sce_oem_cmd_t - * @param[in] encrypted_oem_key User key encryptedand MAC appended - * @param[in] key_update_key Key update keyring - * @param[in,out] wrapped_key wrapped key - * - * @retval FSP_SUCCESS - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT - * @retval FSP_ERR_CRYPTO_SCE_FAIL - **********************************************************************************************************************/ -fsp_err_t R_SCE_UpdateOemKeyIndexPrivate (lifecycle_t lifecycle, - sce_oem_cmd_t key_type, - uint8_t * iv, - uint8_t * encrypted_oem_key, - uint32_t * key_index) -{ - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - - FSP_PARAMETER_NOT_USED(lifecycle); - - switch (key_type) - { - case SCE_OEM_CMD_AES128: - error_code = R_SCE_AES128_EncryptedKeyWrapSub((uint32_t *) iv, (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_AES256: - error_code = R_SCE_AES256_EncryptedKeyWrapSub((uint32_t *) iv, (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_RSA1024_PUBLIC: - error_code = R_SCE_RSA1024_EncryptedPublicKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_RSA1024_PRIVATE: - error_code = R_SCE_RSA1024_EncryptedPrivateKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_RSA2048_PUBLIC: - error_code = R_SCE_RSA2048_EncryptedPublicKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_RSA2048_PRIVATE: - error_code = R_SCE_RSA2048_EncryptedPrivateKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_RSA4096_PUBLIC: - error_code = R_SCE_RSA4096_EncryptedPublicKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_ECC_P192_PUBLIC: - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(&curvetype, - &indata_cmd, - (uint32_t *) iv, - (uint32_t *) encrypted_oem_key, - key_index); - break; - case SCE_OEM_CMD_ECC_P224_PUBLIC: - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(&curvetype, - &indata_cmd, - (uint32_t *) iv, - (uint32_t *) encrypted_oem_key, - key_index); - break; - case SCE_OEM_CMD_ECC_P256_PUBLIC: - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_ECC192224256_EncryptedPublicKeyWrapSub(&curvetype, - &indata_cmd, - (uint32_t *) iv, - (uint32_t *) encrypted_oem_key, - key_index); - break; - case SCE_OEM_CMD_ECC_P512_PUBLIC: - error_code = R_SCE_ECC_BrainpoolP512r1_EncryptedPublicKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - case SCE_OEM_CMD_ECC_P192_PRIVATE: - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(&curvetype, - &indata_cmd, - (uint32_t *) iv, - (uint32_t *) encrypted_oem_key, - key_index); - break; - case SCE_OEM_CMD_ECC_P224_PRIVATE: - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(&curvetype, - &indata_cmd, - (uint32_t *) iv, - (uint32_t *) encrypted_oem_key, - key_index); - break; - case SCE_OEM_CMD_ECC_P256_PRIVATE: - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_ECC192224256_EncryptedPrivateKeyWrapSub(&curvetype, - &indata_cmd, - (uint32_t *) iv, - (uint32_t *) encrypted_oem_key, - key_index); - break; - case SCE_OEM_CMD_ECC_P512_PRIVATE: - error_code = R_SCE_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrapSub((uint32_t *) iv, - (uint32_t *) encrypted_oem_key, key_index); - break; - default: - error_code = FSP_ERR_CRYPTO_SCE_FAIL; /* Not support Key type */ - break; - } - - return error_code; -} diff --git a/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_aes.c b/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_aes.c deleted file mode 100644 index f3ef3c836..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_aes.c +++ /dev/null @@ -1,2174 +0,0 @@ -/********************************************************************************************************************** - * DISCLAIMER - * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No - * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all - * applicable laws, including copyright laws. - * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING - * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM - * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES - * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO - * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of - * this software. By using this software, you agree to the additional terms and conditions found by accessing the - * following link: - * http://www.renesas.com/disclaimer - * - * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. - *********************************************************************************************************************/ -/********************************************************************************************************************** - * File Name : r_sce_aes.c - * Version : 1.0 - * Description : SCE AES Public API source file - *********************************************************************************************************************/ -/********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release - *********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Includes - **********************************************************************************************************************/ -#include -#include "r_sce_private.h" - -/*********************************************************************************************************************** - * Macro definitions - **********************************************************************************************************************/ - -/* Initialization function call state */ -#define CALL_ONLY_INIT (0) -#define CALL_ONLY_UPDATE_FINAL (1) - -/* Magic numbers */ -#ifndef SCE_HEX_E000000 -#define SCE_HEX_E000000 (0xe000000U) -#endif -#ifndef SCE_DEC_110 -#define SCE_DEC_110 (110) -#endif - -/*********************************************************************************************************************** - * Typedef definitions - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private function prototypes - **********************************************************************************************************************/ -static void cal_current_ivec_ctrmode(sce_aes_handle_t *handle , uint32_t block_num); - -/*********************************************************************************************************************** - * Private global variables - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Global variables - **********************************************************************************************************************/ -extern uint32_t g_private_id_counter; -uint32_t g_aes128ecbenc_private_id; -uint32_t g_aes128ecbdec_private_id; -uint32_t g_aes256ecbenc_private_id; -uint32_t g_aes256ecbdec_private_id; -uint32_t g_aes128cbcenc_private_id; -uint32_t g_aes128cbcdec_private_id; -uint32_t g_aes256cbcenc_private_id; -uint32_t g_aes256cbcdec_private_id; -uint32_t g_aes128ctrenc_private_id; -uint32_t g_aes128ctrdec_private_id; -uint32_t g_aes256ctrenc_private_id; -uint32_t g_aes256ctrdec_private_id; -uint32_t g_aes128cmacgen_private_id; -uint32_t g_aes128cmacver_private_id; -uint32_t g_aes256cmacgen_private_id; -uint32_t g_aes256cmacver_private_id; - -/*******************************************************************************************************************//** - * @addtogroup SCE_PROTECTED - * @{ - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Functions - **********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * The R_SCE_AES128ECB_EncryptInit() function performs preparations for the execution of an AES calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument - * in the subsequent R_SCE_AES128ECB_EncryptUpdate() function and R_SCE_AES128ECB_EncryptFinal() function. - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128ECB_EncryptInit (sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) -{ - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128ecbenc_private_id = g_private_id_counter; - handle->id = g_aes128ecbenc_private_id; - - return R_SCE_Aes128EcbEncryptInitPrivate(wrapped_key); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128ECB_EncryptUpdate() function encrypts the second argument, plain, utilizing the key index stored - * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. - * In addition, it writes the encryption result to the third argument, cipher. After plaintext input is completed, - * call R_SCE_AES128ECB_EncryptFinal(). - * - * Specify areas for plain and cipher that do not overlap. For plain and cipher, - * specify RAM addresses that are multiples of 4. - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128ECB_EncryptUpdate (sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128ecbenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - memcpy(handle->last_1_block_as_fraction, - (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - handle->current_input_data_size = plain_length; - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128EcbEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_AES128ECB_EncryptFinal() function writes - * the calculation result to the second argument, cipher, and writes the length of the calculation result - * to the third argument, cipher_length. The original intent was for a portion of the encryption - * result that was not a multiple of 16 bytes to be written to the second argument. - * However, as a result of the restriction that only multiples of 16 can be input to the Update function, - * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length - * are provided for compatibility in anticipation of the time when this restriction is lifted. - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128ECB_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128ecbenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *cipher_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128EcbEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128ECB_DecryptInit() function performs preparations for the execution of an AES calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument - * in the subsequent R_SCE_AES128ECB_DecryptUpdate() function and R_SCE_AES128ECB_DecryptFinal() function. - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128ECB_DecryptInit (sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) -{ - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128ecbdec_private_id = g_private_id_counter; - handle->id = g_aes128ecbdec_private_id; - - return R_SCE_Aes128EcbDecryptInitPrivate(wrapped_key); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128ECB_DecryptUpdate() function decrypts the second argument, cipher, utilizing the key index stored - * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. - * In addition, it writes the decryption result to the third argument, plain. After plaintext input is completed, - * call R_SCE_AES128ECB_DecryptFinal(). - * - * Specify areas for plain and cipher that do not overlap. For plain and cipher, - * specify RAM addresses that are multiples of 4. - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128ECB_DecryptUpdate (sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128ecbdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = cipher_length; - memcpy(handle->last_1_block_as_fraction, - (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128EcbDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_AES128ECB_DecryptFinal() function writes - * the calculation result to the second argument, plain, and writes the length of the calculation result - * to the third argument, plain_length. The original intent was for a portion of the decryption - * result that was not a multiple of 16 bytes to be written to the second argument. - * However, as a result of the restriction that only multiples of 16 can be input to the Update function, - * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length - * are provided for compatibility in anticipation of the time when this restriction is lifted. - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128ECB_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128ecbdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *plain_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128EcbDecryptFinalPrivate((uint32_t *) (plain), plain_length); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256ECB_EncryptInit() function performs preparations for the execution of an AES calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument - * in the subsequent R_SCE_AES256ECB_EncryptUpdate() function and R_SCE_AES256ECB_EncryptFinal() function. - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256ECB_EncryptInit (sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) -{ - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256ecbenc_private_id = g_private_id_counter; - handle->id = g_aes256ecbenc_private_id; - - return R_SCE_Aes256EcbEncryptInitPrivate(wrapped_key); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256ECB_EncryptUpdate() function encrypts the second argument, plain, utilizing the key index stored - * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. - * In addition, it writes the encryption result to the third argument, cipher. After plaintext input is completed, - * call R_SCE_AES256ECB_EncryptFinal(). - * - * Specify areas for plain and cipher that do not overlap. For plain and cipher, - * specify RAM addresses that are multiples of 4. - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256ECB_EncryptUpdate (sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256ecbenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = plain_length; - memcpy(handle->last_1_block_as_fraction, - (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256EcbEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_AES256ECB_EncryptFinal() function writes - * the calculation result to the second argument, cipher, and writes the length of the calculation result - * to the third argument, cipher_length. The original intent was for a portion of the encryption - * result that was not a multiple of 16 bytes to be written to the second argument. - * However, as a result of the restriction that only multiples of 16 can be input to the Update function, - * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length - * are provided for compatibility in anticipation of the time when this restriction is lifted. - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256ECB_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256ecbenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *cipher_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256EcbEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256ECB_DecryptInit() function performs preparations for the execution of an AES calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument - * in the subsequent R_SCE_AES128ECB_DecryptUpdate() function and R_SCE_AES128ECB_DecryptFinal() function. - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256ECB_DecryptInit (sce_aes_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) -{ - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256ecbdec_private_id = g_private_id_counter; - handle->id = g_aes256ecbdec_private_id; - return R_SCE_Aes256EcbDecryptInitPrivate(wrapped_key); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256ECB_DecryptUpdate() function decrypts the second argument, cipher, utilizing the key index stored - * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. - * In addition, it writes the decryption result to the third argument, plain. After plaintext input is completed, - * call R_SCE_AES256ECB_DecryptFinal(). - * - * Specify areas for plain and cipher that do not overlap. For plain and cipher, - * specify RAM addresses that are multiples of 4. - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256ECB_DecryptUpdate (sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256ecbdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = cipher_length; - memcpy(handle->last_1_block_as_fraction, - (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256EcbDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_AES256ECB_DecryptFinal() function writes - * the calculation result to the second argument, plain, and writes the length of the calculation result - * to the third argument, plain_length. The original intent was for a portion of the decryption - * result that was not a multiple of 16 bytes to be written to the second argument. - * However, as a result of the restriction that only multiples of 16 can be input to the Update function, - * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length - * are provided for compatibility in anticipation of the time when this restriction is lifted. - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256ECB_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256ecbdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *plain_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256EcbDecryptFinalPrivate((uint32_t *) (plain), plain_length); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CBC_EncryptInit() function performs preparations for the execution of an AES calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument - * in the subsequent R_SCE_AES128CBC_EncryptUpdate() function and R_SCE_AES128CBC_EncryptFinal() function. - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initialization vector area (16byte) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CBC_EncryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) -{ - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128cbcenc_private_id = g_private_id_counter; - handle->id = g_aes128cbcenc_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CbcEncryptInitPrivate(wrapped_key, (uint32_t *) (initial_vector)); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CBC_EncryptUpdate() function encrypts the second argument, plain, utilizing the key index stored - * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. - * In addition, it writes the encryption result to the third argument, cipher. After plaintext input is completed, - * call R_SCE_AES128CBC_EncryptFinal(). - * - * Specify areas for plain and cipher that do not overlap. For plain and cipher, - * specify RAM addresses that are multiples of 4. - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CBC_EncryptUpdate (sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128cbcenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = plain_length; - memcpy(handle->last_1_block_as_fraction, - (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes128CbcEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); - memcpy(handle->current_initial_vector, - (cipher + (plain_length - HW_SCE_AES_BLOCK_BYTE_SIZE)), - HW_SCE_AES_CBC_IV_BYTE_SIZE); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_AES128CBC_EncryptFinal() function writes - * the calculation result to the second argument, cipher, and writes the length of the calculation result - * to the third argument, cipher_length. The original intent was for a portion of the encryption - * result that was not a multiple of 16 bytes to be written to the second argument. - * However, as a result of the restriction that only multiples of 16 can be input to the Update function, - * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length - * are provided for compatibility in anticipation of the time when this restriction is lifted. - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CBC_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128cbcenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *cipher_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CbcEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CBC_DecryptInit() function performs preparations for the execution of an AES calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument - * in the subsequent R_SCE_AES128CBC_DecryptUpdate() function and R_SCE_AES128CBC_DecryptFinal() function. - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initialization vector area (16byte) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CBC_DecryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) -{ - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128cbcdec_private_id = g_private_id_counter; - handle->id = g_aes128cbcdec_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CbcDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CBC_DecryptUpdate() function decrypts the second argument, cipher, utilizing the key index stored - * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. - * In addition, it writes the decryption result to the third argument, plain. After plaintext input is completed, - * call R_SCE_AES128CBC_DecryptFinal(). - * - * Specify areas for plain and cipher that do not overlap. For plain and cipher, - * specify RAM addresses that are multiples of 4. - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CBC_DecryptUpdate (sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128cbcdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = cipher_length; - memcpy(handle->last_1_block_as_fraction, - (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes128CbcDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); - memcpy(handle->current_initial_vector, - (plain + (cipher_length - HW_SCE_AES_BLOCK_BYTE_SIZE)), - HW_SCE_AES_CBC_IV_BYTE_SIZE); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_AES128CBC_DecryptFinal() function writes - * the calculation result to the second argument, plain, and writes the length of the calculation result - * to the third argument, plain_length. The original intent was for a portion of the decryption - * result that was not a multiple of 16 bytes to be written to the second argument. - * However, as a result of the restriction that only multiples of 16 can be input to the Update function, - * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length - * are provided for compatibility in anticipation of the time when this restriction is lifted. - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CBC_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128cbcdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *plain_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CbcDecryptFinalPrivate((uint32_t *) (plain), plain_length); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CBC_EncryptInit() function performs preparations for the execution of an AES calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument - * in the subsequent R_SCE_AES256CBC_EncryptUpdate() function and R_SCE_AES256CBC_EncryptFinal() function. - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CBC_EncryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) -{ - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256cbcenc_private_id = g_private_id_counter; - handle->id = g_aes256cbcenc_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CbcEncryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CBC_EncryptUpdate() function encrypts the second argument, plain, utilizing the key index stored - * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. - * In addition, it writes the encryption result to the third argument, cipher. After plaintext input is completed, - * call R_SCE_AES256CBC_EncryptFinal(). - * - * Specify areas for plain and cipher that do not overlap. For plain and cipher, - * specify RAM addresses that are multiples of 4. - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CBC_EncryptUpdate (sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256cbcenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = plain_length; - memcpy(handle->last_1_block_as_fraction, - (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes256CbcEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); - memcpy(handle->current_initial_vector, - cipher + (plain_length - HW_SCE_AES_BLOCK_BYTE_SIZE), - HW_SCE_AES_CBC_IV_BYTE_SIZE); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_AES256CBC_EncryptFinal() function writes - * the calculation result to the second argument, cipher, and writes the length of the calculation result - * to the third argument, cipher_length. The original intent was for a portion of the encryption - * result that was not a multiple of 16 bytes to be written to the second argument. - * However, as a result of the restriction that only multiples of 16 can be input to the Update function, - * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length - * are provided for compatibility in anticipation of the time when this restriction is lifted. - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CBC_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256cbcenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *cipher_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CbcEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CBC_DecryptInit() function performs preparations for the execution of an AES calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument - * in the subsequent R_SCE_AES256CBC_DecryptUpdate() function and R_SCE_AES256CBC_DecryptFinal() function. - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initialization vector area (16byte) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CBC_DecryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) -{ - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256cbcdec_private_id = g_private_id_counter; - handle->id = g_aes256cbcdec_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CbcDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CBC_DecryptUpdate() function decrypts the second argument, cipher, utilizing the key index stored - * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. - * In addition, it writes the decryption result to the third argument, plain. After plaintext input is completed, - * call R_SCE_AES256CBC_DecryptFinal(). - * - * Specify areas for plain and cipher that do not overlap. For plain and cipher, - * specify RAM addresses that are multiples of 4. - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CBC_DecryptUpdate (sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256cbcdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = cipher_length; - memcpy(handle->last_1_block_as_fraction, - (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes256CbcDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); - memcpy(handle->current_initial_vector, - plain + (cipher_length - HW_SCE_AES_BLOCK_BYTE_SIZE), - HW_SCE_AES_CBC_IV_BYTE_SIZE); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_AES256CBC_DecryptFinal() function writes - * the calculation result to the second argument, plain, and writes the length of the calculation result - * to the third argument, plain_length. The original intent was for a portion of the decryption - * result that was not a multiple of 16 bytes to be written to the second argument. - * However, as a result of the restriction that only multiples of 16 can be input to the Update function, - * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length - * are provided for compatibility in anticipation of the time when this restriction is lifted. - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CBC_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256cbcdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *plain_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CbcDecryptFinalPrivate((uint32_t *) (plain), plain_length); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CTR_EncryptInit() function performs preparations for the execution of an AES calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument - * in the subsequent R_SCE_AES128CTR_EncryptUpdate() function and R_SCE_AES128CTR_EncryptFinal() function. - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initialization vector area (16byte) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CTR_EncryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) -{ - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128ctrenc_private_id = g_private_id_counter; - handle->id = g_aes128ctrenc_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CtrEncryptInitPrivate(wrapped_key, (uint32_t *) (initial_vector)); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CTR_EncryptUpdate() function encrypts the second argument, plain, utilizing the key index stored - * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. - * In addition, it writes the encryption result to the third argument, cipher. After plaintext input is completed, - * call R_SCE_AES128CTR_EncryptFinal(). - * - * Specify areas for plain and cipher that do not overlap. For plain and cipher, - * specify RAM addresses that are multiples of 4. - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CTR_EncryptUpdate (sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length) -{ - uint32_t block_num = (plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE); - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128ctrenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = plain_length; - memcpy(handle->last_1_block_as_fraction, - (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes128CtrEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); - cal_current_ivec_ctrmode(handle, block_num); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_AES128CTR_EncryptFinal() function writes - * the calculation result to the second argument, cipher, and writes the length of the calculation result - * to the third argument, cipher_length. The original intent was for a portion of the encryption - * result that was not a multiple of 16 bytes to be written to the second argument. - * However, as a result of the restriction that only multiples of 16 can be input to the Update function, - * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length - * are provided for compatibility in anticipation of the time when this restriction is lifted. - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CTR_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128ctrenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *cipher_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CtrEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CTR_DecryptInit() function performs preparations for the execution of an AES calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument - * in the subsequent R_SCE_AES128CTR_DecryptUpdate() function and R_SCE_AES128CTR_DecryptFinal() function. - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * @param[in] initial_vector initialization vector area (16byte) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CTR_DecryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) -{ - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128ctrdec_private_id = g_private_id_counter; - handle->id = g_aes128ctrdec_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CtrDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CTR_DecryptUpdate() function decrypts the second argument, cipher, utilizing the key index stored - * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. - * In addition, it writes the decryption result to the third argument, plain. After plaintext input is completed, - * call R_SCE_AES128CTR_DecryptFinal(). - * - * Specify areas for plain and cipher that do not overlap. For plain and cipher, - * specify RAM addresses that are multiples of 4. - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CTR_DecryptUpdate (sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length) -{ - uint32_t block_num = (cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE); - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128ctrdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = cipher_length; - memcpy(handle->last_1_block_as_fraction, - (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes128CtrDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); - cal_current_ivec_ctrmode(handle, block_num); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_AES128CTR_DecryptFinal() function writes - * the calculation result to the second argument, plain, and writes the length of the calculation result - * to the third argument, plain_length. The original intent was for a portion of the decryption - * result that was not a multiple of 16 bytes to be written to the second argument. - * However, as a result of the restriction that only multiples of 16 can be input to the Update function, - * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length - * are provided for compatibility in anticipation of the time when this restriction is lifted. - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CTR_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128ctrdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *plain_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes128CtrDecryptFinalPrivate((uint32_t *) (plain), plain_length); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CTR_EncryptInit() function performs preparations for the execution of an AES calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument - * in the subsequent R_SCE_AES256CTR_EncryptUpdate() function and R_SCE_AES256CTR_EncryptFinal() function. - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initial vector area (16byte) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CTR_EncryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) -{ - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256ctrenc_private_id = g_private_id_counter; - handle->id = g_aes256ctrenc_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CtrEncryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CTR_EncryptUpdate() function encrypts the second argument, plain, utilizing the key index stored - * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. - * In addition, it writes the encryption result to the third argument, cipher. After plaintext input is completed, - * call R_SCE_AES256CTR_EncryptFinal(). - * - * Specify areas for plain and cipher that do not overlap. For plain and cipher, - * specify RAM addresses that are multiples of 4. - * - * @param[in,out] handle AES handler (work area) - * @param[in] plain plaintext data area - * @param[in,out] cipher ciphertext data area - * @param[in,out] plain_length plaintext data length (must be a multiple of 16) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CTR_EncryptUpdate (sce_aes_handle_t * handle, - uint8_t * plain, - uint8_t * cipher, - uint32_t plain_length) -{ - uint32_t block_num = (plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE); - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256ctrenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = plain_length; - memcpy(handle->last_1_block_as_fraction, - (plain + ((plain_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes256CtrEncryptUpdatePrivate((uint32_t *) (plain), (uint32_t *) (cipher), plain_length >> 2); - cal_current_ivec_ctrmode(handle, block_num); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_AES256CTR_EncryptFinal() function writes - * the calculation result to the second argument, cipher, and writes the length of the calculation result - * to the third argument, cipher_length. The original intent was for a portion of the encryption - * result that was not a multiple of 16 bytes to be written to the second argument. - * However, as a result of the restriction that only multiples of 16 can be input to the Update function, - * nothing is ever written to cipher, and 0 is always written to cipher_length. The arguments cipher and cipher_length - * are provided for compatibility in anticipation of the time when this restriction is lifted. - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] cipher ciphertext data area (nothing ever written here) - * @param[in,out] cipher_length ciphertext data length (0 always written here) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CTR_EncryptFinal (sce_aes_handle_t * handle, uint8_t * cipher, uint32_t * cipher_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256ctrenc_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *cipher_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CtrEncryptFinalPrivate((uint32_t *) (cipher), cipher_length); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CTR_DecryptInit() function performs preparations for the execution of an AES calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument - * in the subsequent R_SCE_AES256CTR_DecryptUpdate() function and R_SCE_AES256CTR_DecryptFinal() function. - * - * @param[in,out] handle AES handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * @param[in] initial_vector initialization vector area (16byte) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Input illegal wrapped key. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CTR_DecryptInit (sce_aes_handle_t * handle, - sce_aes_wrapped_key_t * wrapped_key, - uint8_t * initial_vector) -{ - memset(handle, 0, sizeof(sce_aes_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256ctrdec_private_id = g_private_id_counter; - handle->id = g_aes256ctrdec_private_id; - memcpy(handle->current_initial_vector, initial_vector, sizeof(handle->current_initial_vector)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CtrDecryptInitPrivate(wrapped_key, (uint32_t *) (handle->current_initial_vector)); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CTR_DecryptUpdate() function decrypts the second argument, cipher, utilizing the key index stored - * in the handle specified in the first argument, handle, and writes the ongoing status to this first argument. - * In addition, it writes the decryption result to the third argument, plain. After plaintext input is completed, - * call R_SCE_AES256CTR_DecryptFinal(). - * - * Specify areas for plain and cipher that do not overlap. For plain and cipher, - * specify RAM addresses that are multiples of 4. - * - * @param[in,out] handle AES handler (work area) - * @param[in] cipher ciphertext data area - * @param[in,out] plain plaintext data area - * @param[in,out] cipher_length ciphertext data length (must be a multiple of 16) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CTR_DecryptUpdate (sce_aes_handle_t * handle, - uint8_t * cipher, - uint8_t * plain, - uint32_t cipher_length) -{ - uint32_t block_num = (cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE); - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256ctrdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->current_input_data_size = cipher_length; - memcpy(handle->last_1_block_as_fraction, - (cipher + ((cipher_length / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE)), - (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE)); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes256CtrDecryptUpdatePrivate((uint32_t *) (cipher), (uint32_t *) (plain), cipher_length >> 2); - cal_current_ivec_ctrmode(handle, block_num); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_AES256CTR_DecryptFinal() function writes - * the calculation result to the second argument, plain, and writes the length of the calculation result - * to the third argument, plain_length. The original intent was for a portion of the decryption - * result that was not a multiple of 16 bytes to be written to the second argument. - * However, as a result of the restriction that only multiples of 16 can be input to the Update function, - * nothing is ever written to plain, and 0 is always written to plain_length. The arguments plain and plain_length - * are provided for compatibility in anticipation of the time when this restriction is lifted. - * - * @param[in,out] handle AES handler (work area) - * @param[in,out] plain plaintext data area (nothing ever written here) - * @param[in,out] plain_length plaintext data length (0 always written here) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CTR_DecryptFinal (sce_aes_handle_t * handle, uint8_t * plain, uint32_t * plain_length) -{ - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256ctrdec_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - *plain_length = 0; - memset(handle, 0, sizeof(sce_aes_handle_t)); - - /* Casting uint32_t pointer is used for address. */ - return R_SCE_Aes256CtrDecryptFinalPrivate((uint32_t *) (plain), plain_length); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CMAC_GenerateInit() function performs preparations for the execution of an CMAC calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument in the subsequent - * R_SCE_AES128CMAC_GenerateUpdate() function and R_SCE_AES128CMAC_GenerateFinal() function. - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CMAC_GenerateInit (sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) -{ - memset(handle, 0, sizeof(sce_cmac_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128cmacgen_private_id = g_private_id_counter; - handle->id = g_aes128cmacgen_private_id; - memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES128_KEY_INDEX_WORD_SIZE * 4); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - - return R_SCE_Aes128CmacGenerateInitPrivate(wrapped_key); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CMAC_GenerateUpdate() function performs MAC value generation based on the message specified - * in the second argument, message, using the value specified for wrapped_key in R_SCE_AES128CMAC_GenerateInit(). - * Inside this function, the data that is input by the user is buffered until the input value of message - * exceeds 16 bytes. The length of the message data to input is specified in the third argument, message_len. - * For these, input not the total byte count for message input data, but rather the message data length - * to input when the user calls this function. If the input value, message, is not a multiple of 16 bytes, - * it will be padded within the function. For message, specify a RAM address that are multiples of 4. - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CMAC_GenerateUpdate (sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length) -{ - uint32_t length_rest = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128cmacgen_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->all_received_length += message_length; - if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), - message, - HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes128CmacGenerateUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); - length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - R_SCE_Aes128CmacGenerateUpdatePrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), - (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); - length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); - } - - handle->buffering_length = 0; - memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); - handle->buffering_length = length_rest; - } - else - { - memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); - handle->buffering_length += message_length; - } - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CMAC_GenerateFinal() function outputs the MAC value to the MAC data area specified - * in the second argument, mac, and ends CMAC mode. - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (16byte) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Not used. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CMAC_GenerateFinal (sce_cmac_handle_t * handle, uint8_t * mac) -{ - fsp_err_t ercd = FSP_SUCCESS; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128cmacgen_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) - { - handle->cmac_buffer[handle->buffering_length] = 1 << 7; - memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, - HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); - } - - ercd = R_SCE_Aes128CmacGenerateFinalPrivate(handle->all_received_length, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (handle->cmac_buffer), - (uint32_t *) (mac)); - memset(handle, 0, sizeof(sce_cmac_handle_t)); - - return ercd; -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CMAC_VerifyInit() function performs preparations for the execution of a CMAC calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argumentin the subsequent - * R_SCE_AES128CMAC_VerifyUpdate() function and R_SCE_AES128CMAC_VerifyFinal() function. - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 128-bit AES wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CMAC_VerifyInit (sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) -{ - memset(handle, 0, sizeof(sce_cmac_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes128cmacver_private_id = g_private_id_counter; - handle->id = g_aes128cmacver_private_id; - memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES128_KEY_INDEX_WORD_SIZE * 4); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - - return R_SCE_Aes128CmacVerifyInitPrivate(wrapped_key); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CMAC_VerifyUpdate() function performs MAC value generation based on the message specified - * in the second argument, message, using the value specified for wrapped_key in R_SCE_AES128CMAC_VerifyInit(). - * Inside this function, the data that is input by the user is buffered until the input value of message - * exceeds 16 bytes. The length of the message data to input is specified in the third argument, message_len. - * For these, input not the total byte count for message input data, but rather the message data length to input - * when the user calls this function. If the input value, message, is not a multiple of 16 bytes, - * it will be padded within the function. For message, specify a RAM address that are multiples of 4. - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CMAC_VerifyUpdate (sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length) -{ - uint32_t length_rest = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes128cmacver_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->all_received_length += message_length; - if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), - message, - HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes128CmacVerifyUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); - length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - R_SCE_Aes128CmacVerifyUpdatePrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), - (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); - length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); - } - - handle->buffering_length = 0; - memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); - handle->buffering_length = length_rest; - } - else - { - memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); - handle->buffering_length += message_length; - } - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * The R_SCE_AES128CMAC_VerifyFinal() function inputs the MAC value in the MAC data area specified - * in the second argument, mac, and verifies the MAC value. If authentication fails, the return value will be - * TSIP_ERR_AUTHENTICATION. If the MAC value is less than 16 bytes, it will be padded with zeros inside the function. - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (mac_length byte) - * @param[in,out] mac_length MAC data length (2 to 16 bytes) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES128CMAC_VerifyFinal (sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length) -{ - fsp_err_t ercd = FSP_SUCCESS; - uint32_t mac_tmp[16 / sizeof(uint32_t)] = - { - 0 /* mac_tmp is initialized with 0. */ - }; - uint32_t mac_length_bit = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes128cmacver_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((2 > mac_length) || (mac_length > HW_SCE_AES_BLOCK_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) - { - handle->cmac_buffer[handle->buffering_length] = 1 << 7; - memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, - HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); - } - - memcpy(mac_tmp, mac, mac_length); - mac_length_bit = change_endian_long(mac_length * 8); - - ercd = R_SCE_Aes128CmacVerifyFinalPrivate(handle->all_received_length, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) handle->cmac_buffer, - (uint32_t *) mac_tmp, - &mac_length_bit); - memset(handle, 0, sizeof(sce_cmac_handle_t)); - - return ercd; -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CMAC_GenerateInit() function performs preparations for the execution of an CMAC calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument in the subsequent - * R_SCE_AES256CMAC_GenerateUpdate() function and R_SCE_AES256CMAC_GenerateFinal() function. - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CMAC_GenerateInit (sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) -{ - memset(handle, 0, sizeof(sce_cmac_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256cmacgen_private_id = g_private_id_counter; - handle->id = g_aes256cmacgen_private_id; - memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES256_KEY_INDEX_WORD_SIZE * 4); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - - return R_SCE_Aes256CmacGenerateInitPrivate(wrapped_key); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CMAC_GenerateUpdate() function performs MAC value generation based on the message specified - * in the second argument, message, using the value specified for wrapped_key in R_SCE_AES256CMAC_GenerateInit(). - * Inside this function, the data that is input by the user is buffered until the input value of message - * exceeds 16 bytes. The length of the message data to input is specified in the third argument, message_len. - * For these, input not the total byte count for message input data, but rather the message data length - * to input when the user calls this function. If the input value, message, is not a multiple of 16 bytes, - * it will be padded within the function. For message, specify a RAM address that are multiples of 4. - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CMAC_GenerateUpdate (sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length) -{ - uint32_t length_rest = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256cmacgen_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->all_received_length += message_length; - if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), - message, - HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes256CmacGenerateUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); - length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - R_SCE_Aes256CmacGenerateUpdatePrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), - (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); - length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); - } - - handle->buffering_length = 0; - memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); - handle->buffering_length = length_rest; - } - else - { - memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); - handle->buffering_length += message_length; - } - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CMAC_GenerateFinal() function outputs the MAC value to the MAC data area specified - * in the second argument, mac, and ends CMAC mode. - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (16byte) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Not used. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CMAC_GenerateFinal (sce_cmac_handle_t * handle, uint8_t * mac) -{ - fsp_err_t ercd = FSP_SUCCESS; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256cmacgen_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) - { - handle->cmac_buffer[handle->buffering_length] = 1 << 7; - memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, - HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); - } - - ercd = R_SCE_Aes256CmacGenerateFinalPrivate(handle->all_received_length, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (handle->cmac_buffer), - (uint32_t *) (mac)); - memset(handle, 0, sizeof(sce_cmac_handle_t)); - - return ercd; -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CMAC_VerifyInit() function performs preparations for the execution of a CMAC calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argumentin the subsequent - * R_SCE_AES256CMAC_VerifyUpdate() function and R_SCE_AES256CMAC_VerifyFinal() function. - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] wrapped_key 256-bit AES wrapped key - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CMAC_VerifyInit (sce_cmac_handle_t * handle, sce_aes_wrapped_key_t * wrapped_key) -{ - memset(handle, 0, sizeof(sce_cmac_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_aes256cmacver_private_id = g_private_id_counter; - handle->id = g_aes256cmacver_private_id; - memcpy(handle->wrapped_key.value, wrapped_key->value, HW_SCE_AES256_KEY_INDEX_WORD_SIZE * 4); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - - return R_SCE_Aes256CmacVerifyInitPrivate(wrapped_key); -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CMAC_VerifyUpdate() function performs MAC value generation based on the message specified - * in the second argument, message, using the value specified for wrapped_key in R_SCE_AES256CMAC_VerifyInit(). - * Inside this function, the data that is input by the user is buffered until the input value of message - * exceeds 16 bytes. The length of the message data to input is specified in the third argument, message_len. - * For these, input not the total byte count for message input data, but rather the message data length to input - * when the user calls this function. If the input value, message, is not a multiple of 16 bytes, - * it will be padded within the function. For message, specify a RAM address that are multiples of 4. - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in] message message data area (message_length byte) - * @param[in] message_length message data length (0 or more bytes) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CMAC_VerifyUpdate (sce_cmac_handle_t * handle, uint8_t * message, uint32_t message_length) -{ - uint32_t length_rest = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_aes256cmacver_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->all_received_length += message_length; - if ((handle->buffering_length + message_length) > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - memcpy(((&handle->cmac_buffer[0]) + handle->buffering_length), - message, - HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - - /* Casting uint32_t pointer is used for address. */ - R_SCE_Aes256CmacVerifyUpdatePrivate((uint32_t *) (handle->cmac_buffer), HW_SCE_AES_BLOCK_BYTE_SIZE >> 2); - length_rest = message_length - (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length); - memset(handle->cmac_buffer, 0, sizeof(handle->cmac_buffer)); - if (length_rest > HW_SCE_AES_BLOCK_BYTE_SIZE) - { - R_SCE_Aes256CmacVerifyUpdatePrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (message + (HW_SCE_AES_BLOCK_BYTE_SIZE - handle->buffering_length)), - (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE) >> 2); - length_rest -= (((length_rest - 1) / HW_SCE_AES_BLOCK_BYTE_SIZE) * HW_SCE_AES_BLOCK_BYTE_SIZE); - } - - handle->buffering_length = 0; - memcpy(handle->cmac_buffer, message + (message_length - length_rest), length_rest); - handle->buffering_length = length_rest; - } - else - { - memcpy((&handle->cmac_buffer[0]) + handle->buffering_length, message, message_length); - handle->buffering_length += message_length; - } - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * The R_SCE_AES256CMAC_VerifyFinal() function inputs the MAC value in the MAC data area specified - * in the second argument, mac, and verifies the MAC value. If authentication fails, the return value will be - * TSIP_ERR_AUTHENTICATION. If the MAC value is less than 16 bytes, it will be padded with zeros inside the function. - * - * @param[in,out] handle AES-CMAC handler (work area) - * @param[in,out] mac MAC data area (mac_length byte) - * @param[in,out] mac_length MAC data length (2 to 16 bytes) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_AES256CMAC_VerifyFinal (sce_cmac_handle_t * handle, uint8_t * mac, uint32_t mac_length) -{ - fsp_err_t ercd = FSP_SUCCESS; - uint32_t mac_tmp[16 / sizeof(uint32_t)] = - { - 0 /* mac_tmp is initialized with 0. */ - }; - uint32_t mac_length_bit = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_aes256cmacver_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((2 > mac_length) || (mac_length > HW_SCE_AES_BLOCK_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((0 != (handle->buffering_length % HW_SCE_AES_BLOCK_BYTE_SIZE)) || (0 == handle->all_received_length)) - { - handle->cmac_buffer[handle->buffering_length] = 1 << 7; - memset(handle->cmac_buffer + (handle->buffering_length + 1), 0, - HW_SCE_AES_BLOCK_BYTE_SIZE - (handle->buffering_length + 1)); - } - - memcpy(mac_tmp, mac, mac_length); - mac_length_bit = change_endian_long(mac_length * 8); - - ercd = R_SCE_Aes256CmacVerifyFinalPrivate(handle->all_received_length, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) handle->cmac_buffer, - (uint32_t *) mac_tmp, - &mac_length_bit); - memset(handle, 0, sizeof(sce_cmac_handle_t)); - - return ercd; -} - -/*******************************************************************************************************************//** - * @} (end addtogroup SCE_PROTECTED) - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private Functions - **********************************************************************************************************************/ - -/****************************************************************************** - * calculate curent ivec after update process on AES COUNTER mode - * - * @param[in] block_num encrypted block number. - * @param[in,out] handle Handler for AES(work area). - * - * Return Value :none - *****************************************************************************/ -static void cal_current_ivec_ctrmode(sce_aes_handle_t *handle , uint32_t block_num) -{ - uint8_t carry_num = 0; - for (uint8_t i = 0; i < 16; i++) - { - uint16_t current_byte_sum = (uint16_t)(carry_num + handle->current_initial_vector[15 - i]); - if (i < (sizeof(block_num))) - { - current_byte_sum = (uint16_t)((uint32_t)current_byte_sum + ((block_num >> (i * 8)) & 0xFF)); - } - handle->current_initial_vector[15 - i] = (uint8_t)(current_byte_sum & 0xFF); - carry_num = (uint8_t)(current_byte_sum >> 8) & 0xFF; - } -} diff --git a/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_ecc.c b/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_ecc.c deleted file mode 100644 index ff775ae5c..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_ecc.c +++ /dev/null @@ -1,685 +0,0 @@ -/********************************************************************************************************************** - * DISCLAIMER - * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No - * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all - * applicable laws, including copyright laws. - * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING - * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM - * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES - * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO - * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of - * this software. By using this software, you agree to the additional terms and conditions found by accessing the - * following link: - * http://www.renesas.com/disclaimer - * - * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. - *********************************************************************************************************************/ -/********************************************************************************************************************** - * File Name : r_sce_ecc.c - * Version : 1.0 - * Description : SCE ECC Public API source file - *********************************************************************************************************************/ -/********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release - *********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Includes - **********************************************************************************************************************/ -#include -#include "r_sce_private.h" - -/*********************************************************************************************************************** - * Macro definitions - **********************************************************************************************************************/ -/* Hash data output position for ECDSA P-192. : (256 - 192) / 32 */ -#define SCE_PRV_HASH_WORD_POS_ECDSA_P192 (2) -/* Hash data output position for ECDSA P-224. : (256 - 224) / 32 */ -#define SCE_PRV_HASH_WORD_POS_ECDSA_P224 (1) -/* Hash data output position for ECDSA P-256. : (256 - 256) / 32 */ -#define SCE_PRV_HASH_WORD_POS_ECDSA_P256 (0) -/* For ECDSA P-512 : (256 - 512) / 32 */ -#define SCE_PRV_HASH_WORD_POS_ECDSA_P512 (0xFFFFFFF8UL) - -#ifndef SCE_HEX_FF -#define SCE_HEX_FF (0xFF) -#endif -#ifndef SCE_HEX_80 -#define SCE_HEX_80 (0x80) -#endif -#ifndef SCE_DEC_64 -#define SCE_DEC_64 (64) -#endif - -/*********************************************************************************************************************** - * Typedef definitions - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private function prototypes - **********************************************************************************************************************/ -static fsp_err_t set_ecdsa_hash_data(sce_ecdsa_byte_data_t * p_message_hash, - uint32_t * data_buff, - uint32_t hash_word_pos); - -/*********************************************************************************************************************** - * Private global variables - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Global variables - **********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * @addtogroup SCE_PROTECTED - * @{ - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Functions - **********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * When a message is specified in the first argument, message_hash->data_type, a SHA-256 hash of the message text - * input as the first argument, message_hash->pdata, is calculated, and the signature text is written to the second - * argument, signature, in accordance with secp192r1 using the private wrapped key input as the third argument, - * wrapped_key. - * - * When a hash value is specified in the first argument, message_hash->data_type, the signature text for the first - * 24 bytes of the SHA-256 hash value input to the first argument, message_hash->pdata, is written to the second - * argument, signature, in accordance with secp192r1 using the private wrapped key input as the third argument, - * wrapped_key. - * - * @param[in] message_hash Message or hash value to which to attach signature - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in,out] signature Signature text storage destination information - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "0 padding (64 bits) || - * signature r (192 bits) || 0 padding (64 bits) || - * signature s (192 bits)". - * @arg signature->data_length : Data length (byte units) - * @param[in] wrapped_key Input wrapped key of secp192r1 private key. - * - * @retval FSP_SUCCESS Normal end - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_secp192r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key) -{ - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P192 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P192); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_EcdsaSignatureGenerateSub( - /* Casting uint32_t pointer is used for address. */ - &curvetype, - &indata_cmd, - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - signature->data_length = HW_SCE_ECDSA_DATA_BYTE_SIZE; - - return error_code; -} - -/*******************************************************************************************************************//** - * When a message is specified in the first argument, message_hash->data_type, a SHA-256 hash of the message text - * input as the first argument, message_hash->pdata, is calculated, and the signature text is written to the second - * argument, signature, in accordance with secp224r1 using the private wrapped key input as the third argument, - * wrapped_key. - * - * When a hash value is specified in the first argument, message_hash->data_type, the signature text for the first - * 28 bytes of the SHA-256 hash value input to the first argument, message_hash->pdata, is written to the second - * argument, signature, in accordance with secp224r1 using the private wrapped key input as the third argument, - * wrapped_key. - * - * @param[in] message_hash Message or hash value to which to attach signature - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in,out] signature Signature text storage destination information - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "0 padding (32 bits) || - * signature r (224 bits) || 0 padding (32 bits) || - * signature s (224 bits)". - * @arg signature->data_length : Data length (byte units) - * @param[in] wrapped_key Input wrapped key of secp224r1 private key. - * - * @retval FSP_SUCCESS Normal end - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_secp224r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key) -{ - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P224 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P224); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_EcdsaSignatureGenerateSub( - /* Casting uint32_t pointer is used for address. */ - &curvetype, - &indata_cmd, - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - signature->data_length = HW_SCE_ECDSA_DATA_BYTE_SIZE; - - return error_code; -} - -/*******************************************************************************************************************//** - * When a message is specified in the first argument, message_hash->data_type, a SHA-256 hash of the message text - * input as the first argument, message_hash->pdata, is calculated, and the signature text is written to the second - * argument, signature, in accordance with secp256r1 using the private wrapped key input as the third argument, - * wrapped_key. - * - * When a hash value is specified in the first argument, message_hash->data_type, the signature text for the first - * 32 bytes of the SHA-256 hash value input to the first argument, message_hash->pdata, is written to the second - * argument, signature, in accordance with secp256r1 using the private wrapped key input as the third argument, - * wrapped_key. - * - * @param[in] message_hash Message or hash value to which to attach signature - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in,out] signature Signature text storage destination information - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "signature r (256 bits) || - * signature s (256 bits)". - * @arg signature->data_length : Data length (byte units) - * @param[in] wrapped_key Input wrapped key of secp256r1 private key. - * - * @retval FSP_SUCCESS Normal end - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_secp256r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key) -{ - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P256 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P256); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_EcdsaSignatureGenerateSub( - /* Casting uint32_t pointer is used for address. */ - &curvetype, - &indata_cmd, - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - signature->data_length = HW_SCE_ECDSA_DATA_BYTE_SIZE; - - return error_code; -} - -/*******************************************************************************************************************//** - * When a hash value is specified in the first argument, message_hash->data_type, the signature text for the first - * 64 bytes of the SHA-512 hash value input to the first argument, message_hash->pdata, is written to the second - * argument, signature, in accordance with BrainpoolP512r1 using the private wrapped key input as the third argument, - * wrapped_key. - * - * @param[in] message_hash Message or hash value to which to attach signature - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (only Hash value(1) is support) - * @param[in,out] signature Signature text storage destination information - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "signature r (512 bits) || - * signature s (512 bits)". - * @arg signature->data_length : Data length (byte units) - * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 private key. - * - * @retval FSP_SUCCESS Normal end - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureGenerate (sce_ecdsa_byte_data_t * message_hash, - sce_ecdsa_byte_data_t * signature, - sce_ecc_private_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[(HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - if (1 != message_hash->data_type) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P512); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = R_SCE_EcdsaP512SignatureGenerateSub( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - signature->data_length = HW_SCE_ECDSA_P512_DATA_BYTE_SIZE; - - return error_code; -} - -/*******************************************************************************************************************//** - * When a message is specified in the second argument, message_hash->data_type, a SHA-256 hash of the message text - * input as the second argument, message_hash->pdata, is calculated, and the signature text input to the first argument, - * signature, is validated in accordance with secp192r1 using the public wrapped key input as the third argument, - * wrapped_key. - * - * When a hash value is specified in the second argument, message_hash->data_type, the signature text for the first - * 24 bytes of the SHA-256 hash value input to the second argument, message_hash->pdata, input to the first argument, - * signature, is validated in accordance with secp192r1 using the public wrapped key input as the third argument, - * wrapped_key. - * - * @param[in] signature Signature text information to be verified - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "0 padding (64 bits) || - * signature r (192 bits) || 0 padding (64 bits) || - * signature s (192 bits)". - * @arg signature->data_length : Specifies the data length (byte units) (nonuse) - * @param[in,out] message_hash Message or hash value to be verified - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in] wrapped_key Input wrapped key of secp192r1 public key. - * - * @retval FSP_SUCCESS Normal end - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_secp192r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key) -{ - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P192 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P192); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_192); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_EcdsaSignatureVerificationSub( - /* Casting uint32_t pointer is used for address. */ - &curvetype, - &indata_cmd, - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - - return error_code; -} - -/*******************************************************************************************************************//** - * When a message is specified in the second argument, message_hash->data_type, a SHA-256 hash of the message text - * input as the second argument, message_hash->pdata, is calculated, and the signature text input to the first argument, - * signature, is validated in accordance with secp224r1 using the public wrapped key input as the third argument, - * wrapped_key. - * - * When a hash value is specified in the second argument, message_hash->data_type, the signature text for the first - * 28 bytes of the SHA-256 hash value input to the second argument, message_hash->pdata, input to the first argument, - * signature, is validated in accordance with secp224r1 using the public wrapped key input as the third argument, - * wrapped_key. - * - * @param[in] signature Signature text information to be verified - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "0 padding (32 bits) || - * signature r (224 bits) || 0 padding (32 bits) || - * signature s (224 bits)". - * @arg signature->data_length : Specifies the data length (byte units) (nonuse) - * @param[in,out] message_hash Message or hash value to be verified - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in] wrapped_key Input wrapped key of secp224r1 public key. - * - * @retval FSP_SUCCESS Normal end - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_secp224r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key) -{ - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P224 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P224); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_224); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_EcdsaSignatureVerificationSub( - /* Casting uint32_t pointer is used for address. */ - &curvetype, - &indata_cmd, - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - - return error_code; -} - -/*******************************************************************************************************************//** - * When a message is specified in the second argument, message_hash->data_type, a SHA-256 hash of the message text - * input as the second argument, message_hash->pdata, is calculated, and the signature text input to the first argument, - * signature, is validated in accordance with secp256r1 using the public wrapped key input as the third argument, - * wrapped_key. - * - * When a hash value is specified in the second argument, message_hash->data_type, the signature text for the first - * 32 bytes of the SHA-256 hash value input to the second argument, message_hash->pdata, input to the first argument, - * signature, is validated in accordance with secp256r1 using the public wrapped key input as the third argument, - * wrapped_key. - * - * @param[in] signature Signature text information to be verified - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "signature r (256 bits) || - * signature s (256 bits)". - * @arg signature->data_length : Specifies the data length (byte units) (nonuse) - * @param[in,out] message_hash Message or hash value to be verified - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in] wrapped_key Input wrapped key of secp256r1 public key. - * - * @retval FSP_SUCCESS Normal end - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_secp256r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key) -{ - uint32_t indata_cmd; - uint32_t curvetype; - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[SCE_PRV_HASH_WORD_POS_ECDSA_P256 + (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P256); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - indata_cmd = change_endian_long(SCE_ECC_KEY_LENGTH_256); - curvetype = change_endian_long(SCE_ECC_CURVE_TYPE_NIST); - error_code = R_SCE_EcdsaSignatureVerificationSub( - /* Casting uint32_t pointer is used for address. */ - &curvetype, - &indata_cmd, - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - - return error_code; -} - -/*******************************************************************************************************************//** - * When a hash value is specified in the second argument, message_hash->data_type, the signature text for the first - * 32 bytes of the SHA-256 hash value input to the second argument, message_hash->pdata, input to the first argument, - * signature, is validated in accordance with BrainpoolP512r1 using the public wrapped key input as the third argument, - * wrapped_key. - * - * @param[in] signature Signature text information to be verified - * @arg signature->pdata : Specifies pointer to array storing signature text - * The signature format is "signature r (512 bits) || - * signature s (512 bits)". - * @arg signature->data_length : Specifies the data length (byte units) (nonuse) - * @param[in,out] message_hash Message or hash value to be verified - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (only Hash value(1) is support) - * @param[in] wrapped_key Input wrapped key of BrainpoolP512r1 public key. - * - * @retval FSP_SUCCESS Normal end - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource required - * by the processing is in use by other processing. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred or signature verification failed. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_ECDSA_BrainpoolP512r1_SignatureVerify (sce_ecdsa_byte_data_t * signature, - sce_ecdsa_byte_data_t * message_hash, - sce_ecc_public_wrapped_key_t * wrapped_key) -{ - fsp_err_t error_code = FSP_SUCCESS; - uint32_t data_buff[(HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t))] = - { - 0 - }; - - if (1 != message_hash->data_type) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - error_code = set_ecdsa_hash_data(message_hash, data_buff, SCE_PRV_HASH_WORD_POS_ECDSA_P512); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = R_SCE_EcdsaP512SignatureVerificationSub( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) data_buff, - (uint32_t *) signature->pdata); - - return error_code; -} - -/*******************************************************************************************************************//** - * @} (end addtogroup SCE_PROTECTED) - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private Functions - **********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * For messages, SHA hash operation is performed and the hash value is set according to ECDSA. - * - * @param p_message_hash message or hash value information - * @param data_buff pointer to the hash value area, including 0 padding - * @param hash_word_pos hash value output word position from the beginning of the data_buff - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input parameter illegal - * @retval FSP_ERR_CRYPTO_SCE_FAIL Internal error occurred. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - **********************************************************************************************************************/ -static fsp_err_t set_ecdsa_hash_data (sce_ecdsa_byte_data_t * p_message_hash, - uint32_t * data_buff, - uint32_t hash_word_pos) -{ - fsp_err_t error_code = FSP_SUCCESS; - sce_sha_md5_handle_t ex_sha_handle = - { - 0 - }; - uint32_t hash_length = 0; - - if (0 == p_message_hash->data_type) - { - if (SCE_PRV_HASH_WORD_POS_ECDSA_P512 != hash_word_pos) - { - R_SCE_SHA256_Init(&ex_sha_handle); - error_code = R_SCE_SHA256_Update(&ex_sha_handle, p_message_hash->pdata, p_message_hash->data_length); - if (FSP_SUCCESS == error_code) - { - /* Casting uint8_t pointer is used for address. */ - error_code = R_SCE_SHA256_Final(&ex_sha_handle, (uint8_t *) &data_buff[hash_word_pos], &hash_length); - } - } - else - { - error_code = FSP_ERR_CRYPTO_SCE_FAIL; - } - } - else if (1 == p_message_hash->data_type) - { - if (SCE_PRV_HASH_WORD_POS_ECDSA_P512 != hash_word_pos) - { - memcpy(&data_buff[hash_word_pos], - p_message_hash->pdata, - HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE - (hash_word_pos * sizeof(uint32_t))); - } - else - { - memcpy(data_buff, p_message_hash->pdata, HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE); - } - } - else - { - error_code = FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - return error_code; -} diff --git a/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_rsa.c b/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_rsa.c deleted file mode 100644 index c43fdd2c5..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_rsa.c +++ /dev/null @@ -1,1162 +0,0 @@ -/********************************************************************************************************************** - * DISCLAIMER - * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No - * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all - * applicable laws, including copyright laws. - * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING - * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM - * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES - * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO - * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of - * this software. By using this software, you agree to the additional terms and conditions found by accessing the - * following link: - * http://www.renesas.com/disclaimer - * - * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. - *********************************************************************************************************************/ -/********************************************************************************************************************** - * File Name : r_sce_rsa.c - * Version : 1.0 - * Description : SCE RSA Public API source file - *********************************************************************************************************************/ -/********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release - *********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Includes - **********************************************************************************************************************/ -#include -#include -#include "r_sce_private.h" - -/*********************************************************************************************************************** - * Macro definitions - **********************************************************************************************************************/ -#define SCE_RSA_SIG_SHA256_PREFIX_00 (0x30) -#define SCE_RSA_SIG_SHA256_PREFIX_01 (0x31) -#define SCE_RSA_SIG_SHA256_PREFIX_02 (0x30) -#define SCE_RSA_SIG_SHA256_PREFIX_03 (0x0d) -#define SCE_RSA_SIG_SHA256_PREFIX_04 (0x06) -#define SCE_RSA_SIG_SHA256_PREFIX_05 (0x09) -#define SCE_RSA_SIG_SHA256_PREFIX_06 (0x60) -#define SCE_RSA_SIG_SHA256_PREFIX_07 (0x86) -#define SCE_RSA_SIG_SHA256_PREFIX_08 (0x48) -#define SCE_RSA_SIG_SHA256_PREFIX_09 (0x01) -#define SCE_RSA_SIG_SHA256_PREFIX_10 (0x65) -#define SCE_RSA_SIG_SHA256_PREFIX_11 (0x03) -#define SCE_RSA_SIG_SHA256_PREFIX_12 (0x04) -#define SCE_RSA_SIG_SHA256_PREFIX_13 (0x02) -#define SCE_RSA_SIG_SHA256_PREFIX_14 (0x01) -#define SCE_RSA_SIG_SHA256_PREFIX_15 (0x05) -#define SCE_RSA_SIG_SHA256_PREFIX_16 (0x00) -#define SCE_RSA_SIG_SHA256_PREFIX_17 (0x04) -#define SCE_RSA_SIG_SHA256_PREFIX_18 (0x20) - -#ifndef SCE_HEX_FF -#define SCE_HEX_FF (0xff) -#endif - -/*********************************************************************************************************************** - * Typedef definitions - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private function prototypes - **********************************************************************************************************************/ -static fsp_err_t calc_hash_data(uint8_t * p_mes, uint8_t * p_hash, uint32_t mes_len, uint8_t hash_type); -static fsp_err_t set_rsassapkcs_hash_data(sce_rsa_byte_data_t * p_message_hash, - uint8_t hash_type, - uint32_t rsa_key_byte_size, - uint8_t * data_buff); -static uint32_t get_keyn_size(uint32_t * prsa_key_index, uint32_t key_max_size); -static fsp_err_t get_rand_rsaes_pkcs(uint32_t rand_size, uint8_t * prand_data); - -/*********************************************************************************************************************** - * Private global variables - **********************************************************************************************************************/ -static uint8_t gs_rsa_sig_sha256_prefix[] = -{ - SCE_RSA_SIG_SHA256_PREFIX_00, - SCE_RSA_SIG_SHA256_PREFIX_01, - SCE_RSA_SIG_SHA256_PREFIX_02, - SCE_RSA_SIG_SHA256_PREFIX_03, - SCE_RSA_SIG_SHA256_PREFIX_04, - SCE_RSA_SIG_SHA256_PREFIX_05, - SCE_RSA_SIG_SHA256_PREFIX_06, - SCE_RSA_SIG_SHA256_PREFIX_07, - SCE_RSA_SIG_SHA256_PREFIX_08, - SCE_RSA_SIG_SHA256_PREFIX_09, - SCE_RSA_SIG_SHA256_PREFIX_10, - SCE_RSA_SIG_SHA256_PREFIX_11, - SCE_RSA_SIG_SHA256_PREFIX_12, - SCE_RSA_SIG_SHA256_PREFIX_13, - SCE_RSA_SIG_SHA256_PREFIX_14, - SCE_RSA_SIG_SHA256_PREFIX_15, - SCE_RSA_SIG_SHA256_PREFIX_16, - SCE_RSA_SIG_SHA256_PREFIX_17, - SCE_RSA_SIG_SHA256_PREFIX_18 -}; - -/*********************************************************************************************************************** - * Global variables - **********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * @addtogroup SCE_PROTECTED - * @{ - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Functions - **********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * The R_SCE_RSASSA_PKCS1024_SignatureGenerate() function generates, in accordance with RSASSA-PKCS1-V1_5, a signature - * from the message text or hash value that is input in the first argument, message_hash, using the private wrapped - * key input to the third argument, wrapped_key, and writes the signature text to the second argument, signature. - * When a message is specified in the first argument, message_hash->data_type, a hash value is calculated for - * the message as specified by the fourth argument, hash_type. When specifying a hash value in the first argument, - * message_hash->data_type, a hash value calculated with a hash algorithm as specified by the fourth argument, - * hash_type, must be input to message_hash->pdata. - * - * @param[in] message_hash Message or hash value to which to attach signature - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in,out] signature Signature text storage destination information - * @arg signature->pdata : Specifies pointer to array storing the signature text - * @arg signature->data_length : data length - * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureGenerate (sce_rsa_byte_data_t * message_hash, - sce_rsa_byte_data_t * signature, - sce_rsa1024_private_wrapped_key_t * wrapped_key, - uint8_t hash_type) -{ - fsp_err_t error_code = FSP_SUCCESS; - uint8_t data_buff[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - - error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_1024_DATA_BYTE_SIZE, data_buff); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = R_SCE_Rsa1024ModularExponentDecryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (data_buff), - (uint32_t *) (signature->pdata)); - - signature->data_length = HW_SCE_RSA_1024_DATA_BYTE_SIZE; - - return error_code; -} - -/*******************************************************************************************************************//** - * The R_SCE_RSASSA_PKCS1024_SignatureVerify() function verifies, in accordance with RSASSA-PKCS1-V1_5, - * the signature text input to the first argument signature, - * and the message text or hash value input to the second argument, - * message_hash, using the public wrapped key input to the third argument, wrapped_key. When a message is specified - * in the second argument, message_hash->data_type, a hash value is calculated using the public wrapped key input to - * the third argument, wrapped_key, and as specified by the fourth argument, hash_type. When specifying a hash value - * in the second argument, message_hash->data_type, a hash value calculated with a hash algorithm as specified by the - * fourth argument, hash_type, must be input to message_hash->pdata. - * - * @param[in] signature Signature text information to verify - * @arg signature->pdata : Specifies pointer to array storing the signature text - * @arg signature->data_length : Specifies effective data length of the array - * @param[in] message_hash Message text or hash value to verify - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSASSA_PKCS1024_SignatureVerify (sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, - sce_rsa1024_public_wrapped_key_t * wrapped_key, - uint8_t hash_type) -{ - fsp_err_t error_code = FSP_SUCCESS; - uint8_t data_buff[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t decrypt_data[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t data_ptr = 0; - - data_ptr = HW_SCE_RSA_1024_DATA_BYTE_SIZE - signature->data_length; - memcpy(data_buff + data_ptr, signature->pdata, signature->data_length); - - error_code = R_SCE_Rsa1024ModularExponentEncryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (data_buff), - (uint32_t *) (decrypt_data)); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_1024_DATA_BYTE_SIZE, data_buff); - if (FSP_SUCCESS == error_code) - { - if (memcmp(data_buff, decrypt_data, HW_SCE_RSA_1024_DATA_BYTE_SIZE)) - { - error_code = FSP_ERR_CRYPTO_SCE_AUTHENTICATION; - } - } - - return error_code; -} - -/*******************************************************************************************************************//** - * The R_SCE_RSAES_PKCS1024_Encrypt() function RSA-encrypts the plaintext input to the first argument, plain, - * according to RSAES-PKCS1-V1_5. It writes the encryption result to the second argument, cipher. - * - * @param[in] plain plaintext - * @arg plain->pdata : Specifies pointer to array containing plaintext. - * @arg plain->data_length : Specifies valid data length of plaintext array. - * data size <= public key n size - 11 - * @param[in,out] cipher ciphertext - * @arg cipher->pdata : Specifies pointer to array containing ciphertext. - * @arg cipher->data_length : Inputs ciphertext buffer size. - * Outputs valid data length after encryption - * (public key n size). - * @param[in] wrapped_key Inputs the 1024-bit RSA public wrapped key. - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSAES_PKCS1024_Encrypt (sce_rsa_byte_data_t * plain, - sce_rsa_byte_data_t * cipher, - sce_rsa1024_public_wrapped_key_t * wrapped_key) -{ - fsp_err_t ercd = FSP_SUCCESS; - uint8_t input_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t output_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t key_size = 0; - uint32_t ptr = 0; - - /* Casting uint32_t pointer is used for address. */ - key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_1024_DATA_BYTE_SIZE); - if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((plain->data_length) > (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (cipher->data_length < key_size) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - cipher->data_length = key_size; - - /*** RSAES-PKCS#1_V1.5 format ***/ - /* (1) | (2) | (3) | (4) | (5) */ - /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ - ptr = HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size; - input_data_arry[ptr] = 0x00; - ptr++; - input_data_arry[ptr] = 0x02; - ptr++; - - get_rand_rsaes_pkcs(((key_size - plain->data_length) - 3), &input_data_arry[ptr]); - ptr += ((key_size - plain->data_length) - 3); - input_data_arry[ptr] = 0x00; - ptr++; - - memcpy(&input_data_arry[ptr], plain->pdata, plain->data_length); - - ercd = R_SCE_Rsa1024ModularExponentEncryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (input_data_arry), - (uint32_t *) (output_data_arry)); - memcpy(cipher->pdata, &output_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size], cipher->data_length); - - return ercd; -} - -/*******************************************************************************************************************//** - * The R_SCE_RSAES_PKCS1024_Decrypt() function RSA-decrypts the ciphertext input to the first argument, cipher, - * according to RSAES-PKCS1-V1_5. It writes the decryption result to the second argument, plain. - * - * @param[in] cipher ciphertext - * @arg cipher->pdata : Specifies pointer to array containing ciphertext. - * @arg cipher->data_length : Inputs ciphertext buffer size. - * Outputs valid data length after encryption - * (public key n size). - * @param[in,out] plain plaintext - * @arg plain->pdata : Specifies pointer to array containing plaintext. - * @arg plain->data_length : Inputs plaintext buffer size. - * The following size is required. - * Plaintext buffer size >= public key n size -11. - * Outputs valid data length after decryption - * (public key n size). - * @param[in] wrapped_key Inputs the 1024-bit RSA private wrapped key. - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSAES_PKCS1024_Decrypt (sce_rsa_byte_data_t * cipher, - sce_rsa_byte_data_t * plain, - sce_rsa1024_private_wrapped_key_t * wrapped_key) -{ - fsp_err_t ercd = FSP_SUCCESS; - uint8_t input_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t output_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t key_size = 0; - uint32_t ptr = 0; - uint32_t ptr_start = 0; - uint8_t * p_start = 0; - uint8_t * p_zero_ptr = 0; - - /* Casting uint32_t pointer is used for address. */ - key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_1024_DATA_BYTE_SIZE); - if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (cipher->data_length != key_size) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (plain->data_length < (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - memcpy(&input_data_arry[HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size], cipher->pdata, cipher->data_length); - ercd = R_SCE_Rsa1024ModularExponentDecryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (input_data_arry), - (uint32_t *) (output_data_arry)); - if (FSP_SUCCESS != ercd) - { - return ercd; - } - - /*** RSAES-PKCS#1_V1.5 format ***/ - /* (1) | (2) | (3) | (4) | (5) */ - /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ - ptr = HW_SCE_RSA_1024_DATA_BYTE_SIZE - key_size; - ptr_start = ptr; - - /* (1) */ - if (0x00 != output_data_arry[ptr]) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - ptr++; - - /* (2) */ - if (0x02 != output_data_arry[ptr]) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - ptr++; - - /* (3) and (4) */ - p_start = &output_data_arry[ptr]; - - /* Casting uint8_t pointer is used for address. */ - p_zero_ptr = (uint8_t *) memchr(p_start, 0x00, key_size - 2); /* "2" is (1)+(2) */ - if (NULL == p_zero_ptr) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - if ((HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE - 3) > (uint32_t) (p_zero_ptr - p_start)) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - ptr += (uint32_t) ((p_zero_ptr - p_start) + 1); - - plain->data_length = key_size - (ptr - ptr_start); - memcpy(plain->pdata, &output_data_arry[ptr], plain->data_length); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * The R_SCE_RSASSA_PKCS2048_SignatureGenerate() function generates, in accordance with RSASSA-PKCS1-V1_5, a signature - * from the message text or hash value that is input in the first argument, message_hash, using the private wrapped - * key input to the third argument, wrapped_key, and writes the signature text to the second argument, signature. - * When a message is specified in the first argument, message_hash->data_type, a hash value is calculated for - * the message as specified by the fourth argument, hash_type. When specifying a hash value in the first argument, - * message_hash->data_type, a hash value calculated with a hash algorithm as specified by the fourth argument, - * hash_type, must be input to message_hash->pdata. - * - * @param[in] message_hash Message or hash value to which to attach signature - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in,out] signature Signature text storage destination information - * @arg signature->pdata : Specifies pointer to array storing the signature text - * @arg signature->data_length : data length - * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureGenerate (sce_rsa_byte_data_t * message_hash, - sce_rsa_byte_data_t * signature, - sce_rsa2048_private_wrapped_key_t * wrapped_key, - uint8_t hash_type) -{ - fsp_err_t error_code = FSP_SUCCESS; - uint8_t data_buff[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - - error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_2048_DATA_BYTE_SIZE, data_buff); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = R_SCE_Rsa2048ModularExponentDecryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (data_buff), - (uint32_t *) (signature->pdata)); - - signature->data_length = HW_SCE_RSA_2048_DATA_BYTE_SIZE; - - return error_code; -} - -/*******************************************************************************************************************//** - * The R_SCE_RSASSA_PKCS2048_SignatureVerify() function verifies, in accordance with RSASSA-PKCS1-V1_5, - * the signature text input to the first argument signature, - * and the message text or hash value input to the second argument, - * message_hash, using the public wrapped key input to the third argument, wrapped_key. When a message is specified - * in the second argument, message_hash->data_type, a hash value is calculated using the public wrapped key input to - * the third argument, wrapped_key, and as specified by the fourth argument, hash_type. When specifying a hash value - * in the second argument, message_hash->data_type, a hash value calculated with a hash algorithm as specified by the - * fourth argument, hash_type, must be input to message_hash->pdata. - * - * @param[in] signature Signature text information to verify - * @arg signature->pdata : Specifies pointer to array storing the signature text - * @arg signature->data_length : Specifies effective data length of the array - * @param[in] message_hash Message text or hash value to verify - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSASSA_PKCS2048_SignatureVerify (sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, - sce_rsa2048_public_wrapped_key_t * wrapped_key, - uint8_t hash_type) -{ - fsp_err_t error_code = FSP_SUCCESS; - uint8_t data_buff[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t decrypt_data[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t data_ptr = 0; - - data_ptr = HW_SCE_RSA_2048_DATA_BYTE_SIZE - signature->data_length; - memcpy(data_buff + data_ptr, signature->pdata, signature->data_length); - - error_code = R_SCE_Rsa2048ModularExponentEncryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (data_buff), - (uint32_t *) (decrypt_data)); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_2048_DATA_BYTE_SIZE, data_buff); - if (FSP_SUCCESS == error_code) - { - if (memcmp(data_buff, decrypt_data, HW_SCE_RSA_2048_DATA_BYTE_SIZE)) - { - error_code = FSP_ERR_CRYPTO_SCE_AUTHENTICATION; - } - } - - return error_code; -} - -/*******************************************************************************************************************//** - * The R_SCE_RSASSA_PKCS4096_SignatureVerify() function verifies, in accordance with RSASSA-PKCS1-V1_5, - * the signature text input to the first argument signature, - * and the message text or hash value input to the second argument, - * message_hash, using the public wrapped key input to the third argument, wrapped_key. When a message is specified - * in the second argument, message_hash->data_type, a hash value is calculated using the public wrapped key input to - * the third argument, wrapped_key, and as specified by the fourth argument, hash_type. When specifying a hash value - * in the second argument, message_hash->data_type, a hash value calculated with a hash algorithm as specified by the - * fourth argument, hash_type, must be input to message_hash->pdata. - * - * @param[in] signature Signature text information to verify - * @arg signature->pdata : Specifies pointer to array storing the signature text - * @arg signature->data_length : Specifies effective data length of the array - * @param[in] message_hash Message text or hash value to verify - * @arg message_hash->pdata : Specifies pointer to array storing the message or - * hash value - * @arg message_hash->data_length : Specifies effective data length of the array - * (Specify only when Message is selected) - * @arg message_hash->data_type : Selects the data type of message_hash - * (Message: 0 Hash value: 1) - * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. - * @param[in] hash_type Only HW_SCE_RSA_HASH_SHA256 is supported - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Invalid wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_AUTHENTICATION Authentication failed - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is invalid. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSASSA_PKCS4096_SignatureVerify (sce_rsa_byte_data_t * signature, - sce_rsa_byte_data_t * message_hash, - sce_rsa4096_public_wrapped_key_t * wrapped_key, - uint8_t hash_type) -{ - fsp_err_t error_code = FSP_SUCCESS; - uint8_t data_buff[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t decrypt_data[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t data_ptr = 0; - - data_ptr = HW_SCE_RSA_4096_DATA_BYTE_SIZE - signature->data_length; - memcpy(data_buff + data_ptr, signature->pdata, signature->data_length); - - error_code = R_SCE_Rsa4096ModularExponentEncryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (data_buff), - (uint32_t *) (decrypt_data)); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = set_rsassapkcs_hash_data(message_hash, hash_type, HW_SCE_RSA_4096_DATA_BYTE_SIZE, data_buff); - if (FSP_SUCCESS == error_code) - { - if (memcmp(data_buff, decrypt_data, HW_SCE_RSA_4096_DATA_BYTE_SIZE)) - { - error_code = FSP_ERR_CRYPTO_SCE_AUTHENTICATION; - } - } - - return error_code; -} - -/*******************************************************************************************************************//** - * The R_SCE_RSAES_PKCS2048_Encrypt() function RSA-encrypts the plaintext input to the first argument, plain, - * according to RSAES-PKCS1-V1_5. It writes the encryption result to the second argument, cipher. - * - * @param[in] plain plaintext - * @arg plain->pdata : Specifies pointer to array containing plaintext. - * @arg plain->data_length : Specifies valid data length of plaintext array. - * data size <= public key n size - 11 - * @param[in,out] cipher ciphertext - * @arg cipher->pdata : Specifies pointer to array containing ciphertext. - * @arg cipher->data_length : Inputs ciphertext buffer size. - * Outputs valid data length after encryption - * (public key n size). - * @param[in] wrapped_key Inputs the 2048-bit RSA public wrapped key. - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSAES_PKCS2048_Encrypt (sce_rsa_byte_data_t * plain, - sce_rsa_byte_data_t * cipher, - sce_rsa2048_public_wrapped_key_t * wrapped_key) -{ - fsp_err_t ercd = FSP_SUCCESS; - uint8_t input_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t output_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t key_size = 0; - uint32_t ptr = 0; - - /* Casting uint32_t pointer is used for address. */ - key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_2048_DATA_BYTE_SIZE); - if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((plain->data_length) > (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (cipher->data_length < key_size) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - cipher->data_length = key_size; - - /*** RSAES-PKCS#1_V1.5 format ***/ - /* (1) | (2) | (3) | (4) | (5) */ - /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ - ptr = HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size; - input_data_arry[ptr] = 0x00; - ptr++; - input_data_arry[ptr] = 0x02; - ptr++; - - get_rand_rsaes_pkcs(((key_size - plain->data_length) - 3), &input_data_arry[ptr]); - ptr += ((key_size - plain->data_length) - 3); - input_data_arry[ptr] = 0x00; - ptr++; - - memcpy(&input_data_arry[ptr], plain->pdata, plain->data_length); - - ercd = R_SCE_Rsa2048ModularExponentEncryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (input_data_arry), - (uint32_t *) (output_data_arry)); - memcpy(cipher->pdata, &output_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size], cipher->data_length); - - return ercd; -} - -/*******************************************************************************************************************//** - * The R_SCE_RSAES_PKCS2048_Decrypt() function RSA-decrypts the ciphertext input to the first argument, cipher, - * according to RSAES-PKCS1-V1_5. It writes the decryption result to the second argument, plain. - * - * @param[in] cipher ciphertext - * @arg cipher->pdata : Specifies pointer to array containing ciphertext. - * @arg cipher->data_length : Inputs ciphertext buffer size. - * Outputs valid data length after encryption - * (public key n size). - * @param[in,out] plain plaintext - * @arg plain->pdata : Specifies pointer to array containing plaintext. - * @arg plain->data_length : Inputs plaintext buffer size. - * The following size is required. - * Plaintext buffer size >= public key n size -11. - * Outputs valid data length after decryption - * (public key n size). - * @param[in] wrapped_key Inputs the 2048-bit RSA private wrapped key. - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * @retval FSP_ERR_CRYPTO_SCE_FAIL An internal error occurred. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSAES_PKCS2048_Decrypt (sce_rsa_byte_data_t * cipher, - sce_rsa_byte_data_t * plain, - sce_rsa2048_private_wrapped_key_t * wrapped_key) -{ - fsp_err_t ercd = FSP_SUCCESS; - uint8_t input_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t output_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t key_size = 0; - uint32_t ptr = 0; - uint32_t ptr_start = 0; - uint8_t * p_start = 0; - uint8_t * p_zero_ptr = 0; - - /* Casting uint32_t pointer is used for address. */ - key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_2048_DATA_BYTE_SIZE); - if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (cipher->data_length != key_size) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (plain->data_length < (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - memcpy(&input_data_arry[HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size], cipher->pdata, cipher->data_length); - ercd = R_SCE_Rsa2048ModularExponentDecryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (input_data_arry), - (uint32_t *) (output_data_arry)); - if (FSP_SUCCESS != ercd) - { - return ercd; - } - - /*** RSAES-PKCS#1_V1.5 format ***/ - /* (1) | (2) | (3) | (4) | (5) */ - /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ - ptr = HW_SCE_RSA_2048_DATA_BYTE_SIZE - key_size; - ptr_start = ptr; - - /* (1) */ - if (0x00 != output_data_arry[ptr]) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - ptr++; - - /* (2) */ - if (0x02 != output_data_arry[ptr]) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - ptr++; - - /* (3) and (4) */ - p_start = &output_data_arry[ptr]; - - /* Casting uint8_t pointer is used for address. */ - p_zero_ptr = (uint8_t *) memchr(p_start, 0x00, key_size - 2); /* "2" is (1)+(2) */ - if (NULL == p_zero_ptr) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - if ((HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE - 3) > (uint32_t) (p_zero_ptr - p_start)) - { - return FSP_ERR_CRYPTO_SCE_FAIL; - } - - ptr += (uint32_t) ((p_zero_ptr - p_start) + 1); - - plain->data_length = key_size - (ptr - ptr_start); - memcpy(plain->pdata, &output_data_arry[ptr], plain->data_length); - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * The R_SCE_RSAES_PKCS4096_Encrypt() function RSA-encrypts the plaintext input to the first argument, plain, - * according to RSAES-PKCS1-V1_5. It writes the encryption result to the second argument, cipher. - * - * @param[in] plain plaintext - * @arg plain->pdata : Specifies pointer to array containing plaintext. - * @arg plain->data_length : Specifies valid data length of plaintext array. - * data size <= public key n size - 11 - * @param[in,out] cipher ciphertext - * @arg cipher->pdata : Specifies pointer to array containing ciphertext. - * @arg cipher->data_length : Inputs ciphertext buffer size. - * Outputs valid data length after encryption - * (public key n size). - * @param[in] wrapped_key Inputs the 4096-bit RSA public wrapped key. - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL Incorrect wrapped key was input. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input data is illegal. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_RSAES_PKCS4096_Encrypt (sce_rsa_byte_data_t * plain, - sce_rsa_byte_data_t * cipher, - sce_rsa4096_public_wrapped_key_t * wrapped_key) -{ - fsp_err_t ercd = FSP_SUCCESS; - uint8_t input_data_arry[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = - { - 0 - }; - uint8_t output_data_arry[HW_SCE_RSA_4096_DATA_BYTE_SIZE] = - { - 0 - }; - uint32_t key_size = 0; - uint32_t ptr = 0; - - /* Casting uint32_t pointer is used for address. */ - key_size = get_keyn_size((uint32_t *) &wrapped_key->value.key_n, HW_SCE_RSA_4096_DATA_BYTE_SIZE); - if (key_size < HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if ((plain->data_length) > (key_size - HW_SCE_RSA_RSAES_PKCS_MIN_KEY_N_BYTE_SIZE)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (cipher->data_length < key_size) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - cipher->data_length = key_size; - - /*** RSAES-PKCS#1_V1.5 format ***/ - /* (1) | (2) | (3) | (4) | (5) */ - /* EM = [0x00] | [0x02] | [PS] | [0x00] | [M] */ - ptr = HW_SCE_RSA_4096_DATA_BYTE_SIZE - key_size; - input_data_arry[ptr] = 0x00; - ptr++; - input_data_arry[ptr] = 0x02; - ptr++; - - get_rand_rsaes_pkcs(((key_size - plain->data_length) - 3), &input_data_arry[ptr]); - ptr += ((key_size - plain->data_length) - 3); - input_data_arry[ptr] = 0x00; - ptr++; - - memcpy(&input_data_arry[ptr], plain->pdata, plain->data_length); - - ercd = R_SCE_Rsa4096ModularExponentEncryptPrivate( - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) &wrapped_key->value, - (uint32_t *) (input_data_arry), - (uint32_t *) (output_data_arry)); - memcpy(cipher->pdata, &output_data_arry[HW_SCE_RSA_4096_DATA_BYTE_SIZE - key_size], cipher->data_length); - - return ercd; -} - -/*******************************************************************************************************************//** - * @} (end addtogroup SCE_PROTECTED) - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private Functions - **********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * Hash message text according to the hash type. - * - * @param p_mes message text - * @param p_hash pointer of hash data - * @param mes_len message size(byte) - * @param hash_type hash type - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input parameter illegal - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - **********************************************************************************************************************/ -static fsp_err_t calc_hash_data (uint8_t * p_mes, uint8_t * p_hash, uint32_t mes_len, uint8_t hash_type) -{ - fsp_err_t error_code = FSP_SUCCESS; - sce_sha_md5_handle_t ex_sha_handle = - { - 0 - }; - uint32_t hash_length = 0; - - if (HW_SCE_RSA_HASH_SHA256 == hash_type) - { - R_SCE_SHA256_Init(&ex_sha_handle); - error_code = R_SCE_SHA256_Update(&ex_sha_handle, p_mes, mes_len); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - - error_code = R_SCE_SHA256_Final(&ex_sha_handle, p_hash, &hash_length); - } - - return error_code; -} - -/*******************************************************************************************************************//** - * Prefix the hash of the message according to RSASSA-PKCS1-V1_5. - * - * @param p_message_hash message text or hash value - * @param hash_type hash type - * @param rsa_key_byte_size RSA data size - * @param data_buff pointer of Sig data - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER Input parameter illegal - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - **********************************************************************************************************************/ -static fsp_err_t set_rsassapkcs_hash_data (sce_rsa_byte_data_t * p_message_hash, - uint8_t hash_type, - uint32_t rsa_key_byte_size, - uint8_t * data_buff) -{ - fsp_err_t error_code = FSP_SUCCESS; - sce_rsa_byte_data_t prefix = - { - 0 - }; - uint32_t hash_data_buff[HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t)] = - { - 0 - }; - uint32_t hash_length = 0; - uint32_t data_ptr = 0; - - if ((HW_SCE_RSA_HASH_SHA256 < hash_type) || (1 < p_message_hash->data_type)) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - if (0 == p_message_hash->data_type) - { - /* Casting uint8_t pointer is used for address. */ - error_code = calc_hash_data(p_message_hash->pdata, - (uint8_t *) hash_data_buff, - p_message_hash->data_length, - hash_type); - if (FSP_SUCCESS != error_code) - { - return error_code; - } - } - - if (HW_SCE_RSA_HASH_SHA256 == hash_type) - { - prefix.pdata = gs_rsa_sig_sha256_prefix; - prefix.data_length = sizeof(gs_rsa_sig_sha256_prefix); - hash_length = HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE; - } - - data_buff[0] = 0x00; - data_buff[1] = 0x01; - data_ptr = ((rsa_key_byte_size - prefix.data_length) - hash_length) - 1; - memset(data_buff + 2, SCE_HEX_FF, data_ptr); - data_buff[data_ptr] = 0x0; - data_ptr++; - memcpy(data_buff + data_ptr, prefix.pdata, prefix.data_length); - data_ptr += prefix.data_length; - if (0 == p_message_hash->data_type) - { - memcpy(data_buff + data_ptr, hash_data_buff, hash_length); - } - else /* if (1 == p_message_hash->data_type) */ - { - memcpy(data_buff + data_ptr, p_message_hash->pdata, hash_length); - } - - return FSP_SUCCESS; -} - -/*******************************************************************************************************************//** - * Get key n size from RSA key index - * - * @param prsa_key_index RSA key index - * @param key_max_size key data max byte size - * - * @return key_size - **********************************************************************************************************************/ -static uint32_t get_keyn_size (uint32_t * prsa_key_index, uint32_t key_max_size) -{ - bool get_output_data_length = false; - - /* Casting uint8_t pointer is used for address. */ - uint8_t * p_rsa_key_n_data = (uint8_t *) prsa_key_index; - uint32_t key_size_tmp = 0; - - key_size_tmp = key_max_size; - for (uint32_t i = 0; i < (key_max_size); i++) - { - if (!get_output_data_length) - { - if (0 == p_rsa_key_n_data[i]) - { - key_size_tmp--; - } - else - { - get_output_data_length = true; - } - } - } - - return key_size_tmp; -} - -/*******************************************************************************************************************//** - * In accordance with RSAES-PKCS1-V1_5 to obtain random number data of rand_size that does not contain 0. - * - * @param rand_size random data size - * @param prand_data random data area pointer - * - * @retval FSP_SUCCESS Normal termination. - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT resource conflict - **********************************************************************************************************************/ -static fsp_err_t get_rand_rsaes_pkcs (uint32_t rand_size, uint8_t * prand_data) -{ - fsp_err_t ercd = FSP_SUCCESS; - uint8_t rand_tmp[16] = - { - 0 - }; - uint32_t rest_size = rand_size; - uint32_t rand_ptr = 0; - uint32_t i = 0; - - while (rest_size) - { -#if defined RSA_ENC_TEST_MODE - memset(rand_tmp, SCE_HEX_FF, sizeof(rand_tmp)); -#else - - /* Casting uint32_t pointer is used for address. */ - ercd = R_SCE_RandomNumberGenerate((uint32_t *) rand_tmp); - if (FSP_SUCCESS != ercd) - { - break; - } -#endif /* defined RSA_ENC_TEST_MODE */ - for (i = 0; i < 16; i++) - { - if (0 != rand_tmp[i]) - { - prand_data[rand_ptr] = rand_tmp[i]; - rand_ptr++; - rest_size--; - } - - if (0 == rest_size) - { - break; - } - } - } - - return ercd; -} diff --git a/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_sha.c b/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_sha.c deleted file mode 100644 index 2ba105dc6..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/r_sce/public/r_sce_sha.c +++ /dev/null @@ -1,447 +0,0 @@ -/********************************************************************************************************************** - * DISCLAIMER - * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No - * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all - * applicable laws, including copyright laws. - * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING - * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM - * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES - * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO - * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of - * this software. By using this software, you agree to the additional terms and conditions found by accessing the - * following link: - * http://www.renesas.com/disclaimer - * - * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. - *********************************************************************************************************************/ -/********************************************************************************************************************** - * File Name : r_sce_sha.c - * Version : 1.0 - * Description : SCE Hash Public API source file - *********************************************************************************************************************/ -/********************************************************************************************************************** - * History : DD.MM.YYYY Version Description - * : 03.31.2022 1.00 First Release - *********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Includes - **********************************************************************************************************************/ -#include "r_sce_private.h" -#include - -/*********************************************************************************************************************** - * Macro definitions - **********************************************************************************************************************/ - -/* Block length (in bytes) of SHA */ -#define SHA_BLOCK8_LEN (64U) - -/* Initialization function call state */ -#define CALL_ONLY_INIT (0) -#define CALL_ONLY_UPDATE_FINAL (1) - -#ifndef SCE_HEX_FF -#define SCE_HEX_FF (0xff) -#endif -#ifndef SCE_HEX_80 -#define SCE_HEX_80 (0x80) -#endif -#ifndef SCE_DEC_32 -#define SCE_DEC_32 (32) -#endif -#ifndef SCE_DEC_64 -#define SCE_DEC_64 (64) -#endif - -/*********************************************************************************************************************** - * Typedef definitions - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private function prototypes - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private global variables - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Global variables - **********************************************************************************************************************/ -extern uint32_t g_private_id_counter; -uint32_t g_sha224_private_id; -uint32_t g_sha256_private_id; - -/*******************************************************************************************************************//** - * @addtogroup SCE_PROTECTED - * @{ - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Functions - **********************************************************************************************************************/ - -/*******************************************************************************************************************//** - * The R_SCE_SHA224_Init() function performs preparations for the execution of an SHA-224 hash calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument in the subsequent - * R_SCE_SHA224_Update() function and R_SCE_SHA224_Final() function. - * - * @param[in,out] handle SHA handler (work area) - * - * @retval FSP_SUCCESS Normal termination - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_SHA224_Init (sce_sha_md5_handle_t * handle) -{ - memset(handle, 0, sizeof(sce_sha_md5_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_sha224_private_id = g_private_id_counter; - handle->id = g_sha224_private_id; - memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); - - return R_SCE_Sha224InitPrivate(handle); -} - -/*******************************************************************************************************************//** - * The R_SCE_SHA224_Update() function calculates a hash value based on the second argument, message, - * and the third argument, message_length, and writes the ongoing status to the first argument, handle. - * After message input is completed, call R_SCE_SHA224_Final(). - * - * @param[in,out] handle SHA handler (work area) - * @param[in] message message data area - * @param[in] message_length message data length - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_SHA224_Update (sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length) -{ - fsp_err_t ercd = FSP_SUCCESS; - uint32_t length_rest = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_sha224_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->all_received_length += message_length; - if ((handle->buffering_length + message_length) >= SHA_BLOCK8_LEN) - { - memcpy(handle->sha_buffer + handle->buffering_length, message, SHA_BLOCK8_LEN - handle->buffering_length); - - /*Casting uint32_t pointer is used for address.*/ - ercd = R_SCE_Sha224UpdatePrivate(handle, (uint32_t *) (handle->sha_buffer), SHA_BLOCK8_LEN >> 2); - length_rest = message_length - (SHA_BLOCK8_LEN - handle->buffering_length); - memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); - if (length_rest >= SHA_BLOCK8_LEN) - { - ercd = R_SCE_Sha224UpdatePrivate(handle, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (message + (SHA_BLOCK8_LEN - handle->buffering_length)), - ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN) >> 2); - length_rest -= ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN); - } - - handle->buffering_length = 0; - memcpy(handle->sha_buffer, message + (message_length - length_rest), length_rest); - handle->buffering_length = length_rest; - } - else - { - memcpy(handle->sha_buffer + handle->buffering_length, message, message_length); - handle->buffering_length += message_length; - } - - return ercd; -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_SHA224_Final() function writes the calculation - * result to the second argument, digest, and writes the length of the calculation result to the third argument, - * digest_length. - * - * @param[in,out] handle SHA handler (work area) - * @param[in,out] digest hasha data area - * @param[in,out] digest_length hash data length (32bytes) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_SHA224_Final (sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length) -{ - uint32_t max_cnt_byte = 0; - fsp_err_t ercd = FSP_SUCCESS; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_sha224_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->sha_buffer[handle->buffering_length] = SCE_HEX_80; - if ((SHA_BLOCK8_LEN - handle->buffering_length) >= 9) /* another block unnecessary */ - { - memset(handle->sha_buffer + (handle->buffering_length + 1), 0, - (SHA_BLOCK8_LEN - 4) - (handle->buffering_length + 1)); - - /* According c., but support only l < 2**32 case */ - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 3] = (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 2] = (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); - max_cnt_byte = SHA_BLOCK8_LEN; - } - else - { - /* another block necessary */ - memset(handle->sha_buffer + (handle->buffering_length + 1), 0, - ((2 * SHA_BLOCK8_LEN) - 4) - (handle->buffering_length + 1)); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 3] = - (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 2] = - (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); - max_cnt_byte = 2 * SHA_BLOCK8_LEN; - } - - ercd = R_SCE_Sha224FinalPrivate(handle, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (handle->sha_buffer), - max_cnt_byte >> 2, - (uint32_t *) (digest), - digest_length); - handle->all_received_length = 0; - handle->buffering_length = 0; - memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); - - return ercd; -} - -/*******************************************************************************************************************//** - * The R_SCE_SHA256_Init() function performs preparations for the execution of an SHA-256 hash calculation, - * and writes the result to the first argument, handle. The value of handle is used as an argument in the subsequent - * R_SCE_SHA256_Update() function and R_SCE_SHA256_Final() function. - * - * @param[in,out] handle SHA handler (work area) - * - * @retval FSP_SUCCESS Normal termination - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_SHA256_Init (sce_sha_md5_handle_t * handle) -{ - memset(handle, 0, sizeof(sce_sha_md5_handle_t)); - handle->flag_call_init = CALL_ONLY_UPDATE_FINAL; - g_private_id_counter++; - g_sha256_private_id = g_private_id_counter; - handle->id = g_sha256_private_id; - memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); - - return R_SCE_Sha256InitPrivate(handle); -} - -/*******************************************************************************************************************//** - * The R_SCE_SHA256_Update() function calculates a hash value based on the second argument, message, - * and the third argument, message_length, and writes the ongoing status to the first argument, handle. - * After message input is completed, call R_SCE_SHA256_Final(). - * - * @param[in,out] handle SHA handler (work area) - * @param[in] message message data area - * @param[in] message_length message data length - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_SHA256_Update (sce_sha_md5_handle_t * handle, uint8_t * message, uint32_t message_length) -{ - fsp_err_t ercd = FSP_SUCCESS; - uint32_t length_rest = 0; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - if (handle->id != g_sha256_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->all_received_length += message_length; - if ((handle->buffering_length + message_length) >= SHA_BLOCK8_LEN) - { - memcpy(handle->sha_buffer + handle->buffering_length, message, SHA_BLOCK8_LEN - handle->buffering_length); - - /*Casting uint32_t pointer is used for address.*/ - ercd = R_SCE_Sha256UpdatePrivate(handle, (uint32_t *) (handle->sha_buffer), SHA_BLOCK8_LEN >> 2); - length_rest = message_length - (SHA_BLOCK8_LEN - handle->buffering_length); - memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); - if (length_rest >= SHA_BLOCK8_LEN) - { - ercd = R_SCE_Sha256UpdatePrivate(handle, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (message + (SHA_BLOCK8_LEN - handle->buffering_length)), - ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN) >> 2); - length_rest -= ((length_rest / SHA_BLOCK8_LEN) * SHA_BLOCK8_LEN); - } - - handle->buffering_length = 0; - memcpy(handle->sha_buffer, message + (message_length - length_rest), length_rest); - handle->buffering_length = length_rest; - } - else - { - memcpy(handle->sha_buffer + handle->buffering_length, message, message_length); - handle->buffering_length += message_length; - } - - return ercd; -} - -/*******************************************************************************************************************//** - * Using the handle specified in the first argument, handle, the R_SCE_SHA256_Final() function writes the calculation - * result to the second argument, digest, and writes the length of the calculation result to the third argument, - * digest_length. - * - * @param[in,out] handle SHA handler (work area) - * @param[in,out] digest hasha data area - * @param[in,out] digest_length hash data length (32bytes) - * - * @retval FSP_SUCCESS Normal termination - * @retval FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT A resource conflict occurred because a hardware resource needed - * by the processing routine was in use by another processing routine. - * @retval FSP_ERR_CRYPTO_SCE_PARAMETER An invalid handle was input. - * @retval FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION An invalid function was called. - * - * @note The pre-run state is SCE Enabled State. - * After the function runs the state transitions to SCE Enabled State. - **********************************************************************************************************************/ -fsp_err_t R_SCE_SHA256_Final (sce_sha_md5_handle_t * handle, uint8_t * digest, uint32_t * digest_length) -{ - uint32_t max_cnt_byte = 0; - fsp_err_t ercd = FSP_SUCCESS; - - if (CALL_ONLY_INIT == handle->flag_call_init) - { - return FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION; - } - - handle->flag_call_init = CALL_ONLY_INIT; - if (handle->id != g_sha256_private_id) - { - return FSP_ERR_CRYPTO_SCE_PARAMETER; - } - - handle->sha_buffer[handle->buffering_length] = SCE_HEX_80; - if ((SHA_BLOCK8_LEN - handle->buffering_length) >= 9) /* another block unnecessary */ - { - memset(handle->sha_buffer + (handle->buffering_length + 1), 0, - (SHA_BLOCK8_LEN - 4) - (handle->buffering_length + 1)); - - /* According c., but support only l < 2**32 case */ - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 3] = (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 2] = (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[SHA_BLOCK8_LEN - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); - max_cnt_byte = SHA_BLOCK8_LEN; - } - else - { - /* another block necessary */ - memset(handle->sha_buffer + (handle->buffering_length + 1), 0, - ((2 * SHA_BLOCK8_LEN) - 4) - (handle->buffering_length + 1)); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 4] = (uint8_t) ((handle->all_received_length * 8) >> 24); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 3] = - (uint8_t) (((handle->all_received_length * 8) >> 16) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 2] = - (uint8_t) (((handle->all_received_length * 8) >> 8) & SCE_HEX_FF); - - /* Casting uint32_t data to uint8_t data array. */ - handle->sha_buffer[(2 * SHA_BLOCK8_LEN) - 1] = (uint8_t) ((handle->all_received_length * 8) & SCE_HEX_FF); - max_cnt_byte = 2 * SHA_BLOCK8_LEN; - } - - ercd = R_SCE_Sha256FinalPrivate(handle, - /* Casting uint32_t pointer is used for address. */ - (uint32_t *) (handle->sha_buffer), - max_cnt_byte >> 2, - (uint32_t *) (digest), - digest_length); - handle->all_received_length = 0; - handle->buffering_length = 0; - memset(handle->sha_buffer, 0, sizeof(handle->sha_buffer)); - - return ercd; -} - -/*******************************************************************************************************************//** - * @} (end addtogroup SCE_PROTECTED) - **********************************************************************************************************************/ - -/*********************************************************************************************************************** - * Private Functions - **********************************************************************************************************************/ diff --git a/core/arch/arm/plat-rz/g2l/drivers/r_sce/sub.mk b/core/arch/arm/plat-rz/g2l/drivers/r_sce/sub.mk deleted file mode 100644 index e897784f0..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/r_sce/sub.mk +++ /dev/null @@ -1,11 +0,0 @@ -srcs-y += public/r_sce_aes.c -srcs-y += public/r_sce_ecc.c -srcs-y += public/r_sce_rsa.c -srcs-y += public/r_sce_sha.c -srcs-y += public/r_sce.c -srcs-y += private/r_sce_private.c -global-incdirs-y += private/inc -global-incdirs-y += inc/api -global-incdirs-y += inc/instances - -ldflags-external += $(CFG_RZ_SCE_LIB_DIR)/libr_secure_ip_1_0.a.1.0.0 diff --git a/core/arch/arm/plat-rz/g2l/drivers/sce.c b/core/arch/arm/plat-rz/g2l/drivers/sce.c deleted file mode 100644 index 1266c3135..000000000 --- a/core/arch/arm/plat-rz/g2l/drivers/sce.c +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2021, Renesas Electronics - */ -#include -#include -#include -#include -#include -#include - -#include - -register_phys_mem_pgdir(MEM_AREA_IO_SEC, HW_SCE_BASE, HW_SCE_SIZE); - -static sce_cfg_t sce_cfg; -static sce_instance_ctrl_t sce_instance_ctrl; - -static TEE_Result SCE_Init(void) -{ - fsp_err_t err; - - int32_t retry_cnt = 3; - - gp_sce = (uint32_t *) phys_to_virt_io(HW_SCE_BASE, HW_SCE_SIZE); - - while (0 < retry_cnt) - { - err = g_sce_protected_on_sce.open(&sce_instance_ctrl, &sce_cfg); - switch (err) - { - case FSP_ERR_CRYPTO_SCE_RETRY: - retry_cnt--; - break; - default: - retry_cnt = 0; - break; - } - } - - if (FSP_SUCCESS != err) - { - EMSG("Failed to initialize SCE (0x%08x).", err); - panic(); - } - - return TEE_SUCCESS; -} - -driver_init(SCE_Init); diff --git a/core/arch/arm/plat-rz/g2l/drivers/sub.mk b/core/arch/arm/plat-rz/g2l/drivers/sub.mk index e63cf8379..381408239 100644 --- a/core/arch/arm/plat-rz/g2l/drivers/sub.mk +++ b/core/arch/arm/plat-rz/g2l/drivers/sub.mk @@ -1,7 +1,3 @@ global-incdirs-y += . srcs-y += cpg.c srcs-y += sflash.c -srcs-$(CFG_RZ_SCE) += sce.c - -subdirs-y += spi_multi -subdirs-$(CFG_RZ_SCE) += r_sce diff --git a/core/arch/arm/plat-rz/g2l/pta/include/pta_flash.h b/core/arch/arm/plat-rz/g2l/pta/include/pta_flash.h deleted file mode 100644 index 7cc975e96..000000000 --- a/core/arch/arm/plat-rz/g2l/pta/include/pta_flash.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2021, Renesas Electronics Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef PTA_FLASH_H_ -#define PTA_FLASH_H_ - -#define FLASH_UUID \ - { \ - 0x2c0fca92, 0x5ab1, 0x11eb, \ - { \ - 0x81, 0x53, 0xc7, 0xd7, 0x50, 0xe0, 0xae, 0x47 \ - } \ - } - -/* - * FLASH_CMD_WRITE_SPI - Write data to SPI Flash - * param[0] (value) spi save address - * param[1] (memref) write data buffer - * param[2] unused - * param[3] unused - */ -#define FLASH_CMD_WRITE_SPI 1 - -#endif /* PTA_FLASH_H_ */ diff --git a/core/arch/arm/plat-rz/g2l/pta/include/pta_sce.h b/core/arch/arm/plat-rz/g2l/pta/include/pta_sce.h deleted file mode 100644 index 790d6c60e..000000000 --- a/core/arch/arm/plat-rz/g2l/pta/include/pta_sce.h +++ /dev/null @@ -1,179 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ -#ifndef __PTA_SCE_H -#define __PTA_SCE_H - -#include - -#define PTA_SCE_UUID \ - { 0x3b221d77, 0xe679, 0x4ca5, \ - { 0xa4, 0x48, 0x1f, 0x9f, 0x16, 0x02, 0x15, 0xc5 } } - -/* - * [in/out] memref[0] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES128_WrappedKeyGenerate (0x00010000) - -/* - * [in/out] memref[0] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES256_WrappedKeyGenerate (0x00010100) - -/* - * [in/out] memref[0] : Wrapped key (sce_rsa1024_wrapped_pair_key_t) - */ -#define PTA_CMD_RSA1024_WrappedKeyPairGenerate (0x00011000) - -/* - * [in/out] memref[0] : Wrapped key (sce_rsa2048_wrapped_pair_key_t) - */ -#define PTA_CMD_RSA2048_WrappedKeyPairGenerate (0x00011100) - -/* - * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) - */ -#define PTA_CMD_ECC_secp192r1_WrappedKeyPairGenerate (0x00012000) - -/* - * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) - */ -#define PTA_CMD_ECC_secp224r1_WrappedKeyPairGenerate (0x00012100) - -/* - * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) - */ -#define PTA_CMD_ECC_secp256r1_WrappedKeyPairGenerate (0x00012200) - -/* - * [in/out] memref[0] : Wrapped key (sce_ecc_wrapped_pair_key_t) - */ -#define PTA_CMD_ECC_BrainpoolP512r1_WrappedKeyPairGenerate (0x00013000) - -/* - * [in/out] memref[0] : random data (16byte) - */ -#define PTA_CMD_RandomNumberGenerate (0x00014000) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (32byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES128_EncryptedKeyWrap (0x00015000) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (64byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES256_EncryptedKeyWrap (0x00015100) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (160byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_rsa1024_public_wrapped_key_t) - */ -#define PTA_CMD_RSA1024_EncryptedPublicKeyWrap (0x00016000) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (272byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_rsa1024_private_wrapped_key_t) - */ -#define PTA_CMD_RSA1024_EncryptedPrivateKeyWrap (0x00016010) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (288byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_rsa2048_public_wrapped_key_t) - */ -#define PTA_CMD_RSA2048_EncryptedPublicKeyWrap (0x00016100) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (528byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_rsa2048_private_wrapped_key_t) - */ -#define PTA_CMD_RSA2048_EncryptedPrivateKeyWrap (0x00016110) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (544byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_rsa4096_public_wrapped_key_t) - */ -#define PTA_CMD_RSA4096_EncryptedPublicKeyWrap (0x00016200) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (80byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) - */ -#define PTA_CMD_ECC_secp192r1_EncryptedPublicKeyWrap (0x00017000) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (48byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) - */ -#define PTA_CMD_ECC_secp192r1_EncryptedPrivateKeyWrap (0x00017010) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (80byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) - */ -#define PTA_CMD_ECC_secp224r1_EncryptedPublicKeyWrap (0x00017100) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (48byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) - */ -#define PTA_CMD_ECC_secp224r1_EncryptedPrivateKeyWrap (0x00017110) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (80byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) - */ -#define PTA_CMD_ECC_secp256r1_EncryptedPublicKeyWrap (0x00017200) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (48byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) - */ -#define PTA_CMD_ECC_secp256r1_EncryptedPrivateKeyWrap (0x00017210) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (144byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_public_wrapped_key_t) - */ -#define PTA_CMD_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap (0x00018000) - -/* - * [in] memref[0] : Initial vector (16byte) - * [in] memref[1] : Encrypted Key (80byte) - * [in] memref[2] : Key Update Key (sce_key_update_key_t) - * [in/out] memref[3] : Wrapped key (sce_ecc_private_wrapped_key_t) - */ -#define PTA_CMD_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap (0x00018010) - -#endif /* __PTA_SCE_H */ diff --git a/core/arch/arm/plat-rz/g2l/pta/include/pta_sce_aes.h b/core/arch/arm/plat-rz/g2l/pta/include/pta_sce_aes.h deleted file mode 100644 index 7d552797b..000000000 --- a/core/arch/arm/plat-rz/g2l/pta/include/pta_sce_aes.h +++ /dev/null @@ -1,279 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ -#ifndef __PTA_SCE_AES_H -#define __PTA_SCE_AES_H - -#include - -#define PTA_SCE_AES_UUID \ - { 0x4be7b9c4, 0x4951, 0x4105, \ - { 0xa3, 0xd3, 0x08, 0x1b, 0x50, 0x98, 0x10, 0xef } } - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES128ECB_EncryptInit (0x00020001) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : plain (length must be a multiple of 16) - * [in/out] memref[2] : cipher - */ -#define PTA_CMD_AES128ECB_EncryptUpdate (0x00020002) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES128ECB_EncryptFinal (0x00020003) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES128ECB_DecryptInit (0x00020011) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : cipher (length must be a multiple of 16) - * [in/out] memref[2] : plain - */ -#define PTA_CMD_AES128ECB_DecryptUpdate (0x00020012) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES128ECB_DecryptFinal (0x00020013) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES256ECB_EncryptInit (0x00020101) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : plain (length must be a multiple of 16) - * [in/out] memref[2] : cipher - */ -#define PTA_CMD_AES256ECB_EncryptUpdate (0x00020102) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES256ECB_EncryptFinal (0x00020103) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES256ECB_DecryptInit (0x00020111) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : cipher (length must be a multiple of 16) - * [in/out] memref[2] : plain - */ -#define PTA_CMD_AES256ECB_DecryptUpdate (0x00020112) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES256ECB_DecryptFinal (0x00020113) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES128CBC_EncryptInit (0x00021001) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : plain (length must be a multiple of 16) - * [in/out] memref[2] : cipher - */ -#define PTA_CMD_AES128CBC_EncryptUpdate (0x00021002) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES128CBC_EncryptFinal (0x00021003) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES128CBC_DecryptInit (0x00021011) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : cipher (length must be a multiple of 16) - * [in/out] memref[2] : plain - */ -#define PTA_CMD_AES128CBC_DecryptUpdate (0x00021012) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES128CBC_DecryptFinal (0x00021013) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES256CBC_EncryptInit (0x00021101) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : plain (length must be a multiple of 16) - * [in/out] memref[2] : cipher - */ -#define PTA_CMD_AES256CBC_EncryptUpdate (0x00021102) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES256CBC_EncryptFinal (0x00021103) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES256CBC_DecryptInit (0x00021111) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : cipher (length must be a multiple of 16) - * [in/out] memref[2] : plain - */ -#define PTA_CMD_AES256CBC_DecryptUpdate (0x00021112) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES256CBC_DecryptFinal (0x00021113) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES128CTR_EncryptInit (0x00022001) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : plain (length must be a multiple of 16) - * [in/out] memref[2] : cipher - */ -#define PTA_CMD_AES128CTR_EncryptUpdate (0x00022002) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES128CTR_EncryptFinal (0x00022003) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES128CTR_DecryptInit (0x00022011) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : cipher (length must be a multiple of 16) - * [in/out] memref[2] : plain - */ -#define PTA_CMD_AES128CTR_DecryptUpdate (0x00022012) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES128CTR_DecryptFinal (0x00022013) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES256CTR_EncryptInit (0x00022101) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : plain (length must be a multiple of 16) - * [in/out] memref[2] : cipher - */ -#define PTA_CMD_AES256CTR_EncryptUpdate (0x00022102) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES256CTR_EncryptFinal (0x00022103) - -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - * [in] memref[2] : Initial Vector(16byte) - */ -#define PTA_CMD_AES256CTR_DecryptInit (0x00022111) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - * [in] memref[1] : cipher (length must be a multiple of 16) - * [in/out] memref[2] : plain - */ -#define PTA_CMD_AES256CTR_DecryptUpdate (0x00022112) -/* - * [in/out] memref[0] : AES handler (sce_aes_handle_t) - */ -#define PTA_CMD_AES256CTR_DecryptFinal (0x00022113) - -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES128CMAC_GenerateInit (0x00023001) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : message - */ -#define PTA_CMD_AES128CMAC_GenerateUpdate (0x00023002) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in/out] memref[1] : mac (16byte) - */ -#define PTA_CMD_AES128CMAC_GenerateFinal (0x00023003) - -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES128CMAC_VerifyInit (0x00023011) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : message - */ -#define PTA_CMD_AES128CMAC_VerifyUpdate (0x00023012) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : mac (2 to 16bytes) - */ -#define PTA_CMD_AES128CMAC_VerifyFinal (0x00023013) - -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES256CMAC_GenerateInit (0x00023101) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : message - */ -#define PTA_CMD_AES256CMAC_GenerateUpdate (0x00023102) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in/out] memref[1] : mac (16byte) - */ -#define PTA_CMD_AES256CMAC_GenerateFinal (0x00023103) - -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : Wrapped key (sce_aes_wrapped_key_t) - */ -#define PTA_CMD_AES256CMAC_VerifyInit (0x00023111) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : message - */ -#define PTA_CMD_AES256CMAC_VerifyUpdate (0x00023112) -/* - * [in/out] memref[0] : CMAC handler (sce_cmac_handle_t) - * [in] memref[1] : mac (2 to 16bytes) - */ -#define PTA_CMD_AES256CMAC_VerifyFinal (0x00023113) - - -#endif /* __PTA_SCE_AES_H */ diff --git a/core/arch/arm/plat-rz/g2l/pta/include/pta_sce_rsa.h b/core/arch/arm/plat-rz/g2l/pta/include/pta_sce_rsa.h deleted file mode 100644 index 97bcc9298..000000000 --- a/core/arch/arm/plat-rz/g2l/pta/include/pta_sce_rsa.h +++ /dev/null @@ -1,84 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ -#ifndef __PTA_SCE_RSA_H -#define __PTA_SCE_RSA_H - -#include - -#define PTA_SCE_RSA_UUID \ - { 0x5ad57120, 0xc447, 0x4b17, \ - { 0x90, 0x7b, 0x03, 0x1a, 0xd8, 0xd9, 0xb1, 0x7c } } - -/* - * [in] memref[0] : Message - * [in/out] memref[1] : Signature (128byte) - * [in] memref[2] : Wrapped key (sce_rsa1024_private_wrapped_key_t) - */ -#define PTA_CMD_RSASSA_PKCS1024_SignatureGenerate (0x00040000) - -/* - * [in] memref[0] : Signature (128byte) - * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_rsa1024_public_wrapped_key_t) - */ -#define PTA_CMD_RSASSA_PKCS1024_SignatureVerify (0x00040010) - -/* - * [in] memref[0] : Message - * [in/out] memref[1] : Signature (256byte) - * [in] memref[2] : Wrapped key (sce_rsa2048_private_wrapped_key_t) - */ -#define PTA_CMD_RSASSA_PKCS2048_SignatureGenerate (0x00040100) - -/* - * [in] memref[0] : Signature (256byte) - * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_rsa2048_public_wrapped_key_t) - */ -#define PTA_CMD_RSASSA_PKCS2048_SignatureVerify (0x00040110) - -/* - * [in] memref[0] : Signature (512byte) - * [in] memref[1] : Message - * [in] memref[2] : Wrapped key (sce_rsa4096_public_wrapped_key_t) - */ -#define PTA_CMD_RSASSA_PKCS4096_SignatureVerify (0x00040210) - -/* - * [in] memref[0] : plain (size <= public key n size - 11 byte) - * [in/out] memref[1] : cipher (size >= public key n byte) - * [in] memref[2] : Wrapped key (sce_rsa1024_public_wrapped_key_t) - */ -#define PTA_CMD_RSAES_PKCS1024_Encrypt (0x00041000) - -/* - * [in] memref[0] : cipher (size == public key n byte) - * [in/out] memref[1] : plain (size >= public key n - 11 byte) - * [in] memref[2] : Wrapped key (sce_rsa1024_private_wrapped_key_t) - */ -#define PTA_CMD_RSAES_PKCS1024_Decrypt (0x00041010) - -/* - * [in] memref[0] : plain (size <= public key n - 11 byte) - * [in/out] memref[1] : cipher (size >= public key n byte) - * [in] memref[2] : Wrapped key (sce_rsa2048_public_wrapped_key_t) - */ -#define PTA_CMD_RSAES_PKCS2048_Encrypt (0x00041100) - -/* - * [in] memref[0] : cipher (size == public key n byte) - * [in/out] memref[1] : plain (size >= public key n - 11 byte) - * [in] memref[2] : Wrapped key (sce_rsa2048_private_wrapped_key_t) - */ -#define PTA_CMD_RSAES_PKCS2048_Decrypt (0x00041110) - -/* - * [in] memref[0] : plain (size <= public key n - 11 byte) - * [in/out] memref[1] : cipher (size >= public key n byte) - * [in] memref[2] : Wrapped key (sce_rsa4096_public_wrapped_key_t) - */ -#define PTA_CMD_RSAES_PKCS4096_Encrypt (0x00041200) - -#endif /* __PTA_SCE_RSA_H */ diff --git a/core/arch/arm/plat-rz/g2l/pta/include/pta_sce_sha.h b/core/arch/arm/plat-rz/g2l/pta/include/pta_sce_sha.h deleted file mode 100644 index 414bb53d1..000000000 --- a/core/arch/arm/plat-rz/g2l/pta/include/pta_sce_sha.h +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ -#ifndef __PTA_SCE_SHA_H -#define __PTA_SCE_SHA_H - -#include - -#define PTA_SCE_SHA_UUID \ - { 0x5b6cecf4, 0x12ae, 0x4c0f, \ - { 0x94, 0xb5, 0xce, 0xcc, 0x5f, 0x48, 0x62, 0xe4 } } - -/* - * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) - */ -#define PTA_CMD_SHA224_Init (0x00030000) - -/* - * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) - * [in] memref[1] : Message - */ -#define PTA_CMD_SHA224_Update (0x00030001) - -/* - * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) - * [in/out] memref[1] : Digest (28byte) - */ -#define PTA_CMD_SHA224_Final (0x00030002) - -/* - * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) - */ -#define PTA_CMD_SHA256_Init (0x00030100) - -/* - * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) - * [in] memref[1] : Message - */ -#define PTA_CMD_SHA256_Update (0x00030101) - -/* - * [in/out] memref[0] : AES handler (sce_sha_md5_handle_t) - * [in/out] memref[1] : Digest (32byte) - */ -#define PTA_CMD_SHA256_Final (0x00030102) - -#endif /* __PTA_SCE_SHA_H */ diff --git a/core/arch/arm/plat-rz/g2l/pta/pta_flash.c b/core/arch/arm/plat-rz/g2l/pta/pta_flash.c deleted file mode 100644 index d5fb08b16..000000000 --- a/core/arch/arm/plat-rz/g2l/pta/pta_flash.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2021-2023, Renesas Electronics Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define TA_NAME "flash.ta" - -static TEE_Result spi_write(uint32_t param_types, TEE_Param p[TEE_NUM_PARAMS]) -{ - uint32_t exp_type = TEE_PARAM_TYPES(TEE_PARAM_TYPE_VALUE_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE); - - DMSG("has been called"); - - if (param_types != exp_type) - return TEE_ERROR_BAD_PARAMETERS; - - if (!IS_ALIGNED_WITH_TYPE(p[0].value.a, uint32_t)) - return TEE_ERROR_BAD_PARAMETERS; - - if (!IS_ALIGNED_WITH_TYPE(p[1].memref.buffer, uint32_t)) - return TEE_ERROR_BAD_PARAMETERS; - - if (0 < p[1].memref.size) { - sflash_open(); - - sflash_write_buffer(p[0].value.a, (uintptr_t)p[1].memref.buffer, p[1].memref.size); - - sflash_close(); - } - - return TEE_SUCCESS; -} - -/* - * Trusted Application Entry Points - */ -static TEE_Result create_ta(void) -{ - DMSG("create entry point for pseudo TA \"%s\"", TA_NAME); - return TEE_SUCCESS; -} - -static void destroy_ta(void) -{ - DMSG("destroy entry point for pseudo ta \"%s\"", TA_NAME); -} - -static TEE_Result open_session(uint32_t nParamTypes __unused, - TEE_Param pParams[TEE_NUM_PARAMS] __unused, - void **ppSessionContext __unused) -{ - DMSG("open entry point for pseudo ta \"%s\"", TA_NAME); - return TEE_SUCCESS; -} - -static void close_session(void *pSessionContext __unused) -{ - DMSG("close entry point for pseudo ta \"%s\"", TA_NAME); -} - -static TEE_Result invoke_command(void *psess __unused, - uint32_t cmd, uint32_t ptypes, - TEE_Param params[TEE_NUM_PARAMS]) -{ - switch (cmd) - { - case FLASH_CMD_WRITE_SPI: - return spi_write(ptypes, params); - default: - break; - } - return TEE_ERROR_BAD_PARAMETERS; -} - -pseudo_ta_register(.uuid = FLASH_UUID, .name = TA_NAME, - .flags = PTA_DEFAULT_FLAGS, - .create_entry_point = create_ta, - .destroy_entry_point = destroy_ta, - .open_session_entry_point = open_session, - .close_session_entry_point = close_session, - .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/g2l/pta/pta_sce.c b/core/arch/arm/plat-rz/g2l/pta/pta_sce.c deleted file mode 100644 index 86f44dca7..000000000 --- a/core/arch/arm/plat-rz/g2l/pta/pta_sce.c +++ /dev/null @@ -1,1170 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ - -#include - -#include -#include - -#define PTA_NAME "sce.pta" - -static TEE_Result aes128_wrappedkeygenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128_WrappedKeyGenerate(wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ - return TEE_ERROR_ACCESS_CONFLICT; - } - - params[0].memref.size = sizeof(sce_aes_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256_wrappedkeygenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256_WrappedKeyGenerate(wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ - return TEE_ERROR_ACCESS_CONFLICT; - } - - params[0].memref.size = sizeof(sce_aes_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa1024_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa1024_wrapped_pair_key_t * wrapped_pair_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_pair_key = (sce_rsa1024_wrapped_pair_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_pair_key) || (sizeof(sce_rsa1024_wrapped_pair_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA1024_WrappedKeyPairGenerate(wrapped_pair_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_rsa1024_wrapped_pair_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa2048_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa2048_wrapped_pair_key_t * wrapped_pair_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_pair_key = (sce_rsa2048_wrapped_pair_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_pair_key) || (sizeof(sce_rsa2048_wrapped_pair_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA2048_WrappedKeyPairGenerate(wrapped_pair_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_rsa2048_wrapped_pair_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp192r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecc_wrapped_pair_key_t * wrapped_pair_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp192r1_WrappedKeyPairGenerate(wrapped_pair_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp224r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecc_wrapped_pair_key_t * wrapped_pair_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp224r1_WrappedKeyPairGenerate(wrapped_pair_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp256r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecc_wrapped_pair_key_t * wrapped_pair_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp256r1_WrappedKeyPairGenerate(wrapped_pair_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_brainpoolp512r1_wrappedkeypairgenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecc_wrapped_pair_key_t * wrapped_pair_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_pair_key = (sce_ecc_wrapped_pair_key_t *)params[0].memref.buffer; - if ((NULL == wrapped_pair_key) || (sizeof(sce_ecc_wrapped_pair_key_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_BrainpoolP512r1_WrappedKeyPairGenerate(wrapped_pair_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_ecc_wrapped_pair_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result randomnumbergenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint32_t * random; - - const uint32_t random_length = 16; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - random = (uint32_t *)params[0].memref.buffer; - if ((NULL == random) || (random_length > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.randomNumberGenerate(random); - switch (err) - { - case FSP_SUCCESS: - break; - default: /* FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT */ - return TEE_ERROR_ACCESS_CONFLICT; - } - - params[0].memref.size = random_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128_encryptedkeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || ((SCE_OEM_KEY_SIZE_AES128_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128_EncryptedKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_aes_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256_encryptedkeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || ((SCE_OEM_KEY_SIZE_AES256_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256_EncryptedKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_aes_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa1024_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_rsa1024_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_RSA1024_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa1024_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA1024_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_rsa1024_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa1024_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_rsa1024_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_RSA1024_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa1024_private_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_private_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA1024_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_rsa1024_private_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa2048_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_rsa2048_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_RSA2048_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa2048_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA2048_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_rsa2048_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa2048_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_rsa2048_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_RSA2048_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa2048_private_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_private_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA2048_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_rsa2048_private_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result rsa4096_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_rsa4096_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_RSA4096_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa4096_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa4096_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSA4096_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_rsa4096_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp192r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP192_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp192r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp192r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP192_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp192r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp224r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP224_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp224r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp224r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP224_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp224r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp256r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP256_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp256r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_secp256r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP256_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_secp256r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_brainpoolp512r1_encryptedpublickeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP512_PUBLIC_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_BrainpoolP512r1_EncryptedPublicKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_public_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result ecc_brainpoolp512r1_encryptedprivatekeywrap(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - uint8_t * initial_vector; - uint8_t * encrypted_key; - sce_key_update_key_t * key_update_key; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[0].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - encrypted_key = (uint8_t *)params[1].memref.buffer; - if ((NULL == encrypted_key) || - ((SCE_OEM_KEY_SIZE_ECCP512_PRIVATE_KEY_INST_DATA_WORD * sizeof(uint32_t)) != params[1].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - key_update_key = (sce_key_update_key_t *)params[2].memref.buffer; - if ((NULL == key_update_key) || (sizeof(sce_key_update_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[3].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) > params[3].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap(initial_vector, encrypted_key, key_update_key, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[3].memref.size = sizeof(sce_ecc_private_wrapped_key_t); - - return TEE_SUCCESS; -} - -static TEE_Result invoke_command(void *session __unused, uint32_t cmd, - uint32_t ptypes, - TEE_Param params[TEE_NUM_PARAMS]) -{ - DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); - - switch (cmd) { - case PTA_CMD_AES128_WrappedKeyGenerate : - return aes128_wrappedkeygenerate(ptypes, params); - case PTA_CMD_AES256_WrappedKeyGenerate : - return aes256_wrappedkeygenerate(ptypes, params); - case PTA_CMD_RSA1024_WrappedKeyPairGenerate : - return rsa1024_wrappedkeypairgenerate(ptypes, params); - case PTA_CMD_RSA2048_WrappedKeyPairGenerate : - return rsa2048_wrappedkeypairgenerate(ptypes, params); - case PTA_CMD_ECC_secp192r1_WrappedKeyPairGenerate : - return ecc_secp192r1_wrappedkeypairgenerate(ptypes, params); - case PTA_CMD_ECC_secp224r1_WrappedKeyPairGenerate : - return ecc_secp224r1_wrappedkeypairgenerate(ptypes, params); - case PTA_CMD_ECC_secp256r1_WrappedKeyPairGenerate : - return ecc_secp256r1_wrappedkeypairgenerate(ptypes, params); - case PTA_CMD_ECC_BrainpoolP512r1_WrappedKeyPairGenerate : - return ecc_brainpoolp512r1_wrappedkeypairgenerate(ptypes, params); - case PTA_CMD_RandomNumberGenerate : - return randomnumbergenerate(ptypes, params); - case PTA_CMD_AES128_EncryptedKeyWrap : - return aes128_encryptedkeywrap(ptypes, params); - case PTA_CMD_AES256_EncryptedKeyWrap : - return aes256_encryptedkeywrap(ptypes, params); - case PTA_CMD_RSA1024_EncryptedPublicKeyWrap : - return rsa1024_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_RSA1024_EncryptedPrivateKeyWrap : - return rsa1024_encryptedprivatekeywrap(ptypes, params); - case PTA_CMD_RSA2048_EncryptedPublicKeyWrap : - return rsa2048_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_RSA2048_EncryptedPrivateKeyWrap : - return rsa2048_encryptedprivatekeywrap(ptypes, params); - case PTA_CMD_RSA4096_EncryptedPublicKeyWrap : - return rsa4096_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_ECC_secp192r1_EncryptedPublicKeyWrap : - return ecc_secp192r1_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_ECC_secp224r1_EncryptedPublicKeyWrap : - return ecc_secp224r1_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_ECC_secp256r1_EncryptedPublicKeyWrap : - return ecc_secp256r1_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_ECC_BrainpoolP512r1_EncryptedPublicKeyWrap : - return ecc_brainpoolp512r1_encryptedpublickeywrap(ptypes, params); - case PTA_CMD_ECC_secp192r1_EncryptedPrivateKeyWrap : - return ecc_secp192r1_encryptedprivatekeywrap(ptypes, params); - case PTA_CMD_ECC_secp224r1_EncryptedPrivateKeyWrap : - return ecc_secp224r1_encryptedprivatekeywrap(ptypes, params); - case PTA_CMD_ECC_secp256r1_EncryptedPrivateKeyWrap : - return ecc_secp256r1_encryptedprivatekeywrap(ptypes, params); - case PTA_CMD_ECC_BrainpoolP512r1_EncryptedPrivateKeyWrap : - return ecc_brainpoolp512r1_encryptedprivatekeywrap(ptypes, params); - default: - return TEE_ERROR_NOT_SUPPORTED; - } -} - -pseudo_ta_register(.uuid = PTA_SCE_UUID, .name = PTA_NAME, - .flags = PTA_DEFAULT_FLAGS, - .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/g2l/pta/pta_sce_aes.c b/core/arch/arm/plat-rz/g2l/pta/pta_sce_aes.c deleted file mode 100644 index 7a53c976a..000000000 --- a/core/arch/arm/plat-rz/g2l/pta/pta_sce_aes.c +++ /dev/null @@ -1,2257 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ - -#include - -#include -#include - -#define PTA_NAME "sce_aes.pta" - -static TEE_Result aes128ecb_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128ECB_EncryptInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128ecb_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint8_t * cipher; - uint32_t plain_length; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[1].memref.buffer; - plain_length = (uint32_t)params[1].memref.size; - if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[2].memref.buffer; - cipher_length = (uint32_t)params[2].memref.size; - if ((NULL == cipher) || (cipher_length < plain_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128ECB_EncryptUpdate(handle, plain, cipher, plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = plain_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128ecb_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = NULL; // nothing ever written here - cipher_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES128ECB_EncryptFinal(handle, cipher, &cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128ecb_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128ECB_DecryptInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128ecb_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint8_t * plain; - uint32_t cipher_length; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[1].memref.buffer; - cipher_length = (uint32_t)params[1].memref.size; - if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[2].memref.buffer; - plain_length = (uint32_t)params[2].memref.size; - if ((NULL == plain) || (plain_length < cipher_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128ECB_DecryptUpdate(handle, cipher, plain, cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = cipher_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128ecb_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = NULL; // nothing ever written here - plain_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES128ECB_DecryptFinal(handle, plain, &plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256ecb_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256ECB_EncryptInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256ecb_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint8_t * cipher; - uint32_t plain_length; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[1].memref.buffer; - plain_length = (uint32_t)params[1].memref.size; - if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[2].memref.buffer; - cipher_length = (uint32_t)params[2].memref.size; - if ((NULL == cipher) || (cipher_length < plain_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256ECB_EncryptUpdate(handle, plain, cipher, plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = plain_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes256ecb_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = NULL; // nothing ever written here - cipher_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES256ECB_EncryptFinal(handle, cipher, &cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256ecb_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256ECB_DecryptInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256ecb_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint8_t * plain; - uint32_t cipher_length; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[1].memref.buffer; - cipher_length = (uint32_t)params[1].memref.size; - if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[2].memref.buffer; - plain_length = (uint32_t)params[2].memref.size; - if ((NULL == plain) || (plain_length < cipher_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256ECB_DecryptUpdate(handle, cipher, plain, cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = cipher_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes256ecb_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = NULL; // nothing ever written here - plain_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES256ECB_DecryptFinal(handle, plain, &plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128cbc_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CBC_EncryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128cbc_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint8_t * cipher; - uint32_t plain_length; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[1].memref.buffer; - plain_length = (uint32_t)params[1].memref.size; - if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[2].memref.buffer; - cipher_length = (uint32_t)params[2].memref.size; - if ((NULL == cipher) || (cipher_length < plain_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CBC_EncryptUpdate(handle, plain, cipher, plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = plain_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128cbc_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = NULL; // nothing ever written here - cipher_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES128CBC_EncryptFinal(handle, cipher, &cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128cbc_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CBC_DecryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128cbc_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint8_t * plain; - uint32_t cipher_length; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[1].memref.buffer; - cipher_length = (uint32_t)params[1].memref.size; - if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[2].memref.buffer; - plain_length = (uint32_t)params[2].memref.size; - if ((NULL == plain) || (plain_length < cipher_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CBC_DecryptUpdate(handle, cipher, plain, cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = cipher_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128cbc_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = NULL; // nothing ever written here - plain_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES128CBC_DecryptFinal(handle, plain, &plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256cbc_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CBC_EncryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256cbc_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint8_t * cipher; - uint32_t plain_length; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[1].memref.buffer; - plain_length = (uint32_t)params[1].memref.size; - if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[2].memref.buffer; - cipher_length = (uint32_t)params[2].memref.size; - if ((NULL == cipher) || (cipher_length < plain_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CBC_EncryptUpdate(handle, plain, cipher, plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = plain_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes256cbc_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = NULL; // nothing ever written here - cipher_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES256CBC_EncryptFinal(handle, cipher, &cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256cbc_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CBC_DecryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256cbc_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint8_t * plain; - uint32_t cipher_length; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[1].memref.buffer; - cipher_length = (uint32_t)params[1].memref.size; - if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[2].memref.buffer; - plain_length = (uint32_t)params[2].memref.size; - if ((NULL == plain) || (plain_length < cipher_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CBC_DecryptUpdate(handle, cipher, plain, cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = cipher_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes256cbc_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = NULL; // nothing ever written here - plain_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES256CBC_DecryptFinal(handle, plain, &plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128ctr_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CTR_EncryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128ctr_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint8_t * cipher; - uint32_t plain_length; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[1].memref.buffer; - plain_length = (uint32_t)params[1].memref.size; - if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[2].memref.buffer; - cipher_length = (uint32_t)params[2].memref.size; - if ((NULL == cipher) || (cipher_length < plain_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CTR_EncryptUpdate(handle, plain, cipher, plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = plain_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128ctr_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = NULL; // nothing ever written here - cipher_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES128CTR_EncryptFinal(handle, cipher, &cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128ctr_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CTR_DecryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128ctr_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint8_t * plain; - uint32_t cipher_length; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[1].memref.buffer; - cipher_length = (uint32_t)params[1].memref.size; - if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[2].memref.buffer; - plain_length = (uint32_t)params[2].memref.size; - if ((NULL == plain) || (plain_length < cipher_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CTR_DecryptUpdate(handle, cipher, plain, cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = cipher_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes128ctr_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = NULL; // nothing ever written here - plain_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES128CTR_DecryptFinal(handle, plain, &plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256ctr_encryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CTR_EncryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256ctr_encryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint8_t * cipher; - uint32_t plain_length; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[1].memref.buffer; - plain_length = (uint32_t)params[1].memref.size; - if ((NULL == plain) || (0 != (plain_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[2].memref.buffer; - cipher_length = (uint32_t)params[2].memref.size; - if ((NULL == cipher) || (cipher_length < plain_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CTR_EncryptUpdate(handle, plain, cipher, plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = plain_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes256ctr_encryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint32_t cipher_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = NULL; // nothing ever written here - cipher_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES256CTR_EncryptFinal(handle, cipher, &cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256ctr_decryptinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - uint8_t * initial_vector; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - initial_vector = (uint8_t *)params[2].memref.buffer; - if ((NULL == initial_vector) || (HW_SCE_AES_CBC_IV_BYTE_SIZE != params[2].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CTR_DecryptInit(handle, wrapped_key, initial_vector); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_aes_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256ctr_decryptupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * cipher; - uint8_t * plain; - uint32_t cipher_length; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher = (uint8_t *)params[1].memref.buffer; - cipher_length = (uint32_t)params[1].memref.size; - if ((NULL == cipher) || (0 != (cipher_length % HW_SCE_AES_BLOCK_BYTE_SIZE))) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = (uint8_t *)params[2].memref.buffer; - plain_length = (uint32_t)params[2].memref.size; - if ((NULL == plain) || (plain_length < cipher_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CTR_DecryptUpdate(handle, cipher, plain, cipher_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[2].memref.size = cipher_length; - - return TEE_SUCCESS; -} - -static TEE_Result aes256ctr_decryptfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_aes_handle_t * handle; - uint8_t * plain; - uint32_t plain_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_aes_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_aes_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain = NULL; // nothing ever written here - plain_length = 0; // 0 always written here - - err = g_sce_protected_on_sce.AES256CTR_DecryptFinal(handle, plain, &plain_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128cmac_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CMAC_GenerateInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_cmac_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128cmac_generateupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * message; - uint32_t message_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message = (uint8_t *)params[1].memref.buffer; - message_length = (uint32_t)params[1].memref.size; - if (NULL == message) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CMAC_GenerateUpdate(handle, message, message_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128cmac_generatefinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * mac; - uint32_t mac_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - mac = (uint8_t *)params[1].memref.buffer; - mac_length = params[1].memref.size; - if ((NULL == mac) || (HW_SCE_AES_BLOCK_BYTE_SIZE > mac_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CMAC_GenerateFinal(handle, mac); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION: - return TEE_ERROR_BAD_STATE; - default: /* FSP_ERR_CRYPTO_SCE_AUTHENTICATION */ - return TEE_ERROR_MAC_INVALID; - } - - params[1].memref.size = HW_SCE_AES_BLOCK_BYTE_SIZE; - - return TEE_SUCCESS; -} - -static TEE_Result aes128cmac_verifyinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CMAC_VerifyInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_cmac_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes128cmac_verifyupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * message; - uint32_t message_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message = (uint8_t *)params[1].memref.buffer; - message_length = (uint32_t)params[1].memref.size; - if (NULL == message) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CMAC_VerifyUpdate(handle, message, message_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes128cmac_verifyfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * mac; - uint32_t mac_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - mac = (uint8_t *)params[1].memref.buffer; - mac_length = params[1].memref.size; - if ((NULL == mac) || (2 > mac_length) || (HW_SCE_AES_BLOCK_BYTE_SIZE < mac_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES128CMAC_VerifyFinal(handle, mac, mac_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: - return TEE_ERROR_MAC_INVALID; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256cmac_generateinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CMAC_GenerateInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_cmac_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256cmac_generateupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * message; - uint32_t message_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message = (uint8_t *)params[1].memref.buffer; - message_length = (uint32_t)params[1].memref.size; - if (NULL == message) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CMAC_GenerateUpdate(handle, message, message_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256cmac_generatefinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * mac; - uint32_t mac_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - mac = (uint8_t *)params[1].memref.buffer; - mac_length = params[1].memref.size; - if ((NULL == mac) || (HW_SCE_AES_BLOCK_BYTE_SIZE > mac_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CMAC_GenerateFinal(handle, mac); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION: - return TEE_ERROR_BAD_STATE; - default: /* FSP_ERR_CRYPTO_SCE_AUTHENTICATION */ - return TEE_ERROR_MAC_INVALID; - } - - params[1].memref.size = HW_SCE_AES_BLOCK_BYTE_SIZE; - - return TEE_SUCCESS; -} - -static TEE_Result aes256cmac_verifyinit(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - sce_aes_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_aes_wrapped_key_t *)params[1].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_aes_wrapped_key_t) != params[1].memref.size)){ - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CMAC_VerifyInit(handle, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_cmac_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result aes256cmac_verifyupdate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * message; - uint32_t message_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message = (uint8_t *)params[1].memref.buffer; - message_length = (uint32_t)params[1].memref.size; - if (NULL == message) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CMAC_VerifyUpdate(handle, message, message_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /*FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes256cmac_verifyfinal(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_cmac_handle_t * handle; - uint8_t * mac; - uint32_t mac_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_cmac_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_cmac_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - mac = (uint8_t *)params[1].memref.buffer; - mac_length = params[1].memref.size; - if ((NULL == mac) || (2 > mac_length) || (HW_SCE_AES_BLOCK_BYTE_SIZE < mac_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.AES256CMAC_VerifyFinal(handle, mac, mac_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: - return TEE_ERROR_MAC_INVALID; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result invoke_command( - void *session __unused, - uint32_t cmd, - uint32_t ptypes, - TEE_Param params[TEE_NUM_PARAMS] - ) -{ - DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); - - switch (cmd) { - case PTA_CMD_AES128ECB_EncryptInit : - return aes128ecb_encryptinit(ptypes, params); - case PTA_CMD_AES128ECB_EncryptUpdate : - return aes128ecb_encryptupdate(ptypes, params); - case PTA_CMD_AES128ECB_EncryptFinal : - return aes128ecb_encryptfinal(ptypes, params); - case PTA_CMD_AES128ECB_DecryptInit : - return aes128ecb_decryptinit(ptypes, params); - case PTA_CMD_AES128ECB_DecryptUpdate : - return aes128ecb_decryptupdate(ptypes, params); - case PTA_CMD_AES128ECB_DecryptFinal : - return aes128ecb_decryptfinal(ptypes, params); - case PTA_CMD_AES256ECB_EncryptInit : - return aes256ecb_encryptinit(ptypes, params); - case PTA_CMD_AES256ECB_EncryptUpdate : - return aes256ecb_encryptupdate(ptypes, params); - case PTA_CMD_AES256ECB_EncryptFinal : - return aes256ecb_encryptfinal(ptypes, params); - case PTA_CMD_AES256ECB_DecryptInit : - return aes256ecb_decryptinit(ptypes, params); - case PTA_CMD_AES256ECB_DecryptUpdate : - return aes256ecb_decryptupdate(ptypes, params); - case PTA_CMD_AES256ECB_DecryptFinal : - return aes256ecb_decryptfinal(ptypes, params); - case PTA_CMD_AES128CBC_EncryptInit : - return aes128cbc_encryptinit(ptypes, params); - case PTA_CMD_AES128CBC_EncryptUpdate : - return aes128cbc_encryptupdate(ptypes, params); - case PTA_CMD_AES128CBC_EncryptFinal : - return aes128cbc_encryptfinal(ptypes, params); - case PTA_CMD_AES128CBC_DecryptInit : - return aes128cbc_decryptinit(ptypes, params); - case PTA_CMD_AES128CBC_DecryptUpdate : - return aes128cbc_decryptupdate(ptypes, params); - case PTA_CMD_AES128CBC_DecryptFinal : - return aes128cbc_decryptfinal(ptypes, params); - case PTA_CMD_AES256CBC_EncryptInit : - return aes256cbc_encryptinit(ptypes, params); - case PTA_CMD_AES256CBC_EncryptUpdate : - return aes256cbc_encryptupdate(ptypes, params); - case PTA_CMD_AES256CBC_EncryptFinal : - return aes256cbc_encryptfinal(ptypes, params); - case PTA_CMD_AES256CBC_DecryptInit : - return aes256cbc_decryptinit(ptypes, params); - case PTA_CMD_AES256CBC_DecryptUpdate : - return aes256cbc_decryptupdate(ptypes, params); - case PTA_CMD_AES256CBC_DecryptFinal : - return aes256cbc_decryptfinal(ptypes, params); - case PTA_CMD_AES128CTR_EncryptInit : - return aes128ctr_encryptinit(ptypes, params); - case PTA_CMD_AES128CTR_EncryptUpdate : - return aes128ctr_encryptupdate(ptypes, params); - case PTA_CMD_AES128CTR_EncryptFinal : - return aes128ctr_encryptfinal(ptypes, params); - case PTA_CMD_AES128CTR_DecryptInit : - return aes128ctr_decryptinit(ptypes, params); - case PTA_CMD_AES128CTR_DecryptUpdate : - return aes128ctr_decryptupdate(ptypes, params); - case PTA_CMD_AES128CTR_DecryptFinal : - return aes128ctr_decryptfinal(ptypes, params); - case PTA_CMD_AES256CTR_EncryptInit : - return aes256ctr_encryptinit(ptypes, params); - case PTA_CMD_AES256CTR_EncryptUpdate : - return aes256ctr_encryptupdate(ptypes, params); - case PTA_CMD_AES256CTR_EncryptFinal : - return aes256ctr_encryptfinal(ptypes, params); - case PTA_CMD_AES256CTR_DecryptInit : - return aes256ctr_decryptinit(ptypes, params); - case PTA_CMD_AES256CTR_DecryptUpdate : - return aes256ctr_decryptupdate(ptypes, params); - case PTA_CMD_AES256CTR_DecryptFinal : - return aes256ctr_decryptfinal(ptypes, params); - case PTA_CMD_AES128CMAC_GenerateInit : - return aes128cmac_generateinit(ptypes, params); - case PTA_CMD_AES128CMAC_GenerateUpdate : - return aes128cmac_generateupdate(ptypes, params); - case PTA_CMD_AES128CMAC_GenerateFinal : - return aes128cmac_generatefinal(ptypes, params); - case PTA_CMD_AES128CMAC_VerifyInit : - return aes128cmac_verifyinit(ptypes, params); - case PTA_CMD_AES128CMAC_VerifyUpdate : - return aes128cmac_verifyupdate(ptypes, params); - case PTA_CMD_AES128CMAC_VerifyFinal : - return aes128cmac_verifyfinal(ptypes, params); - case PTA_CMD_AES256CMAC_GenerateInit : - return aes256cmac_generateinit(ptypes, params); - case PTA_CMD_AES256CMAC_GenerateUpdate : - return aes256cmac_generateupdate(ptypes, params); - case PTA_CMD_AES256CMAC_GenerateFinal : - return aes256cmac_generatefinal(ptypes, params); - case PTA_CMD_AES256CMAC_VerifyInit : - return aes256cmac_verifyinit(ptypes, params); - case PTA_CMD_AES256CMAC_VerifyUpdate : - return aes256cmac_verifyupdate(ptypes, params); - case PTA_CMD_AES256CMAC_VerifyFinal : - return aes256cmac_verifyfinal(ptypes, params); - default: - return TEE_ERROR_NOT_SUPPORTED; - } -} - -pseudo_ta_register( - .uuid = PTA_SCE_AES_UUID, - .name = PTA_NAME, - .flags = PTA_DEFAULT_FLAGS | TA_FLAG_DEVICE_ENUM, - .invoke_command_entry_point = invoke_command -); diff --git a/core/arch/arm/plat-rz/g2l/pta/pta_sce_ecc.c b/core/arch/arm/plat-rz/g2l/pta/pta_sce_ecc.c deleted file mode 100644 index 3a2856b2c..000000000 --- a/core/arch/arm/plat-rz/g2l/pta/pta_sce_ecc.c +++ /dev/null @@ -1,483 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ - -#include -#include - -#include -#include - -#define PTA_NAME "sce_ecc.pta" - -static uint32_t sha512_hash[HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE / sizeof(uint32_t)]; - -static TEE_Result ecdsa_secp192r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t message_hash; - sce_ecdsa_byte_data_t signature; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[0].memref.buffer; - message_hash.data_length = params[0].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[1].memref.buffer; - signature.data_length = params[1].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE > signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_secp192r1_SignatureGenerate(&message_hash, &signature, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = signature.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_secp192r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t signature; - sce_ecdsa_byte_data_t message_hash; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[1].memref.buffer; - message_hash.data_length = params[1].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_secp192r1_SignatureVerify(&signature, &message_hash, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_secp224r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t message_hash; - sce_ecdsa_byte_data_t signature; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[0].memref.buffer; - message_hash.data_length = params[0].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[1].memref.buffer; - signature.data_length = params[1].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE > signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_secp224r1_SignatureGenerate(&message_hash, &signature, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = signature.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_secp224r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t signature; - sce_ecdsa_byte_data_t message_hash; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[1].memref.buffer; - message_hash.data_length = params[1].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_secp224r1_SignatureVerify(&signature, &message_hash, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_secp256r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t message_hash; - sce_ecdsa_byte_data_t signature; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[0].memref.buffer; - message_hash.data_length = params[0].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[1].memref.buffer; - signature.data_length = params[1].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE > signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_secp256r1_SignatureGenerate(&message_hash, &signature, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = signature.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_secp256r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t signature; - sce_ecdsa_byte_data_t message_hash; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[1].memref.buffer; - message_hash.data_length = params[1].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_secp256r1_SignatureVerify(&signature, &message_hash, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_brainpoolp512r1_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t message_hash; - sce_ecdsa_byte_data_t signature; - sce_ecc_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)sha512_hash; - message_hash.data_length = HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE; - message_hash.data_type = 1; - err = tee_hash_createdigest(TEE_ALG_SHA512, params[0].memref.buffer, params[0].memref.size, - message_hash.pdata, message_hash.data_length); - if (err) { - return err; - } - - signature.pdata = (uint8_t *)params[1].memref.buffer; - signature.data_length = params[1].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_P512_DATA_BYTE_SIZE > signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_ecc_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_BrainpoolP512r1_SignatureGenerate(&message_hash, &signature, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = signature.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result ecdsa_brainpoolp512r1_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_ecdsa_byte_data_t signature; - sce_ecdsa_byte_data_t message_hash; - sce_ecc_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_ECDSA_P512_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)sha512_hash; - message_hash.data_length = HW_SCE_SHA512_HASH_LENGTH_BYTE_SIZE; - message_hash.data_type = 1; - err = tee_hash_createdigest(TEE_ALG_SHA512, params[1].memref.buffer, params[1].memref.size, - message_hash.pdata, message_hash.data_length); - if (err) { - return err; - } - - wrapped_key = (sce_ecc_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_ecc_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.ECDSA_BrainpoolP512r1_SignatureVerify(&signature, &message_hash, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_FAIL: - return TEE_ERROR_GENERIC; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result invoke_command(void *session __unused, uint32_t cmd, - uint32_t ptypes, - TEE_Param params[TEE_NUM_PARAMS]) -{ - DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); - - switch (cmd) - { - case PTA_CMD_ECDSA_secp192r1_SignatureGenerate : - return ecdsa_secp192r1_signaturegenerate(ptypes, params); - case PTA_CMD_ECDSA_secp192r1_SignatureVerify : - return ecdsa_secp192r1_signatureverify(ptypes, params); - case PTA_CMD_ECDSA_secp224r1_SignatureGenerate : - return ecdsa_secp224r1_signaturegenerate(ptypes, params); - case PTA_CMD_ECDSA_secp224r1_SignatureVerify : - return ecdsa_secp224r1_signatureverify(ptypes, params); - case PTA_CMD_ECDSA_secp256r1_SignatureGenerate : - return ecdsa_secp256r1_signaturegenerate(ptypes, params); - case PTA_CMD_ECDSA_secp256r1_SignatureVerify : - return ecdsa_secp256r1_signatureverify(ptypes, params); - case PTA_CMD_ECDSA_BrainpoolP512r1_SignatureGenerate : - return ecdsa_brainpoolp512r1_signaturegenerate(ptypes, params); - case PTA_CMD_ECDSA_BrainpoolP512r1_SignatureVerify : - return ecdsa_brainpoolp512r1_signatureverify(ptypes, params); - default: - return TEE_ERROR_NOT_SUPPORTED; - } -} - -pseudo_ta_register(.uuid = PTA_SCE_ECC_UUID, .name = PTA_NAME, - .flags = PTA_DEFAULT_FLAGS, - .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/g2l/pta/pta_sce_rsa.c b/core/arch/arm/plat-rz/g2l/pta/pta_sce_rsa.c deleted file mode 100644 index 6fb85f4ee..000000000 --- a/core/arch/arm/plat-rz/g2l/pta/pta_sce_rsa.c +++ /dev/null @@ -1,576 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ - -#include - -#include -#include - -#define PTA_NAME "sce_rsa.pta" - -static TEE_Result rsassa_pkcs1024_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t message_hash; - sce_rsa_byte_data_t signature; - sce_rsa1024_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[0].memref.buffer; - message_hash.data_length = params[0].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[1].memref.buffer; - signature.data_length = params[1].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_RSA_1024_DATA_BYTE_SIZE > signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa1024_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSASSA_PKCS1024_SignatureGenerate(&message_hash, &signature, wrapped_key, HW_SCE_RSA_HASH_SHA256); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = signature.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result rsassa_pkcs1024_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t signature; - sce_rsa_byte_data_t message_hash; - sce_rsa1024_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_RSA_1024_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[1].memref.buffer; - message_hash.data_length = params[1].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa1024_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSASSA_PKCS1024_SignatureVerify(&signature, &message_hash, wrapped_key, HW_SCE_RSA_HASH_SHA256); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: - return TEE_ERROR_SIGNATURE_INVALID; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result rsassa_pkcs2048_signaturegenerate(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t message_hash; - sce_rsa_byte_data_t signature; - sce_rsa2048_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[0].memref.buffer; - message_hash.data_length = params[0].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[1].memref.buffer; - signature.data_length = params[1].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_RSA_2048_DATA_BYTE_SIZE > signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa2048_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSASSA_PKCS2048_SignatureGenerate(&message_hash, &signature, wrapped_key, HW_SCE_RSA_HASH_SHA256); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = signature.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result rsassa_pkcs2048_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t signature; - sce_rsa_byte_data_t message_hash; - sce_rsa2048_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_RSA_2048_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[1].memref.buffer; - message_hash.data_length = params[1].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa2048_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSASSA_PKCS2048_SignatureVerify(&signature, &message_hash, wrapped_key, HW_SCE_RSA_HASH_SHA256); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: - return TEE_ERROR_SIGNATURE_INVALID; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result rsassa_pkcs4096_signatureverify(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t signature; - sce_rsa_byte_data_t message_hash; - sce_rsa4096_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - signature.pdata = (uint8_t *)params[0].memref.buffer; - signature.data_length = params[0].memref.size; - signature.data_type = 0; - if ((NULL == signature.pdata) || (HW_SCE_RSA_4096_DATA_BYTE_SIZE != signature.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message_hash.pdata = (uint8_t *)params[1].memref.buffer; - message_hash.data_length = params[1].memref.size; - message_hash.data_type = 0; - if ((NULL == message_hash.pdata) && (0 < message_hash.data_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa4096_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa4096_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSASSA_PKCS4096_SignatureVerify(&signature, &message_hash, wrapped_key, HW_SCE_RSA_HASH_SHA256); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_AUTHENTICATION: - return TEE_ERROR_SIGNATURE_INVALID; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result rsaes_pkcs1024_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t plain; - sce_rsa_byte_data_t cipher; - sce_rsa1024_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain.pdata = (uint8_t *)params[0].memref.buffer; - plain.data_length = params[0].memref.size; - plain.data_type = 0; - if (NULL == plain.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher.pdata = (uint8_t *)params[1].memref.buffer; - cipher.data_length = params[1].memref.size; - cipher.data_type = 0; - if (NULL == cipher.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa1024_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSAES_PKCS1024_Encrypt(&plain, &cipher, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PARAMETER */ - return TEE_ERROR_BAD_PARAMETERS; - } - - params[1].memref.size = cipher.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result rsaes_pkcs1024_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t plain; - sce_rsa_byte_data_t cipher; - sce_rsa1024_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher.pdata = (uint8_t *)params[0].memref.buffer; - cipher.data_length = params[0].memref.size; - cipher.data_type = 0; - if (NULL == cipher.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain.pdata = (uint8_t *)params[1].memref.buffer; - plain.data_length = params[1].memref.size; - plain.data_type = 0; - if (NULL == plain.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa1024_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa1024_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSAES_PKCS1024_Decrypt(&cipher, &plain, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} -static TEE_Result rsaes_pkcs2048_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t plain; - sce_rsa_byte_data_t cipher; - sce_rsa2048_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain.pdata = (uint8_t *)params[0].memref.buffer; - plain.data_length = params[0].memref.size; - plain.data_type = 0; - if (NULL == plain.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher.pdata = (uint8_t *)params[1].memref.buffer; - cipher.data_length = params[1].memref.size; - cipher.data_type = 0; - if (NULL == cipher.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa2048_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSAES_PKCS2048_Encrypt(&plain, &cipher, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PARAMETER */ - return TEE_ERROR_BAD_PARAMETERS; - } - - params[1].memref.size = cipher.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result rsaes_pkcs2048_decrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t plain; - sce_rsa_byte_data_t cipher; - sce_rsa2048_private_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher.pdata = (uint8_t *)params[0].memref.buffer; - cipher.data_length = params[0].memref.size; - cipher.data_type = 0; - if (NULL == cipher.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain.pdata = (uint8_t *)params[1].memref.buffer; - plain.data_length = params[1].memref.size; - plain.data_type = 0; - if (NULL == plain.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa2048_private_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa2048_private_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSAES_PKCS2048_Decrypt(&cipher, &plain, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_FAIL */ - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static TEE_Result rsaes_pkcs4096_encrypt(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_rsa_byte_data_t plain; - sce_rsa_byte_data_t cipher; - sce_rsa4096_public_wrapped_key_t * wrapped_key; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - plain.pdata = (uint8_t *)params[0].memref.buffer; - plain.data_length = params[0].memref.size; - plain.data_type = 0; - if (NULL == plain.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - cipher.pdata = (uint8_t *)params[1].memref.buffer; - cipher.data_length = params[1].memref.size; - cipher.data_type = 0; - if (NULL == cipher.pdata) { - return TEE_ERROR_BAD_PARAMETERS; - } - - wrapped_key = (sce_rsa4096_public_wrapped_key_t *)params[2].memref.buffer; - if ((NULL == wrapped_key) || (sizeof(sce_rsa4096_public_wrapped_key_t) != params[2].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.RSAES_PKCS4096_Encrypt(&plain, &cipher, wrapped_key); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_KEY_SET_FAIL: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PARAMETER */ - return TEE_ERROR_BAD_PARAMETERS; - } - - params[1].memref.size = cipher.data_length; - - return TEE_SUCCESS; -} - -static TEE_Result invoke_command(void *session __unused, uint32_t cmd, - uint32_t ptypes, - TEE_Param params[TEE_NUM_PARAMS]) -{ - DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); - - switch (cmd) { - case PTA_CMD_RSASSA_PKCS1024_SignatureGenerate : - return rsassa_pkcs1024_signaturegenerate(ptypes, params); - case PTA_CMD_RSASSA_PKCS1024_SignatureVerify : - return rsassa_pkcs1024_signatureverify(ptypes, params); - case PTA_CMD_RSASSA_PKCS2048_SignatureGenerate : - return rsassa_pkcs2048_signaturegenerate(ptypes, params); - case PTA_CMD_RSASSA_PKCS2048_SignatureVerify : - return rsassa_pkcs2048_signatureverify(ptypes, params); - case PTA_CMD_RSASSA_PKCS4096_SignatureVerify : - return rsassa_pkcs4096_signatureverify(ptypes, params); - case PTA_CMD_RSAES_PKCS1024_Encrypt : - return rsaes_pkcs1024_encrypt(ptypes, params); - case PTA_CMD_RSAES_PKCS1024_Decrypt : - return rsaes_pkcs1024_decrypt(ptypes, params); - case PTA_CMD_RSAES_PKCS2048_Encrypt : - return rsaes_pkcs2048_encrypt(ptypes, params); - case PTA_CMD_RSAES_PKCS2048_Decrypt : - return rsaes_pkcs2048_decrypt(ptypes, params); - case PTA_CMD_RSAES_PKCS4096_Encrypt : - return rsaes_pkcs4096_encrypt(ptypes, params); - default: - return TEE_ERROR_NOT_SUPPORTED; - } -} - -pseudo_ta_register(.uuid = PTA_SCE_RSA_UUID, .name = PTA_NAME, - .flags = PTA_DEFAULT_FLAGS, - .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/g2l/pta/pta_sce_sha.c b/core/arch/arm/plat-rz/g2l/pta/pta_sce_sha.c deleted file mode 100644 index 864fcd6bc..000000000 --- a/core/arch/arm/plat-rz/g2l/pta/pta_sce_sha.c +++ /dev/null @@ -1,269 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2022, Renesas Electronics - */ - -#include - -#include -#include - -#define PTA_NAME "sce_sha.pta" - -static TEE_Result sha224_init(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_sha_md5_handle_t * handle; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.SHA224_Init(handle); - switch (err) - { - case FSP_SUCCESS: - break; - default: - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_sha_md5_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result sha224_update(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_sha_md5_handle_t * handle; - uint8_t * message; - uint32_t message_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message = (uint8_t *)params[1].memref.buffer; - message_length = (uint32_t)params[1].memref.size; - - err = g_sce_protected_on_sce.SHA224_Update(handle, message, message_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result sha224_final(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_sha_md5_handle_t * handle; - uint8_t * digest; - uint32_t digest_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - digest = (uint8_t *)params[1].memref.buffer; - digest_length = (uint32_t)params[1].memref.size; - if ((NULL == digest) || (HW_SCE_SHA224_HASH_LENGTH_BYTE_SIZE > digest_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.SHA224_Final(handle, digest, &digest_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = digest_length; - - return TEE_SUCCESS; -} - -static TEE_Result sha256_init(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_sha_md5_handle_t * handle; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) > params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.SHA256_Init(handle); - switch (err) - { - case FSP_SUCCESS: - break; - default: - return TEE_ERROR_GENERIC; - } - - params[0].memref.size = sizeof(sce_sha_md5_handle_t); - - return TEE_SUCCESS; -} - -static TEE_Result sha256_update(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_sha_md5_handle_t * handle; - uint8_t * message; - uint32_t message_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INPUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - message = (uint8_t *)params[1].memref.buffer; - message_length = (uint32_t)params[1].memref.size; - - err = g_sce_protected_on_sce.SHA256_Update(handle, message, message_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - return TEE_SUCCESS; -} - -static TEE_Result sha256_final(uint32_t types, TEE_Param params[TEE_NUM_PARAMS]) -{ - fsp_err_t err; - - sce_sha_md5_handle_t * handle; - uint8_t * digest; - uint32_t digest_length; - - if (types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - handle = (sce_sha_md5_handle_t *)params[0].memref.buffer; - if ((NULL == handle) || (sizeof(sce_sha_md5_handle_t) != params[0].memref.size)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - digest = (uint8_t *)params[1].memref.buffer; - digest_length = (uint32_t)params[1].memref.size; - if ((NULL == digest) || (HW_SCE_SHA256_HASH_LENGTH_BYTE_SIZE > digest_length)) { - return TEE_ERROR_BAD_PARAMETERS; - } - - err = g_sce_protected_on_sce.SHA256_Final(handle, digest, &digest_length); - switch (err) - { - case FSP_SUCCESS: - break; - case FSP_ERR_CRYPTO_SCE_RESOURCE_CONFLICT: - return TEE_ERROR_ACCESS_CONFLICT; - case FSP_ERR_CRYPTO_SCE_PARAMETER: - return TEE_ERROR_BAD_PARAMETERS; - default: /* FSP_ERR_CRYPTO_SCE_PROHIBIT_FUNCTION */ - return TEE_ERROR_BAD_STATE; - } - - params[1].memref.size = digest_length; - - return TEE_SUCCESS; -} - -static TEE_Result invoke_command(void *session __unused, uint32_t cmd, - uint32_t ptypes, - TEE_Param params[TEE_NUM_PARAMS]) -{ - DMSG(PTA_NAME" command %#"PRIx32" ptypes %#"PRIx32, cmd, ptypes); - - switch (cmd) { - case PTA_CMD_SHA224_Init : - return sha224_init(ptypes, params); - case PTA_CMD_SHA224_Update : - return sha224_update(ptypes, params); - case PTA_CMD_SHA224_Final : - return sha224_final(ptypes, params); - case PTA_CMD_SHA256_Init : - return sha256_init(ptypes, params); - case PTA_CMD_SHA256_Update : - return sha256_update(ptypes, params); - case PTA_CMD_SHA256_Final : - return sha256_final(ptypes, params); - default: - return TEE_ERROR_NOT_SUPPORTED; - } -} - -pseudo_ta_register(.uuid = PTA_SCE_SHA_UUID, .name = PTA_NAME, - .flags = PTA_DEFAULT_FLAGS, - .invoke_command_entry_point = invoke_command); diff --git a/core/arch/arm/plat-rz/g2l/pta/sub.mk b/core/arch/arm/plat-rz/g2l/pta/sub.mk deleted file mode 100644 index 596449565..000000000 --- a/core/arch/arm/plat-rz/g2l/pta/sub.mk +++ /dev/null @@ -1,4 +0,0 @@ -global-incdirs-y += include - -srcs-y += pta_flash.c -srcs-$(CFG_RZ_SCE) += pta_sce.c pta_sce_ecc.c pta_sce_rsa.c pta_sce_sha.c pta_sce_aes.c diff --git a/core/arch/arm/plat-rz/g2l/rzg2l_conf.mk b/core/arch/arm/plat-rz/g2l/rzg2l_conf.mk index 5cb578e91..a15755bfd 100644 --- a/core/arch/arm/plat-rz/g2l/rzg2l_conf.mk +++ b/core/arch/arm/plat-rz/g2l/rzg2l_conf.mk @@ -11,6 +11,7 @@ $(call force,CFG_CORE_ARM64_PA_BITS,36) $(call force,CFG_GIC,y) $(call force,CFG_ARM_GICV3,y) $(call force,CFG_RZ_HUK,y) +$(call force,CFG_RZ_SPI_MULTI,y) ifeq ($(PLATFORM_FLAVOR),g2ul_smarc) CFG_TEE_CORE_NB_CORE ?= 1 @@ -28,8 +29,11 @@ else $(call force,CFG_ARM32_core,y) endif -CFG_RZ_SCE ?= n ifeq ($(CFG_RZ_SCE),y) +CFG_RZ_TSIP ?= y +endif + +ifeq ($(CFG_RZ_TSIP),y) CFG_WITH_SOFTWARE_PRNG ?= n endif diff --git a/core/arch/arm/plat-rz/g2l/rzg2l_config.h b/core/arch/arm/plat-rz/g2l/rzg2l_config.h index b4bd04c75..98cd65499 100644 --- a/core/arch/arm/plat-rz/g2l/rzg2l_config.h +++ b/core/arch/arm/plat-rz/g2l/rzg2l_config.h @@ -27,6 +27,8 @@ #define SPI_FLASH_BASE 0x20000000U #define SPI_FLASH_SIZE 0x10000000 +#define HW_SCE_BASE 0x11850000 + #if defined(PLATFORM_FLAVOR_g2l_dev13_1) /* DDR 512Mbyte x2 */ #define NSEC_DDR_0_BASE 0x47E00000U diff --git a/core/arch/arm/plat-rz/g2l/sub.mk b/core/arch/arm/plat-rz/g2l/sub.mk index 5fadfd572..280b1c1e0 100644 --- a/core/arch/arm/plat-rz/g2l/sub.mk +++ b/core/arch/arm/plat-rz/g2l/sub.mk @@ -1,6 +1,4 @@ global-incdirs-y += . srcs-y += main.c -srcs-$(CFG_RZ_SCE) += hw_rng.c - -subdirs-y += drivers pta +subdirs-y += drivers diff --git a/core/arch/arm/plat-rz/g3s/rzg3s_conf.mk b/core/arch/arm/plat-rz/g3s/rzg3s_conf.mk index 2592f3acd..3d3e12a68 100644 --- a/core/arch/arm/plat-rz/g3s/rzg3s_conf.mk +++ b/core/arch/arm/plat-rz/g3s/rzg3s_conf.mk @@ -25,7 +25,10 @@ else $(call force,CFG_ARM32_core,y) endif -CFG_RZ_SCE ?= n ifeq ($(CFG_RZ_SCE),y) -CFG_WITH_SOFTWARE_PRNG ?= n +CFG_RZ_RSIP ?= y endif + +ifeq ($(CFG_RZ_RSIP),y) +CFG_WITH_SOFTWARE_PRNG ?= n +endif \ No newline at end of file diff --git a/core/arch/arm/plat-rz/g3s/rzg3s_config.h b/core/arch/arm/plat-rz/g3s/rzg3s_config.h index 186adc52f..3e28f0996 100644 --- a/core/arch/arm/plat-rz/g3s/rzg3s_config.h +++ b/core/arch/arm/plat-rz/g3s/rzg3s_config.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* * Copyright (c) 2016, GlobalLogic - * Copyright (c) 2023, Renesas Electronics + * Copyright (c) 2024, Renesas Electronics */ #ifndef RZG3S_CONFIG_H @@ -29,6 +29,9 @@ #define XSPI_BASE 0x10060000U #define XSPI_REG_SIZE 0x30000 +#define RSIP_BASE 0x11850000 +#define RSIP_SIZE 0x00010000 + #if defined(PLATFORM_FLAVOR_g3s_dev14_1) /* DDR 1Gbyte x1 */ #define NSEC_DDR_0_BASE 0x47E00000U diff --git a/core/arch/arm/plat-rz/v2h/rzv2h_conf.mk b/core/arch/arm/plat-rz/v2h/rzv2h_conf.mk index eb5052449..a91884a0c 100644 --- a/core/arch/arm/plat-rz/v2h/rzv2h_conf.mk +++ b/core/arch/arm/plat-rz/v2h/rzv2h_conf.mk @@ -25,7 +25,10 @@ else $(call force,CFG_ARM32_core,y) endif -CFG_RZ_SCE ?= n ifeq ($(CFG_RZ_SCE),y) +CFG_RZ_TSIP ?= y +endif + +ifeq ($(CFG_RZ_TSIP),y) CFG_WITH_SOFTWARE_PRNG ?= n endif From f1b6c5d12d65fe3da2dabdd355fe01ce6e7916f3 Mon Sep 17 00:00:00 2001 From: kaiki osakaki Date: Wed, 17 Jul 2024 12:06:36 +0900 Subject: [PATCH 6/7] Change the location of hw_rng for RZ/V2H. Signed-off-by: kaiki osakaki --- core/arch/arm/plat-rz/common/drivers/sub.mk | 4 ++-- core/arch/arm/plat-rz/common/{drivers => }/hw_rng.c | 0 core/arch/arm/plat-rz/common/{drivers => }/hw_rng_rsip.c | 0 core/arch/arm/plat-rz/common/sub.mk | 2 ++ 4 files changed, 4 insertions(+), 2 deletions(-) rename core/arch/arm/plat-rz/common/{drivers => }/hw_rng.c (100%) rename core/arch/arm/plat-rz/common/{drivers => }/hw_rng_rsip.c (100%) diff --git a/core/arch/arm/plat-rz/common/drivers/sub.mk b/core/arch/arm/plat-rz/common/drivers/sub.mk index 296de0337..a6461cb6d 100644 --- a/core/arch/arm/plat-rz/common/drivers/sub.mk +++ b/core/arch/arm/plat-rz/common/drivers/sub.mk @@ -6,8 +6,8 @@ subdirs-$(CFG_RZ_SPI_MULTI) += spi_multi subdirs-$(CFG_RZ_XSPI) += xspi -srcs-$(CFG_RZ_TSIP) += sce.c hw_rng.c +srcs-$(CFG_RZ_TSIP) += sce.c subdirs-$(CFG_RZ_TSIP) += r_sce -srcs-$(CFG_RZ_RSIP) += rsip.c hw_rng_rsip.c +srcs-$(CFG_RZ_RSIP) += rsip.c subdirs-$(CFG_RZ_RSIP) += r_rsip \ No newline at end of file diff --git a/core/arch/arm/plat-rz/common/drivers/hw_rng.c b/core/arch/arm/plat-rz/common/hw_rng.c similarity index 100% rename from core/arch/arm/plat-rz/common/drivers/hw_rng.c rename to core/arch/arm/plat-rz/common/hw_rng.c diff --git a/core/arch/arm/plat-rz/common/drivers/hw_rng_rsip.c b/core/arch/arm/plat-rz/common/hw_rng_rsip.c similarity index 100% rename from core/arch/arm/plat-rz/common/drivers/hw_rng_rsip.c rename to core/arch/arm/plat-rz/common/hw_rng_rsip.c diff --git a/core/arch/arm/plat-rz/common/sub.mk b/core/arch/arm/plat-rz/common/sub.mk index 7777b9f92..ee6611260 100644 --- a/core/arch/arm/plat-rz/common/sub.mk +++ b/core/arch/arm/plat-rz/common/sub.mk @@ -1,4 +1,6 @@ srcs-$(CFG_RZ_HUK) += huk.c +srcs-$(CFG_RZ_TSIP) += hw_rng.c +srcs-$(CFG_RZ_RSIP) += hw_rng_rsip.c subdirs-y += drivers subdirs-y += pta From 517ee9c2c3061667cc78384bfd50bda167359f93 Mon Sep 17 00:00:00 2001 From: kaiki osakaki Date: Tue, 23 Jul 2024 15:11:24 +0900 Subject: [PATCH 7/7] Rename hw_rng to hw_rng_tsip. Signed-off-by: kaiki osakaki --- core/arch/arm/plat-rz/common/{hw_rng.c => hw_rng_tsip.c} | 0 core/arch/arm/plat-rz/common/sub.mk | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename core/arch/arm/plat-rz/common/{hw_rng.c => hw_rng_tsip.c} (100%) diff --git a/core/arch/arm/plat-rz/common/hw_rng.c b/core/arch/arm/plat-rz/common/hw_rng_tsip.c similarity index 100% rename from core/arch/arm/plat-rz/common/hw_rng.c rename to core/arch/arm/plat-rz/common/hw_rng_tsip.c diff --git a/core/arch/arm/plat-rz/common/sub.mk b/core/arch/arm/plat-rz/common/sub.mk index ee6611260..8f7de7ed5 100644 --- a/core/arch/arm/plat-rz/common/sub.mk +++ b/core/arch/arm/plat-rz/common/sub.mk @@ -1,5 +1,5 @@ srcs-$(CFG_RZ_HUK) += huk.c -srcs-$(CFG_RZ_TSIP) += hw_rng.c +srcs-$(CFG_RZ_TSIP) += hw_rng_tsip.c srcs-$(CFG_RZ_RSIP) += hw_rng_rsip.c subdirs-y += drivers