Skip to content

Commit 2d49418

Browse files
committed
Moved the sigType-setting logic inside the if (devId == INVALID_DEVID) block so it only runs for the new callback path
1 parent e83c890 commit 2d49418

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

src/tpm2_wrap.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7828,19 +7828,6 @@ int wolfTPM2_CSR_MakeAndSign_ex(WOLFTPM2_DEV* dev, WOLFTPM2_CSR* csr,
78287828
return BAD_FUNC_ARG;
78297829
}
78307830

7831-
/* Set signature type if not specified */
7832-
if (sigType == 0) {
7833-
if (keyType == RSA_TYPE) {
7834-
csr->req.sigType = CTC_SHA256wRSA;
7835-
}
7836-
else if (keyType == ECC_TYPE) {
7837-
csr->req.sigType = CTC_SHA256wECDSA;
7838-
}
7839-
}
7840-
else {
7841-
csr->req.sigType = sigType;
7842-
}
7843-
78447831
/* Set version to 2 for self-signed certificates, 0 for regular CSRs per RFC2986 */
78457832
if (selfSignCert) {
78467833
csr->req.version = 2;
@@ -7851,6 +7838,18 @@ int wolfTPM2_CSR_MakeAndSign_ex(WOLFTPM2_DEV* dev, WOLFTPM2_CSR* csr,
78517838

78527839
/* Use new callback-based signing if devId not specified */
78537840
if (devId == INVALID_DEVID) {
7841+
/* Set signature type if not specified */
7842+
if (sigType == 0) {
7843+
if (keyType == RSA_TYPE) {
7844+
csr->req.sigType = CTC_SHA256wRSA;
7845+
}
7846+
else if (keyType == ECC_TYPE) {
7847+
csr->req.sigType = CTC_SHA256wECDSA;
7848+
}
7849+
}
7850+
else {
7851+
csr->req.sigType = sigType;
7852+
}
78547853
rc = CSR_MakeAndSign_Cb(dev, csr, key, keyType, outFormat, out, outSz,
78557854
selfSignCert);
78567855
}

0 commit comments

Comments
 (0)