blob: 3105b3e63eddad997af4f15ccba431e56e3fec6c [file] [log] [blame]
# Copyright 2019 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from "tink/python/util/clif.h" import * # Status, StatusOr
from clif.python.postproc import DropOkStatus
from "tink/cc/mac.h":
namespace `crypto::tink`:
# Interface for MACs (Message Authentication Codes).
# This interface should be used for authentication only, and not for other
# purposes (e.g., it should not be used to generate pseudorandom bytes).
class Mac:
# Computes and returns the message authentication code (MAC) for 'data'.
def `ComputeMac` as compute_mac(self, data: bytes) -> StatusOr<bytes>
# Verifies if 'mac' is a correct authentication code (MAC) for 'data'.
# Raises a StatusNotOk exception if the verification fails.
def `VerifyMac` as verify_mac(self, mac: bytes, data: bytes)
-> (ok: Status):
return DropOkStatus(...)