Update to latest version of rustfmt
- Run rustfmt 0.99.6-nightly (750b2526 2018-10-18)
Change-Id: I538323d958478b8d708ffe19bb6acaa29fb60d36
diff --git a/boringssl/boringssl.rs b/boringssl/boringssl.rs
index 6c48250..4ae4e0b 100644
--- a/boringssl/boringssl.rs
+++ b/boringssl/boringssl.rs
@@ -316,19 +316,27 @@
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_ED25519_sign"]
pub fn ED25519_sign(
- out_sig: *mut u8, message: *const u8, message_len: usize, private_key: *const u8,
+ out_sig: *mut u8,
+ message: *const u8,
+ message_len: usize,
+ private_key: *const u8,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_ED25519_verify"]
pub fn ED25519_verify(
- message: *const u8, message_len: usize, signature: *const u8, public_key: *const u8,
+ message: *const u8,
+ message_len: usize,
+ signature: *const u8,
+ public_key: *const u8,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_ED25519_keypair_from_seed"]
pub fn ED25519_keypair_from_seed(
- out_public_key: *mut u8, out_private_key: *mut u8, seed: *const u8,
+ out_public_key: *mut u8,
+ out_private_key: *mut u8,
+ seed: *const u8,
);
}
extern "C" {
@@ -374,21 +382,31 @@
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_EC_KEY_marshal_private_key"]
pub fn EC_KEY_marshal_private_key(
- cbb: *mut CBB, key: *const EC_KEY, enc_flags: ::std::os::raw::c_uint,
+ cbb: *mut CBB,
+ key: *const EC_KEY,
+ enc_flags: ::std::os::raw::c_uint,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_ECDSA_sign"]
pub fn ECDSA_sign(
- type_: ::std::os::raw::c_int, digest: *const u8, digest_len: usize, sig: *mut u8,
- sig_len: *mut ::std::os::raw::c_uint, key: *const EC_KEY,
+ type_: ::std::os::raw::c_int,
+ digest: *const u8,
+ digest_len: usize,
+ sig: *mut u8,
+ sig_len: *mut ::std::os::raw::c_uint,
+ key: *const EC_KEY,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_ECDSA_verify"]
pub fn ECDSA_verify(
- type_: ::std::os::raw::c_int, digest: *const u8, digest_len: usize, sig: *const u8,
- sig_len: usize, key: *const EC_KEY,
+ type_: ::std::os::raw::c_int,
+ digest: *const u8,
+ digest_len: usize,
+ sig: *const u8,
+ sig_len: usize,
+ key: *const EC_KEY,
) -> ::std::os::raw::c_int;
}
extern "C" {
@@ -405,7 +423,8 @@
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_ERR_print_errors_cb"]
pub fn ERR_print_errors_cb(
- callback: ERR_print_errors_callback_t, ctx: *mut ::std::os::raw::c_void,
+ callback: ERR_print_errors_callback_t,
+ ctx: *mut ::std::os::raw::c_void,
);
}
pub type CRYPTO_refcount_t = u32;
@@ -522,16 +541,29 @@
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_PKCS5_PBKDF2_HMAC"]
pub fn PKCS5_PBKDF2_HMAC(
- password: *const ::std::os::raw::c_char, password_len: usize, salt: *const u8,
- salt_len: usize, iterations: ::std::os::raw::c_uint, digest: *const EVP_MD, key_len: usize,
+ password: *const ::std::os::raw::c_char,
+ password_len: usize,
+ salt: *const u8,
+ salt_len: usize,
+ iterations: ::std::os::raw::c_uint,
+ digest: *const EVP_MD,
+ key_len: usize,
out_key: *mut u8,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_EVP_PBE_scrypt"]
pub fn EVP_PBE_scrypt(
- password: *const ::std::os::raw::c_char, password_len: usize, salt: *const u8,
- salt_len: usize, N: u64, r: u64, p: u64, max_mem: usize, out_key: *mut u8, key_len: usize,
+ password: *const ::std::os::raw::c_char,
+ password_len: usize,
+ salt: *const u8,
+ salt_len: usize,
+ N: u64,
+ r: u64,
+ p: u64,
+ max_mem: usize,
+ out_key: *mut u8,
+ key_len: usize,
) -> ::std::os::raw::c_int;
}
#[repr(C)]
@@ -679,20 +711,27 @@
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_HMAC_Init_ex"]
pub fn HMAC_Init_ex(
- ctx: *mut HMAC_CTX, key: *const ::std::os::raw::c_void, key_len: usize, md: *const EVP_MD,
+ ctx: *mut HMAC_CTX,
+ key: *const ::std::os::raw::c_void,
+ key_len: usize,
+ md: *const EVP_MD,
impl_: *mut ENGINE,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_HMAC_Update"]
pub fn HMAC_Update(
- ctx: *mut HMAC_CTX, data: *const u8, data_len: usize,
+ ctx: *mut HMAC_CTX,
+ data: *const u8,
+ data_len: usize,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_HMAC_Final"]
pub fn HMAC_Final(
- ctx: *mut HMAC_CTX, out: *mut u8, out_len: *mut ::std::os::raw::c_uint,
+ ctx: *mut HMAC_CTX,
+ out: *mut u8,
+ out_len: *mut ::std::os::raw::c_uint,
) -> ::std::os::raw::c_int;
}
extern "C" {
@@ -763,7 +802,9 @@
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_CRYPTO_memcmp"]
pub fn CRYPTO_memcmp(
- a: *const ::std::os::raw::c_void, b: *const ::std::os::raw::c_void, len: usize,
+ a: *const ::std::os::raw::c_void,
+ b: *const ::std::os::raw::c_void,
+ len: usize,
) -> ::std::os::raw::c_int;
}
extern "C" {
@@ -777,7 +818,9 @@
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_SHA1_Update"]
pub fn SHA1_Update(
- sha: *mut SHA_CTX, data: *const ::std::os::raw::c_void, len: usize,
+ sha: *mut SHA_CTX,
+ data: *const ::std::os::raw::c_void,
+ len: usize,
) -> ::std::os::raw::c_int;
}
extern "C" {
@@ -976,7 +1019,9 @@
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_SHA256_Update"]
pub fn SHA256_Update(
- sha: *mut SHA256_CTX, data: *const ::std::os::raw::c_void, len: usize,
+ sha: *mut SHA256_CTX,
+ data: *const ::std::os::raw::c_void,
+ len: usize,
) -> ::std::os::raw::c_int;
}
extern "C" {
@@ -1073,7 +1118,9 @@
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_SHA384_Update"]
pub fn SHA384_Update(
- sha: *mut SHA512_CTX, data: *const ::std::os::raw::c_void, len: usize,
+ sha: *mut SHA512_CTX,
+ data: *const ::std::os::raw::c_void,
+ len: usize,
) -> ::std::os::raw::c_int;
}
extern "C" {
@@ -1087,7 +1134,9 @@
extern "C" {
#[link_name = "__RUST_MUNDANE_0_2_2_SHA512_Update"]
pub fn SHA512_Update(
- sha: *mut SHA512_CTX, data: *const ::std::os::raw::c_void, len: usize,
+ sha: *mut SHA512_CTX,
+ data: *const ::std::os::raw::c_void,
+ len: usize,
) -> ::std::os::raw::c_int;
}
extern "C" {
diff --git a/src/boringssl/mod.rs b/src/boringssl/mod.rs
index aa9876a..b53e089 100644
--- a/src/boringssl/mod.rs
+++ b/src/boringssl/mod.rs
@@ -76,13 +76,15 @@
mod raw;
// C types
-pub use boringssl::ffi::{CBB, CBS, EC_GROUP, EC_KEY, EVP_MD, EVP_PKEY, HMAC_CTX, SHA256_CTX,
- SHA512_CTX, SHA_CTX};
+pub use boringssl::ffi::{
+ CBB, CBS, EC_GROUP, EC_KEY, EVP_MD, EVP_PKEY, HMAC_CTX, SHA256_CTX, SHA512_CTX, SHA_CTX,
+};
// C constants
-pub use boringssl::ffi::{NID_X9_62_prime256v1, NID_secp384r1, NID_secp521r1,
- ED25519_PRIVATE_KEY_LEN, ED25519_PUBLIC_KEY_LEN, ED25519_SIGNATURE_LEN,
- SHA256_DIGEST_LENGTH, SHA384_DIGEST_LENGTH, SHA512_DIGEST_LENGTH,
- SHA_DIGEST_LENGTH};
+pub use boringssl::ffi::{
+ NID_X9_62_prime256v1, NID_secp384r1, NID_secp521r1, ED25519_PRIVATE_KEY_LEN,
+ ED25519_PUBLIC_KEY_LEN, ED25519_SIGNATURE_LEN, SHA256_DIGEST_LENGTH, SHA384_DIGEST_LENGTH,
+ SHA512_DIGEST_LENGTH, SHA_DIGEST_LENGTH,
+};
// wrapper types
pub use boringssl::wrapper::{CHeapWrapper, CRef, CStackWrapper};
@@ -93,15 +95,15 @@
use std::{mem, ptr, slice};
use boringssl::abort::UnwrapAbort;
-use boringssl::raw::{CBB_data, CBB_init, CBB_len, CBS_init, CBS_len, CRYPTO_memcmp, ECDSA_sign,
- ECDSA_size, ECDSA_verify, EC_GROUP_get_curve_name,
- EC_GROUP_new_by_curve_name, EC_KEY_generate_key, EC_KEY_get0_group,
- EC_KEY_marshal_private_key, EC_KEY_parse_private_key, EC_KEY_set_group,
- EC_curve_nid2nist, ED25519_keypair, ED25519_keypair_from_seed, ED25519_sign,
- ED25519_verify, ERR_print_errors_cb, EVP_PBE_scrypt, EVP_PKEY_assign_EC_KEY,
- EVP_PKEY_get1_EC_KEY, EVP_marshal_public_key, EVP_parse_public_key,
- HMAC_CTX_init, HMAC_Final, HMAC_Init_ex, HMAC_Update, HMAC_size, RAND_bytes,
- SHA384_Init};
+use boringssl::raw::{
+ CBB_data, CBB_init, CBB_len, CBS_init, CBS_len, CRYPTO_memcmp, ECDSA_sign, ECDSA_size,
+ ECDSA_verify, EC_GROUP_get_curve_name, EC_GROUP_new_by_curve_name, EC_KEY_generate_key,
+ EC_KEY_get0_group, EC_KEY_marshal_private_key, EC_KEY_parse_private_key, EC_KEY_set_group,
+ EC_curve_nid2nist, ED25519_keypair, ED25519_keypair_from_seed, ED25519_sign, ED25519_verify,
+ ERR_print_errors_cb, EVP_PBE_scrypt, EVP_PKEY_assign_EC_KEY, EVP_PKEY_get1_EC_KEY,
+ EVP_marshal_public_key, EVP_parse_public_key, HMAC_CTX_init, HMAC_Final, HMAC_Init_ex,
+ HMAC_Update, HMAC_size, RAND_bytes, SHA384_Init,
+};
impl CStackWrapper<CBB> {
/// Creates a new `CBB` and initializes it with `CBB_init`.
@@ -160,7 +162,8 @@
// TODO(joshlf): Holdover until we figure out how to put lifetimes in CStackWrappers.
#[must_use]
pub fn cbs_with_temp_buffer<O, F: Fn(&mut CStackWrapper<CBS>) -> O>(
- bytes: &[u8], with_cbs: F,
+ bytes: &[u8],
+ with_cbs: F,
) -> O {
unsafe {
let mut cbs = mem::uninitialized();
@@ -206,7 +209,8 @@
/// `EC_KEY_parse_private_key` will be NULL.
#[must_use]
pub fn ec_key_parse_private_key(
- cbs: &mut CStackWrapper<CBS>, group: Option<CRef<'static, EC_GROUP>>,
+ cbs: &mut CStackWrapper<CBS>,
+ group: Option<CRef<'static, EC_GROUP>>,
) -> Result<CHeapWrapper<EC_KEY>, BoringError> {
unsafe {
Ok(CHeapWrapper::new_from(EC_KEY_parse_private_key(
@@ -236,7 +240,8 @@
/// The `EC_KEY_marshal_private_key` function.
#[must_use]
pub fn ec_key_marshal_private_key(
- &self, cbb: &mut CStackWrapper<CBB>,
+ &self,
+ cbb: &mut CStackWrapper<CBB>,
) -> Result<(), BoringError> {
unsafe { EC_KEY_marshal_private_key(cbb.as_mut(), self.as_const(), 0) }
}
@@ -252,7 +257,9 @@
/// size given by `ecdsa_size`, or if `key` doesn't have a group set.
#[must_use]
pub fn ecdsa_sign(
- digest: &[u8], sig: &mut [u8], key: &CHeapWrapper<EC_KEY>,
+ digest: &[u8],
+ sig: &mut [u8],
+ key: &CHeapWrapper<EC_KEY>,
) -> Result<usize, BoringError> {
unsafe {
// If we call ECDSA_sign with sig.len() < min_size, it will invoke UB.
@@ -381,7 +388,13 @@
#[allow(non_snake_case)]
#[must_use]
pub fn evp_pbe_scrypt(
- password: &[u8], salt: &[u8], N: u64, r: u64, p: u64, max_mem: usize, out_key: &mut [u8],
+ password: &[u8],
+ salt: &[u8],
+ N: u64,
+ r: u64,
+ p: u64,
+ max_mem: usize,
+ out_key: &mut [u8],
) -> Result<(), BoringError> {
unsafe {
EVP_PBE_scrypt(
@@ -403,7 +416,10 @@
#[cfg(feature = "kdf")]
#[must_use]
pub fn pkcs5_pbkdf2_hmac(
- password: &[u8], salt: &[u8], iterations: c_uint, digest: &CRef<'static, EVP_MD>,
+ password: &[u8],
+ salt: &[u8],
+ iterations: c_uint,
+ digest: &CRef<'static, EVP_MD>,
out_key: &mut [u8],
) -> Result<(), BoringError> {
unsafe {
@@ -479,7 +495,8 @@
/// due to OOM.
#[must_use]
pub fn hmac_ctx_new(
- key: &[u8], md: &CRef<'static, EVP_MD>,
+ key: &[u8],
+ md: &CRef<'static, EVP_MD>,
) -> Result<CStackWrapper<HMAC_CTX>, BoringError> {
unsafe {
let mut ctx = mem::uninitialized();
diff --git a/src/boringssl/raw.rs b/src/boringssl/raw.rs
index c09bbd2..4d7ee63 100644
--- a/src/boringssl/raw.rs
+++ b/src/boringssl/raw.rs
@@ -15,9 +15,10 @@
//! (e.g., `void` functions).
// infallible functions
-pub use boringssl::ffi::{CBB_cleanup, CBB_len, CBS_init, CBS_len, CRYPTO_memcmp,
- EC_GROUP_get_curve_name, ED25519_keypair, ED25519_keypair_from_seed,
- ERR_print_errors_cb, HMAC_CTX_init, HMAC_size};
+pub use boringssl::ffi::{
+ CBB_cleanup, CBB_len, CBS_init, CBS_len, CRYPTO_memcmp, EC_GROUP_get_curve_name,
+ ED25519_keypair, ED25519_keypair_from_seed, ERR_print_errors_cb, HMAC_CTX_init, HMAC_size,
+};
use std::num::NonZeroUsize;
use std::os::raw::{c_char, c_int, c_uint, c_void};
@@ -50,7 +51,10 @@
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn ED25519_sign(
- out: *mut [u8; 64], message: *const u8, message_len: usize, private_key: *const [u8; 64],
+ out: *mut [u8; 64],
+ message: *const u8,
+ message_len: usize,
+ private_key: *const [u8; 64],
) -> Result<(), BoringError> {
one_or_err(
"ED25519_sign",
@@ -66,7 +70,10 @@
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn ED25519_verify(
- message: *const u8, message_len: usize, signature: *const [u8; 64], public_key: *const [u8; 32],
+ message: *const u8,
+ message_len: usize,
+ signature: *const [u8; 64],
+ public_key: *const [u8; 32],
) -> bool {
match ffi::ED25519_verify(
message,
@@ -138,7 +145,9 @@
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn EC_KEY_marshal_private_key(
- cbb: *mut CBB, key: *const EC_KEY, enc_flags: c_uint,
+ cbb: *mut CBB,
+ key: *const EC_KEY,
+ enc_flags: c_uint,
) -> Result<(), BoringError> {
one_or_err(
"EC_KEY_marshal_private_key",
@@ -149,7 +158,8 @@
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn EC_KEY_parse_private_key(
- cbs: *mut CBS, group: *const EC_GROUP,
+ cbs: *mut CBS,
+ group: *const EC_GROUP,
) -> Result<NonNull<EC_KEY>, BoringError> {
ptr_or_err(
"EC_KEY_parse_private_key",
@@ -160,7 +170,8 @@
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn EC_KEY_set_group(
- key: *mut EC_KEY, group: *const EC_GROUP,
+ key: *mut EC_KEY,
+ group: *const EC_GROUP,
) -> Result<(), BoringError> {
one_or_err("EC_KEY_set_group", ffi::EC_KEY_set_group(key, group))
}
@@ -170,7 +181,11 @@
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn ECDSA_sign(
- type_: c_int, digest: *const u8, digest_len: usize, sig: *mut u8, sig_len: *mut c_uint,
+ type_: c_int,
+ digest: *const u8,
+ digest_len: usize,
+ sig: *mut u8,
+ sig_len: *mut c_uint,
key: *const EC_KEY,
) -> Result<(), BoringError> {
one_or_err(
@@ -188,7 +203,11 @@
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn ECDSA_verify(
- type_: c_int, digest: *const u8, digest_len: usize, sig: *const u8, sig_len: usize,
+ type_: c_int,
+ digest: *const u8,
+ digest_len: usize,
+ sig: *const u8,
+ sig_len: usize,
key: *const EC_KEY,
) -> bool {
match ffi::ECDSA_verify(type_, digest, digest_len, sig, sig_len, key) {
@@ -204,7 +223,8 @@
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn EVP_marshal_public_key(
- cbb: *mut CBB, key: *const EVP_PKEY,
+ cbb: *mut CBB,
+ key: *const EVP_PKEY,
) -> Result<(), BoringError> {
one_or_err(
"EVP_marshal_public_key",
@@ -221,7 +241,8 @@
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn EVP_PKEY_assign_EC_KEY(
- pkey: *mut EVP_PKEY, key: *mut EC_KEY,
+ pkey: *mut EVP_PKEY,
+ key: *mut EC_KEY,
) -> Result<(), BoringError> {
one_or_err(
"EVP_PKEY_assign_EC_KEY",
@@ -241,8 +262,16 @@
#[cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))]
#[must_use]
pub unsafe fn EVP_PBE_scrypt(
- password: *const c_char, password_len: usize, salt: *const u8, salt_len: usize, N: u64, r: u64,
- p: u64, max_mem: usize, out_key: *mut u8, key_len: usize,
+ password: *const c_char,
+ password_len: usize,
+ salt: *const u8,
+ salt_len: usize,
+ N: u64,
+ r: u64,
+ p: u64,
+ max_mem: usize,
+ out_key: *mut u8,
+ key_len: usize,
) -> Result<(), BoringError> {
one_or_err(
"EVP_PBE_scrypt",
@@ -268,8 +297,14 @@
#[cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))]
#[must_use]
pub unsafe fn PKCS5_PBKDF2_HMAC(
- password: *const c_char, password_len: usize, salt: *const u8, salt_len: usize,
- iterations: c_uint, digest: *const EVP_MD, key_len: usize, out_key: *mut u8,
+ password: *const c_char,
+ password_len: usize,
+ salt: *const u8,
+ salt_len: usize,
+ iterations: c_uint,
+ digest: *const EVP_MD,
+ key_len: usize,
+ out_key: *mut u8,
) -> Result<(), BoringError> {
one_or_err(
"PKCS5_PBKDF2_HMAC",
@@ -299,7 +334,10 @@
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn HMAC_Init_ex(
- ctx: *mut HMAC_CTX, key: *const c_void, key_len: usize, md: *const EVP_MD,
+ ctx: *mut HMAC_CTX,
+ key: *const c_void,
+ key_len: usize,
+ md: *const EVP_MD,
) -> Result<(), BoringError> {
one_or_err(
"HMAC_Init_ex",
@@ -316,7 +354,9 @@
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn HMAC_Final(
- ctx: *mut HMAC_CTX, out: *mut u8, out_len: *mut c_uint,
+ ctx: *mut HMAC_CTX,
+ out: *mut u8,
+ out_len: *mut c_uint,
) -> Result<(), BoringError> {
one_or_err("HMAC_Final", ffi::HMAC_Final(ctx, out, out_len))
}
diff --git a/src/boringssl/wrapper.rs b/src/boringssl/wrapper.rs
index 2c63130..3645fe1 100644
--- a/src/boringssl/wrapper.rs
+++ b/src/boringssl/wrapper.rs
@@ -88,7 +88,8 @@
::boringssl::raw::one_or_err(
stringify!($up_ref),
::boringssl::raw::ffi::$up_ref(slf),
- ).unwrap_abort()
+ )
+ .unwrap_abort()
}
}
};
diff --git a/src/kdf.rs b/src/kdf.rs
index 97d5a07..3ed0fb3 100644
--- a/src/kdf.rs
+++ b/src/kdf.rs
@@ -82,7 +82,10 @@
/// [RFC 2898 Appendix B.1]: https://tools.ietf.org/html/rfc2898#appendix-B.1
#[deprecated(note = "PBKDF2-HMAC-SHA1 is considered insecure")]
pub fn insecure_pbkdf2_hmac_sha1(
- password: &[u8], salt: &[u8], iters: NonZeroU32, out_key: &mut [u8],
+ password: &[u8],
+ salt: &[u8],
+ iters: NonZeroU32,
+ out_key: &mut [u8],
) {
#[allow(deprecated)]
pbkdf2::<InsecureSha1>(password, salt, iters, out_key)
@@ -101,7 +104,10 @@
for iters in 1..8 {
for out_key_len in 0..8 {
fn test<H: Hasher>(
- password_len: usize, salt_len: usize, iters: u32, out_key_len: usize,
+ password_len: usize,
+ salt_len: usize,
+ iters: u32,
+ out_key_len: usize,
) {
let password = [0, 1, 2, 3, 4, 5, 6, 7];
let salt = [0, 1, 2, 3, 4, 5, 6, 7];
diff --git a/src/password.rs b/src/password.rs
index e89f0eb..cdd4411 100644
--- a/src/password.rs
+++ b/src/password.rs
@@ -150,7 +150,11 @@
#[allow(non_snake_case)]
#[must_use]
pub fn new(
- hash: [u8; SCRYPT_HASH_LEN], salt: [u8; SCRYPT_SALT_LEN], N: u64, r: u64, p: u64,
+ hash: [u8; SCRYPT_HASH_LEN],
+ salt: [u8; SCRYPT_SALT_LEN],
+ N: u64,
+ r: u64,
+ p: u64,
) -> ScryptHash {
ScryptHash {
hash,
@@ -198,7 +202,8 @@
params.p,
SCRYPT_MAX_MEM,
&mut hash,
- ).unwrap();
+ )
+ .unwrap();
ScryptHash {
hash,
salt,
@@ -221,7 +226,8 @@
hash.params.p,
SCRYPT_MAX_MEM,
&mut out_hash,
- ).is_err()
+ )
+ .is_err()
{
return false;
}
diff --git a/src/public/ec/mod.rs b/src/public/ec/mod.rs
index 63b63db..6bbc6e9 100644
--- a/src/public/ec/mod.rs
+++ b/src/public/ec/mod.rs
@@ -108,7 +108,8 @@
}
fn marshal_private_key(
- &self, cbb: &mut CStackWrapper<boringssl::CBB>,
+ &self,
+ cbb: &mut CStackWrapper<boringssl::CBB>,
) -> Result<(), Error> {
self.key.ec_key_marshal_private_key(cbb).map_err(From::from)
}
@@ -353,8 +354,10 @@
use boringssl;
use hash::{inner::Digest, Hasher, Sha256, Sha384};
- use public::{ec::{EcPrivKey, EcPubKey, PCurve, P256, P384, P521},
- Signature};
+ use public::{
+ ec::{EcPrivKey, EcPubKey, PCurve, P256, P384, P521},
+ Signature,
+ };
use util::Sealed;
use Error;
@@ -541,8 +544,10 @@
use super::*;
use hash::Sha256;
use public::ec::ecdsa::*;
- use public::{marshal_private_key_der, marshal_public_key_der, parse_private_key_der,
- parse_public_key_der, Signature};
+ use public::{
+ marshal_private_key_der, marshal_public_key_der, parse_private_key_der,
+ parse_public_key_der, Signature,
+ };
use util::should_fail;
#[test]
@@ -567,7 +572,8 @@
F: Fn(EcPrivKeyAnyCurve) -> EcPrivKey<C>,
G: Fn(EcPubKeyAnyCurve) -> EcPubKey<C>,
>(
- unwrap_priv_any: F, unwrap_pub_any: G,
+ unwrap_priv_any: F,
+ unwrap_pub_any: G,
) where
Sha256: EcdsaHash<C>,
{
@@ -587,7 +593,8 @@
);
fn sign_and_verify<C1: PCurve, C2: PCurve>(
- privkey: &EcPrivKey<C1>, pubkey: &EcPubKey<C2>,
+ privkey: &EcPrivKey<C1>,
+ pubkey: &EcPubKey<C2>,
) where
Sha256: EcdsaHash<C1>,
Sha256: EcdsaHash<C2>,
diff --git a/src/public/mod.rs b/src/public/mod.rs
index 26dc754..89a2c0b 100644
--- a/src/public/mod.rs
+++ b/src/public/mod.rs
@@ -196,13 +196,18 @@
/// invalid (it's up to the caller). If the byte slice is too short, it
/// fills in the remaining bytes with zeroes.
pub fn test_signature_smoke<S: Signature, F: Fn(&[u8]) -> S, G: Fn(&S) -> &[u8]>(
- key: &S::PrivateKey, sig_from_bytes: F, bytes_from_sig: G,
+ key: &S::PrivateKey,
+ sig_from_bytes: F,
+ bytes_from_sig: G,
) {
// Sign the message, verify the signature, and return the signature.
// Also verify that, if the wrong signature is used, the signature fails
// to verify. Also verify that sig_from_bytes works.
fn sign_and_verify<S: Signature, F: Fn(&[u8]) -> S, G: Fn(&S) -> &[u8]>(
- key: &S::PrivateKey, message: &[u8], sig_from_bytes: F, bytes_from_sig: G,
+ key: &S::PrivateKey,
+ message: &[u8],
+ sig_from_bytes: F,
+ bytes_from_sig: G,
) -> S {
let sig = S::sign(key, message).unwrap();
assert!(sig.verify(&key.public(), message));
@@ -220,7 +225,8 @@
&msg,
&sig_from_bytes,
&bytes_from_sig,
- )).to_vec();
+ ))
+ .to_vec();
}
}
}
diff --git a/src/util.rs b/src/util.rs
index b9bb0e7..256251c 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -19,7 +19,9 @@
/// panics.
#[cfg(test)]
pub fn should_fail<O, E: ::std::fmt::Debug>(
- result: Result<O, E>, desc: &str, expected_substr: &str,
+ result: Result<O, E>,
+ desc: &str,
+ expected_substr: &str,
) {
// Credit to agl@google.com for this implementation.
match result {