-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ability to crypto_box using signing keys (#128)
- Loading branch information
Showing
18 changed files
with
495 additions
and
114 deletions.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
### `lair-keystore --help` | ||
```text | ||
lair_keystore 0.4.3 | ||
lair_keystore 0.4.4 | ||
secret lair private keystore | ||
USAGE: | ||
|
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
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
103 changes: 103 additions & 0 deletions
103
crates/lair_keystore_api/src/lair_api/crypto_box_xsalsa_by_sign_pub_key.rs
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
use super::*; | ||
|
||
/// Request "crypto_box" encryption. | ||
#[derive(Debug, serde::Serialize, serde::Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct LairApiReqCryptoBoxXSalsaBySignPubKey { | ||
/// Msg id to relate request / response. | ||
pub msg_id: Arc<str>, | ||
|
||
/// The pub key representing the sender. | ||
pub sender_pub_key: Ed25519PubKey, | ||
|
||
/// The pub key of the recipient. | ||
pub recipient_pub_key: Ed25519PubKey, | ||
|
||
/// If this new seed is to be deep_locked, the passphrase for that. | ||
#[serde(skip_serializing_if = "Option::is_none", default)] | ||
pub deep_lock_passphrase: Option<SecretDataSized<64, 81>>, | ||
|
||
/// The data to encrypt | ||
pub data: Arc<[u8]>, | ||
} | ||
|
||
impl LairApiReqCryptoBoxXSalsaBySignPubKey { | ||
/// Make a crypto_box request. | ||
pub fn new( | ||
sender_pub_key: Ed25519PubKey, | ||
recipient_pub_key: Ed25519PubKey, | ||
deep_lock_passphrase: Option<SecretDataSized<64, 81>>, | ||
data: Arc<[u8]>, | ||
) -> Self { | ||
Self { | ||
msg_id: new_msg_id(), | ||
sender_pub_key, | ||
recipient_pub_key, | ||
deep_lock_passphrase, | ||
data, | ||
} | ||
} | ||
} | ||
|
||
impl std::convert::TryFrom<LairApiEnum> | ||
for LairApiReqCryptoBoxXSalsaBySignPubKey | ||
{ | ||
type Error = one_err::OneErr; | ||
|
||
fn try_from(e: LairApiEnum) -> Result<Self, Self::Error> { | ||
if let LairApiEnum::ReqCryptoBoxXSalsaBySignPubKey(s) = e { | ||
Ok(s) | ||
} else { | ||
Err(format!("Invalid response type: {e:?}").into()) | ||
} | ||
} | ||
} | ||
|
||
impl AsLairCodec for LairApiReqCryptoBoxXSalsaBySignPubKey { | ||
fn into_api_enum(self) -> LairApiEnum { | ||
LairApiEnum::ReqCryptoBoxXSalsaBySignPubKey(self) | ||
} | ||
} | ||
|
||
/// A "crypto_box" encryption response. | ||
#[derive(Debug, serde::Serialize, serde::Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
#[non_exhaustive] | ||
pub struct LairApiResCryptoBoxXSalsaBySignPubKey { | ||
/// Msg id to relate request / response. | ||
pub msg_id: Arc<str>, | ||
|
||
/// The generated nonce. | ||
pub nonce: [u8; 24], | ||
|
||
/// The encrypted bytes. | ||
pub cipher: Arc<[u8]>, | ||
} | ||
|
||
impl std::convert::TryFrom<LairApiEnum> | ||
for LairApiResCryptoBoxXSalsaBySignPubKey | ||
{ | ||
type Error = one_err::OneErr; | ||
|
||
fn try_from(e: LairApiEnum) -> Result<Self, Self::Error> { | ||
if let LairApiEnum::ResCryptoBoxXSalsaBySignPubKey(s) = e { | ||
Ok(s) | ||
} else { | ||
Err(format!("Invalid response type: {e:?}").into()) | ||
} | ||
} | ||
} | ||
|
||
impl AsLairCodec for LairApiResCryptoBoxXSalsaBySignPubKey { | ||
fn into_api_enum(self) -> LairApiEnum { | ||
LairApiEnum::ResCryptoBoxXSalsaBySignPubKey(self) | ||
} | ||
} | ||
|
||
impl AsLairRequest for LairApiReqCryptoBoxXSalsaBySignPubKey { | ||
type Response = LairApiResCryptoBoxXSalsaBySignPubKey; | ||
} | ||
|
||
impl AsLairResponse for LairApiResCryptoBoxXSalsaBySignPubKey { | ||
type Request = LairApiReqCryptoBoxXSalsaBySignPubKey; | ||
} |
Oops, something went wrong.