xref: /aosp_15_r20/external/tink/cc/subtle/ed25519_verify_boringssl.h (revision e7b1675dde1b92d52ec075b0a92829627f2c52a5)
1 // Copyright 2019 Google Inc.
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 ///////////////////////////////////////////////////////////////////////////////
16 
17 #ifndef TINK_SUBTLE_ED25519_VERIFY_BORINGSSL_H_
18 #define TINK_SUBTLE_ED25519_VERIFY_BORINGSSL_H_
19 
20 #include <memory>
21 #include <string>
22 #include <utility>
23 
24 #include "absl/strings/string_view.h"
25 #include "openssl/evp.h"
26 #include "tink/internal/fips_utils.h"
27 #include "tink/internal/ssl_unique_ptr.h"
28 #include "tink/public_key_verify.h"
29 #include "tink/util/statusor.h"
30 
31 namespace crypto {
32 namespace tink {
33 namespace subtle {
34 
35 class Ed25519VerifyBoringSsl : public PublicKeyVerify {
36  public:
37   static crypto::tink::util::StatusOr<std::unique_ptr<PublicKeyVerify>> New(
38       absl::string_view public_key);
39 
40   // Verifies that 'signature' is a digital signature for 'data'.
41   crypto::tink::util::Status Verify(absl::string_view signature,
42                                     absl::string_view data) const override;
43 
44   static constexpr crypto::tink::internal::FipsCompatibility kFipsStatus =
45       crypto::tink::internal::FipsCompatibility::kNotFips;
46 
47  private:
Ed25519VerifyBoringSsl(internal::SslUniquePtr<EVP_PKEY> public_key)48   explicit Ed25519VerifyBoringSsl(internal::SslUniquePtr<EVP_PKEY> public_key)
49       : public_key_(std::move(public_key)) {}
50 
51   const internal::SslUniquePtr<EVP_PKEY> public_key_;
52 };
53 
54 }  // namespace subtle
55 }  // namespace tink
56 }  // namespace crypto
57 
58 #endif  // TINK_SUBTLE_ED25519_VERIFY_BORINGSSL_H_
59