Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

269
Views
¿Cómo usar crypto.subtle.wrapKey para envolver una clave privada RSA-PSS usando AES-KW?

Recibo el siguiente error cuando intento envolver una clave RSA-PSS usando AES-KW:

 The AES-KW input data length is invalid: not a multiple of 8 bytes

Sin embargo, a veces funciona, pero solo cuando la longitud de la salida de la clave en formato 'pkcs8' es divisible por 8. Quizás eso también se indique en https://developer.mozilla.org/en-US/docs/Web/ API/SubtleCrypto/wrapKey .

Entonces mi pregunta es: ¿No es posible envolver una clave RSA-PSS usando AES-KW? No puedo encontrar ninguna opción de relleno. Si no, ¿es mi mejor opción ir por la ruta IV?

Vea el siguiente código:

 export async function wrapKeyAsync(key: CryptoKey, password: string) { let keyMaterial = await crypto.subtle.importKey( "raw", new TextEncoder().encode(password), { name: "PBKDF2" }, false, ["deriveBits", "deriveKey"] ); let salt = crypto.getRandomValues(new Uint8Array(16)); let wrappingKey = await crypto.subtle.deriveKey( { "name": "PBKDF2", salt: salt, "iterations": 100_000, "hash": "SHA-256" }, keyMaterial, { "name": "AES-KW", "length": 256 }, true, ["wrapKey", "unwrapKey"] ); console.log((await crypto.subtle.exportKey("pkcs8", key)).byteLength / 8); // Only works when input is divisible by 8 return { wrappedKey: new Uint8Array(await crypto.subtle.wrapKey( "pkcs8", key, wrappingKey, "AES-KW" )), salt }; }
about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!