Remove the DSA key generation trait, just make direct methods.

This commit is contained in:
2019-05-26 17:02:27 -07:00
parent 2912c72a07
commit 2145fb47fa

View File

@@ -43,30 +43,16 @@ impl<P: DSAParameters> KeyPair for DSAKeyPair<P>
} }
} }
/// A trait that's useful to indicate that the given key pair can be macro_rules! generate_dsa_pair {
/// generated at runtime, if necessary. Note, once again (I never get ($ptype: ident, $ltype: ident, $ntype: ident, $nbig: ident) => {
/// tired of this): You should probably only use this for testing or, impl DSAKeyPair<$ptype>
/// for legacy protocols, because you probably shouldn't be using DSA {
/// in new systems.
pub trait DSAKeyGeneration
{
type Params;
/// Generate a DSA key pair using the given parameters and random /// Generate a DSA key pair using the given parameters and random
/// number generator. Please make sure that the RNG you're using /// number generator. Please make sure that the RNG you're using
/// is suitable for key generators (look for the term "cryptographic" /// is suitable for key generators (look for the term "cryptographic"
/// or "crypto strong" in its documentation, or see if it matches /// or "crypto strong" in its documentation, or see if it matches
/// any of the NIST-suggested RNG algorithms). /// any of the NIST-suggested RNG algorithms).
fn generate<G: Rng>(params: &Self::Params, rng: &mut G) -> Self; pub fn generate<G: Rng>(params: &$ptype, rng: &mut G) -> Self
}
macro_rules! generate_dsa_pair {
($ptype: ident, $ltype: ident, $ntype: ident, $nbig: ident) => {
impl DSAKeyGeneration for DSAKeyPair<$ptype>
{
type Params = $ptype;
fn generate<G: Rng>(params: &$ptype, rng: &mut G) -> Self
{ {
// 1. N = len(q); L = len(p); // 1. N = len(q); L = len(p);
let n = $ptype::n_size(); let n = $ptype::n_size();