Skip to content

Implement secure randomBytes function with error handling#386

Open
zendrx wants to merge 28 commits into
buzz-language:mainfrom
zendrx:main
Open

Implement secure randomBytes function with error handling#386
zendrx wants to merge 28 commits into
buzz-language:mainfrom
zendrx:main

Conversation

@zendrx

@zendrx zendrx commented Jul 20, 2026

Copy link
Copy Markdown

Summary

This PR adds a randomBytes function to the crypto standard library module, providing cryptographically secure random byte generation.

Changes

  • src/lib/crypto.buzz: Added randomBytes(len: int) > str declaration
  • src/lib/buzz_crypto.zig: Implemented randomBytes using std.Io.random

API

/// Generate cryptographically secure random bytes
/// @param len Number of random bytes to generate
/// @return Random bytes as a string
export extern fun randomBytes(len: int) > str;

zendrx added 22 commits July 20, 2026 07:20
Added a function to generate cryptographically secure random bytes.
Add randomBytes function to generate random bytes and push to VM.
Removed error handling from randomBytes function signature.
Handle memory allocation failure in randomBytes function.
Removed optional parameters from argon2id function signature.
Removed the salt parameter from the argon2 function documentation.
@giann

giann commented Jul 21, 2026

Copy link
Copy Markdown
Member

This also needs some tests

Comment thread src/lib/buzz_crypto.zig Outdated
Comment thread src/lib/buzz_crypto.zig Outdated
Comment thread src/lib/buzz_crypto.zig Outdated
Comment thread src/lib/buzz_crypto.zig
Comment thread src/lib/buzz_crypto.zig Outdated
Comment thread src/lib/crypto.buzz Outdated
@zendrx

zendrx commented Jul 22, 2026

Copy link
Copy Markdown
Author

Have been able to resolve some requested changes

@zendrx
zendrx requested a review from giann July 22, 2026 12:53
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