File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
src/main/java/de/rub/nds/modifiablevariable/bytearray Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 2121 *
2222 */
2323@ XmlRootElement
24- @ XmlType (propOrder = { "shuffle" , "modificationFilter" , "postModification" })
24+ @ XmlType (propOrder = {"shuffle" , "modificationFilter" , "postModification" })
2525public class ByteArrayShuffleModification extends VariableModification <byte []> {
2626
2727 private byte [] shuffle ;
@@ -41,12 +41,14 @@ protected byte[] modifyImplementationHook(final byte[] input) {
4141 }
4242 byte [] result = input .clone ();
4343 int size = input .length ;
44- for (int i = 0 ; i < shuffle .length - 1 ; i += 2 ) {
45- int p1 = (shuffle [i ] & 0xff ) % size ;
46- int p2 = (shuffle [i + 1 ] & 0xff ) % size ;
47- byte tmp = result [p1 ];
48- result [p1 ] = result [p2 ];
49- result [p2 ] = tmp ;
44+ if (size != 0 ) {
45+ for (int i = 0 ; i < shuffle .length - 1 ; i += 2 ) {
46+ int p1 = (shuffle [i ] & 0xff ) % size ;
47+ int p2 = (shuffle [i + 1 ] & 0xff ) % size ;
48+ byte tmp = result [p1 ];
49+ result [p1 ] = result [p2 ];
50+ result [p2 ] = tmp ;
51+ }
5052 }
5153 return result ;
5254 }
You can’t perform that action at this time.
0 commit comments