1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

crypto.[md5/rc4/sha1]: remove extraneous casts

This commit is contained in:
joe-conigliaro
2019-09-26 21:57:31 +10:00
committed by Alexander Medvednikov
parent f1f720cc78
commit c069525e8c
4 changed files with 14 additions and 14 deletions

View File

@@ -48,7 +48,7 @@ fn (d mut Digest) reset() {
d.h[3] = u32(Init3)
d.h[4] = u32(Init4)
d.nx = 0
d.len = u64(0)
d.len = 0
}
// new returns a new Digest (implementing hash.Hash) computing the SHA1 checksum.
@@ -115,7 +115,7 @@ fn (d mut Digest) checksum() []byte {
}
// Length in bits.
len <<= u64(3)
len <<= 3
binary.big_endian_put_u64(mut tmp, len)
d.write(tmp.left(8))

View File

@@ -30,7 +30,7 @@ fn block_generic(dig mut Digest, p_ []byte) {
// rounds below if needed for speed.
for i := 0; i < 16; i++ {
j := i * 4
w[i] = u32(u32(p[j])<<u32(24)) | u32(u32(p[j+1])<<u32(16)) | u32(u32(p[j+2])<<u32(8)) | u32(u32(p[j+3]))
w[i] = u32(p[j]<<24) | u32(p[j+1]<<16) | u32(p[j+2]<<8) | u32(p[j+3])
}
mut a := h0
@@ -44,7 +44,7 @@ fn block_generic(dig mut Digest, p_ []byte) {
// the choice of K (_K0, _K1, etc).
mut i := 0
for i < 16 {
f := u32(b&c | (~b)&d)
f := b&c | (~b)&d
t := bits.rotate_left_32(a, 5) + f + e + w[i&0xf] + u32(_K0)
e = d
d = c
@@ -55,7 +55,7 @@ fn block_generic(dig mut Digest, p_ []byte) {
}
for i < 20 {
tmp := w[(i-3)&0xf] ^ w[(i-8)&0xf] ^ w[(i-14)&0xf] ^ w[(i)&0xf]
w[i&0xf] = u32(tmp<<u32(1)) | u32(tmp>>u32(32-1))
w[i&0xf] = tmp<<1 | u32(tmp>>(32-1))
f := b&c | (~b)&d
t := bits.rotate_left_32(a, 5) + f + e + w[i&0xf] + u32(_K0)
e = d
@@ -67,7 +67,7 @@ fn block_generic(dig mut Digest, p_ []byte) {
}
for i < 40 {
tmp := w[(i-3)&0xf] ^ w[(i-8)&0xf] ^ w[(i-14)&0xf] ^ w[(i)&0xf]
w[i&0xf] = u32(tmp<<u32(1)) | u32(tmp>>u32(32-1))
w[i&0xf] = tmp<<1 | u32(tmp>>(32-1))
f := b ^ c ^ d
t := bits.rotate_left_32(a, 5) + f + e + w[i&0xf] + u32(_K1)
e = d
@@ -79,7 +79,7 @@ fn block_generic(dig mut Digest, p_ []byte) {
}
for i < 60 {
tmp := w[(i-3)&0xf] ^ w[(i-8)&0xf] ^ w[(i-14)&0xf] ^ w[(i)&0xf]
w[i&0xf] = u32(tmp<<u32(1)) | u32(tmp>>u32(32-1))
w[i&0xf] = tmp<<1 | u32(tmp>>(32-1))
f := ((b | c) & d) | (b & c)
t := bits.rotate_left_32(a, 5) + f + e + w[i&0xf] + u32(_K2)
e = d
@@ -91,7 +91,7 @@ fn block_generic(dig mut Digest, p_ []byte) {
}
for i < 80 {
tmp := w[(i-3)&0xf] ^ w[(i-8)&0xf] ^ w[(i-14)&0xf] ^ w[(i)&0xf]
w[i&0xf] = u32(tmp<<u32(1)) | u32(tmp>>u32(32-1))
w[i&0xf] = tmp<<1 | u32(tmp>>(32-1))
f := b ^ c ^ d
t := bits.rotate_left_32(a, 5) + f + e + w[i&0xf] + u32(_K3)
e = d