mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-18 04:29:27 +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.
55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
/* Provenance: openssl/openssl ossl_ffc_validate_public_key_partial (fixed).
|
|
* repo: openssl/openssl
|
|
* commit: bcec03c33cc00a7b5eb89ebeeee59e604570a86a
|
|
* parent: 3436f9c24ab90c1661e4798e7944f028d5d251ce
|
|
* commit_url: https://github.com/openssl/openssl/commit/bcec03c33cc00a7b5eb89ebeeee59e604570a86a
|
|
* cve: CVE-2023-0217
|
|
* license: Apache-2.0
|
|
* function: ossl_ffc_validate_public_key_partial
|
|
* relpath: crypto/ffc/ffc_key_validate.c
|
|
*/
|
|
|
|
int ossl_ffc_validate_public_key_partial(const FFC_PARAMS *params,
|
|
const BIGNUM *pub_key, int *ret)
|
|
{
|
|
int ok = 0;
|
|
BIGNUM *tmp = NULL;
|
|
BN_CTX *ctx = NULL;
|
|
|
|
*ret = 0;
|
|
if (params == NULL || pub_key == NULL || params->p == NULL) {
|
|
*ret = FFC_ERROR_PASSED_NULL_PARAM;
|
|
return 0;
|
|
}
|
|
|
|
ctx = BN_CTX_new_ex(NULL);
|
|
if (ctx == NULL)
|
|
goto err;
|
|
|
|
BN_CTX_start(ctx);
|
|
tmp = BN_CTX_get(ctx);
|
|
/* Step(1): Verify pub_key >= 2 */
|
|
if (tmp == NULL
|
|
|| !BN_set_word(tmp, 1))
|
|
goto err;
|
|
if (BN_cmp(pub_key, tmp) <= 0) {
|
|
*ret |= FFC_ERROR_PUBKEY_TOO_SMALL;
|
|
goto err;
|
|
}
|
|
/* Step(1): Verify pub_key <= p-2 */
|
|
if (BN_copy(tmp, params->p) == NULL
|
|
|| !BN_sub_word(tmp, 1))
|
|
goto err;
|
|
if (BN_cmp(pub_key, tmp) >= 0) {
|
|
*ret |= FFC_ERROR_PUBKEY_TOO_LARGE;
|
|
goto err;
|
|
}
|
|
ok = 1;
|
|
err:
|
|
if (ctx != NULL) {
|
|
BN_CTX_end(ctx);
|
|
BN_CTX_free(ctx);
|
|
}
|
|
return ok;
|
|
}
|