HmacKeyManager extends KeyTypeManager<HmacKey> { public static final KeyTemplate hmacSha256Template() { return createTemplate(32, 32, HashType.SHA256); } HmacKeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override KeyMaterialType keyMaterialType(); @Override void validateKey(HmacKey key); @Override HmacKey parseKey(ByteString byteString); @Override KeyFactory<HmacKeyFormat, HmacKey> keyFactory(); static void register(boolean newKeyAllowed); static final KeyTemplate hmacSha256HalfDigestTemplate(); static final KeyTemplate hmacSha256Template(); static final KeyTemplate hmacSha512HalfDigestTemplate(); static final KeyTemplate hmacSha512Template();  }
@Test public void testHmacSha256Template() throws Exception { KeyTemplate template = HmacKeyManager.hmacSha256Template(); assertThat(template.getTypeUrl()).isEqualTo(new HmacKeyManager().getKeyType()); assertThat(template.getOutputPrefixType()).isEqualTo(KeyTemplate.OutputPrefixType.TINK); HmacKeyFormat format = HmacKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry()); assertThat(format.getKeySize()).isEqualTo(32); assertThat(format.getParams().getTagSize()).isEqualTo(32); assertThat(format.getParams().getHash()).isEqualTo(HashType.SHA256); }