hohl / MIHCrypto

OpenSSL wrapper for Objective-C [cryptography]
MIT License
340 stars 66 forks source link

Update to OpenSSL 1.1.180 #64

Closed matanelgabsi closed 3 years ago

matanelgabsi commented 3 years ago

Universal-OpenSSL 1.1.X is a breaking change.. had to do a few adjustments:

  1. updated minimum dependency version
  2. EVP_CIPHER_CTX can't be used directly, using EVP_CIPHER_CTX_new.
  3. Updated imports to #import <OpenSSL/OpenSSL.h> instead of directly importing files
  4. Updated some deprecated functions (initWithBase64Encoding for example)
  5. replace CRYPTO_add(&_rsa->references, 1, CRYPTO_LOCK_RSA); with RSA_up_ref

This change also fixes listing issue (https://github.com/hohl/MIHCrypto/issues/62), so now lint has no errors..

hohl commented 3 years ago

Great, and thanks for sharing this. Would be happy to release a new version. But, any ideas why the MIHBigIntegerTests -testInitWithSignedInteger fails?

matanelgabsi commented 3 years ago

Yes, I think so, I'm trying to debug right now and fix.. sorry for missing the test :( (the reason, I think, is that BN_LONG was removed from openssl, trying to find an alternative macro)

matanelgabsi commented 3 years ago

If you have any idea I would love to hear it.. can't find an alternative macro for it.. not sure why they removed it..

matanelgabsi commented 3 years ago

@hohl I can confirm this is the issue, do you have any good idea what to do with it? it seems that OpenSSL removed BN_LONG. I can think of two options:

  1. Remove support for signed values (less preferable)
  2. Copy BL_LONG def from older versions of openssl, and add it to the top of MIHBigInteger.h. something like this:
/*
 * 64-bit processor with LP64 ABI
 */
# ifdef SIXTY_FOUR_BIT_LONG
#  define BN_LONG        long
# endif

/*
 * 64-bit processor other than LP64 ABI
 */
# ifdef SIXTY_FOUR_BIT
#  define BN_LONG        long long
# endif

# ifdef THIRTY_TWO_BIT
#  define BN_LONG        int
# endif

What do you think?

hohl commented 3 years ago

I guess option two is the best one for now.

matanelgabsi commented 3 years ago

Tests now passed

hohl commented 3 years ago

Looks good to me. I'll have a closer look at the weekend and will most likely push out an update thereafter. Thanks for your work! Then, let's get that pod finally up-to-date again! :)

hohl commented 3 years ago

Did you run pod lib lint? Test cases pass in Xcode, but I can't make CocoaPods become friends with the OpenSSL dependency.

Ignoring ffi-1.12.2 because its extensions are not built. Try: gem pristine ffi --version 1.12.2

 -> MIHCrypto (0.6.0)
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  note: Using new build system
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  note: Building targets in parallel
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  note: Using codesigning identity override: -
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  note: Planning build
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  note: Constructing build description
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the App editor. (in target 'App' from project 'App')
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bio.h:687:1: error: expected function body after function declarator
    - WARN  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bio.h:699:55: warning: declaration of 'union BIO_sock_info_u' will not be visible outside of this function [-Wvisibility]
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:183:43: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:186:39: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:214:22: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:266:1: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:266:39: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:267:1: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:267:33: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:268:28: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:269:28: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:270:28: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:271:28: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:272:1: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:288:37: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:323:24: error: unknown type name 'BN_ULONG'
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:332:1: error: expected function body after function declarator
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/bn.h:403:1: error: expected function body after function declarator
    - WARN  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/asn1.h:554:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/asn1.h:554:68: error: expected ';' after top level declarator
    - ERROR | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/ios-arm64_arm64e_armv7_armv7s/openssl.framework/Headers/ec.h:274:1: error: expected function body after function declarator
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  fatal error: too many errors emitted, stopping now [-ferror-limit=]
    - NOTE  | [MIHCrypto/SHA] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/SHA/MIHSecureHashAlgorithm512.m:20:9: fatal error: could not build module 'OpenSSL'
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/Utils/NSData+MIHConversion.m:20:10: fatal error: could not build module 'OpenSSL'
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  note: Using codesigning identity override: 
    - WARN  | [MIHCrypto/RSA] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/RSA/MIHRSAKeyFactory.m:43:60: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    - WARN  | [MIHCrypto/EC] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/EC/MIHECPublicKey.m:51:27: warning: passing 'unsigned char **' to parameter of type 'const unsigned char **' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
    - NOTE  | [MIHCrypto/EC] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/macos-arm64_arm64e_x86_64/OpenSSL.framework/Headers/ec.h:1062:61: note: passing argument to parameter 'in' here
    - WARN  | [MIHCrypto/EC] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/EC/MIHECPublicKey.m:76:50: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    - WARN  | [MIHCrypto/EC] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/EC/MIHECPublicKey.m:76:80: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    - WARN  | [MIHCrypto/EC] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/EC/MIHECPublicKey.m:98:50: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    - WARN  | [MIHCrypto/EC] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/EC/MIHECPrivateKey.m:51:28: warning: passing 'unsigned char **' to parameter of type 'const unsigned char **' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
    - NOTE  | [MIHCrypto/EC] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/macos-arm64_arm64e_x86_64/OpenSSL.framework/Headers/ec.h:1019:62: note: passing argument to parameter 'in' here
    - WARN  | [MIHCrypto/EC] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/EC/MIHECPrivateKey.m:77:31: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    - WARN  | [MIHCrypto/EC] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/EC/MIHECPrivateKey.m:107:51: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    - WARN  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/Utils/MIHCryptoConfiguration.m:61:5: warning: 'OPENSSL_config' is deprecated [-Wdeprecated-declarations]
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  OpenSSL-Universal/Frameworks/OpenSSL.xcframework/macos-arm64_arm64e_x86_64/OpenSSL.framework/Headers/conf.h:91:1: note: 'OPENSSL_config' has been explicitly marked deprecated here
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  warning: [CP] Unable to find matching .xcframework slice in ' false macos-arm64_arm64e_x86_64/OpenSSL.framework' for the current build architectures (arm64 x86_64).
    - NOTE  | [MIHCrypto/Core, MIHCrypto/Mathematics, MIHCrypto/AES, and more...] xcodebuild:  ld: warning: directory not found for option '-LOpenSSL-Universal/lib-ios'
    - NOTE  | [MIHCrypto/AES,MIHCrypto/EC] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/Utils/MIHInternal.m:20:10: fatal error: could not build module 'OpenSSL'
    - NOTE  | [MIHCrypto/RSA] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/RSA/MIHRSAPublicKey.h:18:10: fatal error: could not build module 'OpenSSL'
    - NOTE  | [iOS] [MIHCrypto/SHA] xcodebuild:  <PROJECT_DIR>/MIHCrypto/MIHCrypto/SHA/MIHSecureHashAlgorithm384.m:20:9: fatal error: could not build module 'OpenSSL'

[!] MIHCrypto did not pass validation, due to 20 errors and 11 warnings.
You can use the `--no-clean` option to inspect any issue.
matanelgabsi commented 3 years ago

I did run it, but when i created the PR, seems that changes done as a result of the failed test messed something up.. I will look into it..

hohl commented 3 years ago

Great, thank you for your dedication to this upgrade! 🙂