Lines Matching refs:ctx
24 mbedtls_aes_context ctx; in crypto_aes_expand_enc_key()
26 memset(&ctx, 0, sizeof(ctx)); in crypto_aes_expand_enc_key()
27 mbedtls_aes_init(&ctx); in crypto_aes_expand_enc_key()
28 if (mbedtls_aes_setkey_enc(&ctx, key, key_len * 8) != 0) in crypto_aes_expand_enc_key()
31 if (enc_keylen > sizeof(ctx.buf)) in crypto_aes_expand_enc_key()
33 memcpy(enc_key, ctx.buf, enc_keylen); in crypto_aes_expand_enc_key()
34 *rounds = ctx.nr; in crypto_aes_expand_enc_key()
35 mbedtls_aes_free(&ctx); in crypto_aes_expand_enc_key()
46 mbedtls_aes_context ctx; in crypto_aes_enc_block()
48 memset(&ctx, 0, sizeof(ctx)); in crypto_aes_enc_block()
49 mbedtls_aes_init(&ctx); in crypto_aes_enc_block()
50 if (enc_keylen > sizeof(ctx.buf)) in crypto_aes_enc_block()
52 memcpy(ctx.buf, enc_key, enc_keylen); in crypto_aes_enc_block()
53 ctx.rk = ctx.buf; in crypto_aes_enc_block()
54 ctx.nr = rounds; in crypto_aes_enc_block()
55 mbedtls_aes_encrypt(&ctx, src, dst); in crypto_aes_enc_block()
56 mbedtls_aes_free(&ctx); in crypto_aes_enc_block()
61 void mbedtls_aes_init(mbedtls_aes_context *ctx) in mbedtls_aes_init() argument
63 assert(ctx); in mbedtls_aes_init()
64 memset(ctx, 0, sizeof(*ctx)); in mbedtls_aes_init()
67 void mbedtls_aes_free( mbedtls_aes_context *ctx ) in mbedtls_aes_free() argument
69 if (ctx) in mbedtls_aes_free()
70 mbedtls_platform_zeroize(ctx, sizeof(*ctx)); in mbedtls_aes_free()
73 int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, in mbedtls_aes_setkey_enc() argument
76 assert(ctx && key); in mbedtls_aes_setkey_enc()
81 if (crypto_accel_aes_expand_keys(key, keybits / 8, ctx->key, NULL, in mbedtls_aes_setkey_enc()
82 sizeof(ctx->key), &ctx->round_count)) in mbedtls_aes_setkey_enc()
88 int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, in mbedtls_aes_setkey_dec() argument
91 uint32_t enc_key[sizeof(ctx->key)] = { 0 }; in mbedtls_aes_setkey_dec()
93 assert(ctx && key); in mbedtls_aes_setkey_dec()
98 if (crypto_accel_aes_expand_keys(key, keybits / 8, enc_key, ctx->key, in mbedtls_aes_setkey_dec()
99 sizeof(ctx->key), &ctx->round_count)) in mbedtls_aes_setkey_dec()