MCPcopy Create free account
hub / github.com/F-Stack/f-stack / aesni_cipher_process

Function aesni_cipher_process

freebsd/crypto/aesni/aesni.c:632–687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630}
631
632static int
633aesni_cipher_process(struct aesni_session *ses, struct cryptop *crp)
634{
635 const struct crypto_session_params *csp;
636 struct fpu_kern_ctx *ctx;
637 int error, ctxidx;
638 bool kt;
639
640 csp = crypto_get_params(crp->crp_session);
641 switch (csp->csp_cipher_alg) {
642 case CRYPTO_AES_ICM:
643 case CRYPTO_AES_NIST_GCM_16:
644 case CRYPTO_AES_CCM_16:
645 if ((crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0)
646 return (EINVAL);
647 break;
648 case CRYPTO_AES_CBC:
649 case CRYPTO_AES_XTS:
650 /* CBC & XTS can only handle full blocks for now */
651 if ((crp->crp_payload_length % AES_BLOCK_LEN) != 0)
652 return (EINVAL);
653 break;
654 }
655
656 ctx = NULL;
657 ctxidx = 0;
658 error = 0;
659 kt = is_fpu_kern_thread(0);
660 if (!kt) {
661 ACQUIRE_CTX(ctxidx, ctx);
662 fpu_kern_enter(curthread, ctx,
663 FPU_KERN_NORMAL | FPU_KERN_KTHR);
664 }
665
666 /* Do work */
667 if (csp->csp_mode == CSP_MODE_ETA) {
668 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) {
669 error = aesni_cipher_crypt(ses, crp, csp);
670 if (error == 0)
671 error = aesni_cipher_mac(ses, crp, csp);
672 } else {
673 error = aesni_cipher_mac(ses, crp, csp);
674 if (error == 0)
675 error = aesni_cipher_crypt(ses, crp, csp);
676 }
677 } else if (csp->csp_mode == CSP_MODE_DIGEST)
678 error = aesni_cipher_mac(ses, crp, csp);
679 else
680 error = aesni_cipher_crypt(ses, crp, csp);
681
682 if (!kt) {
683 fpu_kern_leave(curthread, ctx);
684 RELEASE_CTX(ctxidx, ctx);
685 }
686 return (error);
687}
688
689static int

Callers 1

aesni_processFunction · 0.85

Calls 6

crypto_get_paramsFunction · 0.85
aesni_cipher_cryptFunction · 0.85
aesni_cipher_macFunction · 0.85
is_fpu_kern_threadFunction · 0.50
fpu_kern_enterFunction · 0.50
fpu_kern_leaveFunction · 0.50

Tested by

no test coverage detected