Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby Support - DSA custom md #1953

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions crypto/dsa/dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ int DSA_set0_pqg(DSA *dsa, BIGNUM *p, BIGNUM *q, BIGNUM *g) {
int DSA_generate_parameters_ex(DSA *dsa, unsigned bits, const uint8_t *seed_in,
size_t seed_len, int *out_counter,
unsigned long *out_h, BN_GENCB *cb) {
const EVP_MD *evpmd = (bits >= 2048) ? EVP_sha256() : EVP_sha1();
return dsa_internal_paramgen(dsa, bits, evpmd, seed_in, seed_len, out_counter, out_h, cb);
}

int dsa_internal_paramgen(DSA *dsa, size_t bits, const EVP_MD *evpmd,
const unsigned char *seed_in, size_t seed_len,
int *out_counter, unsigned long *out_h,
BN_GENCB *cb)
{
int ok = 0;
unsigned char seed[SHA256_DIGEST_LENGTH];
unsigned char md[SHA256_DIGEST_LENGTH];
Expand All @@ -244,10 +253,7 @@ int DSA_generate_parameters_ex(DSA *dsa, unsigned bits, const uint8_t *seed_in,
int r = 0;
BN_CTX *ctx = NULL;
unsigned int h = 2;
const EVP_MD *evpmd;

evpmd = (bits >= 2048) ? EVP_sha256() : EVP_sha1();
size_t qsize = EVP_MD_size(evpmd);
const size_t qsize = EVP_MD_size(evpmd);

if (bits < 512) {
bits = 512;
Expand Down
3 changes: 3 additions & 0 deletions crypto/dsa/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ struct dsa_st {
// DoS bounds. It returns one on success and zero on error.
int dsa_check_key(const DSA *dsa);

int dsa_internal_paramgen(DSA *dsa, size_t bits, const EVP_MD *evpmd,
const unsigned char *seed_in, size_t seed_len,
int *out_counter, unsigned long *out_h, BN_GENCB *cb);

#if defined(__cplusplus)
} // extern C
Expand Down
Loading