Skip to content

Commit

Permalink
Fix RSA key generation and test size
Browse files Browse the repository at this point in the history
Fixes latchset#331

Signed-off-by: Simo Sorce <simo@redhat.com>
  • Loading branch information
simo5 committed Jan 9, 2024
1 parent 01ebd73 commit a08197a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/tgenkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ static void check_rsa_key(EVP_PKEY *pubkey)
fprintf(stderr, "Failed to get N param from public key");
exit(EXIT_FAILURE);
} else {
int bits;
bits = EVP_PKEY_get_bits(pubkey);
if (bits < 3072) {
fprintf(stderr, "Expected 3072 bits key, got %d\n", bits);
exit(EXIT_FAILURE);
}
BN_free(tmp);
tmp = NULL;
}
Expand Down Expand Up @@ -339,7 +345,8 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
params[0] = OSSL_PARAM_construct_utf8_string("pkcs11_uri", uri, 0);
params[1] = OSSL_PARAM_construct_size_t("rsa_keygen_bits", &rsa_bits);
params[1] = OSSL_PARAM_construct_size_t(OSSL_PKEY_PARAM_RSA_BITS,
&rsa_bits);
params[2] = OSSL_PARAM_construct_end();

gen_keys("RSA", label, idhex, params, false);
Expand All @@ -365,7 +372,8 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
params[0] = OSSL_PARAM_construct_utf8_string("pkcs11_uri", uri, 0);
params[1] = OSSL_PARAM_construct_size_t("rsa_keygen_bits", &rsa_bits);
params[1] = OSSL_PARAM_construct_size_t(OSSL_PKEY_PARAM_RSA_BITS,
&rsa_bits);
params[2] = OSSL_PARAM_construct_utf8_string("rsa_pss_keygen_md",
(char *)"SHA256", 0);
params[3] = OSSL_PARAM_construct_end();
Expand Down Expand Up @@ -422,7 +430,8 @@ int main(int argc, char *argv[])
params[0] = OSSL_PARAM_construct_utf8_string("pkcs11_uri", uri, 0);
params[1] = OSSL_PARAM_construct_utf8_string("pkcs11_key_usage",
(char *)key_usage, 0);
params[2] = OSSL_PARAM_construct_size_t("rsa_keygen_bits", &rsa_bits);
params[2] = OSSL_PARAM_construct_size_t(OSSL_PKEY_PARAM_RSA_BITS,
&rsa_bits);
params[3] = OSSL_PARAM_construct_end();

gen_keys("RSA", label, idhex, params, false);
Expand Down

0 comments on commit a08197a

Please sign in to comment.