RSA encryption, error 80700011, undocumented required "hash" argument

Issue #12782429 • Assigned to Steve B.

Details

Author
J.
Created
Jul 15, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Standard affected
Web Cryptography API

Found in build #
40.15063
Reports
Reported by 3 people

Sign in to watch or report this issue.

Steps to reproduce

This simple code:

var data = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);

var crypto = window.crypto || window.msCrypto;
var cryptoSubtle = crypto.subtle;

cryptoSubtle.generateKey(
    {
        name: "RSA-OAEP",
        modulusLength: 2048, 
        publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
        hash: { name: "SHA-256" }, 
    },
    true, 
    ["encrypt", "decrypt"]
).then(function (key) { 
    console.log(key);
    console.log(key.publicKey);
    return cryptoSubtle.encrypt(
        {
            name: "RSA-OAEP"
        },
        key.publicKey,
        data
        );
}).then(function (encrypted) { 
    console.log(new Uint8Array(encrypted));
}).catch(function (err) {
    console.error(err);
});

Works on all major browsers, but fails in edge.

It can be fixed by adding hash algorithm to encrypt:

         return cryptoSubtle.encrypt(
            {
                name: "RSA-OAEP",
                hash: { name: "SHA-256" }
            },
            key.publicKey,
            data
            );

But this doesn’t match WebCryptoAPI Spec:

Promise<any> encrypt(AlgorithmIdentifier algorithm,
                   CryptoKey key,
                   BufferSource data);

12. KeyAlgorithm dictionary

The KeyAlgorithm dictionary represents information about the contents of a given CryptoKey object.

dictionary KeyAlgorithm {
  required DOMString name;
};

12.2. KeyAlgorithm dictionary members

name
The name of the algorithm used to generate the CryptoKey

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Steven K.”

      Changed Assigned To to “Venkat K.”

      Changed Assigned To from “Venkat K.” to “Steve B.”

    You need to sign in to your Microsoft account to add a comment.

    Sign in