Skip to content

Commit

Permalink
Merge branch 'aws:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
manastasova authored Sep 18, 2024
2 parents 2770797 + 7090b90 commit f976a35
Show file tree
Hide file tree
Showing 38 changed files with 73,039 additions and 1,944 deletions.
1 change: 1 addition & 0 deletions crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ if(BUILD_TESTING)
fipsmodule/ec/ec_test.cc
fipsmodule/ec/p256-nistz_test.cc
fipsmodule/ecdsa/ecdsa_test.cc
fipsmodule/evp/evp_ctx_test.cc
fipsmodule/kdf/kdf_test.cc
fipsmodule/md5/md5_test.cc
fipsmodule/modes/gcm_test.cc
Expand Down
5 changes: 5 additions & 0 deletions crypto/bn_extra/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ static int bn_x2bn(BIGNUM **outp, const char *in, decode_func decode, char_test_

for (i = 0; want_char((unsigned char)in[i]) && i + neg < INT_MAX; i++) {}

if(i == 0) {
OPENSSL_PUT_ERROR(BN, BN_R_INVALID_INPUT);
return 0;
}

num = i + neg;
if (outp == NULL) {
return num;
Expand Down
26 changes: 25 additions & 1 deletion crypto/evp_extra/p_dh.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* https://www.openssl.org/source/license.html
*/

#include <string.h>
#include <openssl/evp.h>

#include <assert.h>
Expand Down Expand Up @@ -121,6 +122,29 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) {
}
}

static int pkey_dh_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
const char *value) {
// We don't support:
// * dh_paramgen_prime_len
// * dh_rfc5114
// * dh_param
// * dh_paramgen_generator
// * dh_paramgen_subprime_len
// * dh_paramgen_type

if (strcmp(type, "dh_pad") == 0) {
char* str_end = NULL;
long pad = strtol(value, &str_end, 10);
if(str_end == value || pad < 0 || pad > INT_MAX) {
OPENSSL_PUT_ERROR(EVP, EVP_R_INVALID_OPERATION);
return 0;
}
return EVP_PKEY_CTX_set_dh_pad(ctx, pad);
}
return -2;
}


const EVP_PKEY_METHOD dh_pkey_meth = {
.pkey_id = EVP_PKEY_DH,
.init = pkey_dh_init,
Expand All @@ -129,7 +153,7 @@ const EVP_PKEY_METHOD dh_pkey_meth = {
.keygen = pkey_dh_keygen,
.derive = pkey_dh_derive,
.ctrl = pkey_dh_ctrl,
.ctrl_str = NULL
.ctrl_str = pkey_dh_ctrl_str
};

int EVP_PKEY_CTX_set_dh_pad(EVP_PKEY_CTX *ctx, int pad) {
Expand Down
Loading

0 comments on commit f976a35

Please sign in to comment.