Expose bounded operating-system cryptographic random bytes

Đang mở
#198 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi

Hướng nghiên cứu

Bắt đầu bằng việc đọc design.md và thống nhất cách đặt tên với module Random của basic-cli. Sử dụng điểm vào pf.Random.bytes! và các kiểm tra được liệt kê về độ dài bằng không, giới hạn tối đa, tính đồng thời, thành công/thất bại của host và các nền tảng native làm bản đồ xác thực. Được coi là hoàn tất khi các tiêu chí chấp nhận được đáp ứng trên Linux, macOS và Windows mà không để lộ các byte chưa đầy đủ hoặc trạng thái PRNG toàn cục có thể thay đổi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

Expose cryptographically secure bytes from the operating system:

bytes = Random.bytes!(32)?

Illustrative API:

bytes! : U64 => Try(
    List(U8),
    [
        EntropyUnavailable(IOErr),
        TooManyBytes({ requested : U64, max : U64 }),
    ],
)

Exact names can be settled during implementation.

Why this belongs in the platform

Secure randomness is necessary for session identifiers, CSRF tokens, password-reset tokens, webhook secrets, and other conventional web application capabilities. Applications cannot implement it safely in pure Roc, and the platform is the only supported boundary through which they can access the operating system.

OWASP recommends a CSPRNG and at least 128 bits when an application creates session identifiers. A byte API avoids encouraging applications to concatenate or reinterpret a small integer seed.

This is a small, app-independent OS primitive with identical semantics on every target, so it meets the platform subsystem criteria in design.md.

Required contract

  • Use the operating system's preferred cryptographic random source on Linux, macOS, and Windows.
  • Return exactly the requested number of bytes or a typed failure; never return partial success.
  • bytes!(0) returns Ok([]).
  • Enforce a documented hard allocation bound before allocating. A proposed initial maximum is 64 KiB.
  • Calls are safe under concurrent request handling.
  • Do not expose a mutable global PRNG or require application-provided seeding.
  • Do not log, inspect, or otherwise expose generated bytes on an error path.
  • Coordinate naming with basic-cli's Random module, while keeping this repository independently usable.

Tests

  • Zero length, exact maximum, and over-maximum.
  • Exact output length over representative sizes.
  • Concurrent calls.
  • Injected host success and failure paths.
  • Native smoke coverage on Linux, macOS, and Windows.
  • No statistical randomness tests: those do not validate the security of the OS source.

Non-goals

  • Deterministic seeded random-number generation
  • Probability distributions or random collection helpers
  • UUIDs, tokens, Base64, or hexadecimal encoding
  • Key derivation, hashing, signing, or encryption
  • Arbitrarily large random buffers

Acceptance criteria

  • pf.Random.bytes! returns exact-length OS cryptographic randomness.
  • Allocation has a finite documented maximum and typed over-limit error.
  • The operation has one cross-platform semantic contract.
  • The implementation has no mutable process-global PRNG state.
  • Failure and concurrency paths are covered.

References

Ngôn ngữ chính
HTML
Star
110
Fork
25
Merge trung bình
18 giờ 28 phút
Pull request đã merge (30 ngày)
16

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của roc-lang/basic-webserver

Tất cả issue của roc-lang/basic-webserver

Issue tương tự

Thêm issue về Operating Systems

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.