use of com.google.crypto.tink.proto.JwtHmacKey in project tink by google.
the class JwtHmacKeyManagerTest method getRfc7515ExampleKeysetHandle.
private static KeysetHandle getRfc7515ExampleKeysetHandle() throws Exception {
String keyValue = "AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow";
JwtHmacKey key = JwtHmacKey.newBuilder().setVersion(0).setAlgorithm(JwtHmacAlgorithm.HS256).setKeyValue(ByteString.copyFrom(Base64.urlSafeDecode(keyValue))).build();
KeyData keyData = KeyData.newBuilder().setTypeUrl("type.googleapis.com/google.crypto.tink.JwtHmacKey").setValue(key.toByteString()).setKeyMaterialType(KeyData.KeyMaterialType.SYMMETRIC).build();
Keyset.Key keySetKey = Keyset.Key.newBuilder().setKeyData(keyData).setKeyId(123).setStatus(KeyStatusType.ENABLED).setOutputPrefixType(OutputPrefixType.RAW).build();
Keyset keyset = Keyset.newBuilder().addKey(keySetKey).setPrimaryKeyId(123).build();
return CleartextKeysetHandle.fromKeyset(keyset);
}
use of com.google.crypto.tink.proto.JwtHmacKey in project tink by google.
the class JwtHmacKeyManagerTest method validateKey_wrongVersion_throws.
@Test
public void validateKey_wrongVersion_throws() throws Exception {
JwtHmacKey validKey = factory.createKey(makeJwtHmacKeyFormat(32, JwtHmacAlgorithm.HS256));
assertThrows(GeneralSecurityException.class, () -> manager.validateKey(JwtHmacKey.newBuilder(validKey).setVersion(1).build()));
}
use of com.google.crypto.tink.proto.JwtHmacKey in project tink by google.
the class JwtHmacKeyManagerTest method createKey_checkValues.
@Test
public void createKey_checkValues() throws Exception {
JwtHmacKeyFormat keyFormat = makeJwtHmacKeyFormat(32, JwtHmacAlgorithm.HS256);
JwtHmacKey key = factory.createKey(keyFormat);
assertThat(key.getKeyValue()).hasSize(keyFormat.getKeySize());
assertThat(key.getAlgorithm()).isEqualTo(keyFormat.getAlgorithm());
}
Aggregations