mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-22 22:33:58 -07:00
combined bindings to one crate
This commit is contained in:
parent
29b0800798
commit
970d075e25
21 changed files with 43 additions and 94 deletions
|
@ -7,7 +7,6 @@ members = [
|
|||
"service",
|
||||
"vl1-service",
|
||||
"utils",
|
||||
"openssl-zt",
|
||||
"openssl-sys",
|
||||
]
|
||||
|
||||
|
|
|
@ -1,20 +1,32 @@
|
|||
[package]
|
||||
authors = ["ZeroTier, Inc. <contact@zerotier.com>", "Adam Ierymenko <adam.ierymenko@zerotier.com>"]
|
||||
edition = "2021"
|
||||
license = "MPL-2.0"
|
||||
name = "zerotier-crypto"
|
||||
authors = ["Steven Fackler <sfackler@gmail.com>"]
|
||||
license = "Apache-2.0"
|
||||
description = "OpenSSL bindings"
|
||||
readme = "README.md"
|
||||
keywords = ["crypto", "tls", "ssl", "dtls"]
|
||||
categories = ["cryptography", "api-bindings"]
|
||||
edition = "2021"
|
||||
version = "0.1.0"
|
||||
|
||||
|
||||
[features]
|
||||
vendored = ['ffi/vendored']
|
||||
bindgen = ['ffi/bindgen']
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
zerotier-utils = { path = "../utils" }
|
||||
ed25519-dalek = { version = "1.0.1", features = ["std", "u64_backend"], default-features = false }
|
||||
poly1305 = { version = "0.8.0", features = [], default-features = false }
|
||||
x25519-dalek = { version = "1.2.0", features = ["std", "u64_backend"], default-features = false }
|
||||
openssl = { package = "openssl-zt", path = "../openssl-zt" }
|
||||
cfg-if = "1.0"
|
||||
foreign-types = "0.5.0"
|
||||
libc = "0.2"
|
||||
lazy_static = "^1"
|
||||
rand_core = "0.5.1"
|
||||
|
||||
[target."cfg(windows)".dependencies]
|
||||
winapi = { version = "^0", features = ["handleapi", "ws2ipdef", "ws2tcpip"] }
|
||||
ffi = { package = "openssl-sys", version = "0.9.80", path = "../openssl-sys" }
|
||||
|
||||
[target."cfg(not(windows))".dependencies]
|
||||
libc = "^0"
|
||||
signal-hook = "^0"
|
||||
[dev-dependencies]
|
||||
hex = "0.4.3"
|
||||
hex-literal = "0.3.4"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../rustfmt.toml
|
|
@ -1,16 +1,28 @@
|
|||
// (c) 2020-2022 ZeroTier, Inc. -- currently proprietary pending actual release and licensing. See LICENSE.md.
|
||||
pub use openssl::aes;
|
||||
pub use openssl::hash;
|
||||
pub use openssl::p384;
|
||||
pub use openssl::random;
|
||||
pub use openssl::secret;
|
||||
pub use openssl::aes_gmac_siv;
|
||||
|
||||
mod error;
|
||||
mod cipher_ctx;
|
||||
mod bn;
|
||||
mod ec;
|
||||
|
||||
pub mod aes_gmac_siv;
|
||||
pub mod secret;
|
||||
pub mod random;
|
||||
pub mod aes;
|
||||
pub mod hash;
|
||||
pub mod p384;
|
||||
|
||||
pub mod poly1305;
|
||||
pub mod salsa;
|
||||
pub mod typestate;
|
||||
pub mod x25519;
|
||||
|
||||
|
||||
/// This must be called before using any function from this library.
|
||||
pub fn init() {
|
||||
ffi::init();
|
||||
lazy_static::initialize(&p384::GROUP_P384);
|
||||
}
|
||||
|
||||
/// Constant time byte slice equality.
|
||||
#[inline]
|
||||
pub fn secure_eq<A: AsRef<[u8]> + ?Sized, B: AsRef<[u8]> + ?Sized>(a: &A, b: &B) -> bool {
|
||||
|
@ -25,13 +37,3 @@ pub fn secure_eq<A: AsRef<[u8]> + ?Sized, B: AsRef<[u8]> + ?Sized>(a: &A, b: &B)
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn OPENSSL_cleanse(ptr: *mut std::ffi::c_void, len: usize);
|
||||
}
|
||||
|
||||
/// Destroy the contents of some memory
|
||||
#[inline(always)]
|
||||
pub fn burn(b: &mut [u8]) {
|
||||
unsafe { OPENSSL_cleanse(b.as_mut_ptr().cast(), b.len()) };
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ use std::io::Write;
|
|||
|
||||
use ed25519_dalek::Digest;
|
||||
|
||||
use openssl::random::SecureRandom;
|
||||
use openssl::secret::Secret;
|
||||
use crate::random::SecureRandom;
|
||||
use crate::secret::Secret;
|
||||
|
||||
pub const C25519_PUBLIC_KEY_SIZE: usize = 32;
|
||||
pub const C25519_SECRET_KEY_SIZE: usize = 32;
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
[package]
|
||||
name = "openssl-zt"
|
||||
version = "0.0.1"
|
||||
authors = ["Steven Fackler <sfackler@gmail.com>"]
|
||||
license = "Apache-2.0"
|
||||
description = "OpenSSL bindings"
|
||||
repository = "https://github.com/sfackler/rust-openssl"
|
||||
readme = "README.md"
|
||||
keywords = ["crypto", "tls", "ssl", "dtls"]
|
||||
categories = ["cryptography", "api-bindings"]
|
||||
edition = "2018"
|
||||
|
||||
[features]
|
||||
vendored = ['ffi/vendored']
|
||||
bindgen = ['ffi/bindgen']
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
cfg-if = "1.0"
|
||||
foreign-types = "0.5.0"
|
||||
libc = "0.2"
|
||||
lazy_static = "^1"
|
||||
rand_core = "0.5.1"
|
||||
|
||||
ffi = { package = "openssl-sys", version = "0.9.80", path = "../openssl-sys" }
|
||||
|
||||
[dev-dependencies]
|
||||
hex = "0.4.3"
|
||||
hex-literal = "0.3.4"
|
|
@ -1 +0,0 @@
|
|||
../README.md
|
|
@ -1,33 +0,0 @@
|
|||
|
||||
mod error;
|
||||
mod cipher_ctx;
|
||||
mod bn;
|
||||
mod ec;
|
||||
|
||||
pub mod aes_gmac_siv;
|
||||
pub mod secret;
|
||||
pub mod random;
|
||||
pub mod aes;
|
||||
pub mod hash;
|
||||
pub mod p384;
|
||||
|
||||
/// This must be called before using any function from this library.
|
||||
pub fn init() {
|
||||
ffi::init();
|
||||
lazy_static::initialize(&p384::GROUP_P384);
|
||||
}
|
||||
|
||||
/// Constant time byte slice equality.
|
||||
#[inline]
|
||||
pub fn secure_eq<A: AsRef<[u8]> + ?Sized, B: AsRef<[u8]> + ?Sized>(a: &A, b: &B) -> bool {
|
||||
let (a, b) = (a.as_ref(), b.as_ref());
|
||||
if a.len() == b.len() {
|
||||
let mut x = 0u8;
|
||||
for (aa, bb) in a.iter().zip(b.iter()) {
|
||||
x |= *aa ^ *bb;
|
||||
}
|
||||
x == 0
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue