Lines Matching defs:ctx

52 void mbedtls_block_cipher_free(mbedtls_block_cipher_context_t *ctx)
55 if (ctx->engine == MBEDTLS_BLOCK_CIPHER_ENGINE_PSA) {
56 psa_destroy_key(ctx->psa_key_id);
60 switch (ctx->id) {
63 mbedtls_aes_free(&ctx->ctx.aes);
68 mbedtls_aria_free(&ctx->ctx.aria);
73 mbedtls_camellia_free(&ctx->ctx.camellia);
79 ctx->id = MBEDTLS_BLOCK_CIPHER_ID_NONE;
82 int mbedtls_block_cipher_setup(mbedtls_block_cipher_context_t *ctx,
85 ctx->id = (cipher_id == MBEDTLS_CIPHER_ID_AES) ? MBEDTLS_BLOCK_CIPHER_ID_AES :
91 psa_key_type_t psa_key_type = psa_key_type_from_block_cipher_id(ctx->id);
94 ctx->engine = MBEDTLS_BLOCK_CIPHER_ENGINE_PSA;
97 ctx->engine = MBEDTLS_BLOCK_CIPHER_ENGINE_LEGACY;
100 switch (ctx->id) {
103 mbedtls_aes_init(&ctx->ctx.aes);
108 mbedtls_aria_init(&ctx->ctx.aria);
113 mbedtls_camellia_init(&ctx->ctx.camellia);
117 ctx->id = MBEDTLS_BLOCK_CIPHER_ID_NONE;
122 int mbedtls_block_cipher_setkey(mbedtls_block_cipher_context_t *ctx,
127 if (ctx->engine == MBEDTLS_BLOCK_CIPHER_ENGINE_PSA) {
131 psa_set_key_type(&key_attr, psa_key_type_from_block_cipher_id(ctx->id));
136 status = psa_import_key(&key_attr, key, PSA_BITS_TO_BYTES(key_bitlen), &ctx->psa_key_id);
146 switch (ctx->id) {
149 return mbedtls_aes_setkey_enc(&ctx->ctx.aes, key, key_bitlen);
153 return mbedtls_aria_setkey_enc(&ctx->ctx.aria, key, key_bitlen);
157 return mbedtls_camellia_setkey_enc(&ctx->ctx.camellia, key, key_bitlen);
164 int mbedtls_block_cipher_encrypt(mbedtls_block_cipher_context_t *ctx,
169 if (ctx->engine == MBEDTLS_BLOCK_CIPHER_ENGINE_PSA) {
173 status = psa_cipher_encrypt(ctx->psa_key_id, PSA_ALG_ECB_NO_PADDING,
182 switch (ctx->id) {
185 return mbedtls_aes_crypt_ecb(&ctx->ctx.aes, MBEDTLS_AES_ENCRYPT,
190 return mbedtls_aria_crypt_ecb(&ctx->ctx.aria, input, output);
194 return mbedtls_camellia_crypt_ecb(&ctx->ctx.camellia,