Adding CipherSuite trait to handle bundling of underlying crypto primitives

This commit is contained in:
Kevin Lewi
2020-06-14 23:25:31 -07:00
parent f030fca1cb
commit 0cf13c2266
7 changed files with 446 additions and 371 deletions
+27 -3
View File
@@ -1,6 +1,30 @@
// 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.
//! Defines the CipherSuite trait to specify the underlying primitives for OPAQUE
use crate::{
errors::InternalPakeError,
group::Group,
keypair::{Key, KeyPair},
slow_hash::SlowHash,
};
use generic_array::typenum::{U32, U64};
use rand_core::{CryptoRng, RngCore};
/// Configures the underlying primitives used in OPAQUE
pub trait CipherSuite {
type Aead;
type Group;
type Keypair;
type Aead: aead::NewAead<KeySize = U32> + aead::Aead;
type Group: Group<ScalarLen = U32, UniformBytesLen = U64>;
type KeyFormat: KeyPair<Repr = Key> + PartialEq;
type SlowHash: SlowHash;
/// Generating a random key pair given a cryptographic rng
fn generate_random_keypair<R: RngCore + CryptoRng>(
rng: &mut R,
) -> Result<Self::KeyFormat, InternalPakeError> {
Self::KeyFormat::generate_random(rng)
}
}