lint fixes
This commit is contained in:
parent
8427ddbb2e
commit
4703e6061f
|
@ -5,6 +5,7 @@
|
|||
## Build generated
|
||||
build/
|
||||
DerivedData/
|
||||
Keycard.xcodeproj
|
||||
|
||||
## Various settings
|
||||
*.pbxuser
|
||||
|
|
|
@ -9,5 +9,5 @@ file_name:
|
|||
- Package.swift
|
||||
identifier_name:
|
||||
excluded:
|
||||
- id
|
||||
- to
|
||||
- p1
|
||||
- p2
|
||||
|
|
|
@ -10,12 +10,12 @@ struct APDUCommand {
|
|||
let needsLE: Bool
|
||||
|
||||
init(cla: UInt8, ins: UInt8, p1: UInt8, p2: UInt8, data: [UInt8] = [], needsLE: Bool = false) {
|
||||
self.cla = cla;
|
||||
self.ins = ins;
|
||||
self.p1 = p1;
|
||||
self.p2 = p2;
|
||||
self.data = data;
|
||||
self.needsLE = needsLE;
|
||||
self.cla = cla
|
||||
self.ins = ins
|
||||
self.p1 = p1
|
||||
self.p2 = p2
|
||||
self.data = data
|
||||
self.needsLE = needsLE
|
||||
}
|
||||
|
||||
func serialize() -> [UInt8] {
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
* ISO7816-4 R-APDU.
|
||||
*/
|
||||
struct APDUResponse {
|
||||
let data : [UInt8]
|
||||
let sw1 : UInt8
|
||||
let sw2 : UInt8
|
||||
let data: [UInt8]
|
||||
let sw1: UInt8
|
||||
let sw2: UInt8
|
||||
|
||||
var sw : UInt16 {
|
||||
var sw: UInt16 {
|
||||
get {
|
||||
(UInt16(self.sw1) << 8) | UInt16(self.sw2)
|
||||
return (UInt16(self.sw1) << 8) | UInt16(self.sw2)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ struct APDUResponse {
|
|||
}
|
||||
|
||||
func checkSW(_ codes: StatusWord...) throws -> APDUResponse {
|
||||
try checkSW(codes: codes.map({$0.rawValue}))
|
||||
try checkSW(codes: codes.map({ $0.rawValue }))
|
||||
}
|
||||
|
||||
func checkSW(_ codes: UInt16...) throws -> APDUResponse {
|
||||
|
|
|
@ -16,13 +16,37 @@ enum AppCapability: UInt8 {
|
|||
|
||||
struct ApplicationInfo {
|
||||
let instanceUID: [UInt8]
|
||||
let freePairingSlots : Int
|
||||
let appVersion : UInt16
|
||||
let freePairingSlots: Int
|
||||
let appVersion: UInt16
|
||||
let keyUID: [UInt8]
|
||||
let secureChannelPubKey: [UInt8]
|
||||
let initializedCard: Bool
|
||||
let capabilities: UInt8
|
||||
|
||||
var appVersionString: String {
|
||||
return "\(appVersion >> 8).\(appVersion & 0xff)"
|
||||
}
|
||||
|
||||
var hasMasterKey: Bool {
|
||||
return keyUID.count > 0
|
||||
}
|
||||
|
||||
var hasSecureChannelCapability: Bool {
|
||||
return (capabilities & AppCapability.secureChannel.rawValue) != 0
|
||||
}
|
||||
|
||||
var hasKeyManagementCapability: Bool {
|
||||
return (capabilities & AppCapability.keyManagement.rawValue) != 0
|
||||
}
|
||||
|
||||
var hasCredentialsManagementCapability: Bool {
|
||||
return (capabilities & AppCapability.credentialsManagement.rawValue) != 0
|
||||
}
|
||||
|
||||
var hasNDEFCapability: Bool {
|
||||
return (capabilities & AppCapability.ndef.rawValue) != 0
|
||||
}
|
||||
|
||||
init(_ data: [UInt8]) throws {
|
||||
let tlv = TinyBERTLV(data)
|
||||
let topTag = try tlv.readTag()
|
||||
|
@ -61,11 +85,4 @@ struct ApplicationInfo {
|
|||
|
||||
initializedCard = true
|
||||
}
|
||||
|
||||
var appVersionString: String { get { "\(appVersion >> 8).\(appVersion & 0xff)" } }
|
||||
var hasMasterKey: Bool { get { keyUID.count > 0 } }
|
||||
var hasSecureChannelCapability: Bool { get { (capabilities & AppCapability.secureChannel.rawValue) != 0 } }
|
||||
var hasKeyManagementCapability: Bool { get { (capabilities & AppCapability.keyManagement.rawValue) != 0 } }
|
||||
var hasCredentialsManagementCapability: Bool { get { (capabilities & AppCapability.credentialsManagement.rawValue) != 0 } }
|
||||
var hasNDEFCapability: Bool { get { (capabilities & AppCapability.ndef.rawValue) != 0 } }
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ protocol CardChannel {
|
|||
|
||||
extension CardChannel {
|
||||
var pairingPasswordPBKDF2IterationCount: Int {
|
||||
get {
|
||||
return 50000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
enum CardError : Error {
|
||||
enum CardError: Error {
|
||||
case wrongPIN(retryCounter: Int)
|
||||
}
|
||||
|
|
|
@ -92,14 +92,12 @@ enum Identifier: String {
|
|||
case keycardCashAID = "A000000804000103"
|
||||
case keycardCashInstanceAID = "A00000080400010301"
|
||||
|
||||
var val: [UInt8] {
|
||||
return rawValue.hexToBytes
|
||||
}
|
||||
|
||||
static func getKeycardInstanceAID(instanceId: UInt8 = 1) -> [UInt8] {
|
||||
precondition(instanceId >= 1, "The instance index must be between 1 and 255")
|
||||
return keycardAID.val + [instanceId]
|
||||
}
|
||||
|
||||
var val: [UInt8] {
|
||||
get {
|
||||
self.rawValue.hexToBytes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,12 @@ struct Pairing {
|
|||
let pairingKey: [UInt8]
|
||||
let pairingIndex: UInt8
|
||||
|
||||
var bytes: [UInt8] {
|
||||
get {
|
||||
return [pairingIndex] + pairingKey
|
||||
}
|
||||
}
|
||||
|
||||
init(pairingKey: [UInt8], pairingIndex: UInt8) {
|
||||
self.pairingKey = pairingKey
|
||||
self.pairingIndex = pairingIndex
|
||||
|
@ -11,10 +17,4 @@ struct Pairing {
|
|||
self.pairingIndex = pairingData[0]
|
||||
self.pairingKey = Array(pairingData[1...(pairingData.count - 1)])
|
||||
}
|
||||
|
||||
var bytes: [UInt8] {
|
||||
get {
|
||||
[pairingIndex] + pairingKey
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,9 @@ extension Collection where Element == Character {
|
|||
last = $0
|
||||
return nil
|
||||
}
|
||||
defer { last = nil }
|
||||
defer {
|
||||
last = nil
|
||||
}
|
||||
return UInt8(lastHexDigitValue * 16 + hexDigitValue)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue