feat: get rid of lifetime annotations
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -13,20 +13,20 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.82"
|
||||
version = "1.0.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519"
|
||||
checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.153"
|
||||
version = "0.2.154"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
|
||||
|
||||
[[package]]
|
||||
name = "shared_memory_heap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://gitea.rixxc.de/rixxc/shared_memory_heap.git#72b2e58244a90ca919219b8181eac0f70f482434"
|
||||
source = "git+https://gitea.rixxc.de/rixxc/shared_memory_heap.git#7c336c87695955a222e9e6d3d55987e6539c8c50"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
22
src/lib.rs
22
src/lib.rs
@@ -16,13 +16,13 @@ static AGENT: LazyLock<Mutex<Agent>> = LazyLock::new(|| {
|
||||
});
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct X25519PrivKey<'a>(SharedPtr<'a, 8>);
|
||||
pub struct X25519PrivKey(SharedPtr<8>);
|
||||
#[derive(Debug)]
|
||||
pub struct X25519PubKey<'a>(SharedPtr<'a, 32>);
|
||||
pub struct X25519PubKey(SharedPtr<32>);
|
||||
#[derive(Debug)]
|
||||
pub struct X25519SharedKey<'a>(SharedPtr<'a, 32>);
|
||||
pub struct X25519SharedKey(SharedPtr<32>);
|
||||
|
||||
impl From<&[u8; 32]> for X25519PubKey<'_> {
|
||||
impl From<&[u8; 32]> for X25519PubKey {
|
||||
fn from(value: &[u8; 32]) -> Self {
|
||||
let mut pk = SharedPtr::<32>::new().unwrap();
|
||||
pk.copy_from_slice(value);
|
||||
@@ -30,7 +30,7 @@ impl From<&[u8; 32]> for X25519PubKey<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&[u8; 8]> for X25519PrivKey<'_> {
|
||||
impl From<&[u8; 8]> for X25519PrivKey {
|
||||
fn from(value: &[u8; 8]) -> Self {
|
||||
let mut sk = SharedPtr::<8>::new().unwrap();
|
||||
sk.copy_from_slice(value);
|
||||
@@ -38,7 +38,7 @@ impl From<&[u8; 8]> for X25519PrivKey<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for X25519PrivKey<'_> {
|
||||
impl Deref for X25519PrivKey {
|
||||
type Target = [u8; 8];
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@@ -46,7 +46,7 @@ impl Deref for X25519PrivKey<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for X25519PubKey<'_> {
|
||||
impl Deref for X25519PubKey {
|
||||
type Target = [u8; 32];
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@@ -54,7 +54,7 @@ impl Deref for X25519PubKey<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for X25519SharedKey<'_> {
|
||||
impl Deref for X25519SharedKey {
|
||||
type Target = [u8; 32];
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@@ -62,7 +62,7 @@ impl Deref for X25519SharedKey<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn x25519_keygen<'a>() -> (X25519PrivKey<'a>, X25519PubKey<'a>) {
|
||||
pub fn x25519_keygen() -> (X25519PrivKey, X25519PubKey) {
|
||||
let sk = X25519PrivKey(SharedPtr::<8>::new().unwrap());
|
||||
let pk = X25519PubKey(SharedPtr::<32>::new().unwrap());
|
||||
|
||||
@@ -75,7 +75,7 @@ pub fn x25519_keygen<'a>() -> (X25519PrivKey<'a>, X25519PubKey<'a>) {
|
||||
(sk, pk)
|
||||
}
|
||||
|
||||
pub fn x22519_pubkey<'a>(sk: &X25519PrivKey) -> X25519PubKey<'a> {
|
||||
pub fn x22519_pubkey(sk: &X25519PrivKey) -> X25519PubKey {
|
||||
let pk = X25519PubKey(SharedPtr::<32>::new().unwrap());
|
||||
|
||||
let mut agent = AGENT.lock().unwrap();
|
||||
@@ -87,7 +87,7 @@ pub fn x22519_pubkey<'a>(sk: &X25519PrivKey) -> X25519PubKey<'a> {
|
||||
pk
|
||||
}
|
||||
|
||||
pub fn x25519<'a>(sk: &X25519PrivKey, pk: &X25519PubKey) -> X25519SharedKey<'a> {
|
||||
pub fn x25519(sk: &X25519PrivKey, pk: &X25519PubKey) -> X25519SharedKey {
|
||||
let out = X25519SharedKey(SharedPtr::<32>::new().unwrap());
|
||||
|
||||
let mut agent = AGENT.lock().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user