This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Restrict Protected
to some heap types.
#6471
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
43f7295
Restrict `Protected` to some heap types.
cheme c7d7b07
Comment abut Protected usage.
cheme 3f0b9b2
Remove Protected from crypto, use secrecy crate for existing uses.
cheme 2438b4c
use a parse function
cheme 91cb0f3
Merge branch 'master' into avoid_stack_protected
cheme 56c965a
Merge branch 'master' into avoid_stack_protected
cheme cf77ff3
fix error convert
cheme 005dfc4
Rename and move secretY string function.
cheme 27cbd6a
std result
cheme 0eeebc9
Merge branch 'master' into avoid_stack_protected
cheme File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,10 +37,16 @@ use regex::Regex; | |
use base58::{FromBase58, ToBase58}; | ||
#[cfg(feature = "std")] | ||
use crate::hexdisplay::HexDisplay; | ||
use zeroize::Zeroize; | ||
#[doc(hidden)] | ||
pub use sp_std::ops::Deref; | ||
use sp_runtime_interface::pass_by::PassByInner; | ||
#[doc(hidden)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are both of these exported hidden? |
||
pub use zeroize::Zeroize; | ||
#[doc(hidden)] | ||
pub use secrecy::ExposeSecret; | ||
/// A store for sensitive data. | ||
#[cfg(feature = "std")] | ||
pub use secrecy::SecretString; | ||
|
||
/// The root phrase for our publicly known keys. | ||
pub const DEV_PHRASE: &str = "bottom drive obey lake curtain smoke basket hold race lonely fit walk"; | ||
|
@@ -79,51 +85,6 @@ impl<S, T: UncheckedFrom<S>> UncheckedInto<T> for S { | |
} | ||
} | ||
|
||
/// A store for sensitive data. | ||
/// | ||
/// Calls `Zeroize::zeroize` upon `Drop`. | ||
#[derive(Clone)] | ||
pub struct Protected<T: Zeroize>(T); | ||
|
||
impl<T: Zeroize> AsRef<T> for Protected<T> { | ||
fn as_ref(&self) -> &T { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl<T: Zeroize> sp_std::ops::Deref for Protected<T> { | ||
type Target = T; | ||
|
||
fn deref(&self) -> &T { | ||
&self.0 | ||
} | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
impl<T: Zeroize> std::fmt::Debug for Protected<T> { | ||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
write!(fmt, "<protected>") | ||
} | ||
} | ||
|
||
impl<T: Zeroize> From<T> for Protected<T> { | ||
fn from(t: T) -> Self { | ||
Protected(t) | ||
} | ||
} | ||
|
||
impl<T: Zeroize> Zeroize for Protected<T> { | ||
fn zeroize(&mut self) { | ||
self.0.zeroize() | ||
} | ||
} | ||
|
||
impl<T: Zeroize> Drop for Protected<T> { | ||
fn drop(&mut self) { | ||
self.zeroize() | ||
} | ||
} | ||
|
||
/// An error with the interpretation of a secret. | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
#[cfg(feature = "full_crypto")] | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not replace
password: Option<StringSecret>
to remove this custom implementation ofDrop
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It implements FromStr, but structopt complain about to_string not being implemented. Could use a type wrapper, but I am not sure it is worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, it is actually the from str error that needed to be display, so no pb.