neubert
neubert

Reputation: 16802

why do you have to define the algorithm in decrypt() if importKey() already has it?

To decrypt something with the Web Crypto API you have to first import the key thusly:

const result = crypto.subtle.importKey(
    format,
    keyData,
    algorithm,
    extractable,
    usages
);

This returns a promise. If you append .then(function(importedKey) {}) to that you'll be able to use the actual imported key to decrypt:

const result = crypto.subtle.decrypt(algorithm, key, data);

My question is... since the imported key object already has the algorithm specified why do you need to respecify the algorithm when trying to do the actual decryption?

Related to this, importKey seems to support RSASSA-PKCS1-v1_5 as an algorithm but decrypt doesn't. If decrypt() doesn't support RSASSA-PKCS1-v1_5 then why does importKey?

Upvotes: 0

Views: 107

Answers (0)

Related Questions