blob: f3140db0ce485b66730efc084bea91be68b37691 [file] [log] [blame]
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <cstdint>
#include "net/third_party/quic/core/crypto/key_exchange.h"
#include "net/third_party/quic/platform/api/quic_export.h"
#include "net/third_party/quic/platform/api/quic_string.h"
#include "net/third_party/quic/platform/api/quic_string_piece.h"
namespace quic {
class QuicRandom;
// Curve25519KeyExchange implements a KeyExchange using elliptic-curve
// Diffie-Hellman on curve25519. See
class QUIC_EXPORT_PRIVATE Curve25519KeyExchange : public KeyExchange {
~Curve25519KeyExchange() override;
// New creates a new object from a private key. If the private key is
// invalid, nullptr is returned.
static std::unique_ptr<Curve25519KeyExchange> New(
QuicStringPiece private_key);
// NewPrivateKey returns a private key, generated from |rand|, suitable for
// passing to |New|.
static QuicString NewPrivateKey(QuicRandom* rand);
// KeyExchange interface.
const Factory& GetFactory() const override;
bool CalculateSharedKey(QuicStringPiece peer_public_value,
QuicString* shared_key) const override;
void CalculateSharedKey(QuicStringPiece peer_public_value,
QuicString* shared_key,
std::unique_ptr<Callback> callback) const override;
QuicStringPiece public_value() const override;
uint8_t private_key_[32];
uint8_t public_key_[32];
} // namespace quic