Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
Unwrap a RSA key with AES key WebCrypto

I'm trying to unwrap a RSA-OAEP key I just wrapped with an AES-GCM key. The wrapping step seems to work. But when I tried to unwrap the key this exception throws : DOMException: Data provided to an operation does not meet requirements which is not helping... I ran the code on Firefox (78.15.0esr)

var iv = window.crypto.getRandomValues(new Uint8Array(12)); //create an initialization vector
var AESkey= await window.crypto.subtle.generateKey( //create an AES key => the wrapping key 
      {
        name: "AES-GCM",
        length: 256
      },
      true,
      ["wrapKey","unwrapKey"]
    );
var keyPair= await window.crypto.subtle.generateKey(//create an RSA keypair 
  {
    name: "RSA-OAEP",
    modulusLength: 4096,
    publicExponent: new Uint8Array([1, 0, 1]),
    hash: "SHA-256"
  },
  true,
  ["encrypt", "decrypt"]
);

var privateRSAKey=keyPair.privateKey;//=> this key will be wrapped 

//the function below works
var wrappedRSAKey= await window.crypto.subtle.wrapKey(// we wrap the RSA key with the AES 
        "jwk",
        privateRSAKey,
        AESkey, 
        {name: "AES-GCM",iv: iv}
    );


// The function below doesn't work X(
//exeception DataError: Data provided to an operation does not meet requirements
var unwrapped = await window.crypto.subtle.unwrapKey(
    "jwk",                     // it's the right format
    wrappedRSAKey,             // wrappedRSAKey is a ArrayBuffer 
    AESkey,                    // the encryption key
    {name: "AES-GCM",iv: iv},  // algorithm params for key encryption key

    {                      // algorithm params for key to unwrap
      name: "RSA-OAEP",
      hash: "SHA-256"
    },
    true,                  // extractability of key to unwrap
    ["encrypt", "decrypt"] // key usages for key to unwrap
  );

Any help to tell me what's wrong in unwrapKey would be appreciate !

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda