Right now, I am testing Web Crypto API by doing simple test. So, I have user's public key (as a string) and I want to let him pass his private key (also as a string), so my app could do some encrypting/decrypting. And so, I try to import his keys int Web Crypto API by doing:
var textEncoder = new TextEncoder();
var alg = {
name: "RSA-OAEP",
hash: {name: "SHA-256"}
}
window.crypto.subtle.importKey('raw', textEncoder.encode(myPublicKey), alg, false, ['encrypt'])
Keys are generateded by
openssl genrsa -out mykey.pem 4096
openssl rsa -in mykey.pem -pubout > mykey.pub
WCAPI throws
Unsupported import key format for algorithm
I tried other hashes in alg, but still, no success.
A help with an example would be nice.