[Mono-bugs] [Bug 71062][Wis] New - ABC removal not performed for substitution boxes

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 6 Jan 2005 14:07:43 -0500 (EST)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by sebastien@ximian.com.


--- shadow/71062	2005-01-06 14:07:43.000000000 -0500
+++ shadow/71062.tmp.19678	2005-01-06 14:07:43.000000000 -0500
@@ -0,0 +1,59 @@
+Bug#: 71062
+Product: Mono: Runtime
+Version: 1.1
+OS: All
+OS Details: 
+Status: NEW   
+Priority: Wishlist
+Component: JIT
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sebastien@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: ABC removal not performed for substitution boxes
+Description of Problem:
+ABC removal doesn't seems to apply in some common pattern used in the
+cryptographic implementations.
+Let's take the case where I have a small sbox (substitution box), like in
+Rjindael (AES). The sbox is an array of 256 bytes. Now I have a method,
+SubByte, that substitute (heh it's not magic ;-) the bytes. Now the index
+is (currently) an integer, so when I execute...
+mono -v -v -v -v =O=abcrem sbox.exe 1 > sbox.v4
+...I'm not "too" surprised to see that no ABC removal was done in that
+method (even if each integer is & 0xff). The log show that ABC removal was
+attempted 4 times (as the substitution is done for each byte in the
+integer) but no success is reported in the log (ARRAY-ACCESS: Removed *).
+Anyway, I recoded the method so that the indexer is now a byte (so
+[0..255]). In this case the array bound check should not be required as it
+would be impossible for any byte value to fail to address an element in the
+However if I execute the sbox.exe application again there is still no
+removal done by mono.
+Looking at abcremoval.c I noticed the comment that the array must be local.
+So I created a local array and assigned the global one (static readonly) to
+it. This got me a little further in the abcremoval process (i.e. more logs)
+but did also show strange things (like the reference being used as if it
+was a value). Sadly it didn't make any ABC go aways with the sbox.
+Additional Information:
+- The performance for the same code is two times faster under MS.NET 1.1
+than under Mono 1.1.x (SVN). But that may not (only) be related to ABC
+- The sbox is a very common pattern in symmetric and hash algorithms. Very
+similar arrays (but not sboxes) are also used (e.g. RC2 also has it's own
+pitable of 256 elements for it's key setup).