summaryrefslogtreecommitdiff
path: root/ext/crypto/shared.rs
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2021-12-15 22:18:26 +0100
committerGitHub <noreply@github.com>2021-12-15 22:18:26 +0100
commitf0e1a6b84c282a37a5cfd278fc145ba645ee9073 (patch)
tree4231858e8745e34bda932829911e0c71433f132a /ext/crypto/shared.rs
parent5a3ded66113e7a2cacae3ffb8123038450c701e8 (diff)
refactor(ext/crypto): clean up encrypt rust code (#13094)
Diffstat (limited to 'ext/crypto/shared.rs')
-rw-r--r--ext/crypto/shared.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/crypto/shared.rs b/ext/crypto/shared.rs
index 0b70db24e..1a0703b26 100644
--- a/ext/crypto/shared.rs
+++ b/ext/crypto/shared.rs
@@ -90,6 +90,13 @@ impl RawKeyData {
_ => Err(type_error("expected private key")),
}
}
+
+ pub fn as_secret_key(&self) -> Result<&[u8], AnyError> {
+ match self {
+ RawKeyData::Secret(data) => Ok(data),
+ _ => Err(type_error("expected secret key")),
+ }
+ }
}
pub fn data_error(msg: impl Into<Cow<'static, str>>) -> AnyError {