7

I'm looking for a crypto library to use with Objective-C code. There is a C++ library which is too big for my needs. It's 20 mb when compiled. I think a C library would be perfect to use with Objective-C. Here is my needs for this library: AES (Rijndael) CFB Mode SHA1 SHA256 HMAC-SHA1 HMAC-SHA256 PBKDF2

Your help will be greatly appreciated.

cocoatoucher
  • 1,483
  • 3
  • 17
  • 22

3 Answers3

19

The usual/official way to do this is to #import <CommonCrypto/CommonDigest.h>, which is the CommonCrypto library. Then, you can use functions like CC_MD5(), CC_SHA(), CC_HMac(), etc.

The CommonCrypto man page has links to all the available functions.

Matt Ball
  • 6,608
  • 1
  • 32
  • 31
  • 5
    Matt has the better answer here, unless you're looking for portability to other OS's. OpenSSL is basically there for compatibility only. Apple's own projects either use or are migrating to CommonCrypto or Keychain Services. – Kaelin Colclasure Oct 17 '11 at 22:42
  • Apple's sample code for CommonCrypto can be found here: https://opensource.apple.com//source/CommonCrypto/ – iHS Nov 12 '18 at 23:56
10

I link against OpenSSL for cryptography in my Objective-C projects. If you're using OS X, this is already installed on every user's machine. There's also a cocoa framework called SSCrypto which provides Objective-C wrappers for openssl, which makes the C-based openssl library a little easier to use.

Jarret Hardie
  • 95,172
  • 10
  • 132
  • 126
1

I started a libsodium/NaCl wrapper for Objective-C at https://github.com/gabriel/NACL

Gabriel
  • 964
  • 9
  • 8