eapm#
EAP-MD5 and EAP-PWD as peer and server state machines without I/O -- crate root lib/eapm/lib.rs
eapm -- EAP methods as state machines without I/O: the peer and the server of EAP-MD5 and
EAP-PWD with the framing of netpkt::eap and the sums of crypto (RFC 3748, 5931). They take the
packets they get and give the packets to send; whoever holds them carries the bytes (EAPOL,
RADIUS), keeps the timers and repeats a Request that got no answer. Randomness comes from
the caller, so a run is the same byte for byte
Method Md5 (wired ports, no keys) | Pwd (makes an MSK); word, parse,
of_type, typ, makes_keys
Peer::new(identity, password, method)
Peer::on_packet(&b, rnd) -> PeerOut Send(bytes) | Success | Failure | Silent
Peer::msk() / emsk() / method_used() after Success
Server::new(server_id, methods) methods in the order to offer them
Server::on_packet(&b, lookup, rnd) -> ServerOut
Send(bytes) | Success { eap, msk, emsk } | Failure { eap } |
Silent; lookup: a user's password (None: no such user)
Server::user() / method() who is logging in, with which method now
rand_scalar(rnd) a scalar of P-256 from random bytes
The peer answers a Request again with the same bytes when its identifier repeats (RFC 3748
4.1) and takes a method it was not told to use with a Nak that names the one it knows. A
Success before the method is over is ignored, for EAP-PWD unless its Confirm checked out
(RFC 3748 4.2 and 7.2); a Confirm that does not fit (another password) ends the method without
an answer, as RFC 5931 2.8.5.3 says, so the authenticator's retries run out.
The server starts when the first Response/Identity comes. It offers its methods in order and
goes on to the one a Nak names if it has it; with none left, it answers with Failure.
eapm crate root#
type Rnd<'a> = &'a mut dyn FnMut(&mut [u8])where random bytes come fromenum Methodan EAP methodMd5Pwd
impl Method
fn word(self) -> &'static strits word in a wpa_supplicant-style file ("MD5", "PWD")fn parse(s: &str) -> Option<Method>by its word, in any casefn typ(self) -> u8the EAP typefn of_type(t: u8) -> Option<Method>fn makes_keys(self) -> boolit derives an MSK (WPA-Enterprise needs one)fn rand_scalar(rnd: Rnd) -> [u8; 32]a scalar in [1, n - 1] of P-256 from random bytesenum PeerOutwhat a peer does with a packetSend(Vec<u8>)-- send this packetSuccess-- EAP-Success after the method is over: msk() holds its keysFailure-- EAP-Failure, or a method that ended hereSilent-- nothing to do
struct Peerthe peer's side of EAPidentity: String
impl Peer
fn new(identity: &str, password: &str, method: Method) -> Peerfn msk(&self) -> Option<&[u8; 64]>fn emsk(&self) -> Option<&[u8; 64]>fn method_used(&self) -> Option<Method>the method that ranfn reset(&mut self)back to the start (a new authentication on the same port)fn on_packet(&mut self, b: &[u8], rnd: Rnd) -> PeerOuta packet from the authenticatorenum ServerOutwhat a server does with a packetSend(Vec<u8>)-- send this RequestSuccess { eap: Vec<u8>, msk: Option<[u8; 64]>, emsk: Option<[u8; 64]> }-- the peer is in: the EAP-Success, the keys of a method that makes themFailure { eap: Vec<u8> }-- the peer is out: the EAP-FailureSilent-- nothing to do
struct Serverthe server's side of EAP
impl Server
fn new(server_id: &str, methods: &[Method]) -> Serverfn user(&self) -> &strwho is logging in (after the Response/Identity)fn method(&self) -> Option<Method>the method it runs nowfn on_packet(&mut self, b: &[u8], lookup: &dyn Fn(&str) -> Option<String>, rnd: Rnd) -> ServerOuta Response;lookupgives a user's password,rndthe random bytes