1# Copyright 2019 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"""Interface for PublicKeyVerify.""" 16 17import abc 18 19 20class PublicKeyVerify(metaclass=abc.ABCMeta): 21 """Interface for public key verifying. 22 23 Digital Signatures provide functionality of signing data and verification of 24 the signatures. They are represented by a pair of primitives (interfaces) 25 'PublicKeySign' for signing of data, and 'PublicKeyVerify' for verification 26 of signatures. Implementations of these interfaces are secure against 27 adaptive chosen-message attacks. Signing data ensures the authenticity and 28 the integrity of that data, but not its secrecy. 29 """ 30 31 @abc.abstractmethod 32 def verify(self, signature: bytes, data: bytes) -> bytes: 33 """Verifies that signature is a digital signature for data. 34 35 Args: 36 signature: The signature bytes to be checked. 37 data: The data bytes to be checked. 38 39 Raises: 40 tink.TinkError if the verification fails. 41 """ 42 raise NotImplementedError() 43