-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crypto: add missing docs #23864
crypto: add missing docs #23864
Conversation
Connected to Huly®: V_0.6-22268 |
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that each byte is xor-ed?
To me it is not obvious 🤔 .
@blackshirt, @kimshrier what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just saw the comments in the interface:
// A Stream represents a stream cipher.
pub interface Stream {
mut:
// xor_key_stream XORs each byte in the given slice with a byte from the
// cipher's key stream. Dst and src must overlap entirely or not at all.
//
// If len(dst) < len(src), xor_key_stream should panic. It is acceptable
// to pass a dst bigger than src, and in that case, xor_key_stream will
// only update dst[:len(src)] and will not touch the rest of dst.
//
// Multiple calls to xor_key_stream behave as if the concatenation of
// the src buffers was passed in a single run. That is, Stream
// maintains state and does not reset at each xor_key_stream call.
xor_key_stream(mut dst []u8, src []u8)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that method implements that Stream interface, I think it is safe to assume that the same comments should apply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge it as it is for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work.
This pull request introduces several documentation improvements across multiple files in the
vlib/crypto
directory.vlib/crypto/cipher/cfb.v
: Added a comment to thexor_key_stream
function explaining its purpose.vlib/crypto/cipher/ctr.v
: Added a comment to thexor_key_stream
function explaining its purpose.vlib/crypto/cipher/ofb.v
: Added a comment to thexor_key_stream
function explaining its purpose.vlib/crypto/des/des.v
: Added comments to theencrypt
anddecrypt
functions in bothDesCipher
andTripleDesCipher
classes explaining their purposes. [1] [2] [3] [4]vlib/crypto/rand/rand.v
: Added a comment to themsg
function in theReadError
struct explaining its purpose.