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

Secret validation #52

Closed
tdelabro opened this issue Mar 7, 2025 · 2 comments · Fixed by #62
Closed

Secret validation #52

tdelabro opened this issue Mar 7, 2025 · 2 comments · Fixed by #62
Assignees
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@tdelabro
Copy link
Collaborator

tdelabro commented Mar 7, 2025

the proof field secret, defined in crates/nuts/src/nut00/secret.rs is just a random [u8; 32] hex encoded into a string.
Meaning it can only ever be 64 chars long (hex encoding uses 2 chars per bytes), with char in the [0..9], [a..f] and [A..F] range.
Make sure it is not possible to construct one without respecting those conditions.

I believe the functions

    #[inline]
    pub fn new<S>(secret: S) -> Self
    where
        S: Into<String>,
    {
        Self(secret.into())
    }

and

impl FromStr for Secret {
    type Err = Error;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        Ok(Self(s.to_string()))
    }
}

to be really problematic in this regard

@tdelabro tdelabro added bug Something isn't working enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Mar 7, 2025
@ftupas
Copy link
Contributor

ftupas commented Mar 17, 2025

Hi may I take this?

@tdelabro
Copy link
Collaborator Author

Sure @ftupas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants