Skip to content

Commit

Permalink
crypto: add drvcrypt_register_x25519() and drvcrypt_register_x448()
Browse files Browse the repository at this point in the history
Add X25519 and X448 drvcrypt.

Signed-off-by: loubaihui <loubaihui1@huawei.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
  • Loading branch information
bhLou committed Jul 26, 2023
1 parent dd148be commit 182d84a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/drivers/crypto/crypto_api/include/drvcrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ enum drvcrypt_algo_id {
CRYPTO_MATH, /* Mathematical driver */
CRYPTO_CIPHER, /* Cipher driver */
CRYPTO_ECC, /* Asymmetric ECC driver */
CRYPTO_X25519, /* Asymmetric X25519 driver */
CRYPTO_X448, /* Asymmetric X448 driver */
CRYPTO_DH, /* Asymmetric DH driver */
CRYPTO_DSA, /* Asymmetric DSA driver */
CRYPTO_AUTHENC, /* Authenticated Encryption driver */
Expand Down
36 changes: 36 additions & 0 deletions core/drivers/crypto/crypto_api/include/drvcrypt_acipher.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,40 @@ static inline TEE_Result drvcrypt_register_dsa(struct drvcrypt_dsa *ops)
return drvcrypt_register(CRYPTO_DSA, (void *)ops);
}

/*
* Crypto Library Montgomery driver operations
*/

struct drvcrypt_montgomery {
/* Allocates the Montgomery key pair */
TEE_Result (*alloc_keypair)(struct montgomery_keypair *key,
size_t size_bits);
/* Generates the Montgomery key pair */
TEE_Result (*gen_keypair)(struct montgomery_keypair *key,
size_t key_size);
/* Montgomery Shared Secret */
TEE_Result (*shared_secret)(struct drvcrypt_secret_data *sdata);
};

/*
* Register a X25519 processing driver in the crypto API
*
* @ops - Driver operations in the HW layer
*/
static inline TEE_Result drvcrypt_register_x25519(struct drvcrypt_montgomery
*ops)
{
return drvcrypt_register(CRYPTO_X25519, (void *)ops);
}

/*
* Register a X448 processing driver in the crypto API
*
* @ops - Driver operations in the HW layer
*/
static inline TEE_Result drvcrypt_register_x448(struct drvcrypt_montgomery *ops)
{
return drvcrypt_register(CRYPTO_X448, (void *)ops);
}

#endif /* __DRVCRYPT_ACIPHER_H__ */
2 changes: 1 addition & 1 deletion lib/libutee/include/utee_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#define TEE_MAIN_ALGO_X25519 0x44 /* Not in v1.2 spec */
#define TEE_MAIN_ALGO_SHAKE128 0xC3 /* OP-TEE extension */
#define TEE_MAIN_ALGO_SHAKE256 0xC4 /* OP-TEE extension */
#define TEE_MAIN_ALGO_X448 0xC5 /* OP-TEE extension */
#define TEE_MAIN_ALGO_X448 0xC5 /* OP-TEE extension */


#define TEE_CHAIN_MODE_ECB_NOPAD 0x0
Expand Down

0 comments on commit 182d84a

Please sign in to comment.