Skip to content

Commit

Permalink
Merge pull request #7659 from embhorn/zd18179
Browse files Browse the repository at this point in the history
Fixes in ASN1 and X509
  • Loading branch information
JacobBarthelmeh committed Jun 20, 2024
2 parents d545253 + d4a90e8 commit 63f666a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
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

0 comments on commit 63f666a

Please sign in to comment.