Skip to content
Snippets Groups Projects
hkdf.h 1.79 KiB
Newer Older
Quan Nguyen's avatar
Quan Nguyen committed
// Copyright 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////////////

#ifndef TINK_SUBTLE_HKDF_H_
#define TINK_SUBTLE_HKDF_H_

#include "absl/strings/string_view.h"
#include "tink/subtle/common_enums.h"
#include "tink/util/status.h"
#include "tink/util/statusor.h"
Quan Nguyen's avatar
Quan Nguyen committed

namespace crypto {
namespace tink {
namespace subtle {
Quan Nguyen's avatar
Quan Nguyen committed

class Hkdf {
 public:
  // Computes hkdf according to RFC5869.
  static crypto::tink::util::StatusOr<std::string> ComputeHkdf(
      absl::string_view ikm,
      absl::string_view salt,
      absl::string_view info,

  // Computes symmetric key for ECIES with HKDF from the provided parameters.
  // This function follows Shoup's recommendation of including ECIES
  // ephemeral KEM bytes into the commputation of the symmetric key
  // (cf. http://eprint.iacr.org/2001/112.pdf, Sections 15.6 and 15.6.1)
  static crypto::tink::util::StatusOr<std::string> ComputeEciesHkdfSymmetricKey(
      absl::string_view kem_bytes,
      absl::string_view shared_secret,
      absl::string_view salt,
      absl::string_view info,
Quan Nguyen's avatar
Quan Nguyen committed
};
}  // namespace subtle
Quan Nguyen's avatar
Quan Nguyen committed
}  // namespace tink
}  // namespace crypto

#endif  // TINK_SUBTLE_HKDF_H_