From d6aecd51060bbb4a3db9d68c154dd93dc29fa618 Mon Sep 17 00:00:00 2001 From: Dmitry Bespalov Date: Wed, 4 Sep 2019 14:14:53 +0200 Subject: [PATCH] log to encryption --- Sources/Keycard/SecureChannel.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/Keycard/SecureChannel.swift b/Sources/Keycard/SecureChannel.swift index 465aadf..736e8f7 100644 --- a/Sources/Keycard/SecureChannel.swift +++ b/Sources/Keycard/SecureChannel.swift @@ -1,3 +1,6 @@ +import CryptoSwift +import Foundation + class SecureChannel { static let secretLength = 32 static let blockLength = 16 @@ -160,7 +163,10 @@ class SecureChannel { func oneShotEncrypt(data: [UInt8]) -> [UInt8] { self.iv = Crypto.shared.random(count: SecureChannel.blockLength) let encrypted = Crypto.shared.aes256Enc(data: data, iv: iv, key: secret!) - return [UInt8(self.publicKey!.count)] + publicKey! + iv + encrypted + let result = [UInt8(self.publicKey!.count)] + publicKey! + iv + encrypted + + Logger.shared.log("oneShotEncrypt: iv=\(Data(iv).toHexString()) secret=\(Data(secret!).toHexString()) encrypted=\(Data(encrypted).toHexString()) ==> \(Data(result).toHexString())") + return result } private func encryptAPDU(_ data: [UInt8]) -> [UInt8] {