Skip to content

Commit acac3fe

Browse files
author
Lealem Amedie
committed
Add testing and make jenkins happy
1 parent 0cd5a29 commit acac3fe

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

tests/api.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39717,6 +39717,7 @@ static int test_wolfSSL_X509_NAME_ENTRY(void)
3971739717

3971839718
ExpectNotNull(subject = X509_NAME_oneline(nm, 0, 0));
3971939719
ExpectNotNull(XSTRSTR(subject, "favouriteDrink=tequila"));
39720+
ExpectNotNull(XSTRSTR(subject, "contentType=Server"));
3972039721
#ifdef DEBUG_WOLFSSL
3972139722
if (subject != NULL) {
3972239723
fprintf(stderr, "\n\t%s\n", subject);
@@ -57149,7 +57150,8 @@ static int test_ECDH_compute_key(void)
5714957150
#if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \
5715057151
defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_REQ) && \
5715157152
!defined(NO_ASN_TIME)
57152-
static int test_openssl_make_self_signed_certificate(EVP_PKEY* pkey)
57153+
static int test_openssl_make_self_signed_certificate(EVP_PKEY* pkey,
57154+
int expectedDerSz)
5715357155
{
5715457156
EXPECT_DECLS;
5715557157
X509* x509 = NULL;
@@ -57158,6 +57160,7 @@ static int test_openssl_make_self_signed_certificate(EVP_PKEY* pkey)
5715857160
time_t epoch_off = 0;
5715957161
ASN1_INTEGER* asn1_serial_number;
5716057162
long not_before, not_after;
57163+
int derSz;
5716157164

5716257165
ExpectNotNull(x509 = X509_new());
5716357166

@@ -57175,6 +57178,8 @@ static int test_openssl_make_self_signed_certificate(EVP_PKEY* pkey)
5717557178

5717657179
ExpectIntNE(X509_NAME_add_entry_by_NID(name, NID_commonName, MBSTRING_UTF8,
5717757180
(unsigned char*)"www.wolfssl.com", -1, -1, 0), 0);
57181+
ExpectIntNE(X509_NAME_add_entry_by_NID(name, NID_pkcs9_contentType,
57182+
MBSTRING_UTF8,(unsigned char*)"Server", -1, -1, 0), 0);
5717857183

5717957184
ExpectIntNE(X509_set_subject_name(x509, name), 0);
5718057185
ExpectIntNE(X509_set_issuer_name(x509, name), 0);
@@ -57188,6 +57193,9 @@ static int test_openssl_make_self_signed_certificate(EVP_PKEY* pkey)
5718857193

5718957194
ExpectIntNE(X509_sign(x509, pkey, EVP_sha256()), 0);
5719057195

57196+
ExpectNotNull(wolfSSL_X509_get_der(x509, &derSz));
57197+
ExpectIntGE(derSz, expectedDerSz);
57198+
5719157199
BN_free(serial_number);
5719257200
X509_NAME_free(name);
5719357201
X509_free(x509);
@@ -57205,6 +57213,7 @@ static int test_openssl_generate_key_and_cert(void)
5720557213
EC_KEY* ec_key = NULL;
5720657214
#endif
5720757215
#if !defined(NO_RSA)
57216+
int expectedDerSz;
5720857217
int key_length = 2048;
5720957218
BIGNUM* exponent = NULL;
5721057219
RSA* rsa = NULL;
@@ -57243,11 +57252,13 @@ static int test_openssl_generate_key_and_cert(void)
5724357252

5724457253
#if !defined(NO_CERTS) && defined(WOLFSSL_CERT_GEN) && \
5724557254
defined(WOLFSSL_CERT_REQ) && !defined(NO_ASN_TIME)
57246-
ExpectIntEQ(test_openssl_make_self_signed_certificate(pkey),
57247-
TEST_SUCCESS);
57255+
expectedDerSz = 743;
57256+
ExpectIntEQ(test_openssl_make_self_signed_certificate(pkey,
57257+
expectedDerSz), TEST_SUCCESS);
5724857258
#endif
5724957259
}
5725057260

57261+
(void)expectedDerSz;
5725157262
EVP_PKEY_free(pkey);
5725257263
pkey = NULL;
5725357264
BN_free(exponent);
@@ -57269,7 +57280,9 @@ static int test_openssl_generate_key_and_cert(void)
5726957280

5727057281
#if !defined(NO_CERTS) && defined(WOLFSSL_CERT_GEN) && \
5727157282
defined(WOLFSSL_CERT_REQ) && !defined(NO_ASN_TIME)
57272-
ExpectIntEQ(test_openssl_make_self_signed_certificate(pkey), TEST_SUCCESS);
57283+
expectedDerSz = 345;
57284+
ExpectIntEQ(test_openssl_make_self_signed_certificate(pkey, expectedDerSz),
57285+
TEST_SUCCESS);
5727357286
#endif
5727457287

5727557288
EVP_PKEY_free(pkey);

wolfcrypt/src/asn.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13194,6 +13194,7 @@ static int GetRDN(DecodedCert* cert, char* full, word32* idx, int* nid,
1319413194
*nid = NID_favouriteDrink;
1319513195
#endif
1319613196
}
13197+
#ifdef WOLFSSL_CERT_REQ
1319713198
else if (oidSz == sizeof(attrPkcs9ContentTypeOid) &&
1319813199
XMEMCMP(oid, attrPkcs9ContentTypeOid, oidSz) == 0) {
1319913200
/* Set the pkcs9_contentType, type string, length and NID. */
@@ -13204,6 +13205,7 @@ static int GetRDN(DecodedCert* cert, char* full, word32* idx, int* nid,
1320413205
*nid = NID_pkcs9_contentType;
1320513206
#endif
1320613207
}
13208+
#endif
1320713209
/* Other OIDs that start with the same values. */
1320813210
else if (oidSz == sizeof(dcOid) && XMEMCMP(oid, dcOid, oidSz-1) == 0) {
1320913211
WOLFSSL_MSG("Unknown pilot attribute type");
@@ -26475,9 +26477,12 @@ static int EncodeName(EncodedName* name, const char* nameStr,
2647526477
firstSz = cname->custom.oidSz;
2647626478
break;
2647726479
#endif
26480+
#ifdef WOLFSSL_CERT_REQ
2647826481
case ASN_CONTENT_TYPE:
2647926482
thisLen += (int)sizeof(attrPkcs9ContentTypeOid);
2648026483
firstSz = (int)sizeof(attrPkcs9ContentTypeOid);
26484+
break;
26485+
#endif
2648126486
default:
2648226487
thisLen += DN_OID_SZ;
2648326488
firstSz = DN_OID_SZ;
@@ -26542,13 +26547,15 @@ static int EncodeName(EncodedName* name, const char* nameStr,
2654226547
name->encoded[idx++] = nameTag;
2654326548
break;
2654426549
#endif
26550+
#ifdef WOLFSSL_CERT_REQ
2654526551
case ASN_CONTENT_TYPE:
2654626552
XMEMCPY(name->encoded + idx, attrPkcs9ContentTypeOid,
2654726553
sizeof(attrPkcs9ContentTypeOid));
2654826554
idx += (int)sizeof(attrPkcs9ContentTypeOid);
2654926555
/* str type */
2655026556
name->encoded[idx++] = nameTag;
2655126557
break;
26558+
#endif
2655226559
default:
2655326560
name->encoded[idx++] = 0x55;
2655426561
name->encoded[idx++] = 0x04;
@@ -26621,10 +26628,12 @@ static int EncodeName(EncodedName* name, const char* nameStr,
2662126628
oidSz = cname->custom.oidSz;
2662226629
break;
2662326630
#endif
26631+
#ifdef WOLFSSL_CERT_REQ
2662426632
case ASN_CONTENT_TYPE:
2662526633
oid = attrPkcs9ContentTypeOid;
2662626634
oidSz = sizeof(attrPkcs9ContentTypeOid);
2662726635
break;
26636+
#endif
2662826637
default:
2662926638
/* Construct OID using type. */
2663026639
dnOid[2] = type;

0 commit comments

Comments
 (0)