Skip to content

Commit 1b7f50a

Browse files
committed
throw PinRequiredClientError if no PIN is provided
1 parent fe5ed9c commit 1b7f50a

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

fido/src/main/java/com/yubico/yubikit/fido/client/BasicWebAuthnClient.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.yubico.yubikit.core.application.CommandException;
2020
import com.yubico.yubikit.core.application.CommandState;
2121
import com.yubico.yubikit.core.fido.CtapException;
22-
import com.yubico.yubikit.core.internal.Logger;
2322
import com.yubico.yubikit.fido.ctap.ClientPin;
2423
import com.yubico.yubikit.fido.ctap.CredentialManagement;
2524
import com.yubico.yubikit.fido.ctap.Ctap2Session;
@@ -188,7 +187,6 @@ public PublicKeyCredential makeCredential(
188187
if (e.getCtapError() == CtapException.ERR_PIN_INVALID) {
189188
throw new PinInvalidClientError(e, clientPin.getPinRetries().getCount());
190189
}
191-
Logger.debug(logger, "makeCredential CTAP error: {}", String.format("0x%02x", e.getCtapError()));
192190
throw ClientError.wrapCtapException(e);
193191
}
194192
}
@@ -432,9 +430,8 @@ protected Ctap2Session.CredentialData ctapMakeCredential(
432430
pinToken = clientPin.getUvToken(ClientPin.PIN_PERMISSION_MC, rpId, null);
433431
pinUvAuthParam = clientPin.getPinUvAuth().authenticate(pinToken, clientDataHash);
434432
pinUvAuthProtocol = clientPin.getPinUvAuth().getVersion();
435-
} else if (pinConfigured && Boolean.TRUE.equals(ctapOptions.get(OPTION_RESIDENT_KEY))) {
436-
// the authenticator supports pin and a discoverable credential creation has been
437-
// requested, but no PIN was provided
433+
} else if (pinConfigured) {
434+
// the authenticator supports pin but no PIN was provided
438435
throw new PinRequiredClientError();
439436
}
440437

@@ -555,7 +552,6 @@ protected List<Ctap2Session.AssertionData> ctapGetAssertions(
555552
if (e.getCtapError() == CtapException.ERR_PIN_INVALID) {
556553
throw new PinInvalidClientError(e, clientPin.getPinRetries().getCount());
557554
}
558-
Logger.debug(logger, "getAssertion CTAP error: {}", String.format("0x%02x", e.getCtapError()));
559555
throw ClientError.wrapCtapException(e);
560556
} finally {
561557
if (pinToken != null) {

testing-android/src/androidTest/java/com/yubico/yubikit/testing/fido/UvDiscouragedInstrumentedTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import androidx.test.filters.LargeTest;
2020

21-
import com.yubico.yubikit.fido.client.ClientError;
21+
import com.yubico.yubikit.fido.client.PinRequiredClientError;
2222
import com.yubico.yubikit.fido.ctap.Ctap2Session;
2323
import com.yubico.yubikit.testing.framework.FidoInstrumentedTests;
2424

@@ -43,9 +43,9 @@ public void testMakeCredentialGetAssertion() throws Throwable {
4343

4444
/**
4545
* Run this test only on devices with PIN set
46-
* this is expected to fail with 0x36
46+
* Expected to fail with PinRequiredClientError
4747
*/
48-
@Test(expected = ClientError.class)
48+
@Test(expected = PinRequiredClientError.class)
4949
public void testMakeCredentialGetAssertionOnProtected() throws Throwable {
5050
withCtap2Session(
5151
"This device has no PIN set",

0 commit comments

Comments
 (0)