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

Function crypto_invoke

freebsd/opencrypto/crypto.c:1674–1732  ·  view source on GitHub ↗

* Dispatch a crypto request to the appropriate crypto devices. */

Source from the content-addressed store, hash-verified

1672 * Dispatch a crypto request to the appropriate crypto devices.
1673 */
1674static int
1675crypto_invoke(struct cryptocap *cap, struct cryptop *crp, int hint)
1676{
1677
1678 KASSERT(crp != NULL, ("%s: crp == NULL", __func__));
1679 KASSERT(crp->crp_callback != NULL,
1680 ("%s: crp->crp_callback == NULL", __func__));
1681 KASSERT(crp->crp_session != NULL,
1682 ("%s: crp->crp_session == NULL", __func__));
1683
1684 if (cap->cc_flags & CRYPTOCAP_F_CLEANUP) {
1685 struct crypto_session_params csp;
1686 crypto_session_t nses;
1687
1688 /*
1689 * Driver has unregistered; migrate the session and return
1690 * an error to the caller so they'll resubmit the op.
1691 *
1692 * XXX: What if there are more already queued requests for this
1693 * session?
1694 *
1695 * XXX: Real solution is to make sessions refcounted
1696 * and force callers to hold a reference when
1697 * assigning to crp_session. Could maybe change
1698 * crypto_getreq to accept a session pointer to make
1699 * that work. Alternatively, we could abandon the
1700 * notion of rewriting crp_session in requests forcing
1701 * the caller to deal with allocating a new session.
1702 * Perhaps provide a method to allow a crp's session to
1703 * be swapped that callers could use.
1704 */
1705 csp = crp->crp_session->csp;
1706 crypto_freesession(crp->crp_session);
1707
1708 /*
1709 * XXX: Key pointers may no longer be valid. If we
1710 * really want to support this we need to define the
1711 * KPI such that 'csp' is required to be valid for the
1712 * duration of a session by the caller perhaps.
1713 *
1714 * XXX: If the keys have been changed this will reuse
1715 * the old keys. This probably suggests making
1716 * rekeying more explicit and updating the key
1717 * pointers in 'csp' when the keys change.
1718 */
1719 if (crypto_newsession(&nses, &csp,
1720 CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE) == 0)
1721 crp->crp_session = nses;
1722
1723 crp->crp_etype = EAGAIN;
1724 crypto_done(crp);
1725 return 0;
1726 } else {
1727 /*
1728 * Invoke the driver to process the request.
1729 */
1730 return CRYPTODEV_PROCESS(cap->cc_dev, crp, hint);
1731 }

Callers 3

crypto_dispatchFunction · 0.85
crypto_task_invokeFunction · 0.85
crypto_procFunction · 0.85

Calls 3

crypto_freesessionFunction · 0.85
crypto_newsessionFunction · 0.85
crypto_doneFunction · 0.85

Tested by

no test coverage detected