Skip to content

Commit

Permalink
Merge pull request #32 from RustCrypto/hkdf/2018-edition
Browse files Browse the repository at this point in the history
hkdf: 2018 edition upgrade
  • Loading branch information
tarcieri committed Jun 1, 2020
2 parents 6de4913 + 023a60a commit 12c7d13
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 24 deletions.
1 change: 1 addition & 0 deletions hkdf/Cargo.toml
Expand Up @@ -8,6 +8,7 @@ repository = "https://github.com/RustCrypto/KDFs/"
description = "HMAC-based Extract-and-Expand Key Derivation Function (HKDF)"
keywords = [ "HKDF", "Crypto" ]
readme = "README.md"
edition = "2018"

[features]
std = []
Expand Down
2 changes: 0 additions & 2 deletions hkdf/benches/hkdf.rs
@@ -1,7 +1,5 @@
#[macro_use]
extern crate bencher;
extern crate hkdf;
extern crate sha2;

use bencher::Bencher;
use hkdf::Hkdf;
Expand Down
4 changes: 0 additions & 4 deletions hkdf/examples/extract.rs
@@ -1,7 +1,3 @@
extern crate hex;
extern crate hkdf;
extern crate sha2;

use hkdf::Hkdf;
use sha2::Sha256;

Expand Down
4 changes: 0 additions & 4 deletions hkdf/examples/from_prk.rs
@@ -1,7 +1,3 @@
extern crate hex;
extern crate hkdf;
extern crate sha2;

use hkdf::Hkdf;
use sha2::Sha256;

Expand Down
4 changes: 0 additions & 4 deletions hkdf/examples/main.rs
@@ -1,7 +1,3 @@
extern crate hex;
extern crate hkdf;
extern crate sha2;

use hkdf::Hkdf;
use sha2::Sha256;

Expand Down
12 changes: 6 additions & 6 deletions hkdf/src/hkdf.rs
Expand Up @@ -23,10 +23,10 @@
//! ```
//!
//! [1]: https://tools.ietf.org/html/rfc5869

#![no_std]
#![warn(rust_2018_idioms)]

extern crate digest;
extern crate hmac;
#[cfg(feature = "std")]
extern crate std;

Expand Down Expand Up @@ -71,7 +71,7 @@ where
/// Create `Hkdf` from an already cryptographically strong pseudorandom key
/// as per section 3.3 from RFC5869.
pub fn from_prk(prk: &[u8]) -> Result<Hkdf<D>, InvalidPrkLength> {
use generic_array::typenum::Unsigned;
use crate::generic_array::typenum::Unsigned;

// section 2.3 specifies that prk must be "at least HashLen octets"
if prk.len() < D::OutputSize::to_usize() {
Expand Down Expand Up @@ -100,7 +100,7 @@ where

/// The RFC5869 HKDF-Expand operation
pub fn expand(&self, info: &[u8], okm: &mut [u8]) -> Result<(), InvalidLength> {
use generic_array::typenum::Unsigned;
use crate::generic_array::typenum::Unsigned;

let mut prev: Option<GenericArray<u8, <D as digest::FixedOutput>::OutputSize>> = None;

Expand Down Expand Up @@ -130,7 +130,7 @@ where
}

impl fmt::Display for InvalidPrkLength {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
f.write_str("invalid pseudorandom key length, too short")
}
}
Expand All @@ -139,7 +139,7 @@ impl fmt::Display for InvalidPrkLength {
impl ::std::error::Error for InvalidPrkLength {}

impl fmt::Display for InvalidLength {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
f.write_str("invalid number of blocks, too large output")
}
}
Expand Down
5 changes: 1 addition & 4 deletions hkdf/tests/tests.rs
@@ -1,7 +1,4 @@
extern crate hex;
extern crate hkdf;
extern crate sha1;
extern crate sha2;
use hex;

use hkdf::Hkdf;
use sha1::Sha1;
Expand Down

0 comments on commit 12c7d13

Please sign in to comment.