mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cleanup: replace C for loops with range
This commit is contained in:
@@ -63,7 +63,7 @@ fn encrypt_block_generic(xk []u32, dst, src []byte) {
|
||||
mut t1 := u32(0)
|
||||
mut t2 := u32(0)
|
||||
mut t3 := u32(0)
|
||||
for r := 0; r < nr; r++ {
|
||||
for r in 0..nr {
|
||||
t0 = xk[k+0] ^ te0[byte(s0>>24)] ^ te1[byte(s1>>16)] ^ te2[byte(s2>>8)] ^ u32(te3[byte(s3)])
|
||||
t1 = xk[k+1] ^ te0[byte(s1>>24)] ^ te1[byte(s2>>16)] ^ te2[byte(s3>>8)] ^ u32(te3[byte(s0)])
|
||||
t2 = xk[k+2] ^ te0[byte(s2>>24)] ^ te1[byte(s3>>16)] ^ te2[byte(s0>>8)] ^ u32(te3[byte(s1)])
|
||||
@@ -115,7 +115,7 @@ fn decrypt_block_generic(xk []u32, dst, src []byte) {
|
||||
mut t1 := u32(0)
|
||||
mut t2 := u32(0)
|
||||
mut t3 := u32(0)
|
||||
for r := 0; r < nr; r++ {
|
||||
for r in 0..nr {
|
||||
t0 = xk[k+0] ^ td0[byte(s0>>24)] ^ td1[byte(s3>>16)] ^ td2[byte(s2>>8)] ^ u32(td3[byte(s1)])
|
||||
t1 = xk[k+1] ^ td0[byte(s1>>24)] ^ td1[byte(s0>>16)] ^ td2[byte(s3>>8)] ^ u32(td3[byte(s2)])
|
||||
t2 = xk[k+2] ^ td0[byte(s2>>24)] ^ td1[byte(s1>>16)] ^ td2[byte(s0>>8)] ^ u32(td3[byte(s3)])
|
||||
@@ -189,7 +189,7 @@ fn expand_key_generic(key []byte, enc mut []u32, dec mut []u32) {
|
||||
n := enc.len
|
||||
for i = 0; i < n; i += 4 {
|
||||
ei := n - i - 4
|
||||
for j := 0; j < 4; j++ {
|
||||
for j in 0..4 {
|
||||
mut x := enc[ei+j]
|
||||
if i > 0 && i+4 < n {
|
||||
x = td0[s_box0[x>>24]] ^ td1[s_box0[x>>16&0xff]] ^ td2[s_box0[x>>8&0xff]] ^ td3[s_box0[x&u32(0xff)]]
|
||||
|
||||
Reference in New Issue
Block a user