lib/crypto/mpi/mpi-mul.c
Source file repositories/reference/linux-study-clean/lib/crypto/mpi/mpi-mul.c
File Facts
- System
- Linux kernel
- Corpus path
lib/crypto/mpi/mpi-mul.c- Extension
.c- Size
- 2533 bytes
- Lines
- 112
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
linux/export.hmpi-internal.h
Detected Declarations
function mpi_mulfunction mpi_mulmexport mpi_mulexport mpi_mulm
Annotated Snippet
if (wp == up || wp == vp) {
wp = mpi_alloc_limb_space(wsize);
if (!wp)
return -ENOMEM;
assign_wp = 1;
} else {
err = mpi_resize(w, wsize);
if (err)
return err;
wp = w->d;
}
} else { /* Make U and V not overlap with W. */
if (wp == up) {
/* W and U are identical. Allocate temporary space for U. */
up = tmp_limb = mpi_alloc_limb_space(usize);
if (!up)
return -ENOMEM;
/* Is V identical too? Keep it identical with U. */
if (wp == vp)
vp = up;
/* Copy to the temporary space. */
MPN_COPY(up, wp, usize);
} else if (wp == vp) {
/* W and V are identical. Allocate temporary space for V. */
vp = tmp_limb = mpi_alloc_limb_space(vsize);
if (!vp)
return -ENOMEM;
/* Copy to the temporary space. */
MPN_COPY(vp, wp, vsize);
}
}
if (!vsize)
wsize = 0;
else {
err = mpihelp_mul(wp, up, usize, vp, vsize, &cy);
if (err) {
if (assign_wp)
mpi_free_limb_space(wp);
goto free_tmp_limb;
}
wsize -= cy ? 0:1;
}
if (assign_wp)
mpi_assign_limb_space(w, wp, wsize);
w->nlimbs = wsize;
w->sign = sign_product;
free_tmp_limb:
if (tmp_limb)
mpi_free_limb_space(tmp_limb);
return err;
}
EXPORT_SYMBOL_GPL(mpi_mul);
int mpi_mulm(MPI w, MPI u, MPI v, MPI m)
{
return mpi_mul(w, u, v) ?:
mpi_tdiv_r(w, w, m);
}
EXPORT_SYMBOL_GPL(mpi_mulm);
Annotation
- Immediate include surface: `linux/export.h`, `mpi-internal.h`.
- Detected declarations: `function mpi_mul`, `function mpi_mulm`, `export mpi_mul`, `export mpi_mulm`.
- Atlas domain: Kernel Services / lib.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.