crypto: add missing doc comments for public methods (#23864)

This commit is contained in:
Noa Santo 2025-03-05 13:36:15 +01:00 committed by GitHub
parent e467747fe4
commit 3aed78e76a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -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'
}