Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure on OS X ≤ 10.9 due to missing CommonCrypto/CommonRandom.h #384

Closed
ryandesign opened this issue Apr 30, 2019 · 9 comments
Closed
Labels
compilation Issues related to compiling source code fixed Issue or bug has been fixed

Comments

@ryandesign
Copy link

Hi,

Just wanted to let you know that minizip 2.8.6 fails to build on OS X 10.9 and earlier because:

mz_crypt_apple.c:19:10: fatal error: 'CommonCrypto/CommonRandom.h' file not found
#include <CommonCrypto/CommonRandom.h>
         ^

Here are build failure logs for OS X 10.7, 10.8, and 10.9.

It builds fine on OS X 10.10 and later.

@nmoinvaz
Copy link
Member

You can build instead using the Brian's Gladman's library -DMZ_BRG=ON or OpenSSL instead -DMZ_OPENSSL=ON

@Coeur
Copy link
Contributor

Coeur commented Apr 30, 2019

Note that if you're coming from the branch 1.2, then it was historically using BRG (Brian's Gladman's AES lib), so -DMZ_BRG=ON will give you the least surprises.

@nmoinvaz
Copy link
Member

I have added a check to the cmake in the dev branch that will check for the availablity of common crypto library.

nmoinvaz added a commit that referenced this issue Apr 30, 2019
@nmoinvaz nmoinvaz added 2.0 compilation Issues related to compiling source code fixed Issue or bug has been fixed labels May 1, 2019
@ryandesign
Copy link
Author

You can build instead using the Brian's Gladman's library -DMZ_BRG=ON or OpenSSL instead -DMZ_OPENSSL=ON

Thanks, I'll look into those.

I have added a check to the cmake in the dev branch that will check for the availablity of common crypto library.

Thanks, but it looks like you added a check for CommonCrypto.h, but the header you're using that's missing is CommonRandom.h.

The first appearance of some of the Common Crypto functions was Mac OS X 10.4. The CommonCrypto.h header (which just includes some of the others) was added in OS X 10.8. The CommonRandom.h header (which contains the CCRandomGenerateBytes function minizip is using) was added in OS X 10.10.

@nmoinvaz
Copy link
Member

nmoinvaz commented May 2, 2019

Ok, I have updated it again. Thank you.

@nmoinvaz
Copy link
Member

nmoinvaz commented May 2, 2019

I'm not sure if it makes sense to use SecRandomCopyBytes instead. @Coeur thoughts?

@nmoinvaz
Copy link
Member

nmoinvaz commented May 2, 2019

I have changed it to use SecRandomCopyBytes which is available on 10.7. I wouldn't be surprised if underneath CCRandomCopyBytes it uses this function. Let me know if you have any issues with this.

@Coeur
Copy link
Contributor

Coeur commented May 2, 2019

I'm not sure if it makes sense to use SecRandomCopyBytes instead. @Coeur thoughts?

Regarding CommonCrypto.h, in my projects, I only target macOS 10.8+ for "modern" Objective-C or macOS 10.14.3+ for Swift with stable ABI, so I always have that header.

Regarding CCRandomCopyBytes, it's partially open source: https://opensource.apple.com/source/CommonCrypto/CommonCrypto-60074/lib/CommonRandom.c
It does:

rng = ccDRBGGetRngState();
return ccrng_generate((struct ccrng_state *)(struct ccrng_CommonCrypto_state *)rng, count, bytes);

So it has the same signature as SecRandomCopyBytes, and yes, they are probably interchangeable.

And for the laugh, CommonCrypto is using Brian Gladman AES under the hood: https://opensource.apple.com/source/CommonCrypto/CommonCrypto-55010/Source/GladmanAES/

@nmoinvaz
Copy link
Member

nmoinvaz commented May 2, 2019

And for the laugh, CommonCrypto is using Brian Gladman AES under the hood: https://opensource.apple.com/source/CommonCrypto/CommonCrypto-55010/Source/GladmanAES/

Haha that is a good laugh! It looks like more recent versions might not use it, still funny though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compilation Issues related to compiling source code fixed Issue or bug has been fixed
Projects
None yet
Development

No branches or pull requests

3 participants