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

support for HashSet in secrecy? #1299

Open
tessus opened this issue Mar 19, 2025 · 5 comments
Open

support for HashSet in secrecy? #1299

tessus opened this issue Mar 19, 2025 · 5 comments

Comments

@tessus
Copy link

tessus commented Mar 19, 2025

It's currently not possible to use HasHset<SecretString>. How can I use a HashSet?
Is there any chance that support for HashSet is added?

@c-git
Copy link
Contributor

c-git commented Mar 20, 2025

That's an interesting idea. If support is added I think it would be good to use a wrapper so it would be opt in so as not to leak info without cause. Can you share a possible use case for this as right now I can't actually think of one other than loading a set of secretes and not wanting to duplicate them but then how would you know which to use?

The wrapper could take a hash of the incoming secret and then store that hash for later use for calls to get a hash.

@tessus
Copy link
Author

tessus commented Mar 20, 2025

Thanks for the reply.

As for the use case... we use tokens in rustypaste to allow sending/deleting paste data to/from the server.

Config struct: https://github.com/orhun/rustypaste/blob/master/src/config.rs#L56
Retrieving tokens: https://github.com/orhun/rustypaste/blob/master/src/config.rs#L156-L212
Auth code: https://github.com/orhun/rustypaste/blob/master/src/auth.rs#L13-L45

@tony-iqlusion
Copy link
Member

secrecy bounds on the zeroize::Zeroize trait and there is no impl for such types. Since HashSet stores data non-contiguously on the heap, writing such an impl would require access to its internals, which are in Rust's liballoc.

It might be possible to add it to hashbrown (from which liballoc sources it): https://github.com/rust-lang/hashbrown/

@tessus
Copy link
Author

tessus commented Mar 20, 2025

I asked Orhun to comment. He's got a better understanding of Rust... ;-)

@orhun
Copy link

orhun commented Mar 21, 2025

That's fair, we might give hashbrown's HashSet a try instead then.

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

No branches or pull requests

4 participants