Lines Matching refs:ctx
144 static inline int __paes_convert_key(struct s390_paes_ctx *ctx)
150 ret = __paes_keyblob2pkey(&ctx->kb, &pkey);
154 spin_lock_bh(&ctx->pk_lock);
155 memcpy(&ctx->pk, &pkey, sizeof(pkey));
156 spin_unlock_bh(&ctx->pk_lock);
163 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
165 ctx->kb.key = NULL;
166 spin_lock_init(&ctx->pk_lock);
173 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
175 _free_kb_keybuf(&ctx->kb);
178 static inline int __ecb_paes_set_key(struct s390_paes_ctx *ctx)
183 rc = __paes_convert_key(ctx);
188 fc = (ctx->pk.type == PKEY_KEYTYPE_AES_128) ? CPACF_KM_PAES_128 :
189 (ctx->pk.type == PKEY_KEYTYPE_AES_192) ? CPACF_KM_PAES_192 :
190 (ctx->pk.type == PKEY_KEYTYPE_AES_256) ? CPACF_KM_PAES_256 : 0;
193 ctx->fc = (fc && cpacf_test_func(&km_functions, fc)) ? fc : 0;
195 return ctx->fc ? 0 : -EINVAL;
202 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
204 _free_kb_keybuf(&ctx->kb);
205 rc = _key_to_kb(&ctx->kb, in_key, key_len);
209 return __ecb_paes_set_key(ctx);
215 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
227 spin_lock_bh(&ctx->pk_lock);
228 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
229 spin_unlock_bh(&ctx->pk_lock);
234 k = cpacf_km(ctx->fc | modifier, ¶m,
239 if (__paes_convert_key(ctx))
241 spin_lock_bh(&ctx->pk_lock);
242 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
243 spin_unlock_bh(&ctx->pk_lock);
278 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
280 ctx->kb.key = NULL;
281 spin_lock_init(&ctx->pk_lock);
288 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
290 _free_kb_keybuf(&ctx->kb);
293 static inline int __cbc_paes_set_key(struct s390_paes_ctx *ctx)
298 rc = __paes_convert_key(ctx);
303 fc = (ctx->pk.type == PKEY_KEYTYPE_AES_128) ? CPACF_KMC_PAES_128 :
304 (ctx->pk.type == PKEY_KEYTYPE_AES_192) ? CPACF_KMC_PAES_192 :
305 (ctx->pk.type == PKEY_KEYTYPE_AES_256) ? CPACF_KMC_PAES_256 : 0;
308 ctx->fc = (fc && cpacf_test_func(&kmc_functions, fc)) ? fc : 0;
310 return ctx->fc ? 0 : -EINVAL;
317 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
319 _free_kb_keybuf(&ctx->kb);
320 rc = _key_to_kb(&ctx->kb, in_key, key_len);
324 return __cbc_paes_set_key(ctx);
330 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
344 spin_lock_bh(&ctx->pk_lock);
345 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
346 spin_unlock_bh(&ctx->pk_lock);
351 k = cpacf_kmc(ctx->fc | modifier, ¶m,
358 if (__paes_convert_key(ctx))
360 spin_lock_bh(&ctx->pk_lock);
361 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
362 spin_unlock_bh(&ctx->pk_lock);
398 struct s390_pxts_ctx *ctx = crypto_skcipher_ctx(tfm);
400 ctx->kb[0].key = NULL;
401 ctx->kb[1].key = NULL;
402 spin_lock_init(&ctx->pk_lock);
409 struct s390_pxts_ctx *ctx = crypto_skcipher_ctx(tfm);
411 _free_kb_keybuf(&ctx->kb[0]);
412 _free_kb_keybuf(&ctx->kb[1]);
415 static inline int __xts_paes_convert_key(struct s390_pxts_ctx *ctx)
422 if (__paes_keyblob2pkey(&ctx->kb[0], &pkey0) ||
423 __paes_keyblob2pkey(&ctx->kb[1], &pkey1))
426 spin_lock_bh(&ctx->pk_lock);
427 memcpy(&ctx->pk[0], &pkey0, sizeof(pkey0));
428 memcpy(&ctx->pk[1], &pkey1, sizeof(pkey1));
429 spin_unlock_bh(&ctx->pk_lock);
434 static inline int __xts_paes_set_key(struct s390_pxts_ctx *ctx)
438 if (__xts_paes_convert_key(ctx))
441 if (ctx->pk[0].type != ctx->pk[1].type)
445 fc = (ctx->pk[0].type == PKEY_KEYTYPE_AES_128) ? CPACF_KM_PXTS_128 :
446 (ctx->pk[0].type == PKEY_KEYTYPE_AES_256) ?
450 ctx->fc = (fc && cpacf_test_func(&km_functions, fc)) ? fc : 0;
452 return ctx->fc ? 0 : -EINVAL;
459 struct s390_pxts_ctx *ctx = crypto_skcipher_ctx(tfm);
468 _free_kb_keybuf(&ctx->kb[0]);
469 _free_kb_keybuf(&ctx->kb[1]);
470 rc = _key_to_kb(&ctx->kb[0], in_key, key_len);
473 rc = _key_to_kb(&ctx->kb[1], in_key + key_len, key_len);
477 rc = __xts_paes_set_key(ctx);
486 ckey_len = (ctx->pk[0].type == PKEY_KEYTYPE_AES_128) ?
488 memcpy(ckey, ctx->pk[0].protkey, ckey_len);
489 memcpy(ckey + ckey_len, ctx->pk[1].protkey, ckey_len);
496 struct s390_pxts_ctx *ctx = crypto_skcipher_ctx(tfm);
516 keylen = (ctx->pk[0].type == PKEY_KEYTYPE_AES_128) ? 48 : 64;
517 offset = (ctx->pk[0].type == PKEY_KEYTYPE_AES_128) ? 16 : 0;
521 spin_lock_bh(&ctx->pk_lock);
522 memcpy(pcc_param.key + offset, ctx->pk[1].protkey, keylen);
523 memcpy(xts_param.key + offset, ctx->pk[0].protkey, keylen);
524 spin_unlock_bh(&ctx->pk_lock);
525 cpacf_pcc(ctx->fc, pcc_param.key + offset);
531 k = cpacf_km(ctx->fc | modifier, xts_param.key + offset,
536 if (__xts_paes_convert_key(ctx))
538 spin_lock_bh(&ctx->pk_lock);
540 ctx->pk[0].protkey, keylen);
541 spin_unlock_bh(&ctx->pk_lock);
578 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
580 ctx->kb.key = NULL;
581 spin_lock_init(&ctx->pk_lock);
588 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
590 _free_kb_keybuf(&ctx->kb);
593 static inline int __ctr_paes_set_key(struct s390_paes_ctx *ctx)
598 rc = __paes_convert_key(ctx);
603 fc = (ctx->pk.type == PKEY_KEYTYPE_AES_128) ? CPACF_KMCTR_PAES_128 :
604 (ctx->pk.type == PKEY_KEYTYPE_AES_192) ? CPACF_KMCTR_PAES_192 :
605 (ctx->pk.type == PKEY_KEYTYPE_AES_256) ?
609 ctx->fc = (fc && cpacf_test_func(&kmctr_functions, fc)) ? fc : 0;
611 return ctx->fc ? 0 : -EINVAL;
618 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
620 _free_kb_keybuf(&ctx->kb);
621 rc = _key_to_kb(&ctx->kb, in_key, key_len);
625 return __ctr_paes_set_key(ctx);
646 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
659 spin_lock_bh(&ctx->pk_lock);
660 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
661 spin_unlock_bh(&ctx->pk_lock);
670 k = cpacf_kmctr(ctx->fc, ¶m, walk.dst.virt.addr,
680 if (__paes_convert_key(ctx)) {
685 spin_lock_bh(&ctx->pk_lock);
686 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
687 spin_unlock_bh(&ctx->pk_lock);
699 if (cpacf_kmctr(ctx->fc, ¶m, buf,
703 if (__paes_convert_key(ctx))
705 spin_lock_bh(&ctx->pk_lock);
706 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
707 spin_unlock_bh(&ctx->pk_lock);