AesCmacKeyManager extends KeyTypeManager<AesCmacKey> { public static final KeyTemplate rawAes256CmacTemplate() { AesCmacKeyFormat format = AesCmacKeyFormat.newBuilder() .setKeySize(32) .setParams(AesCmacParams.newBuilder().setTagSize(16).build()) .build(); return KeyTemplate.create( new AesCmacKeyManager().getKeyType(), format.toByteArray(), KeyTemplate.OutputPrefixType.RAW); } AesCmacKeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override KeyMaterialType keyMaterialType(); @Override void validateKey(AesCmacKey key); @Override AesCmacKey parseKey(ByteString byteString); @Override KeyFactory<AesCmacKeyFormat, AesCmacKey> keyFactory(); static void register(boolean newKeyAllowed); static final KeyTemplate aes256CmacTemplate(); static final KeyTemplate rawAes256CmacTemplate();  }
@Test public void testRawAes256CmacTemplate() throws Exception { KeyTemplate template = AesCmacKeyManager.rawAes256CmacTemplate(); assertThat(template.getTypeUrl()).isEqualTo(new AesCmacKeyManager().getKeyType()); assertThat(template.getOutputPrefixType()).isEqualTo(KeyTemplate.OutputPrefixType.RAW); AesCmacKeyFormat format = AesCmacKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry()); assertThat(format.getKeySize()).isEqualTo(32); assertThat(format.getParams().getTagSize()).isEqualTo(16); }