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

Fixes in ASN1 and X509 #7659

Merged
merged 3 commits into from
Jun 20, 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
7 changes: 5 additions & 2 deletions src/ssl_asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -3510,14 +3510,17 @@ WOLFSSL_ASN1_TIME* wolfSSL_ASN1_TIME_to_generalizedtime(WOLFSSL_ASN1_TIME *t,
if (ret != NULL) {
/* Set the ASN.1 type and length of string. */
ret->type = V_ASN1_GENERALIZEDTIME;
ret->length = ASN_GENERALIZED_TIME_SIZE;

if (t->type == V_ASN1_GENERALIZEDTIME) {
ret->length = ASN_GENERALIZED_TIME_SIZE;

/* Just copy as data already appropriately formatted. */
XMEMCPY(ret->data, t->data, ASN_GENERALIZED_TIME_SIZE);
}
else {
/* Convert UTC TIME to GENERALIZED TIME. */
ret->length = t->length + 2; /* Add two extra year digits */

if (t->data[0] >= '5') {
/* >= 50 is 1900s. */
ret->data[0] = '1'; ret->data[1] = '9';
Expand All @@ -3527,7 +3530,7 @@ WOLFSSL_ASN1_TIME* wolfSSL_ASN1_TIME_to_generalizedtime(WOLFSSL_ASN1_TIME *t,
ret->data[0] = '2'; ret->data[1] = '0';
}
/* Append rest of the data as it is the same. */
XMEMCPY(&ret->data[2], t->data, ASN_UTC_TIME_SIZE);
XMEMCPY(&ret->data[2], t->data, t->length);
}

/* Check for pointer to return result through. */
Expand Down
11 changes: 10 additions & 1 deletion src/x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -8236,7 +8236,8 @@ int wolfSSL_X509_CRL_get_signature(WOLFSSL_X509_CRL* crl,
{
WOLFSSL_ENTER("wolfSSL_X509_CRL_get_signature");

if (crl == NULL || crl->crlList == NULL || bufSz == NULL)
if (crl == NULL || crl->crlList == NULL ||
crl->crlList->signature == NULL || bufSz == NULL)
return BAD_FUNC_ARG;

if (buf != NULL)
Expand Down Expand Up @@ -12972,6 +12973,14 @@ static int get_dn_attr_by_nid(int n, const char** buf)
str = "UID";
len = 3;
break;
case NID_serialNumber:
str = "serialNumber";
len = 12;
break;
case NID_title:
str = "title";
len = 5;
break;
default:
WOLFSSL_MSG("Attribute type not found");
str = NULL;
Expand Down