crypto icon indicating copy to clipboard operation
crypto copied to clipboard

Unable to sign data

Open nolags opened this issue 8 years ago • 0 comments

I used the crypto library to create a private Key and sign data. My code is following:

var KEY_START = '-----BEGIN EC PRIVATE KEY-----\n';
var KEY_END = '\n-----END EC PRIVATE KEY-----\n';
const ecdh = crypto.createECDH('brainpoolP512t1');
        ecdh.generateKeys();
        var key =KEY_START + ecdh.getPrivateKey('base64') + KEY_END;
        console.log(key);
        const sign = crypto.createSign('sha512');
        sign.update('abcdefg');
        var signature = sign.sign(key, 'hex');

        console.log(signature);

But i get the error:

Error: error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long
    at Error (native)
    at Sign.sign (crypto.js:283:26)

Is this a problem with my key format?

nolags avatar Sep 26 '16 12:09 nolags