From b0c33c688df3aaa8fee24c542a29290a2361bc80 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 29 Aug 2024 17:05:40 -0700 Subject: [PATCH] src: linting cleanups with crypto changes --- src/crypto/crypto_hkdf.cc | 30 +++++++++++++++--------------- src/crypto/crypto_pbkdf2.cc | 19 +++++++++---------- src/crypto/crypto_scrypt.cc | 16 ++++++++-------- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/crypto/crypto_hkdf.cc b/src/crypto/crypto_hkdf.cc index 9990f11edc6e13..aebb5d718dff9e 100644 --- a/src/crypto/crypto_hkdf.cc +++ b/src/crypto/crypto_hkdf.cc @@ -102,21 +102,21 @@ bool HKDFTraits::DeriveBits( Environment* env, const HKDFConfig& params, ByteSource* out) { - auto dp = ncrypto::hkdf( - params.digest, - ncrypto::Buffer { - .data = reinterpret_cast(params.key->GetSymmetricKey()), - .len = params.key->GetSymmetricKeySize(), - }, - ncrypto::Buffer { - .data = params.info.data(), - .len = params.info.size(), - }, - ncrypto::Buffer { - .data = params.salt.data(), - .len = params.salt.size(), - }, - params.length); + auto dp = ncrypto::hkdf(params.digest, + ncrypto::Buffer{ + .data = reinterpret_cast( + params.key->GetSymmetricKey()), + .len = params.key->GetSymmetricKeySize(), + }, + ncrypto::Buffer{ + .data = params.info.data(), + .len = params.info.size(), + }, + ncrypto::Buffer{ + .data = params.salt.data(), + .len = params.salt.size(), + }, + params.length); if (!dp) return false; *out = ByteSource::Allocated(dp.release()); diff --git a/src/crypto/crypto_pbkdf2.cc b/src/crypto/crypto_pbkdf2.cc index 645be2f10870a7..017b0085891c0d 100644 --- a/src/crypto/crypto_pbkdf2.cc +++ b/src/crypto/crypto_pbkdf2.cc @@ -111,18 +111,17 @@ Maybe PBKDF2Traits::AdditionalConfig( return Just(true); } -bool PBKDF2Traits::DeriveBits( - Environment* env, - const PBKDF2Config& params, - ByteSource* out) { - +bool PBKDF2Traits::DeriveBits(Environment* env, + const PBKDF2Config& params, + ByteSource* out) { // Both pass and salt may be zero length here. auto dp = ncrypto::pbkdf2( - params.digest, - ncrypto::Buffer(params.pass.data(), params.pass.size()), - ncrypto::Buffer(params.salt.data(), params.salt.size()), - params.iterations, - params.length); + params.digest, + ncrypto::Buffer(params.pass.data(), params.pass.size()), + ncrypto::Buffer(params.salt.data(), + params.salt.size()), + params.iterations, + params.length); if (!dp) return false; *out = ByteSource::Allocated(dp.release()); diff --git a/src/crypto/crypto_scrypt.cc b/src/crypto/crypto_scrypt.cc index fb6d3d73a98b78..d0e17fd4ef0837 100644 --- a/src/crypto/crypto_scrypt.cc +++ b/src/crypto/crypto_scrypt.cc @@ -96,7 +96,8 @@ Maybe ScryptTraits::AdditionalConfig( params->length = args[offset + 6].As()->Value(); CHECK_GE(params->length, 0); - if (!ncrypto::checkScryptParams(params->N, params->r, params->p, params->maxmem)) { + if (!ncrypto::checkScryptParams( + params->N, params->r, params->p, params->maxmem)) { // Do not use CryptoErrorStore or ThrowCryptoError here in order to maintain // backward compatibility with ERR_CRYPTO_INVALID_SCRYPT_PARAMS. uint32_t err = ERR_peek_last_error(); @@ -118,7 +119,6 @@ bool ScryptTraits::DeriveBits( Environment* env, const ScryptConfig& params, ByteSource* out) { - // If the params.length is zero-length, just return an empty buffer. // It's useless, yes, but allowed via the API. if (params.length == 0) { @@ -127,13 +127,13 @@ bool ScryptTraits::DeriveBits( } auto dp = ncrypto::scrypt( - ncrypto::Buffer { - .data = params.pass.data(), - .len = params.pass.size(), + ncrypto::Buffer{ + .data = params.pass.data(), + .len = params.pass.size(), }, - ncrypto::Buffer { - .data = params.salt.data(), - .len = params.salt.size(), + ncrypto::Buffer{ + .data = params.salt.data(), + .len = params.salt.size(), }, params.N, params.r,