Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/wp_dec_epki2pki.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static int wp_epki2pki_decode(wp_Epki2Pki* ctx, OSSL_CORE_BIO* coreBio,
else if (data == NULL) {
done = 1;
}
if (wc_GetPkcs8TraditionalOffset(data, &tradIdx, (word32)len) <= 0) {
if ((!done) && ok && wc_GetPkcs8TraditionalOffset(data, &tradIdx, (word32)len) <= 0) {
/* This is not PKCS8, we are done */
done = 1;
ok = 1;
Expand Down
22 changes: 14 additions & 8 deletions src/wp_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,22 @@ int wp_mp_read_unsigned_bin_le(mp_int* mp, const unsigned char* data,

WOLFPROV_ENTER(WP_LOG_COMP_PROVIDER, "wp_mp_read_unsigned_bin_le");

/* Make big-endian. */
for (i = 0; i < len; i++) {
rdata[i] = data[len - 1 - i];
if (len > sizeof(rdata)) {
ok = 0;
}

/* Read big-endian data in. */
rc = mp_read_unsigned_bin(mp, rdata, (word32)len);
if (rc != 0) {
WOLFPROV_MSG_DEBUG_RETCODE(WP_LOG_LEVEL_DEBUG, "mp_read_unsigned_bin", rc);
ok = 0;
if (ok) {
/* Make big-endian. */
for (i = 0; i < len; i++) {
rdata[i] = data[len - 1 - i];
}

/* Read big-endian data in. */
rc = mp_read_unsigned_bin(mp, rdata, (word32)len);
if (rc != 0) {
WOLFPROV_MSG_DEBUG_RETCODE(WP_LOG_LEVEL_DEBUG, "mp_read_unsigned_bin", rc);
ok = 0;
}
}

WOLFPROV_LEAVE(WP_LOG_COMP_PROVIDER, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), ok);
Expand Down
17 changes: 12 additions & 5 deletions test/test_pkcs7_x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,16 @@ int test_pkcs7_x509_sign_verify(void* data)
X509_gmtime_adj(X509_get_notAfter(cert), 31536000L);
X509_set_pubkey(cert, pkey);

X509_NAME *name = X509_get_subject_name(cert);
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (unsigned char *)"Test Signer", -1, -1, 0);
X509_NAME *name = X509_NAME_new();
if (!name) {
PRINT_MSG("X509_NAME_new failed");
return -1;
}
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC,
(unsigned char *)"Test Signer", -1, -1, 0);
X509_set_subject_name(cert, name);
X509_set_issuer_name(cert, name);
X509_NAME_free(name);
X509_sign(cert, pkey, EVP_sha256());

/* === Step 3: Create the data to be signed === */
Expand Down Expand Up @@ -206,11 +213,11 @@ static int test_x509_name(const X509_NAME *name) {
}

for (int i = 0; i < count; i++) {
X509_NAME_ENTRY *entry = X509_NAME_get_entry(name, i);
const X509_NAME_ENTRY *entry = X509_NAME_get_entry(name, i);
if (!entry) continue;

ASN1_OBJECT *obj = X509_NAME_ENTRY_get_object(entry);
ASN1_STRING *data = X509_NAME_ENTRY_get_data(entry);
const ASN1_OBJECT *obj = X509_NAME_ENTRY_get_object(entry);
const ASN1_STRING *data = X509_NAME_ENTRY_get_data(entry);

char obj_buf[80];
OBJ_obj2txt(obj_buf, sizeof(obj_buf), obj, 1);
Expand Down
Loading