Skip to content

Zeroize: Discrepency between [Z; N], `[Z], Vec<Z>, Box<[Z]> #899

Closed as not planned
@elichai

Description

@elichai

Right now [Z] only implements Zeroize if Z: DefaultIsZeroes[0].
While Vec<Z>[1], Box<[Z]>[2], and even [Z; N][3] all implement Zeroize if Z: Zeroize.

The justification for impl<Z: DefaultIsZeros> Zeroize for [Z] is given here:

utils/zeroize/src/lib.rs

Lines 455 to 457 in 017165f

/// This impl can eventually be optimized using an memset intrinsic,
/// such as [`core::intrinsics::volatile_set_memory`]. For that reason the
/// blanket impl on slices is bounded by [`DefaultIsZeroes`].

To me it feels like they should all behave ~the same with regard to zeroing

[0] https://docs.rs/zeroize/1.6.0/zeroize/trait.Zeroize.html#impl-Zeroize-for-%5BZ%5D
[1] https://docs.rs/zeroize/1.6.0/zeroize/trait.Zeroize.html#impl-Zeroize-for-Vec%3CZ%3E
[2] https://docs.rs/zeroize/1.6.0/zeroize/trait.Zeroize.html#impl-Zeroize-for-Box%3C%5BZ%5D%3E
[3] https://docs.rs/zeroize/1.6.0/zeroize/trait.Zeroize.html#impl-Zeroize-for-%5BZ;+N%5D

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions