mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-18 12:39:28 +00:00
Harvest 176 isolated vuln-vs-fix functions (109 CVEs, 352 training rows) into benchmarks/pairs/vfc with provenance and a JSONL training manifest. Score the slice as an honesty dashboard (ousast pairs --slice vfc); keep the pair gate on the local fixtures only.
66 lines
1.8 KiB
C
66 lines
1.8 KiB
C
/* Provenance: openssl/openssl rsasve_generate (vuln).
|
|
* repo: openssl/openssl
|
|
* commit: a91e537d16d74050dbde50bb0dfb1fe9930f0521
|
|
* parent: a91e537d16d74050dbde50bb0dfb1fe9930f0521
|
|
* commit_url: https://github.com/openssl/openssl/commit/eed200f58cd8645ed77e46b7e9f764e284df379e
|
|
* cve: CVE-2026-31790
|
|
* license: Apache-2.0
|
|
* function: rsasve_generate
|
|
* relpath: providers/implementations/kem/rsa_kem.c
|
|
*/
|
|
|
|
static int rsasve_generate(PROV_RSA_CTX *prsactx,
|
|
unsigned char *out, size_t *outlen,
|
|
unsigned char *secret, size_t *secretlen)
|
|
{
|
|
int ret;
|
|
size_t nlen;
|
|
|
|
/* Step (1): nlen = Ceil(len(n)/8) */
|
|
nlen = RSA_size(prsactx->rsa);
|
|
|
|
if (out == NULL) {
|
|
if (nlen == 0) {
|
|
ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);
|
|
return 0;
|
|
}
|
|
if (outlen == NULL && secretlen == NULL)
|
|
return 0;
|
|
if (outlen != NULL)
|
|
*outlen = nlen;
|
|
if (secretlen != NULL)
|
|
*secretlen = nlen;
|
|
return 1;
|
|
}
|
|
|
|
/*
|
|
* If outlen is specified, then it must report the length
|
|
* of the out buffer on input so that we can confirm
|
|
* its size is sufficient for encapsulation
|
|
*/
|
|
if (outlen != NULL && *outlen < nlen) {
|
|
ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_OUTPUT_LENGTH);
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Step (2): Generate a random byte string z of nlen bytes where
|
|
* 1 < z < n - 1
|
|
*/
|
|
if (!rsasve_gen_rand_bytes(prsactx->rsa, secret, nlen))
|
|
return 0;
|
|
|
|
/* Step(3): out = RSAEP((n,e), z) */
|
|
ret = RSA_public_encrypt(nlen, secret, out, prsactx->rsa, RSA_NO_PADDING);
|
|
if (ret) {
|
|
ret = 1;
|
|
if (outlen != NULL)
|
|
*outlen = nlen;
|
|
if (secretlen != NULL)
|
|
*secretlen = nlen;
|
|
} else {
|
|
OPENSSL_cleanse(secret, nlen);
|
|
}
|
|
return ret;
|
|
}
|