use of com.google.crypto.tink.proto.KeyTypeEntry 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.KeyTypeEntry 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.KeyTypeEntry in project tink by google.
the class PublicKeyVerifyCatalogueTest method testBasic.
@Test
public void testBasic() throws Exception {
PublicKeyVerifyCatalogue catalogue = new PublicKeyVerifyCatalogue();
// Check a single key type for verifying, incl. case-insensitve primitive name.
String keyType = "type.googleapis.com/google.crypto.tink.Ed25519PublicKey";
{
KeyManager<PublicKeyVerify> manager = catalogue.getKeyManager(keyType, "PublicKeyVerify", 0);
assertThat(manager.doesSupport(keyType)).isTrue();
}
{
KeyManager<PublicKeyVerify> manager = catalogue.getKeyManager(keyType, "PUBLicKeYVerIFY", 0);
assertThat(manager.doesSupport(keyType)).isTrue();
}
{
KeyManager<PublicKeyVerify> manager = catalogue.getKeyManager(keyType, "PUBLICKEYVERIFY", 0);
assertThat(manager.doesSupport(keyType)).isTrue();
}
// Check all entries from the current SignatureConfig.
RegistryConfig config = SignatureConfig.TINK_1_0_0;
int count = 0;
for (KeyTypeEntry entry : config.getEntryList()) {
if ("PublicKeyVerify".equals(entry.getPrimitiveName())) {
count = count + 1;
KeyManager<PublicKeyVerify> manager = catalogue.getKeyManager(entry.getTypeUrl(), "publickeyverify", entry.getKeyManagerVersion());
assertThat(manager.doesSupport(entry.getTypeUrl())).isTrue();
}
}
assertEquals(2, count);
}
use of com.google.crypto.tink.proto.KeyTypeEntry in project tink by google.
the class PublicKeySignCatalogueTest method testBasic.
@Test
public void testBasic() throws Exception {
PublicKeySignCatalogue catalogue = new PublicKeySignCatalogue();
// Check a single key type for signing, incl. case-insensitve primitive name.
String keyType = "type.googleapis.com/google.crypto.tink.EcdsaPrivateKey";
{
KeyManager<PublicKeySign> manager = catalogue.getKeyManager(keyType, "PublicKeySign", 0);
assertThat(manager.doesSupport(keyType)).isTrue();
}
{
KeyManager<PublicKeySign> manager = catalogue.getKeyManager(keyType, "PUBLicKeYSigN", 0);
assertThat(manager.doesSupport(keyType)).isTrue();
}
{
KeyManager<PublicKeySign> manager = catalogue.getKeyManager(keyType, "PUBLICKEYSIGN", 0);
assertThat(manager.doesSupport(keyType)).isTrue();
}
// Check all entries from the current SignatureConfig.
RegistryConfig config = SignatureConfig.TINK_1_0_0;
int count = 0;
for (KeyTypeEntry entry : config.getEntryList()) {
if ("PublicKeySign".equals(entry.getPrimitiveName())) {
count = count + 1;
KeyManager<PublicKeySign> manager = catalogue.getKeyManager(entry.getTypeUrl(), "publickeysign", entry.getKeyManagerVersion());
assertThat(manager.doesSupport(entry.getTypeUrl())).isTrue();
}
}
assertEquals(2, 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();
assertThrows(GeneralSecurityException.class, () -> Config.registerKeyType(entry));
}
Aggregations