3

I am building a license generator for nodejs and I am currently testing on Heroku.

On my local machine running OpenSSL 1.0.1g, I'm able to test my key pairs (sign and verify) like this:

# data.txt's content (the content of the string literal): "Tsenkov"
openssl dgst -sha1 -sign private.pem data.txt > license.txt
openssl dgst -verify public.pem -signature license.txt data.txt

But on Heroku (OpenSSL 0.9.8) I get the following error:

Error Signing Data
27:error:0606B06E:digital envelope routines:EVP_SignFinal:wrong public key type:p_sign.c:99:

Here's how my pair is generated:

openssl ecparam -genkey -name secp521r1 -noout -out private.pem
openssl ec -in private.pem -pubout -outform PEM -out public.pem

I remember having the same problem on OS X 10.9.2 (local machine), but before trying anything else, I updated OpenSSL through Homebrew and it miraculously started working.

I guess there's an older way of signing data (syntax, etc.) which I'm not aware of.

Can someone help? Thanks.

  • Why are you sticking with the out-of-date OpenSSL version? – Steven Volckaert Apr 17 '14 at 13:53
  • Well, I'm off-guard here... I guess it'll be great to find something that will work on older versions of OpenSSL, too. And also, because upgrading OpenSSL isn't exactly trivial on heroku - one has to build a custom buildpack. – Nikolay Tsenkov Apr 17 '14 at 14:12
  • 2
    I understand. However, given the security impact of using an older OpenSSL version (even though OpenSSL 0.9.8 isn't affected by Heartbleed), wouldn't it be a better strategy to go through the hassle and update anyway? Seems logical to me that updating should be the recommendation. – Steven Volckaert Apr 17 '14 at 14:16
  • I will, but there might be people that will not have that option. Also the security of 0.9.8 should be pretty much up-to-date - it was last updated in 2013 (as pointed in a comment bellow), so it's not a huge gain on that front. Thanks @Steven. – Nikolay Tsenkov Apr 18 '14 at 10:53
2

OpenSSL-0.9.8 is old (from 2005) and support for elliptic curves was not completely added at that point, especially for the command-line tools. OpenSSL is primarily a library; the command-line tools are provided for testing, but are often lagging in functionality. The "normal" way to use OpenSSL is programmatically, by writing C code which calls the library.

MacOS X still uses OpenSSL-0.9.8 because the OpenSSL people broke binary compatibility for some functions, preventing MacOS from doing a transparent upgrade (it could break some applications). Apple's reaction was to mark all the OpenSSL functions as "deprecated" (you get a ton of warnings if you compile C code using the system-provided OpenSSL headers) and write their own cryptographic library.

In any case, you should want to upgrade, not only for better functionality, but also for security (for instance, some algorithm implementations got some extra shielding with regards to side channel attacks) and for performance (e.g. on a 64-bit x86, RSA will be 5 or 6 times faster with 1.0.1g than with 0.9.8).

  • 1
    While not disagreeing, the 0.9.8 line of OpenSSL was last updated in Feb 2013 (0.9.8y), so some types of major vulnerabilities in OpenSSL were fixed (and 0.9.8 never had features like heartbeats), granted the 0.9.8 line never supported things like the latest version TLS 1.2. – dr jimbob Apr 17 '14 at 20:40
  • Yep, Heroku uses version from 2009. But I agree, I will go for the upgrade. Thanks everyone. I am not marking it as an answer, because it isn't (or is it? Can you confirm that openssl 0.9.8 can generate keys with elliptic curve, but can't sign with them?) and the question might still be relevant to people that don't have the option of upgrading. Still I will upvote. – Nikolay Tsenkov Apr 18 '14 at 10:55
  • 1
    I confirm 0.9.8 cannot ECDSA sign and verify using the 'generic' API EVP_{Sign,Verify}{Init,Update,Final} which the commandline subcommand dgst -sign/verify uses. 1.0.0 added (and commandline now uses) an improved API EVP_Digest{Sign,Verify}{Init,Update,Final} which does. As Thomas indicates, in 0.9.8 you can write your own code which calls the openssl primitives (SHA**, or EVP_Digest* for SHA*, and EC*); this will still work in 1.0.0 and later though less conveniently. – dave_thompson_085 Jul 4 '14 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.