Lines Matching refs:ctx
275 static int rk_sha_init(struct udevice *dev, sha_context *ctx, in rk_sha_init() argument
283 if ((ctx->algo & priv->capability) == 0) in rk_sha_init()
299 ce_algo = rk_get_cemode(rk_hash_map, ARRAY_SIZE(rk_hash_map), ctx->algo); in rk_sha_init()
381 static int rockchip_crypto_sha_init(struct udevice *dev, sha_context *ctx) in rockchip_crypto_sha_init() argument
383 return rk_sha_init(dev, ctx, NULL, 0, false); in rockchip_crypto_sha_init()
391 static int rockchip_crypto_sha_final(struct udevice *dev, sha_context *ctx, u8 *output) in rockchip_crypto_sha_final() argument
401 nbits = crypto_algo_nbits(ctx->algo); in rockchip_crypto_sha_final()
403 if (hash_ctx->length != ctx->length) { in rockchip_crypto_sha_final()
405 hash_ctx->length, ctx->length); in rockchip_crypto_sha_final()
422 static int rockchip_crypto_hmac_init(struct udevice *dev, sha_context *ctx, u8 *key, u32 key_len) in rockchip_crypto_hmac_init() argument
424 return rk_sha_init(dev, ctx, key, key_len, true); in rockchip_crypto_hmac_init()
432 static int rockchip_crypto_hmac_final(struct udevice *dev, sha_context *ctx, u8 *output) in rockchip_crypto_hmac_final() argument
434 return rockchip_crypto_sha_final(dev, ctx, output); in rockchip_crypto_hmac_final()
708 u32 ce_algo, u32 ce_mode, cipher_context *ctx) in rk_set_symm_td_buf_key() argument
714 memcpy(td_buf->key1, ctx->key, ctx->key_len); in rk_set_symm_td_buf_key()
715 memcpy(td_buf->key2, ctx->twk_key, ctx->key_len); in rk_set_symm_td_buf_key()
717 memcpy(td_buf->key1, ctx->key, ctx->key_len); in rk_set_symm_td_buf_key()
720 if (ctx->key_len == DES_KEYSIZE * 2 && in rk_set_symm_td_buf_key()
751 static int rk_crypto_cipher(struct udevice *dev, cipher_context *ctx, in rk_crypto_cipher() argument
763 if (!ctx->key && ctx->key_len) in rk_crypto_cipher()
766 ret = rk_get_cipher_cemode(ctx->algo, ctx->mode, &ce_algo, &ce_mode); in rk_crypto_cipher()
780 hw_ctx->td->ctrl.key_size = rk_get_td_keysize(ce_algo, ce_mode, ctx->key_len); in rk_crypto_cipher()
786 memcpy(hw_ctx->td_buf->iv, ctx->iv, ctx->iv_len); in rk_crypto_cipher()
787 hw_ctx->td->ctrl.iv_len = ctx->iv_len; in rk_crypto_cipher()
790 ret = rk_set_symm_td_buf_key(hw_ctx->td_buf, ce_algo, ce_mode, ctx); in rk_crypto_cipher()
806 hw_ctx->td_buf->iv, ctx->iv_len, in rk_crypto_cipher()
894 static int rockchip_crypto_cipher(struct udevice *dev, cipher_context *ctx, in rockchip_crypto_cipher() argument
897 return rk_crypto_cipher(dev, ctx, in, out, len, enc, NULL, 0, NULL); in rockchip_crypto_cipher()
900 static int rockchip_crypto_mac(struct udevice *dev, cipher_context *ctx, in rockchip_crypto_mac() argument
903 return rk_crypto_cipher(dev, ctx, in, NULL, len, true, NULL, 0, tag); in rockchip_crypto_mac()
906 static int rockchip_crypto_ae(struct udevice *dev, cipher_context *ctx, in rockchip_crypto_ae() argument
910 return rk_crypto_cipher(dev, ctx, in, out, len, true, aad, aad_len, tag); in rockchip_crypto_ae()
914 int rockchip_crypto_fw_cipher(struct udevice *dev, cipher_fw_context *ctx, in rockchip_crypto_fw_cipher() argument
921 cipher_ctx.algo = ctx->algo; in rockchip_crypto_fw_cipher()
922 cipher_ctx.mode = ctx->mode; in rockchip_crypto_fw_cipher()
923 cipher_ctx.key_len = ctx->key_len; in rockchip_crypto_fw_cipher()
924 cipher_ctx.iv = ctx->iv; in rockchip_crypto_fw_cipher()
925 cipher_ctx.iv_len = ctx->iv_len; in rockchip_crypto_fw_cipher()
948 static int rockchip_crypto_rsa_verify(struct udevice *dev, rsa_key *ctx, in rockchip_crypto_rsa_verify() argument
956 if (!ctx) in rockchip_crypto_rsa_verify()
959 if (ctx->algo != CRYPTO_RSA512 && in rockchip_crypto_rsa_verify()
960 ctx->algo != CRYPTO_RSA1024 && in rockchip_crypto_rsa_verify()
961 ctx->algo != CRYPTO_RSA2048 && in rockchip_crypto_rsa_verify()
962 ctx->algo != CRYPTO_RSA3072 && in rockchip_crypto_rsa_verify()
963 ctx->algo != CRYPTO_RSA4096) in rockchip_crypto_rsa_verify()
966 n_bits = crypto_algo_nbits(ctx->algo); in rockchip_crypto_rsa_verify()
973 ret = rk_mpa_alloc(&mpa_e, ctx->e, n_words); in rockchip_crypto_rsa_verify()
977 ret = rk_mpa_alloc(&mpa_n, ctx->n, n_words); in rockchip_crypto_rsa_verify()
981 if (ctx->c) { in rockchip_crypto_rsa_verify()
982 ret = rk_mpa_alloc(&mpa_c, ctx->c, n_words); in rockchip_crypto_rsa_verify()
1009 static int rockchip_crypto_ec_verify(struct udevice *dev, ec_key *ctx, in rockchip_crypto_ec_verify() argument
1017 if (!ctx) in rockchip_crypto_ec_verify()
1020 if (ctx->algo != CRYPTO_SM2 && in rockchip_crypto_ec_verify()
1021 ctx->algo != CRYPTO_ECC_192R1 && in rockchip_crypto_ec_verify()
1022 ctx->algo != CRYPTO_ECC_224R1 && in rockchip_crypto_ec_verify()
1023 ctx->algo != CRYPTO_ECC_256R1) in rockchip_crypto_ec_verify()
1026 n_bits = crypto_algo_nbits(ctx->algo); in rockchip_crypto_ec_verify()
1033 ret = rk_mpa_alloc(&point_P.x, ctx->x, n_words); in rockchip_crypto_ec_verify()
1034 ret |= rk_mpa_alloc(&point_P.y, ctx->y, n_words); in rockchip_crypto_ec_verify()
1044 ret = rockchip_ecc_verify(ctx->algo, hash, hash_len, &point_P, &point_sign); in rockchip_crypto_ec_verify()