fn response(keys: NTSKeys, rotator: &Arc<RwLock<KeyRotator>>, port: u16) -> Vec<u8> {
    let start = Instant::now();
    
    let mut response: Vec<u8> = Vec::new();

    let next_protocol_record = NextProtocolRecord::from(vec![
        KnownNextProtocol::Ntpv4,
    ]);
    let aead_record = AeadAlgorithmRecord::from(vec![
        KnownAeadAlgorithm::AeadAesSivCmac256,
    ]);
    let port_record = PortRecord::new(Party::Server, port);
    let end_record = EndOfMessageRecord;

    response.append(&mut serialize(next_protocol_record));
    response.append(&mut serialize(aead_record));

    let rotor = rotator.read().unwrap();
    let (key_id, actual_key) = rotor.latest_key_value();

    // According to the spec, if the next protocol is NTPv4, we should send eight cookies to the
    // client.
    // 4.1.6.  New Cookie for NTPv4
    // Servers MUST send at least one record of this type, and SHOULD send eight of them, if the Next Protocol Negotiation response record contains Protocol ID 0 (NTPv4) and the AEAD Algorithm Negotiation response record is not empty. 
    for _ in 0..8 {
        let cookie = make_cookie(keys, actual_key.as_ref(), key_id);
        let cookie_record = NewCookieRecord::from(cookie);
        response.append(&mut serialize(cookie_record));
    }
    response.append(&mut serialize(port_record));
    response.append(&mut serialize(end_record));

    let end = Instant::now();
    SERVER_KE_S.get().clone().unwrap().send((end - start).as_nanos().to_string()).expect("unable to write to channel.");

    response
}
// response uses the configuration and the keys and computes the response
// sent to the client.
response uses the configuration and the keys and computes the response
sent to the client.
response uses the configuration and the keys and computes the response sent to the client .
fn response(keys: NTSKeys, rotator: &Arc<RwLock<KeyRotator>>, port: u16) -> Vec<u8> {
    let start = Instant::now();
    let mut response: Vec<u8> = Vec::new();
    let next_protocol_record = NextProtocolRecord::from(vec![
        KnownNextProtocol::Ntpv4,
    ]);
    let aead_record = AeadAlgorithmRecord::from(vec![
        KnownAeadAlgorithm::AeadAesSivCmac256,
    ]);
    let port_record = PortRecord::new(Party::Server, port);
    let end_record = EndOfMessageRecord;
    response.append(&mut serialize(next_protocol_record));
    response.append(&mut serialize(aead_record));
    let rotor = rotator.read().unwrap();
    let (key_id, actual_key) = rotor.latest_key_value();
    // According to the spec, if the next protocol is NTPv4, we should send eight cookies to the
    // client.
    // 4.1.6.  New Cookie for NTPv4
    // Servers MUST send at least one record of this type, and SHOULD send eight of them, if the Next Protocol Negotiation response record contains Protocol ID 0 (NTPv4) and the AEAD Algorithm Negotiation response record is not empty. 
    for _ in 0..8 {
        let cookie = make_cookie(keys, actual_key.as_ref(), key_id);
        let cookie_record = NewCookieRecord::from(cookie);
        response.append(&mut serialize(cookie_record));
    }
    response.append(&mut serialize(port_record));
    response.append(&mut serialize(end_record));
    let end = Instant::now();
    SERVER_KE_S.get().clone().unwrap().send((end - start).as_nanos().to_string()).expect("unable to write to channel.");
    response
}
fn response ( keys : NTSKeys , rotator : & Arc < RwLock < KeyRotator > > , port : u16 ) -> Vec < u8 > { let start = Instant :: now ( ) ; let mut response : Vec < u8 > = Vec :: new ( ) ; let next_protocol_record = NextProtocolRecord :: from ( vec ! [ KnownNextProtocol Ntpv4 ] ) ; let aead_record = AeadAlgorithmRecord :: from ( vec ! [ KnownAeadAlgorithm AeadAesSivCmac256 ] ) ; let port_record = PortRecord :: new ( Party :: Server , port ) ; let end_record = EndOfMessageRecord ; response . append ( & mut serialize ( next_protocol_record ) ) ; response . append ( & mut serialize ( aead_record ) ) ; let rotor = rotator . read ( ) . unwrap ( ) ; let ( key_id , actual_key ) = rotor . latest_key_value ( ) ; // According to the spec, if the next protocol is NTPv4, we should send eight cookies to the // client. // 4.1.6.  New Cookie for NTPv4 // Servers MUST send at least one record of this type, and SHOULD send eight of them, if the Next Protocol Negotiation response record contains Protocol ID 0 (NTPv4) and the AEAD Algorithm Negotiation response record is not empty.  for _ in 0 .. 8 { let cookie = make_cookie ( keys , actual_key . as_ref ( ) , key_id ) ; let cookie_record = NewCookieRecord :: from ( cookie ) ; response . append ( & mut serialize ( cookie_record ) ) ; } response . append ( & mut serialize ( port_record ) ) ; response . append ( & mut serialize ( end_record ) ) ; let end = Instant :: now ( ) ; SERVER_KE_S . get ( ) . clone ( ) . unwrap ( ) . send ( ( end - start ) . as_nanos ( ) . to_string ( ) ) . expect ( " " ) ; response }
response uses the configuration and the keys and computes the response
sent to the client.
response uses the configuration and the keys and computes the response sent to the client .
keys
NTSKeys
rotator
&Arc<RwLock<KeyRotator>>
port
u16
keys
NTSKeys
rotator
&Arc<RwLock<KeyRotator>>
port
u16