Search in sources :

Example 1 with KeyManager

use of com.google.crypto.tink.KeyManager in project tink by google.

the class HybridDecryptCatalogueTest method testBasic.

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

Example 2 with KeyManager

use of com.google.crypto.tink.KeyManager in project tink by google.

the class HybridEncryptCatalogueTest method testBasic.

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

Example 3 with KeyManager

use of com.google.crypto.tink.KeyManager in project tink by google.

the class DeterministicAeadCatalogueTest method testBasic.

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

Example 4 with KeyManager

use of com.google.crypto.tink.KeyManager in project tink by google.

the class StreamingAeadCatalogueTest method testBasic.

@Test
public void testBasic() throws Exception {
    StreamingAeadCatalogue catalogue = new StreamingAeadCatalogue();
    // Check a single key type, incl. case-insensitve primitive name.
    String keyType = "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey";
    {
        KeyManager<StreamingAead> manager = catalogue.getKeyManager(keyType, "StreamingAead", 0);
        assertThat(manager.doesSupport(keyType)).isTrue();
    }
    {
        KeyManager<StreamingAead> manager = catalogue.getKeyManager(keyType, "STReaMIngAeAD", 0);
        assertThat(manager.doesSupport(keyType)).isTrue();
    }
    {
        KeyManager<StreamingAead> manager = catalogue.getKeyManager(keyType, "STREAMINgaEAD", 0);
        assertThat(manager.doesSupport(keyType)).isTrue();
    }
    // Check all entries from the current StreamingAeadConfig.
    RegistryConfig config = StreamingAeadConfig.TINK_1_1_0;
    int count = 0;
    for (KeyTypeEntry entry : config.getEntryList()) {
        if ("StreamingAead".equals(entry.getPrimitiveName())) {
            count = count + 1;
            KeyManager<StreamingAead> manager = catalogue.getKeyManager(entry.getTypeUrl(), "streamingaead", 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) StreamingAead(com.google.crypto.tink.StreamingAead) Test(org.junit.Test)

Example 5 with KeyManager

use of com.google.crypto.tink.KeyManager in project tink by google.

the class AeadCatalogueTest method testBasic.

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

Aggregations

KeyManager (com.google.crypto.tink.KeyManager)8 KeyTypeEntry (com.google.crypto.tink.proto.KeyTypeEntry)8 RegistryConfig (com.google.crypto.tink.proto.RegistryConfig)8 Test (org.junit.Test)8 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