Skip to content

Commit 26ca919

Browse files
committed
Modify pkcs8 decoder to properly allow fallback decoding on failure
1 parent a578b6f commit 26ca919

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/wp_dec_epki2pki.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ static int wp_epki2pki_decode(wp_Epki2Pki* ctx, OSSL_CORE_BIO* coreBio,
192192
word32 len = 0;
193193
char password[1024];
194194
size_t passwordLen;
195+
word32 tradIdx = 0;
195196

196197
(void)ctx;
197198
(void)selection;
@@ -204,6 +205,11 @@ static int wp_epki2pki_decode(wp_Epki2Pki* ctx, OSSL_CORE_BIO* coreBio,
204205
else if (data == NULL) {
205206
done = 1;
206207
}
208+
if (wc_GetPkcs8TraditionalOffset(data, &tradIdx, (word32)len) <= 0) {
209+
/* This is not PKCS8, we are done */
210+
done = 1;
211+
ok = 1;
212+
}
207213
if ((!done) && ok && (!pwCb(password, sizeof(password), &passwordLen, NULL,
208214
pwCbArg))) {
209215
done = 1;

0 commit comments

Comments
 (0)