Skip to content

Commit 265bd21

Browse files
author
Bill Abt
committed
Updated to latest (7/25) toolchain.
1 parent f0583fd commit 265bd21

File tree

11 files changed

+68
-66
lines changed

11 files changed

+68
-66
lines changed

Cryptor.xcodeproj/project.pbxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898
isa = PBXGroup;
9999
children = (
100100
8CD16C6C1CC81DE5007296B5 /* LICENSE */,
101-
8CD16C6D1CC81DE5007296B5 /* README.md */,
102101
__PBXFileRef_Package.swift /* Package.swift */,
102+
8CD16C6D1CC81DE5007296B5 /* README.md */,
103103
"_____Sources_" /* Sources */,
104104
8C9590261CC807EA00A2C2B4 /* Tests */,
105105
Dependencies_ /* Dependencies */,
@@ -429,6 +429,7 @@
429429
GCC_WARN_UNINITIALIZED_AUTOS = YES;
430430
GCC_WARN_UNUSED_FUNCTION = YES;
431431
GCC_WARN_UNUSED_VARIABLE = YES;
432+
SWIFT_VERSION = 3.0;
432433
};
433434
name = Release;
434435
};
@@ -452,6 +453,7 @@
452453
GCC_WARN_UNUSED_FUNCTION = YES;
453454
GCC_WARN_UNUSED_VARIABLE = YES;
454455
ONLY_ACTIVE_ARCH = YES;
456+
SWIFT_VERSION = 3.0;
455457
};
456458
name = Debug;
457459
};

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ This package is functionally complete and has all current relevant tests passing
1111
## Prerequisites
1212

1313
### Swift
14-
* Swift Open Source `swift-DEVELOPMENT-SNAPSHOT-2016-06-20-a` toolchain (**Minimum REQUIRED for latest release**)
14+
* Swift Open Source `swift-DEVELOPMENT-SNAPSHOT-2016-07-25-a` toolchain (**Minimum REQUIRED for latest release**)
1515

1616
### macOS
1717

18-
* macOS 10.11.0 (*El Capitan*) or higher
19-
* Xcode Version 8.0 beta (8S128d) or higher using the above toolchain (*Recommended*)
18+
* macOS 10.11.6 (*El Capitan*) or higher
19+
* Xcode Version 8.0 beta 3 (8S174q) or higher using the above toolchain (*Recommended*)
2020

2121
### Linux
2222

Sources/Crypto.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ extension CryptoDigest {
7575
///
7676
/// Extension for Data to return an Data object containing the digest.
7777
///
78-
#if os(OSX)
78+
#if os(macOS)
7979

8080
extension Data: CryptoDigest {
8181
///

Sources/Digest.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import Foundation
1919

20-
#if os(OSX)
20+
#if os(macOS)
2121
import CommonCrypto
2222
#elseif os(Linux)
2323
import OpenSSL
@@ -87,56 +87,56 @@ public class Digest : Updateable {
8787
switch algorithm {
8888

8989
case .md2:
90-
#if os(OSX)
90+
#if os(macOS)
9191
engine = DigestEngineCC<CC_MD2_CTX>(initializer:CC_MD2_Init, updater:CC_MD2_Update, finalizer:CC_MD2_Final, length:CC_MD2_DIGEST_LENGTH)
9292
#elseif os(Linux)
9393
fatalError("MD2 digest not supported by OpenSSL")
9494
#endif
9595

9696
case .md4:
97-
#if os(OSX)
97+
#if os(macOS)
9898
engine = DigestEngineCC<CC_MD4_CTX>(initializer:CC_MD4_Init, updater:CC_MD4_Update, finalizer:CC_MD4_Final, length:CC_MD4_DIGEST_LENGTH)
9999
#elseif os(Linux)
100100
engine = DigestEngineCC<MD4_CTX>(initializer:MD4_Init, updater:MD4_Update, finalizer:MD4_Final, length:MD4_DIGEST_LENGTH)
101101
#endif
102102

103103
case .md5:
104-
#if os(OSX)
104+
#if os(macOS)
105105
engine = DigestEngineCC<CC_MD5_CTX>(initializer:CC_MD5_Init, updater:CC_MD5_Update, finalizer:CC_MD5_Final, length:CC_MD5_DIGEST_LENGTH)
106106
#elseif os(Linux)
107107
engine = DigestEngineCC<MD5_CTX>(initializer:MD5_Init, updater:MD5_Update, finalizer:MD5_Final, length:MD5_DIGEST_LENGTH)
108108
#endif
109109

110110
case .sha1:
111-
#if os(OSX)
111+
#if os(macOS)
112112
engine = DigestEngineCC<CC_SHA1_CTX>(initializer:CC_SHA1_Init, updater:CC_SHA1_Update, finalizer:CC_SHA1_Final, length:CC_SHA1_DIGEST_LENGTH)
113113
#elseif os(Linux)
114114
fatalError("SHA1 digest not supported by OpenSSL")
115115
#endif
116116

117117
case .sha224:
118-
#if os(OSX)
118+
#if os(macOS)
119119
engine = DigestEngineCC<CC_SHA256_CTX>(initializer:CC_SHA224_Init, updater:CC_SHA224_Update, finalizer:CC_SHA224_Final, length:CC_SHA224_DIGEST_LENGTH)
120120
#elseif os(Linux)
121121
engine = DigestEngineCC<SHA256_CTX>(initializer:SHA224_Init, updater:SHA224_Update, finalizer:SHA224_Final, length:SHA224_DIGEST_LENGTH)
122122
#endif
123123

124124
case .sha256:
125-
#if os(OSX)
125+
#if os(macOS)
126126
engine = DigestEngineCC<CC_SHA256_CTX>(initializer:CC_SHA256_Init, updater:CC_SHA256_Update, finalizer:CC_SHA256_Final, length:CC_SHA256_DIGEST_LENGTH)
127127
#elseif os(Linux)
128128
engine = DigestEngineCC<SHA256_CTX>(initializer: SHA256_Init, updater:SHA256_Update, finalizer:SHA256_Final, length:SHA256_DIGEST_LENGTH)
129129
#endif
130130

131131
case .sha384:
132-
#if os(OSX)
132+
#if os(macOS)
133133
engine = DigestEngineCC<CC_SHA512_CTX>(initializer:CC_SHA384_Init, updater:CC_SHA384_Update, finalizer:CC_SHA384_Final, length:CC_SHA384_DIGEST_LENGTH)
134134
#elseif os(Linux)
135135
engine = DigestEngineCC<SHA512_CTX>(initializer:SHA384_Init, updater:SHA384_Update, finalizer:SHA384_Final, length:SHA384_DIGEST_LENGTH)
136136
#endif
137137

138138
case .sha512:
139-
#if os(OSX)
139+
#if os(macOS)
140140
engine = DigestEngineCC<CC_SHA512_CTX>(initializer:CC_SHA512_Init, updater:CC_SHA512_Update, finalizer:CC_SHA512_Final, length:CC_SHA512_DIGEST_LENGTH)
141141
#elseif os(Linux)
142142
engine = DigestEngineCC<SHA512_CTX>(initializer:SHA512_Init, updater:SHA512_Update, finalizer:SHA512_Final, length:SHA512_DIGEST_LENGTH)
@@ -211,7 +211,7 @@ private class DigestEngineCC<CTX>: DigestEngine {
211211
typealias Updater = (Context, Buffer, CC_LONG) -> (Int32)
212212
typealias Finalizer = (Digest, Context) -> (Int32)
213213

214-
let context = Context(allocatingCapacity: 1)
214+
let context = Context.allocate(capacity: 1)
215215
var initializer : Initializer
216216
var updater : Updater
217217
var finalizer : Finalizer
@@ -240,7 +240,7 @@ private class DigestEngineCC<CTX>: DigestEngine {
240240
///
241241
deinit {
242242

243-
context.deallocateCapacity(1)
243+
context.deallocate(capacity: 1)
244244
}
245245

246246
///

Sources/HMAC.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import Foundation
1919

20-
#if os(OSX)
20+
#if os(macOS)
2121
import CommonCrypto
2222
#elseif os(Linux)
2323
import OpenSSL
@@ -51,7 +51,7 @@ public class HMAC : Updateable {
5151
/// Secure Hash Algorithm 2 512-bit
5252
case sha512
5353

54-
#if os(OSX)
54+
#if os(macOS)
5555

5656
static let fromNative: [CCHmacAlgorithm: Algorithm] = [
5757
CCHmacAlgorithm(kCCHmacAlgSHA1):.sha1,
@@ -113,7 +113,7 @@ public class HMAC : Updateable {
113113
///
114114
public func digestLength() -> Int {
115115

116-
#if os(OSX)
116+
#if os(macOS)
117117

118118
switch self {
119119

@@ -155,7 +155,7 @@ public class HMAC : Updateable {
155155
}
156156

157157
/// Context
158-
#if os(OSX)
158+
#if os(macOS)
159159

160160
typealias Context = UnsafeMutablePointer<CCHmacContext>
161161

@@ -169,7 +169,7 @@ public class HMAC : Updateable {
169169
public internal(set) var status: Status = .success
170170

171171

172-
private let context = Context(allocatingCapacity: 1)
172+
private let context = Context.allocate(capacity: 1)
173173
private var algorithm: Algorithm
174174

175175
// MARK: Lifecycle Methods
@@ -185,7 +185,7 @@ public class HMAC : Updateable {
185185
init(using algorithm: Algorithm, keyBuffer: UnsafePointer<Void>, keyByteCount: Int) {
186186

187187
self.algorithm = algorithm
188-
#if os(OSX)
188+
#if os(macOS)
189189
CCHmacInit(context, algorithm.nativeValue(), keyBuffer, size_t(keyByteCount))
190190
#elseif os(Linux)
191191
HMAC_Init(context, keyBuffer, Int32(keyByteCount), algorithm.nativeValue())
@@ -202,7 +202,7 @@ public class HMAC : Updateable {
202202
public init(using algorithm: Algorithm, key: NSData) {
203203

204204
self.algorithm = algorithm
205-
#if os(OSX)
205+
#if os(macOS)
206206
CCHmacInit(context, algorithm.nativeValue(), key.bytes, size_t(key.length))
207207
#elseif os(Linux)
208208
HMAC_Init(context, key.bytes, Int32(key.length), algorithm.nativeValue())
@@ -219,7 +219,7 @@ public class HMAC : Updateable {
219219
public init(using algorithm: Algorithm, key: [UInt8]) {
220220

221221
self.algorithm = algorithm
222-
#if os(OSX)
222+
#if os(macOS)
223223
CCHmacInit(context, algorithm.nativeValue(), key, size_t(key.count))
224224
#elseif os(Linux)
225225
HMAC_Init(context, key, Int32(key.count), algorithm.nativeValue())
@@ -237,7 +237,7 @@ public class HMAC : Updateable {
237237
public init(using algorithm: Algorithm, key: String) {
238238

239239
self.algorithm = algorithm
240-
#if os(OSX)
240+
#if os(macOS)
241241
CCHmacInit(context, algorithm.nativeValue(), key, size_t(key.lengthOfBytes(using: String.Encoding.utf8)))
242242
#elseif os(Linux)
243243
HMAC_Init(context, key, Int32(key.utf8.count), algorithm.nativeValue())
@@ -248,7 +248,7 @@ public class HMAC : Updateable {
248248
/// Cleanup
249249
///
250250
deinit {
251-
context.deallocateCapacity(1)
251+
context.deallocate(capacity: 1)
252252
}
253253

254254
// MARK: Public Methods
@@ -262,7 +262,7 @@ public class HMAC : Updateable {
262262
///
263263
public func update(from buffer: UnsafePointer<Void>, byteCount: size_t) -> Self? {
264264

265-
#if os(OSX)
265+
#if os(macOS)
266266
CCHmacUpdate(context, buffer, byteCount)
267267
#elseif os(Linux)
268268
HMAC_Update(context, UnsafePointer<UInt8>(buffer), byteCount)
@@ -278,7 +278,7 @@ public class HMAC : Updateable {
278278
public func final() -> [UInt8] {
279279

280280
var hmac = Array<UInt8>(repeating: 0, count:algorithm.digestLength())
281-
#if os(OSX)
281+
#if os(macOS)
282282
CCHmacFinal(context, &hmac)
283283
#elseif os(Linux)
284284
var length: UInt32 = 0

Sources/KeyDerivation.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import Foundation
1919

20-
#if os(OSX)
20+
#if os(macOS)
2121
import CommonCrypto
2222
#elseif os(Linux)
2323
import OpenSSL
@@ -46,7 +46,7 @@ public class PBKDF {
4646
/// Secure Hash Algorithm 2 512-bit
4747
case sha512
4848

49-
#if os(OSX)
49+
#if os(macOS)
5050
/// Return the OS native value
5151
func nativeValue() -> CCPseudoRandomAlgorithm {
5252

@@ -102,7 +102,7 @@ public class PBKDF {
102102
///
103103
public class func calibrate(passwordLength: Int, saltLength: Int, algorithm: PseudoRandomAlgorithm, derivedKeyLength: Int, msec : UInt32) -> UInt {
104104

105-
#if os(OSX)
105+
#if os(macOS)
106106
return UInt(CCCalibratePBKDF(CCPBKDFAlgorithm(kCCPBKDF2), passwordLength, saltLength, algorithm.nativeValue(), derivedKeyLength, msec))
107107
#elseif os(Linux)
108108
// Value as per RFC 2898.
@@ -126,7 +126,7 @@ public class PBKDF {
126126
public class func deriveKey(fromPassword password: String, salt: String, prf: PseudoRandomAlgorithm, rounds: uint, derivedKeyLength: UInt) -> [UInt8] {
127127

128128
var derivedKey = Array<UInt8>(repeating: 0, count:Int(derivedKeyLength))
129-
#if os(OSX)
129+
#if os(macOS)
130130
let status: Int32 = CCKeyDerivationPBKDF(CCPBKDFAlgorithm(kCCPBKDF2), password, password.utf8.count, salt, salt.utf8.count, prf.nativeValue(), rounds, &derivedKey, derivedKey.count)
131131
if status != Int32(kCCSuccess) {
132132

@@ -157,7 +157,7 @@ public class PBKDF {
157157
public class func deriveKey(fromPassword password: String, salt: [UInt8], prf: PseudoRandomAlgorithm, rounds: uint, derivedKeyLength: UInt) -> [UInt8] {
158158

159159
var derivedKey = Array<UInt8>(repeating: 0, count:Int(derivedKeyLength))
160-
#if os(OSX)
160+
#if os(macOS)
161161
let status: Int32 = CCKeyDerivationPBKDF(CCPBKDFAlgorithm(kCCPBKDF2), password, password.utf8.count, salt, salt.count, prf.nativeValue(), rounds, &derivedKey, derivedKey.count)
162162
if status != Int32(kCCSuccess) {
163163

@@ -190,7 +190,7 @@ public class PBKDF {
190190
///
191191
public class func deriveKey(fromPassword password: UnsafePointer<Int8>, passwordLen: Int, salt: UnsafePointer<UInt8>, saltLen: Int, prf: PseudoRandomAlgorithm, rounds: uint, derivedKey: UnsafeMutablePointer<UInt8>, derivedKeyLen: Int) {
192192

193-
#if os(OSX)
193+
#if os(macOS)
194194
let status: Int32 = CCKeyDerivationPBKDF(CCPBKDFAlgorithm(kCCPBKDF2), password, passwordLen, salt, saltLen, prf.nativeValue(), rounds, derivedKey, derivedKeyLen)
195195
if status != Int32(kCCSuccess) {
196196

@@ -204,4 +204,4 @@ public class PBKDF {
204204
}
205205
#endif
206206
}
207-
}
207+
}

Sources/Random.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import Foundation
1919

20-
#if os(OSX)
20+
#if os(macOS)
2121
import CommonCrypto
2222
#elseif os(Linux)
2323
import OpenSSL
@@ -41,7 +41,7 @@ public class Random {
4141
///
4242
public class func generate(bytes: UnsafeMutablePointer<UInt8>, byteCount: Int ) -> RNGStatus {
4343

44-
#if os(OSX)
44+
#if os(macOS)
4545
let statusCode = CCRandomGenerateBytes(bytes, byteCount)
4646
guard let status = Status(rawValue: statusCode) else {
4747
fatalError("CCRandomGenerateBytes returned unexpected status code: \(statusCode)")
@@ -103,4 +103,4 @@ public class Random {
103103
throw status
104104
//return bytes
105105
}
106-
}
106+
}

Sources/Status.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717

1818
import Foundation
1919

20-
#if os(OSX)
20+
#if os(macOS)
2121
import CommonCrypto
2222
#elseif os(Linux)
2323
import OpenSSL
2424
#endif
2525

26-
#if os(OSX)
26+
#if os(macOS)
2727
///
2828
/// Links the native CommonCryptoStatus enumeration to Swift versions.
2929
///
30-
public enum Status: CCCryptorStatus, ErrorProtocol, CustomStringConvertible {
30+
public enum Status: CCCryptorStatus, Error, CustomStringConvertible {
3131

3232
/// successful
3333
case success
@@ -129,7 +129,7 @@ public enum Status: CCCryptorStatus, ErrorProtocol, CustomStringConvertible {
129129
///
130130
/// Error status
131131
///
132-
public enum Status: ErrorProtocol, CustomStringConvertible {
132+
public enum Status: Error, CustomStringConvertible {
133133

134134
/// success
135135
case success

0 commit comments

Comments
 (0)