11bb92983SJerome Forissier /* SPDX-License-Identifier: BSD-2-Clause */ 2e1770e71SJens Wiklander /* 3e1770e71SJens Wiklander * Copyright (c) 2014-2017, Linaro Limited 4e1770e71SJens Wiklander */ 5e1770e71SJens Wiklander 6e1770e71SJens Wiklander /* 7e1770e71SJens Wiklander * This is the Cryptographic Provider API (CP API). 8e1770e71SJens Wiklander * 9e1770e71SJens Wiklander * This defines how most crypto syscalls that implement the Cryptographic 10e1770e71SJens Wiklander * Operations API can invoke the actual providers of cryptographic algorithms 11e1770e71SJens Wiklander * (such as LibTomCrypt). 12e1770e71SJens Wiklander * 13e1770e71SJens Wiklander * To add a new provider, you need to provide an implementation of this 14e1770e71SJens Wiklander * interface. 15e1770e71SJens Wiklander * 16e1770e71SJens Wiklander * The following parameters are commonly used. 17e1770e71SJens Wiklander * 18e1770e71SJens Wiklander * @ctx: context allocated by the syscall, for later use by the algorithm 19e1770e71SJens Wiklander * @algo: algorithm identifier (TEE_ALG_*) 20e1770e71SJens Wiklander */ 21e1770e71SJens Wiklander 22e1770e71SJens Wiklander #ifndef __CRYPTO_CRYPTO_H 23e1770e71SJens Wiklander #define __CRYPTO_CRYPTO_H 24e1770e71SJens Wiklander 25e1770e71SJens Wiklander #include <tee_api_types.h> 26e1770e71SJens Wiklander 27e1770e71SJens Wiklander TEE_Result crypto_init(void); 28e1770e71SJens Wiklander 29e1770e71SJens Wiklander /* Message digest functions */ 30ecf2e014SJens Wiklander TEE_Result crypto_hash_alloc_ctx(void **ctx, uint32_t algo); 31e1770e71SJens Wiklander TEE_Result crypto_hash_init(void *ctx, uint32_t algo); 32e1770e71SJens Wiklander TEE_Result crypto_hash_update(void *ctx, uint32_t algo, const uint8_t *data, 33e1770e71SJens Wiklander size_t len); 34e1770e71SJens Wiklander TEE_Result crypto_hash_final(void *ctx, uint32_t algo, uint8_t *digest, 35e1770e71SJens Wiklander size_t len); 36ecf2e014SJens Wiklander void crypto_hash_free_ctx(void *ctx, uint32_t algo); 37ecf2e014SJens Wiklander void crypto_hash_copy_state(void *dst_ctx, void *src_ctx, uint32_t algo); 38e1770e71SJens Wiklander 39e1770e71SJens Wiklander /* Symmetric ciphers */ 4072a9b1a0SJens Wiklander TEE_Result crypto_cipher_alloc_ctx(void **ctx, uint32_t algo); 41e1770e71SJens Wiklander TEE_Result crypto_cipher_init(void *ctx, uint32_t algo, TEE_OperationMode mode, 42e1770e71SJens Wiklander const uint8_t *key1, size_t key1_len, 43e1770e71SJens Wiklander const uint8_t *key2, size_t key2_len, 44e1770e71SJens Wiklander const uint8_t *iv, size_t iv_len); 45e1770e71SJens Wiklander TEE_Result crypto_cipher_update(void *ctx, uint32_t algo, 46e1770e71SJens Wiklander TEE_OperationMode mode, bool last_block, 47e1770e71SJens Wiklander const uint8_t *data, size_t len, uint8_t *dst); 48e1770e71SJens Wiklander void crypto_cipher_final(void *ctx, uint32_t algo); 49e1770e71SJens Wiklander TEE_Result crypto_cipher_get_block_size(uint32_t algo, size_t *size); 5072a9b1a0SJens Wiklander void crypto_cipher_free_ctx(void *ctx, uint32_t algo); 5172a9b1a0SJens Wiklander void crypto_cipher_copy_state(void *dst_ctx, void *src_ctx, uint32_t algo); 52e1770e71SJens Wiklander 53e1770e71SJens Wiklander /* Message Authentication Code functions */ 5482ef73bcSJens Wiklander TEE_Result crypto_mac_alloc_ctx(void **ctx, uint32_t algo); 55e1770e71SJens Wiklander TEE_Result crypto_mac_init(void *ctx, uint32_t algo, const uint8_t *key, 56e1770e71SJens Wiklander size_t len); 57e1770e71SJens Wiklander TEE_Result crypto_mac_update(void *ctx, uint32_t algo, const uint8_t *data, 58e1770e71SJens Wiklander size_t len); 59e1770e71SJens Wiklander TEE_Result crypto_mac_final(void *ctx, uint32_t algo, uint8_t *digest, 60e1770e71SJens Wiklander size_t digest_len); 6182ef73bcSJens Wiklander void crypto_mac_free_ctx(void *ctx, uint32_t algo); 6282ef73bcSJens Wiklander void crypto_mac_copy_state(void *dst_ctx, void *src_ctx, uint32_t algo); 63e1770e71SJens Wiklander 64e1770e71SJens Wiklander /* Authenticated encryption */ 65d7ac7d0fSJens Wiklander TEE_Result crypto_authenc_alloc_ctx(void **ctx, uint32_t algo); 66e1770e71SJens Wiklander TEE_Result crypto_authenc_init(void *ctx, uint32_t algo, TEE_OperationMode mode, 67e1770e71SJens Wiklander const uint8_t *key, size_t key_len, 68e1770e71SJens Wiklander const uint8_t *nonce, size_t nonce_len, 69e1770e71SJens Wiklander size_t tag_len, size_t aad_len, 70e1770e71SJens Wiklander size_t payload_len); 71e1770e71SJens Wiklander TEE_Result crypto_authenc_update_aad(void *ctx, uint32_t algo, 72e1770e71SJens Wiklander TEE_OperationMode mode, 73e1770e71SJens Wiklander const uint8_t *data, size_t len); 74e1770e71SJens Wiklander TEE_Result crypto_authenc_update_payload(void *ctx, uint32_t algo, 75e1770e71SJens Wiklander TEE_OperationMode mode, 76e1770e71SJens Wiklander const uint8_t *src_data, 77e1770e71SJens Wiklander size_t src_len, uint8_t *dst_data, 78e1770e71SJens Wiklander size_t *dst_len); 79e1770e71SJens Wiklander TEE_Result crypto_authenc_enc_final(void *ctx, uint32_t algo, 80e1770e71SJens Wiklander const uint8_t *src_data, size_t src_len, 81e1770e71SJens Wiklander uint8_t *dst_data, size_t *dst_len, 82e1770e71SJens Wiklander uint8_t *dst_tag, size_t *dst_tag_len); 83e1770e71SJens Wiklander TEE_Result crypto_authenc_dec_final(void *ctx, uint32_t algo, 84e1770e71SJens Wiklander const uint8_t *src_data, size_t src_len, 85e1770e71SJens Wiklander uint8_t *dst_data, size_t *dst_len, 86e1770e71SJens Wiklander const uint8_t *tag, size_t tag_len); 87e1770e71SJens Wiklander void crypto_authenc_final(void *ctx, uint32_t algo); 88d7ac7d0fSJens Wiklander void crypto_authenc_free_ctx(void *ctx, uint32_t algo); 89d7ac7d0fSJens Wiklander void crypto_authenc_copy_state(void *dst_ctx, void *src_ctx, uint32_t algo); 90e1770e71SJens Wiklander 91e1770e71SJens Wiklander /* Implementation-defined big numbers */ 92e1770e71SJens Wiklander 93e1770e71SJens Wiklander /* 94e1770e71SJens Wiklander * Allocate a bignum capable of holding an unsigned integer value of 95e1770e71SJens Wiklander * up to bitsize bits 96e1770e71SJens Wiklander */ 97e1770e71SJens Wiklander struct bignum *crypto_bignum_allocate(size_t size_bits); 98e1770e71SJens Wiklander TEE_Result crypto_bignum_bin2bn(const uint8_t *from, size_t fromsize, 99e1770e71SJens Wiklander struct bignum *to); 100e1770e71SJens Wiklander size_t crypto_bignum_num_bytes(struct bignum *a); 101e1770e71SJens Wiklander size_t crypto_bignum_num_bits(struct bignum *a); 102e1770e71SJens Wiklander void crypto_bignum_bn2bin(const struct bignum *from, uint8_t *to); 103e1770e71SJens Wiklander void crypto_bignum_copy(struct bignum *to, const struct bignum *from); 104e1770e71SJens Wiklander void crypto_bignum_free(struct bignum *a); 105e1770e71SJens Wiklander void crypto_bignum_clear(struct bignum *a); 106e1770e71SJens Wiklander 107e1770e71SJens Wiklander /* return -1 if a<b, 0 if a==b, +1 if a>b */ 108e1770e71SJens Wiklander int32_t crypto_bignum_compare(struct bignum *a, struct bignum *b); 109e1770e71SJens Wiklander 110e1770e71SJens Wiklander /* Asymmetric algorithms */ 111e1770e71SJens Wiklander 112e1770e71SJens Wiklander struct rsa_keypair { 113e1770e71SJens Wiklander struct bignum *e; /* Public exponent */ 114e1770e71SJens Wiklander struct bignum *d; /* Private exponent */ 115e1770e71SJens Wiklander struct bignum *n; /* Modulus */ 116e1770e71SJens Wiklander 117e1770e71SJens Wiklander /* Optional CRT parameters (all NULL if unused) */ 118e1770e71SJens Wiklander struct bignum *p; /* N = pq */ 119e1770e71SJens Wiklander struct bignum *q; 120e1770e71SJens Wiklander struct bignum *qp; /* 1/q mod p */ 121e1770e71SJens Wiklander struct bignum *dp; /* d mod (p-1) */ 122e1770e71SJens Wiklander struct bignum *dq; /* d mod (q-1) */ 123e1770e71SJens Wiklander }; 124e1770e71SJens Wiklander 125e1770e71SJens Wiklander struct rsa_public_key { 126e1770e71SJens Wiklander struct bignum *e; /* Public exponent */ 127e1770e71SJens Wiklander struct bignum *n; /* Modulus */ 128e1770e71SJens Wiklander }; 129e1770e71SJens Wiklander 130e1770e71SJens Wiklander struct dsa_keypair { 131e1770e71SJens Wiklander struct bignum *g; /* Generator of subgroup (public) */ 132e1770e71SJens Wiklander struct bignum *p; /* Prime number (public) */ 133e1770e71SJens Wiklander struct bignum *q; /* Order of subgroup (public) */ 134e1770e71SJens Wiklander struct bignum *y; /* Public key */ 135e1770e71SJens Wiklander struct bignum *x; /* Private key */ 136e1770e71SJens Wiklander }; 137e1770e71SJens Wiklander 138e1770e71SJens Wiklander struct dsa_public_key { 139e1770e71SJens Wiklander struct bignum *g; /* Generator of subgroup (public) */ 140e1770e71SJens Wiklander struct bignum *p; /* Prime number (public) */ 141e1770e71SJens Wiklander struct bignum *q; /* Order of subgroup (public) */ 142e1770e71SJens Wiklander struct bignum *y; /* Public key */ 143e1770e71SJens Wiklander }; 144e1770e71SJens Wiklander 145e1770e71SJens Wiklander struct dh_keypair { 146e1770e71SJens Wiklander struct bignum *g; /* Generator of Z_p (shared) */ 147e1770e71SJens Wiklander struct bignum *p; /* Prime modulus (shared) */ 148e1770e71SJens Wiklander struct bignum *x; /* Private key */ 149e1770e71SJens Wiklander struct bignum *y; /* Public key y = g^x */ 150e1770e71SJens Wiklander 151e1770e71SJens Wiklander /* 152e1770e71SJens Wiklander * Optional parameters used by key generation. 153e1770e71SJens Wiklander * When not used, q == NULL and xbits == 0 154e1770e71SJens Wiklander */ 155e1770e71SJens Wiklander struct bignum *q; /* x must be in the range [2, q-2] */ 156e1770e71SJens Wiklander uint32_t xbits; /* Number of bits in the private key */ 157e1770e71SJens Wiklander }; 158e1770e71SJens Wiklander 159e1770e71SJens Wiklander struct ecc_public_key { 160e1770e71SJens Wiklander struct bignum *x; /* Public value x */ 161e1770e71SJens Wiklander struct bignum *y; /* Public value y */ 162e1770e71SJens Wiklander uint32_t curve; /* Curve type */ 163e1770e71SJens Wiklander }; 164e1770e71SJens Wiklander 165e1770e71SJens Wiklander struct ecc_keypair { 166e1770e71SJens Wiklander struct bignum *d; /* Private value */ 167e1770e71SJens Wiklander struct bignum *x; /* Public value x */ 168e1770e71SJens Wiklander struct bignum *y; /* Public value y */ 169e1770e71SJens Wiklander uint32_t curve; /* Curve type */ 170e1770e71SJens Wiklander }; 171e1770e71SJens Wiklander 172e1770e71SJens Wiklander /* 173e1770e71SJens Wiklander * Key allocation functions 174e1770e71SJens Wiklander * Allocate the bignum's inside a key structure. 175e1770e71SJens Wiklander * TEE core will later use crypto_bignum_free(). 176e1770e71SJens Wiklander */ 177e1770e71SJens Wiklander TEE_Result crypto_acipher_alloc_rsa_keypair(struct rsa_keypair *s, 178e1770e71SJens Wiklander size_t key_size_bits); 179e1770e71SJens Wiklander TEE_Result crypto_acipher_alloc_rsa_public_key(struct rsa_public_key *s, 180e1770e71SJens Wiklander size_t key_size_bits); 181e1770e71SJens Wiklander void crypto_acipher_free_rsa_public_key(struct rsa_public_key *s); 182e1770e71SJens Wiklander TEE_Result crypto_acipher_alloc_dsa_keypair(struct dsa_keypair *s, 183e1770e71SJens Wiklander size_t key_size_bits); 184e1770e71SJens Wiklander TEE_Result crypto_acipher_alloc_dsa_public_key(struct dsa_public_key *s, 185e1770e71SJens Wiklander size_t key_size_bits); 186e1770e71SJens Wiklander TEE_Result crypto_acipher_alloc_dh_keypair(struct dh_keypair *s, 187e1770e71SJens Wiklander size_t key_size_bits); 188e1770e71SJens Wiklander TEE_Result crypto_acipher_alloc_ecc_public_key(struct ecc_public_key *s, 189e1770e71SJens Wiklander size_t key_size_bits); 190e1770e71SJens Wiklander TEE_Result crypto_acipher_alloc_ecc_keypair(struct ecc_keypair *s, 191e1770e71SJens Wiklander size_t key_size_bits); 192e1770e71SJens Wiklander void crypto_acipher_free_ecc_public_key(struct ecc_public_key *s); 193e1770e71SJens Wiklander 194e1770e71SJens Wiklander /* 195e1770e71SJens Wiklander * Key generation functions 196e1770e71SJens Wiklander */ 197e1770e71SJens Wiklander TEE_Result crypto_acipher_gen_rsa_key(struct rsa_keypair *key, size_t key_size); 198e1770e71SJens Wiklander TEE_Result crypto_acipher_gen_dsa_key(struct dsa_keypair *key, size_t key_size); 199e1770e71SJens Wiklander TEE_Result crypto_acipher_gen_dh_key(struct dh_keypair *key, struct bignum *q, 200e1770e71SJens Wiklander size_t xbits); 201e1770e71SJens Wiklander TEE_Result crypto_acipher_gen_ecc_key(struct ecc_keypair *key); 202e1770e71SJens Wiklander 203e1770e71SJens Wiklander TEE_Result crypto_acipher_dh_shared_secret(struct dh_keypair *private_key, 204e1770e71SJens Wiklander struct bignum *public_key, 205e1770e71SJens Wiklander struct bignum *secret); 206e1770e71SJens Wiklander 207e1770e71SJens Wiklander TEE_Result crypto_acipher_rsanopad_decrypt(struct rsa_keypair *key, 208e1770e71SJens Wiklander const uint8_t *src, size_t src_len, 209e1770e71SJens Wiklander uint8_t *dst, size_t *dst_len); 210e1770e71SJens Wiklander TEE_Result crypto_acipher_rsanopad_encrypt(struct rsa_public_key *key, 211e1770e71SJens Wiklander const uint8_t *src, size_t src_len, 212e1770e71SJens Wiklander uint8_t *dst, size_t *dst_len); 213e1770e71SJens Wiklander TEE_Result crypto_acipher_rsaes_decrypt(uint32_t algo, struct rsa_keypair *key, 214e1770e71SJens Wiklander const uint8_t *label, size_t label_len, 215e1770e71SJens Wiklander const uint8_t *src, size_t src_len, 216e1770e71SJens Wiklander uint8_t *dst, size_t *dst_len); 217e1770e71SJens Wiklander TEE_Result crypto_acipher_rsaes_encrypt(uint32_t algo, 218e1770e71SJens Wiklander struct rsa_public_key *key, 219e1770e71SJens Wiklander const uint8_t *label, size_t label_len, 220e1770e71SJens Wiklander const uint8_t *src, size_t src_len, 221e1770e71SJens Wiklander uint8_t *dst, size_t *dst_len); 222e1770e71SJens Wiklander /* RSA SSA sign/verify: if salt_len == -1, use default value */ 223e1770e71SJens Wiklander TEE_Result crypto_acipher_rsassa_sign(uint32_t algo, struct rsa_keypair *key, 224e1770e71SJens Wiklander int salt_len, const uint8_t *msg, 225e1770e71SJens Wiklander size_t msg_len, uint8_t *sig, 226e1770e71SJens Wiklander size_t *sig_len); 227e1770e71SJens Wiklander TEE_Result crypto_acipher_rsassa_verify(uint32_t algo, 228e1770e71SJens Wiklander struct rsa_public_key *key, 229e1770e71SJens Wiklander int salt_len, const uint8_t *msg, 230e1770e71SJens Wiklander size_t msg_len, const uint8_t *sig, 231e1770e71SJens Wiklander size_t sig_len); 232e1770e71SJens Wiklander TEE_Result crypto_acipher_dsa_sign(uint32_t algo, struct dsa_keypair *key, 233e1770e71SJens Wiklander const uint8_t *msg, size_t msg_len, 234e1770e71SJens Wiklander uint8_t *sig, size_t *sig_len); 235e1770e71SJens Wiklander TEE_Result crypto_acipher_dsa_verify(uint32_t algo, struct dsa_public_key *key, 236e1770e71SJens Wiklander const uint8_t *msg, size_t msg_len, 237e1770e71SJens Wiklander const uint8_t *sig, size_t sig_len); 238e1770e71SJens Wiklander TEE_Result crypto_acipher_ecc_sign(uint32_t algo, struct ecc_keypair *key, 239e1770e71SJens Wiklander const uint8_t *msg, size_t msg_len, 240e1770e71SJens Wiklander uint8_t *sig, size_t *sig_len); 241e1770e71SJens Wiklander TEE_Result crypto_acipher_ecc_verify(uint32_t algo, struct ecc_public_key *key, 242e1770e71SJens Wiklander const uint8_t *msg, size_t msg_len, 243e1770e71SJens Wiklander const uint8_t *sig, size_t sig_len); 244e1770e71SJens Wiklander TEE_Result crypto_acipher_ecc_shared_secret(struct ecc_keypair *private_key, 245e1770e71SJens Wiklander struct ecc_public_key *public_key, 246e1770e71SJens Wiklander void *secret, 247e1770e71SJens Wiklander unsigned long *secret_len); 248e1770e71SJens Wiklander 249e1770e71SJens Wiklander /* 250e1770e71SJens Wiklander * Verifies a SHA-256 hash, doesn't require crypto_init() to be called in 251e1770e71SJens Wiklander * advance and has as few dependencies as possible. 252e1770e71SJens Wiklander * 253e1770e71SJens Wiklander * This function is primarily used by pager and early initialization code 254e1770e71SJens Wiklander * where the complete crypto library isn't available. 255e1770e71SJens Wiklander */ 256e1770e71SJens Wiklander TEE_Result hash_sha256_check(const uint8_t *hash, const uint8_t *data, 257e1770e71SJens Wiklander size_t data_size); 258e1770e71SJens Wiklander 259b8bb0afaSSumit Garg /* 260b8bb0afaSSumit Garg * Computes a SHA-512/256 hash, vetted conditioner as per NIST.SP.800-90B. 261b8bb0afaSSumit Garg * It doesn't require crypto_init() to be called in advance and has as few 262b8bb0afaSSumit Garg * dependencies as possible. 263b8bb0afaSSumit Garg * 264b8bb0afaSSumit Garg * This function could be used inside interrupt context where the crypto 265b8bb0afaSSumit Garg * library can't be used due to mutex handling. 266b8bb0afaSSumit Garg */ 267b8bb0afaSSumit Garg TEE_Result hash_sha512_256_compute(uint8_t *digest, const uint8_t *data, 268b8bb0afaSSumit Garg size_t data_size); 269b8bb0afaSSumit Garg 2706e954a6eSJens Wiklander #define CRYPTO_RNG_SRC_IS_QUICK(sid) (!!((sid) & 1)) 271e1770e71SJens Wiklander 2726e954a6eSJens Wiklander /* 2736e954a6eSJens Wiklander * enum crypto_rng_src - RNG entropy source 2746e954a6eSJens Wiklander * 2756e954a6eSJens Wiklander * Identifiers for different RNG entropy sources. The lowest bit indicates 2766e954a6eSJens Wiklander * if the source is to be merely queued (bit is 1) or if it's delivered 2776e954a6eSJens Wiklander * directly to the pool. The difference is that in the latter case RPC to 2786e954a6eSJens Wiklander * normal world can be performed and in the former it must not. 2796e954a6eSJens Wiklander */ 2806e954a6eSJens Wiklander enum crypto_rng_src { 2816e954a6eSJens Wiklander CRYPTO_RNG_SRC_JITTER_SESSION = (0 << 1 | 0), 2826e954a6eSJens Wiklander CRYPTO_RNG_SRC_JITTER_RPC = (1 << 1 | 1), 2836e954a6eSJens Wiklander CRYPTO_RNG_SRC_NONSECURE = (1 << 1 | 0), 2846e954a6eSJens Wiklander }; 285e1770e71SJens Wiklander 2866e954a6eSJens Wiklander /* 2876e954a6eSJens Wiklander * crypto_rng_init() - initialize the RNG 2886e954a6eSJens Wiklander * @data: buffer with initial seed 2896e954a6eSJens Wiklander * @dlen: length of @data 2906e954a6eSJens Wiklander */ 2916e954a6eSJens Wiklander TEE_Result crypto_rng_init(const void *data, size_t dlen); 2926e954a6eSJens Wiklander 2936e954a6eSJens Wiklander /* 2946e954a6eSJens Wiklander * crypto_rng_add_event() - supply entropy to RNG from a source 2956e954a6eSJens Wiklander * @sid: Source identifier, should be unique for a specific source 2966e954a6eSJens Wiklander * @pnum: Pool number, acquired using crypto_rng_get_next_pool_num() 2976e954a6eSJens Wiklander * @data: Data associated with the event 2986e954a6eSJens Wiklander * @dlen: Length of @data 2996e954a6eSJens Wiklander * 3006e954a6eSJens Wiklander * @sid controls whether the event is merly queued in a ring buffer or if 3016e954a6eSJens Wiklander * it's added to one of the pools directly. If CRYPTO_RNG_SRC_IS_QUICK() is 3026e954a6eSJens Wiklander * true (lowest bit set) events are queue otherwise added to corresponding 3036e954a6eSJens Wiklander * pool. If CRYPTO_RNG_SRC_IS_QUICK() is false, eventual queued events are 3046e954a6eSJens Wiklander * added to their queues too. 3056e954a6eSJens Wiklander */ 3066e954a6eSJens Wiklander void crypto_rng_add_event(enum crypto_rng_src sid, unsigned int *pnum, 3076e954a6eSJens Wiklander const void *data, size_t dlen); 3086e954a6eSJens Wiklander 3096e954a6eSJens Wiklander /* 3106e954a6eSJens Wiklander * crypto_rng_read() - read cryptograhically secure RNG 3116e954a6eSJens Wiklander * @buf: Buffer to hold the data 3126e954a6eSJens Wiklander * @len: Length of buffer. 3136e954a6eSJens Wiklander * 3146e954a6eSJens Wiklander * Eventual queued events are also added to their pools during this 3156e954a6eSJens Wiklander * function call. 3166e954a6eSJens Wiklander */ 3176e954a6eSJens Wiklander TEE_Result crypto_rng_read(void *buf, size_t len); 318e1770e71SJens Wiklander 319*e7dbc357SSummer Qin /* 320*e7dbc357SSummer Qin * crypto_aes_expand_enc_key() - Expand an AES key 321*e7dbc357SSummer Qin * @key: AES key buffer 322*e7dbc357SSummer Qin * @key_len: Size of the the @key buffer in bytes 323*e7dbc357SSummer Qin * @enc_key: Expanded AES encryption key buffer 324*e7dbc357SSummer Qin * @enc_keylen: Size of the @enc_key buffer in bytes 325*e7dbc357SSummer Qin * @rounds: Number of rounds to be used during encryption 326*e7dbc357SSummer Qin */ 3270d360202SJens Wiklander TEE_Result crypto_aes_expand_enc_key(const void *key, size_t key_len, 328*e7dbc357SSummer Qin void *enc_key, size_t enc_keylen, 329*e7dbc357SSummer Qin unsigned int *rounds); 330*e7dbc357SSummer Qin 331*e7dbc357SSummer Qin /* 332*e7dbc357SSummer Qin * crypto_aes_enc_block() - Encrypt an AES block 333*e7dbc357SSummer Qin * @enc_key: Expanded AES encryption key 334*e7dbc357SSummer Qin * @enc_keylen: Size of @enc_key in bytes 335*e7dbc357SSummer Qin * @rounds: Number of rounds 336*e7dbc357SSummer Qin * @src: Source buffer of one AES block (16 bytes) 337*e7dbc357SSummer Qin * @dst: Destination buffer of one AES block (16 bytes) 338*e7dbc357SSummer Qin */ 339*e7dbc357SSummer Qin void crypto_aes_enc_block(const void *enc_key, size_t enc_keylen, 340*e7dbc357SSummer Qin unsigned int rounds, const void *src, void *dst); 3410d360202SJens Wiklander 342e1770e71SJens Wiklander #endif /* __CRYPTO_CRYPTO_H */ 343