Skip to content

Commit

Permalink
updating Turnstile + TurnstileCrypto to 8-18
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Jiang committed Aug 23, 2016
1 parent fb545e6 commit c2d6092
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DEVELOPMENT-SNAPSHOT-2016-07-25-a
DEVELOPMENT-SNAPSHOT-2016-08-18-a
2 changes: 1 addition & 1 deletion Sources/Turnstile/Core/Subject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Subject {
public func login(credentials: Credentials, persist: Bool = false) throws {
let account = try turnstile.realm.authenticate(credentials: credentials)
let sessionID: String? = persist ? turnstile.sessionManager.createSession(user: self) : nil
let credentialType = credentials.dynamicType
let credentialType = type(of: credentials)

authDetails = AuthenticationDetails(account: account, sessionID: sessionID, credentialType: credentialType)
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Turnstile/Realm/MemoryRealm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public class MemoryRealm: Realm {
/**
Account object representing an account in the MemoryRealm.
*/
private struct MemoryAccount: Account {
private var accountID: String
private let realm: Realm.Type = MemoryRealm.self
fileprivate struct MemoryAccount: Account {
fileprivate var accountID: String
fileprivate let realm: Realm.Type = MemoryRealm.self

private init(id: String) {
fileprivate init(id: String) {
accountID = id
}
}
12 changes: 6 additions & 6 deletions Sources/TurnstileCrypto/BCrypt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,11 @@ public class BCrypt {
private func initKey() {
// p = P_orig
p = UnsafeMutablePointer<Int32>.allocate(capacity: BCrypt.P_orig.count)
p.initialize(from: UnsafeMutablePointer<Int32>(BCrypt.P_orig), count: BCrypt.P_orig.count)
p.initialize(from: UnsafeMutableRawPointer(mutating: BCrypt.P_orig).assumingMemoryBound(to: Int32.self), count: BCrypt.P_orig.count)

// s = S_orig
s = UnsafeMutablePointer<Int32>.allocate(capacity: BCrypt.S_orig.count)
s.initialize(from: UnsafeMutablePointer<Int32>(BCrypt.S_orig), count: BCrypt.S_orig.count)
s.initialize(from: UnsafeMutableRawPointer(mutating: BCrypt.S_orig).assumingMemoryBound(to: Int32.self), count: BCrypt.S_orig.count)
}

private func deinitKey() {
Expand All @@ -478,7 +478,7 @@ public class BCrypt {
let plen : Int = 18
let slen : Int = 1024

let keyPointer : UnsafeMutablePointer<Int8> = UnsafeMutablePointer<Int8>(key)
let keyPointer : UnsafeMutablePointer<Int8> = UnsafeMutablePointer<Int8>(mutating: key)
let keyLength : Int = key.count

for i in 0..<plen {
Expand Down Expand Up @@ -512,9 +512,9 @@ public class BCrypt {



let keyPointer: UnsafeMutablePointer<Int8> = UnsafeMutablePointer<Int8>(key)
let keyPointer: UnsafeMutablePointer<Int8> = UnsafeMutablePointer<Int8>(mutating: key)
let keyLength: Int = key.count
let dataPointer: UnsafeMutablePointer<Int8> = UnsafeMutablePointer<Int8>(data)
let dataPointer: UnsafeMutablePointer<Int8> = UnsafeMutablePointer<Int8>(mutating: data)
let dataLength: Int = data.count

for i in 0..<plen {
Expand Down Expand Up @@ -561,7 +561,7 @@ public struct BCryptSalt {
public let data: [UInt8]

// temp for while old code is still Int8
private var dataInt8: [Int8] {
fileprivate var dataInt8: [Int8] {
return data.map({Int8(bitPattern: $0)})
}

Expand Down
14 changes: 5 additions & 9 deletions Sources/TurnstileCrypto/URandom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public class URandom: Random {
/// Get a random int16
public var int16: Int16 {
let bytes = read(numBytes: 2)
let pointer = UnsafeMutablePointer<Int16>(bytes)
return pointer.pointee
return UnsafeMutableRawPointer(mutating: bytes).assumingMemoryBound(to: Int16.self).pointee
}

/// Get a random uint16
Expand All @@ -67,8 +66,7 @@ public class URandom: Random {
/// Get a random int32
public var int32: Int32 {
let bytes = read(numBytes: 4)
let pointer = UnsafeMutablePointer<Int32>(bytes)
return pointer.pointee
return UnsafeMutableRawPointer(mutating: bytes).assumingMemoryBound(to: Int32.self).pointee
}

/// Get a random uint32
Expand All @@ -79,8 +77,7 @@ public class URandom: Random {
/// Get a random int64
public var int64: Int64 {
let bytes = read(numBytes: 8)
let pointer = UnsafeMutablePointer<Int64>(bytes)
return pointer.pointee
return UnsafeMutableRawPointer(mutating: bytes).assumingMemoryBound(to: Int64.self).pointee
}

/// Get a random uint64
Expand All @@ -90,9 +87,8 @@ public class URandom: Random {

/// Get a random int
public var int: Int {
let bytes = read(numBytes: sizeof(Int.self))
let pointer = UnsafeMutablePointer<Int>(bytes)
return pointer.pointee
let bytes = read(numBytes: MemoryLayout<Int>.size)
return UnsafeMutableRawPointer(mutating: bytes).assumingMemoryBound(to: Int.self).pointee
}

/// Get a random uint
Expand Down
6 changes: 3 additions & 3 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import XCTest
@testable import TurnstileTestSuite
@testable import TurnstileCryptoTestSuite
@testable import TurnstileWebTestSuite
@testable import TurnstileTests
@testable import TurnstileCryptoTests
@testable import TurnstileWebTests

XCTMain([
testCase(SubjectTests.allTests),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c2d6092

Please sign in to comment.