Skip to content

Commit

Permalink
Ruby Support - DSA custom md/qbits
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Oct 28, 2024
1 parent b77a698 commit de5f9ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 9 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();
const size_t qsize = EVP_MD_size(evpmd);
return dsa_builtin_paramgen(dsa, bits, qsize, evpmd, seed_in, seed_len, out_counter, out_h, cb);
}

int dsa_builtin_paramgen(DSA *dsa, size_t bits, size_t qsize,
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,6 @@ 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);

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_builtin_paramgen(DSA *dsa, size_t bits, size_t qsize,
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

0 comments on commit de5f9ce

Please sign in to comment.