Guides and Sample Code Developer
Search

CryptoTokenKit Changes for Swift

CryptoTokenKit

Removed TKSmartCardProtocol.init(_: UInt)
Added TKSmartCardPINCompletion.init(rawValue: UInt)
Added TKSmartCardPINConfirmation.init(rawValue: UInt)
DeclarationRaw Value Type
From
enum TKErrorCode : Int {
    case CodeNotImplemented
    case CodeCommunicationError
    case CodeCorruptedData
    case CodeCanceledByUser
    case AuthenticationFailed
    case ObjectNotFound
    case TokenNotFound
}
--
To
enum TKErrorCode : Int {
    case NotImplemented
    case CommunicationError
    case CorruptedData
    case CanceledByUser
    case AuthenticationFailed
    case ObjectNotFound
    case TokenNotFound
    case BadParameter
    static var TKErrorAuthenticationFailed: TKErrorCode { get }
    static var TKErrorObjectNotFound: TKErrorCode { get }
    static var TKErrorTokenNotFound: TKErrorCode { get }
}
Int

Declaration
From
case CodeCanceledByUser
To
case CanceledByUser

Declaration
From
case CodeCommunicationError
To
case CommunicationError

Declaration
From
case CodeCorruptedData
To
case CorruptedData

Declaration
From
case CodeNotImplemented
To
case NotImplemented

NameDeclarationDeprecation
FromAuthenticationFailed
case AuthenticationFailed
--
ToTKErrorAuthenticationFailed
static var TKErrorAuthenticationFailed: TKErrorCode { get }
OS X 10.11

NameDeclarationDeprecation
FromObjectNotFound
case ObjectNotFound
--
ToTKErrorObjectNotFound
static var TKErrorObjectNotFound: TKErrorCode { get }
OS X 10.11

NameDeclarationDeprecation
FromTokenNotFound
case TokenNotFound
--
ToTKErrorTokenNotFound
static var TKErrorTokenNotFound: TKErrorCode { get }
OS X 10.11

Modified TKSmartCard
Declaration
From
class TKSmartCard : NSObject {
    var slot: TKSmartCardSlot! { get }
    var valid: Bool { get }
    var allowedProtocols: TKSmartCardProtocol
    var currentProtocol: TKSmartCardProtocol { get }
    var sensitive: Bool
    var context: AnyObject!
    func beginSessionWithReply(_ reply: ((Bool, NSError!) -> Void)!)
    func transmitRequest(_ request: NSData!, reply reply: ((NSData!, NSError!) -> Void)!)
    func endSession()
}
extension TKSmartCard {
    var cla: UInt8
    var useExtendedLength: Bool
    func sendIns(_ ins: UInt8, p1 p1: UInt8, p2 p2: UInt8, data requestData: NSData!, le le: NSNumber!, reply reply: ((NSData!, UInt16, NSError!) -> Void)!)
}
To
class TKSmartCard : NSObject {
    var slot: TKSmartCardSlot { get }
    var valid: Bool { get }
    var allowedProtocols: TKSmartCardProtocol
    var currentProtocol: TKSmartCardProtocol { get }
    var sensitive: Bool
    var context: AnyObject?
    func beginSessionWithReply(_ reply: (Bool, NSError?) -> Void)
    func transmitRequest(_ request: NSData, reply reply: (NSData?, NSError?) -> Void)
    func endSession()
    func userInteractionForSecurePINVerificationWithPINFormat(_ PINFormat: TKSmartCardPINFormat, APDU APDU: NSData, PINByteOffset PINByteOffset: Int) -> TKSmartCardUserInteractionForSecurePINVerification?
    func userInteractionForSecurePINChangeWithPINFormat(_ PINFormat: TKSmartCardPINFormat, APDU APDU: NSData, currentPINByteOffset currentPINByteOffset: Int, newPINByteOffset newPINByteOffset: Int) -> TKSmartCardUserInteractionForSecurePINChange?
}
extension TKSmartCard {
    var cla: UInt8
    var useExtendedLength: Bool
    func sendIns(_ ins: UInt8, p1 p1: UInt8, p2 p2: UInt8, data requestData: NSData, le le: NSNumber?, reply reply: (NSData?, UInt16, NSError?) -> Void)
}

Declaration
From
func beginSessionWithReply(_ reply: ((Bool, NSError!) -> Void)!)
To
func beginSessionWithReply(_ reply: (Bool, NSError?) -> Void)

Declaration
From
var context: AnyObject!
To
var context: AnyObject?

Declaration
From
func sendIns(_ ins: UInt8, p1 p1: UInt8, p2 p2: UInt8, data requestData: NSData!, le le: NSNumber!, reply reply: ((NSData!, UInt16, NSError!) -> Void)!)
To
func sendIns(_ ins: UInt8, p1 p1: UInt8, p2 p2: UInt8, data requestData: NSData, le le: NSNumber?, reply reply: (NSData?, UInt16, NSError?) -> Void)

Declaration
From
var slot: TKSmartCardSlot! { get }
To
var slot: TKSmartCardSlot { get }

Declaration
From
func transmitRequest(_ request: NSData!, reply reply: ((NSData!, NSError!) -> Void)!)
To
func transmitRequest(_ request: NSData, reply reply: (NSData?, NSError?) -> Void)

Declaration
From
class TKSmartCardATR : NSObject {
    init!(bytes bytes: NSData!)
    init!(source source: (() -> Int32)!)
    var bytes: NSData! { get }
    var protocols: [AnyObject]! { get }
    func interfaceGroupAtIndex(_ index: Int) -> TKSmartCardATRInterfaceGroup!
    func interfaceGroupForProtocol(_ `protocol`: TKSmartCardProtocol) -> TKSmartCardATRInterfaceGroup!
    var historicalBytes: NSData! { get }
}
To
class TKSmartCardATR : NSObject {
    init?(bytes bytes: NSData)
    init?(source source: () -> Int32)
    var bytes: NSData { get }
    var protocols: [NSNumber] { get }
    func interfaceGroupAtIndex(_ index: Int) -> TKSmartCardATRInterfaceGroup?
    func interfaceGroupForProtocol(_ `protocol`: TKSmartCardProtocol) -> TKSmartCardATRInterfaceGroup?
    var historicalBytes: NSData { get }
}

Declaration
From
var bytes: NSData! { get }
To
var bytes: NSData { get }

Declaration
From
var historicalBytes: NSData! { get }
To
var historicalBytes: NSData { get }

Declaration
From
init!(bytes bytes: NSData!)
To
init?(bytes bytes: NSData)

Declaration
From
init!(source source: (() -> Int32)!)
To
init?(source source: () -> Int32)

Declaration
From
func interfaceGroupAtIndex(_ index: Int) -> TKSmartCardATRInterfaceGroup!
To
func interfaceGroupAtIndex(_ index: Int) -> TKSmartCardATRInterfaceGroup?

Declaration
From
func interfaceGroupForProtocol(_ `protocol`: TKSmartCardProtocol) -> TKSmartCardATRInterfaceGroup!
To
func interfaceGroupForProtocol(_ `protocol`: TKSmartCardProtocol) -> TKSmartCardATRInterfaceGroup?

Declaration
From
var protocols: [AnyObject]! { get }
To
var protocols: [NSNumber] { get }

Declaration
From
class TKSmartCardATRInterfaceGroup : NSObject {
    var TA: NSNumber! { get }
    var TB: NSNumber! { get }
    var TC: NSNumber! { get }
    var `protocol`: NSNumber! { get }
}
To
class TKSmartCardATRInterfaceGroup : NSObject {
    var TA: NSNumber? { get }
    var TB: NSNumber? { get }
    var TC: NSNumber? { get }
    var `protocol`: NSNumber? { get }
}

Declaration
From
var `protocol`: NSNumber! { get }
To
var `protocol`: NSNumber? { get }

Declaration
From
var TA: NSNumber! { get }
To
var TA: NSNumber? { get }

Declaration
From
var TB: NSNumber! { get }
To
var TB: NSNumber? { get }

Declaration
From
var TC: NSNumber! { get }
To
var TC: NSNumber? { get }

DeclarationProtocols
From
struct TKSmartCardProtocol : RawOptionSetType {
    init(_ rawValue: UInt)
    init(rawValue rawValue: UInt)
    static var None: TKSmartCardProtocol { get }
    static var T0: TKSmartCardProtocol { get }
    static var T1: TKSmartCardProtocol { get }
    static var T15: TKSmartCardProtocol { get }
    static var Any: TKSmartCardProtocol { get }
}
RawOptionSetType
To
struct TKSmartCardProtocol : OptionSetType {
    init(rawValue rawValue: UInt)
    static var None: TKSmartCardProtocol { get }
    static var T0: TKSmartCardProtocol { get }
    static var T1: TKSmartCardProtocol { get }
    static var T15: TKSmartCardProtocol { get }
    static var Any: TKSmartCardProtocol { get }
}
OptionSetType

Declaration
From
class TKSmartCardSlot : NSObject {
    var state: TKSmartCardSlotState { get }
    var ATR: TKSmartCardATR! { get }
    var name: String! { get }
    var maxInputLength: Int { get }
    var maxOutputLength: Int { get }
    func makeSmartCard() -> TKSmartCard!
}
To
class TKSmartCardSlot : NSObject {
    var state: TKSmartCardSlotState { get }
    var ATR: TKSmartCardATR? { get }
    var name: String { get }
    var maxInputLength: Int { get }
    var maxOutputLength: Int { get }
    func makeSmartCard() -> TKSmartCard?
}

Declaration
From
var ATR: TKSmartCardATR! { get }
To
var ATR: TKSmartCardATR? { get }

Declaration
From
func makeSmartCard() -> TKSmartCard!
To
func makeSmartCard() -> TKSmartCard?

Declaration
From
var name: String! { get }
To
var name: String { get }

Declaration
From
class TKSmartCardSlotManager : NSObject {
    class func defaultManager() -> Self!
    var slotNames: [AnyObject]! { get }
    func getSlotWithName(_ name: String!, reply reply: ((TKSmartCardSlot!) -> Void)!)
}
To
class TKSmartCardSlotManager : NSObject {
    class func defaultManager() -> Self?
    var slotNames: [String] { get }
    func getSlotWithName(_ name: String, reply reply: (TKSmartCardSlot?) -> Void)
}

Declaration
From
class func defaultManager() -> Self!
To
class func defaultManager() -> Self?

Declaration
From
func getSlotWithName(_ name: String!, reply reply: ((TKSmartCardSlot!) -> Void)!)
To
func getSlotWithName(_ name: String, reply reply: (TKSmartCardSlot?) -> Void)

Declaration
From
var slotNames: [AnyObject]! { get }
To
var slotNames: [String] { get }

DeclarationRaw Value Type
From
enum TKSmartCardSlotState : Int {
    case SlotStateMissing
    case SlotStateEmpty
    case SlotStateProbing
    case SlotStateMuteCard
    case SlotStateValidCard
}
--
To
enum TKSmartCardSlotState : Int {
    case Missing
    case Empty
    case Probing
    case MuteCard
    case ValidCard
}
Int

Declaration
From
case SlotStateEmpty
To
case Empty

Declaration
From
case SlotStateMissing
To
case Missing

Declaration
From
case SlotStateMuteCard
To
case MuteCard

Declaration
From
case SlotStateProbing
To
case Probing

Declaration
From
case SlotStateValidCard
To
case ValidCard

Feedback