Skip to content

Commit

Permalink
Merge pull request #59 from ColtonWilley/wp_p8_decoder_fallback_handling
Browse files Browse the repository at this point in the history
Modify pkcs8 decoder to properly allow fallback decoding on failure
  • Loading branch information
SparkiDev authored Jan 7, 2025
2 parents a578b6f + 26ca919 commit 819f8d5
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit 819f8d5

Please sign in to comment.