Lines Matching refs:ctx

174 static void compute_aes_dec_key(struct mv_ctx *ctx)  in compute_aes_dec_key()  argument
179 if (!ctx->need_calc_aes_dkey) in compute_aes_dec_key()
182 crypto_aes_expand_key(&gen_aes_key, ctx->aes_enc_key, ctx->key_len); in compute_aes_dec_key()
184 key_pos = ctx->key_len + 24; in compute_aes_dec_key()
185 memcpy(ctx->aes_dec_key, &gen_aes_key.key_enc[key_pos], 4 * 4); in compute_aes_dec_key()
186 switch (ctx->key_len) { in compute_aes_dec_key()
192 memcpy(&ctx->aes_dec_key[4], &gen_aes_key.key_enc[key_pos], in compute_aes_dec_key()
196 ctx->need_calc_aes_dkey = 0; in compute_aes_dec_key()
203 struct mv_ctx *ctx = crypto_tfm_ctx(tfm); in mv_setkey_aes() local
214 ctx->key_len = len; in mv_setkey_aes()
215 ctx->need_calc_aes_dkey = 1; in mv_setkey_aes()
217 memcpy(ctx->aes_enc_key, key, AES_KEY_LEN); in mv_setkey_aes()
261 struct mv_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in mv_process_current_q() local
280 memcpy(cpg->sram + SRAM_DATA_KEY_P, ctx->aes_dec_key, in mv_process_current_q()
284 memcpy(cpg->sram + SRAM_DATA_KEY_P, ctx->aes_enc_key, in mv_process_current_q()
288 switch (ctx->key_len) { in mv_process_current_q()
393 static inline int mv_hash_import_sha1_ctx(const struct mv_req_hash_ctx *ctx, in mv_hash_import_sha1_ctx() argument
399 shash_state.count = ctx->count + ctx->count_add; in mv_hash_import_sha1_ctx()
401 shash_state.state[i] = ctx->state[i]; in mv_hash_import_sha1_ctx()
402 memcpy(shash_state.buffer, ctx->buffer, sizeof(shash_state.buffer)); in mv_hash_import_sha1_ctx()
431 static void mv_save_digest_state(struct mv_req_hash_ctx *ctx) in mv_save_digest_state() argument
433 ctx->state[0] = readl(cpg->reg + DIGEST_INITIAL_VAL_A); in mv_save_digest_state()
434 ctx->state[1] = readl(cpg->reg + DIGEST_INITIAL_VAL_B); in mv_save_digest_state()
435 ctx->state[2] = readl(cpg->reg + DIGEST_INITIAL_VAL_C); in mv_save_digest_state()
436 ctx->state[3] = readl(cpg->reg + DIGEST_INITIAL_VAL_D); in mv_save_digest_state()
437 ctx->state[4] = readl(cpg->reg + DIGEST_INITIAL_VAL_E); in mv_save_digest_state()
443 struct mv_req_hash_ctx *ctx = ahash_request_ctx(req); in mv_hash_algo_completion() local
445 if (ctx->extra_bytes) in mv_hash_algo_completion()
446 copy_src_to_buf(&cpg->p, ctx->buffer, ctx->extra_bytes); in mv_hash_algo_completion()
449 if (likely(ctx->last_chunk)) { in mv_hash_algo_completion()
450 if (likely(ctx->count <= MAX_HW_HASH_SIZE)) { in mv_hash_algo_completion()
455 mv_save_digest_state(ctx); in mv_hash_algo_completion()
459 mv_save_digest_state(ctx); in mv_hash_algo_completion()
554 struct mv_req_hash_ctx *ctx = ahash_request_ctx(req); in mv_start_new_hash_req() local
558 hw_bytes = req->nbytes + ctx->extra_bytes; in mv_start_new_hash_req()
559 old_extra_bytes = ctx->extra_bytes; in mv_start_new_hash_req()
561 ctx->extra_bytes = hw_bytes % SHA1_BLOCK_SIZE; in mv_start_new_hash_req()
562 if (ctx->extra_bytes != 0 in mv_start_new_hash_req()
563 && (!ctx->last_chunk || ctx->count > MAX_HW_HASH_SIZE)) in mv_start_new_hash_req()
564 hw_bytes -= ctx->extra_bytes; in mv_start_new_hash_req()
566 ctx->extra_bytes = 0; in mv_start_new_hash_req()
577 memcpy(cpg->sram + SRAM_DATA_IN_START, ctx->buffer, in mv_start_new_hash_req()
584 copy_src_to_buf(p, ctx->buffer + old_extra_bytes, in mv_start_new_hash_req()
585 ctx->extra_bytes - old_extra_bytes); in mv_start_new_hash_req()
587 if (ctx->last_chunk) in mv_start_new_hash_req()
670 struct mv_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in mv_dec_aes_ecb() local
676 compute_aes_dec_key(ctx); in mv_dec_aes_ecb()
692 struct mv_ctx *ctx = crypto_tfm_ctx(req->base.tfm); in mv_dec_aes_cbc() local
698 compute_aes_dec_key(ctx); in mv_dec_aes_cbc()
708 static void mv_init_hash_req_ctx(struct mv_req_hash_ctx *ctx, int op, in mv_init_hash_req_ctx() argument
712 memset(ctx, 0, sizeof(*ctx)); in mv_init_hash_req_ctx()
713 ctx->op = op; in mv_init_hash_req_ctx()
714 ctx->count = req_len; in mv_init_hash_req_ctx()
715 ctx->first_hash = 1; in mv_init_hash_req_ctx()
716 ctx->last_chunk = is_last; in mv_init_hash_req_ctx()
717 ctx->count_add = count_add; in mv_init_hash_req_ctx()
720 static void mv_update_hash_req_ctx(struct mv_req_hash_ctx *ctx, int is_last, in mv_update_hash_req_ctx() argument
723 ctx->last_chunk = is_last; in mv_update_hash_req_ctx()
724 ctx->count += req_len; in mv_update_hash_req_ctx()
746 struct mv_req_hash_ctx *ctx = ahash_request_ctx(req); in mv_hash_final() local
749 mv_update_hash_req_ctx(ctx, 1, 0); in mv_hash_final()
767 static void mv_hash_init_ivs(struct mv_tfm_hash_ctx *ctx, const void *istate, in mv_hash_init_ivs() argument
773 ctx->ivs[i] = cpu_to_be32(isha1_state->state[i]); in mv_hash_init_ivs()
774 ctx->ivs[i + 5] = cpu_to_be32(osha1_state->state[i]); in mv_hash_init_ivs()
782 struct mv_tfm_hash_ctx *ctx = crypto_tfm_ctx(&tfm->base); in mv_hash_setkey() local
785 if (!ctx->base_hash) in mv_hash_setkey()
788 rc = crypto_shash_setkey(ctx->fallback, key, keylen); in mv_hash_setkey()
794 bs = crypto_shash_blocksize(ctx->base_hash); in mv_hash_setkey()
795 ds = crypto_shash_digestsize(ctx->base_hash); in mv_hash_setkey()
796 ss = crypto_shash_statesize(ctx->base_hash); in mv_hash_setkey()
799 SHASH_DESC_ON_STACK(shash, ctx->base_hash); in mv_hash_setkey()
805 shash->tfm = ctx->base_hash; in mv_hash_setkey()
806 shash->flags = crypto_shash_get_flags(ctx->base_hash) & in mv_hash_setkey()
837 mv_hash_init_ivs(ctx, ipad, opad); in mv_hash_setkey()
847 struct mv_tfm_hash_ctx *ctx = crypto_tfm_ctx(tfm); in mv_cra_hash_init() local
852 ctx->op = op; in mv_cra_hash_init()
853 ctx->count_add = count_add; in mv_cra_hash_init()
865 ctx->fallback = fallback_tfm; in mv_cra_hash_init()
879 ctx->base_hash = base_hash; in mv_cra_hash_init()
883 crypto_shash_descsize(ctx->fallback)); in mv_cra_hash_init()
893 struct mv_tfm_hash_ctx *ctx = crypto_tfm_ctx(tfm); in mv_cra_hash_exit() local
895 crypto_free_shash(ctx->fallback); in mv_cra_hash_exit()
896 if (ctx->base_hash) in mv_cra_hash_exit()
897 crypto_free_shash(ctx->base_hash); in mv_cra_hash_exit()