Search in sources :

Example 11 with RegistryConfig

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

the class AeadConfigTest method testConfigContents1_0_0.

@Test
public void testConfigContents1_0_0() throws Exception {
    RegistryConfig config = AeadConfig.TINK_1_0_0;
    assertEquals(7, config.getEntryCount());
    assertEquals("TINK_AEAD_1_0_0", config.getConfigName());
    TestUtil.verifyConfigEntry(config.getEntry(0), "TinkMac", "Mac", "type.googleapis.com/google.crypto.tink.HmacKey", true, 0);
    TestUtil.verifyConfigEntry(config.getEntry(1), "TinkAead", "Aead", "type.googleapis.com/google.crypto.tink.AesCtrHmacAeadKey", true, 0);
    TestUtil.verifyConfigEntry(config.getEntry(2), "TinkAead", "Aead", "type.googleapis.com/google.crypto.tink.AesEaxKey", true, 0);
    TestUtil.verifyConfigEntry(config.getEntry(3), "TinkAead", "Aead", "type.googleapis.com/google.crypto.tink.AesGcmKey", true, 0);
    TestUtil.verifyConfigEntry(config.getEntry(4), "TinkAead", "Aead", "type.googleapis.com/google.crypto.tink.ChaCha20Poly1305Key", true, 0);
    TestUtil.verifyConfigEntry(config.getEntry(5), "TinkAead", "Aead", "type.googleapis.com/google.crypto.tink.KmsAeadKey", true, 0);
    TestUtil.verifyConfigEntry(config.getEntry(6), "TinkAead", "Aead", "type.googleapis.com/google.crypto.tink.KmsEnvelopeAeadKey", true, 0);
}
Also used : RegistryConfig(com.google.crypto.tink.proto.RegistryConfig) Test(org.junit.Test)

Example 12 with RegistryConfig

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

the class SignatureConfigTest method testConfigContents1_1_0.

@Test
public void testConfigContents1_1_0() throws Exception {
    RegistryConfig config = SignatureConfig.TINK_1_1_0;
    assertEquals(4, config.getEntryCount());
    assertEquals("TINK_SIGNATURE_1_1_0", config.getConfigName());
    TestUtil.verifyConfigEntry(config.getEntry(0), "TinkPublicKeySign", "PublicKeySign", "type.googleapis.com/google.crypto.tink.EcdsaPrivateKey", true, 0);
    TestUtil.verifyConfigEntry(config.getEntry(1), "TinkPublicKeySign", "PublicKeySign", "type.googleapis.com/google.crypto.tink.Ed25519PrivateKey", true, 0);
    TestUtil.verifyConfigEntry(config.getEntry(2), "TinkPublicKeyVerify", "PublicKeyVerify", "type.googleapis.com/google.crypto.tink.EcdsaPublicKey", true, 0);
    TestUtil.verifyConfigEntry(config.getEntry(3), "TinkPublicKeyVerify", "PublicKeyVerify", "type.googleapis.com/google.crypto.tink.Ed25519PublicKey", true, 0);
}
Also used : RegistryConfig(com.google.crypto.tink.proto.RegistryConfig) Test(org.junit.Test)

Example 13 with RegistryConfig

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

the class SignatureConfigTest method aaaTestInitialization.

// This test must run first.
@Test
public void aaaTestInitialization() throws Exception {
    try {
        Registry.getCatalogue("tinkpublickeysign");
        fail("Expected GeneralSecurityException");
    } catch (GeneralSecurityException e) {
        assertThat(e.toString()).contains("no catalogue found");
        assertThat(e.toString()).contains("SignatureConfig.init()");
    }
    try {
        Registry.getCatalogue("tinkpublickeyverify");
        fail("Expected GeneralSecurityException");
    } catch (GeneralSecurityException e) {
        assertThat(e.toString()).contains("no catalogue found");
        assertThat(e.toString()).contains("SignatureConfig.init()");
    }
    // Get the config proto, now the catalogues should be present,
    // as init() was triggered by a static block.
    RegistryConfig unused = SignatureConfig.TINK_1_1_0;
    Registry.getCatalogue("tinkpublickeysign");
    Registry.getCatalogue("tinkpublickeyverify");
    // Running init() manually again should succeed.
    SignatureConfig.init();
}
Also used : RegistryConfig(com.google.crypto.tink.proto.RegistryConfig) GeneralSecurityException(java.security.GeneralSecurityException) Test(org.junit.Test)

Example 14 with RegistryConfig

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

the class SignatureConfigTest method testConfigContents.

@Test
public void testConfigContents() throws Exception {
    RegistryConfig config = SignatureConfig.TINK_1_0_0;
    assertEquals(4, config.getEntryCount());
    assertEquals("TINK_SIGNATURE_1_0_0", config.getConfigName());
    TestUtil.verifyConfigEntry(config.getEntry(0), "TinkPublicKeySign", "PublicKeySign", "type.googleapis.com/google.crypto.tink.EcdsaPrivateKey", true, 0);
    TestUtil.verifyConfigEntry(config.getEntry(1), "TinkPublicKeySign", "PublicKeySign", "type.googleapis.com/google.crypto.tink.Ed25519PrivateKey", true, 0);
    TestUtil.verifyConfigEntry(config.getEntry(2), "TinkPublicKeyVerify", "PublicKeyVerify", "type.googleapis.com/google.crypto.tink.EcdsaPublicKey", true, 0);
    TestUtil.verifyConfigEntry(config.getEntry(3), "TinkPublicKeyVerify", "PublicKeyVerify", "type.googleapis.com/google.crypto.tink.Ed25519PublicKey", true, 0);
}
Also used : RegistryConfig(com.google.crypto.tink.proto.RegistryConfig) Test(org.junit.Test)

Example 15 with RegistryConfig

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

the class MacConfigTest method testConfigContents1_0_0.

@Test
public void testConfigContents1_0_0() throws Exception {
    RegistryConfig config = MacConfig.TINK_1_0_0;
    assertEquals(1, config.getEntryCount());
    assertEquals("TINK_MAC_1_0_0", config.getConfigName());
    TestUtil.verifyConfigEntry(config.getEntry(0), "TinkMac", "Mac", "type.googleapis.com/google.crypto.tink.HmacKey", true, 0);
}
Also used : RegistryConfig(com.google.crypto.tink.proto.RegistryConfig) 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