FredericJacobs / OpenSSL-Pod

Unmaintained - please fork. Email me to take over the CocoaPod
74 stars 112 forks source link

WatchOS 2 support #34

Closed AdrianaPineda closed 8 years ago

AdrianaPineda commented 8 years ago

Hi! Im trying to integrate this pod in my watchOS 2 target, but Im getting the following error:

ld: file is universal (5 slices) but does not contain a(n) armv7k slice: .../Pods/OpenSSL/lib/libssl.a file '.../Pods/OpenSSL/lib/libssl.a' for architecture armv7k

Do you support arch armv7k?

Thanks!

FredericJacobs commented 8 years ago

I'll look into it tomorrow. I have a deadline soon. Thanks for reporting.

AdrianaPineda commented 8 years ago

@FredericJacobs awesome. Thank you! If I can help you in some way, just let me know

FredericJacobs commented 8 years ago

Adding the arch to the ARCHS list should work. But no time to test today.

https://github.com/FredericJacobs/OpenSSL-Pod/blob/master/1.0.208/OpenSSL.podspec#L20

AdrianaPineda commented 8 years ago

@FredericJacobs I tried doing that but its not working for me. I'm testing other changes and I'll write back if it works

AdrianaPineda commented 8 years ago

@FredericJacobs did you have any chance to look at this? Thanks!

FredericJacobs commented 8 years ago

Do you have a sample project?

AdrianaPineda commented 8 years ago

@FredericJacobs not a public one, but I can create one if you want

FredericJacobs commented 8 years ago

@AdrianaPineda That would be helpful.

AdrianaPineda commented 8 years ago

@FredericJacobs I did one here https://github.com/AdrianaPineda/testWatch2, let me know if it helps

FredericJacobs commented 8 years ago

@AdrianaPineda Thanks for providing that. But I'm not getting the same error you originally reported. Can you reproduce it on the project you provided?

AdrianaPineda commented 8 years ago

@FredericJacobs are you building it for a real device, or simulator? The error happens just when you try to run a real device

AdrianaPineda commented 8 years ago

@FredericJacobs were you able to get the error on a real device?

FredericJacobs commented 8 years ago

Sadly not.

I tried doing that but its not working for me

What did it say after adding the new architecture to the list of build targets?

AdrianaPineda commented 8 years ago

@FredericJacobs it takes a while and it crashes when building for armv7k

Building openssl-1.0.2x for ... armv7k Please stand by...

/Users/apineda/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/cocoapods-0.38.2/lib/cocoapods/executable.rb:70:in execute_command' /Users/apineda/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/cocoapods-0.38.2/lib/cocoapods/executable.rb:27:inblock in executable' /Users/apineda/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/cocoapods-0.38.2/lib/cocoapods/installer/pod_source_preparer.rb:64:in `block (2 levels) in run_prepare_command' ...

FredericJacobs commented 8 years ago

Looks like the issue is that Bitcode is required for watchOS, I think we'll have to make a Bitcode option for those targeting watchOS.

For iOS apps, bitcode is the default, but optional. For watchOS and tvOS apps, bitcode is required.

https://developer.apple.com/library/tvos/documentation/IDEs/Conceptual/AppDistributionGuide/AppThinning/AppThinning.html

AdrianaPineda commented 8 years ago

@FredericJacobs do you have an ETA for this bitcode option? Thanks!

FredericJacobs commented 8 years ago

@AdrianaPineda What crypto operation do you want to do on the Watch?

AdrianaPineda commented 8 years ago

@FredericJacobs Im working on an app that decrypts a secret received from a server.

chrisballinger commented 8 years ago

@AdrianaPineda You probably want to do the crypto operations on the iOS device and pass the results back and forth using the Watch Connectivity framework: https://developer.apple.com/library/watchos/documentation/WatchConnectivity/Reference/WatchConnectivity_framework/index.html#//apple_ref/doc/uid/TP40015269

FredericJacobs commented 8 years ago

@AdrianaPineda:

Im working on an app that decrypts a secret received from a server.

Does it use AES? Do you need P256? Let me know what operation you need and we can figure it out.

AdrianaPineda commented 8 years ago

@chrisballinger thanks. I going to try that one out :) @FredericJacobs yes Im using AES. Im going to try to remove OpenSSL from the watch as @chrisballinger suggested and if it works then there is no need to update the pod :)

FredericJacobs commented 8 years ago

@AdrianaPineda I strongly recommend you to use CommonCrypto that is provided by Apple instead of OpenSSL if you're going to do crypto operations on the Watch. It's safer against some Bitcode attacks (affecting timing of crypto operations) that I wrote previously about.CommonCrypto is open-source.

CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding,
                                     keyPtr, kCCKeySizeAES256,
                                     NULL /* initialization vector (optional) */,
                                     [self bytes], dataLength, /* input */
                                     buffer, bufferSize, /* output */
                                     &numBytesEncrypted);
AdrianaPineda commented 8 years ago

@FredericJacobs thanks! I exclude OpenSSL for the watch app, and I was able to run on a real device. I will definitely migrate to CommonCrypto. Thank you very much for your help!

flash23 commented 8 years ago

Hi I run in to a problem today. I am using openssl pod to generate ecc key pair in my ios app. From that key pair I generate csr using ecdsa sign... I send that to server and I get back server cert witch I sign using my ecc private key.... to get client certificate in PKCS12 format. From that point I use that PKCS12cliet cert for TLS communication....

I need to support watchos also. And from this discussion I will not be able to use this openssl pod on watchos?

If there is any way to use functions I need from openssl lib on watchos?

Or does anybody now how can I do all of described in cryptocommon lib? I cant find good documentation?

thx