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

Obfuscate shared secret when printing #396

Merged

Commits on Feb 24, 2022

  1. Mention bitcoin_hashes in obfuscated secret msg

    Hashing the debug output for secrets can be done with `bitcoin_hashes`
    not just `std`. Mention this in the obfuscated string output when
    neither are available.
    tcharding committed Feb 24, 2022
    Copy the full SHA
    6dca996 View commit details
    Browse the repository at this point in the history
  2. Remove magic number

    In array initialisation we use magic number 64, this is the secret bytes
    length multiplied by 2.
    
    Please note; we still use the magic number 32, left as such because it
    is used in various ways and its not immediately clear that using a
    single const would be any more descriptive.
    
    Use `SECRET_KEY_SIZE * 2` instead of magic number 64.
    tcharding committed Feb 24, 2022
    Copy the full SHA
    91106f5 View commit details
    Browse the repository at this point in the history
  3. Use byte instead of i

    The identifier `i` is predominantly used for indexing an array but we
    are using it as a place holder for the iterated value of an array that
    is then printed. The identifier `byte` is more descriptive.
    
    Done in preparation for adding similar code to the `ecdh` module.
    tcharding committed Feb 24, 2022
    Copy the full SHA
    4ded2c0 View commit details
    Browse the repository at this point in the history

Commits on Feb 28, 2022

  1. Rename serialize_secret -> secret_bytes

    The `serialize_secret` method is a getter method, it does not do any
    serialisation. However we use the method on secret keys and key types so
    in order for the name to be uniform use the descriptive name
    `secret_bytes`.
    
    Rename `serialize_secret` to be `secret_bytes`.
    tcharding committed Feb 28, 2022
    Copy the full SHA
    5c7c76e View commit details
    Browse the repository at this point in the history
  2. Improve rustdocs for displaying secrets

    Improve rustdocs on `display_secret` by doing:
    
    - Minor improvements to the rustdocs to aid readability in the editor.
    - Do not guarantee (`assert_eq!`) debug output
    tcharding committed Feb 28, 2022
    Copy the full SHA
    e4be664 View commit details
    Browse the repository at this point in the history
  3. Obfuscate SharedSecret when printing

    Currently printing the `SharedSecret` using `Display` or `Debug` prints
    the real secret, this is sub-optimal. We have a solution for other
    secrets in the project where printing is obfuscated and we provide a
    `display_secret` method for explicitly printing.
    
    Mirror the logic for other secrets and obfuscate the `SharedSecret` when printing.
    tcharding committed Feb 28, 2022
    Copy the full SHA
    cf6badf View commit details
    Browse the repository at this point in the history