diff --git a/.travis.yml b/.travis.yml index 1cdc8320..4c1311b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,16 @@ language: objective-c osx_image: xcode7.3 -#before_install: -# - brew update -# - brew install carthage -before_script: - - carthage bootstrap before_deploy: - carthage build --no-skip-current cache: cocoapods -# podfile: Example/Podfile +podfile: Example/Podfile -# before_install: -# - gem install cocoapods # Since Travis is not always on latest version -# - pod install --project-directory=Example +before_install: +- gem install cocoapods # Since Travis is not always on latest version +- pod install --project-directory=Example script: -# TODO: Build the CocoaPods project -# - set -o pipefail && xcodebuild -workspace Example/xDripG5.xcworkspace -scheme xDripG5-Example -sdk iphonesimulator -destination name="iPhone 6" ONLY_ACTIVE_ARCH=NO | xcpretty +- set -o pipefail && xcodebuild -workspace Example/xDripG5.xcworkspace -scheme xDripG5-Example -sdk iphonesimulator -destination name="iPhone 6" ONLY_ACTIVE_ARCH=NO | xcpretty - xctool -project xDripG5.xcodeproj -scheme xDripG5 -sdk iphonesimulator9.3 build test -- pod lib lint --allow-warnings +- pod lib lint diff --git a/Cartfile b/Cartfile deleted file mode 100644 index 77b4b3a3..00000000 --- a/Cartfile +++ /dev/null @@ -1 +0,0 @@ -github "loudnate/Crypto" "master" diff --git a/Cartfile.resolved b/Cartfile.resolved deleted file mode 100644 index 31ffa277..00000000 --- a/Cartfile.resolved +++ /dev/null @@ -1 +0,0 @@ -github "loudnate/Crypto" "13fee45175b88629aeabe60b4b4fc3daf86fa0a3" diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 88ce2e8e..9eb2715d 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,7 +1,5 @@ PODS: - - RNCryptor (4.0.0) - - xDripG5 (0.4.0): - - RNCryptor (~> 4.0) + - xDripG5 (0.5.0) DEPENDENCIES: - xDripG5 (from `../`) @@ -11,9 +9,8 @@ EXTERNAL SOURCES: :path: ../ SPEC CHECKSUMS: - RNCryptor: 59d6483908115af5c12b884db23392024e52a5fe - xDripG5: ebd5b967768e7823b80c504b87256fd5dd55d469 + xDripG5: 0e6b96df757adbd51d5aa24c1ef63cb25a2d2b72 PODFILE CHECKSUM: 6b30cba971694d5258509315fb52eb645c9bc5e3 -COCOAPODS: 1.0.0 +COCOAPODS: 1.0.1 diff --git a/Example/xDripG5.xcodeproj/project.pbxproj b/Example/xDripG5.xcodeproj/project.pbxproj index 10bb1f28..10708edc 100644 --- a/Example/xDripG5.xcodeproj/project.pbxproj +++ b/Example/xDripG5.xcodeproj/project.pbxproj @@ -121,12 +121,12 @@ isa = PBXNativeTarget; buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "xDripG5_Example" */; buildPhases = ( - 1A9A76347F38888700DA6FA9 /* 📦 Check Pods Manifest.lock */, + 1A9A76347F38888700DA6FA9 /* [CP] Check Pods Manifest.lock */, 607FACCC1AFB9204008FA782 /* Sources */, 607FACCD1AFB9204008FA782 /* Frameworks */, 607FACCE1AFB9204008FA782 /* Resources */, - 4B912A9AD16911278D3DAA5C /* 📦 Embed Pods Frameworks */, - 2FC4228A9369221D367ED688 /* 📦 Copy Pods Resources */, + 4B912A9AD16911278D3DAA5C /* [CP] Embed Pods Frameworks */, + 2FC4228A9369221D367ED688 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -189,14 +189,14 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 1A9A76347F38888700DA6FA9 /* 📦 Check Pods Manifest.lock */ = { + 1A9A76347F38888700DA6FA9 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "📦 Check Pods Manifest.lock"; + name = "[CP] Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -204,14 +204,14 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - 2FC4228A9369221D367ED688 /* 📦 Copy Pods Resources */ = { + 2FC4228A9369221D367ED688 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "📦 Copy Pods Resources"; + name = "[CP] Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -219,14 +219,14 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-xDripG5_Example/Pods-xDripG5_Example-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 4B912A9AD16911278D3DAA5C /* 📦 Embed Pods Frameworks */ = { + 4B912A9AD16911278D3DAA5C /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "📦 Embed Pods Frameworks"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Pod/xDripG5.h b/Pod/xDripG5.h index b2fb2008..63dab445 100644 --- a/Pod/xDripG5.h +++ b/Pod/xDripG5.h @@ -6,4 +6,5 @@ // Copyright © 2015 Nathan Racklyeft. All rights reserved. // -@import RNCryptor; + +#import \ No newline at end of file diff --git a/xDripG5.podspec b/xDripG5.podspec index 3e698922..5151c924 100644 --- a/xDripG5.podspec +++ b/xDripG5.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "xDripG5" - s.version = "0.4.1" + s.version = "0.5.0" s.summary = "An interface for communicating with the G5 glucose transmitter over Bluetooth." s.description = <<-DESC @@ -20,9 +20,8 @@ Please note this project is neither created nor backed by Dexcom, Inc. Use of th s.platform = :ios, '9.3' s.requires_arc = true - s.source_files = ['xDripG5/**/*.swift', 'Pod/*.h'] - s.public_header_files = 'Pod/*.h' + s.source_files = ['xDripG5/**/*.swift', 'xDripG5/AESCrypt.{h,m}', 'Pod/*.h'] + s.public_header_files = ['Pod/*.h', 'xDripG5/AESCrypt.h'] s.frameworks = 'CoreBluetooth' - s.dependency 'RNCryptor', '~> 4.0' end diff --git a/xDripG5.xcodeproj/project.pbxproj b/xDripG5.xcodeproj/project.pbxproj index 7465e57b..638c3494 100644 --- a/xDripG5.xcodeproj/project.pbxproj +++ b/xDripG5.xcodeproj/project.pbxproj @@ -8,9 +8,6 @@ /* Begin PBXBuildFile section */ 430D64C51CB7846A00FCA750 /* NSData+CRC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430D64C41CB7846A00FCA750 /* NSData+CRC.swift */; }; - 4337D7EB1C351B0B0016851F /* CommonCrypto.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4337D7EA1C351B0B0016851F /* CommonCrypto.framework */; }; - 4337D7ED1C3521210016851F /* CommonCrypto.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4337D7EA1C351B0B0016851F /* CommonCrypto.framework */; }; - 434FD68A1C3523A7000B4E2E /* CommonCrypto.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4337D7EA1C351B0B0016851F /* CommonCrypto.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 43CABDF71C3506F100005705 /* xDripG5.h in Headers */ = {isa = PBXBuildFile; fileRef = 43CABDF61C3506F100005705 /* xDripG5.h */; settings = {ATTRIBUTES = (Public, ); }; }; 43CABDFE1C3506F100005705 /* xDripG5.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43CABDF31C3506F100005705 /* xDripG5.framework */; }; 43CABE121C350B2800005705 /* BluetoothManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43CABE0E1C350B2800005705 /* BluetoothManager.swift */; }; @@ -39,6 +36,8 @@ 43CE7CDC1CA77468003CC1B0 /* TransmitterStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43CE7CDB1CA77468003CC1B0 /* TransmitterStatus.swift */; }; 43DC87C01C8B509B005BC30D /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43DC87BF1C8B509B005BC30D /* NSData.swift */; }; 43DC87C21C8B520F005BC30D /* GlucoseRxMessageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43DC87C11C8B520F005BC30D /* GlucoseRxMessageTests.swift */; }; + 43EEA7111D14DC0800CBBDA0 /* AESCrypt.h in Headers */ = {isa = PBXBuildFile; fileRef = 43EEA70F1D14DC0800CBBDA0 /* AESCrypt.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 43EEA7121D14DC0800CBBDA0 /* AESCrypt.m in Sources */ = {isa = PBXBuildFile; fileRef = 43EEA7101D14DC0800CBBDA0 /* AESCrypt.m */; }; 43F82BCC1D035AA4006F5DD7 /* TransmitterTimeRxMessageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F82BCB1D035AA4006F5DD7 /* TransmitterTimeRxMessageTests.swift */; }; 43F82BCE1D035D5C006F5DD7 /* SessionStartRxMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F82BCD1D035D5C006F5DD7 /* SessionStartRxMessage.swift */; }; 43F82BD01D035D68006F5DD7 /* SessionStopRxMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F82BCF1D035D68006F5DD7 /* SessionStopRxMessage.swift */; }; @@ -63,7 +62,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 434FD68A1C3523A7000B4E2E /* CommonCrypto.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -71,7 +69,6 @@ /* Begin PBXFileReference section */ 430D64C41CB7846A00FCA750 /* NSData+CRC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSData+CRC.swift"; sourceTree = ""; }; - 4337D7EA1C351B0B0016851F /* CommonCrypto.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CommonCrypto.framework; path = Carthage/Build/iOS/CommonCrypto.framework; sourceTree = ""; }; 43CABDF31C3506F100005705 /* xDripG5.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = xDripG5.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 43CABDF61C3506F100005705 /* xDripG5.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = xDripG5.h; sourceTree = ""; }; 43CABDF81C3506F100005705 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -103,6 +100,8 @@ 43CE7CDB1CA77468003CC1B0 /* TransmitterStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransmitterStatus.swift; sourceTree = ""; }; 43DC87BF1C8B509B005BC30D /* NSData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSData.swift; sourceTree = ""; }; 43DC87C11C8B520F005BC30D /* GlucoseRxMessageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GlucoseRxMessageTests.swift; sourceTree = ""; }; + 43EEA70F1D14DC0800CBBDA0 /* AESCrypt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AESCrypt.h; sourceTree = ""; }; + 43EEA7101D14DC0800CBBDA0 /* AESCrypt.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AESCrypt.m; sourceTree = ""; }; 43F82BCB1D035AA4006F5DD7 /* TransmitterTimeRxMessageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransmitterTimeRxMessageTests.swift; sourceTree = ""; }; 43F82BCD1D035D5C006F5DD7 /* SessionStartRxMessage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SessionStartRxMessage.swift; sourceTree = ""; }; 43F82BCF1D035D68006F5DD7 /* SessionStopRxMessage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SessionStopRxMessage.swift; sourceTree = ""; }; @@ -115,7 +114,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 4337D7EB1C351B0B0016851F /* CommonCrypto.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -123,7 +121,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 4337D7ED1C3521210016851F /* CommonCrypto.framework in Frameworks */, 43CABDFE1C3506F100005705 /* xDripG5.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -134,7 +131,6 @@ 43CABDE91C3506F100005705 = { isa = PBXGroup; children = ( - 4337D7EA1C351B0B0016851F /* CommonCrypto.framework */, 43CABDF51C3506F100005705 /* xDripG5 */, 43CABE011C3506F100005705 /* xDripG5Tests */, 43CABDF41C3506F100005705 /* Products */, @@ -162,6 +158,8 @@ 43CABE111C350B2800005705 /* Transmitter.swift */, 43CE7CDB1CA77468003CC1B0 /* TransmitterStatus.swift */, 43CABE161C350B2E00005705 /* Messages */, + 43EEA70F1D14DC0800CBBDA0 /* AESCrypt.h */, + 43EEA7101D14DC0800CBBDA0 /* AESCrypt.m */, ); path = xDripG5; sourceTree = ""; @@ -215,6 +213,7 @@ buildActionMask = 2147483647; files = ( 43CABDF71C3506F100005705 /* xDripG5.h in Headers */, + 43EEA7111D14DC0800CBBDA0 /* AESCrypt.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -264,7 +263,7 @@ 43CABDEA1C3506F100005705 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 0720; + LastSwiftUpdateCheck = 0730; LastUpgradeCheck = 0720; ORGANIZATIONNAME = "Nathan Racklyeft"; TargetAttributes = { @@ -328,6 +327,7 @@ 43CABE2A1C350B3D00005705 /* GlucoseTxMessage.swift in Sources */, 43CE7CC81CA73AEB003CC1B0 /* FirmwareVersionTxMessage.swift in Sources */, 43CE7CCC1CA73BCC003CC1B0 /* BatteryStatusTxMessage.swift in Sources */, + 43EEA7121D14DC0800CBBDA0 /* AESCrypt.m in Sources */, 43CE7CCE1CA73C22003CC1B0 /* SessionStartTxMessage.swift in Sources */, 43CABE2E1C350B3D00005705 /* TransmitterTimeTxMessage.swift in Sources */, 43CABE2C1C350B3D00005705 /* TransmitterMessage.swift in Sources */, @@ -388,7 +388,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 11; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -436,7 +436,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 11; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -464,12 +464,8 @@ CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 10; + DYLIB_CURRENT_VERSION = 11; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INFOPLIST_FILE = xDripG5/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -486,12 +482,8 @@ CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 10; + DYLIB_CURRENT_VERSION = 11; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INFOPLIST_FILE = xDripG5/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; diff --git a/xDripG5/AESCrypt.h b/xDripG5/AESCrypt.h new file mode 100644 index 00000000..357420d6 --- /dev/null +++ b/xDripG5/AESCrypt.h @@ -0,0 +1,19 @@ +// +// AESCrypt.h +// xDripG5 +// +// Created by Nate Racklyeft on 6/17/16. +// Copyright © 2016 Nathan Racklyeft. All rights reserved. +// + +#import + +@interface AESCrypt : NSObject + +NS_ASSUME_NONNULL_BEGIN + ++ (nullable NSData *)encryptData:(NSData *)data usingKey:(NSData *)key error:(NSError **)error; + +NS_ASSUME_NONNULL_END + +@end diff --git a/xDripG5/AESCrypt.m b/xDripG5/AESCrypt.m new file mode 100644 index 00000000..1c3850b6 --- /dev/null +++ b/xDripG5/AESCrypt.m @@ -0,0 +1,33 @@ +// +// AESCrypt.m +// xDripG5 +// +// Created by Nate Racklyeft on 6/17/16. +// Copyright © 2016 Nathan Racklyeft. All rights reserved. +// + +#import "AESCrypt.h" +#import + +@implementation AESCrypt + ++ (NSData *)encryptData:(NSData *)data usingKey:(NSData *)key error:(NSError * _Nullable __autoreleasing *)error +{ + NSMutableData *dataOut = [[NSMutableData alloc] initWithCapacity:16]; + + CCCryptorStatus status = CCCrypt(kCCEncrypt, + kCCAlgorithmAES, + kCCOptionECBMode, + key.bytes, + key.length, + NULL, + data.bytes, + data.length, + dataOut.mutableBytes, + dataOut.length, + NULL); + + return status == kCCSuccess ? dataOut : nil; +} + +@end diff --git a/xDripG5/Info.plist b/xDripG5/Info.plist index 7c9f8bd3..288c341b 100644 --- a/xDripG5/Info.plist +++ b/xDripG5/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.4.2 + 0.5.0 CFBundleSignature ???? CFBundleVersion diff --git a/xDripG5/Transmitter.swift b/xDripG5/Transmitter.swift index f5642b3a..d1e020cc 100644 --- a/xDripG5/Transmitter.swift +++ b/xDripG5/Transmitter.swift @@ -284,31 +284,17 @@ public class Transmitter: BluetoothManagerDelegate { } private func calculateHash(data: NSData) -> NSData? { - guard data.length == 8, let key = cryptKey, outData = NSMutableData(length: 16) else { + guard data.length == 8, let key = cryptKey else { return nil } let doubleData = NSMutableData(data: data) doubleData.appendData(data) - let status = CCCrypt( - 0, // kCCEncrypt - 0, // kCCAlgorithmAES - 0x0002, // kCCOptionECBMode - key.bytes, - key.length, - nil, - doubleData.bytes, - doubleData.length, - outData.mutableBytes, - outData.length, - nil - ) - - if status != 0 { // kCCSuccess + guard let outData = try? AESCrypt.encryptData(doubleData, usingKey: key) else { return nil - } else { - return outData[0..<8] } + + return outData[0..<8] } } \ No newline at end of file diff --git a/xDripG5/xDripG5.h b/xDripG5/xDripG5.h index 1ac6a8b8..3b949160 100644 --- a/xDripG5/xDripG5.h +++ b/xDripG5/xDripG5.h @@ -7,7 +7,7 @@ // #import -@import CommonCrypto; +#import //! Project version number for xDripG5. FOUNDATION_EXPORT double xDripG5VersionNumber; diff --git a/xDripG5Tests/Info.plist b/xDripG5Tests/Info.plist index a6ae57f6..94b6ed95 100644 --- a/xDripG5Tests/Info.plist +++ b/xDripG5Tests/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 0.4.2 + 0.5.0 CFBundleSignature ???? CFBundleVersion