Skip to content

Commit

Permalink
quic: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Mar 30, 2023
1 parent ed2039a commit 265a245
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
32 changes: 16 additions & 16 deletions src/quic/tokens.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ StatelessResetToken StatelessResetToken::kInvalid;
// ============================================================================
// RetryToken and RegularToken
namespace {
ngtcp2_vec generate_retry_token(uint8_t* buffer,
uint64_t version,
const SocketAddress& address,
const CID& retry_cid,
const CID& odcid,
const TokenSecret& token_secret) {
ngtcp2_vec GenerateRetryToken(uint8_t* buffer,
uint32_t version,
const SocketAddress& address,
const CID& retry_cid,
const CID& odcid,
const TokenSecret& token_secret) {
ssize_t ret =
ngtcp2_crypto_generate_retry_token(buffer,
token_secret,
Expand All @@ -148,10 +148,10 @@ ngtcp2_vec generate_retry_token(uint8_t* buffer,
return {buffer, static_cast<size_t>(ret)};
}

ngtcp2_vec generate_regular_token(uint8_t* buffer,
uint64_t version,
const SocketAddress& address,
const TokenSecret& token_secret) {
ngtcp2_vec GenerateRegularToken(uint8_t* buffer,
uint32_t version,
const SocketAddress& address,
const TokenSecret& token_secret) {
ssize_t ret =
ngtcp2_crypto_generate_regular_token(buffer,
token_secret,
Expand All @@ -168,13 +168,13 @@ ngtcp2_vec generate_regular_token(uint8_t* buffer,
}
} // namespace

RetryToken::RetryToken(uint64_t version,
RetryToken::RetryToken(uint32_t version,
const SocketAddress& address,
const CID& retry_cid,
const CID& odcid,
const TokenSecret& token_secret)
: buf_(),
ptr_(generate_retry_token(
ptr_(GenerateRetryToken(
buf_, version, address, retry_cid, odcid, token_secret)) {}

RetryToken::RetryToken(const uint8_t* token, size_t size)
Expand All @@ -183,7 +183,7 @@ RetryToken::RetryToken(const uint8_t* token, size_t size)
DCHECK_IMPLIES(token == nullptr, size = 0);
}

std::optional<CID> RetryToken::Validate(uint64_t version,
std::optional<CID> RetryToken::Validate(uint32_t version,
const SocketAddress& addr,
const CID& dcid,
const TokenSecret& token_secret,
Expand Down Expand Up @@ -213,19 +213,19 @@ RetryToken::operator const ngtcp2_vec*() const {
return &ptr_;
}

RegularToken::RegularToken(uint64_t version,
RegularToken::RegularToken(uint32_t version,
const SocketAddress& address,
const TokenSecret& token_secret)
: buf_(),
ptr_(generate_regular_token(buf_, version, address, token_secret)) {}
ptr_(GenerateRegularToken(buf_, version, address, token_secret)) {}

RegularToken::RegularToken(const uint8_t* token, size_t size)
: ptr_(ngtcp2_vec{const_cast<uint8_t*>(token), size}) {
DCHECK_LE(size, RegularToken::kRegularTokenLen);
DCHECK_IMPLIES(token == nullptr, size = 0);
}

bool RegularToken::Validate(uint64_t version,
bool RegularToken::Validate(uint32_t version,
const SocketAddress& addr,
const TokenSecret& token_secret,
uint64_t verification_expiration) {
Expand Down
8 changes: 4 additions & 4 deletions src/quic/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class RetryToken final : public MemoryRetainer {
static constexpr uint64_t QUIC_MIN_RETRYTOKEN_EXPIRATION = 1 * NGTCP2_SECONDS;

// Generates a new retry token.
RetryToken(uint64_t version,
RetryToken(uint32_t version,
const SocketAddress& address,
const CID& retry_cid,
const CID& odcid,
Expand All @@ -176,7 +176,7 @@ class RetryToken final : public MemoryRetainer {
// the embedded original CID will be extracted from the token an
// returned. If the token is invalid, std::nullopt will be returned.
std::optional<CID> Validate(
uint64_t version,
uint32_t version,
const SocketAddress& address,
const CID& cid,
const TokenSecret& token_secret,
Expand Down Expand Up @@ -212,7 +212,7 @@ class RegularToken final : public MemoryRetainer {
1 * NGTCP2_SECONDS;

// Generates a new retry token.
RegularToken(uint64_t version,
RegularToken(uint32_t version,
const SocketAddress& address,
const TokenSecret& token_secret);

Expand All @@ -221,7 +221,7 @@ class RegularToken final : public MemoryRetainer {

// Validates the retry token given the input.
bool Validate(
uint64_t version,
uint32_t version,
const SocketAddress& address,
const TokenSecret& token_secret,
uint64_t verification_expiration = QUIC_DEFAULT_REGULARTOKEN_EXPIRATION);
Expand Down

0 comments on commit 265a245

Please sign in to comment.