Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

perf: remove jwk2privPem and jwk2pubPem #162

Merged
merged 1 commit into from
Feb 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions src/keys/jwk2pem.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict'

const forge = {
util: require('node-forge/lib/util'),
pki: require('node-forge/lib/pki'),
jsbn: require('node-forge/lib/jsbn')
}
require('node-forge/lib/rsa')
require('node-forge/lib/util')
require('node-forge/lib/jsbn')
const forge = require('node-forge/lib/forge')

function base64urlToBigInteger (str) {
var bytes = forge.util.decode64(
Expand All @@ -22,21 +21,11 @@ function jwk2priv (key) {
return forge.pki.setRsaPrivateKey(...convert(key, ['n', 'e', 'd', 'p', 'q', 'dp', 'dq', 'qi']))
}

function jwk2privPem (key) {
return forge.pki.privateKeyToPem(jwk2priv(key))
}

function jwk2pub (key) {
return forge.pki.setRsaPublicKey(...convert(key, ['n', 'e']))
}

function jwk2pubPem (key) {
return forge.pki.publicKeyToPem(jwk2pub(key))
}

module.exports = {
jwk2pub,
jwk2pubPem,
jwk2priv,
jwk2privPem
jwk2priv
}