1 // Copyright 2019 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_SUBTLE_PRF_HKDF_STREAMING_PRF_H_ 18 #define TINK_SUBTLE_PRF_HKDF_STREAMING_PRF_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/subtle/common_enums.h" 27 #include "tink/subtle/prf/streaming_prf.h" 28 #include "tink/internal/fips_utils.h" 29 #include "tink/util/secret_data.h" 30 #include "tink/util/statusor.h" 31 32 namespace crypto { 33 namespace tink { 34 namespace subtle { 35 36 class HkdfStreamingPrf : public StreamingPrf { 37 public: 38 static crypto::tink::util::StatusOr<std::unique_ptr<StreamingPrf>> New( 39 HashType hash, util::SecretData secret, absl::string_view salt); 40 41 std::unique_ptr<InputStream> ComputePrf( 42 absl::string_view input) const override; 43 44 static constexpr crypto::tink::internal::FipsCompatibility kFipsStatus = 45 crypto::tink::internal::FipsCompatibility::kNotFips; 46 47 private: HkdfStreamingPrf(const EVP_MD * hash,util::SecretData secret,absl::string_view salt)48 HkdfStreamingPrf(const EVP_MD* hash, util::SecretData secret, 49 absl::string_view salt) 50 : hash_(hash), secret_(std::move(secret)), salt_(salt) {} 51 52 const EVP_MD* hash_; 53 const util::SecretData secret_; 54 const std::string salt_; 55 }; 56 57 } // namespace subtle 58 } // namespace tink 59 } // namespace crypto 60 61 #endif // TINK_SUBTLE_PRF_HKDF_STREAMING_PRF_H_ 62