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

derive_key: Add default-off, unstable derive_key_u8ref API call #424

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Aug 28, 2024

  1. derive_key: Add default-off, unstable derive_key_u8ref API call

    This can be enabled with the unstable feature flag, `i_know_what_i_am_doing`.
    
    Developers attempting to deploy blake3 via the Rust crate often encounter
    `derive_key(&str, ...)` which forces the INFO parameter to be a valid UTF-8
    string.
    
    Please see the discussion in issue [13](BLAKE3-team#13),
    in particular, this [comment](BLAKE3-team#13 (comment)).
    
    The recommended course of action for those with non-UTF-8 INFO is to use `hash`
    and `keyed_hash` and open code their own `derive_key` which takes an `&[u8]`.
    
    This is not good for two reasons:  First, it is quickly seen that this forces
    deviation from the Blake3 paper for how `derive_key` should be performed, as
    `hash` doesn't let you set the `flags` field.  Attempting to use the underlying
    `hash_all_at_once` fails because it's not exported.  Second, the developer is
    now forced into the position of maintaining their own patches on top of the
    blake3 repo.  This is a burden on the developer, and makes following blake3
    upstream releases *much* less likely.
    
    This patch proposes a reasonable compromise.  For developers who require `&[u8]`
    INFO field, they can enable the rust feature flag `i_know_what_i_am_doing` to
    expose the API `derive_key_u8ref`.  This enables developers to use upstream
    blake3 directly, while still discouraging sloppy behavior in the default case.
    
    Signed-off-by: Jason Cooper <[email protected]>
    Jason Cooper committed Aug 28, 2024
    Configuration menu
    Copy the full SHA
    498a18b View commit details
    Browse the repository at this point in the history