Rust implementation libsodium/utils
.
-
memeq
/memcmp
-
memset
/memzero
-
mlock
/munlock
-
alloc
/free
/mprotect
- Linux only:
alloc_memfd_secret
/free_memfd_secret
functions similar toalloc
/free
implementation backed bymemfd_secret
Rust implementation `libsodium/utils`.
License: MIT License
Rust implementation libsodium/utils
.
memeq
/memcmp
memset
/memzero
mlock
/munlock
alloc
/free
/mprotect
alloc_memfd_secret
/free_memfd_secret
functions similar to alloc
/free
implementation backed by memfd_secret
This library has been stable for a while and I don't think there will be any further changes in the base API.
but there are some internal changes that may happen in future.
std::sync::OnceCell
to reduce unsafe. https://github.com/quininer/memsec/blob/master/src/alloc.rs#L18windows-sys
These changes affect the MSRVs supported by memsec
, and while memsec
doesn't state which MSRV it supports right now, I would like it to change as little as possible.
The comment here claims that memeq is constant time. It's really not -- it's Ө(n) where n = len. Same thing for memcmp.
https://docs.rs/sodiumoxide/0.2.6/sodiumoxide/utils/index.html
Would be cool if you could add the missing ones.
Building memsec for android using MacOS fails
cargo build --target armv7-linux-androideabi -vv
Machine-MacBook-Pro:memsec User$ cargo build --target armv7-linux-androideabi -vv
Compiling libc v0.2.55
Compiling memsec v0.5.5 (/Users/User/src/memsec)
Running `CARGO_PKG_VERSION_PRE= CARGO_PKG_VERSION_MAJOR=0 DYLD_FALLBACK_LIBRARY_PATH='/Users/User/src/memsec/target/debug/deps:/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/User/lib:/usr/local/lib:/usr/lib:/Users/User/lib:/usr/local/lib:/lib:/usr/lib' CARGO_PKG_NAME=libc CARGO_PKG_VERSION=0.2.55 CARGO_PKG_REPOSITORY='https://github.com/rust-lang/libc' CARGO=/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_PKG_VERSION_MINOR=2 CARGO_PKG_VERSION_PATCH=55 CARGO_MANIFEST_DIR=/Users/User/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.55 CARGO_PKG_DESCRIPTION='Raw FFI bindings to platform libraries like libc.
' CARGO_PKG_HOMEPAGE='https://github.com/rust-lang/libc' CARGO_PKG_AUTHORS='The Rust Project Developers' rustc --crate-name build_script_build /Users/User/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.55/build.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="use_std"' -C metadata=ad5ddcb9ef777b62 -C extra-filename=-ad5ddcb9ef777b62 --out-dir /Users/User/src/memsec/target/debug/build/libc-ad5ddcb9ef777b62 -L dependency=/Users/User/src/memsec/target/debug/deps --cap-lints warn`
Running `CARGO_PKG_VERSION_PRE= CARGO_PKG_VERSION_MAJOR=0 DYLD_FALLBACK_LIBRARY_PATH='/Users/User/src/memsec/target/debug/deps:/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/User/lib:/usr/local/lib:/usr/lib:/Users/User/lib:/usr/local/lib:/lib:/usr/lib' CARGO_PKG_NAME=memsec CARGO_PKG_VERSION=0.5.5 CARGO_PKG_REPOSITORY='https://github.com/quininer/memsec' CARGO=/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_PKG_VERSION_MINOR=5 CARGO_PKG_VERSION_PATCH=5 CARGO_PRIMARY_PACKAGE=1 CARGO_MANIFEST_DIR=/Users/User/src/memsec CARGO_PKG_DESCRIPTION='Rust implementation `libsodium/utils`.' CARGO_PKG_HOMEPAGE= CARGO_PKG_AUTHORS='quininer kel <[email protected]>' rustc --crate-name build_script_build build.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg 'feature="alloc"' --cfg 'feature="default"' --cfg 'feature="getrandom"' --cfg 'feature="libc"' --cfg 'feature="mach_o_sys"' --cfg 'feature="use_os"' --cfg 'feature="winapi"' -C metadata=644572c87eb180c9 -C extra-filename=-644572c87eb180c9 --out-dir /Users/User/src/memsec/target/debug/build/memsec-644572c87eb180c9 -C incremental=/Users/User/src/memsec/target/debug/incremental -L dependency=/Users/User/src/memsec/target/debug/deps`
Running `/Users/User/src/memsec/target/debug/build/memsec-644572c87eb180c9/build-script-build`
[memsec 0.5.5] cargo:rustc-cfg=apple
Running `/Users/User/src/memsec/target/debug/build/libc-ad5ddcb9ef777b62/build-script-build`
[libc 0.2.55] cargo:rustc-cfg=libc_priv_mod_use
[libc 0.2.55] cargo:rustc-cfg=libc_union
[libc 0.2.55] cargo:rustc-cfg=libc_const_size_of
[libc 0.2.55] cargo:rustc-cfg=libc_align
[libc 0.2.55] cargo:rustc-cfg=libc_core_cvoid
[libc 0.2.55] cargo:rustc-cfg=libc_packedN
Running `CARGO_PKG_VERSION_PRE= OUT_DIR=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/build/libc-57c702f685547b8d/out CARGO_PKG_VERSION_MAJOR=0 DYLD_FALLBACK_LIBRARY_PATH='/Users/User/src/memsec/target/debug/deps:/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/User/lib:/usr/local/lib:/usr/lib:/Users/User/lib:/usr/local/lib:/lib:/usr/lib' CARGO_PKG_NAME=libc CARGO_PKG_VERSION=0.2.55 CARGO_PKG_REPOSITORY='https://github.com/rust-lang/libc' CARGO=/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_PKG_VERSION_MINOR=2 CARGO_PKG_VERSION_PATCH=55 CARGO_MANIFEST_DIR=/Users/User/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.55 CARGO_PKG_DESCRIPTION='Raw FFI bindings to platform libraries like libc.
' CARGO_PKG_HOMEPAGE='https://github.com/rust-lang/libc' CARGO_PKG_AUTHORS='The Rust Project Developers' rustc --crate-name libc /Users/User/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.55/src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="use_std"' -C metadata=2963020b54ba7cc1 -C extra-filename=-2963020b54ba7cc1 --out-dir /Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps --target armv7-linux-androideabi -C ar=/Users/User/src/NDK/arm/bin/arm-linux-androideabi-ar -C linker=/Users/User/src/NDK/arm/bin/arm-linux-androideabi-clang -L dependency=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps -L dependency=/Users/User/src/memsec/target/debug/deps --cap-lints warn --cfg libc_priv_mod_use --cfg libc_union --cfg libc_const_size_of --cfg libc_align --cfg libc_core_cvoid --cfg libc_packedN`
Compiling getrandom v0.1.3
Running `CARGO_PKG_VERSION_PRE= CARGO_PKG_VERSION_MAJOR=0 DYLD_FALLBACK_LIBRARY_PATH='/Users/User/src/memsec/target/debug/deps:/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/User/lib:/usr/local/lib:/usr/lib:/Users/User/lib:/usr/local/lib:/lib:/usr/lib' CARGO_PKG_NAME=getrandom CARGO_PKG_VERSION=0.1.3 CARGO_PKG_REPOSITORY='https://github.com/rust-random/getrandom' CARGO=/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=3 CARGO_MANIFEST_DIR=/Users/User/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.1.3 CARGO_PKG_DESCRIPTION='A small cross-platform library for retrieving random data from system source' CARGO_PKG_HOMEPAGE= CARGO_PKG_AUTHORS='The Rand Project Developers' rustc --edition=2018 --crate-name getrandom /Users/User/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.1.3/src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=a57b553dffd209ec -C extra-filename=-a57b553dffd209ec --out-dir /Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps --target armv7-linux-androideabi -C ar=/Users/User/src/NDK/arm/bin/arm-linux-androideabi-ar -C linker=/Users/User/src/NDK/arm/bin/arm-linux-androideabi-clang -L dependency=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps -L dependency=/Users/User/src/memsec/target/debug/deps --extern libc=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps/liblibc-2963020b54ba7cc1.rlib --cap-lints warn`
Running `CARGO_PKG_VERSION_PRE= OUT_DIR=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/build/memsec-65bda352a3700c4b/out CARGO_PKG_VERSION_MAJOR=0 DYLD_FALLBACK_LIBRARY_PATH='/Users/User/src/memsec/target/debug/deps:/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/User/lib:/usr/local/lib:/usr/lib:/Users/User/lib:/usr/local/lib:/lib:/usr/lib' CARGO_PKG_NAME=memsec CARGO_PKG_VERSION=0.5.5 CARGO_PKG_REPOSITORY='https://github.com/quininer/memsec' CARGO=/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_PKG_VERSION_MINOR=5 CARGO_PKG_VERSION_PATCH=5 CARGO_PRIMARY_PACKAGE=1 CARGO_MANIFEST_DIR=/Users/User/src/memsec CARGO_PKG_DESCRIPTION='Rust implementation `libsodium/utils`.' CARGO_PKG_HOMEPAGE= CARGO_PKG_AUTHORS='quininer kel <[email protected]>' rustc --crate-name memsec src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg 'feature="alloc"' --cfg 'feature="default"' --cfg 'feature="getrandom"' --cfg 'feature="libc"' --cfg 'feature="mach_o_sys"' --cfg 'feature="use_os"' --cfg 'feature="winapi"' -C metadata=745173220f5af749 -C extra-filename=-745173220f5af749 --out-dir /Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps --target armv7-linux-androideabi -C ar=/Users/User/src/NDK/arm/bin/arm-linux-androideabi-ar -C linker=/Users/User/src/NDK/arm/bin/arm-linux-androideabi-clang -C incremental=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/incremental -L dependency=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps -L dependency=/Users/User/src/memsec/target/debug/deps --extern getrandom=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps/libgetrandom-a57b553dffd209ec.rlib --extern libc=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps/liblibc-2963020b54ba7cc1.rlib --cfg apple`
error[E0463]: can't find crate for `mach_o_sys`
--> src/lib.rs:8:40
|
8 | #[cfg(all(apple, feature = "use_os"))] extern crate mach_o_sys;
| ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `memsec`.
Caused by:
process didn't exit successfully: `CARGO_PKG_VERSION_PRE= OUT_DIR=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/build/memsec-65bda352a3700c4b/out CARGO_PKG_VERSION_MAJOR=0 DYLD_FALLBACK_LIBRARY_PATH='/Users/User/src/memsec/target/debug/deps:/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/User/lib:/usr/local/lib:/usr/lib:/Users/User/lib:/usr/local/lib:/lib:/usr/lib' CARGO_PKG_NAME=memsec CARGO_PKG_VERSION=0.5.5 CARGO_PKG_REPOSITORY='https://github.com/quininer/memsec' CARGO=/Users/User/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_PKG_VERSION_MINOR=5 CARGO_PKG_VERSION_PATCH=5 CARGO_PRIMARY_PACKAGE=1 CARGO_MANIFEST_DIR=/Users/User/src/memsec CARGO_PKG_DESCRIPTION='Rust implementation `libsodium/utils`.' CARGO_PKG_HOMEPAGE= CARGO_PKG_AUTHORS='quininer kel <[email protected]>' rustc --crate-name memsec src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg 'feature="alloc"' --cfg 'feature="default"' --cfg 'feature="getrandom"' --cfg 'feature="libc"' --cfg 'feature="mach_o_sys"' --cfg 'feature="use_os"' --cfg 'feature="winapi"' -C metadata=745173220f5af749 -C extra-filename=-745173220f5af749 --out-dir /Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps --target armv7-linux-androideabi -C ar=/Users/User/src/NDK/arm/bin/arm-linux-androideabi-ar -C linker=/Users/User/src/NDK/arm/bin/arm-linux-androideabi-clang -C incremental=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/incremental -L dependency=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps -L dependency=/Users/User/src/memsec/target/debug/deps --extern getrandom=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps/libgetrandom-a57b553dffd209ec.rlib --extern libc=/Users/User/src/memsec/target/armv7-linux-androideabi/debug/deps/liblibc-2963020b54ba7cc1.rlib --cfg apple` (exit code: 1)
I guess it is detecting the build-os instead of the target-os and therefore trying to use march_o_sys instead of libc when building from apple.
See this thread: rosenpass/rosenpass#224
Maybe you @quininer have some thoughts?
We are interested in having a memfd_secret
based allocator, that uses memsec
as fallback. So we figured it would make sense to ask, if this would be a functionality desired directly in memsec
?
The basic ideas are:
memfd_secret
support (this we already have, on non-linux systems that is compile time known false)memfd_secret
support is available, try memfd_secret
+ mmap
to allocateAll that of course feature gated, not active by default.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.