How to generate PKCS7 format signature using IOS iphone SDK? - ios

I could Generate PKCS1 formatted raw signature.. and was able to verify it even.
But could not find the resource to generate PCKS7 Formatted Signature using IPHONE IOS SDK.
I need to sign a simple text message.
Which library I have to use?
Can we use openssl for this? if yes? then how to include it in the XCODE library framework?
Pls help out.

Yes you can use openssl for this, however you will need to compile it yourself and link your App against the static library. If you want to run it in both the iPhone Simulator and a real iPhone Device (you do), you'll need to create a 'fat' library containing both armv7 and i386 architecture code. If you want to support iPhone 3 instead then you'll need to include armv6 architecture code. It's best therefore to build the library with all 3 architectures.
Here's a couple of resources that describe how to build openssl for iOS:
http://atastypixel.com/blog/easy-inclusion-of-openssl-into-iphone-app-projects/
https://github.com/st3fan/ios-openssl
EDIT: I actually modified st3fan's build script, which I have pasted here:
setenv.sh and build_openssl.sh
Download these scripts and keep them somewhere like ~/bin (review them and then chmod them 0755 once you are sure they are not malicious).
Next edit setenv.sh as it assumes there is a directory where you will install your 3rd-party libraries. By default this is /opt/local/ioslibs so make sure that exists and is owned by you else the final bit will fail. It's been configured for Xcode 4.2/iOS SDK 5 using the default locations so that might need correcting too.
build_openssl.sh is configured to build a specific version of openssl (1.0.0e) and will download the source tarball if it's not in the current directory (you need wget for that, but if you cannot be bothered to install wget then manually download it using the link within the script). When you run it, it will build the library in armv6, armv7 and i386 arch's and copy the correct files to the installation directory.

Related

How does one build a OpenSSL library for Project Catalyst?

I have to support OpenSSL in my project in building my iPad app for UIKitForMac. Currently, I get these errors.
Building for UIKit for Mac, but the linked library 'libssl.a' was built for freestanding. You may need to restrict the platforms for which this library should be linked in the target editor.
Building for UIKit for Mac, but the linked library 'libcrypto.a' was built for freestanding. You may need to restrict the platforms for which this library should be linked in the target editor.
I was reading about XCFrameworks, but Apple really hasn't put out much information here. Has anyone figured out build scenarios?
The solution in the comments doesn't work for me. However, I just build to different libs: iOS as I used to and another one for Catalyst by adding the build parameters: -target x86_64-apple-ios13.0-macabi and defining Mac SDK in -isysroot. After that, I just conditionally add each of the libraries for each build version and it works.
Amid mounting frustration following many failed attempts and Google searches, I successfully built openSSL 1.1.1g for Catalyst, compiled my project, linked openSSL and launched the app on my Mac by doing the following:
I used the same directory in to which I had previously extracted and built openSSL for IOS.
Following instructions here, I edited <openSSL directory>/Configurations/10-main.conf. Scrolling down to the "darwin64-x86_64-cc" section, I added a second CFLAGS line:
CFLAGS => add("-target x86_64-apple-ios13.0-macabi"),
In the openSSL directory, execute ./Configure darwin64-x86_64-cc -shared Note that I've seen several other versions of this Configure statement, some with many more options. This command worked for me, but I'm not sure what all the other variations do. You may want to research this further.
Execute make clean to clear all the objects from the prior IOS build
Execute make This successfully built openSSL.
In Xcode, under -> General -> "Frameworks, Libraries and Embedded Content" I removed both libcrypto.a and libssl.a this was a critical step
Switching tabs to Build Phases -> Link Binary With Libraries, verify both archives are removed from this section as well. (It appeared that removing them in step 5 also cleared them in step 6, but I'm not certain).
Back on General -> Frameworks, click the + to add new entries, select "add other" in the lower left corner of the popup window, then provide the path to the newly built libcrypto.a. Repeat for libssl.a
Delete the derived data in a terminal window (I'm not certain this was necessary, but did it out of an abundance of caution):
cd ~/Library/Developer/Xcode
mv DerivedData DerivedData.old
Build the project in Xcode. This successfully completed.
Steps 5-7 turned out to be critical. Even though I moved and/or completely replaced the prior libraries, when I tried to build in Xcode I would get linker errors that I was building for MacOS Catalina but trying to link something built for MacOS x86.

Embed OpenSSL module in Swift framework so its not needed when importing into application [duplicate]

I have installed OpenSSL in xcode for receipt validation, but it doesn't work.
I download openssl.xcodeproj and openssl-1.0.1f. I extract openssl-1.0.1f and add openssl.xcodeproj to my project.
I edit the Header Search Path to :
/Users/marko/Documents/Razvoj/BIView\ Mobile\ New\ Version/openssl/include/openssl
I added libcrypto.a in Target Dependencies under Build Phases
and added libcrypto.a in Link Binary With Libraries
as was described in http://atastypixel.com/blog/easy-inclusion-of-openssl-into-iphone-app-projects/.
But when I build project it stops with error :
clang: error: no such file or directory: '/Users/ .... -bmgslnakszsfovecplbzoslykrxo/Build/Products/Debug-iphoneos/libcrypto.a'
Why ?
OK, how to build and install it....
It might be easier to use a pre-built version of OpenSSL for iOS. You can find one at this Github account. The OpenSSL from that Github are multi-arch. They have ARMv7, ARMv7s, ARM64, and i386. That means they work with devices and simulators.
Download either OpenSSL 1.0.1e or 1.0.1f. Install it in a location like /usr/local/ssl/ios.
Then, add the headers to your Xcode project. They are located in /usr/local/ssl/ios/include:
Finally, add the multi-arch libs (libcrypto.a and libssl.a) to your Xcode project. They are located in /usr/local/ssl/ios/lib:
You need to add the library as a Framework. See this question: how to add an existing framework in Xcode 5.
Its OK to add the OpenSSL libraries under Frameworks. Its how things are done under Apple/Xcode.
I use the Absolute Path like in the image below because Crypto++, OpenSSL, etc are installed in /usr/local. The image below is a screen capture I have handy of Crypto++, and not OpenSSL's libcrypto.a or libssl.a. But the same applies to all libraries.

Installing OpenSSL library for Xcode

I have installed OpenSSL in xcode for receipt validation, but it doesn't work.
I download openssl.xcodeproj and openssl-1.0.1f. I extract openssl-1.0.1f and add openssl.xcodeproj to my project.
I edit the Header Search Path to :
/Users/marko/Documents/Razvoj/BIView\ Mobile\ New\ Version/openssl/include/openssl
I added libcrypto.a in Target Dependencies under Build Phases
and added libcrypto.a in Link Binary With Libraries
as was described in http://atastypixel.com/blog/easy-inclusion-of-openssl-into-iphone-app-projects/.
But when I build project it stops with error :
clang: error: no such file or directory: '/Users/ .... -bmgslnakszsfovecplbzoslykrxo/Build/Products/Debug-iphoneos/libcrypto.a'
Why ?
OK, how to build and install it....
It might be easier to use a pre-built version of OpenSSL for iOS. You can find one at this Github account. The OpenSSL from that Github are multi-arch. They have ARMv7, ARMv7s, ARM64, and i386. That means they work with devices and simulators.
Download either OpenSSL 1.0.1e or 1.0.1f. Install it in a location like /usr/local/ssl/ios.
Then, add the headers to your Xcode project. They are located in /usr/local/ssl/ios/include:
Finally, add the multi-arch libs (libcrypto.a and libssl.a) to your Xcode project. They are located in /usr/local/ssl/ios/lib:
You need to add the library as a Framework. See this question: how to add an existing framework in Xcode 5.
Its OK to add the OpenSSL libraries under Frameworks. Its how things are done under Apple/Xcode.
I use the Absolute Path like in the image below because Crypto++, OpenSSL, etc are installed in /usr/local. The image below is a screen capture I have handy of Crypto++, and not OpenSSL's libcrypto.a or libssl.a. But the same applies to all libraries.

Blackberry 10 Webworks SDK command line generate build with package and signing

So I already was able to build the .bar file, but now I want to build the .bar file to be sent to the store with the package and signing.
So far I've tried this.
bbwp C:\xampp\htdocs\maddash\packaged\maddash.zip -g (password) -b 1.0.0 -o C:\xampp\htdocs\maddash\packaged\
and my error is..
failed to find signing key file
Did you register your keys from RIM and put them in the default location (%HOMEPATH%\Local Settings\Application Data\Research In Motion for Windows)
Did you update your SDK? Then check your keys in bbwp\bin and rename sigtool to author and move your file to the default location.
If not sufficient, try installing the native IDE and use the UI for managing the keys in the preferences
My personal opinion about this problem.
First. If you have your signing key, great for you, because BB changed the system of signing apps. (Now they use BBtokenID, related with your BBID and, in this moment, the webworks framework is the only one that doesn't support this tokens) (Come on, Hip, Hip, Hurrah! :P).
According to your command, one comment
bbwp C:\xampp\htdocs\maddash\packaged\maddash.zip -g (password) -b 1.0.0 -o C:\xampp\htdocs\maddash\packaged\
In the first paramenter yoy must add the FOLDER of your source code, not your zipped code.
If you have your keys where it corresponds, it will generate a bar file signed.
NOW, you must package it in a zip file. If you need more help with that, tell me :)

How to separate the SDK from the Xcode and SDK bundle downloaded from Apple developer portal

I downloaded Xcode 4 and iOS SDK 4.3 bundle from https://developer.apple.com/downloads/index.action#. It's a dmg file and I am wondering if there is a way to find out where the iOS SDK is in the dmg file and copy it down to local disk? Anyone has tried that before?
Yes, I have tried that when I was trying to build an unofficial iOS toolchain on Linux (with success, by the way).
You have to mount the DMG - the best option for that is double-clicking the DMG in Finder or typing
hdiutil attach filename.dmg
to a command line.
When you have mounted the file, you'll see a bunch of directories - I don't remember to the exact path, but there should be a directory named Packages. In there, you'll find a dozen of files with the extension .pkg. Actually, these are XAR archives which contain GZip archives, which in turn contain cpio archives.
After having extracted the ones you feel logical (look for iPhoneOS4.3.sdk.pkg and the compilers [clang, GCC] as well), you will have the essential components of the iOS SDK, namely: the toolchain (containing the clang and GCC compilers and the necessary tools, including an assembler, linker and the GNU debugger, GDB) and the headers, frameworks and libraries (for example, UIKit, Foundation, libSystem, libsqlite3).
From now on, you shall be able to write simple makefiles and compile iOS apps without the need for using Xcode.

Resources