Module fcp_cryptoauth::handshake_packet
[−]
[src]
Contains the HandshakePacket
structure, and a HandshakePacketBuilder
to
construct it field by field.
Example
use fcp_cryptoauth::handshake_packet::{HandshakePacketBuilder, HandshakePacket, HandshakePacketType}; let packet = HandshakePacketBuilder::new() .packet_type(&HandshakePacketType::Key) .auth_challenge(&[1u8; 12]) .random_nonce(&[2u8; 24]) .sender_perm_pub_key(&[3u8; 32]) .msg_auth_code(&[4u8; 16]) .sender_encrypted_temp_pub_key(&[5u8; 32]) .encrypted_data(&vec![6u8, 7u8, 8u8]) .finalize() .unwrap(); assert_eq!(packet.packet_type(), Ok(HandshakePacketType::Key)); assert_eq!(packet.auth_challenge(), [1u8; 12]); assert_eq!(packet.random_nonce(), [2u8; 24]); assert_eq!(packet.sender_perm_pub_key(), [3u8; 32]); assert_eq!(packet.msg_auth_code(), [4u8; 16]); assert_eq!(packet.sender_encrypted_temp_pub_key(), [5u8; 32]); assert_eq!(packet.encrypted_data(), [6u8, 7u8, 8u8]); assert_eq!(packet.raw, vec![ // session state 0, 0, 0, 2, // auth challenge 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // random nonce 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // sender's permanent public key 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // message authentication code 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // sender's encrypted temporary public key 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // encrypted data 6, 7, 8, ])
Structs
HandshakePacket |
Represents a raw CryptoAuth packet, as defined by https://github.com/fc00/spec/blob/10b349ab11/cryptoauth.md#packet-layout |
HandshakePacketBuilder |
Used to construct a |
Enums
HandshakePacketType |
Represents the CryptoAuth session state, as defined by https://github.com/fc00/spec/blob/10b349ab11/cryptoauth.md#protocol |