| Ticket UUID: | 2155034 | |||
| Title: | Sign overflow in AddRoundKey | |||
| Type: | Bug | Version: | None | |
| Submitter: | twylite | Created on: | 2008-10-09 12:53:18 | |
| Subsystem: | aes | Assigned To: | patthoyts | |
| Priority: | 8 | Severity: | ||
| Status: | Closed | Last Modified: | 2013-01-10 15:10:06 | |
| Resolution: | Fixed | Closed By: | twylite | |
| Closed on: | 2013-01-10 08:10:06 | |||
| Description: |
There is a sign overflow in AddRoundKey that can cause
a 'integer value too large to represent' error from EncryptBlock or DecryptBlock. When expr{} xors together a positive & negative number it preserves the sign and may extend the values to 64 bit.
Similar sign overflows were fixed in EncryptBlock & DecryptBlock in aes.tcl 1.6.
To reproduce:
--
package require aes
set keyhex c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558
set texthex 46f2fb342d6f0ab477476fc501242c5f
aes::aes -dir decrypt -mode ecb -hex -key [binary format H* $keyhex] -- [binary format H* $texthex]
--
Fix: use a mask to limit the result to 32 bit
Change to aes.tcl:
--
proc ::aes::AddRoundKey {Key round words} {
upvar #0 $Key state
set r {}
set n [expr {$round * $state(Nb)}]
foreach w $words {
lappend r [expr {0xffffffff & ($w ^ [lindex $state(W) $n])}]
incr n
}
return $r
}
--
Additional note:
There are uses of expr{} in ExpandKey that may also overflow in a similar manner, and should be investigated.
| |||
| User Comments: |
twylite added on 2013-01-10 15:10:06:
allow_comments - 1 twylite added on 2013-01-10 15:10:05: Fixed since aes 1.0.1 (May 2008). twylite added on 2008-12-03 15:27:48: Upped the priority -- the implementation currently does not pass the NIST test suite for the AES algorithm. | |||
Home
Blog
Docs
Downloads
Tickets
Timeline
Branches
Tags
Wiki