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

consider removing Hpke's internal RwLock #52

Closed
japaric opened this issue Nov 24, 2023 · 2 comments
Closed

consider removing Hpke's internal RwLock #52

japaric opened this issue Nov 24, 2023 · 2 comments

Comments

@japaric
Copy link
Contributor

japaric commented Nov 24, 2023

hpke_rs::Hpke wraps its internal PRNG in a RwLock. I assume this to make its methods work with just access to a shared reference (&self) and to keep the type Send and Sync.

an alternative is to remove the internal RwLock and make Hpke's methods require a mutable reference. the end user then can wrap the whole Hpke object in a Arc<RwLock>, or Arc<Mutex>, or RefCell (if they don't need Send / Sync-ness) depending on their application requirements so it makes the API more flexible.

the internal RwLock prevents the crate from being no-std compatible so removing it clears the path towards no-std support

@franziskuskiefer
Copy link
Member

Yes, this was done for the evercrypt provider. But I agree that it would be better to drop it. Using a mutable reference sounds like the way to go.

@japaric
Copy link
Contributor Author

japaric commented Nov 29, 2023

done in PR #55

@japaric japaric closed this as completed Nov 29, 2023
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

2 participants