4242 return ThrowException (Exception::TypeError (String::New (" Not a string or buffer" ))); \
4343 }
4444
45- static const char *RSA_PUB_KEY_PFX = " -----BEGIN RSA PUBLIC KEY-----" ;
46- static const char *DSA_PUB_KEY_PFX = " -----BEGIN PUBLIC KEY-----" ;
47- static const int RSA_PUB_KEY_PFX_LEN = strlen(RSA_PUB_KEY_PFX);
48- static const int DSA_PUB_KEY_PFX_LEN = strlen(DSA_PUB_KEY_PFX);
45+ static const char *PUBLIC_KEY_PFX = " -----BEGIN PUBLIC KEY-----" ;
46+ static const int PUBLIC_KEY_PFX_LEN = strlen(PUBLIC_KEY_PFX);
4947
5048namespace node {
5149namespace crypto {
@@ -2776,10 +2774,8 @@ class Verify : public ObjectWrap {
27762774 return 0 ;
27772775 }
27782776
2779- // Check if this is an RSA or DSA "raw" public key before trying
2780- // X.509
2781- if (strncmp (key_pem, RSA_PUB_KEY_PFX, RSA_PUB_KEY_PFX_LEN) == 0 ||
2782- strncmp (key_pem, DSA_PUB_KEY_PFX, DSA_PUB_KEY_PFX_LEN) == 0 ) {
2777+ // Check if this is a PKCS#8 public key before trying as X.509
2778+ if (strncmp (key_pem, PUBLIC_KEY_PFX, PUBLIC_KEY_PFX_LEN) == 0 ) {
27832779 pkey = PEM_read_bio_PUBKEY (bp, NULL , NULL , NULL );
27842780 if (pkey == NULL ) {
27852781 ERR_print_errors_fp (stderr);
@@ -2801,8 +2797,6 @@ class Verify : public ObjectWrap {
28012797 }
28022798
28032799 r = EVP_VerifyFinal (&mdctx, sig, siglen, pkey);
2804- if (r != 1 )
2805- ERR_print_errors_fp (stderr);
28062800
28072801 if (pkey != NULL )
28082802 EVP_PKEY_free (pkey);
0 commit comments