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

Function xlp_sec_process

freebsd/mips/nlm/dev/sec/nlmsec.c:564–689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

562}
563
564static int
565xlp_sec_process(device_t dev, struct cryptop *crp, int hint)
566{
567 struct xlp_sec_softc *sc = device_get_softc(dev);
568 const struct crypto_session_params *csp;
569 struct xlp_sec_command *cmd = NULL;
570 int err = -1, ret = 0;
571 struct xlp_sec_session *ses;
572 unsigned int nsegs = 0;
573
574 ses = crypto_get_driver_session(crp->crp_session);
575 csp = crypto_get_params(crp->crp_session);
576
577 /*
578 * This device only support AAD requests where the AAD is
579 * adjacent to the payload.
580 */
581 if (crp->crp_aad_length != 0 && crp->crp_payload_start !=
582 crp->crp_aad_start + crp->crp_aad_length) {
583 err = EFBIG;
584 goto errout;
585 }
586
587 if ((cmd = malloc(sizeof(struct xlp_sec_command), M_DEVBUF,
588 M_NOWAIT | M_ZERO)) == NULL) {
589 err = ENOMEM;
590 goto errout;
591 }
592
593 cmd->crp = crp;
594 cmd->ses = ses;
595 cmd->hash_dst_len = ses->hs_mlen;
596
597 if ((ret = xlp_get_nsegs(crp, &nsegs)) != 0) {
598 err = EINVAL;
599 goto errout;
600 }
601
602 if (crp->crp_flags & CRYPTO_F_IV_SEPARATE) {
603 /* Since IV is given as separate segment to avoid copy */
604 nsegs += 1;
605 }
606 cmd->nsegs = nsegs;
607
608 if ((err = xlp_alloc_cmd_params(cmd, nsegs)) != 0)
609 goto errout;
610
611 switch (csp->csp_mode) {
612 case CSP_MODE_CIPHER:
613 if ((ret = nlm_get_cipher_param(cmd, csp)) != 0) {
614 err = EINVAL;
615 goto errout;
616 }
617 cmd->cipheroff = crp->crp_payload_start;
618 cmd->cipherlen = crp->crp_payload_length;
619 if (crp->crp_flags & CRYPTO_F_IV_SEPARATE) {
620 cmd->cipheroff += cmd->ivlen;
621 cmd->ivoff = 0;

Callers

nothing calls this directly

Calls 14

device_get_softcFunction · 0.85
crypto_get_paramsFunction · 0.85
mallocFunction · 0.85
xlp_get_nsegsFunction · 0.85
xlp_alloc_cmd_paramsFunction · 0.85
nlm_get_cipher_paramFunction · 0.85
xlp_copyivFunction · 0.85
nlm_crypto_do_cipherFunction · 0.85
nlm_get_digest_paramFunction · 0.85
nlm_crypto_do_digestFunction · 0.85

Tested by

no test coverage detected