|
1 | 1 | package com.yubico.webauthn;
|
2 | 2 |
|
| 3 | +import COSE.CoseException; |
| 4 | +import com.yubico.webauthn.data.AttestationObject; |
3 | 5 | import com.yubico.webauthn.data.RelyingPartyIdentity;
|
| 6 | +import java.io.IOException; |
| 7 | +import java.security.NoSuchAlgorithmException; |
| 8 | +import java.security.PublicKey; |
| 9 | +import java.security.spec.InvalidKeySpecException; |
4 | 10 | import org.junit.Test;
|
5 | 11 | import org.mockito.Mockito;
|
6 | 12 |
|
7 | 13 | import java.security.Security;
|
8 | 14 | import java.util.Arrays;
|
9 | 15 |
|
10 | 16 | import static org.junit.Assert.assertTrue;
|
| 17 | +import static org.junit.Assert.fail; |
11 | 18 |
|
12 | 19 | /**
|
13 | 20 | * Test that the BouncyCastle provider is not loaded by default
|
@@ -46,4 +53,26 @@ public void bouncyCastleProviderIsNotLoadedAfterInstantiatingRelyingParty() {
|
46 | 53 | ));
|
47 | 54 | }
|
48 | 55 |
|
| 56 | + @Test |
| 57 | + public void bouncyCastleProviderIsNotLoadedAfterAttemptingToLoadEddsaKey() throws IOException, CoseException, NoSuchAlgorithmException, InvalidKeySpecException { |
| 58 | + try { |
| 59 | + WebAuthnCodecs.importCosePublicKey( |
| 60 | + new AttestationObject(RegistrationTestData.Packed$.MODULE$.BasicAttestationEdDsa().attestationObject()) |
| 61 | + .getAuthenticatorData() |
| 62 | + .getAttestedCredentialData() |
| 63 | + .get() |
| 64 | + .getCredentialPublicKey() |
| 65 | + ); |
| 66 | + } catch (NoSuchAlgorithmException e) { |
| 67 | + // OK |
| 68 | + } |
| 69 | + |
| 70 | + assertTrue( |
| 71 | + Arrays.stream(Security.getProviders()) |
| 72 | + .noneMatch(prov -> |
| 73 | + prov.getName().equals("BC") |
| 74 | + || prov.getClass().getCanonicalName().contains("bouncy") |
| 75 | + )); |
| 76 | + } |
| 77 | + |
49 | 78 | }
|
0 commit comments