Skip to content
Open
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
19 changes: 15 additions & 4 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2954,17 +2954,29 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx,
WMEMCPY(der, in, inSz);
derSz = inSz;
}
#ifdef WOLFSSH_CERTS
else if (format == WOLFSSH_FORMAT_PEM) {
/* The der size will be smaller than the pem size. */
der = (byte*)WMALLOC(inSz, heap, dynamicType);
if (der == NULL)
return WS_MEMORY_E;

if (type == BUFTYPE_PRIVKEY)
if (type == BUFTYPE_PRIVKEY) {
/* Private-key PEM decoding does not depend on WOLFSSH_CERTS;
* gating it there rejected PEM private keys (e.g. a PKCS#8 ML-DSA
* host key) unless wolfSSH was built with certificate support. */
ret = wc_KeyPemToDer(in, inSz, der, inSz, NULL);
Comment thread
ejohnstown marked this conversation as resolved.
else
}
#ifdef WOLFSSH_CERTS
else {
ret = wc_CertPemToDer(in, inSz, der, inSz, wcType);
}
#else
else {
/* Certificate/CA PEM decoding still requires WOLFSSH_CERTS. */
WFREE(der, heap, dynamicType);
return WS_UNIMPLEMENTED_E;
}
Comment thread
ejohnstown marked this conversation as resolved.
#endif /* WOLFSSH_CERTS */
if (ret < 0) {
if (type == BUFTYPE_PRIVKEY) {
/* wc_KeyPemToDer may have written partial key material;
Expand All @@ -2976,7 +2988,6 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx,
}
derSz = (word32)ret;
}
#endif /* WOLFSSH_CERTS */
else {
return WS_UNIMPLEMENTED_E;
}
Expand Down
Loading