• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DILITHIUM_AVX2_SIGN_H_
18 #define TINK_EXPERIMENTAL_PQCRYPTO_SIGNATURE_SUBTLE_DILITHIUM_AVX2_SIGN_H_
19 
20 #include <memory>
21 #include <string>
22 #include <utility>
23 
24 #include "tink/experimental/pqcrypto/signature/subtle/dilithium_key.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 an optimized implementation of Dilithium,
35 // based on AVX2 vector instructions
36 class DilithiumAvx2Sign : public PublicKeySign {
37  public:
38   static crypto::tink::util::StatusOr<std::unique_ptr<PublicKeySign>> New(
39       DilithiumPrivateKeyPqclean private_key);
40 
41   // Computes the signature for 'data'.
42   crypto::tink::util::StatusOr<std::string> Sign(
43       absl::string_view data) const override;
44 
45   ~DilithiumAvx2Sign() override = default;
46 
47   static constexpr crypto::tink::internal::FipsCompatibility kFipsStatus =
48       crypto::tink::internal::FipsCompatibility::kNotFips;
49 
50  private:
DilithiumAvx2Sign(DilithiumPrivateKeyPqclean private_key)51   explicit DilithiumAvx2Sign(DilithiumPrivateKeyPqclean private_key)
52       : private_key_(std::move(private_key)) {}
53 
54   const DilithiumPrivateKeyPqclean private_key_;
55 };
56 
57 }  // namespace subtle
58 }  // namespace tink
59 }  // namespace crypto
60 
61 // TINK_EXPERIMENTAL_PQCRYPTO_SIGNATURE_SUBTLE_DILITHIUM_AVX2_SIGN_H_
62 #endif  // TINK_EXPERIMENTAL_PQCRYPTO_SIGNATURE_SUBTLE_DILITHIUM_AVX2_SIGN_H_
63