|
1 |
| -// Copyright 2021 Yubico AB |
| 1 | +// Copyright 2021 Yubico AB |
2 | 2 | //
|
3 | 3 | // Licensed under the Apache License, Version 2.0 (the "License").
|
4 | 4 | // You may not use this file except in compliance with the License.
|
@@ -67,12 +67,11 @@ private ResponseApdu SendChainedApdu(CommandApdu command, Type commandType, Type
|
67 | 67 | while (!sourceData.IsEmpty)
|
68 | 68 | {
|
69 | 69 | responseApdu = SendPartial(command, commandType, responseType, ref sourceData);
|
70 |
| - if (responseApdu.SW == SWConstants.Success) |
| 70 | + if (responseApdu.SW != SWConstants.Success) |
71 | 71 | {
|
72 |
| - continue; |
| 72 | + _log.LogWarning("Received error response from YubiKey. (SW: 0x{StatusWord})", responseApdu.SW.ToString("X4", CultureInfo.CurrentCulture)); |
| 73 | + return responseApdu; |
73 | 74 | }
|
74 |
| - |
75 |
| - return FailedResponse(responseApdu); |
76 | 75 | }
|
77 | 76 |
|
78 | 77 | return responseApdu!;
|
@@ -102,22 +101,5 @@ private ResponseApdu SendPartial(
|
102 | 101 | var responseApdu = _pipeline.Invoke(partialApdu, commandType, responseType);
|
103 | 102 | return responseApdu;
|
104 | 103 | }
|
105 |
| - |
106 |
| - private ResponseApdu FailedResponse(ResponseApdu responseApdu) |
107 |
| - { |
108 |
| - var currentCulture = CultureInfo.CurrentCulture; |
109 |
| - string errorMessage = responseApdu.SW switch |
110 |
| - { |
111 |
| - SWConstants.WrongLength => string.Format( |
112 |
| - currentCulture, "Sent data exceeds max allowed length by YubiKey. (SW: 0x{0})", |
113 |
| - responseApdu.SW.ToString("X4", currentCulture)), |
114 |
| - _ => string.Format( |
115 |
| - currentCulture, "Received error response from YubiKey. (SW: 0x{0})", |
116 |
| - responseApdu.SW.ToString("X4", currentCulture)) |
117 |
| - }; |
118 |
| - |
119 |
| - _log.LogWarning(errorMessage); |
120 |
| - return responseApdu; |
121 |
| - } |
122 | 104 | }
|
123 | 105 | }
|
0 commit comments