BcDHKeyPairGenerator extends AbstractBcKeyPairGenerator { @Override public AsymmetricKeyPair generate() { return generate(new DHKeyParametersGenerationParameters()); }  @Override AsymmetricKeyPair generate(); @Override AsymmetricKeyPair generate(KeyGenerationParameters parameters);  }
@Test void generateWithoutArgument() { AsymmetricKeyPair kp1 = generator.generate(); AsymmetricKeyPair kp2 = generator.generate(); assertThat(kp1, not(nullValue())); assertThat(kp2, not(nullValue())); assertThat(kp1.getPrivate(), instanceOf(BcAsymmetricKeyParameters.class)); assertThat(kp2.getPrivate(), instanceOf(BcAsymmetricKeyParameters.class)); assertThat(kp1.getPublic(), instanceOf(BcAsymmetricKeyParameters.class)); assertThat(kp2.getPublic(), instanceOf(BcAsymmetricKeyParameters.class)); assertThat(((BcAsymmetricKeyParameters) kp1.getPrivate()).getParameters(), instanceOf( DHPrivateKeyParameters.class)); assertThat(((BcAsymmetricKeyParameters) kp2.getPrivate()).getParameters(), instanceOf( DHPrivateKeyParameters.class)); assertThat(((BcAsymmetricKeyParameters) kp1.getPublic()).getParameters(), instanceOf( DHPublicKeyParameters.class)); assertThat(((BcAsymmetricKeyParameters) kp2.getPublic()).getParameters(), instanceOf( DHPublicKeyParameters.class)); }
@Test void generateWithDefaultParameters() { DHKeyGenerationParameters params = (DHKeyGenerationParameters) parameterGenerator.generate(); assertThat(params, not(nullValue())); AsymmetricKeyPair kp1 = generator.generate(params); assertThat(kp1, not(nullValue())); assertThat(kp1.getPrivate(), instanceOf(BcAsymmetricKeyParameters.class)); assertThat(kp1.getPublic(), instanceOf(BcAsymmetricKeyParameters.class)); assertThat(((BcAsymmetricKeyParameters) kp1.getPrivate()).getParameters(), instanceOf(DHPrivateKeyParameters.class)); assertThat(((BcAsymmetricKeyParameters) kp1.getPublic()).getParameters(), instanceOf(DHPublicKeyParameters.class)); AsymmetricKeyPair kp2 = generator.generate(params); assertThat(kp2, not(nullValue())); assertThat(kp2.getPrivate(), instanceOf(BcAsymmetricKeyParameters.class)); assertThat(kp2.getPublic(), instanceOf(BcAsymmetricKeyParameters.class)); assertThat(((BcAsymmetricKeyParameters) kp2.getPrivate()).getParameters(), instanceOf( DHPrivateKeyParameters.class)); assertThat(((BcAsymmetricKeyParameters) kp2.getPublic()).getParameters(), instanceOf( DHPublicKeyParameters.class)); assertThat(kp2, not(equalTo(kp1))); }