Skip to content

Commit

Permalink
fix use of lowercase constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Sep 5, 2015
1 parent 2c68e08 commit 5032abe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
19 changes: 10 additions & 9 deletions sign.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
var parseKeys = require('parse-asn1')
var BN = require('bn.js')
var elliptic = require('elliptic')
var crt = require('browserify-rsa')
var createHmac = require('create-hmac')
var crt = require('browserify-rsa')
var curves = require('./curves')
var elliptic = require('elliptic')
var parseKeys = require('parse-asn1')

var BN = require('bn.js')
var EC = elliptic.ec

function sign (hash, key, hashType, signType) {
var priv = parseKeys(key)
Expand Down Expand Up @@ -35,15 +37,14 @@ function sign (hash, key, hashType, signType) {

function ecSign (hash, priv) {
var curveId = curves[priv.curve.join('.')]
if (!curveId) {
throw new Error('unknown curve ' + priv.curve.join('.'))
}

var curve = new elliptic.ec(curveId)
if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'))

var curve = new EC(curveId)
var key = curve.genKeyPair()

key._importPrivate(priv.privateKey)
var out = key.sign(hash)

return new Buffer(out.toDER())
}

Expand Down
8 changes: 5 additions & 3 deletions verify.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
var parseKeys = require('parse-asn1')
var elliptic = require('elliptic')
var curves = require('./curves')
var elliptic = require('elliptic')
var parseKeys = require('parse-asn1')

var BN = require('bn.js')
var EC = elliptic.ec

function verify (sig, hash, key, signType) {
var pub = parseKeys(key)
Expand Down Expand Up @@ -60,7 +62,7 @@ function ecVerify (sig, hash, pub) {
var curveId = curves[pub.data.algorithm.curve.join('.')]
if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'))

var curve = new elliptic.ec(curveId)
var curve = new EC(curveId)
var pubkey = pub.data.subjectPrivateKey.data

return curve.verify(hash, sig, pubkey)
Expand Down

0 comments on commit 5032abe

Please sign in to comment.