diff --git a/vlib/crypto/cipher/cfb.v b/vlib/crypto/cipher/cfb.v index ceb3725d6b..e24b823881 100644 --- a/vlib/crypto/cipher/cfb.v +++ b/vlib/crypto/cipher/cfb.v @@ -63,6 +63,7 @@ fn new_cfb(b Block, iv []u8, decrypt bool) Cfb { return x } +// xor_key_stream xors each byte in the given slice with a byte from the key stream. pub fn (mut x Cfb) xor_key_stream(mut dst []u8, src []u8) { unsafe { mut local_dst := *dst diff --git a/vlib/crypto/cipher/ctr.v b/vlib/crypto/cipher/ctr.v index 1781d9cc40..fa71eb6f52 100644 --- a/vlib/crypto/cipher/ctr.v +++ b/vlib/crypto/cipher/ctr.v @@ -49,6 +49,7 @@ pub fn new_ctr(b Block, iv []u8) Ctr { } } +// xor_key_stream xors each byte in the given slice with a byte from the key stream. pub fn (mut x Ctr) xor_key_stream(mut dst []u8, src []u8) { unsafe { mut local_dst := *dst diff --git a/vlib/crypto/cipher/ofb.v b/vlib/crypto/cipher/ofb.v index 65fb325ad7..1f95fbc147 100644 --- a/vlib/crypto/cipher/ofb.v +++ b/vlib/crypto/cipher/ofb.v @@ -35,6 +35,7 @@ pub fn new_ofb(b Block, iv []u8) Ofb { return x } +// xor_key_stream xors each byte in the given slice with a byte from the key stream. pub fn (mut x Ofb) xor_key_stream(mut dst []u8, src []u8) { unsafe { mut local_dst := *dst diff --git a/vlib/crypto/des/des.v b/vlib/crypto/des/des.v index d96e434716..4332fc564b 100644 --- a/vlib/crypto/des/des.v +++ b/vlib/crypto/des/des.v @@ -56,6 +56,7 @@ fn (mut c DesCipher) generate_subkeys(key_bytes []u8) { } } +// encrypt a block of data using the DES algorithm pub fn (c &DesCipher) encrypt(mut dst []u8, src []u8) { if src.len < block_size { panic('crypto/des: input not full block') @@ -69,6 +70,7 @@ pub fn (c &DesCipher) encrypt(mut dst []u8, src []u8) { encrypt_block(c.subkeys[..], mut dst, src) } +// decrypt a block of data using the DES algorithm pub fn (c &DesCipher) decrypt(mut dst []u8, src []u8) { if src.len < block_size { panic('crypto/des: input not full block') @@ -94,6 +96,7 @@ pub fn new_triple_des_cipher(key []u8) cipher.Block { return c } +// encrypt a block of data using the TripleDES algorithm pub fn (c &TripleDesCipher) encrypt(mut dst []u8, src []u8) { if src.len < block_size { panic('crypto/des: input not full block') @@ -130,6 +133,7 @@ pub fn (c &TripleDesCipher) encrypt(mut dst []u8, src []u8) { binary.big_endian_put_u64(mut dst, permute_final_block(pre_output)) } +// decrypt a block of data using the TripleDES algorithm pub fn (c &TripleDesCipher) decrypt(mut dst []u8, src []u8) { if src.len < block_size { panic('crypto/des: input not full block') diff --git a/vlib/crypto/rand/rand.v b/vlib/crypto/rand/rand.v index e7cef51fa0..bd24a65f80 100644 --- a/vlib/crypto/rand/rand.v +++ b/vlib/crypto/rand/rand.v @@ -8,6 +8,7 @@ struct ReadError { Error } +// msg returns the error message. pub fn (err ReadError) msg() string { return 'crypto.rand.read() error reading random bytes' }