@Test
    public void initInvalidKeys() throws Exception {
        HpkeContextSender sender = HpkeContextSender.getInstance(DEFAULT_SUITE_NAME);
        PublicKey dhKey = DefaultKeys.getPublicKey("DH");

        assertThrows(InvalidKeyException.class,
                () -> sender.init(null, null));
        assertThrows(InvalidKeyException.class,
              () -> sender.init(null, DEFAULT_INFO));
        // DH keys not supported
        assertThrows(InvalidKeyException.class,
          () -> sender.init(dhKey , DEFAULT_INFO));
        HpkeContextRecipient recipient = HpkeContextRecipient.getInstance(DEFAULT_SUITE_NAME);
        final PrivateKey invalidKey = DefaultKeys.getPrivateKey("DH");
        assertThrows(NullPointerException.class,
                () -> recipient.init(/* enc= */ null, DEFAULT_SK, DEFAULT_INFO));
        assertThrows(InvalidKeyException.class,
                () -> recipient.init(DEFAULT_ENC, /* privateKey= */ null, DEFAULT_INFO));
        // Incorrect enc size
        assertThrows(InvalidKeyException.class,
                () -> recipient.init(new byte[1], DEFAULT_SK, DEFAULT_INFO));
        assertThrows(InvalidKeyException.class,
                () -> recipient.init(DEFAULT_ENC, invalidKey, DEFAULT_INFO));
    }
Tests for DuckTypedHpkeSpiTest. Essentially the same as the tests for HpkeContext but
with a "foreign" HPKE Provider inserted ahead of Conscrypt. That is, one which returns
SPI instances with all the correct methods but which don't inherit directly from "our"
HpkeSpi.
common/src/test/java/org/conscrypt/DuckTypedHpkeSpiTest.java