1

So I was trying to compile a code which has a SHA1 function .. I included following header:

#include <openssl/sha.h>

And I got the following error while compiling:

test.c:9:5: error: 'SHA1' is deprecated: first deprecated in OS X 10.7
  [-Werror,-Wdeprecated-declarations]
SHA1(msg, strlen(msg), hs);
^

But man pages still have the descriptions for that function.

Can anyone suggest any other header for a similar function ( MD5 or SHA1 )?

PS - also do I need to link any libraries while compiling using gcc?

sukhvir
  • 5,265
  • 6
  • 41
  • 43
  • You can still use it. Deprecated does not mean not available. It's a recommendation to use a different hashing algorithm. You need to link to libcrypto - add `-lcrypto` to libraries to link to. – Anya Shenanigans Nov 07 '13 at 16:01

2 Answers2

2

You can still use it. Deprecated does not mean not available. It's a recommendation to use a different hashing algorithm. You need to link to libcrypto - add -lcrypto to libraries to link to.

If you're using more of openssl, you'll also need to link in libssl, using -lssl.

so, for example if your test code is test.c, you would do:

gcc -o test test.c -lcrypto -lssl
Anya Shenanigans
  • 91,618
  • 3
  • 107
  • 122
  • so what would my gcc command look like? do i need to link both lssl and lcrypto? – sukhvir Nov 07 '13 at 16:05
  • You only need to link both if you were making use of openssl specific functionality. If you're developing a mac only application, then I would recommend using the [Common Crypto](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/Common%20Crypto.3cc.html#//apple_ref/doc/man/3cc/CommonCrypto), but if you're just making some sample code then it's ok to keep using openssl like that. – Anya Shenanigans Nov 07 '13 at 16:26
1

Apple have deprecated OpenSSL, but don't worry, OpenSSL is a huge project and not going away any time soon.

You can turn off the deprecated error by adding -Wno-error=deprecated-declarations to your command line. This will keep the warnings (which is useful because it could help you catch other deprecated declarations) without causing it to error out.

There's some debate on why this happening on this post: Why is Apple Deprecating OpenSSL in MacOS 10.7 (Lion)?

Community
  • 1
  • 1
robbie_c
  • 2,428
  • 1
  • 19
  • 28