Lines Matching refs:ctx

169 static void compute_aes_dec_key(struct mv_ctx *ctx)  in compute_aes_dec_key()  argument
174 if (!ctx->need_calc_aes_dkey) in compute_aes_dec_key()
177 crypto_aes_expand_key(&gen_aes_key, ctx->aes_enc_key, ctx->key_len); in compute_aes_dec_key()
179 key_pos = ctx->key_len + 24; in compute_aes_dec_key()
180 memcpy(ctx->aes_dec_key, &gen_aes_key.key_enc[key_pos], 4 * 4); in compute_aes_dec_key()
181 switch (ctx->key_len) { in compute_aes_dec_key()
187 memcpy(&ctx->aes_dec_key[4], &gen_aes_key.key_enc[key_pos], in compute_aes_dec_key()
191 ctx->need_calc_aes_dkey = 0; in compute_aes_dec_key()
198 struct mv_ctx *ctx = crypto_tfm_ctx(tfm); in mv_setkey_aes() local
209 ctx->key_len = len; in mv_setkey_aes()
210 ctx->need_calc_aes_dkey = 1; in mv_setkey_aes()
212 memcpy(ctx->aes_enc_key, key, AES_KEY_LEN); in mv_setkey_aes()
256 struct mv_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in mv_process_current_q() local
275 memcpy(cpg->sram + SRAM_DATA_KEY_P, ctx->aes_dec_key, in mv_process_current_q()
279 memcpy(cpg->sram + SRAM_DATA_KEY_P, ctx->aes_enc_key, in mv_process_current_q()
283 switch (ctx->key_len) { in mv_process_current_q()
388 static inline int mv_hash_import_sha1_ctx(const struct mv_req_hash_ctx *ctx, in mv_hash_import_sha1_ctx() argument
394 shash_state.count = ctx->count + ctx->count_add; in mv_hash_import_sha1_ctx()
396 shash_state.state[i] = ctx->state[i]; in mv_hash_import_sha1_ctx()
397 memcpy(shash_state.buffer, ctx->buffer, sizeof(shash_state.buffer)); in mv_hash_import_sha1_ctx()
426 static void mv_save_digest_state(struct mv_req_hash_ctx *ctx) in mv_save_digest_state() argument
428 ctx->state[0] = readl(cpg->reg + DIGEST_INITIAL_VAL_A); in mv_save_digest_state()
429 ctx->state[1] = readl(cpg->reg + DIGEST_INITIAL_VAL_B); in mv_save_digest_state()
430 ctx->state[2] = readl(cpg->reg + DIGEST_INITIAL_VAL_C); in mv_save_digest_state()
431 ctx->state[3] = readl(cpg->reg + DIGEST_INITIAL_VAL_D); in mv_save_digest_state()
432 ctx->state[4] = readl(cpg->reg + DIGEST_INITIAL_VAL_E); in mv_save_digest_state()
438 struct mv_req_hash_ctx *ctx = ahash_request_ctx(req); in mv_hash_algo_completion() local
440 if (ctx->extra_bytes) in mv_hash_algo_completion()
441 copy_src_to_buf(&cpg->p, ctx->buffer, ctx->extra_bytes); in mv_hash_algo_completion()
444 if (likely(ctx->last_chunk)) { in mv_hash_algo_completion()
445 if (likely(ctx->count <= MAX_HW_HASH_SIZE)) { in mv_hash_algo_completion()
450 mv_save_digest_state(ctx); in mv_hash_algo_completion()
454 mv_save_digest_state(ctx); in mv_hash_algo_completion()
549 struct mv_req_hash_ctx *ctx = ahash_request_ctx(req); in mv_start_new_hash_req() local
553 hw_bytes = req->nbytes + ctx->extra_bytes; in mv_start_new_hash_req()
554 old_extra_bytes = ctx->extra_bytes; in mv_start_new_hash_req()
556 ctx->extra_bytes = hw_bytes % SHA1_BLOCK_SIZE; in mv_start_new_hash_req()
557 if (ctx->extra_bytes != 0 in mv_start_new_hash_req()
558 && (!ctx->last_chunk || ctx->count > MAX_HW_HASH_SIZE)) in mv_start_new_hash_req()
559 hw_bytes -= ctx->extra_bytes; in mv_start_new_hash_req()
561 ctx->extra_bytes = 0; in mv_start_new_hash_req()
572 memcpy(cpg->sram + SRAM_DATA_IN_START, ctx->buffer, in mv_start_new_hash_req()
579 copy_src_to_buf(p, ctx->buffer + old_extra_bytes, in mv_start_new_hash_req()
580 ctx->extra_bytes - old_extra_bytes); in mv_start_new_hash_req()
582 if (ctx->last_chunk) in mv_start_new_hash_req()
665 struct mv_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in mv_dec_aes_ecb() local
671 compute_aes_dec_key(ctx); in mv_dec_aes_ecb()
687 struct mv_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in mv_dec_aes_cbc() local
693 compute_aes_dec_key(ctx); in mv_dec_aes_cbc()
703 static void mv_init_hash_req_ctx(struct mv_req_hash_ctx *ctx, int op, in mv_init_hash_req_ctx() argument
707 memset(ctx, 0, sizeof(*ctx)); in mv_init_hash_req_ctx()
708 ctx->op = op; in mv_init_hash_req_ctx()
709 ctx->count = req_len; in mv_init_hash_req_ctx()
710 ctx->first_hash = 1; in mv_init_hash_req_ctx()
711 ctx->last_chunk = is_last; in mv_init_hash_req_ctx()
712 ctx->count_add = count_add; in mv_init_hash_req_ctx()
715 static void mv_update_hash_req_ctx(struct mv_req_hash_ctx *ctx, int is_last, in mv_update_hash_req_ctx() argument
718 ctx->last_chunk = is_last; in mv_update_hash_req_ctx()
719 ctx->count += req_len; in mv_update_hash_req_ctx()
741 struct mv_req_hash_ctx *ctx = ahash_request_ctx(req); in mv_hash_final() local
744 mv_update_hash_req_ctx(ctx, 1, 0); in mv_hash_final()
762 static void mv_hash_init_ivs(struct mv_tfm_hash_ctx *ctx, const void *istate, in mv_hash_init_ivs() argument
768 ctx->ivs[i] = cpu_to_be32(isha1_state->state[i]); in mv_hash_init_ivs()
769 ctx->ivs[i + 5] = cpu_to_be32(osha1_state->state[i]); in mv_hash_init_ivs()
777 struct mv_tfm_hash_ctx *ctx = crypto_tfm_ctx(&tfm->base); in mv_hash_setkey() local
780 if (!ctx->base_hash) in mv_hash_setkey()
783 rc = crypto_shash_setkey(ctx->fallback, key, keylen); in mv_hash_setkey()
789 bs = crypto_shash_blocksize(ctx->base_hash); in mv_hash_setkey()
790 ds = crypto_shash_digestsize(ctx->base_hash); in mv_hash_setkey()
791 ss = crypto_shash_statesize(ctx->base_hash); in mv_hash_setkey()
794 SHASH_DESC_ON_STACK(shash, ctx->base_hash); in mv_hash_setkey()
800 shash->tfm = ctx->base_hash; in mv_hash_setkey()
801 shash->flags = crypto_shash_get_flags(ctx->base_hash) & in mv_hash_setkey()
832 mv_hash_init_ivs(ctx, ipad, opad); in mv_hash_setkey()
842 struct mv_tfm_hash_ctx *ctx = crypto_tfm_ctx(tfm); in mv_cra_hash_init() local
847 ctx->op = op; in mv_cra_hash_init()
848 ctx->count_add = count_add; in mv_cra_hash_init()
860 ctx->fallback = fallback_tfm; in mv_cra_hash_init()
874 ctx->base_hash = base_hash; in mv_cra_hash_init()
878 crypto_shash_descsize(ctx->fallback)); in mv_cra_hash_init()
888 struct mv_tfm_hash_ctx *ctx = crypto_tfm_ctx(tfm); in mv_cra_hash_exit() local
890 crypto_free_shash(ctx->fallback); in mv_cra_hash_exit()
891 if (ctx->base_hash) in mv_cra_hash_exit()
892 crypto_free_shash(ctx->base_hash); in mv_cra_hash_exit()