use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.
the class StreamingAeadConfigTest method aaaTestInitialization.
// This test must run first.
@Test
public void aaaTestInitialization() throws Exception {
try {
Registry.getCatalogue("tinkstreamingaead");
fail("Expected GeneralSecurityException");
} catch (GeneralSecurityException e) {
assertThat(e.toString()).contains("no catalogue found");
assertThat(e.toString()).contains("StreamingAeadConfig.init()");
}
try {
Registry.getCatalogue("TinkStreamingAead");
fail("Expected GeneralSecurityException");
} catch (GeneralSecurityException e) {
assertThat(e.toString()).contains("no catalogue found");
assertThat(e.toString()).contains("StreamingAeadConfig.init()");
}
// Get the config proto, now the catalogues should be present,
// as init() was triggered by a static block.
RegistryConfig unused = StreamingAeadConfig.TINK_1_1_0;
Registry.getCatalogue("TinkStreamingAead");
// Running init() manually again should succeed.
StreamingAeadConfig.init();
}
use of com.google.crypto.tink.proto.RegistryConfig 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);
}
use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.
the class AeadConfigTest method aaaTestInitialization.
// This test must run first.
@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()");
}
// Get the config proto, now the catalogues should be present,
// as init() was triggered by a static block.
RegistryConfig unused = AeadConfig.TINK_1_1_0;
Registry.getCatalogue("tinkmac");
Registry.getCatalogue("tinkaead");
// Running init() manually again should succeed.
AeadConfig.init();
}
use of com.google.crypto.tink.proto.RegistryConfig in project tink by google.
the class MacCatalogueTest method testBasic.
@Test
public void testBasic() throws Exception {
MacCatalogue catalogue = new MacCatalogue();
// Check a single key type, incl. case-insensitve primitive name.
String keyType = "type.googleapis.com/google.crypto.tink.HmacKey";
{
KeyManager<Mac> manager = catalogue.getKeyManager(keyType, "Mac", 0);
assertThat(manager.doesSupport(keyType)).isTrue();
}
{
KeyManager<Mac> manager = catalogue.getKeyManager(keyType, "MaC", 0);
assertThat(manager.doesSupport(keyType)).isTrue();
}
{
KeyManager<Mac> manager = catalogue.getKeyManager(keyType, "mAC", 0);
assertThat(manager.doesSupport(keyType)).isTrue();
}
// Check all entries from the current MacConfig.
RegistryConfig config = MacConfig.TINK_1_0_0;
int count = 0;
for (KeyTypeEntry entry : config.getEntryList()) {
if ("Mac".equals(entry.getPrimitiveName())) {
count = count + 1;
KeyManager<Mac> manager = catalogue.getKeyManager(entry.getTypeUrl(), "mac", 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 MacConfigTest method aaaTestInitialization.
// This test must run first.
@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()");
}
// Get the config proto, now the catalogues should be present,
// as init() was triggered by a static block.
RegistryConfig unused = MacConfig.TINK_1_1_0;
Registry.getCatalogue("tinkmac");
Registry.getCatalogue("tinkmac");
// Running init() manually again should succeed.
MacConfig.init();
}
Aggregations