Commit 4261058
committed
Delay KangarooAbsorb until needed, to avoid 168 erroneous 0-byte-padding
This avoid too eagerly absorbing queued data, on queue fill-up, which would be wrong
if there were no more data to be written, and the 10*1 bit-padding should complete
within the same byte as the one which contains the start of the padding.
This bug would trigger when, e.g., a buffer of 166 bytes, and an empty personalisation,
was hashed, where the write of the "SINGLE" delimiter would fill the data queue, and
be immediately absorbed, followed by an explicit pad-and-squeeze, which would then
add another 168 0-bytes, with the final bit set. The correct would instead be to set
the final bit of the buffer after adding the "SINGLE" delimiter, and then absorb that.
Signed-off-by: Jon Marius Venstad <[email protected]>1 parent d252f96 commit 4261058
File tree
2 files changed
+21
-8
lines changed- core/src
- main/java/org/bouncycastle/crypto/digests
- test/java/org/bouncycastle/crypto/test
2 files changed
+21
-8
lines changedLines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
628 | 634 | | |
629 | 635 | | |
630 | 636 | | |
| |||
642 | 648 | | |
643 | 649 | | |
644 | 650 | | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | 651 | | |
652 | 652 | | |
653 | 653 | | |
| |||
Lines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
150 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
151 | 158 | | |
152 | 159 | | |
153 | 160 | | |
| |||
170 | 177 | | |
171 | 178 | | |
172 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
173 | 186 | | |
174 | 187 | | |
175 | 188 | | |
| |||
0 commit comments