chore: update to latest shared_memory_heap

This commit is contained in:
2024-10-10 16:44:56 +02:00
parent d36eb9afcf
commit cbf0454517
3 changed files with 32 additions and 32 deletions

10
Cargo.lock generated
View File

@@ -13,20 +13,20 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.86"
version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
[[package]]
name = "libc"
version = "0.2.158"
version = "0.2.159"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
[[package]]
name = "shared_memory_heap"
version = "0.1.0"
source = "git+https://gitea.rixxc.de/rixxc/shared_memory_heap.git#9ec0b728c2936c57ef8b0e6b015cdcc0474060d4"
source = "git+https://gitea.rixxc.de/rixxc/shared_memory_heap.git#7f46573218dc46417608a700a6146950dfea1442"
dependencies = [
"libc",
]

View File

@@ -13,17 +13,17 @@ static MLKEMAGENT: LazyLock<Mutex<Agent>> = LazyLock::new(|| {
});
#[derive(Debug)]
pub struct MLKEMPrivKey(SharedPtr<8>);
pub struct MLKEMPrivKey(SharedPtr);
#[derive(Debug)]
pub struct MLKEMPubKey(SharedPtr<1184>);
pub struct MLKEMPubKey(SharedPtr);
#[derive(Debug)]
pub struct MLKEMCiphertext(SharedPtr<1088>);
pub struct MLKEMCiphertext(SharedPtr);
#[derive(Debug)]
pub struct MLKEMSharedKey(SharedPtr<32>);
pub struct MLKEMSharedKey(SharedPtr);
impl From<&[u8; 1184]> for MLKEMPubKey {
fn from(value: &[u8; 1184]) -> Self {
let mut pk = SharedPtr::<1184>::new().unwrap();
let mut pk = SharedPtr::new(1184).unwrap();
pk.copy_from_slice(value);
MLKEMPubKey(pk)
}
@@ -31,7 +31,7 @@ impl From<&[u8; 1184]> for MLKEMPubKey {
impl From<&[u8; 8]> for MLKEMPrivKey {
fn from(value: &[u8; 8]) -> Self {
let mut sk = SharedPtr::<8>::new().unwrap();
let mut sk = SharedPtr::new(8).unwrap();
sk.copy_from_slice(value);
MLKEMPrivKey(sk)
}
@@ -41,7 +41,7 @@ impl Deref for MLKEMPrivKey {
type Target = [u8; 8];
fn deref(&self) -> &Self::Target {
self.0.deref()
self.0.deref().try_into().expect("this should never fail")
}
}
@@ -49,7 +49,7 @@ impl Deref for MLKEMPubKey {
type Target = [u8; 1184];
fn deref(&self) -> &Self::Target {
self.0.deref()
self.0.deref().try_into().expect("this should never fail")
}
}
@@ -57,7 +57,7 @@ impl Deref for MLKEMCiphertext {
type Target = [u8; 1088];
fn deref(&self) -> &Self::Target {
self.0.deref()
self.0.deref().try_into().expect("this should never fail")
}
}
@@ -65,13 +65,13 @@ impl Deref for MLKEMSharedKey {
type Target = [u8; 32];
fn deref(&self) -> &Self::Target {
self.0.deref()
self.0.deref().try_into().expect("this should never fail")
}
}
pub fn mlkem_keygen() -> (MLKEMPrivKey, MLKEMPubKey) {
let sk = MLKEMPrivKey(SharedPtr::<8>::new().unwrap());
let pk = MLKEMPubKey(SharedPtr::<1184>::new().unwrap());
let sk = MLKEMPrivKey(SharedPtr::new(8).unwrap());
let pk = MLKEMPubKey(SharedPtr::new(1184).unwrap());
let mut agent = MLKEMAGENT.lock().unwrap();
@@ -83,8 +83,8 @@ pub fn mlkem_keygen() -> (MLKEMPrivKey, MLKEMPubKey) {
}
pub fn mlkem_encap(pk: &MLKEMPubKey) -> (MLKEMCiphertext, MLKEMSharedKey) {
let ct = MLKEMCiphertext(SharedPtr::<1088>::new().unwrap());
let ss = MLKEMSharedKey(SharedPtr::<32>::new().unwrap());
let ct = MLKEMCiphertext(SharedPtr::new(1184).unwrap());
let ss = MLKEMSharedKey(SharedPtr::new(32).unwrap());
let mut agent = MLKEMAGENT.lock().unwrap();
@@ -96,7 +96,7 @@ pub fn mlkem_encap(pk: &MLKEMPubKey) -> (MLKEMCiphertext, MLKEMSharedKey) {
}
pub fn mlkem_decap(ct: &MLKEMCiphertext, sk: &MLKEMPrivKey) -> MLKEMSharedKey {
let ss = MLKEMSharedKey(SharedPtr::<32>::new().unwrap());
let ss = MLKEMSharedKey(SharedPtr::new(32).unwrap());
let mut agent = MLKEMAGENT.lock().unwrap();

View File

@@ -13,15 +13,15 @@ static X25519AGENT: LazyLock<Mutex<Agent>> = LazyLock::new(|| {
});
#[derive(Debug)]
pub struct X25519PrivKey(SharedPtr<8>);
pub struct X25519PrivKey(SharedPtr);
#[derive(Debug)]
pub struct X25519PubKey(SharedPtr<32>);
pub struct X25519PubKey(SharedPtr);
#[derive(Debug)]
pub struct X25519SharedKey(SharedPtr<32>);
pub struct X25519SharedKey(SharedPtr);
impl From<&[u8; 32]> for X25519PubKey {
fn from(value: &[u8; 32]) -> Self {
let mut pk = SharedPtr::<32>::new().unwrap();
let mut pk = SharedPtr::new(32).unwrap();
pk.copy_from_slice(value);
X25519PubKey(pk)
}
@@ -29,7 +29,7 @@ impl From<&[u8; 32]> for X25519PubKey {
impl From<&[u8; 8]> for X25519PrivKey {
fn from(value: &[u8; 8]) -> Self {
let mut sk = SharedPtr::<8>::new().unwrap();
let mut sk = SharedPtr::new(8).unwrap();
sk.copy_from_slice(value);
X25519PrivKey(sk)
}
@@ -39,7 +39,7 @@ impl Deref for X25519PrivKey {
type Target = [u8; 8];
fn deref(&self) -> &Self::Target {
self.0.deref()
self.0.deref().try_into().expect("this should never fail")
}
}
@@ -47,7 +47,7 @@ impl Deref for X25519PubKey {
type Target = [u8; 32];
fn deref(&self) -> &Self::Target {
self.0.deref()
self.0.deref().try_into().expect("this should never fail")
}
}
@@ -55,13 +55,13 @@ impl Deref for X25519SharedKey {
type Target = [u8; 32];
fn deref(&self) -> &Self::Target {
self.0.deref()
self.0.deref().try_into().expect("this should never fail")
}
}
pub fn x25519_keygen() -> (X25519PrivKey, X25519PubKey) {
let sk = X25519PrivKey(SharedPtr::<8>::new().unwrap());
let pk = X25519PubKey(SharedPtr::<32>::new().unwrap());
let sk = X25519PrivKey(SharedPtr::new(8).unwrap());
let pk = X25519PubKey(SharedPtr::new(32).unwrap());
let mut agent = X25519AGENT.lock().unwrap();
@@ -73,7 +73,7 @@ pub fn x25519_keygen() -> (X25519PrivKey, X25519PubKey) {
}
pub fn x22519_pubkey(sk: &X25519PrivKey) -> X25519PubKey {
let pk = X25519PubKey(SharedPtr::<32>::new().unwrap());
let pk = X25519PubKey(SharedPtr::new(32).unwrap());
let mut agent = X25519AGENT.lock().unwrap();
@@ -85,7 +85,7 @@ pub fn x22519_pubkey(sk: &X25519PrivKey) -> X25519PubKey {
}
pub fn x25519(sk: &X25519PrivKey, pk: &X25519PubKey) -> X25519SharedKey {
let out = X25519SharedKey(SharedPtr::<32>::new().unwrap());
let out = X25519SharedKey(SharedPtr::new(32).unwrap());
let mut agent = X25519AGENT.lock().unwrap();