Skip to content

Modify pkcs8 decoder to properly allow fallback decoding on failure #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
6 changes: 6 additions & 0 deletions src/wp_dec_epki2pki.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ static int wp_epki2pki_decode(wp_Epki2Pki* ctx, OSSL_CORE_BIO* coreBio,
word32 len = 0;
char password[1024];
size_t passwordLen;
word32 tradIdx = 0;

(void)ctx;
(void)selection;
Expand All @@ -204,6 +205,11 @@ static int wp_epki2pki_decode(wp_Epki2Pki* ctx, OSSL_CORE_BIO* coreBio,
else if (data == NULL) {
done = 1;
}
if (wc_GetPkcs8TraditionalOffset(data, &tradIdx, (word32)len) <= 0) {
/* This is not PKCS8, we are done */
done = 1;
ok = 1;
}
if ((!done) && ok && (!pwCb(password, sizeof(password), &passwordLen, NULL,
pwCbArg))) {
done = 1;
Expand Down
Loading