franziskuskiefer / hpke-rs

Pure Rust implementation of HPKE (https://www.rfc-editor.org/rfc/rfc9180.html)
28 stars 14 forks source link

consider removing `Hpke`'s internal `RwLock` #52

Closed japaric closed 7 months ago

japaric commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

done in PR #55