use of com.google.crypto.tink.proto.KeyTypeEntry 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);
}
use of com.google.crypto.tink.proto.KeyTypeEntry 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);
}
use of com.google.crypto.tink.proto.KeyTypeEntry 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.KeyTypeEntry in project tink by google.
the class ConfigTest method testRegisterKeyType_NoCatalogue_shouldThrowException.
@Test
public void testRegisterKeyType_NoCatalogue_shouldThrowException() throws Exception {
KeyTypeEntry entry = KeyTypeEntry.newBuilder().setCatalogueName("DoesNotExist").build();
try {
Config.registerKeyType(entry);
fail("Expected GeneralSecurityException");
} catch (GeneralSecurityException e) {
// expected
}
}
use of com.google.crypto.tink.proto.KeyTypeEntry 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);
}
Aggregations