xref: /aosp_15_r20/external/tink/cc/signature/signature_public_key.h (revision e7b1675dde1b92d52ec075b0a92829627f2c52a5)
1*e7b1675dSTing-Kang Chang // Copyright 2023 Google LLC
2*e7b1675dSTing-Kang Chang //
3*e7b1675dSTing-Kang Chang // Licensed under the Apache License, Version 2.0 (the "License");
4*e7b1675dSTing-Kang Chang // you may not use this file except in compliance with the License.
5*e7b1675dSTing-Kang Chang // You may obtain a copy of the License at
6*e7b1675dSTing-Kang Chang //
7*e7b1675dSTing-Kang Chang //      http://www.apache.org/licenses/LICENSE-2.0
8*e7b1675dSTing-Kang Chang //
9*e7b1675dSTing-Kang Chang // Unless required by applicable law or agreed to in writing, software
10*e7b1675dSTing-Kang Chang // distributed under the License is distributed on an "AS IS" BASIS,
11*e7b1675dSTing-Kang Chang // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*e7b1675dSTing-Kang Chang // See the License for the specific language governing permissions and
13*e7b1675dSTing-Kang Chang // limitations under the License.
14*e7b1675dSTing-Kang Chang //
15*e7b1675dSTing-Kang Chang ////////////////////////////////////////////////////////////////////////////////
16*e7b1675dSTing-Kang Chang 
17*e7b1675dSTing-Kang Chang #ifndef TINK_SIGNATURE_SIGNATURE_PUBLIC_KEY_H_
18*e7b1675dSTing-Kang Chang #define TINK_SIGNATURE_SIGNATURE_PUBLIC_KEY_H_
19*e7b1675dSTing-Kang Chang 
20*e7b1675dSTing-Kang Chang #include "absl/strings/string_view.h"
21*e7b1675dSTing-Kang Chang #include "tink/key.h"
22*e7b1675dSTing-Kang Chang #include "tink/signature/signature_parameters.h"
23*e7b1675dSTing-Kang Chang 
24*e7b1675dSTing-Kang Chang namespace crypto {
25*e7b1675dSTing-Kang Chang namespace tink {
26*e7b1675dSTing-Kang Chang 
27*e7b1675dSTing-Kang Chang // Represents a function to verify digital signatures.
28*e7b1675dSTing-Kang Chang class SignaturePublicKey : public Key {
29*e7b1675dSTing-Kang Chang  public:
30*e7b1675dSTing-Kang Chang   // Returns the bytes prefixed to every signature generated by the
31*e7b1675dSTing-Kang Chang   // corresponding private key.
32*e7b1675dSTing-Kang Chang   //
33*e7b1675dSTing-Kang Chang   // In order to make key rotation more efficient, Tink allows every signature
34*e7b1675dSTing-Kang Chang   // public key to have an associated signature output prefix. When verifying a
35*e7b1675dSTing-Kang Chang   // digital signature, only keys with a matching prefix have to be tried.
36*e7b1675dSTing-Kang Chang   //
37*e7b1675dSTing-Kang Chang   // See https://developers.google.com/tink/wire-format#tink_output_prefix for
38*e7b1675dSTing-Kang Chang   // more background information on Tink output prefixes.
39*e7b1675dSTing-Kang Chang   virtual absl::string_view GetOutputPrefix() const = 0;
40*e7b1675dSTing-Kang Chang 
41*e7b1675dSTing-Kang Chang   const SignatureParameters& GetParameters() const override = 0;
42*e7b1675dSTing-Kang Chang 
43*e7b1675dSTing-Kang Chang   bool operator==(const Key& other) const override = 0;
44*e7b1675dSTing-Kang Chang };
45*e7b1675dSTing-Kang Chang 
46*e7b1675dSTing-Kang Chang }  // namespace tink
47*e7b1675dSTing-Kang Chang }  // namespace crypto
48*e7b1675dSTing-Kang Chang 
49*e7b1675dSTing-Kang Chang #endif  // TINK_SIGNATURE_SIGNATURE_PUBLIC_KEY_H_
50