1 // Copyright 2021 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 /////////////////////////////////////////////////////////////////////////////// 16 17 #ifndef TINK_EXPERIMENTAL_PQCRYPTO_SIGNATURE_SUBTLE_SPHINCS_SIGN_H_ 18 #define TINK_EXPERIMENTAL_PQCRYPTO_SIGNATURE_SUBTLE_SPHINCS_SIGN_H_ 19 20 #include <memory> 21 #include <string> 22 #include <utility> 23 24 #include "tink/experimental/pqcrypto/signature/subtle/sphincs_subtle_utils.h" 25 #include "tink/internal/fips_utils.h" 26 #include "tink/public_key_sign.h" 27 #include "tink/util/secret_data.h" 28 #include "tink/util/statusor.h" 29 30 namespace crypto { 31 namespace tink { 32 namespace subtle { 33 34 // Post-Quantum Signing using different variants of Sphincs stateless hash-based 35 // signature scheme 36 class SphincsSign : public PublicKeySign { 37 public: 38 static constexpr crypto::tink::internal::FipsCompatibility kFipsStatus = 39 crypto::tink::internal::FipsCompatibility::kNotFips; 40 41 static crypto::tink::util::StatusOr<std::unique_ptr<PublicKeySign>> New( 42 SphincsPrivateKeyPqclean key); 43 44 ~SphincsSign() override = default; 45 46 // Computes the signature for 'data'. 47 crypto::tink::util::StatusOr<std::string> Sign( 48 absl::string_view data) const override; 49 50 private: SphincsSign(SphincsPrivateKeyPqclean key)51 explicit SphincsSign(SphincsPrivateKeyPqclean key) : key_(std::move(key)) {} 52 53 const SphincsPrivateKeyPqclean key_; 54 }; 55 56 } // namespace subtle 57 } // namespace tink 58 } // namespace crypto 59 60 #endif // TINK_EXPERIMENTAL_PQCRYPTO_SIGNATURE_SUBTLE_SPHINCS_SIGN_H_ 61