[GH-ISSUE #605] CommonCrypto fixes #274

Closed
opened 2026-10-14 02:59:33 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @magnumripper on GitHub (May 27, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/605

Originally assigned to: @magnumripper on GitHub.

CommonCrypto stuff is messy. It should be overhauled. We now have HAVE_COMMONCRYPTO from autoconf.

Here's a comment from CommonCrypto/CommonDigest.h:

/*
 * To use the above digest functions with existing code which uses
 * the corresponding openssl functions, #define the symbol 
 * COMMON_DIGEST_FOR_OPENSSL in your client code (BEFORE including
 * this file), and simply link against libSystem (or System.framework)
 * instead of libcrypto.
 *
 * You can *NOT* mix and match functions operating on a given data
 * type from the two implementations; i.e., if you do a CC_MD5_Init()
 * on a CC_MD5_CTX object, do not assume that you can do an openssl-style
 * MD5_Update() on that same context.
 */

My CommonCrypto (10.9 Mavericks) seem to support MD2, MD4, MD5, SHA1 and SHA2 this way. AES and other stuff are supported, but not with this "OpenSSL syntax" hack.

Originally created by @magnumripper on GitHub (May 27, 2014). Original GitHub issue: https://github.com/openwall/john/issues/605 Originally assigned to: @magnumripper on GitHub. CommonCrypto stuff is messy. It should be overhauled. We now have HAVE_COMMONCRYPTO from autoconf. Here's a comment from CommonCrypto/CommonDigest.h: ``` /* * To use the above digest functions with existing code which uses * the corresponding openssl functions, #define the symbol * COMMON_DIGEST_FOR_OPENSSL in your client code (BEFORE including * this file), and simply link against libSystem (or System.framework) * instead of libcrypto. * * You can *NOT* mix and match functions operating on a given data * type from the two implementations; i.e., if you do a CC_MD5_Init() * on a CC_MD5_CTX object, do not assume that you can do an openssl-style * MD5_Update() on that same context. */ ``` My CommonCrypto (10.9 Mavericks) seem to support MD2, MD4, MD5, SHA1 and SHA2 this way. AES and other stuff _are_ supported, but **not** with this "OpenSSL syntax" hack.
bsakaguchi 2026-10-14 02:59:33 +07:00
Author
Owner

@magnumripper commented on GitHub (May 27, 2014):

So we should ultimately have this, eg. for (our own) md5.h:

#if HAVE_COMMONCRYPTO
#define COMMON_DIGEST_FOR_OPENSSL
#include <CommonCrypto/CommonDigest.h>
#elif HAVE_OPENSSL
#include <openssl/md5.h>
#else
...our own implementation...
#endif

I guess this is what was intended all the time, but it's not right in all places. Especially not in PBKDF2 files, they bug out totally on 32-bit OSX for some reason.

<!-- gh-comment-id:44341285 --> @magnumripper commented on GitHub (May 27, 2014): So we should ultimately have this, eg. for (our own) md5.h: ``` #if HAVE_COMMONCRYPTO #define COMMON_DIGEST_FOR_OPENSSL #include <CommonCrypto/CommonDigest.h> #elif HAVE_OPENSSL #include <openssl/md5.h> #else ...our own implementation... #endif ``` I guess this is what was intended all the time, but it's not right in all places. Especially not in PBKDF2 files, they bug out totally on 32-bit OSX for some reason.
Author
Owner

@magnumripper commented on GitHub (May 28, 2014):

Lots of stuff fixed as of f4e9a70d. We are close to being able to build with only CommonCrypto, or OpenSSL, or both.

<!-- gh-comment-id:44430751 --> @magnumripper commented on GitHub (May 28, 2014): Lots of stuff fixed as of f4e9a70d. We are close to being able to build with _only_ CommonCrypto, or OpenSSL, or both.
Author
Owner

@magnumripper commented on GitHub (May 31, 2014):

...although I am contemplating NOT supporting building with both. That would be safer and easier.

<!-- gh-comment-id:44758010 --> @magnumripper commented on GitHub (May 31, 2014): ...although I am contemplating _NOT_ supporting building with both. That would be safer and easier.
Author
Owner

@magnumripper commented on GitHub (May 9, 2018):

I think we should drop support for CommonCrypto altogether

<!-- gh-comment-id:387860168 --> @magnumripper commented on GitHub (May 9, 2018): I think we should drop support for CommonCrypto altogether
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#274
No description provided.