Skip to content

Commit 1c6e0ad

Browse files
authored
Merge pull request #100 from iosdevzone/github-issue-99
Remove some obsoleted constants.
2 parents 4cd6ef4 + a46a530 commit 1c6e0ad

File tree

8 files changed

+41
-44
lines changed

8 files changed

+41
-44
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode10.1
2+
osx_image: xcode10.2
33
install:
44
- npm install -g playground
55

DemoPlayground.playground/Contents.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var md5String = hexString(fromArray: digest)
1717

1818
s.MD5
1919

20-
// MARK: - HMAC Demogit s
20+
// MARK: - HMAC Demo
2121
// Data from RFC 2202
2222
var key = arrayFrom(hexString: "0102030405060708090a0b0c0d0e0f10111213141516171819")
2323
var data : [UInt8] = Array(repeating:0xcd, count:50)

IDZSwiftCommonCrypto.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "IDZSwiftCommonCrypto"
4-
s.version = "0.12.1"
4+
s.version = "0.13.0"
55
s.summary = "A wrapper for Apple's Common Crypto library written in Swift."
66

77
s.homepage = "https://github.com/iosdevzone/IDZSwiftCommonCrypto"

IDZSwiftCommonCrypto/Status.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public enum Status : CCCryptorStatus, CustomStringConvertible, Error
7272
///
7373
public static func fromRaw(status: CCCryptorStatus) -> Status?
7474
{
75-
var from = [ kCCSuccess: success, kCCParamError: paramError,
75+
let from = [ kCCSuccess: success, kCCParamError: paramError,
7676
kCCBufferTooSmall: bufferTooSmall, kCCMemoryFailure: memoryFailure,
7777
kCCAlignmentError: alignmentError, kCCDecodeError: decodeError, kCCUnimplemented: unimplemented,
7878
kCCOverflow: overflow, kCCRNGFailure: rngFailure]

IDZSwiftCommonCrypto/StreamCryptor.swift

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -84,44 +84,38 @@ open class StreamCryptor
8484
///
8585
/// Enumerates encryption mode
8686
///
87-
public enum Mode
88-
{
87+
public enum Mode
88+
{
8989
/// Electronic Code Book
90-
case ECB
90+
case ECB
9191
/// Cipher Block Chaining
92-
case CBC
92+
case CBC
9393
/// Cipher FeeBack
94-
case CFB
94+
case CFB
9595
/// Counter
96-
case CTR
97-
/// Unimplemented for now (not included)
98-
case F8 // = 5, // Unimplemented for now (not included)
99-
/// Unimplemented for now (not included)
100-
case LRW// = 6, // Unimplemented for now (not included)
96+
case CTR
10197
/// Output FeedBack
102-
case OFB
103-
/// Xor-encode-xor Tweaked with ciphertext Stealing
104-
case XTS
98+
case OFB
10599
/// RC4 streaming
106-
case RC4
100+
case RC4
107101
/// Cipher FeebBack with 8-bit shifts
108-
case CFB8
109-
110-
func nativeValue() -> CCMode {
111-
switch self {
112-
case .ECB : return CCMode(kCCModeECB)
113-
case .CBC : return CCMode(kCCModeCBC)
114-
case .CFB : return CCMode(kCCModeCFB)
115-
case .CTR : return CCMode(kCCModeCTR)
116-
case .F8 : return CCMode(kCCModeF8)// Unimplemented for now (not included)
117-
case .LRW : return CCMode(kCCModeLRW)// Unimplemented for now (not included)
118-
case .OFB : return CCMode(kCCModeOFB)
119-
case .XTS : return CCMode(kCCModeXTS)
120-
case .RC4 : return CCMode(kCCModeRC4)
121-
case .CFB8 : return CCMode(kCCModeCFB8)
122-
}
123-
}
102+
case CFB8
103+
124104

105+
/// Obtain the native value for a Mode.
106+
func nativeValue() -> CCMode {
107+
switch self {
108+
case .ECB : return CCMode(kCCModeECB)
109+
case .CBC : return CCMode(kCCModeCBC)
110+
case .CFB : return CCMode(kCCModeCFB)
111+
case .CTR : return CCMode(kCCModeCTR)
112+
case .OFB : return CCMode(kCCModeOFB)
113+
case .RC4 : return CCMode(kCCModeRC4)
114+
case .CFB8 : return CCMode(kCCModeCFB8)
115+
}
116+
}
117+
118+
/// Returns true if this `Mode` requires an initialization vector.
125119
func requiresInitializationVector() -> Bool {
126120
switch self {
127121
case .ECB:
@@ -130,7 +124,7 @@ open class StreamCryptor
130124
return true;
131125
}
132126
}
133-
}
127+
}
134128

135129
/**
136130
Enumerated encryption paddings

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Which version you use depends on which version of Xcode and Swift you are curren
2727
* 0.10.x -- Xcode 9.0, Swift 4.0
2828
* 0.11.x -- Xcode 10.0, Swift 4.2
2929
* 0.12.x -- Xcode 10.2, Swift 5.0
30+
* 0.13.x -- Xcode 11.0, Swift 5.1, iOS 13.0
3031

3132
Using `Digest`
3233
--------------

README.playground/Contents.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import IDZSwiftCommonCrypto
2020
Using `Digest`
2121
--------------
2222

23+
* Note: The code below uses MD5 for demonstration purposes because it generates short digests, however, it is considered cryptographically broken and new code should use at least SHA256.
24+
2325
To calculate a message digest you create an instance of `Digest`, call `update` one or more times with the data over which the digest is being calculated and finally call `final` to obtain the digest itself.
2426

2527
The `update` method can take a `String`
@@ -63,11 +65,11 @@ var digests4 = Digest(algorithm: .md5).update(s)?.final() // digest is of type [
6365
### Supported Algorithms
6466
The `Digest` class supports the following algorithms:
6567

66-
* `.md2`
67-
* `.md4`
68-
* `.md5`
69-
* `.sha1`
70-
* `.sha224`
68+
* `.md2` -- insecure and should not be used in new code.
69+
* `.md4` -- insecure and should not be used in new code.
70+
* `.md5` -- insecure and should not be used in new code.
71+
* `.sha1` -- insecure and should not be used in new code.
72+
* `.sha224` -- insecure and should not be used in new code.
7173
* `.sha256`
7274
* `.sha384`
7375
* `.sha512`
@@ -89,9 +91,9 @@ assert(hmacs5! == expectedRFC2202)
8991
/*:
9092

9193
### Supported Algorithms
92-
* `.md5`
93-
* `.sha1`
94-
* `.sha224`
94+
* `.md5` -- insecure and should not be used in new code.
95+
* `.sha1` -- insecure and should not be used in new code.
96+
* `.sha224` -- insecure and should not be used in new code.
9597
* `.sha256`
9698
* `.sha384`
9799
* `.sha512`
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<playground version='6.0' target-platform='macos' allows-reset='true' display-mode='raw'/>
2+
<playground version='6.0' target-platform='macos' allows-reset='true' display-mode='rendered'/>

0 commit comments

Comments
 (0)