2020-06-14 23:25:31 -07:00
|
|
|
// Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
|
//
|
|
|
|
|
// This source code is licensed under the MIT license found in the
|
|
|
|
|
// LICENSE file in the root directory of this source tree.
|
2020-06-11 14:46:46 -07:00
|
|
|
|
2020-06-14 23:25:31 -07:00
|
|
|
//! Defines the CipherSuite trait to specify the underlying primitives for OPAQUE
|
|
|
|
|
|
|
|
|
|
use crate::{
|
2021-04-16 01:07:07 -07:00
|
|
|
hash::Hash, key_exchange::traits::KeyExchange, map_to_curve::GroupWithMapToCurve,
|
|
|
|
|
slow_hash::SlowHash,
|
2020-06-14 23:25:31 -07:00
|
|
|
};
|
2021-01-28 14:31:20 -08:00
|
|
|
use digest::Digest;
|
2020-07-03 18:28:35 -04:00
|
|
|
|
2020-06-14 23:25:31 -07:00
|
|
|
/// Configures the underlying primitives used in OPAQUE
|
2020-07-13 15:23:29 -07:00
|
|
|
/// * `Group`: a finite cyclic group along with a point representation, along
|
|
|
|
|
/// with an extension trait PasswordToCurve that allows some customization on
|
|
|
|
|
/// how to hash a password to a curve point. See `group::Group` and
|
|
|
|
|
/// `map_to_curve::GroupWithMapToCurve`.
|
|
|
|
|
/// * `KeyExchange`: The key exchange protocol to use in the login step
|
2020-07-27 15:25:04 -07:00
|
|
|
/// * `Hash`: The main hashing function to use
|
|
|
|
|
/// * `SlowHash`: A slow hashing function, typically used for password hashing
|
2020-06-11 14:46:46 -07:00
|
|
|
pub trait CipherSuite {
|
2020-07-06 15:40:35 -04:00
|
|
|
/// A finite cyclic group along with a point representation along with
|
|
|
|
|
/// an extension trait PasswordToCurve that allows some customization on
|
|
|
|
|
/// how to hash a password to a curve point. See `group::Group` and
|
|
|
|
|
/// `map_to_curve::GroupWithMapToCurve`.
|
2021-01-28 14:31:20 -08:00
|
|
|
type Group: GroupWithMapToCurve<UniformBytesLen = <Self::Hash as Digest>::OutputSize>;
|
2020-07-13 15:23:29 -07:00
|
|
|
/// A key exchange protocol
|
2021-01-25 13:20:36 -08:00
|
|
|
type KeyExchange: KeyExchange<Self::Hash, Self::Group>;
|
2020-07-27 15:25:04 -07:00
|
|
|
/// The main hash function use (for HKDF computations and hashing transcripts)
|
|
|
|
|
type Hash: Hash;
|
2020-07-06 15:40:35 -04:00
|
|
|
/// A slow hashing function, typically used for password hashing
|
2020-07-27 15:25:04 -07:00
|
|
|
type SlowHash: SlowHash<Self::Hash>;
|
2020-06-11 14:46:46 -07:00
|
|
|
}
|