1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use {PublicKey, PrivateKey};
impl Clone for PublicKey {
fn clone(&self) -> PublicKey {
use PublicKey::*;
match *self {
Rsa { ref exponent, ref modulus } => {
Rsa { exponent: exponent.clone(), modulus: modulus.clone() }
}
Ed25519(data) => Ed25519(data),
}
}
}
impl PartialEq for PublicKey {
fn eq(&self, other: &PublicKey) -> bool {
use PublicKey::*;
match (self, other) {
(&Rsa { exponent: ref e1, modulus: ref n1 },
&Rsa { exponent: ref e2, modulus: ref n2 })
=> e1 == e2 && n1 == n2,
(&Rsa {..}, _) => false,
(&Ed25519(ref d1), &Ed25519(ref d2)) => d1 == d2,
(&Ed25519(..), _) => false,
}
}
}
impl Eq for PublicKey { }
impl Clone for PrivateKey {
fn clone(&self) -> PrivateKey {
use PrivateKey::*;
match *self {
Ed25519(data) => Ed25519(data),
Rsa { ref n, ref e, ref d, ref iqmp, ref p, ref q }
=> Rsa { n: n.clone(), e: e.clone(), d: d.clone(),
iqmp: iqmp.clone(), p: p.clone(), q: q.clone() },
}
}
}
impl PartialEq for PrivateKey {
fn eq(&self, other: &PrivateKey) -> bool {
use PrivateKey::*;
match (self, other) {
(&Rsa { n: ref n1, e: ref e1, d: ref d1, iqmp: ref iqmp1,
p: ref p1, q: ref q1 },
&Rsa { n: ref n2, e: ref e2, d: ref d2, iqmp: ref iqmp2,
p: ref p2, q: ref q2 }
) => {
n1 == n2 && e1 == e2 && d1 == d2 && iqmp1 == iqmp2 &&
p1 == p2 && q1 == q2
}
(&Rsa {..}, _) => false,
(&Ed25519(ref d1), &Ed25519(ref d2)) => &d1[..] == &d2[..],
(&Ed25519(..), _) => false,
}
}
}
impl Eq for PrivateKey { }