#Getting error `Unrecognized algorithm name` on `crypto.subtle.importKey()`

1 messages · Page 1 of 1 (latest)

rocky garnet
#

I can't figure this one out. I've done some searching and found a list of supported algos at https://deno.land/[email protected]/crypto/mod.ts

See anything I'm doing wrong? I tried it without the hash as well. Here's a snippet:

/* supabase edge function */
import { crypto } from 'https://deno.land/[email protected]/crypto/mod.ts'

const cryptokey = await crypto.subtle.importKey('spki', encoded_plain_key, 'SHA-512', false, ['sign'])
rocky garnet
#

I've now tried passing in an eliptical curve params object, instead of 'SHA-512'. This ends up throwing an undefined error.

{
  name: 'ECDSA',
  namedCurve: 'P-521'
}

I also changed spki to pkcs8, as I realized this is for a private key.

rocky garnet
#

Found out I need to base64 decode the key, before I convert it to an array buffer. But even then, undefined is thrown. Thoughts?