I exctracted pkcs#8 private key with the help of other JS library (forge). After that I converted pkcs8 to PEM (stripped "BEGIN, END" headers and footers) and tried to give that key to standart web crypto API function:
window.crypto.subtle.importKey(
"pkcs8", //can be "jwk" (public or private), "spki" (public only), or "pkcs8" (private only)
//der,
//der.getBytes().buffer,
b64ToArrayBuffer(PEM_headers_stripped);
//b64ToArrayBuffer(PEM_headers_NOT_stripped);
{ //these are the algorithm options
name: "RSASSA-PKCS1-v1_5",
hash: {name: "SHA-256"}, //can be "SHA-1", "SHA-256", "SHA-384", or "SHA-512"
},
false, //whether the key is extractable (i.e. can be used in exportKey)
["sign"] //"verify" for public key import, "sign" for private key imports
)
.then ...
and in console recieving message "DataError", code: 0.
You can see above, I tried to pass PEM without stripping headers, passed key in der format but all my efforts failed.
May be you know, how pass a pkcs8 in PEM format to web crypto?
I exctracted pkcs#8 private key with the help of other JS library (forge). After that I converted pkcs8 to PEM (stripped "BEGIN, END" headers and footers) and tried to give that key to standart web crypto API function:
and in console recieving message
"DataError", code: 0
.You can see above, I tried to pass PEM without stripping headers, passed key in der format but all my efforts failed.
May be you know, how pass a pkcs8 in PEM format to web crypto?
Thanks.