auth12crypt.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright (c) 1996 by Sun Microsystems, Inc.
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* auth12crypt.c - routines to support two stage NTP encryption
*/
#include "ntp_stdlib.h"
/*
* For our purposes an NTP packet looks like:
*
* a variable amount of encrypted data, multiple of 8 bytes, which
* is encrypted in pass 1, followed by:
* an 8 byte chunk of data which is encrypted in pass 2
* NOCRYPT_OCTETS worth of unencrypted data, followed by:
* BLOCK_OCTETS worth of ciphered checksum.
*/
#define NOCRYPT_OCTETS 4
#define BLOCK_OCTETS 8
/*
* Imported from the key data base module
*/
/*
* Stat counters, from the database module
*/
extern u_int32 authencryptions;
extern u_int32 authkeyuncached;
/*
* auth1crypt - do the first stage of a two stage encryption
*/
void
int length; /* length of all encrypted data */
{
register int i;
if (keyno == 0) {
} else {
if (keyno != cache_keyid) {
if (!authhavekey(keyno)) {
authnokey++;
return;
}
}
}
/*
* Do the first five encryptions. Stick the intermediate result
* in the mac field. The sixth encryption must wait until the
* caller freezes a transmit time stamp, and will be done in stage 2.
*/
}
/*
* Space to the end of the packet and stick the intermediate
* result in the mac field.
*/
}
/*
* auth2crypt - do the second stage of a two stage encryption
*/
int
int length; /* total length of encrypted area */
{
/*
* Skip the key check. The call to the first stage should
* have got it.
*/
if (keyno == 0)
else
/*
* The mac currently should hold the results of the first `n'
* encryptions. We xor in the last block in data section and
* do the final encryption in place.
*
* Get a pointer to the MAC block. XOR in the last two words of
* the data area. Call the encryption routine.
*/
return 4 + 8; /* return size of key number and MAC */
}