@@ -41,14 +41,15 @@ public ResponseApdu Invoke(CommandApdu command, Type commandType, Type responseT
41
41
if ( commandType == typeof ( ReadStatusCommand ) ||
42
42
responseType != typeof ( ReadStatusResponse ) )
43
43
{
44
- return InvokeCommand ( command , commandType , responseType ) ;
44
+ return _nextTransform . Invoke ( command , commandType , responseType ) ;
45
45
}
46
46
47
47
// Otherwise we assume this to be a command that applies a config (and therefore looks for a status response).
48
48
// In order to detect failures, we grab the status structure before applying said command so that we have a
49
49
// sequence number to compare to.
50
50
var beforeStatus = GetCurrentStatus ( ) ;
51
- var responseApdu = InvokeCommand ( command , commandType , responseType , out var afterStatus ) ;
51
+ var responseApdu = _nextTransform . Invoke ( command , commandType , responseType ) ;
52
+ var afterStatus = ReadStatus ( responseApdu ) ;
52
53
53
54
try
54
55
{
@@ -62,7 +63,7 @@ public ResponseApdu Invoke(CommandApdu command, Type commandType, Type responseT
62
63
{
63
64
_logger . LogWarning ( e , "Handling keyboard connection exception. Translating to APDU response." ) ;
64
65
65
- return CreateFailedApdu ( [ ] ) ;
66
+ return CreateFailedApdu ( ) ;
66
67
}
67
68
}
68
69
@@ -83,20 +84,6 @@ internal static bool IsValidSequenceProgression(OtpStatus beforeStatus, OtpStatu
83
84
return normalIncrement || validReset ;
84
85
}
85
86
86
- private ResponseApdu InvokeCommand (
87
- CommandApdu commandApdu ,
88
- Type commandType ,
89
- Type responseType ,
90
- out OtpStatus afterStatus )
91
- {
92
- var responseApdu = _nextTransform . Invoke ( commandApdu , commandType , responseType ) ;
93
- afterStatus = ReadStatus ( responseApdu ) ;
94
- return responseApdu ;
95
- }
96
-
97
- private ResponseApdu InvokeCommand ( CommandApdu commandApdu , Type commandType , Type responseType ) =>
98
- _nextTransform . Invoke ( commandApdu , commandType , responseType ) ;
99
-
100
87
private OtpStatus GetCurrentStatus ( )
101
88
{
102
89
var command = new ReadStatusCommand ( ) ;
@@ -105,9 +92,7 @@ private OtpStatus GetCurrentStatus()
105
92
typeof ( ReadStatusCommand ) ,
106
93
typeof ( ReadStatusResponse ) ) ;
107
94
108
- return command
109
- . CreateResponseForApdu ( responseApdu )
110
- . GetData ( ) ;
95
+ return ReadStatus ( responseApdu ) ;
111
96
}
112
97
113
98
private static OtpStatus ReadStatus ( ResponseApdu responseApdu )
@@ -117,6 +102,6 @@ private static OtpStatus ReadStatus(ResponseApdu responseApdu)
117
102
return afterStatus ;
118
103
}
119
104
120
- private static ResponseApdu CreateFailedApdu ( byte [ ] data ) => new ( data , SWConstants . WarningNvmUnchanged ) ;
105
+ private static ResponseApdu CreateFailedApdu ( byte [ ] ? data = null ) => new ( data ?? [ ] , SWConstants . WarningNvmUnchanged ) ;
121
106
}
122
107
}
0 commit comments