diff --git a/hashlib/__md5.vp b/hashlib/__md5.vp index b378547..b6ed956 100644 --- a/hashlib/__md5.vp +++ b/hashlib/__md5.vp @@ -118,11 +118,11 @@ class md5: # Write total bit count bits: uint64 = self.count << 3 for i in range(8): - self.buf[MD5_BLOCK_LEN - 8 + i] = (bits >> (i * 8)) & 0xFF + self.buf[MD5_BLOCK_LEN - 8 + i] = uint8((bits >> (i * 8)) & 0xFF) self.transform(self.buf) # State registers to little-endian byte output output for i in range(4): - out[i * 4 + 0] = (self.state[i] >> 0) & 0xFF - out[i * 4 + 1] = (self.state[i] >> 8) & 0xFF - out[i * 4 + 2] = (self.state[i] >> 16) & 0xFF - out[i * 4 + 3] = (self.state[i] >> 24) & 0xFF + out[i * 4 + 0] = uint8((self.state[i] >> 0) & 0xFF) + out[i * 4 + 1] = uint8((self.state[i] >> 8) & 0xFF) + out[i * 4 + 2] = uint8((self.state[i] >> 16) & 0xFF) + out[i * 4 + 3] = uint8((self.state[i] >> 24) & 0xFF) diff --git a/hashlib/__sha1.vp b/hashlib/__sha1.vp index d25a0b6..2116072 100644 --- a/hashlib/__sha1.vp +++ b/hashlib/__sha1.vp @@ -105,11 +105,11 @@ class sha1: bits: uint64 = self.count << 3 # SHA1 big-endian write length for i in range(8): - self.buf[SHA1_BLOCK_LEN - 8 + i] = (bits >> (56 - i * 8)) & 0xFF + self.buf[SHA1_BLOCK_LEN - 8 + i] = uint8((bits >> (56 - i * 8)) & 0xFF) self.transform(self.buf) # State registers to big-endian byte output output output for i in range(5): - out[i * 4 + 0] = (self.state[i] >> 24) & 0xFF - out[i * 4 + 1] = (self.state[i] >> 16) & 0xFF - out[i * 4 + 2] = (self.state[i] >> 8) & 0xFF - out[i * 4 + 3] = (self.state[i] >> 0) & 0xFF + out[i * 4 + 0] = uint8((self.state[i] >> 24) & 0xFF) + out[i * 4 + 1] = uint8((self.state[i] >> 16) & 0xFF) + out[i * 4 + 2] = uint8((self.state[i] >> 8) & 0xFF) + out[i * 4 + 3] = uint8((self.state[i] >> 0) & 0xFF) diff --git a/hashlib/__sha256.vp b/hashlib/__sha256.vp index f2b1221..3d9ae6a 100644 --- a/hashlib/__sha256.vp +++ b/hashlib/__sha256.vp @@ -108,11 +108,11 @@ class sha256: string.memset(self.buf + idx, 0, SHA256_BLOCK_LEN - 8 - idx) bits: uint64 = self.count << 3 for i in range(8): - self.buf[SHA256_BLOCK_LEN-8+i] = (bits >> (56 - i*8)) & 0xFF + self.buf[SHA256_BLOCK_LEN-8+i] = uint8((bits >> (56 - i*8)) & 0xFF) self.transform(self.buf) # Byte order 32-bit words for i in range(8): - out[i * 4 + 0] = (self.state[i] >> 24) & 0xFF - out[i * 4 + 1] = (self.state[i] >> 16) & 0xFF - out[i * 4 + 2] = (self.state[i] >> 8) & 0xFF - out[i * 4 + 3] = (self.state[i] >> 0) & 0xFF + out[i * 4 + 0] = uint8((self.state[i] >> 24) & 0xFF) + out[i * 4 + 1] = uint8((self.state[i] >> 16) & 0xFF) + out[i * 4 + 2] = uint8((self.state[i] >> 8) & 0xFF) + out[i * 4 + 3] = uint8((self.state[i] >> 0) & 0xFF)