use of com.google.crypto.tink.proto.RegistryConfig 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);
}
use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.
the class DeterministicAeadConfigTest method testConfigContents.
@Test
public void testConfigContents() throws Exception {
RegistryConfig config = DeterministicAeadConfig.TINK_1_1_0;
assertEquals(1, config.getEntryCount());
assertEquals("TINK_DETERMINISTIC_AEAD_1_1_0", config.getConfigName());
TestUtil.verifyConfigEntry(config.getEntry(0), "TinkDeterministicAead", "DeterministicAead", "type.googleapis.com/google.crypto.tink.AesSivKey", true, 0);
}
use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.
the class DeterministicAeadConfigTest method aaaTestInitialization.
// This test must run first.
@Test
public void aaaTestInitialization() throws Exception {
try {
Registry.getCatalogue("tinkdeterministicaead");
fail("Expected GeneralSecurityException");
} catch (GeneralSecurityException e) {
assertThat(e.toString()).contains("no catalogue found");
assertThat(e.toString()).contains("DeterministicAeadConfig.init()");
}
// Get the config proto, now the catalogues should be present,
// as init() was triggered by a static block.
RegistryConfig unused = DeterministicAeadConfig.TINK_1_1_0;
Registry.getCatalogue("tinkdeterministicaead");
// Running init() manually again should succeed.
DeterministicAeadConfig.init();
}
use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.
the class TinkConfigTest method testConfigContentsVersion1_0_0.
@Test
public void testConfigContentsVersion1_0_0() throws Exception {
RegistryConfig config = TinkConfig.TINK_1_0_0;
assertEquals(13, config.getEntryCount());
assertEquals("TINK_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);
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);
}
use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.
the class AeadConfigTest method testConfigContents1_1_0.
@Test
public void testConfigContents1_1_0() throws Exception {
RegistryConfig config = AeadConfig.TINK_1_1_0;
assertEquals(7, config.getEntryCount());
assertEquals("TINK_AEAD_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);
}
Aggregations