Skip to content

Commit 320b450

Browse files
authored
crypto: strengthen argument CHECKs in TurboSHAKE
Instead of first discarding the top 24 bits of the argument and then checking that the low 8 bits are within the expected range, first check that the original 32-bit integer is within the expected range and then discard the top 24 bits. PR-URL: #62763 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Xuguang Mei <meixuguang@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 5f02bdb commit 320b450

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/crypto/crypto_turboshake.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,10 @@ Maybe<void> TurboShakeTraits::AdditionalConfig(
449449

450450
// args[offset + 1] = domain separation byte (uint32)
451451
CHECK(args[offset + 1]->IsUint32());
452-
params->domain_separation =
453-
static_cast<uint8_t>(args[offset + 1].As<Uint32>()->Value());
454-
CHECK_GE(params->domain_separation, 0x01);
455-
CHECK_LE(params->domain_separation, 0x7F);
452+
uint32_t domain_separation_u32 = args[offset + 1].As<Uint32>()->Value();
453+
CHECK_GE(domain_separation_u32, 0x01);
454+
CHECK_LE(domain_separation_u32, 0x7F);
455+
params->domain_separation = static_cast<uint8_t>(domain_separation_u32);
456456

457457
// args[offset + 2] = output length in bytes (uint32)
458458
CHECK(args[offset + 2]->IsUint32());

0 commit comments

Comments
 (0)