Lines Matching refs:ctx

139 static inline int __paes_convert_key(struct s390_paes_ctx *ctx)
143 if (__paes_keyblob2pkey(&ctx->kb, &pkey))
146 spin_lock_bh(&ctx->pk_lock);
147 memcpy(&ctx->pk, &pkey, sizeof(pkey));
148 spin_unlock_bh(&ctx->pk_lock);
155 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
157 ctx->kb.key = NULL;
158 spin_lock_init(&ctx->pk_lock);
165 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
167 _free_kb_keybuf(&ctx->kb);
170 static inline int __ecb_paes_set_key(struct s390_paes_ctx *ctx)
174 if (__paes_convert_key(ctx))
178 fc = (ctx->pk.type == PKEY_KEYTYPE_AES_128) ? CPACF_KM_PAES_128 :
179 (ctx->pk.type == PKEY_KEYTYPE_AES_192) ? CPACF_KM_PAES_192 :
180 (ctx->pk.type == PKEY_KEYTYPE_AES_256) ? CPACF_KM_PAES_256 : 0;
183 ctx->fc = (fc && cpacf_test_func(&km_functions, fc)) ? fc : 0;
185 return ctx->fc ? 0 : -EINVAL;
192 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
194 _free_kb_keybuf(&ctx->kb);
195 rc = _key_to_kb(&ctx->kb, in_key, key_len);
199 return __ecb_paes_set_key(ctx);
205 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
217 spin_lock_bh(&ctx->pk_lock);
218 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
219 spin_unlock_bh(&ctx->pk_lock);
224 k = cpacf_km(ctx->fc | modifier, &param,
229 if (__paes_convert_key(ctx))
231 spin_lock_bh(&ctx->pk_lock);
232 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
233 spin_unlock_bh(&ctx->pk_lock);
268 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
270 ctx->kb.key = NULL;
271 spin_lock_init(&ctx->pk_lock);
278 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
280 _free_kb_keybuf(&ctx->kb);
283 static inline int __cbc_paes_set_key(struct s390_paes_ctx *ctx)
287 if (__paes_convert_key(ctx))
291 fc = (ctx->pk.type == PKEY_KEYTYPE_AES_128) ? CPACF_KMC_PAES_128 :
292 (ctx->pk.type == PKEY_KEYTYPE_AES_192) ? CPACF_KMC_PAES_192 :
293 (ctx->pk.type == PKEY_KEYTYPE_AES_256) ? CPACF_KMC_PAES_256 : 0;
296 ctx->fc = (fc && cpacf_test_func(&kmc_functions, fc)) ? fc : 0;
298 return ctx->fc ? 0 : -EINVAL;
305 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
307 _free_kb_keybuf(&ctx->kb);
308 rc = _key_to_kb(&ctx->kb, in_key, key_len);
312 return __cbc_paes_set_key(ctx);
318 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
332 spin_lock_bh(&ctx->pk_lock);
333 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
334 spin_unlock_bh(&ctx->pk_lock);
339 k = cpacf_kmc(ctx->fc | modifier, &param,
346 if (__paes_convert_key(ctx))
348 spin_lock_bh(&ctx->pk_lock);
349 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
350 spin_unlock_bh(&ctx->pk_lock);
386 struct s390_pxts_ctx *ctx = crypto_skcipher_ctx(tfm);
388 ctx->kb[0].key = NULL;
389 ctx->kb[1].key = NULL;
390 spin_lock_init(&ctx->pk_lock);
397 struct s390_pxts_ctx *ctx = crypto_skcipher_ctx(tfm);
399 _free_kb_keybuf(&ctx->kb[0]);
400 _free_kb_keybuf(&ctx->kb[1]);
403 static inline int __xts_paes_convert_key(struct s390_pxts_ctx *ctx)
407 if (__paes_keyblob2pkey(&ctx->kb[0], &pkey0) ||
408 __paes_keyblob2pkey(&ctx->kb[1], &pkey1))
411 spin_lock_bh(&ctx->pk_lock);
412 memcpy(&ctx->pk[0], &pkey0, sizeof(pkey0));
413 memcpy(&ctx->pk[1], &pkey1, sizeof(pkey1));
414 spin_unlock_bh(&ctx->pk_lock);
419 static inline int __xts_paes_set_key(struct s390_pxts_ctx *ctx)
423 if (__xts_paes_convert_key(ctx))
426 if (ctx->pk[0].type != ctx->pk[1].type)
430 fc = (ctx->pk[0].type == PKEY_KEYTYPE_AES_128) ? CPACF_KM_PXTS_128 :
431 (ctx->pk[0].type == PKEY_KEYTYPE_AES_256) ?
435 ctx->fc = (fc && cpacf_test_func(&km_functions, fc)) ? fc : 0;
437 return ctx->fc ? 0 : -EINVAL;
444 struct s390_pxts_ctx *ctx = crypto_skcipher_ctx(tfm);
453 _free_kb_keybuf(&ctx->kb[0]);
454 _free_kb_keybuf(&ctx->kb[1]);
455 rc = _key_to_kb(&ctx->kb[0], in_key, key_len);
458 rc = _key_to_kb(&ctx->kb[1], in_key + key_len, key_len);
462 rc = __xts_paes_set_key(ctx);
471 ckey_len = (ctx->pk[0].type == PKEY_KEYTYPE_AES_128) ?
473 memcpy(ckey, ctx->pk[0].protkey, ckey_len);
474 memcpy(ckey + ckey_len, ctx->pk[1].protkey, ckey_len);
481 struct s390_pxts_ctx *ctx = crypto_skcipher_ctx(tfm);
501 keylen = (ctx->pk[0].type == PKEY_KEYTYPE_AES_128) ? 48 : 64;
502 offset = (ctx->pk[0].type == PKEY_KEYTYPE_AES_128) ? 16 : 0;
506 spin_lock_bh(&ctx->pk_lock);
507 memcpy(pcc_param.key + offset, ctx->pk[1].protkey, keylen);
508 memcpy(xts_param.key + offset, ctx->pk[0].protkey, keylen);
509 spin_unlock_bh(&ctx->pk_lock);
510 cpacf_pcc(ctx->fc, pcc_param.key + offset);
516 k = cpacf_km(ctx->fc | modifier, xts_param.key + offset,
521 if (__xts_paes_convert_key(ctx))
523 spin_lock_bh(&ctx->pk_lock);
525 ctx->pk[0].protkey, keylen);
526 spin_unlock_bh(&ctx->pk_lock);
563 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
565 ctx->kb.key = NULL;
566 spin_lock_init(&ctx->pk_lock);
573 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
575 _free_kb_keybuf(&ctx->kb);
578 static inline int __ctr_paes_set_key(struct s390_paes_ctx *ctx)
582 if (__paes_convert_key(ctx))
586 fc = (ctx->pk.type == PKEY_KEYTYPE_AES_128) ? CPACF_KMCTR_PAES_128 :
587 (ctx->pk.type == PKEY_KEYTYPE_AES_192) ? CPACF_KMCTR_PAES_192 :
588 (ctx->pk.type == PKEY_KEYTYPE_AES_256) ?
592 ctx->fc = (fc && cpacf_test_func(&kmctr_functions, fc)) ? fc : 0;
594 return ctx->fc ? 0 : -EINVAL;
601 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
603 _free_kb_keybuf(&ctx->kb);
604 rc = _key_to_kb(&ctx->kb, in_key, key_len);
608 return __ctr_paes_set_key(ctx);
629 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
642 spin_lock_bh(&ctx->pk_lock);
643 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
644 spin_unlock_bh(&ctx->pk_lock);
653 k = cpacf_kmctr(ctx->fc, &param, walk.dst.virt.addr,
663 if (__paes_convert_key(ctx)) {
668 spin_lock_bh(&ctx->pk_lock);
669 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
670 spin_unlock_bh(&ctx->pk_lock);
682 if (cpacf_kmctr(ctx->fc, &param, buf,
686 if (__paes_convert_key(ctx))
688 spin_lock_bh(&ctx->pk_lock);
689 memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE);
690 spin_unlock_bh(&ctx->pk_lock);