Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to init a Signature object from keypair generated by KEYUTIL.generateKeypair fails. #54

Closed
trusktr opened this issue Apr 21, 2014 · 1 comment
Labels

Comments

@trusktr
Copy link

trusktr commented Apr 21, 2014

I'm passing in a RSAKey object to Signature.init() and it fails with

Uncaught init failed.:[object Object]

My code looks like this:

           // in browser, using browserify.
            var rsa = require("jsrsasign");
            var keypair = rsa.KEYUTIL.generateKeypair("RSA", 256);
            console.log(keypair.prvKeyObj);
                var signature = new rsa.Signature({alg: "MD5withRSA"});
                signature.init(keypair.prvKeyObj); // ERROR HERE
                    signature.updateString("Hello");
                    var signatureValue = signature.sign();
                    console.log(signatureValue);

Why might the init fail?

@kjur kjur added the question label Jun 6, 2015
@kjur
Copy link
Owner

kjur commented Jun 6, 2015

I've tried your code on Node and gotten error like "key is too short for SigAlg".
Your RSA key seems to short for PKCS#1 padding for MD5withRSA.
For example key length is 512bit, it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants