Skip to content

Commit

Permalink
Updates for the new swift-DEVELOPMENT-SNAPSHOT-2016-06-20-a builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Abt committed Jun 22, 2016
1 parent a8e5845 commit 5d67b5d
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 46 deletions.
36 changes: 35 additions & 1 deletion Cryptor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 9999;
LastUpgradeCheck = 0800;
TargetAttributes = {
8C95902A1CC80A2300A2C2B4 = {
CreatedOnToolsVersion = 7.3;
Expand Down Expand Up @@ -362,6 +362,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ibm.oss.CryptorTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
USER_HEADER_SEARCH_PATHS = /usr/local/opt/openssl/include;
};
name = Release;
Expand All @@ -383,6 +384,7 @@
PRODUCT_MODULE_NAME = Cryptor;
PRODUCT_NAME = "lib$(TARGET_NAME)";
SWIFT_INCLUDE_PATHS = "\"$SRCROOT/CommonCrypto\"";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
USER_HEADER_SEARCH_PATHS = /usr/local/opt/openssl/include;
};
name = Release;
Expand Down Expand Up @@ -412,12 +414,44 @@
"_____Release_" /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
};
name = Release;
};
"_______Debug_" /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
};
name = Debug;
};
Expand Down
91 changes: 69 additions & 22 deletions Cryptor.xcodeproj/xcshareddata/xcschemes/Cryptor.xcscheme
Original file line number Diff line number Diff line change
@@ -1,24 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme LastUpgradeVersion = "9999" version = "1.3">
<BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "______Target_Cryptor"
BuildableName = "libCryptor.dylib"
BlueprintName = "Cryptor"
ReferencedContainer = "container:Cryptor.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<Scheme
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "______Target_Cryptor"
BuildableName = "libCryptor.dylib"
BlueprintName = "Cryptor"
ReferencedContainer = "container:Cryptor.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "______Target_Cryptor"
BuildableName = "libCryptor.dylib"
BlueprintName = "Cryptor"
ReferencedContainer = "container:Cryptor.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ This package is functionally complete and has all current relevant tests passing
## Prerequisites

### Swift
* Swift Open Source `swift-DEVELOPMENT-SNAPSHOT-2016-05-09-a` toolchain (**Minimum REQUIRED for latest release**)
* Swift Open Source `swift-DEVELOPMENT-SNAPSHOT-2016-05-31-a` toolchain *or*
* Swift Open Source `swift-DEVELOPMENT-SNAPSHOT-2016-06-06-a` toolchain (*Recommended*)
* Swift Open Source `swift-DEVELOPMENT-SNAPSHOT-2016-06-20-a` toolchain (**Minimum REQUIRED for latest release**)

### OS X

* OS X 10.11.0 (*El Capitan*) or higher
* Xcode Version 7.3.1 (7D1012) or higher using the one of the above toolchains (*Recommended*)
* Xcode Version 8.0 beta (8S128d) or higher using the above toolchain (*Recommended*)

### Linux

* Ubuntu 15.10 (or 14.04 but only tested on 15.10)
* One of the Swift Open Source toolchains listed above
* The Swift Open Source toolchains listed above

## Build

Expand Down
28 changes: 12 additions & 16 deletions Sources/Crypto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ extension CryptoDigest {
}

///
/// Extension for NSData to return an NSData object containing the digest.
/// Extension for Data to return an Data object containing the digest.
///
extension NSData: CryptoDigest {
#if os(OSX)

extension Data: CryptoDigest {
///
/// Calculates the Message Digest for this data.
///
Expand All @@ -85,23 +87,17 @@ extension NSData: CryptoDigest {
///
/// - Note: Not supported on Linux due to differences in the `NSData` Foundation API.
///
public func digest(using algorithm: Digest.Algorithm) -> Self {
public func digest(using algorithm: Digest.Algorithm) -> Data {

#if os(OSX)

// This force unwrap may look scary but for CommonCrypto this cannot fail.
// The API allows for optionals to support the OpenSSL implementation which can.
let result = (Digest(using: algorithm).update(data: self)?.final())!
let data = self.dynamicType.init(bytes: result, length: result.count)
return data

#elseif os(Linux)

fatalError("This API currently not supported on Linux.")

#endif
// This force unwrap may look scary but for CommonCrypto this cannot fail.
// The API allows for optionals to support the OpenSSL implementation which can.
let result = (Digest(using: algorithm).update(data: self)?.final())!
let data = self.dynamicType.init(bytes: result, count: result.count)
return data
}
}

#endif

///
/// Extension for String to return a String containing the digest.
Expand Down
2 changes: 1 addition & 1 deletion Sources/HMAC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public class HMAC : Updateable {

self.algorithm = algorithm
#if os(OSX)
CCHmacInit(context, algorithm.nativeValue(), key, size_t(key.lengthOfBytes(using: NSUTF8StringEncoding)))
CCHmacInit(context, algorithm.nativeValue(), key, size_t(key.lengthOfBytes(using: String.Encoding.utf8)))
#elseif os(Linux)
HMAC_Init(context, key, Int32(key.utf8.count), algorithm.nativeValue())
#endif
Expand Down
2 changes: 1 addition & 1 deletion Tests/Cryptor/CryptorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class CryptorTests: XCTestCase {
XCTAssertEqual(shaShortBlock.sha384, sha384BlockOutput)
XCTAssertEqual(shaShortBlock.sha512, sha512BlockOutput)
#if os(OSX)
let theData: NSData = shaShortBlock.data(using:NSUTF8StringEncoding)!
let theData: Data = shaShortBlock.data(using:String.Encoding.utf8)!
XCTAssertEqual(theData.sha224, CryptoUtils.data(fromHex: sha224BlockOutput))
XCTAssertEqual(theData.sha256, CryptoUtils.data(fromHex: sha256BlockOutput))
XCTAssertEqual(theData.sha384, CryptoUtils.data(fromHex: sha384BlockOutput))
Expand Down

0 comments on commit 5d67b5d

Please sign in to comment.