Avoid unnecessarily-named explicit lifetime parameters.
This commit is contained in:
parent
a19a4e6be8
commit
d712f6493b
10
build.rs
10
build.rs
@ -157,7 +157,7 @@ const RING_PERL_INCLUDES: &[&str] =
|
|||||||
|
|
||||||
const RING_BUILD_FILE: &[&str] = &["build.rs"];
|
const RING_BUILD_FILE: &[&str] = &["build.rs"];
|
||||||
|
|
||||||
const PREGENERATED: &'static str = "pregenerated";
|
const PREGENERATED: &str = "pregenerated";
|
||||||
|
|
||||||
fn c_flags(target: &Target) -> &'static [&'static str] {
|
fn c_flags(target: &Target) -> &'static [&'static str] {
|
||||||
if target.env != MSVC {
|
if target.env != MSVC {
|
||||||
@ -245,10 +245,10 @@ const ASM_TARGETS: &[(&str, Option<&str>, &str)] = &[
|
|||||||
("arm", None, "linux32"),
|
("arm", None, "linux32"),
|
||||||
];
|
];
|
||||||
|
|
||||||
const WINDOWS: &'static str = "windows";
|
const WINDOWS: &str = "windows";
|
||||||
const MSVC: &'static str = "msvc";
|
const MSVC: &str = "msvc";
|
||||||
const MSVC_OBJ_OPT: &'static str = "/Fo";
|
const MSVC_OBJ_OPT: &str = "/Fo";
|
||||||
const MSVC_OBJ_EXT: &'static str = "obj";
|
const MSVC_OBJ_EXT: &str = "obj";
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Ok(package_name) = std::env::var("CARGO_PKG_NAME") {
|
if let Ok(package_name) = std::env::var("CARGO_PKG_NAME") {
|
||||||
|
@ -72,12 +72,12 @@ impl Block {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a [u8; BLOCK_LEN]> for Block {
|
impl From<&'_ [u8; BLOCK_LEN]> for Block {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(bytes: &[u8; BLOCK_LEN]) -> Self { unsafe { core::mem::transmute_copy(bytes) } }
|
fn from(bytes: &[u8; BLOCK_LEN]) -> Self { unsafe { core::mem::transmute_copy(bytes) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From_<&'a [u8; 2 * BLOCK_LEN]> for [Block; 2] {
|
impl From_<&'_ [u8; 2 * BLOCK_LEN]> for [Block; 2] {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_(bytes: &[u8; 2 * BLOCK_LEN]) -> Self { unsafe { core::mem::transmute_copy(bytes) } }
|
fn from_(bytes: &[u8; 2 * BLOCK_LEN]) -> Self { unsafe { core::mem::transmute_copy(bytes) } }
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ use libc::size_t;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct Key([Block; KEY_BLOCKS]);
|
pub struct Key([Block; KEY_BLOCKS]);
|
||||||
|
|
||||||
impl<'a> From<&'a [u8; KEY_LEN]> for Key {
|
impl From<&'_ [u8; KEY_LEN]> for Key {
|
||||||
fn from(value: &[u8; KEY_LEN]) -> Self { Key(<[Block; KEY_BLOCKS]>::from_(value)) }
|
fn from(value: &[u8; KEY_LEN]) -> Self { Key(<[Block; KEY_BLOCKS]>::from_(value)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ pub struct EphemeralPrivateKey {
|
|||||||
alg: &'static Algorithm,
|
alg: &'static Algorithm,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> EphemeralPrivateKey {
|
impl EphemeralPrivateKey {
|
||||||
/// Generate a new ephemeral private key for the given algorithm.
|
/// Generate a new ephemeral private key for the given algorithm.
|
||||||
pub fn generate(
|
pub fn generate(
|
||||||
alg: &'static Algorithm, rng: &rand::SecureRandom,
|
alg: &'static Algorithm, rng: &rand::SecureRandom,
|
||||||
@ -126,7 +126,7 @@ impl<'a> EphemeralPrivateKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub fn bytes(&'a self) -> &'a [u8] { self.private_key.bytes_less_safe() }
|
pub fn bytes(&self) -> &[u8] { self.private_key.bytes_less_safe() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A public key for key agreement.
|
/// A public key for key agreement.
|
||||||
|
@ -62,7 +62,7 @@ pub(crate) fn write_hex_tuple(
|
|||||||
|
|
||||||
struct HexStr<'a>(pub &'a [u8]);
|
struct HexStr<'a>(pub &'a [u8]);
|
||||||
|
|
||||||
impl<'a> core::fmt::Debug for HexStr<'a> {
|
impl core::fmt::Debug for HexStr<'_> {
|
||||||
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
|
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
|
||||||
fmt.write_str("\"")?;
|
fmt.write_str("\"")?;
|
||||||
write_hex_bytes(fmt, self.0)?;
|
write_hex_bytes(fmt, self.0)?;
|
||||||
|
@ -42,7 +42,7 @@ pub struct KeyPair {
|
|||||||
|
|
||||||
derive_debug_via_field!(KeyPair, stringify!(Ed25519KeyPair), public_key);
|
derive_debug_via_field!(KeyPair, stringify!(Ed25519KeyPair), public_key);
|
||||||
|
|
||||||
impl<'a> KeyPair {
|
impl KeyPair {
|
||||||
/// Generates a new key pair and returns the key pair serialized as a
|
/// Generates a new key pair and returns the key pair serialized as a
|
||||||
/// PKCS#8 document.
|
/// PKCS#8 document.
|
||||||
///
|
///
|
||||||
|
@ -140,12 +140,7 @@ mod tests {
|
|||||||
use crate::{agreement, ec, limb, test};
|
use crate::{agreement, ec, limb, test};
|
||||||
use core;
|
use core;
|
||||||
|
|
||||||
static SUPPORTED_SUITE_B_ALGS: [(
|
static SUPPORTED_SUITE_B_ALGS: [(&str, &agreement::Algorithm, &ec::Curve, &ops::CommonOps); 2] = [
|
||||||
&'static str,
|
|
||||||
&'static agreement::Algorithm,
|
|
||||||
&'static ec::Curve,
|
|
||||||
&'static ops::CommonOps,
|
|
||||||
); 2] = [
|
|
||||||
(
|
(
|
||||||
"P-256",
|
"P-256",
|
||||||
&agreement::ECDH_P256,
|
&agreement::ECDH_P256,
|
||||||
|
@ -36,8 +36,7 @@ pub struct Algorithm {
|
|||||||
private_key_ops: &'static PrivateKeyOps,
|
private_key_ops: &'static PrivateKeyOps,
|
||||||
digest_alg: &'static digest::Algorithm,
|
digest_alg: &'static digest::Algorithm,
|
||||||
pkcs8_template: &'static pkcs8::Template,
|
pkcs8_template: &'static pkcs8::Template,
|
||||||
format_rs:
|
format_rs: fn(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &mut [u8]) -> usize,
|
||||||
for<'a> fn(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &'a mut [u8]) -> usize,
|
|
||||||
id: AlgorithmID,
|
id: AlgorithmID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,9 +245,7 @@ impl AsRef<[u8]> for PublicKey {
|
|||||||
fn as_ref(&self) -> &[u8] { self.0.as_ref() }
|
fn as_ref(&self) -> &[u8] { self.0.as_ref() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn format_rs_fixed<'a>(
|
fn format_rs_fixed(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &mut [u8]) -> usize {
|
||||||
ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &'a mut [u8],
|
|
||||||
) -> usize {
|
|
||||||
let scalar_len = ops.scalar_bytes_len();
|
let scalar_len = ops.scalar_bytes_len();
|
||||||
|
|
||||||
let (r_out, rest) = out.split_at_mut(scalar_len);
|
let (r_out, rest) = out.split_at_mut(scalar_len);
|
||||||
@ -260,7 +257,7 @@ fn format_rs_fixed<'a>(
|
|||||||
2 * scalar_len
|
2 * scalar_len
|
||||||
}
|
}
|
||||||
|
|
||||||
fn format_rs_asn1<'a>(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &'a mut [u8]) -> usize {
|
fn format_rs_asn1(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &mut [u8]) -> usize {
|
||||||
// This assumes `a` is not zero since neither `r` or `s` is allowed to be
|
// This assumes `a` is not zero since neither `r` or `s` is allowed to be
|
||||||
// zero.
|
// zero.
|
||||||
fn format_integer_tlv(ops: &ScalarOps, a: &Scalar, out: &mut [u8]) -> usize {
|
fn format_integer_tlv(ops: &ScalarOps, a: &Scalar, out: &mut [u8]) -> usize {
|
||||||
|
@ -219,9 +219,9 @@ mod tests {
|
|||||||
assert!(r.is_err());
|
assert!(r.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZERO_INTEGER: &'static [u8] = &[0x02, 0x01, 0x00];
|
static ZERO_INTEGER: &[u8] = &[0x02, 0x01, 0x00];
|
||||||
|
|
||||||
static GOOD_POSITIVE_INTEGERS: &'static [(&'static [u8], u8)] = &[
|
static GOOD_POSITIVE_INTEGERS: &[(&[u8], u8)] = &[
|
||||||
(&[0x02, 0x01, 0x01], 0x01),
|
(&[0x02, 0x01, 0x01], 0x01),
|
||||||
(&[0x02, 0x01, 0x02], 0x02),
|
(&[0x02, 0x01, 0x02], 0x02),
|
||||||
(&[0x02, 0x01, 0x7e], 0x7e),
|
(&[0x02, 0x01, 0x7e], 0x7e),
|
||||||
@ -234,7 +234,7 @@ mod tests {
|
|||||||
(&[0x02, 0x02, 0x00, 0xff], 0xff),
|
(&[0x02, 0x02, 0x00, 0xff], 0xff),
|
||||||
];
|
];
|
||||||
|
|
||||||
static BAD_NONNEGATIVE_INTEGERS: &'static [&'static [u8]] = &[
|
static BAD_NONNEGATIVE_INTEGERS: &[&[u8]] = &[
|
||||||
&[], // At end of input
|
&[], // At end of input
|
||||||
&[0x02], // Tag only
|
&[0x02], // Tag only
|
||||||
&[0x02, 0x00], // Empty value
|
&[0x02, 0x00], // Empty value
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
//! use ring::{digest, pbkdf2};
|
//! use ring::{digest, pbkdf2};
|
||||||
//! use std::{collections::HashMap, num::NonZeroU32};
|
//! use std::{collections::HashMap, num::NonZeroU32};
|
||||||
//!
|
//!
|
||||||
//! static DIGEST_ALG: &'static digest::Algorithm = &digest::SHA256;
|
//! static DIGEST_ALG: &digest::Algorithm = &digest::SHA256;
|
||||||
//! const CREDENTIAL_LEN: usize = digest::SHA256_OUTPUT_LEN;
|
//! const CREDENTIAL_LEN: usize = digest::SHA256_OUTPUT_LEN;
|
||||||
//! pub type Credential = [u8; CREDENTIAL_LEN];
|
//! pub type Credential = [u8; CREDENTIAL_LEN];
|
||||||
//!
|
//!
|
||||||
|
@ -285,7 +285,7 @@ mod darwin {
|
|||||||
|
|
||||||
#[link(name = "Security", kind = "framework")]
|
#[link(name = "Security", kind = "framework")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static kSecRandomDefault: &'static SecRandomRef;
|
static kSecRandomDefault: &SecRandomRef;
|
||||||
|
|
||||||
// For now `rnd` must be `kSecRandomDefault`.
|
// For now `rnd` must be `kSecRandomDefault`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
@ -350,7 +350,7 @@ struct PartialModulus<'a, M> {
|
|||||||
m: PhantomData<M>,
|
m: PhantomData<M>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, M> PartialModulus<'a, M> {
|
impl<M> PartialModulus<'_, M> {
|
||||||
// TODO: XXX Avoid duplication with `Modulus`.
|
// TODO: XXX Avoid duplication with `Modulus`.
|
||||||
fn zero(&self) -> Elem<M, R> {
|
fn zero(&self) -> Elem<M, R> {
|
||||||
let width = Width {
|
let width = Width {
|
||||||
|
@ -407,7 +407,7 @@ impl PublicKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The public modulus (n).
|
/// The public modulus (n).
|
||||||
pub fn modulus<'a>(&'a self) -> io::Positive<'a> {
|
pub fn modulus(&self) -> io::Positive {
|
||||||
// Parsing won't fail because we serialized it ourselves.
|
// Parsing won't fail because we serialized it ourselves.
|
||||||
let (public_key, _exponent) =
|
let (public_key, _exponent) =
|
||||||
super::parse_public_key(untrusted::Input::from(self.as_ref())).unwrap();
|
super::parse_public_key(untrusted::Input::from(self.as_ref())).unwrap();
|
||||||
@ -415,7 +415,7 @@ impl PublicKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The public exponent (e).
|
/// The public exponent (e).
|
||||||
pub fn exponent<'a>(&'a self) -> io::Positive<'a> {
|
pub fn exponent(&self) -> io::Positive {
|
||||||
// Parsing won't fail because we serialized it ourselves.
|
// Parsing won't fail because we serialized it ourselves.
|
||||||
let (_public_key, exponent) =
|
let (_public_key, exponent) =
|
||||||
super::parse_public_key(untrusted::Input::from(self.as_ref())).unwrap();
|
super::parse_public_key(untrusted::Input::from(self.as_ref())).unwrap();
|
||||||
|
14
src/test.rs
14
src/test.rs
@ -376,8 +376,8 @@ fn from_hex_digit(d: u8) -> Result<u8, String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_test_case<'a>(
|
fn parse_test_case(
|
||||||
current_section: &mut String, lines: &mut Iterator<Item = &'a str>,
|
current_section: &mut String, lines: &mut Iterator<Item = &str>,
|
||||||
) -> Option<TestCase> {
|
) -> Option<TestCase> {
|
||||||
let mut attributes = Vec::new();
|
let mut attributes = Vec::new();
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ pub mod rand {
|
|||||||
pub bytes: &'a [u8],
|
pub bytes: &'a [u8],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> rand::SecureRandom for FixedSliceRandom<'a> {
|
impl rand::SecureRandom for FixedSliceRandom<'_> {
|
||||||
fn fill(&self, dest: &mut [u8]) -> Result<(), error::Unspecified> {
|
fn fill(&self, dest: &mut [u8]) -> Result<(), error::Unspecified> {
|
||||||
dest.copy_from_slice(self.bytes);
|
dest.copy_from_slice(self.bytes);
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -501,7 +501,7 @@ pub mod rand {
|
|||||||
pub current: core::cell::UnsafeCell<usize>,
|
pub current: core::cell::UnsafeCell<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> rand::SecureRandom for FixedSliceSequenceRandom<'a> {
|
impl rand::SecureRandom for FixedSliceSequenceRandom<'_> {
|
||||||
fn fill(&self, dest: &mut [u8]) -> Result<(), error::Unspecified> {
|
fn fill(&self, dest: &mut [u8]) -> Result<(), error::Unspecified> {
|
||||||
let current = unsafe { *self.current.get() };
|
let current = unsafe { *self.current.get() };
|
||||||
let bytes = self.bytes[current];
|
let bytes = self.bytes[current];
|
||||||
@ -513,7 +513,7 @@ pub mod rand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Drop for FixedSliceSequenceRandom<'a> {
|
impl Drop for FixedSliceSequenceRandom<'_> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// Ensure that `fill()` was called exactly the right number of
|
// Ensure that `fill()` was called exactly the right number of
|
||||||
// times.
|
// times.
|
||||||
@ -522,8 +522,8 @@ pub mod rand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl sealed::Sealed for FixedByteRandom {}
|
impl sealed::Sealed for FixedByteRandom {}
|
||||||
impl<'a> sealed::Sealed for FixedSliceRandom<'a> {}
|
impl sealed::Sealed for FixedSliceRandom<'_> {}
|
||||||
impl<'a> sealed::Sealed for FixedSliceSequenceRandom<'a> {}
|
impl sealed::Sealed for FixedSliceSequenceRandom<'_> {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,9 +210,9 @@ fn signature_ecdsa_verify_fixed_test() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ecdsa_test_public_key_coverage() {
|
fn ecdsa_test_public_key_coverage() {
|
||||||
const PRIVATE_KEY: &'static [u8] = include_bytes!("ecdsa_test_private_key_p256.p8");
|
const PRIVATE_KEY: &[u8] = include_bytes!("ecdsa_test_private_key_p256.p8");
|
||||||
const PUBLIC_KEY: &'static [u8] = include_bytes!("ecdsa_test_public_key_p256.der");
|
const PUBLIC_KEY: &[u8] = include_bytes!("ecdsa_test_public_key_p256.der");
|
||||||
const PUBLIC_KEY_DEBUG: &'static str = include_str!("ecdsa_test_public_key_p256_debug.txt");
|
const PUBLIC_KEY_DEBUG: &str = include_str!("ecdsa_test_public_key_p256_debug.txt");
|
||||||
|
|
||||||
let key_pair = signature::EcdsaKeyPair::from_pkcs8(
|
let key_pair = signature::EcdsaKeyPair::from_pkcs8(
|
||||||
&signature::ECDSA_P256_SHA256_FIXED_SIGNING,
|
&signature::ECDSA_P256_SHA256_FIXED_SIGNING,
|
||||||
|
@ -168,8 +168,8 @@ fn test_ed25519_from_pkcs8() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ed25519_test_public_key_coverage() {
|
fn ed25519_test_public_key_coverage() {
|
||||||
const PRIVATE_KEY: &'static [u8] = include_bytes!("ed25519_test_private_key.p8");
|
const PRIVATE_KEY: &[u8] = include_bytes!("ed25519_test_private_key.p8");
|
||||||
const PUBLIC_KEY: &'static [u8] = include_bytes!("ed25519_test_public_key.der");
|
const PUBLIC_KEY: &[u8] = include_bytes!("ed25519_test_public_key.der");
|
||||||
const PUBLIC_KEY_DEBUG: &'static str =
|
const PUBLIC_KEY_DEBUG: &'static str =
|
||||||
"PublicKey(\"5809e9fef6dcec58f0f2e3b0d67e9880a11957e083ace85835c3b6c8fbaf6b7d\")";
|
"PublicKey(\"5809e9fef6dcec58f0f2e3b0d67e9880a11957e083ace85835c3b6c8fbaf6b7d\")";
|
||||||
|
|
||||||
|
@ -280,9 +280,9 @@ fn test_signature_rsa_primitive_verification() {
|
|||||||
#[cfg(feature = "use_heap")]
|
#[cfg(feature = "use_heap")]
|
||||||
#[test]
|
#[test]
|
||||||
fn rsa_test_public_key_coverage() {
|
fn rsa_test_public_key_coverage() {
|
||||||
const PRIVATE_KEY: &'static [u8] = include_bytes!("rsa_test_private_key_2048.p8");
|
const PRIVATE_KEY: &[u8] = include_bytes!("rsa_test_private_key_2048.p8");
|
||||||
const PUBLIC_KEY: &'static [u8] = include_bytes!("rsa_test_public_key_2048.der");
|
const PUBLIC_KEY: &[u8] = include_bytes!("rsa_test_public_key_2048.der");
|
||||||
const PUBLIC_KEY_DEBUG: &'static str = include_str!("rsa_test_public_key_2048_debug.txt");
|
const PUBLIC_KEY_DEBUG: &str = include_str!("rsa_test_public_key_2048_debug.txt");
|
||||||
|
|
||||||
let key_pair = signature::RsaKeyPair::from_pkcs8(untrusted::Input::from(PRIVATE_KEY)).unwrap();
|
let key_pair = signature::RsaKeyPair::from_pkcs8(untrusted::Input::from(PRIVATE_KEY)).unwrap();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user