Spake2Context.forPairing constructor
Spake2Context.forPairing({
- required Spake2Role role,
- Spake2RandomBytesSource? randomBytesSource,
Creates a SPAKE2 context pre-configured for ADB pairing.
ADB uses specific name strings and the client acts as Alice.
Implementation
factory Spake2Context.forPairing({
required Spake2Role role,
Spake2RandomBytesSource? randomBytesSource,
}) {
// ADB uses sizeof() on these string literals, so the null terminator is included.
final clientName = utf8.encode('adb pair client\x00');
final serverName = utf8.encode('adb pair server\x00');
return Spake2Context(
role,
Uint8List.fromList(role == Spake2Role.alice ? clientName : serverName),
Uint8List.fromList(role == Spake2Role.alice ? serverName : clientName),
randomBytesSource: randomBytesSource,
);
}