A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/commit/857efee6d2d43c5c12fc7e377ce437144c728ab8 below:

Fix buffer overflows in _sha3 module (GH-98519) (#98526) · python/cpython@857efee · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+18

-7

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+18

-7

lines changed Original file line number Diff line number Diff line change

@@ -497,6 +497,15 @@ def test_case_md5_huge(self, size):

497 497

def test_case_md5_uintmax(self, size):

498 498

self.check('md5', b'A'*size, '28138d306ff1b8281f1a9067e1a1a2b3')

499 499 500 +

@unittest.skipIf(sys.maxsize < _4G - 1, 'test cannot run on 32-bit systems')

501 +

@bigmemtest(size=_4G - 1, memuse=1, dry_run=False)

502 +

def test_sha3_update_overflow(self, size):

503 +

"""Regression test for gh-98517 CVE-2022-37454."""

504 +

h = hashlib.sha3_224()

505 +

h.update(b'\x01')

506 +

h.update(b'\x01'*0xffff_ffff)

507 +

self.assertEqual(h.hexdigest(), '80762e8ce6700f114fec0f621fd97c4b9c00147fa052215294cceeed')

508 + 500 509

# use the three examples from Federal Information Processing Standards

501 510

# Publication 180-1, Secure Hash Standard, 1995 April 17

502 511

# http://www.itl.nist.gov/div897/pubs/fip180-1.htm

Original file line number Diff line number Diff line change

@@ -0,0 +1 @@

1 +

Port XKCP's fix for the buffer overflows in SHA-3 (CVE-2022-37454).

Original file line number Diff line number Diff line change

@@ -171,7 +171,7 @@ int SpongeAbsorb(SpongeInstance *instance, const unsigned char *data, size_t dat

171 171

i = 0;

172 172

curData = data;

173 173

while(i < dataByteLen) {

174 -

if ((instance->byteIOIndex == 0) && (dataByteLen >= (i + rateInBytes))) {

174 +

if ((instance->byteIOIndex == 0) && (dataByteLen-i >= rateInBytes)) {

175 175

#ifdef SnP_FastLoop_Absorb

176 176

/* processing full blocks first */

177 177

@@ -199,10 +199,10 @@ int SpongeAbsorb(SpongeInstance *instance, const unsigned char *data, size_t dat

199 199

}

200 200

else {

201 201

/* normal lane: using the message queue */

202 - 203 -

partialBlock = (unsigned int)(dataByteLen - i);

204 -

if (partialBlock+instance->byteIOIndex > rateInBytes)

202 +

if (dataByteLen-i > rateInBytes-instance->byteIOIndex)

205 203

partialBlock = rateInBytes-instance->byteIOIndex;

204 +

else

205 +

partialBlock = (unsigned int)(dataByteLen - i);

206 206

#ifdef KeccakReference

207 207

displayBytes(1, "Block to be absorbed (part)", curData, partialBlock);

208 208

#endif

@@ -281,7 +281,7 @@ int SpongeSqueeze(SpongeInstance *instance, unsigned char *data, size_t dataByte

281 281

i = 0;

282 282

curData = data;

283 283

while(i < dataByteLen) {

284 -

if ((instance->byteIOIndex == rateInBytes) && (dataByteLen >= (i + rateInBytes))) {

284 +

if ((instance->byteIOIndex == rateInBytes) && (dataByteLen-i >= rateInBytes)) {

285 285

for(j=dataByteLen-i; j>=rateInBytes; j-=rateInBytes) {

286 286

SnP_Permute(instance->state);

287 287

SnP_ExtractBytes(instance->state, curData, 0, rateInBytes);

@@ -299,9 +299,10 @@ int SpongeSqueeze(SpongeInstance *instance, unsigned char *data, size_t dataByte

299 299

SnP_Permute(instance->state);

300 300

instance->byteIOIndex = 0;

301 301

}

302 -

partialBlock = (unsigned int)(dataByteLen - i);

303 -

if (partialBlock+instance->byteIOIndex > rateInBytes)

302 +

if (dataByteLen-i > rateInBytes-instance->byteIOIndex)

304 303

partialBlock = rateInBytes-instance->byteIOIndex;

304 +

else

305 +

partialBlock = (unsigned int)(dataByteLen - i);

305 306

i += partialBlock;

306 307 307 308

SnP_ExtractBytes(instance->state, curData, instance->byteIOIndex, partialBlock);

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4