mirror of
https://github.com/vlang/v.git
synced 2025-08-03 09:47:15 -04:00
crypto: cleanup the internal constant declarations
This commit is contained in:
parent
71784e2342
commit
aa4c06c5a8
@ -15,10 +15,10 @@ pub const size = 16
|
||||
// The blocksize of MD5 in bytes.
|
||||
pub const block_size = 64
|
||||
|
||||
const init0 = 0x67452301
|
||||
const init0 = u32(0x67452301)
|
||||
const init1 = u32(0xEFCDAB89)
|
||||
const init2 = u32(0x98BADCFE)
|
||||
const init3 = 0x10325476
|
||||
const init3 = u32(0x10325476)
|
||||
|
||||
// Digest represents the partial evaluation of a checksum.
|
||||
struct Digest {
|
||||
@ -110,9 +110,7 @@ pub fn (d &Digest) sum(b_in []u8) []u8 {
|
||||
mut d0 := d.clone()
|
||||
hash := d0.checksum()
|
||||
mut b_out := b_in.clone()
|
||||
for b in hash {
|
||||
b_out << b
|
||||
}
|
||||
b_out << hash
|
||||
return b_out
|
||||
}
|
||||
|
||||
|
@ -16,10 +16,10 @@ pub const size = 20
|
||||
pub const block_size = 64
|
||||
|
||||
const chunk = 64
|
||||
const init0 = 0x67452301
|
||||
const init0 = u32(0x67452301)
|
||||
const init1 = u32(0xEFCDAB89)
|
||||
const init2 = u32(0x98BADCFE)
|
||||
const init3 = 0x10325476
|
||||
const init3 = u32(0x10325476)
|
||||
const init4 = u32(0xC3D2E1F0)
|
||||
|
||||
// digest represents the partial evaluation of a checksum.
|
||||
@ -124,6 +124,7 @@ pub fn (d &Digest) sum(b_in []u8) []u8 {
|
||||
}
|
||||
|
||||
// checksum returns the current byte checksum of the `Digest`,
|
||||
@[direct_array_access]
|
||||
fn (mut d Digest) checksum() []u8 {
|
||||
mut len := d.len
|
||||
// Padding. Add a 1 bit and 0 bits until 56 bytes mod 64.
|
||||
|
@ -8,8 +8,8 @@ module sha1
|
||||
|
||||
import math.bits
|
||||
|
||||
const _k0 = 0x5A827999
|
||||
const _k1 = 0x6ED9EBA1
|
||||
const _k0 = u32(0x5A827999)
|
||||
const _k1 = u32(0x6ED9EBA1)
|
||||
const _k2 = u32(0x8F1BBCDC)
|
||||
const _k3 = u32(0xCA62C1D6)
|
||||
|
||||
|
@ -17,21 +17,21 @@ pub const size224 = 28
|
||||
pub const block_size = 64
|
||||
|
||||
const chunk = 64
|
||||
const init0 = 0x6A09E667
|
||||
const init0 = u32(0x6A09E667)
|
||||
const init1 = u32(0xBB67AE85)
|
||||
const init2 = 0x3C6EF372
|
||||
const init2 = u32(0x3C6EF372)
|
||||
const init3 = u32(0xA54FF53A)
|
||||
const init4 = 0x510E527F
|
||||
const init4 = u32(0x510E527F)
|
||||
const init5 = u32(0x9B05688C)
|
||||
const init6 = 0x1F83D9AB
|
||||
const init7 = 0x5BE0CD19
|
||||
const init6 = u32(0x1F83D9AB)
|
||||
const init7 = u32(0x5BE0CD19)
|
||||
const init0_224 = u32(0xC1059ED8)
|
||||
const init1_224 = 0x367CD507
|
||||
const init2_224 = 0x3070DD17
|
||||
const init1_224 = u32(0x367CD507)
|
||||
const init2_224 = u32(0x3070DD17)
|
||||
const init3_224 = u32(0xF70E5939)
|
||||
const init4_224 = u32(0xFFC00B31)
|
||||
const init5_224 = 0x68581511
|
||||
const init6_224 = 0x64F98FA7
|
||||
const init5_224 = u32(0x68581511)
|
||||
const init6_224 = u32(0x64F98FA7)
|
||||
const init7_224 = u32(0xBEFA4FA4)
|
||||
|
||||
// digest represents the partial evaluation of a checksum.
|
||||
@ -165,6 +165,7 @@ pub fn (d &Digest) sum(b_in []u8) []u8 {
|
||||
|
||||
// checksum returns the current byte checksum of the Digest,
|
||||
// it is an internal method and is not recommended because its results are not idempotent.
|
||||
@[direct_array_access]
|
||||
fn (mut d Digest) checksum() []u8 {
|
||||
mut len := d.len
|
||||
// Padding. Add a 1 bit and 0 bits until 56 bytes mod 64.
|
||||
|
Loading…
x
Reference in New Issue
Block a user