parent
00efcb4cd7
commit
b4c4e0bbaa
@ -3005,9 +3005,15 @@ class Sign : public ObjectWrap {
|
|||||||
if(!BIO_write(bp, key_pem, key_pemLen)) return 0;
|
if(!BIO_write(bp, key_pem, key_pemLen)) return 0;
|
||||||
|
|
||||||
pkey = PEM_read_bio_PrivateKey( bp, NULL, NULL, NULL );
|
pkey = PEM_read_bio_PrivateKey( bp, NULL, NULL, NULL );
|
||||||
if (pkey == NULL) return 0;
|
if (pkey == NULL) {
|
||||||
|
ERR_print_errors_fp(stderr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
EVP_SignFinal(&mdctx, *md_value, md_len, pkey);
|
if (!EVP_SignFinal(&mdctx, *md_value, md_len, pkey)) {
|
||||||
|
ERR_print_errors_fp(stderr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
EVP_MD_CTX_cleanup(&mdctx);
|
EVP_MD_CTX_cleanup(&mdctx);
|
||||||
initialised_ = false;
|
initialised_ = false;
|
||||||
EVP_PKEY_free(pkey);
|
EVP_PKEY_free(pkey);
|
||||||
@ -3107,8 +3113,11 @@ class Sign : public ObjectWrap {
|
|||||||
|
|
||||||
int r = sign->SignFinal(&md_value, &md_len, buf, len);
|
int r = sign->SignFinal(&md_value, &md_len, buf, len);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
|
delete [] buf;
|
||||||
|
delete [] md_value;
|
||||||
md_value = NULL;
|
md_value = NULL;
|
||||||
md_len = r;
|
md_len = r;
|
||||||
|
return ThrowException(Exception::Error(String::New("SignFinal error")));
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] buf;
|
delete [] buf;
|
||||||
|
@ -937,3 +937,16 @@ assert.throws(function() {
|
|||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
crypto.createVerify('RSA-SHA1').update('0', 'hex');
|
crypto.createVerify('RSA-SHA1').update('0', 'hex');
|
||||||
}, /Bad input string/);
|
}, /Bad input string/);
|
||||||
|
|
||||||
|
assert.throws(function() {
|
||||||
|
var private = [
|
||||||
|
'-----BEGIN RSA PRIVATE KEY-----',
|
||||||
|
'MIGrAgEAAiEA+3z+1QNF2/unumadiwEr+C5vfhezsb3hp4jAnCNRpPcCAwEAAQIgQNriSQK4',
|
||||||
|
'EFwczDhMZp2dvbcz7OUUyt36z3S4usFPHSECEQD/41K7SujrstBfoCPzwC1xAhEA+5kt4BJy',
|
||||||
|
'eKN7LggbF3Dk5wIQN6SL+fQ5H/+7NgARsVBp0QIRANxYRukavs4QvuyNhMx+vrkCEQCbf6j/',
|
||||||
|
'Ig6/HueCK/0Jkmp+',
|
||||||
|
'-----END RSA PRIVATE KEY-----',
|
||||||
|
''
|
||||||
|
].join('\n');
|
||||||
|
crypto.createSign('RSA-SHA256').update('test').sign(private);
|
||||||
|
}, /SignFinal/);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user