• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:algorithm

1 // Copyright 2015-2017 Brian Smith.
19 //! Note that this example uses X25519, but ECDH using NIST P-256/P-384 is done
70 /// A key agreement algorithm.
71 pub struct Algorithm { struct
77 ) -> Result<(), error::Unspecified>,
80 derive_debug_via_field!(Algorithm, curve); argument
82 impl Eq for Algorithm {} implementation
83 impl PartialEq for Algorithm { implementation
84 fn eq(&self, other: &Self) -> bool { in eq()
94 algorithm: &'static Algorithm, field
100 algorithm
104 /// Generate a new ephemeral private key for the given algorithm.
106 alg: &'static Algorithm, in generate() argument
108 ) -> Result<Self, error::Unspecified> { in generate()
118 algorithm: alg, in generate()
124 pub fn compute_public_key(&self) -> Result<PublicKey, error::Unspecified> { in compute_public_key()
133 algorithm: self.algorithm, in compute_public_key()
138 /// The algorithm for the private key.
140 pub fn algorithm(&self) -> &'static Algorithm { in algorithm() argument
141 self.algorithm in algorithm()
145 pub fn bytes(&self) -> &[u8] { in bytes()
153 algorithm: &'static Algorithm, field
158 fn as_ref(&self) -> &[u8] { in as_ref()
164 fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { in fmt()
166 .field("algorithm", &self.algorithm) in fmt()
173 /// The algorithm for the public key.
175 pub fn algorithm(&self) -> &'static Algorithm { in algorithm() argument
176 self.algorithm in algorithm()
182 algorithm: &'static Algorithm, field
192 fn clone(&self) -> Self { in clone()
194 algorithm: self.algorithm, in clone()
204 fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { in fmt()
206 .field("algorithm", &self.algorithm) in fmt()
214 pub fn new(algorithm: &'static Algorithm, bytes: B) -> Self { in new() argument
215 Self { algorithm, bytes } in new()
220 pub fn algorithm(&self) -> &'static Algorithm { in algorithm() argument
221 self.algorithm in algorithm()
226 pub fn bytes(&self) -> &B { in bytes()
239 /// `Err(error_value)` if it does not match `my_private_key's` algorithm/curve.
241 /// algorithm and that the key is *valid*; see the algorithm's documentation for
243 /// that algorithm.
252 kdf: impl FnOnce(&[u8]) -> R, in agree_ephemeral()
253 ) -> Result<R, error::Unspecified> { in agree_ephemeral()
255 algorithm: peer_public_key.algorithm, in agree_ephemeral()
264 kdf: impl FnOnce(&[u8]) -> R, in agree_ephemeral_()
265 ) -> Result<R, error::Unspecified> { in agree_ephemeral_()
268 // The domain parameters are hard-coded. This check verifies that the in agree_ephemeral_()
271 if peer_public_key.algorithm != my_private_key.algorithm { in agree_ephemeral_()
275 let alg = &my_private_key.algorithm; in agree_ephemeral_()
280 // NSA Guide Prerequisite 3, "Prior to or during the key-agreement process, in agree_ephemeral_()
282 // during the key-agreement scheme," is delegated to the caller. in agree_ephemeral_()