My application calls for encrypting one public key with another public key. I can generate both keys, but calling wrapKey throws an OperationError
with no details regarding why it is failing.
const {publicKey: wrappingKey} = await window.crypto.subtle.generateKey(
{name: 'RSA-OAEP', modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: 'SHA-256'},
true, ['decrypt', 'wrapKey', 'unwrapKey']);
const {publicKey: myKey} = await window.crypto.subtle.generateKey(
{name: 'RSA-OAEP', modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: 'SHA-256'},
true, ['encrypt', 'decrypt']);
try {
const output = await window.crypto.subtle.wrapKey('jwk', myKey, wrappingKey, {name: 'RSA-OAEP', modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: 'SHA-256'});
console.log(output);
} catch (e) {
console.log(e);
}
What about this operation is causing a problem? Running in Chrome.
The empty error looks like this:
{
stack: "OperationError"
code: 0
message: ""
name: "OperationError"
}