crypto/rsa_helper.c
Source file repositories/reference/linux-study-clean/crypto/rsa_helper.c
File Facts
- System
- Linux kernel
- Corpus path
crypto/rsa_helper.c- Extension
.c- Size
- 4126 bytes
- Lines
- 187
- Domain
- Kernel Services
- Bucket
- crypto
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/export.hlinux/err.hlinux/fips.hcrypto/internal/rsa.hrsapubkey.asn1.hrsaprivkey.asn1.h
Detected Declarations
function Copyrightfunction rsa_get_efunction rsa_get_dfunction rsa_get_pfunction rsa_get_qfunction rsa_get_dpfunction rsa_get_dqfunction rsa_get_qinvfunction rsa_parse_pub_keyfunction rsa_parse_priv_keyexport rsa_parse_pub_keyexport rsa_parse_priv_key
Annotated Snippet
while (n_sz && !*ptr) {
ptr++;
n_sz--;
}
/* In FIPS mode only allow key size 2K and higher */
if (n_sz < 256) {
pr_err("RSA: key size not allowed in FIPS mode\n");
return -EINVAL;
}
}
key->n = value;
key->n_sz = vlen;
return 0;
}
int rsa_get_e(void *context, size_t hdrlen, unsigned char tag,
const void *value, size_t vlen)
{
struct rsa_key *key = context;
/* invalid key provided */
if (!value || !key->n_sz || !vlen || vlen > key->n_sz)
return -EINVAL;
key->e = value;
key->e_sz = vlen;
return 0;
}
int rsa_get_d(void *context, size_t hdrlen, unsigned char tag,
const void *value, size_t vlen)
{
struct rsa_key *key = context;
/* invalid key provided */
if (!value || !key->n_sz || !vlen || vlen > key->n_sz)
return -EINVAL;
key->d = value;
key->d_sz = vlen;
return 0;
}
int rsa_get_p(void *context, size_t hdrlen, unsigned char tag,
const void *value, size_t vlen)
{
struct rsa_key *key = context;
/* invalid key provided */
if (!value || !vlen || vlen > key->n_sz)
return -EINVAL;
key->p = value;
key->p_sz = vlen;
return 0;
}
int rsa_get_q(void *context, size_t hdrlen, unsigned char tag,
const void *value, size_t vlen)
{
struct rsa_key *key = context;
/* invalid key provided */
if (!value || !vlen || vlen > key->n_sz)
return -EINVAL;
key->q = value;
key->q_sz = vlen;
return 0;
}
int rsa_get_dp(void *context, size_t hdrlen, unsigned char tag,
const void *value, size_t vlen)
{
struct rsa_key *key = context;
/* invalid key provided */
if (!value || !vlen || vlen > key->n_sz)
return -EINVAL;
key->dp = value;
key->dp_sz = vlen;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/export.h`, `linux/err.h`, `linux/fips.h`, `crypto/internal/rsa.h`, `rsapubkey.asn1.h`, `rsaprivkey.asn1.h`.
- Detected declarations: `function Copyright`, `function rsa_get_e`, `function rsa_get_d`, `function rsa_get_p`, `function rsa_get_q`, `function rsa_get_dp`, `function rsa_get_dq`, `function rsa_get_qinv`, `function rsa_parse_pub_key`, `function rsa_parse_priv_key`.
- Atlas domain: Kernel Services / crypto.
- 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.