Search in sources :

Example 1 with TinkKey

use of com.google.crypto.tink.tinkkey.TinkKey in project tink by google.

the class KeysetManagerTest method addKeyHandle_unsupportedTinkKey_shouldThrow.

@Test
public void addKeyHandle_unsupportedTinkKey_shouldThrow() throws Exception {
    TinkKey tinkKey = new TinkKey() {

        @Override
        public boolean hasSecret() {
            return false;
        }

        @Override
        public KeyTemplate getKeyTemplate() {
            throw new UnsupportedOperationException();
        }
    };
    KeyHandle keyHandle = KeyHandle.createFromKey(tinkKey, KeyAccess.publicAccess());
    KeysetManager keysetManager = KeysetManager.withEmptyKeyset();
    assertThrows(UnsupportedOperationException.class, () -> keysetManager.add(keyHandle));
}
Also used : TinkKey(com.google.crypto.tink.tinkkey.TinkKey) KeyHandle(com.google.crypto.tink.tinkkey.KeyHandle) Test(org.junit.Test)

Example 2 with TinkKey

use of com.google.crypto.tink.tinkkey.TinkKey in project tink by google.

the class KeysetManagerTest method addKeyHandleWithKeyAccess_unsupportedTinkKey_shouldThrow.

@Test
public void addKeyHandleWithKeyAccess_unsupportedTinkKey_shouldThrow() throws Exception {
    TinkKey tinkKey = new TinkKey() {

        @Override
        public boolean hasSecret() {
            return false;
        }

        @Override
        public KeyTemplate getKeyTemplate() {
            throw new UnsupportedOperationException();
        }
    };
    KeyAccess keyAccess = KeyAccess.publicAccess();
    KeyHandle keyHandle = KeyHandle.createFromKey(tinkKey, keyAccess);
    KeysetManager keysetManager = KeysetManager.withEmptyKeyset();
    assertThrows(UnsupportedOperationException.class, () -> keysetManager.add(keyHandle, keyAccess));
}
Also used : SecretKeyAccess(com.google.crypto.tink.tinkkey.SecretKeyAccess) KeyAccess(com.google.crypto.tink.tinkkey.KeyAccess) TinkKey(com.google.crypto.tink.tinkkey.TinkKey) KeyHandle(com.google.crypto.tink.tinkkey.KeyHandle) Test(org.junit.Test)

Aggregations

KeyHandle (com.google.crypto.tink.tinkkey.KeyHandle)2 TinkKey (com.google.crypto.tink.tinkkey.TinkKey)2 Test (org.junit.Test)2 KeyAccess (com.google.crypto.tink.tinkkey.KeyAccess)1 SecretKeyAccess (com.google.crypto.tink.tinkkey.SecretKeyAccess)1