File tree 5 files changed +131
-5
lines changed
TangemSdk/TangemSdk/Common
5 files changed +131
-5
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,6 @@ public struct ResponseApdu {
68
68
69
69
extension ResponseApdu : CustomStringConvertible {
70
70
public var description : String {
71
- return " <-- RECEIVED [ \( data. count + 2 ) bytes]: \( data ) \( sw1) \( sw2) (SW: \( statusWord) ) "
71
+ return " <-- RECEIVED [ \( data. count + 2 ) bytes]: *** \( sw1) \( sw2) (SW: \( statusWord) ) "
72
72
}
73
73
}
Original file line number Diff line number Diff line change @@ -292,9 +292,7 @@ public class CardSession {
292
292
completion ( . failure( . sessionInactive) )
293
293
return
294
294
}
295
-
296
- Log . apdu ( " Not encrypted apdu: \( apdu) " )
297
-
295
+
298
296
reader. tag
299
297
. filter { $0 != . none }
300
298
. filter { [ weak self] tag in
Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ protocol TlvLogging {
14
14
15
15
extension TlvLogging {
16
16
func logTlv< T> ( _ tlv: Tlv , _ value: T ) {
17
+ guard !tlv. tag. shouldMask else {
18
+ logMasked ( tlv)
19
+ return
20
+ }
21
+
17
22
var tlvString = " \( tlv) "
18
23
19
24
if tlv. tag. valueType != . data && tlv. tag. valueType != . hexString {
@@ -22,4 +27,11 @@ extension TlvLogging {
22
27
23
28
Log . tlv ( tlvString)
24
29
}
30
+
31
+ private func logMasked( _ tlv: Tlv ) {
32
+ let tagName = " \( tlv. tag) " . capitalizingFirst ( )
33
+ let tagFullName = " TAG_ \( tagName) "
34
+
35
+ Log . tlv ( " \( tagFullName) [0x \( tlv. tagRaw) :***]: *** " )
36
+ }
25
37
}
Original file line number Diff line number Diff line change @@ -321,7 +321,7 @@ extension NFCReader: CardReader {
321
321
} //todo: handle tag lost
322
322
323
323
let requestTS = Date ( )
324
- Log . apdu ( " SEND --> \( apdu ) " )
324
+
325
325
return iso7816tag
326
326
. sendCommandPublisher ( cApdu: apdu)
327
327
. combineLatest ( self . cancellationPublisher)
Original file line number Diff line number Diff line change @@ -192,4 +192,120 @@ public enum TlvTag: Byte {
192
192
return . data
193
193
}
194
194
}
195
+
196
+ var shouldMask : Bool {
197
+ switch self {
198
+ case . pin,
199
+ . pin2,
200
+ . newPin,
201
+ . newPin2,
202
+ . newPin3,
203
+ . walletPublicKey,
204
+ . walletPrivateKey:
205
+ return true
206
+ case . unknown,
207
+ . cardId,
208
+ . transactionOutHash,
209
+ . transactionOutHashSize,
210
+ . walletSignature,
211
+ . walletRemainingSignatures,
212
+ . walletSignedHashes,
213
+ . pause,
214
+ . flash,
215
+ . issuerTxSignature,
216
+ . status,
217
+ . cardPublicKey,
218
+ . cardSignature,
219
+ . curveId,
220
+ . hashAlgId,
221
+ . signingMethod,
222
+ . maxSignatures,
223
+ . pauseBeforePin2,
224
+ . settingsMask,
225
+ . userSettingsMask,
226
+ . cardData,
227
+ . ndefData,
228
+ . createWalletAtPersonalize,
229
+ . health,
230
+ . crExKey,
231
+ . publicKeyChallenge,
232
+ . publicKeySalt,
233
+ . challenge,
234
+ . salt,
235
+ . validationCounter,
236
+ . cvc,
237
+ . sessionKeyA,
238
+ . sessionKeyB,
239
+ . uid,
240
+ . manufacturerName,
241
+ . manufacturerSignature,
242
+ . issuerPublicKey,
243
+ . issuerTransactionPublicKey,
244
+ . issuerData,
245
+ . issuerDataSignature,
246
+ . issuerDataCounter,
247
+ . isActivated,
248
+ . activationSeed,
249
+ . paymentFlowVersion,
250
+ . userData,
251
+ . userProtectedData,
252
+ . userCounter,
253
+ . userProtectedCounter,
254
+ . resetPin,
255
+ . codePageAddress,
256
+ . codePageCount,
257
+ . codeHash,
258
+ . trOutRaw,
259
+ . firmwareVersion,
260
+ . batchId,
261
+ . manufactureDateTime,
262
+ . issuerName,
263
+ . blockchainName,
264
+ . manufacturerPublicKey,
265
+ . cardIDManufacturerSignature,
266
+ . tokenSymbol,
267
+ . tokenContractAddress,
268
+ . tokenDecimal,
269
+ . tokenName,
270
+ . denomination,
271
+ . validatedBalance,
272
+ . lastSignDate,
273
+ . denominationText,
274
+ . checkWalletCounter,
275
+ . productMask,
276
+ . isLinked,
277
+ . terminalPublicKey,
278
+ . terminalTransactionSignature,
279
+ . legacyMode,
280
+ . interactionMode,
281
+ . offset,
282
+ . size,
283
+ . acquirerPublicKey,
284
+ . pin2IsDefault,
285
+ . pinIsDefault,
286
+ . walletIndex,
287
+ . walletsCount,
288
+ . walletData,
289
+ . cardWallet,
290
+ . fileIndex,
291
+ . fileSettings,
292
+ . fileTypeName,
293
+ . fileData,
294
+ . fileSignature,
295
+ . fileCounter,
296
+ . fileOwnerIndex,
297
+ . walletHDPath,
298
+ . walletHDChain,
299
+ . certificate,
300
+ . backupStatus,
301
+ . backupCount,
302
+ . primaryCardLinkingKey,
303
+ . backupCardLinkingKey,
304
+ . backupCardLink,
305
+ . backupAttestSignature,
306
+ . backupCardPublicKey,
307
+ . proof:
308
+ return false
309
+ }
310
+ }
195
311
}
You can’t perform that action at this time.
0 commit comments