use of com.google.crypto.tink.KeyManager 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.KeyManager 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.KeyManager 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.KeyManager 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.KeyManager 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);
}
Aggregations