rustfmt with the latest Fuchsia style rules
Added a rustfmt.toml lifted from
https://fuchsia.googlesource.com/fuchsia/+/master/rustfmt.toml at the
time of writing, and then reran rustfmt on everything in the repo.
Change-Id: Ie81510c39bb0c7f6047fa149aa7210412cb6a42c
diff --git a/boringssl/boringssl.rs b/boringssl/boringssl.rs
index 36b54eb..ddf4fc8 100644
--- a/boringssl/boringssl.rs
+++ b/boringssl/boringssl.rs
@@ -45,11 +45,7 @@
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = if cfg!(target_endian = "big") {
- 7 - (index % 8)
- } else {
- index % 8
- };
+ let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 };
let mask = 1 << bit_index;
@@ -63,11 +59,7 @@
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = if cfg!(target_endian = "big") {
- 7 - (index % 8)
- } else {
- index % 8
- };
+ let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 };
let mask = 1 << bit_index;
if val {
@@ -87,11 +79,8 @@
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- let index = if cfg!(target_endian = "big") {
- bit_width as usize - 1 - i
- } else {
- i
- };
+ let index =
+ if cfg!(target_endian = "big") { bit_width as usize - 1 - i } else { i };
val |= 1 << index;
}
}
@@ -108,11 +97,7 @@
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- let index = if cfg!(target_endian = "big") {
- bit_width as usize - 1 - i
- } else {
- i
- };
+ let index = if cfg!(target_endian = "big") { bit_width as usize - 1 - i } else { i };
self.set_bit(index + bit_offset, val_bit_is_set);
}
}
@@ -153,12 +138,7 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<_opaque_pthread_rwlock_t>())).__sig as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(_opaque_pthread_rwlock_t),
- "::",
- stringify!(__sig)
- )
+ concat!("Offset of field: ", stringify!(_opaque_pthread_rwlock_t), "::", stringify!(__sig))
);
assert_eq!(
unsafe {
@@ -277,22 +257,12 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<bn_gencb_st>())).arg as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(bn_gencb_st),
- "::",
- stringify!(arg)
- )
+ concat!("Offset of field: ", stringify!(bn_gencb_st), "::", stringify!(arg))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<bn_gencb_st>())).callback as *const _ as usize },
8usize,
- concat!(
- "Offset of field: ",
- stringify!(bn_gencb_st),
- "::",
- stringify!(callback)
- )
+ concat!("Offset of field: ", stringify!(bn_gencb_st), "::", stringify!(callback))
);
}
#[repr(C)]
@@ -319,52 +289,27 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<bignum_st>())).d as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(bignum_st),
- "::",
- stringify!(d)
- )
+ concat!("Offset of field: ", stringify!(bignum_st), "::", stringify!(d))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<bignum_st>())).width as *const _ as usize },
8usize,
- concat!(
- "Offset of field: ",
- stringify!(bignum_st),
- "::",
- stringify!(width)
- )
+ concat!("Offset of field: ", stringify!(bignum_st), "::", stringify!(width))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<bignum_st>())).dmax as *const _ as usize },
12usize,
- concat!(
- "Offset of field: ",
- stringify!(bignum_st),
- "::",
- stringify!(dmax)
- )
+ concat!("Offset of field: ", stringify!(bignum_st), "::", stringify!(dmax))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<bignum_st>())).neg as *const _ as usize },
16usize,
- concat!(
- "Offset of field: ",
- stringify!(bignum_st),
- "::",
- stringify!(neg)
- )
+ concat!("Offset of field: ", stringify!(bignum_st), "::", stringify!(neg))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<bignum_st>())).flags as *const _ as usize },
20usize,
- concat!(
- "Offset of field: ",
- stringify!(bignum_st),
- "::",
- stringify!(flags)
- )
+ concat!("Offset of field: ", stringify!(bignum_st), "::", stringify!(flags))
);
}
#[repr(C)]
@@ -389,32 +334,17 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<bn_mont_ctx_st>())).RR as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(bn_mont_ctx_st),
- "::",
- stringify!(RR)
- )
+ concat!("Offset of field: ", stringify!(bn_mont_ctx_st), "::", stringify!(RR))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<bn_mont_ctx_st>())).N as *const _ as usize },
24usize,
- concat!(
- "Offset of field: ",
- stringify!(bn_mont_ctx_st),
- "::",
- stringify!(N)
- )
+ concat!("Offset of field: ", stringify!(bn_mont_ctx_st), "::", stringify!(N))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<bn_mont_ctx_st>())).n0 as *const _ as usize },
48usize,
- concat!(
- "Offset of field: ",
- stringify!(bn_mont_ctx_st),
- "::",
- stringify!(n0)
- )
+ concat!("Offset of field: ", stringify!(bn_mont_ctx_st), "::", stringify!(n0))
);
}
#[repr(C)]
@@ -425,11 +355,7 @@
}
#[test]
fn bindgen_test_layout_cbs_st() {
- assert_eq!(
- ::std::mem::size_of::<cbs_st>(),
- 16usize,
- concat!("Size of: ", stringify!(cbs_st))
- );
+ assert_eq!(::std::mem::size_of::<cbs_st>(), 16usize, concat!("Size of: ", stringify!(cbs_st)));
assert_eq!(
::std::mem::align_of::<cbs_st>(),
8usize,
@@ -438,22 +364,12 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbs_st>())).data as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(cbs_st),
- "::",
- stringify!(data)
- )
+ concat!("Offset of field: ", stringify!(cbs_st), "::", stringify!(data))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbs_st>())).len as *const _ as usize },
8usize,
- concat!(
- "Offset of field: ",
- stringify!(cbs_st),
- "::",
- stringify!(len)
- )
+ concat!("Offset of field: ", stringify!(cbs_st), "::", stringify!(len))
);
}
extern "C" {
@@ -488,52 +404,27 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbb_buffer_st>())).buf as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(cbb_buffer_st),
- "::",
- stringify!(buf)
- )
+ concat!("Offset of field: ", stringify!(cbb_buffer_st), "::", stringify!(buf))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbb_buffer_st>())).len as *const _ as usize },
8usize,
- concat!(
- "Offset of field: ",
- stringify!(cbb_buffer_st),
- "::",
- stringify!(len)
- )
+ concat!("Offset of field: ", stringify!(cbb_buffer_st), "::", stringify!(len))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbb_buffer_st>())).cap as *const _ as usize },
16usize,
- concat!(
- "Offset of field: ",
- stringify!(cbb_buffer_st),
- "::",
- stringify!(cap)
- )
+ concat!("Offset of field: ", stringify!(cbb_buffer_st), "::", stringify!(cap))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbb_buffer_st>())).can_resize as *const _ as usize },
24usize,
- concat!(
- "Offset of field: ",
- stringify!(cbb_buffer_st),
- "::",
- stringify!(can_resize)
- )
+ concat!("Offset of field: ", stringify!(cbb_buffer_st), "::", stringify!(can_resize))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbb_buffer_st>())).error as *const _ as usize },
25usize,
- concat!(
- "Offset of field: ",
- stringify!(cbb_buffer_st),
- "::",
- stringify!(error)
- )
+ concat!("Offset of field: ", stringify!(cbb_buffer_st), "::", stringify!(error))
);
}
#[repr(C)]
@@ -548,11 +439,7 @@
}
#[test]
fn bindgen_test_layout_cbb_st() {
- assert_eq!(
- ::std::mem::size_of::<cbb_st>(),
- 32usize,
- concat!("Size of: ", stringify!(cbb_st))
- );
+ assert_eq!(::std::mem::size_of::<cbb_st>(), 32usize, concat!("Size of: ", stringify!(cbb_st)));
assert_eq!(
::std::mem::align_of::<cbb_st>(),
8usize,
@@ -561,62 +448,32 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbb_st>())).base as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(cbb_st),
- "::",
- stringify!(base)
- )
+ concat!("Offset of field: ", stringify!(cbb_st), "::", stringify!(base))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbb_st>())).child as *const _ as usize },
8usize,
- concat!(
- "Offset of field: ",
- stringify!(cbb_st),
- "::",
- stringify!(child)
- )
+ concat!("Offset of field: ", stringify!(cbb_st), "::", stringify!(child))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbb_st>())).offset as *const _ as usize },
16usize,
- concat!(
- "Offset of field: ",
- stringify!(cbb_st),
- "::",
- stringify!(offset)
- )
+ concat!("Offset of field: ", stringify!(cbb_st), "::", stringify!(offset))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbb_st>())).pending_len_len as *const _ as usize },
24usize,
- concat!(
- "Offset of field: ",
- stringify!(cbb_st),
- "::",
- stringify!(pending_len_len)
- )
+ concat!("Offset of field: ", stringify!(cbb_st), "::", stringify!(pending_len_len))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbb_st>())).pending_is_asn1 as *const _ as usize },
25usize,
- concat!(
- "Offset of field: ",
- stringify!(cbb_st),
- "::",
- stringify!(pending_is_asn1)
- )
+ concat!("Offset of field: ", stringify!(cbb_st), "::", stringify!(pending_is_asn1))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<cbb_st>())).is_top_level as *const _ as usize },
26usize,
- concat!(
- "Offset of field: ",
- stringify!(cbb_st),
- "::",
- stringify!(is_top_level)
- )
+ concat!("Offset of field: ", stringify!(cbb_st), "::", stringify!(is_top_level))
);
}
extern "C" {
@@ -746,12 +603,7 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<crypto_ex_data_st>())).sk as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(crypto_ex_data_st),
- "::",
- stringify!(sk)
- )
+ concat!("Offset of field: ", stringify!(crypto_ex_data_st), "::", stringify!(sk))
);
}
extern "C" {
@@ -874,42 +726,22 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<env_md_ctx_st>())).digest as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(env_md_ctx_st),
- "::",
- stringify!(digest)
- )
+ concat!("Offset of field: ", stringify!(env_md_ctx_st), "::", stringify!(digest))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<env_md_ctx_st>())).md_data as *const _ as usize },
8usize,
- concat!(
- "Offset of field: ",
- stringify!(env_md_ctx_st),
- "::",
- stringify!(md_data)
- )
+ concat!("Offset of field: ", stringify!(env_md_ctx_st), "::", stringify!(md_data))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<env_md_ctx_st>())).pctx as *const _ as usize },
16usize,
- concat!(
- "Offset of field: ",
- stringify!(env_md_ctx_st),
- "::",
- stringify!(pctx)
- )
+ concat!("Offset of field: ", stringify!(env_md_ctx_st), "::", stringify!(pctx))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<env_md_ctx_st>())).pctx_ops as *const _ as usize },
24usize,
- concat!(
- "Offset of field: ",
- stringify!(env_md_ctx_st),
- "::",
- stringify!(pctx_ops)
- )
+ concat!("Offset of field: ", stringify!(env_md_ctx_st), "::", stringify!(pctx_ops))
);
}
extern "C" {
@@ -1009,52 +841,27 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<evp_pkey_st__bindgen_ty_1>())).ptr as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(evp_pkey_st__bindgen_ty_1),
- "::",
- stringify!(ptr)
- )
+ concat!("Offset of field: ", stringify!(evp_pkey_st__bindgen_ty_1), "::", stringify!(ptr))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evp_pkey_st__bindgen_ty_1>())).rsa as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(evp_pkey_st__bindgen_ty_1),
- "::",
- stringify!(rsa)
- )
+ concat!("Offset of field: ", stringify!(evp_pkey_st__bindgen_ty_1), "::", stringify!(rsa))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evp_pkey_st__bindgen_ty_1>())).dsa as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(evp_pkey_st__bindgen_ty_1),
- "::",
- stringify!(dsa)
- )
+ concat!("Offset of field: ", stringify!(evp_pkey_st__bindgen_ty_1), "::", stringify!(dsa))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evp_pkey_st__bindgen_ty_1>())).dh as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(evp_pkey_st__bindgen_ty_1),
- "::",
- stringify!(dh)
- )
+ concat!("Offset of field: ", stringify!(evp_pkey_st__bindgen_ty_1), "::", stringify!(dh))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evp_pkey_st__bindgen_ty_1>())).ec as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(evp_pkey_st__bindgen_ty_1),
- "::",
- stringify!(ec)
- )
+ concat!("Offset of field: ", stringify!(evp_pkey_st__bindgen_ty_1), "::", stringify!(ec))
);
}
#[test]
@@ -1072,42 +879,22 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<evp_pkey_st>())).references as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(evp_pkey_st),
- "::",
- stringify!(references)
- )
+ concat!("Offset of field: ", stringify!(evp_pkey_st), "::", stringify!(references))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evp_pkey_st>())).type_ as *const _ as usize },
4usize,
- concat!(
- "Offset of field: ",
- stringify!(evp_pkey_st),
- "::",
- stringify!(type_)
- )
+ concat!("Offset of field: ", stringify!(evp_pkey_st), "::", stringify!(type_))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evp_pkey_st>())).pkey as *const _ as usize },
8usize,
- concat!(
- "Offset of field: ",
- stringify!(evp_pkey_st),
- "::",
- stringify!(pkey)
- )
+ concat!("Offset of field: ", stringify!(evp_pkey_st), "::", stringify!(pkey))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<evp_pkey_st>())).ameth as *const _ as usize },
16usize,
- concat!(
- "Offset of field: ",
- stringify!(evp_pkey_st),
- "::",
- stringify!(ameth)
- )
+ concat!("Offset of field: ", stringify!(evp_pkey_st), "::", stringify!(ameth))
);
}
extern "C" {
@@ -1171,42 +958,22 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<hmac_ctx_st>())).md as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(hmac_ctx_st),
- "::",
- stringify!(md)
- )
+ concat!("Offset of field: ", stringify!(hmac_ctx_st), "::", stringify!(md))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<hmac_ctx_st>())).md_ctx as *const _ as usize },
8usize,
- concat!(
- "Offset of field: ",
- stringify!(hmac_ctx_st),
- "::",
- stringify!(md_ctx)
- )
+ concat!("Offset of field: ", stringify!(hmac_ctx_st), "::", stringify!(md_ctx))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<hmac_ctx_st>())).i_ctx as *const _ as usize },
40usize,
- concat!(
- "Offset of field: ",
- stringify!(hmac_ctx_st),
- "::",
- stringify!(i_ctx)
- )
+ concat!("Offset of field: ", stringify!(hmac_ctx_st), "::", stringify!(i_ctx))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<hmac_ctx_st>())).o_ctx as *const _ as usize },
72usize,
- concat!(
- "Offset of field: ",
- stringify!(hmac_ctx_st),
- "::",
- stringify!(o_ctx)
- )
+ concat!("Offset of field: ", stringify!(hmac_ctx_st), "::", stringify!(o_ctx))
);
}
extern "C" {
@@ -1372,102 +1139,52 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_meth_st>())).common as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_meth_st),
- "::",
- stringify!(common)
- )
+ concat!("Offset of field: ", stringify!(rsa_meth_st), "::", stringify!(common))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_meth_st>())).app_data as *const _ as usize },
8usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_meth_st),
- "::",
- stringify!(app_data)
- )
+ concat!("Offset of field: ", stringify!(rsa_meth_st), "::", stringify!(app_data))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_meth_st>())).init as *const _ as usize },
16usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_meth_st),
- "::",
- stringify!(init)
- )
+ concat!("Offset of field: ", stringify!(rsa_meth_st), "::", stringify!(init))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_meth_st>())).finish as *const _ as usize },
24usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_meth_st),
- "::",
- stringify!(finish)
- )
+ concat!("Offset of field: ", stringify!(rsa_meth_st), "::", stringify!(finish))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_meth_st>())).size as *const _ as usize },
32usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_meth_st),
- "::",
- stringify!(size)
- )
+ concat!("Offset of field: ", stringify!(rsa_meth_st), "::", stringify!(size))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_meth_st>())).sign as *const _ as usize },
40usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_meth_st),
- "::",
- stringify!(sign)
- )
+ concat!("Offset of field: ", stringify!(rsa_meth_st), "::", stringify!(sign))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_meth_st>())).sign_raw as *const _ as usize },
48usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_meth_st),
- "::",
- stringify!(sign_raw)
- )
+ concat!("Offset of field: ", stringify!(rsa_meth_st), "::", stringify!(sign_raw))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_meth_st>())).decrypt as *const _ as usize },
56usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_meth_st),
- "::",
- stringify!(decrypt)
- )
+ concat!("Offset of field: ", stringify!(rsa_meth_st), "::", stringify!(decrypt))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_meth_st>())).private_transform as *const _ as usize },
64usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_meth_st),
- "::",
- stringify!(private_transform)
- )
+ concat!("Offset of field: ", stringify!(rsa_meth_st), "::", stringify!(private_transform))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_meth_st>())).flags as *const _ as usize },
72usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_meth_st),
- "::",
- stringify!(flags)
- )
+ concat!("Offset of field: ", stringify!(rsa_meth_st), "::", stringify!(flags))
);
}
#[repr(C)]
@@ -1507,11 +1224,7 @@
}
#[test]
fn bindgen_test_layout_rsa_st() {
- assert_eq!(
- ::std::mem::size_of::<rsa_st>(),
- 376usize,
- concat!("Size of: ", stringify!(rsa_st))
- );
+ assert_eq!(::std::mem::size_of::<rsa_st>(), 376usize, concat!("Size of: ", stringify!(rsa_st)));
assert_eq!(
::std::mem::align_of::<rsa_st>(),
8usize,
@@ -1520,12 +1233,7 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).meth as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(meth)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(meth))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).n as *const _ as usize },
@@ -1555,132 +1263,67 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).dmp1 as *const _ as usize },
48usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(dmp1)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(dmp1))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).dmq1 as *const _ as usize },
56usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(dmq1)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(dmq1))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).iqmp as *const _ as usize },
64usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(iqmp)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(iqmp))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).ex_data as *const _ as usize },
72usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(ex_data)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(ex_data))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).references as *const _ as usize },
80usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(references)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(references))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).flags as *const _ as usize },
84usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(flags)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(flags))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).lock as *const _ as usize },
88usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(lock)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(lock))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).mont_n as *const _ as usize },
288usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(mont_n)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(mont_n))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).mont_p as *const _ as usize },
296usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(mont_p)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(mont_p))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).mont_q as *const _ as usize },
304usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(mont_q)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(mont_q))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).d_fixed as *const _ as usize },
312usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(d_fixed)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(d_fixed))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).dmp1_fixed as *const _ as usize },
320usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(dmp1_fixed)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(dmp1_fixed))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).dmq1_fixed as *const _ as usize },
328usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(dmq1_fixed)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(dmq1_fixed))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).inv_small_mod_large_mont as *const _ as usize },
@@ -1695,32 +1338,17 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).num_blindings as *const _ as usize },
344usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(num_blindings)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(num_blindings))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).blindings as *const _ as usize },
352usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(blindings)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(blindings))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rsa_st>())).blindings_inuse as *const _ as usize },
360usize,
- concat!(
- "Offset of field: ",
- stringify!(rsa_st),
- "::",
- stringify!(blindings_inuse)
- )
+ concat!("Offset of field: ", stringify!(rsa_st), "::", stringify!(blindings_inuse))
);
}
impl rsa_st {
@@ -1794,18 +1422,12 @@
assert_eq!(
::std::mem::size_of::<sha_state_st__bindgen_ty_1__bindgen_ty_1>(),
20usize,
- concat!(
- "Size of: ",
- stringify!(sha_state_st__bindgen_ty_1__bindgen_ty_1)
- )
+ concat!("Size of: ", stringify!(sha_state_st__bindgen_ty_1__bindgen_ty_1))
);
assert_eq!(
::std::mem::align_of::<sha_state_st__bindgen_ty_1__bindgen_ty_1>(),
4usize,
- concat!(
- "Alignment of ",
- stringify!(sha_state_st__bindgen_ty_1__bindgen_ty_1)
- )
+ concat!("Alignment of ", stringify!(sha_state_st__bindgen_ty_1__bindgen_ty_1))
);
assert_eq!(
unsafe {
@@ -1888,12 +1510,7 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha_state_st__bindgen_ty_1>())).h as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(sha_state_st__bindgen_ty_1),
- "::",
- stringify!(h)
- )
+ concat!("Offset of field: ", stringify!(sha_state_st__bindgen_ty_1), "::", stringify!(h))
);
}
#[test]
@@ -1911,42 +1528,22 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha_state_st>())).Nl as *const _ as usize },
20usize,
- concat!(
- "Offset of field: ",
- stringify!(sha_state_st),
- "::",
- stringify!(Nl)
- )
+ concat!("Offset of field: ", stringify!(sha_state_st), "::", stringify!(Nl))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha_state_st>())).Nh as *const _ as usize },
24usize,
- concat!(
- "Offset of field: ",
- stringify!(sha_state_st),
- "::",
- stringify!(Nh)
- )
+ concat!("Offset of field: ", stringify!(sha_state_st), "::", stringify!(Nh))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha_state_st>())).data as *const _ as usize },
28usize,
- concat!(
- "Offset of field: ",
- stringify!(sha_state_st),
- "::",
- stringify!(data)
- )
+ concat!("Offset of field: ", stringify!(sha_state_st), "::", stringify!(data))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha_state_st>())).num as *const _ as usize },
92usize,
- concat!(
- "Offset of field: ",
- stringify!(sha_state_st),
- "::",
- stringify!(num)
- )
+ concat!("Offset of field: ", stringify!(sha_state_st), "::", stringify!(num))
);
}
extern "C" {
@@ -1990,62 +1587,32 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha256_state_st>())).h as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(sha256_state_st),
- "::",
- stringify!(h)
- )
+ concat!("Offset of field: ", stringify!(sha256_state_st), "::", stringify!(h))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha256_state_st>())).Nl as *const _ as usize },
32usize,
- concat!(
- "Offset of field: ",
- stringify!(sha256_state_st),
- "::",
- stringify!(Nl)
- )
+ concat!("Offset of field: ", stringify!(sha256_state_st), "::", stringify!(Nl))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha256_state_st>())).Nh as *const _ as usize },
36usize,
- concat!(
- "Offset of field: ",
- stringify!(sha256_state_st),
- "::",
- stringify!(Nh)
- )
+ concat!("Offset of field: ", stringify!(sha256_state_st), "::", stringify!(Nh))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha256_state_st>())).data as *const _ as usize },
40usize,
- concat!(
- "Offset of field: ",
- stringify!(sha256_state_st),
- "::",
- stringify!(data)
- )
+ concat!("Offset of field: ", stringify!(sha256_state_st), "::", stringify!(data))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha256_state_st>())).num as *const _ as usize },
104usize,
- concat!(
- "Offset of field: ",
- stringify!(sha256_state_st),
- "::",
- stringify!(num)
- )
+ concat!("Offset of field: ", stringify!(sha256_state_st), "::", stringify!(num))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha256_state_st>())).md_len as *const _ as usize },
108usize,
- concat!(
- "Offset of field: ",
- stringify!(sha256_state_st),
- "::",
- stringify!(md_len)
- )
+ concat!("Offset of field: ", stringify!(sha256_state_st), "::", stringify!(md_len))
);
}
extern "C" {
@@ -2145,61 +1712,31 @@
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha512_state_st>())).h as *const _ as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(sha512_state_st),
- "::",
- stringify!(h)
- )
+ concat!("Offset of field: ", stringify!(sha512_state_st), "::", stringify!(h))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha512_state_st>())).Nl as *const _ as usize },
64usize,
- concat!(
- "Offset of field: ",
- stringify!(sha512_state_st),
- "::",
- stringify!(Nl)
- )
+ concat!("Offset of field: ", stringify!(sha512_state_st), "::", stringify!(Nl))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha512_state_st>())).Nh as *const _ as usize },
72usize,
- concat!(
- "Offset of field: ",
- stringify!(sha512_state_st),
- "::",
- stringify!(Nh)
- )
+ concat!("Offset of field: ", stringify!(sha512_state_st), "::", stringify!(Nh))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha512_state_st>())).u as *const _ as usize },
80usize,
- concat!(
- "Offset of field: ",
- stringify!(sha512_state_st),
- "::",
- stringify!(u)
- )
+ concat!("Offset of field: ", stringify!(sha512_state_st), "::", stringify!(u))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha512_state_st>())).num as *const _ as usize },
208usize,
- concat!(
- "Offset of field: ",
- stringify!(sha512_state_st),
- "::",
- stringify!(num)
- )
+ concat!("Offset of field: ", stringify!(sha512_state_st), "::", stringify!(num))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<sha512_state_st>())).md_len as *const _ as usize },
212usize,
- concat!(
- "Offset of field: ",
- stringify!(sha512_state_st),
- "::",
- stringify!(md_len)
- )
+ concat!("Offset of field: ", stringify!(sha512_state_st), "::", stringify!(md_len))
);
}
diff --git a/rustfmt.toml b/rustfmt.toml
new file mode 100644
index 0000000..57d9942
--- /dev/null
+++ b/rustfmt.toml
@@ -0,0 +1,15 @@
+# Fuchsia Format Style
+# last reviewed: Jan 29, 2019
+
+# Fuchsia uses 2018 edition only
+edition = "2018"
+
+# The "Default" setting has a heuristic which splits lines too aggresively.
+# We are willing to revisit this setting in future versions of rustfmt.
+# Bugs:
+# * https://github.com/rust-lang/rustfmt/issues/3119
+# * https://github.com/rust-lang/rustfmt/issues/3120
+use_small_heuristics = "Max"
+
+# Prevent carriage returns
+newline_style = "Unix"
diff --git a/src/boringssl/mod.rs b/src/boringssl/mod.rs
index 3b95135..ce5af6a 100644
--- a/src/boringssl/mod.rs
+++ b/src/boringssl/mod.rs
@@ -302,14 +302,7 @@
#[must_use]
pub fn ecdsa_verify(digest: &[u8], sig: &[u8], key: &CHeapWrapper<EC_KEY>) -> bool {
unsafe {
- ECDSA_verify(
- 0,
- digest.as_ptr(),
- digest.len(),
- sig.as_ptr(),
- sig.len(),
- key.as_const(),
- )
+ ECDSA_verify(0, digest.as_ptr(), digest.len(), sig.as_ptr(), sig.len(), key.as_const())
}
}
@@ -325,10 +318,7 @@
let mut public_unused = [0u8; ED25519_PUBLIC_KEY_LEN as usize];
let mut private = [0u8; ED25519_PRIVATE_KEY_LEN as usize];
unsafe {
- ED25519_keypair(
- (&mut public_unused[..]).as_mut_ptr(),
- (&mut private[..]).as_mut_ptr(),
- )
+ ED25519_keypair((&mut public_unused[..]).as_mut_ptr(), (&mut private[..]).as_mut_ptr())
};
private
}
@@ -537,12 +527,7 @@
unsafe {
let mut ctx = mem::uninitialized();
HMAC_CTX_init(&mut ctx);
- HMAC_Init_ex(
- &mut ctx,
- key.as_ptr() as *const c_void,
- key.len(),
- md.as_const(),
- )?;
+ HMAC_Init_ex(&mut ctx, key.as_ptr() as *const c_void, key.len(), md.as_const())?;
Ok(CStackWrapper::new(ctx))
}
}
@@ -725,13 +710,7 @@
if a.len() != b.len() {
return false;
}
- unsafe {
- CRYPTO_memcmp(
- a.as_ptr() as *const c_void,
- b.as_ptr() as *const c_void,
- a.len(),
- ) == 0
- }
+ unsafe { CRYPTO_memcmp(a.as_ptr() as *const c_void, b.as_ptr() as *const c_void, a.len()) == 0 }
}
/// The `RAND_bytes` function.
@@ -799,12 +778,7 @@
}
let mut stack_trace = Vec::new();
- unsafe {
- ERR_print_errors_cb(
- Some(error_callback),
- &mut stack_trace as *mut _ as *mut c_void,
- )
- };
+ unsafe { ERR_print_errors_cb(Some(error_callback), &mut stack_trace as *mut _ as *mut c_void) };
stack_trace
}
diff --git a/src/boringssl/raw.rs b/src/boringssl/raw.rs
index 0251597..8f94ee7 100644
--- a/src/boringssl/raw.rs
+++ b/src/boringssl/raw.rs
@@ -76,12 +76,7 @@
) -> Result<(), BoringError> {
one_or_err(
"ED25519_sign",
- ffi::ED25519_sign(
- out as *mut u8,
- message,
- message_len,
- private_key as *const u8,
- ),
+ ffi::ED25519_sign(out as *mut u8, message, message_len, private_key as *const u8),
)
}
@@ -93,12 +88,8 @@
signature: *const [u8; 64],
public_key: *const [u8; 32],
) -> bool {
- match ffi::ED25519_verify(
- message,
- message_len,
- signature as *const u8,
- public_key as *const u8,
- ) {
+ match ffi::ED25519_verify(message, message_len, signature as *const u8, public_key as *const u8)
+ {
0 => false,
1 => true,
// ED25519_verify promises to only return 0 or 1
@@ -131,10 +122,7 @@
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn EC_GROUP_new_by_curve_name(nid: c_int) -> Result<NonNull<EC_GROUP>, BoringError> {
- ptr_or_err(
- "EC_GROUP_new_by_curve_name",
- ffi::EC_GROUP_new_by_curve_name(nid),
- )
+ ptr_or_err("EC_GROUP_new_by_curve_name", ffi::EC_GROUP_new_by_curve_name(nid))
}
// ec_key.h
@@ -167,10 +155,7 @@
key: *const EC_KEY,
enc_flags: c_uint,
) -> Result<(), BoringError> {
- one_or_err(
- "EC_KEY_marshal_private_key",
- ffi::EC_KEY_marshal_private_key(cbb, key, enc_flags),
- )
+ one_or_err("EC_KEY_marshal_private_key", ffi::EC_KEY_marshal_private_key(cbb, key, enc_flags))
}
#[allow(non_snake_case)]
@@ -179,10 +164,7 @@
cbs: *mut CBS,
group: *const EC_GROUP,
) -> Result<NonNull<EC_KEY>, BoringError> {
- ptr_or_err(
- "EC_KEY_parse_private_key",
- ffi::EC_KEY_parse_private_key(cbs, group),
- )
+ ptr_or_err("EC_KEY_parse_private_key", ffi::EC_KEY_parse_private_key(cbs, group))
}
#[allow(non_snake_case)]
@@ -206,10 +188,7 @@
sig_len: *mut c_uint,
key: *const EC_KEY,
) -> Result<(), BoringError> {
- one_or_err(
- "ECDSA_sign",
- ffi::ECDSA_sign(type_, digest, digest_len, sig, sig_len, key),
- )
+ one_or_err("ECDSA_sign", ffi::ECDSA_sign(type_, digest, digest_len, sig, sig_len, key))
}
#[allow(non_snake_case)]
@@ -244,10 +223,7 @@
cbb: *mut CBB,
key: *const EVP_PKEY,
) -> Result<(), BoringError> {
- one_or_err(
- "EVP_marshal_public_key",
- ffi::EVP_marshal_public_key(cbb, key),
- )
+ one_or_err("EVP_marshal_public_key", ffi::EVP_marshal_public_key(cbb, key))
}
#[allow(non_snake_case)]
@@ -262,10 +238,7 @@
pkey: *mut EVP_PKEY,
key: *mut EC_KEY,
) -> Result<(), BoringError> {
- one_or_err(
- "EVP_PKEY_assign_EC_KEY",
- ffi::EVP_PKEY_assign_EC_KEY(pkey, key),
- )
+ one_or_err("EVP_PKEY_assign_EC_KEY", ffi::EVP_PKEY_assign_EC_KEY(pkey, key))
}
#[allow(non_snake_case)]
@@ -365,10 +338,7 @@
key_len: usize,
md: *const EVP_MD,
) -> Result<(), BoringError> {
- one_or_err(
- "HMAC_Init_ex",
- ffi::HMAC_Init_ex(ctx, key, key_len, md, ptr::null_mut()),
- )
+ one_or_err("HMAC_Init_ex", ffi::HMAC_Init_ex(ctx, key, key_len, md, ptr::null_mut()))
}
#[allow(non_snake_case)]
@@ -407,19 +377,13 @@
e: *const BIGNUM,
cb: *mut BN_GENCB,
) -> Result<(), BoringError> {
- one_or_err(
- "RSA_generate_key_ex",
- ffi::RSA_generate_key_ex(rsa, bits, e, cb),
- )
+ one_or_err("RSA_generate_key_ex", ffi::RSA_generate_key_ex(rsa, bits, e, cb))
}
#[allow(non_snake_case)]
#[must_use]
pub unsafe fn RSA_marshal_private_key(cbb: *mut CBB, rsa: *const RSA) -> Result<(), BoringError> {
- one_or_err(
- "RSA_marshal_private_key",
- ffi::RSA_marshal_private_key(cbb, rsa),
- )
+ one_or_err("RSA_marshal_private_key", ffi::RSA_marshal_private_key(cbb, rsa))
}
#[allow(non_snake_case)]
diff --git a/src/boringssl/wrapper.rs b/src/boringssl/wrapper.rs
index 91ff668..3b6ac46 100644
--- a/src/boringssl/wrapper.rs
+++ b/src/boringssl/wrapper.rs
@@ -281,10 +281,7 @@
/// ever be sent to other threads so long as this `CRef` exists.
#[must_use]
pub unsafe fn new(obj: NonNull<C>) -> CRef<'a, C> {
- CRef {
- obj,
- _lifetime: PhantomData,
- }
+ CRef { obj, _lifetime: PhantomData }
}
#[must_use]
@@ -315,10 +312,7 @@
/// called on `obj` when this `CStackWrapper` is dropped.
#[must_use]
pub unsafe fn new(obj: C) -> CStackWrapper<C> {
- CStackWrapper {
- obj,
- _no_sync: PhantomData,
- }
+ CStackWrapper { obj, _no_sync: PhantomData }
}
#[must_use]
@@ -346,10 +340,7 @@
unsafe {
let mut obj: C = mem::uninitialized();
C::init(&mut obj);
- CStackWrapper {
- obj,
- _no_sync: PhantomData,
- }
+ CStackWrapper { obj, _no_sync: PhantomData }
}
}
}
diff --git a/src/hash.rs b/src/hash.rs
index a42da6b..4f2ca68 100644
--- a/src/hash.rs
+++ b/src/hash.rs
@@ -144,9 +144,7 @@
// The Default impl for CStackWrapper<boringssl::SHA512_CTX> initializes
// it for a SHA-512 hash. Thus, we have to implement Default manually
// instead of deriving Default on Sha384.
- Sha384 {
- ctx: CStackWrapper::sha384_new(),
- }
+ Sha384 { ctx: CStackWrapper::sha384_new() }
}
}
diff --git a/src/hmac.rs b/src/hmac.rs
index 2a32cf5..57f5a1e 100644
--- a/src/hmac.rs
+++ b/src/hmac.rs
@@ -107,9 +107,7 @@
#[must_use]
#[deprecated(note = "HMAC-SHA1 is considered insecure")]
pub fn insecure_new(key: &[u8]) -> InsecureHmacSha1 {
- InsecureHmacSha1 {
- hmac: Hmac::new(key),
- }
+ InsecureHmacSha1 { hmac: Hmac::new(key) }
}
/// INSECURE: Adds bytes to the HMAC-SHA1.
diff --git a/src/password.rs b/src/password.rs
index cdd4411..1cb32a0 100644
--- a/src/password.rs
+++ b/src/password.rs
@@ -156,11 +156,7 @@
r: u64,
p: u64,
) -> ScryptHash {
- ScryptHash {
- hash,
- salt,
- params: ScryptParams { N, r, p },
- }
+ ScryptHash { hash, salt, params: ScryptParams { N, r, p } }
}
/// Gets the hash.
@@ -204,11 +200,7 @@
&mut hash,
)
.unwrap();
- ScryptHash {
- hash,
- salt,
- params: *params,
- }
+ ScryptHash { hash, salt, params: *params }
}
/// Verifies a password against an scrypt hash.
@@ -247,12 +239,7 @@
let mut params = SCRYPT_PARAMS_LAPTOP;
params.N /= 4;
let hash = scrypt_generate(&pass, ¶ms);
- assert!(
- scrypt_verify(&pass, &hash),
- "pass: {:?}, hash: {:?}",
- &pass[..],
- hash
- );
+ assert!(scrypt_verify(&pass, &hash), "pass: {:?}, hash: {:?}", &pass[..], hash);
}
}
}
diff --git a/src/public/ec/curve.rs b/src/public/ec/curve.rs
index f7e0da7..8e33e78 100644
--- a/src/public/ec/curve.rs
+++ b/src/public/ec/curve.rs
@@ -130,10 +130,7 @@
self::NID_P256 => Ok(CurveKind::P256),
self::NID_P384 => Ok(CurveKind::P384),
self::NID_P521 => Ok(CurveKind::P521),
- _ => Err(Error::new(format!(
- "unsupported curve: {}",
- nid_name(nid).unwrap()
- ))),
+ _ => Err(Error::new(format!("unsupported curve: {}", nid_name(nid).unwrap()))),
}
}
}
diff --git a/src/public/ec/mod.rs b/src/public/ec/mod.rs
index 8297ada..9de9ee5 100644
--- a/src/public/ec/mod.rs
+++ b/src/public/ec/mod.rs
@@ -58,10 +58,7 @@
// EC_KEY_set_group only errors if there's already a group set
key.ec_key_set_group(&C::group()).unwrap();
key.ec_key_generate_key()?;
- Ok(EcKey {
- key,
- _marker: PhantomData,
- })
+ Ok(EcKey { key, _marker: PhantomData })
}
/// Creates an `EcKey` from a BoringSSL `EC_KEY`.
@@ -76,10 +73,7 @@
// ec_key_get0_group returns the EC_KEY's internal group pointer,
// which is guaranteed to be set by the caller.
C::validate_group(key.ec_key_get0_group().unwrap())?;
- Ok(EcKey {
- key,
- _marker: PhantomData,
- })
+ Ok(EcKey { key, _marker: PhantomData })
}
}
@@ -185,9 +179,7 @@
/// Generates a new private key.
#[must_use]
pub fn generate() -> Result<EcPrivKey<C>, Error> {
- Ok(EcPrivKey {
- inner: EcKey::generate()?,
- })
+ Ok(EcPrivKey { inner: EcKey::generate()? })
}
}
@@ -208,9 +200,7 @@
type Public = EcPubKey<C>;
fn public(&self) -> EcPubKey<C> {
- EcPubKey {
- inner: self.inner.clone(),
- }
+ EcPubKey { inner: self.inner.clone() }
}
}
@@ -254,27 +244,23 @@
let mut evp_pkey = CHeapWrapper::evp_parse_public_key(cbs)?;
let key = evp_pkey.evp_pkey_get1_ec_key()?;
if cbs.cbs_len() > 0 {
- return Err(Error::new(
- "excess data provided after valid DER input".to_string(),
- ));
+ return Err(Error::new("excess data provided after valid DER input".to_string()));
}
// EVP_parse_public_key guarantees that the returned key has its group
// set, so this unwrap is safe.
let group = key.ec_key_get0_group().unwrap();
- Ok(
- match CurveKind::from_nid(group.ec_group_get_curve_name())? {
- CurveKind::P256 => EcPubKeyAnyCurve::P256(EcPubKey {
- inner: EcKey::from_EC_KEY(key.clone())?,
- }),
- CurveKind::P384 => EcPubKeyAnyCurve::P384(EcPubKey {
- inner: EcKey::from_EC_KEY(key.clone())?,
- }),
- CurveKind::P521 => EcPubKeyAnyCurve::P521(EcPubKey {
- inner: EcKey::from_EC_KEY(key.clone())?,
- }),
- },
- )
+ Ok(match CurveKind::from_nid(group.ec_group_get_curve_name())? {
+ CurveKind::P256 => {
+ EcPubKeyAnyCurve::P256(EcPubKey { inner: EcKey::from_EC_KEY(key.clone())? })
+ }
+ CurveKind::P384 => {
+ EcPubKeyAnyCurve::P384(EcPubKey { inner: EcKey::from_EC_KEY(key.clone())? })
+ }
+ CurveKind::P521 => {
+ EcPubKeyAnyCurve::P521(EcPubKey { inner: EcKey::from_EC_KEY(key.clone())? })
+ }
+ })
})
}
}
@@ -324,27 +310,23 @@
// EC_KEY_parse_private_key will require the DER to name the group.
let key = CHeapWrapper::ec_key_parse_private_key(cbs, None)?;
if cbs.cbs_len() > 0 {
- return Err(Error::new(
- "excess data provided after valid DER input".to_string(),
- ));
+ return Err(Error::new("excess data provided after valid DER input".to_string()));
}
// TODO(joshlf): Add documentation to EC_KEY_parse_private_key
// guaranteeing that the internal group pointer is set.
let group = key.ec_key_get0_group().unwrap();
- Ok(
- match CurveKind::from_nid(group.ec_group_get_curve_name())? {
- CurveKind::P256 => EcPrivKeyAnyCurve::P256(EcPrivKey {
- inner: EcKey::from_EC_KEY(key.clone())?,
- }),
- CurveKind::P384 => EcPrivKeyAnyCurve::P384(EcPrivKey {
- inner: EcKey::from_EC_KEY(key.clone())?,
- }),
- CurveKind::P521 => EcPrivKeyAnyCurve::P521(EcPrivKey {
- inner: EcKey::from_EC_KEY(key.clone())?,
- }),
- },
- )
+ Ok(match CurveKind::from_nid(group.ec_group_get_curve_name())? {
+ CurveKind::P256 => {
+ EcPrivKeyAnyCurve::P256(EcPrivKey { inner: EcKey::from_EC_KEY(key.clone())? })
+ }
+ CurveKind::P384 => {
+ EcPrivKeyAnyCurve::P384(EcPrivKey { inner: EcKey::from_EC_KEY(key.clone())? })
+ }
+ CurveKind::P521 => {
+ EcPrivKeyAnyCurve::P521(EcPrivKey { inner: EcKey::from_EC_KEY(key.clone())? })
+ }
+ })
})
}
}
@@ -455,11 +437,7 @@
}
fn empty() -> EcdsaSignature<C, H> {
- EcdsaSignature {
- bytes: [0u8; MAX_SIGNATURE_LEN],
- len: 0,
- _marker: PhantomData,
- }
+ EcdsaSignature { bytes: [0u8; MAX_SIGNATURE_LEN], len: 0, _marker: PhantomData }
}
}
diff --git a/src/public/ed25519.rs b/src/public/ed25519.rs
index e2564c3..ce253dd 100644
--- a/src/public/ed25519.rs
+++ b/src/public/ed25519.rs
@@ -59,9 +59,7 @@
/// Generates a new private key.
#[must_use]
pub fn generate() -> Ed25519PrivKey {
- Ed25519PrivKey {
- key: ed25519_keypair(),
- }
+ Ed25519PrivKey { key: ed25519_keypair() }
}
/// Constructs a new private key from a key pair.
diff --git a/src/public/mod.rs b/src/public/mod.rs
index 85e4a8c..574afeb 100644
--- a/src/public/mod.rs
+++ b/src/public/mod.rs
@@ -68,9 +68,7 @@
self.boring().pkey_assign(&mut evp_pkey);
// cbb_new can only fail due to OOM
let mut cbb = CStackWrapper::cbb_new(64).unwrap();
- evp_pkey
- .evp_marshal_public_key(&mut cbb)
- .expect("failed to marshal public key");
+ evp_pkey.evp_marshal_public_key(&mut cbb).expect("failed to marshal public key");
cbb.cbb_with_data(<[u8]>::to_vec)
}
@@ -121,9 +119,7 @@
fn marshal_to_der(&self) -> Vec<u8> {
// cbb_new can only fail due to OOM
let mut cbb = CStackWrapper::cbb_new(64).unwrap();
- self.boring()
- .marshal_private_key(&mut cbb)
- .expect("failed to marshal private key");
+ self.boring().marshal_private_key(&mut cbb).expect("failed to marshal private key");
cbb.cbb_with_data(<[u8]>::to_vec)
}
@@ -209,7 +205,7 @@
fn boring(&self) -> &Self::Boring;
- fn from_boring(Self::Boring) -> Self;
+ fn from_boring(boring: Self::Boring) -> Self;
}
}
@@ -256,13 +252,8 @@
// the next message to test, and repeat many times.
let mut msg = Vec::new();
for _ in 0..16 {
- msg = bytes_from_sig(&sign_and_verify(
- key,
- &msg,
- &sig_from_bytes,
- &bytes_from_sig,
- ))
- .to_vec();
+ msg = bytes_from_sig(&sign_and_verify(key, &msg, &sig_from_bytes, &bytes_from_sig))
+ .to_vec();
}
}
}
diff --git a/src/public/rsa/mod.rs b/src/public/rsa/mod.rs
index 7cdd395..d2f9a35 100644
--- a/src/public/rsa/mod.rs
+++ b/src/public/rsa/mod.rs
@@ -50,10 +50,7 @@
// BN_set_u64 can only fail due to OOM.
e.bn_set_u64(boringssl::RSA_F4.into()).unwrap();
key.rsa_generate_key_ex(B::BITS.try_into().unwrap(), &e.as_c_ref())?;
- Ok(RsaKey {
- key,
- _marker: PhantomData,
- })
+ Ok(RsaKey { key, _marker: PhantomData })
}
/// Creates an `RsaKey` from a BoringSSL `RSA`.
@@ -62,10 +59,7 @@
#[allow(non_snake_case)]
pub fn from_RSA(key: CHeapWrapper<boringssl::RSA>) -> Result<RsaKey<B>, Error> {
B::validate_bits(key.rsa_bits())?;
- Ok(RsaKey {
- key,
- _marker: PhantomData,
- })
+ Ok(RsaKey { key, _marker: PhantomData })
}
}
@@ -188,9 +182,7 @@
/// Generates a new private key.
#[must_use]
pub fn generate() -> Result<RsaPrivKey<B>, Error> {
- Ok(RsaPrivKey {
- inner: RsaKey::generate()?,
- })
+ Ok(RsaPrivKey { inner: RsaKey::generate()? })
}
}
@@ -211,9 +203,7 @@
type Public = RsaPubKey<B>;
fn public(&self) -> RsaPubKey<B> {
- RsaPubKey {
- inner: self.inner.clone(),
- }
+ RsaPubKey { inner: self.inner.clone() }
}
}
@@ -256,27 +246,25 @@
let mut evp_pkey = CHeapWrapper::evp_parse_public_key(cbs)?;
let key = evp_pkey.evp_pkey_get1_rsa()?;
if cbs.cbs_len() > 0 {
- return Err(Error::new(
- "excess data provided after valid DER input".to_string(),
- ));
+ return Err(Error::new("excess data provided after valid DER input".to_string()));
}
Ok(match key.rsa_bits().try_into().unwrap() {
- B2048::BITS => RsaPubKeyAnyBits::B2048(RsaPubKey {
- inner: RsaKey::from_RSA(key.clone())?,
- }),
- B3072::BITS => RsaPubKeyAnyBits::B3072(RsaPubKey {
- inner: RsaKey::from_RSA(key.clone())?,
- }),
- B4096::BITS => RsaPubKeyAnyBits::B4096(RsaPubKey {
- inner: RsaKey::from_RSA(key.clone())?,
- }),
- B6144::BITS => RsaPubKeyAnyBits::B6144(RsaPubKey {
- inner: RsaKey::from_RSA(key.clone())?,
- }),
- B8192::BITS => RsaPubKeyAnyBits::B8192(RsaPubKey {
- inner: RsaKey::from_RSA(key.clone())?,
- }),
+ B2048::BITS => {
+ RsaPubKeyAnyBits::B2048(RsaPubKey { inner: RsaKey::from_RSA(key.clone())? })
+ }
+ B3072::BITS => {
+ RsaPubKeyAnyBits::B3072(RsaPubKey { inner: RsaKey::from_RSA(key.clone())? })
+ }
+ B4096::BITS => {
+ RsaPubKeyAnyBits::B4096(RsaPubKey { inner: RsaKey::from_RSA(key.clone())? })
+ }
+ B6144::BITS => {
+ RsaPubKeyAnyBits::B6144(RsaPubKey { inner: RsaKey::from_RSA(key.clone())? })
+ }
+ B8192::BITS => {
+ RsaPubKeyAnyBits::B8192(RsaPubKey { inner: RsaKey::from_RSA(key.clone())? })
+ }
bits => return Err(Error::new(format!("unsupported bit length: {}", bits))),
})
})
@@ -327,27 +315,25 @@
CStackWrapper::cbs_with_temp_buffer(bytes, |cbs| {
let key = CHeapWrapper::rsa_parse_private_key(cbs)?;
if cbs.cbs_len() > 0 {
- return Err(Error::new(
- "excess data provided after valid DER input".to_string(),
- ));
+ return Err(Error::new("excess data provided after valid DER input".to_string()));
}
Ok(match key.rsa_bits().try_into().unwrap() {
- B2048::BITS => RsaPrivKeyAnyBits::B2048(RsaPrivKey {
- inner: RsaKey::from_RSA(key.clone())?,
- }),
- B3072::BITS => RsaPrivKeyAnyBits::B3072(RsaPrivKey {
- inner: RsaKey::from_RSA(key.clone())?,
- }),
- B4096::BITS => RsaPrivKeyAnyBits::B4096(RsaPrivKey {
- inner: RsaKey::from_RSA(key.clone())?,
- }),
- B6144::BITS => RsaPrivKeyAnyBits::B6144(RsaPrivKey {
- inner: RsaKey::from_RSA(key.clone())?,
- }),
- B8192::BITS => RsaPrivKeyAnyBits::B8192(RsaPrivKey {
- inner: RsaKey::from_RSA(key.clone())?,
- }),
+ B2048::BITS => {
+ RsaPrivKeyAnyBits::B2048(RsaPrivKey { inner: RsaKey::from_RSA(key.clone())? })
+ }
+ B3072::BITS => {
+ RsaPrivKeyAnyBits::B3072(RsaPrivKey { inner: RsaKey::from_RSA(key.clone())? })
+ }
+ B4096::BITS => {
+ RsaPrivKeyAnyBits::B4096(RsaPrivKey { inner: RsaKey::from_RSA(key.clone())? })
+ }
+ B6144::BITS => {
+ RsaPrivKeyAnyBits::B6144(RsaPrivKey { inner: RsaKey::from_RSA(key.clone())? })
+ }
+ B8192::BITS => {
+ RsaPrivKeyAnyBits::B8192(RsaPrivKey { inner: RsaKey::from_RSA(key.clone())? })
+ }
bits => return Err(Error::new(format!("unsupported bit length: {}", bits))),
})
})