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_SIGN_BORINGSSL_H_ 18 #define TINK_SUBTLE_ED25519_SIGN_BORINGSSL_H_ 19 20 #include <memory> 21 #include <string> 22 #include <utility> 23 24 #include "openssl/evp.h" 25 #include "tink/config/tink_fips.h" 26 #include "tink/internal/ssl_unique_ptr.h" 27 #include "tink/public_key_sign.h" 28 #include "tink/util/secret_data.h" 29 #include "tink/util/statusor.h" 30 31 namespace crypto { 32 namespace tink { 33 namespace subtle { 34 35 class Ed25519SignBoringSsl : public PublicKeySign { 36 public: 37 static crypto::tink::util::StatusOr<std::unique_ptr<PublicKeySign>> New( 38 util::SecretData private_key); 39 40 // Computes the signature for 'data'. 41 crypto::tink::util::StatusOr<std::string> Sign( 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: Ed25519SignBoringSsl(internal::SslUniquePtr<EVP_PKEY> priv_key)48 explicit Ed25519SignBoringSsl(internal::SslUniquePtr<EVP_PKEY> priv_key) 49 : priv_key_(std::move(priv_key)) {} 50 51 const internal::SslUniquePtr<EVP_PKEY> priv_key_; 52 }; 53 54 } // namespace subtle 55 } // namespace tink 56 } // namespace crypto 57 58 #endif // TINK_SUBTLE_ED25519_SIGN_BORINGSSL_H_ 59