Skip to content

Commit 6dfd723

Browse files
committed
fix README and setting subject
1 parent 7fb2bc9 commit 6dfd723

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Following is a scenario creating Chimera (dual algorithms) certificates for PQC(
163163

164164
The following demonstrates how to create a root CA and use it to sign other certificates. This example uses ECC and ML-DSA. In this scenario there are three entities A, B, and C, where A is meant to function as a root CA.
165165

166-
Before running the commands below, ensure you have the `ml-dsa` option enabled in wolfSSL. This can be done by configuring wolfSSL with `--enable-dilithium`, `--enable-dual-alg-certs` and `--enable-experimental`.
166+
Before running the commands below, ensure you have the `ml-dsa` option enabled in wolfSSL. This can be done by configuring wolfSSL with `--enable-wolfclu`, `--enable-dilithium`, `--enable-dual-alg-certs` and `--enable-experimental`.
167167

168168
The following steps demonstrate how to generate keys and certificates for A, B, and C, where A is self-signed and B and C are signed by A
169169

src/x509/clu_x509_sign.c

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ int wolfCLU_GenChimeraCertSign(WOLFSSL_BIO *bioCaKey, WOLFSSL_BIO *bioAltCaKey,
248248
char *key = NULL;
249249
char *value = NULL;
250250
char *saveptr = NULL;
251+
char *slash = NULL;
251252
char *subj = NULL;
252253
int subjSz = 0;
253254

@@ -617,49 +618,50 @@ int wolfCLU_GenChimeraCertSign(WOLFSSL_BIO *bioCaKey, WOLFSSL_BIO *bioAltCaKey,
617618
}
618619

619620
if (ret == WOLFCLU_SUCCESS) {
620-
subjSz = XSTRLEN(subject) + 1;
621+
subjSz = (int)XSTRLEN(subject) + 1;
621622
subj = (char*)XMALLOC(subjSz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
622623
if (subj == NULL) {
623624
wolfCLU_LogError("Failed to allocate memory for subject");
624625
ret = MEMORY_E;
625626
}
626627
else {
627628
XMEMCPY(subj, subject, subjSz);
628-
token = XSTRTOK(subj, "/", &saveptr);
629+
token = XSTRTOK(subj, "/", &slash);
629630
while (token != NULL) {
631+
saveptr = NULL;
630632
key = XSTRTOK(token, "=", &saveptr);
631633
value = XSTRTOK(NULL, "=", &saveptr);
632634

633-
if (key == NULL || value == NULL) {
634-
/* exit loop if key or value is NULL */
635-
break;
636-
}
637-
if (XSTRCMP(key, "C") == 0) {
638-
XSTRLCPY(newCert.subject.country, value, CTC_NAME_SIZE);
639-
}
640-
else if (XSTRCMP(key, "ST") == 0) {
641-
XSTRLCPY(newCert.subject.state, value, CTC_NAME_SIZE);
642-
}
643-
else if (XSTRCMP(key, "L") == 0) {
644-
XSTRLCPY(newCert.subject.locality, value, CTC_NAME_SIZE);
645-
}
646-
else if (XSTRCMP(key, "O") == 0) {
647-
XSTRLCPY(newCert.subject.org, value, CTC_NAME_SIZE);
648-
}
649-
else if (XSTRCMP(key, "OU") == 0) {
650-
XSTRLCPY(newCert.subject.unit, value, CTC_NAME_SIZE);
651-
}
652-
else if (XSTRCMP(key, "CN") == 0) {
653-
XSTRLCPY(newCert.subject.commonName, value, CTC_NAME_SIZE);
654-
}
655-
else if (XSTRCMP(key, "emailAddress") == 0) {
656-
XSTRLCPY(newCert.subject.email, value, CTC_NAME_SIZE);
635+
if (!(key == NULL && value ==NULL)) {
636+
if (XSTRCMP(key, "C") == 0) {
637+
XSTRLCPY(newCert.subject.country, value, CTC_NAME_SIZE);
638+
}
639+
else if (XSTRCMP(key, "ST") == 0) {
640+
XSTRLCPY(newCert.subject.state, value, CTC_NAME_SIZE);
641+
}
642+
else if (XSTRCMP(key, "L") == 0) {
643+
XSTRLCPY(newCert.subject.locality, value, CTC_NAME_SIZE);
644+
}
645+
else if (XSTRCMP(key, "O") == 0) {
646+
XSTRLCPY(newCert.subject.org, value, CTC_NAME_SIZE);
647+
}
648+
else if (XSTRCMP(key, "OU") == 0) {
649+
XSTRLCPY(newCert.subject.unit, value, CTC_NAME_SIZE);
650+
}
651+
else if (XSTRCMP(key, "CN") == 0) {
652+
XSTRLCPY(newCert.subject.commonName, value, CTC_NAME_SIZE);
653+
}
654+
else if (XSTRCMP(key, "emailAddress") == 0) {
655+
XSTRLCPY(newCert.subject.email, value, CTC_NAME_SIZE);
656+
}
657657
}
658658

659-
token = XSTRTOK(NULL, "/", &saveptr);
659+
token = XSTRTOK(NULL, "/", &slash);
660660
}
661661

662+
XMEMSET(subj, 0, subjSz);
662663
XFREE(subj, HEAP_HINT, NULL);
664+
subj = NULL;
663665
}
664666
}
665667

0 commit comments

Comments
 (0)