Skip to content

Commit 545c6b3

Browse files
committed
Fix for RSA private key import with PKCS8 header
1 parent 3120dac commit 545c6b3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

examples/pcr/policy_sign.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ static int PolicySign(TPM_ALG_ID alg, const char* keyFile, const char* password,
138138
if (rc == 0) {
139139
byte encHash[WC_MAX_DIGEST_SIZE + WC_MAX_ENCODED_DIG_ASN_SZ];
140140
word32 idx = 0;
141+
#ifdef HAVE_PKCS8
142+
/* skip PKCS8 header */
143+
(void)wc_GetPkcs8TraditionalOffset((byte*)buf, &idx, bufSz);
144+
#endif
141145
rc = wc_RsaPrivateKeyDecode(buf, &idx, &key.rsa, (word32)bufSz);
142146
if (rc == 0) {
143147
rc = wolfTPM2_DecodeRsaDer(buf, (word32)bufSz, &authPubKey->pub, NULL, 0);

0 commit comments

Comments
 (0)