Skip to content
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

Merged
merged 3 commits into from
Mar 5, 2025
Merged

Conversation

virus-rpi
Copy link
Contributor

@virus-rpi virus-rpi commented Mar 5, 2025

This pull request introduces several documentation improvements across multiple files in the vlib/crypto directory.

Copy link

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.
Copy link
Member

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?

Copy link
Member

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)
}

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit 3aed78e into vlang:master Mar 5, 2025
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants