Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
a7b325d
Convert to swift 2.0
iosdevzone Sep 14, 2015
d816676
Add app target to verify on device. Travis to Xcode7
iosdevzone Sep 14, 2015
2a01b99
Update travis from ios 8 -> 9. Fix username in some comments.
iosdevzone Sep 14, 2015
e2c790e
Clean up warnings. Fix AES CBC 1 test.
iosdevzone Sep 15, 2015
b5f9e5b
Update to recommended build settings.
iosdevzone Sep 15, 2015
cffdecb
Update Random to use Swift 2.0 throw.
iosdevzone Sep 16, 2015
79a891c
Make API compatible with https://github.com/soffes/Crypto
iosdevzone Sep 16, 2015
ada1b67
Use Updateable to simplify Digest, HMAC and Cryptor.
iosdevzone Sep 16, 2015
b9aaf5b
Fix username in comments.
iosdevzone Sep 16, 2015
a70d008
Added Carthage label
iosdevzone Sep 17, 2015
ffbae2e
Added space README
iosdevzone Sep 17, 2015
7ae7336
Remove CommonCrypto module. Now done by run script
iosdevzone Sep 17, 2015
87ca790
Add run script phase to generate CommonCrypto module map.
iosdevzone Sep 17, 2015
a1bf40d
Reorder build phases.
iosdevzone Sep 17, 2015
5a32000
[CocoaPods] Fix typo and tags in podspec.
iosdevzone Sep 17, 2015
4847793
[CocoaPods] Typo in podspec.
iosdevzone Sep 17, 2015
274d00c
[CocoaPods] Another attempts to get podspec to lint
iosdevzone Sep 17, 2015
ac43ab6
[CocoaPods] Be more explicit about source file.
iosdevzone Sep 17, 2015
4f4d008
[CocoaPods] Another try.
iosdevzone Sep 17, 2015
1722e7f
[CocoaPods] Try just iOS.
iosdevzone Sep 17, 2015
9e308b7
[CocoaPods] Remove osx platform.
iosdevzone Sep 17, 2015
a03bd31
[CocoaPods] Specify iOS 9 deployment target.
iosdevzone Sep 17, 2015
d42e0ff
Remove uneeded layer of directories
iosdevzone Sep 17, 2015
47390c2
[CocoaPods] Add prepare_command to create CommonCrypto fake module.
iosdevzone Sep 18, 2015
e82f750
Add Makefile
iosdevzone Sep 18, 2015
06e95d3
[CocoaPods] Add prints to prepare_command
iosdevzone Sep 18, 2015
799e864
[CocoaPods] Use document here for prepare_command
iosdevzone Sep 18, 2015
b169946
Add SWIFT_INCLUDE_PATH flag.
iosdevzone Sep 18, 2015
9d48859
Ignore prepare_command.txt
iosdevzone Sep 18, 2015
ac4da19
[CocoaPods] Correct SWIFT_INCLUDE_PATHS (hopefully).
iosdevzone Sep 18, 2015
1073bd8
[CocoaPods] Try preserve_paths
iosdevzone Sep 18, 2015
57aa2ef
[CocoaPods] Correct (hopefully) SWIFT_INCLUDE_PATHS
iosdevzone Sep 18, 2015
2ea1d25
[Tavis] Add dummy all target to makefile.
iosdevzone Sep 18, 2015
6759329
Fix Makefile.
iosdevzone Sep 18, 2015
b9e2b4b
[playground] Update from swift-playground-builder
iosdevzone Sep 18, 2015
a771088
[Travis] Updated YAML for new dir structure
iosdevzone Sep 18, 2015
a92ec89
[Carthage/Xcode] First try at cerificates
iosdevzone Sep 18, 2015
38feced
[Travis] Fix cert script permissions.
iosdevzone Sep 18, 2015
0fb69da
[Travis] Fix paths.
iosdevzone Sep 18, 2015
4f0173c
[Travis] Add missing KEYCHAIN var.
iosdevzone Sep 18, 2015
f0a847a
[Travis] Probe issue with incorrect failures
iosdevzone Sep 18, 2015
1025991
[Travis] Move env section.
iosdevzone Sep 18, 2015
9fbf16b
Trying to find reason for travis failure.
iosdevzone Sep 18, 2015
75dc22b
[Travis] Remove newlines.
iosdevzone Sep 18, 2015
196fa5b
[Travis] comment out some YAML.
iosdevzone Sep 18, 2015
4b7c254
[Travis] Remove cert stuff.
iosdevzone Sep 18, 2015
e469529
[Travis] Move more stuff to Makefile.
iosdevzone Sep 18, 2015
9b3ed18
[Travis] More Makefile.
iosdevzone Sep 18, 2015
30cb96f
[Travis] Fix branch in travis label in README.
iosdevzone Sep 18, 2015
a2e41e5
Fix for issue #4. Also import instead of
iosdevzone Oct 29, 2015
8e3438c
Merge branch 'swift2.0' of https://github.com/iosdevzone/IDZSwiftComm…
iosdevzone Oct 29, 2015
f07b16c
Update for iOS 9.1
iosdevzone Oct 29, 2015
48eb46f
Update podspec for 0.6.1
iosdevzone Oct 29, 2015
86fa5d4
Fix some missing 9.0 references. Pod spec 0.6.2
iosdevzone Oct 29, 2015
23139e4
Get to 100% documenation
iosdevzone Oct 29, 2015
dd73f7b
Add docs back in.
iosdevzone Oct 29, 2015
0928a40
Improved docs
iosdevzone Oct 29, 2015
d08b1ef
Update travis build.
iosdevzone Oct 29, 2015
1f9f285
Added instructions for CocoaPods and Carthage.
iosdevzone Oct 29, 2015
fef6038
Update podspec.
iosdevzone Oct 29, 2015
18a8c50
Improved docs & tests. First attempt at coveralls.
iosdevzone Oct 29, 2015
9a84468
[coveralls/slather/travis] Install slather gem
iosdevzone Oct 29, 2015
76f8198
Updated coverage settings for slather.
iosdevzone Oct 29, 2015
33c8808
Try using custom slather with Swift support.
iosdevzone Nov 3, 2015
cab2909
Added more test cases for Digest and HMAC.
iosdevzone Nov 4, 2015
6e881a9
Added Coveralls badge.
iosdevzone Nov 4, 2015
8e458b6
Improve test coverage. Tweak test output.
iosdevzone Nov 4, 2015
9d1e968
Merge branch 'swift2.0' of https://github.com/iosdevzone/IDZSwiftComm…
iosdevzone Nov 4, 2015
62b1487
Resolve swift2.0 merge conflicts
iosdevzone Nov 4, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
service_name: travis-ci
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
prepate_command.txt
CommonCrypto
# Xcode
#
build/
Expand Down
3 changes: 3 additions & 0 deletions .slather.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ci_service: travis_ci
coverage_service: coveralls
xcodeproj: IDZSwiftCommonCrypto
25 changes: 14 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
language: objective-c

osx_image: xcode7.1
install:
- npm install -g swift-playground-builder
- npm install -g playground

env:
matrix:
secure: a2fi02GPkxw27jVjW47EkvB/BW/SOIxlmLQJaiZ3xqbKe4udUxKE0ZigD0nVJDmxpiVHv5/Uc9ZQDPtKvvmU9kakusxjBVqMy+IxCYsH4+aDaATdaY9WHvVbARXJGjE/KmKnTfos/P8G8XqXahNKznql/gF2wZNoQIQD49JNk8s=

before_install:
- bundle install

script:
# Generate README.playground from README.md
- echo Available SDKs
- xcodebuild -showsdks
- make
- git config --global push.default simple
- git diff-files --exit-code; if [[ "$?" == "1" ]]; then git commit -a -m "Playground update from Travis [ci skip]"; git push; fi
- pushd IDZSwiftCommonCrypto
- rm -rf CommonCrypto
- ./GenerateCommonCryptoModule iphonesimulator8.1 .
- ./GenerateCommonCryptoModule iphonesimulator9.0 .
- cat CommonCrypto/module.map
- pwd
- xcodebuild build -scheme IDZSwiftCommonCrypto -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1'
# Remove testing pending solution to https://github.com/travis-ci/travis-ci/issues/2829
- xcodebuild test -scheme IDZSwiftCommonCrypto -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1'
- popd
- xcodebuild build -scheme IDZSwiftCommonCrypto -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.0'
- make test

after_success: bundle exec slather coverage --input-format profdata IDZSwiftCommonCrypto.xcodeproj
Binary file removed .travis.yml.swp
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='3.0' sdk='iphonesimulator'>
<playground version='3.0' sdk='iphonesimulator' runInFullSimulator='YES'>
<sections>
<code source-file-name='section-1.swift'/>
</sections>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ import UIKit
import CommonCrypto
import IDZSwiftCommonCrypto

var ss = ""
var ss = "" as NSString
ss.stringByAppendingPathComponent("hello")


// MARK: - Message Digest Demo
let s = "The quick brown fox jumps over the lazy dog."
var md5 = Digest(algorithm: .MD5)
md5.update(s)
var digest = md5.final()
var md5String = hexStringFromArray(digest)

s.MD5

// MARK: - HMAC Demo
// Data from RFC 2202
var key = arrayFromHexString("0102030405060708090a0b0c0d0e0f10111213141516171819")
Expand All @@ -34,26 +35,41 @@ for (password, salt, rounds, dkLen, expected) in tests
}

// MARK: - Random Demo
var randomBytes = hexStringFromArray(Random.generateBytes(16))
var randomBytes = hexStringFromArray(try Random.generateBytes(16))

do {
try Random.generateBytesThrow(16)
}
catch let e {
print("generateBytesThrow threw \(e)")
}


do {
try Random.generateBytesThrow(16)
}
catch {
print("generateBytesThrow threw an error (expected).")
}


// MARK: - Crypto Demo
// Test data from NIST Special Publication
// F.1.1 p24
// http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
func test_StreamCryptor_AES_ECB() {
var key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c")
var plainText = arrayFromHexString("6bc1bee22e409f96e93d7e117393172a")
var expectedCipherText = arrayFromHexString("3ad77bb40d7a3660a89ecaf32466ef97")
let key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c")
let plainText = arrayFromHexString("6bc1bee22e409f96e93d7e117393172a")
let expectedCipherText = arrayFromHexString("3ad77bb40d7a3660a89ecaf32466ef97")

var aesEncrypt = StreamCryptor(operation:.Encrypt, algorithm:.AES, options:.ECBMode, key:key, iv:Array<UInt8>())
let aesEncrypt = StreamCryptor(operation:.Encrypt, algorithm:.AES, options:.ECBMode, key:key, iv:Array<UInt8>())
var cipherText : [UInt8] = []
var dataOut = Array<UInt8>(count:plainText.count, repeatedValue:UInt8(0))
var (byteCount, status) = aesEncrypt.update(plainText, byteArrayOut: &dataOut)
let (byteCount, status) = aesEncrypt.update(plainText, byteArrayOut: &dataOut)
dataOut
"\(status)"
status


var c = UIColor.redColor()


cipherText += dataOut[0..<Int(byteCount)]
//(byteCount, status) = aesEncrypt.final(&dataOut)
//assert(byteCount == 0, "Final byte count is 0")
Expand All @@ -64,11 +80,11 @@ func test_StreamCryptor_AES_ECB() {
test_StreamCryptor_AES_ECB()
// Single block ECB mode
func test_Cryptor_AES_ECB_1() {
var key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c")
var plainText = arrayFromHexString("6bc1bee22e409f96e93d7e117393172a")
var expectedCipherText = arrayFromHexString("3ad77bb40d7a3660a89ecaf32466ef97")
let key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c")
let plainText = arrayFromHexString("6bc1bee22e409f96e93d7e117393172a")
let expectedCipherText = arrayFromHexString("3ad77bb40d7a3660a89ecaf32466ef97")

var cipherText = Cryptor(operation:.Encrypt, algorithm:.AES, options:.ECBMode, key:key, iv:Array<UInt8>()).update(plainText)?.final()
let cipherText = Cryptor(operation:.Encrypt, algorithm:.AES, options:.ECBMode, key:key, iv:Array<UInt8>()).update(plainText)?.final()

assert(expectedCipherText.count == cipherText!.count , "Counts are as expected")
assert(expectedCipherText == cipherText!, "Obtained expected cipher text")
Expand All @@ -79,14 +95,14 @@ test_Cryptor_AES_ECB_1()
// Double repeated block ECB mode
// Shows weakness of ECB mode -- same plaintext block gets same ciphertext
func test_Cryptor_AES_ECB_2() {
var key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c")
let key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c")
var plainText = arrayFromHexString("6bc1bee22e409f96e93d7e117393172a")
var expectedCipherText = arrayFromHexString("3ad77bb40d7a3660a89ecaf32466ef97")

plainText += plainText
expectedCipherText += expectedCipherText

var cipherText = Cryptor(operation:.Encrypt, algorithm:.AES, options:.ECBMode, key:key, iv:Array<UInt8>()).update(plainText)?.final()
let cipherText = Cryptor(operation:.Encrypt, algorithm:.AES, options:.ECBMode, key:key, iv:Array<UInt8>()).update(plainText)?.final()

assert(expectedCipherText.count == cipherText!.count , "Counts are as expected")
assert(expectedCipherText == cipherText!, "Obtained expected cipher text")
Expand All @@ -99,27 +115,29 @@ test_Cryptor_AES_ECB_2()

// Single block ECB mode
func test_Cryptor_AES_ECB_Short() {
var key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c")
var plainText = arrayFromHexString("6bc1bee22e409f96e93d7e11739317")
var expectedCipherText = arrayFromHexString("3ad77bb40d7a3660a89ecaf32466ef97")
let key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c")
let plainText = arrayFromHexString("6bc1bee22e409f96e93d7e11739317")
let expectedCipherText = arrayFromHexString("3ad77bb40d7a3660a89ecaf32466ef97")

var cryptor = Cryptor(operation:.Encrypt, algorithm:.AES, options:.ECBMode, key:key, iv:Array<UInt8>())
var cipherText = cryptor.update(plainText)?.final()
let cryptor = Cryptor(operation:.Encrypt, algorithm:.AES, options:.ECBMode, key:key, iv:Array<UInt8>())
let cipherText = cryptor.update(plainText)?.final()
if(cipherText == nil)
{
println("Encryption failed (as expected) with status \(cryptor.status)")
print("Encryption failed (as expected) with status \(cryptor.status)")
}
}

test_Cryptor_AES_ECB_Short()

func test_Cryptor_AES_ECB_Short_Padding() {
var key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c")
var plainText = arrayFromHexString("6bc1bee22e409f96e93d7e11739317")
var expectedCipherText = arrayFromHexString("21ea2ba3e445a0ef710a7c26618d1975")
let key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c")
let plainText = arrayFromHexString("6bc1bee22e409f96e93d7e11739317")
let expectedCipherText = arrayFromHexString("21ea2ba3e445a0ef710a7c26618d1975")

var cryptor = Cryptor(operation:.Encrypt, algorithm:.AES, options:.ECBMode | .PKCS7Padding, key:key, iv:Array<UInt8>())
var cipherText = cryptor.update(plainText)?.final()
let cryptor = Cryptor(operation:.Encrypt,
algorithm:.AES,
options:[.ECBMode,.PKCS7Padding], key:key, iv:Array<UInt8>())
let cipherText = cryptor.update(plainText)?.final()
assert(cipherText != nil)
assert(cipherText! == expectedCipherText)
}
Expand All @@ -130,13 +148,13 @@ func test_Cryptor_AES_ECB_Short_Padding() {
//test_Cryptor_AES_CBC_1()

func test_Cryptor_AES_CBC_2() {
var key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c")
let key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c")
var plainText = arrayFromHexString("6bc1bee22e409f96e93d7e117393172a")
var expectedCipherText = arrayFromHexString("3ad77bb40d7a3660a89ecaf32466ef97025c61efee87e604cd1b12ce9dde5c51")
let expectedCipherText = arrayFromHexString("3ad77bb40d7a3660a89ecaf32466ef97025c61efee87e604cd1b12ce9dde5c51")

plainText += plainText

var optionalCipherText = Cryptor(operation:.Encrypt, algorithm:.AES, options:.None, key:key, iv:Array<UInt8>()).update(plainText)?.final()
let optionalCipherText = Cryptor(operation:.Encrypt, algorithm:.AES, options:.None, key:key, iv:Array<UInt8>()).update(plainText)?.final()
if let cipherText = optionalCipherText
{

Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Gemfile
source 'https://rubygems.org'
gem 'slather', :git => "https://github.com/mattdelves/slather.git", :branch => "feature-profdata"
44 changes: 44 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
GIT
remote: https://github.com/mattdelves/slather.git
revision: d09ce4f5d5928bebdd121f621f530f1751a6c2c9
branch: feature-profdata
specs:
slather (1.8.1)
clamp (~> 0.6)
nokogiri (~> 1.6.3)
xcodeproj (~> 0.27.2)

GEM
remote: https://rubygems.org/
specs:
activesupport (4.2.4)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
claide (0.9.1)
clamp (0.6.5)
colored (1.2)
i18n (0.7.0)
json (1.8.3)
mini_portile (0.6.2)
minitest (5.8.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
xcodeproj (0.27.2)
activesupport (>= 3)
claide (~> 0.9.1)
colored (~> 1.2)

PLATFORMS
ruby

DEPENDENCIES
slather!

BUNDLED WITH
1.10.6
Loading