├── .gitignore ├── README.markdown └── openssl.xcodeproj └── project.pbxproj /.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.pbxuser 3 | xcuserdata 4 | xcuserdata/* 5 | *.xcworkspace/* 6 | *.xcworkspace 7 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | openssl-xcode 2 | ============= 3 | 4 | This is an XCode project skeleton structure that can be used to build a static 5 | libcrypto.a library for use in Mac and iPhone projects. 6 | 7 | It is specifically intended for use in building secure iPhone 8 | applications alongside [SQLCipher](http://sqlcipher.net), 9 | but it can easily be used for other applications. 10 | 11 | ## Discontinued 12 | 13 | This project is no longer being actively maintained by Zetetic, LLC. 14 | 15 | It was originally created to help build SQLCipher for Apple platforms using OpenSSL as the crypto provider. It was no longer needed once Common Crypto became the crypto provider for SQLCipher on these platforms. For help building SQLCipher and including it in an Xcode project, [please see this tutorial](https://www.zetetic.net/sqlcipher/ios-tutorial/). 16 | 17 | Usage 18 | ----- 19 | 20 | In a normal case you would use it thusly: 21 | 22 | 1. Download the OpenSSL source code directly from 23 | http://www.openssl.org/source/ 24 | 2. Clone the openssl-xcode git repo to make a local copy 25 | 3. Either: 26 | a. Put the downloaded OpenSSL source tar.gz into the same folder 27 | as openssl.xcodeproj. 28 | b. Place an extracted OpenSSL distribution in a folder called 'openssl' 29 | within the same folder as openssl.xcodeproj 30 | c. Extracted the OpenSSL distribution directly into the same folder 31 | as openssl.xcodeproj. 32 | d. Setup a source tree definition in XCode for OPENSSL_SRC pointing the 33 | folder containing openssl source code 34 | 35 | Then, either open openssl.xcodeproj in XCode and initiate a build, or integrate 36 | it within another project: 37 | 38 | 1. Drag the openssl.xcodeproj file into your main project 39 | 2. Right-click on your project target, and add openssl.xcodeproj under "Direct 40 | Dependencies" on the General tab. 41 | 3. On the Build tab for your project's target, find the "Header Search Paths" 42 | option, and add the path: 43 | > `$(SRCROOT)/Library/openssl/build/openssl.build/openssl/include` 44 | 45 | (Assuming you've put openssl.xcodeproj at the path Library/openssl, and are 46 | building from a source tarball) 47 | 4. Expand your target's "Link Binary With Libraries" build stage, and drag 48 | libcrypto.a from the openssl.xcodeproj group. 49 | 50 | 51 | This project actually relies on the OpenSSL configure and make 52 | system to build the libraries. However, it does attempt to automatically 53 | detect and use the appropriate build settings for arch (i386/ppc/armv6), 54 | build tools, and SDK directories. This makes it appropriate for inclusion 55 | as a project reference into an iPhone application project. This project will 56 | also check to see if the resulting crypto library is newer than the project 57 | Makefile to avoid time consuming rebuild cycles. 58 | 59 | License 60 | ------- 61 | 62 | Copyright (c) 2009, ZETETIC LLC 63 | All rights reserved. 64 | 65 | Redistribution and use in source and binary forms, with or without 66 | modification, are permitted provided that the following conditions are met: 67 | 68 | * Redistributions of source code must retain the above copyright 69 | notice, this list of conditions and the following disclaimer. 70 | * Redistributions in binary form must reproduce the above copyright 71 | notice, this list of conditions and the following disclaimer in the 72 | documentation and/or other materials provided with the distribution. 73 | * Neither the name of the ZETETIC LLC nor the 74 | names of its contributors may be used to endorse or promote products 75 | derived from this software without specific prior written permission. 76 | 77 | THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY 78 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 79 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 80 | DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY 81 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 82 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 83 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 84 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 85 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 86 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 87 | 88 | Credits 89 | ------- 90 | 91 | * openssl-xcode was developed by Stephen Lombardo at Zetetic LLC (sjlombardo at zetetic.net / http://www.zetetic.net) 92 | * adapted for use with source archives by Michael Tyson of A Tasty Pixel (michael at atastypixel.com) 93 | 94 | -------------------------------------------------------------------------------- /openssl.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXFileReference section */ 10 | 9069D28C0FCE659A0042E34C /* libcrypto.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libcrypto.a; sourceTree = BUILT_PRODUCTS_DIR; }; 11 | /* End PBXFileReference section */ 12 | 13 | /* Begin PBXGroup section */ 14 | 9069D12D0FCE340B0042E34C = { 15 | isa = PBXGroup; 16 | children = ( 17 | 9069D25C0FCE62420042E34C /* Products */, 18 | ); 19 | sourceTree = ""; 20 | }; 21 | 9069D25C0FCE62420042E34C /* Products */ = { 22 | isa = PBXGroup; 23 | children = ( 24 | 9069D28C0FCE659A0042E34C /* libcrypto.a */, 25 | ); 26 | name = Products; 27 | sourceTree = ""; 28 | }; 29 | /* End PBXGroup section */ 30 | 31 | /* Begin PBXNativeTarget section */ 32 | 9069D28B0FCE659A0042E34C /* crypto */ = { 33 | isa = PBXNativeTarget; 34 | buildConfigurationList = 9069D2980FCE65C10042E34C /* Build configuration list for PBXNativeTarget "crypto" */; 35 | buildPhases = ( 36 | 9038ACD812DCAC96004FA0D0 /* ShellScript */, 37 | ); 38 | buildRules = ( 39 | ); 40 | dependencies = ( 41 | ); 42 | name = crypto; 43 | productName = crypto; 44 | productReference = 9069D28C0FCE659A0042E34C /* libcrypto.a */; 45 | productType = "com.apple.product-type.library.static"; 46 | }; 47 | /* End PBXNativeTarget section */ 48 | 49 | /* Begin PBXProject section */ 50 | 9069D12F0FCE340B0042E34C /* Project object */ = { 51 | isa = PBXProject; 52 | attributes = { 53 | LastUpgradeCheck = 0450; 54 | }; 55 | buildConfigurationList = 9069D1320FCE340B0042E34C /* Build configuration list for PBXProject "openssl" */; 56 | compatibilityVersion = "Xcode 3.2"; 57 | developmentRegion = English; 58 | hasScannedForEncodings = 0; 59 | knownRegions = ( 60 | English, 61 | Japanese, 62 | French, 63 | German, 64 | ); 65 | mainGroup = 9069D12D0FCE340B0042E34C; 66 | projectDirPath = ""; 67 | projectRoot = ""; 68 | targets = ( 69 | 9069D28B0FCE659A0042E34C /* crypto */, 70 | ); 71 | }; 72 | /* End PBXProject section */ 73 | 74 | /* Begin PBXShellScriptBuildPhase section */ 75 | 9038ACD812DCAC96004FA0D0 /* ShellScript */ = { 76 | isa = PBXShellScriptBuildPhase; 77 | buildActionMask = 2147483647; 78 | files = ( 79 | ); 80 | inputPaths = ( 81 | ); 82 | outputPaths = ( 83 | ); 84 | runOnlyForDeploymentPostprocessing = 0; 85 | shellPath = /bin/sh; 86 | shellScript = "set | grep ARCH\nset -x\n\n## Determine the appropriate openssl source path to use\n## Introduced by michaeltyson, adapted to account for OPENSSL_SRC build path\n\n# locate src archive file if present\nSRC_ARCHIVE=`ls openssl*tar.gz 2>/dev/null`\n\n# if there is an openssl directory immediately under the openssl.xcode source \n# folder then build there\nif [ -d \"$SRCROOT/openssl\" ]; then\nOPENSSL_SRC=\"$SRCROOT/openssl\"\n# else, if there is a openssl.tar.gz in the directory, expand it to openssl\n# and use it\nelif [ -f \"$SRC_ARCHIVE\" ]; then\nOPENSSL_SRC=\"$PROJECT_TEMP_DIR/openssl\"\nif [ ! -d \"$OPENSSL_SRC\" ]; then\necho \"extracting $SRC_ARCHIVE...\"\nmkdir \"$OPENSSL_SRC\"\ntar -C \"$OPENSSL_SRC\" --strip-components=1 -zxf \"$SRC_ARCHIVE\" || exit 1\ncp -RL \"$OPENSSL_SRC/include\" \"$TARGET_BUILD_DIR\"\nfi\n# else, if $OPENSSL_SRC is not already defined (i.e. by prerequisites for SQLCipher XCode config)\n# then assume openssl is in the current directory\nelif [ ! -d \"$OPENSSL_SRC\" ]; then\nOPENSSL_SRC=\"$SRCROOT\"\nfi\n\necho \"***** using $OPENSSL_SRC for openssl source code *****\"\n\n# check whether libcrypto.a already exists - we'll only build if it does not\nif [ -f \"$TARGET_BUILD_DIR/libcrypto.a\" ]; then\necho \"***** Using previously-built libary $TARGET_BUILD_DIR/libcrypto.a - skipping build *****\"\necho \"***** To force a rebuild clean project and clean dependencies *****\"\nexit 0;\nelse\necho \"***** No previously-built libary present at $TARGET_BUILD_DIR/libcrypto.a - performing build *****\"\nfi\n\n# figure out the right set of build architectures for this run\nBUILDARCHS=\"$ARCHS\"\n\necho \"***** creating universal binary for architectures: $BUILDARCHS *****\"\n\nif [ \"$SDKROOT\" != \"\" ]; then\nISYSROOT=\"-isysroot $SDKROOT\"\nfi\n\necho \"***** using ISYSROOT $ISYSROOT *****\"\n\nOPENSSL_OPTIONS=\"no-krb5 no-gost\"\n\necho \"***** using OPENSSL_OPTIONS $OPENSSL_OPTIONS *****\"\n\ncd \"$OPENSSL_SRC\"\n\nfor BUILDARCH in $BUILDARCHS\ndo\necho \"***** BUILDING UNIVERSAL ARCH $BUILDARCH ******\"\nmake clean\n\n# disable assembler\necho \"***** configuring WITHOUT assembler optimizations based on architecture $BUILDARCH and build style $BUILD_STYLE *****\"\n./config no-asm $OPENSSL_OPTIONS -openssldir=\"$BUILD_DIR\"\nASM_DEF=\"-UOPENSSL_BN_ASM_PART_WORDS\"\n\nmake CFLAG=\"-D_DARWIN_C_SOURCE $ASM_DEF -arch $BUILDARCH $ISYSROOT -Wno-unused-value -Wno-parentheses\" SHARED_LDFLAGS=\"-arch $BUILDARCH -dynamiclib\"\n\necho \"***** copying intermediate libraries to $CONFIGURATION_TEMP_DIR/$BUILDARCH-*.a *****\"\ncp libcrypto.a \"$CONFIGURATION_TEMP_DIR\"/$BUILDARCH-libcrypto.a\ncp libssl.a \"$CONFIGURATION_TEMP_DIR\"/$BUILDARCH-libssl.a\ndone\n\necho \"***** creating universallibraries in $TARGET_BUILD_DIR *****\"\nmkdir -p \"$TARGET_BUILD_DIR\"\nlipo -create \"$CONFIGURATION_TEMP_DIR/\"*-libcrypto.a -output \"$TARGET_BUILD_DIR/libcrypto.a\"\nlipo -create \"$CONFIGURATION_TEMP_DIR/\"*-libssl.a -output \"$TARGET_BUILD_DIR/libssl.a\"\n \necho \"***** removing temporary files from $CONFIGURATION_TEMP_DIR *****\"\nrm -f \"$CONFIGURATION_TEMP_DIR/\"*-libcrypto.a\nrm -f \"$CONFIGURATION_TEMP_DIR/\"*-libssl.a\n \necho \"***** executing ranlib on libraries in $TARGET_BUILD_DIR *****\"\nranlib \"$TARGET_BUILD_DIR/libcrypto.a\"\nranlib \"$TARGET_BUILD_DIR/libssl.a\"\n \n"; 87 | }; 88 | /* End PBXShellScriptBuildPhase section */ 89 | 90 | /* Begin XCBuildConfiguration section */ 91 | 9069D1300FCE340B0042E34C /* Debug */ = { 92 | isa = XCBuildConfiguration; 93 | buildSettings = { 94 | "ARCHS[sdk=iphoneos*]" = ( 95 | armv7, 96 | armv7s, 97 | ); 98 | "ARCHS[sdk=macosx*]" = ( 99 | x86_64, 100 | i386, 101 | ); 102 | COPY_PHASE_STRIP = NO; 103 | ONLY_ACTIVE_ARCH = YES; 104 | SDKROOT = "$(PLATFORM_NAME)"; 105 | SKIP_INSTALL = YES; 106 | SUPPORTED_PLATFORMS = "iphonesimulator macosx iphoneos"; 107 | VALID_ARCHS = "i386 x86_64 armv7 armv7s"; 108 | }; 109 | name = Debug; 110 | }; 111 | 9069D1310FCE340B0042E34C /* Release */ = { 112 | isa = XCBuildConfiguration; 113 | buildSettings = { 114 | "ARCHS[sdk=iphoneos*]" = ( 115 | armv7, 116 | armv7s, 117 | ); 118 | "ARCHS[sdk=macosx*]" = ( 119 | x86_64, 120 | i386, 121 | ); 122 | COPY_PHASE_STRIP = YES; 123 | SDKROOT = "$(PLATFORM_NAME)"; 124 | SKIP_INSTALL = YES; 125 | SUPPORTED_PLATFORMS = "iphonesimulator macosx iphoneos"; 126 | VALID_ARCHS = "i386 x86_64 armv7 armv7s"; 127 | }; 128 | name = Release; 129 | }; 130 | 9069D28D0FCE659B0042E34C /* Debug */ = { 131 | isa = XCBuildConfiguration; 132 | buildSettings = { 133 | ALWAYS_SEARCH_USER_PATHS = NO; 134 | COMBINE_HIDPI_IMAGES = YES; 135 | COPY_PHASE_STRIP = NO; 136 | GCC_DYNAMIC_NO_PIC = NO; 137 | GCC_MODEL_TUNING = G5; 138 | GCC_OPTIMIZATION_LEVEL = 0; 139 | INSTALL_PATH = /usr/local/lib; 140 | PRODUCT_NAME = crypto; 141 | }; 142 | name = Debug; 143 | }; 144 | 9069D28E0FCE659B0042E34C /* Release */ = { 145 | isa = XCBuildConfiguration; 146 | buildSettings = { 147 | ALWAYS_SEARCH_USER_PATHS = NO; 148 | COMBINE_HIDPI_IMAGES = YES; 149 | COPY_PHASE_STRIP = YES; 150 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 151 | GCC_MODEL_TUNING = G5; 152 | INSTALL_PATH = /usr/local/lib; 153 | PRODUCT_NAME = crypto; 154 | ZERO_LINK = NO; 155 | }; 156 | name = Release; 157 | }; 158 | /* End XCBuildConfiguration section */ 159 | 160 | /* Begin XCConfigurationList section */ 161 | 9069D1320FCE340B0042E34C /* Build configuration list for PBXProject "openssl" */ = { 162 | isa = XCConfigurationList; 163 | buildConfigurations = ( 164 | 9069D1300FCE340B0042E34C /* Debug */, 165 | 9069D1310FCE340B0042E34C /* Release */, 166 | ); 167 | defaultConfigurationIsVisible = 0; 168 | defaultConfigurationName = Release; 169 | }; 170 | 9069D2980FCE65C10042E34C /* Build configuration list for PBXNativeTarget "crypto" */ = { 171 | isa = XCConfigurationList; 172 | buildConfigurations = ( 173 | 9069D28D0FCE659B0042E34C /* Debug */, 174 | 9069D28E0FCE659B0042E34C /* Release */, 175 | ); 176 | defaultConfigurationIsVisible = 0; 177 | defaultConfigurationName = Release; 178 | }; 179 | /* End XCConfigurationList section */ 180 | }; 181 | rootObject = 9069D12F0FCE340B0042E34C /* Project object */; 182 | } 183 | --------------------------------------------------------------------------------