Search in sources :

Example 26 with RegistryConfig

use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.

the class PublicKeyVerifyCatalogueTest method testBasic.

@Test
public void testBasic() throws Exception {
    PublicKeyVerifyCatalogue catalogue = new PublicKeyVerifyCatalogue();
    // Check a single key type for verifying, incl. case-insensitve primitive name.
    String keyType = "type.googleapis.com/google.crypto.tink.Ed25519PublicKey";
    {
        KeyManager<PublicKeyVerify> manager = catalogue.getKeyManager(keyType, "PublicKeyVerify", 0);
        assertThat(manager.doesSupport(keyType)).isTrue();
    }
    {
        KeyManager<PublicKeyVerify> manager = catalogue.getKeyManager(keyType, "PUBLicKeYVerIFY", 0);
        assertThat(manager.doesSupport(keyType)).isTrue();
    }
    {
        KeyManager<PublicKeyVerify> manager = catalogue.getKeyManager(keyType, "PUBLICKEYVERIFY", 0);
        assertThat(manager.doesSupport(keyType)).isTrue();
    }
    // Check all entries from the current SignatureConfig.
    RegistryConfig config = SignatureConfig.TINK_1_0_0;
    int count = 0;
    for (KeyTypeEntry entry : config.getEntryList()) {
        if ("PublicKeyVerify".equals(entry.getPrimitiveName())) {
            count = count + 1;
            KeyManager<PublicKeyVerify> manager = catalogue.getKeyManager(entry.getTypeUrl(), "publickeyverify", entry.getKeyManagerVersion());
            assertThat(manager.doesSupport(entry.getTypeUrl())).isTrue();
        }
    }
    assertEquals(2, count);
}
Also used : RegistryConfig(com.google.crypto.tink.proto.RegistryConfig) PublicKeyVerify(com.google.crypto.tink.PublicKeyVerify) KeyTypeEntry(com.google.crypto.tink.proto.KeyTypeEntry) KeyManager(com.google.crypto.tink.KeyManager) Test(org.junit.Test)

Example 27 with RegistryConfig

use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.

the class PublicKeySignCatalogueTest method testBasic.

@Test
public void testBasic() throws Exception {
    PublicKeySignCatalogue catalogue = new PublicKeySignCatalogue();
    // Check a single key type for signing, incl. case-insensitve primitive name.
    String keyType = "type.googleapis.com/google.crypto.tink.EcdsaPrivateKey";
    {
        KeyManager<PublicKeySign> manager = catalogue.getKeyManager(keyType, "PublicKeySign", 0);
        assertThat(manager.doesSupport(keyType)).isTrue();
    }
    {
        KeyManager<PublicKeySign> manager = catalogue.getKeyManager(keyType, "PUBLicKeYSigN", 0);
        assertThat(manager.doesSupport(keyType)).isTrue();
    }
    {
        KeyManager<PublicKeySign> manager = catalogue.getKeyManager(keyType, "PUBLICKEYSIGN", 0);
        assertThat(manager.doesSupport(keyType)).isTrue();
    }
    // Check all entries from the current SignatureConfig.
    RegistryConfig config = SignatureConfig.TINK_1_0_0;
    int count = 0;
    for (KeyTypeEntry entry : config.getEntryList()) {
        if ("PublicKeySign".equals(entry.getPrimitiveName())) {
            count = count + 1;
            KeyManager<PublicKeySign> manager = catalogue.getKeyManager(entry.getTypeUrl(), "publickeysign", entry.getKeyManagerVersion());
            assertThat(manager.doesSupport(entry.getTypeUrl())).isTrue();
        }
    }
    assertEquals(2, count);
}
Also used : RegistryConfig(com.google.crypto.tink.proto.RegistryConfig) KeyTypeEntry(com.google.crypto.tink.proto.KeyTypeEntry) KeyManager(com.google.crypto.tink.KeyManager) PublicKeySign(com.google.crypto.tink.PublicKeySign) Test(org.junit.Test)

Aggregations

RegistryConfig (com.google.crypto.tink.proto.RegistryConfig)27 Test (org.junit.Test)27 KeyManager (com.google.crypto.tink.KeyManager)8 KeyTypeEntry (com.google.crypto.tink.proto.KeyTypeEntry)8 GeneralSecurityException (java.security.GeneralSecurityException)7 Aead (com.google.crypto.tink.Aead)1 DeterministicAead (com.google.crypto.tink.DeterministicAead)1 HybridDecrypt (com.google.crypto.tink.HybridDecrypt)1 HybridEncrypt (com.google.crypto.tink.HybridEncrypt)1 Mac (com.google.crypto.tink.Mac)1 PublicKeySign (com.google.crypto.tink.PublicKeySign)1 PublicKeyVerify (com.google.crypto.tink.PublicKeyVerify)1 StreamingAead (com.google.crypto.tink.StreamingAead)1