1 // Copyright 2023 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 /// Trait which defines hkdf operations 16 pub trait Hkdf { 17 /// Creates a new instance of an hkdf from a salt and key material new(salt: Option<&[u8]>, ikm: &[u8]) -> Self18 fn new(salt: Option<&[u8]>, ikm: &[u8]) -> Self; 19 20 /// The RFC5869 HKDF-Expand operation. The info argument for the expand is set to 21 /// the concatenation of all the elements of info_components expand_multi_info( &self, info_components: &[&[u8]], okm: &mut [u8], ) -> Result<(), InvalidLength>22 fn expand_multi_info( 23 &self, 24 info_components: &[&[u8]], 25 okm: &mut [u8], 26 ) -> Result<(), InvalidLength>; 27 28 /// The RFC5869 HKDF-Expand operation. expand(&self, info: &[u8], okm: &mut [u8]) -> Result<(), InvalidLength>29 fn expand(&self, info: &[u8], okm: &mut [u8]) -> Result<(), InvalidLength>; 30 } 31 32 /// Error type returned from the hkdf expand operations when the output key material has 33 /// an invalid length 34 #[derive(Debug)] 35 pub struct InvalidLength; 36