use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.
the class MacConfigTest method testConfigContents1_1_0.
@Test
public void testConfigContents1_1_0() throws Exception {
RegistryConfig config = MacConfig.TINK_1_1_0;
assertEquals(1, config.getEntryCount());
assertEquals("TINK_MAC_1_1_0", config.getConfigName());
TestUtil.verifyConfigEntry(config.getEntry(0), "TinkMac", "Mac", "type.googleapis.com/google.crypto.tink.HmacKey", true, 0);
}
use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.
the class TinkConfigTest method testConfigContentsVersion1_1_0.
@Test
public void testConfigContentsVersion1_1_0() throws Exception {
RegistryConfig config = TinkConfig.TINK_1_1_0;
assertEquals(16, config.getEntryCount());
assertEquals("TINK_1_1_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);
TestUtil.verifyConfigEntry(config.getEntry(7), "TinkHybridDecrypt", "HybridDecrypt", "type.googleapis.com/google.crypto.tink.EciesAeadHkdfPrivateKey", true, 0);
TestUtil.verifyConfigEntry(config.getEntry(8), "TinkHybridEncrypt", "HybridEncrypt", "type.googleapis.com/google.crypto.tink.EciesAeadHkdfPublicKey", true, 0);
TestUtil.verifyConfigEntry(config.getEntry(9), "TinkPublicKeySign", "PublicKeySign", "type.googleapis.com/google.crypto.tink.EcdsaPrivateKey", true, 0);
TestUtil.verifyConfigEntry(config.getEntry(10), "TinkPublicKeySign", "PublicKeySign", "type.googleapis.com/google.crypto.tink.Ed25519PrivateKey", true, 0);
TestUtil.verifyConfigEntry(config.getEntry(11), "TinkPublicKeyVerify", "PublicKeyVerify", "type.googleapis.com/google.crypto.tink.EcdsaPublicKey", true, 0);
TestUtil.verifyConfigEntry(config.getEntry(12), "TinkPublicKeyVerify", "PublicKeyVerify", "type.googleapis.com/google.crypto.tink.Ed25519PublicKey", true, 0);
TestUtil.verifyConfigEntry(config.getEntry(13), "TinkDeterministicAead", "DeterministicAead", "type.googleapis.com/google.crypto.tink.AesSivKey", true, 0);
TestUtil.verifyConfigEntry(config.getEntry(14), "TinkStreamingAead", "StreamingAead", "type.googleapis.com/google.crypto.tink.AesCtrHmacStreamingKey", true, 0);
TestUtil.verifyConfigEntry(config.getEntry(15), "TinkStreamingAead", "StreamingAead", "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", true, 0);
}
use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.
the class TinkConfigTest method aaaTestInitialization.
@Test
public void aaaTestInitialization() throws Exception {
try {
Registry.getCatalogue("tinkmac");
fail("Expected GeneralSecurityException");
} catch (GeneralSecurityException e) {
assertThat(e.toString()).contains("no catalogue found");
assertThat(e.toString()).contains("MacConfig.init()");
}
try {
Registry.getCatalogue("tinkaead");
fail("Expected GeneralSecurityException");
} catch (GeneralSecurityException e) {
assertThat(e.toString()).contains("no catalogue found");
assertThat(e.toString()).contains("AeadConfig.init()");
}
try {
Registry.getCatalogue("tinkhybriddecrypt");
fail("Expected GeneralSecurityException");
} catch (GeneralSecurityException e) {
assertThat(e.toString()).contains("no catalogue found");
assertThat(e.toString()).contains("HybridConfig.init()");
}
try {
Registry.getCatalogue("tinkhybridencrypt");
fail("Expected GeneralSecurityException");
} catch (GeneralSecurityException e) {
assertThat(e.toString()).contains("no catalogue found");
assertThat(e.toString()).contains("HybridConfig.init()");
}
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()'s were triggered by static block in referenced Config-classes.
RegistryConfig unused = TinkConfig.TINK_1_1_0;
Registry.getCatalogue("tinkmac");
Registry.getCatalogue("tinkaead");
Registry.getCatalogue("tinkdeterministicaead");
Registry.getCatalogue("tinkhybridencrypt");
Registry.getCatalogue("tinkhybriddecrypt");
Registry.getCatalogue("tinkpublickeysign");
Registry.getCatalogue("tinkpublickeyverify");
}
use of com.google.crypto.tink.proto.RegistryConfig 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);
}
use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.
the class StreamingAeadConfigTest method testConfigContents.
@Test
public void testConfigContents() throws Exception {
RegistryConfig config = StreamingAeadConfig.TINK_1_1_0;
assertEquals(2, config.getEntryCount());
assertEquals("TINK_STREAMINGAEAD_1_1_0", config.getConfigName());
TestUtil.verifyConfigEntry(config.getEntry(0), "TinkStreamingAead", "StreamingAead", "type.googleapis.com/google.crypto.tink.AesCtrHmacStreamingKey", true, 0);
TestUtil.verifyConfigEntry(config.getEntry(1), "TinkStreamingAead", "StreamingAead", "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", true, 0);
}
Aggregations