Skip to content

Commit

Permalink
add fake proof source/verifier
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Zhang <danzh@google.com>
  • Loading branch information
danzh1989 committed May 8, 2019
1 parent af6e1b6 commit 3253b11
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once

#include "quiche/quic/core/crypto/proof_source.h"
#include "quiche/quic/platform/api/quic_reference_counted.h"

namespace Envoy {

class EnvoyQuicFakeProofSource : public quic::ProofSource {
public:
EnvoyQuicFakeProofSource() {}
~EnvoyQuicFakeProofSource() override {}

// ProofSource
void GetProof(const quic::QuicSocketAddress& server_address, const std::string& hostname,
const std::string& server_config, quic::QuicTransportVersion transport_version,
quic::QuicStringPiece chlo_hash,
std::unique_ptr<quic::Callback> callback) override {
quic::QuicReferenceCountedPointer<quic::ProofSource::Chain> chain =
GetCertChain(server_address, hostname);
quic::QuicCryptoProof proof;
proof.signature = "Dummy signature";
proof.leaf_cert_scts = "Dummy timestamp";
callback->Run(true, chain, proof, nullptr /* details */);
}

quic::QuicReferenceCountedPointer<Chain>
GetCertChain(const quic::QuicSocketAddress& server_address,
const std::string& hostname) override {
std::vector<std::string> certs;
certs.push_back(kDummyCertName);
return quic::QuicReferenceCountedPointer<quic::ProofSource::Chain>(
new quic::ProofSource::Chain(certs));
}

void ComputeTlsSignature(const quic::QuicSocketAddress& server_address,
const std::string& hostname, uint16_t signature_algorithm,
quic::QuicStringPiece in,
std::unique_ptr<quic::SignatureCallback> callback) override {
callback->Run(true, "Dummy signature");
}
};

} // namespace Envoy
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include "quiche/quic/core/crypto/proof_verifier.h"

namespace Envoy {

class EnvoyQuicFakeProofVerifier : public quic::ProofVerifier {
public:
EnvoyQuicFakeProofVerifier() {}
~EnvoyQuicFakeProofVerifier() override {}

quic::QuicAsyncStatus
VerifyProof(const string& /*hostname*/, const uint16_t /*port*/, const string& /*server_config*/,
quic::QuicTransportVersion /*quic_version*/, absl::string_view /*chlo_hash*/,
const std::vector<string>& /*certs*/, const string& /*cert_sct*/,
const string& /*signature*/, const quic::ProofVerifyContext* /*context*/,
string* /*error_details*/, std::unique_ptr<quic::ProofVerifyDetails>* /*details*/,
std::unique_ptr<quic::ProofVerifierCallback> /*callback*/) override {
return quic::QUIC_SUCCESS;
}
quic::QuicAsyncStatus
VerifyCertChain(const string& /*hostname*/, const std::vector<string>& /*certs*/,
const quic::ProofVerifyContext* /*context*/, string* /*error_details*/,
std::unique_ptr<quic::ProofVerifyDetails>* /*details*/,
std::unique_ptr<quic::ProofVerifierCallback> /*callback*/) override {
return quic::QUIC_SUCCESS;
}
std::unique_ptr<quic::ProofVerifyContext> CreateDefaultContext() override { return nullptr; }
};

} // namespace Envoy

0 comments on commit 3253b11

Please sign in to comment.