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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! The sans-IO handshake every authentication method implements.
//!
//! A [`Handshake`] does no I/O. The caller feeds it what arrived with
//! [`receive`](Handshake::receive), asks what to send with
//! [`transmit`](Handshake::transmit), and when [`is_complete`](Handshake::is_complete)
//! calls [`finish`](Handshake::finish) for the verified peer and whatever the method
//! produced (an encrypted channel, session keys, or nothing). Because the caller owns the
//! transport, one implementation runs over a byte stream, WebSocket messages, QUIC
//! datagrams or shared memory; [`drive_stream`](crate::drive_stream) and
//! [`drive_messages`](crate::drive_messages) (and the `asynch` versions with the `tokio`
//! feature) are the thin loops for the common cases.
//!
//! # Requirements on a method
//!
//! - **Key proof before pairing.** Record a peer in the [`TrustStore`](crate::TrustStore)
//! as waiting only after it proved, inside this handshake, that it holds the key it
//! presented. See the store's pairing contract.
//! - **`finish` before completion is an error**, never a half-verified peer.
//! - **No input is dropped.** Bytes received beyond the end of the handshake stay in the
//! [`Output`](Handshake::Output) (a TLS connection keeps its buffered application data).
//! - **Nothing global.** A method keeps its state in the handshake value.
use SocketAddr;
use cratePeerId;
use crateKeyMaterial;
/// How a method divides what it sends.
/// A verified peer and what the method produced besides.
/// One authentication exchange, driven by the caller.
/// An authentication method: a configured factory of handshakes.
///
/// Methods are named `coqui-peer-<method>`; [`name`](Method::name) is the `<method>` part and
/// the name under which the method's keys are kept in the trust store.