oxedyne/fe2o3/fe2o3_iop_crypto/src/keys.rs
1.1 KiB, 3 runs
created by r1870400018:383, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | use oxedyne_fe2o3_core::prelude::*; |
| 2 | |
| 3 | pub trait KeyManager { |
| 4 | |
| 5 | fn clone_with_keys( |
| 6 | &self, |
| 7 | pk: Option<&[u8]>, |
| 8 | sk: Option<&[u8]>, |
| 9 | ) |
| 10 | -> Outcome<Self> where Self: Sized; |
| 11 | |
| 12 | /// Get the public key. |
| 13 | fn get_public_key(&self) -> Outcome<Option<&[u8]>>; |
| 14 | /// Get the private key. |
| 15 | fn get_secret_key(&self) -> Outcome<Option<&[u8]>>; |
| 16 | /// Set the optional public key. |
| 17 | fn set_public_key(self, pk: Option<&[u8]>) -> Outcome<Self> where Self: Sized; |
| 18 | /// Set the optional secret key. |
| 19 | fn set_secret_key(self, sk: Option<&[u8]>) -> Outcome<Self> where Self: Sized; |
| 20 | } |
| 21 | |
| 22 | impl KeyManager for () { |
| 23 | fn clone_with_keys( |
| 24 | &self, |
| 25 | _pk: Option<&[u8]>, |
| 26 | _sk: Option<&[u8]>, |
| 27 | ) |
| 28 | -> Outcome<Self> |
| 29 | { |
| 30 | Ok(()) |
| 31 | } |
| 32 | |
| 33 | fn get_public_key(&self) -> Outcome<Option<&[u8]>> { Ok(None) } |
| 34 | fn get_secret_key(&self) -> Outcome<Option<&[u8]>> { Ok(None) } |
| 35 | fn set_public_key(self, _pk: Option<&[u8]>) -> Outcome<Self> { Ok(()) } |
| 36 | fn set_secret_key(self, _sk: Option<&[u8]>) -> Outcome<Self> { Ok(()) } |
| 37 | } |