| 1 | // Copyright 2015-2024 Brian Smith. |
| 2 | // |
| 3 | // Permission to use, copy, modify, and/or distribute this software for any |
| 4 | // purpose with or without fee is hereby granted, provided that the above |
| 5 | // copyright notice and this permission notice appear in all copies. |
| 6 | // |
| 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES |
| 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY |
| 10 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 13 | // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 14 | |
| 15 | use super::LeakyWord; |
| 16 | |
| 17 | /// A native word that may hold a secret. |
| 18 | /// |
| 19 | /// XXX: Currently this is a type alias of `LeakyWord` so it doesn't enforce, |
| 20 | /// except by convention, the prevention of leaks. This is a temporary state to |
| 21 | /// support the refactorings that will |
| 22 | /// |
| 23 | /// XXX: This isn't the native word size on targets where a pointer isn't the |
| 24 | /// same size as a native word. TODO: Fix this. |
| 25 | /// |
| 26 | /// XXX: Over time, we'll evolve Word into a newtype with an API that minimizes |
| 27 | /// leaks and makes all leaks explicit, like so: |
| 28 | pub(crate) type Word = LeakyWord; |
| 29 | |
| 30 | /* TODO: |
| 31 | #[repr(transparent)] |
| 32 | pub(crate) struct Word(LeakyWord); |
| 33 | |
| 34 | impl Word { |
| 35 | pub fn leak_word(self) -> LeakyWord { self.0 } |
| 36 | } |
| 37 | |
| 38 | impl From<LeakyWord> for Word { |
| 39 | fn from(w: LeakyWord) -> Self { |
| 40 | // TODO: Use a stronger `black_box`. |
| 41 | Self(core::hint::black_box(w)) |
| 42 | } |
| 43 | } |
| 44 | */ |
| 45 | |