vitaminc_protected/
lib.rs1#![doc = include_str!("../README.md")]
2mod as_protected_ref;
3mod controlled;
4mod conversions;
5mod debug;
6mod digest;
7mod equatable;
8mod exportable;
9mod ops;
10mod protected;
11mod timing_safe;
12mod usage;
13mod zeroed;
14use zeroize::Zeroize;
15
16#[cfg(feature = "bitvec")]
17pub mod bitvec;
18
19pub mod slice_index;
20
21pub use as_protected_ref::{AsProtectedRef, ProtectedRef};
22pub use zeroed::Zeroed;
23
24pub use controlled::Controlled;
26pub use digest::ProtectedDigest;
27pub use equatable::{ConstantTimeEq, Equatable};
28pub use exportable::{Exportable, SafeDeserialize, SafeSerialize};
29pub use protected::{flatten_array, Protected};
30pub use usage::{Acceptable, DefaultScope, Scope, Usage};
31
32pub use debug::{OpaqueDebug, Redacted};
33pub use timing_safe::{Choice, TimingSafeEq};
34pub use vitaminc_protected_derive::{OpaqueDebug, TimingSafeEq};
35
36pub trait ReplaceT<K>: private::Sealed {
39 type Output: Controlled;
40}
41
42impl<T, K> ReplaceT<K> for Protected<T>
43where
44 Protected<K>: Controlled,
45{
46 type Output = Protected<K>;
47}
48
49impl<T, K> ReplaceT<K> for Equatable<Protected<T>>
50where
51 Equatable<Protected<K>>: Controlled,
52{
53 type Output = Equatable<Protected<K>>;
54}
55
56impl<T, K> ReplaceT<K> for Equatable<Exportable<Protected<T>>>
57where
58 Equatable<Exportable<Protected<K>>>: Controlled,
59{
60 type Output = Equatable<Exportable<Protected<K>>>;
61}
62
63impl<T, K> ReplaceT<K> for Exportable<Protected<T>>
64where
65 K: Zeroize,
66{
67 type Output = Exportable<Protected<K>>;
68}
69
70impl<T, K> ReplaceT<K> for Exportable<Equatable<Protected<T>>>
71where
72 K: Zeroize,
73{
74 type Output = Exportable<Equatable<Protected<K>>>;
75}
76
77impl<T, K, S> ReplaceT<K> for Usage<Protected<T>, S>
80where
81 Protected<K>: Controlled,
82{
83 type Output = Protected<K>;
84}
85
86mod private {
87 use crate::{Equatable, Exportable, Protected, Usage};
88
89 pub trait Sealed {}
90 impl<T> Sealed for Protected<T> {}
91 impl<T> Sealed for Equatable<T> {}
92 impl<T> Sealed for Exportable<T> {}
93 impl<T, S> Sealed for Usage<T, S> {}
94
95 pub trait ControlledPrivate {}
100}