-
Notifications
You must be signed in to change notification settings - Fork 151
Description
The zeroize crate used to have a ZeroizeOnDrop trait: iqlusioninc/crates#168
It was removed in favor of #[zeroize(drop)] which largely turned out to be a mistake: iqlusioninc/crates#188
Originally filed by @fjarri as iqlusioninc/crates#757:
Person A creates a crate with a type that has some secret data inside, say,
SecretKey { inner: SecretDataType }. They implementZeroizeandDrop(or#[zeroize(drop)]) forSecretDataType, and stop at that - the secret data is now safe (to the extend Rust can guarantee it), thedrop()ofSecretKeywill call the zeroizingdrop()ofSecretDataType, so there's no need to define anything forSecretKeyitself.Person B uses A's crate and wants to use
Secret<SecretKey>. But they cannot, becauseSecretKeydoes not implementZeroize- so they have to wrap it in a newtype and implement an emptyZeroizefor it. And they still cannot assert in code thatSecretKeykeeps its secret - they have to rely on the docs.So what are the responsibilities of A here? Should they define an (empty)
ZeroizeforSecretKey? Should they export aSecret<Box<SecretKey>>? What's the convention?I wonder if it would be more convenient to have a marker trait
ZeroizedOnDrop, that A could implement forSecretKey, andSecretcould require?