Skip to content

Which key algorithms are available? #13465

Answered by littledivy
justinmchase asked this question in Q&A
Discussion options

You must be logged in to vote

You're looking for https://doc.deno.land/deno/stable/~/RsaHashedImportParams

If you read Github docs carefully it's a PEM-encoded PKCS#1 RSAPrivateKey. First, You need to convert it to pkcs8:

openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in private-key.pem -out private-key-pkcs8.pem

Then extract the DER encoded material out of the PEM and pass it to WebCrypto:

const keyFile = await Deno.readTextFile('private-key-pkcs8.pem');

const pemHeader = "-----BEGIN PRIVATE KEY-----";
const pemFooter = "-----END PRIVATE KEY-----";
const pemContents = keyFile.substring(
  pemHeader.length,
  keyFile.length - pemFooter.length,
);
const binaryDerString = atob(pemContents);
const binaryDer = new

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@justinmchase
Comment options

Comment options

You must be logged in to vote
2 replies
@justinmchase
Comment options

@justinmchase
Comment options

Answer selected by justinmchase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants