def new_hmac_prf_key_template(self, hash_type, key_size): key_format = hmac_prf_pb2.HmacPrfKeyFormat() key_format.params.hash = hash_type key_format.key_size = key_size key_format.version = 0 key_template = tink_pb2.KeyTemplate() key_template.type_url = 'type.googleapis.com/google.crypto.tink.HmacPrfKey' key_template.value = key_format.SerializeToString() return key_template.SerializeToString()
def _create_hmac_key_template( key_size: int, hash_type: common_pb2.HashType) -> tink_pb2.KeyTemplate: """Creates an HMAC PRF KeyTemplate, and fills in its values.""" key_format = hmac_prf_pb2.HmacPrfKeyFormat() key_format.params.hash = hash_type key_format.key_size = key_size key_format.version = 0 key_template = tink_pb2.KeyTemplate() key_template.value = key_format.SerializeToString() key_template.type_url = _HMAC_PRF_KEY_TYPE_URL key_template.output_prefix_type = tink_pb2.RAW return key_template