Commit 73345af
Blake2bDigest: defensive improvements and cleanup
Defensive changes:
- Validate key length before copying to fail fast and avoid
unnecessary allocation on invalid input
- Add null check before zeroing chainValue in reset()
- Centralize state cleanup in reset() to avoid double-zeroing
and ensure consistent cleanup path
Code quality:
- Use explicit 64-bit literals for long fields (f1) for clarity
- Add final modifier to ROUNDS constant
- Remove redundant return statement
Minor fixes:
- Fix typo in Javadoc (Blakbe2b -> Blake2b)
- Use more efficient Pack.longToLittleEndian overload for
partial digest output, avoiding intermediate byte[] allocation1 parent 98d81fc commit 73345af
File tree
1 file changed
+14
-18
lines changed- core/src/main/java/org/bouncycastle/crypto/digests
1 file changed
+14
-18
lines changedLines changed: 14 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | 198 | | |
202 | 199 | | |
203 | 200 | | |
204 | 201 | | |
205 | 202 | | |
| 203 | + | |
| 204 | + | |
206 | 205 | | |
207 | 206 | | |
208 | 207 | | |
| |||
264 | 263 | | |
265 | 264 | | |
266 | 265 | | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | 266 | | |
271 | 267 | | |
272 | 268 | | |
273 | 269 | | |
274 | 270 | | |
| 271 | + | |
| 272 | + | |
275 | 273 | | |
276 | 274 | | |
277 | 275 | | |
| |||
386 | 384 | | |
387 | 385 | | |
388 | 386 | | |
389 | | - | |
390 | 387 | | |
391 | 388 | | |
392 | 389 | | |
| |||
471 | 468 | | |
472 | 469 | | |
473 | 470 | | |
474 | | - | |
| 471 | + | |
475 | 472 | | |
476 | 473 | | |
477 | 474 | | |
478 | 475 | | |
479 | 476 | | |
480 | 477 | | |
481 | 478 | | |
482 | | - | |
483 | 479 | | |
484 | 480 | | |
485 | 481 | | |
486 | 482 | | |
487 | 483 | | |
488 | 484 | | |
489 | | - | |
490 | | - | |
491 | | - | |
| 485 | + | |
492 | 486 | | |
493 | 487 | | |
494 | | - | |
495 | | - | |
496 | 488 | | |
497 | 489 | | |
498 | 490 | | |
| |||
507 | 499 | | |
508 | 500 | | |
509 | 501 | | |
510 | | - | |
| 502 | + | |
511 | 503 | | |
512 | 504 | | |
513 | 505 | | |
514 | | - | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
515 | 511 | | |
516 | 512 | | |
517 | 513 | | |
| |||
0 commit comments