authencrypt.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright (c) 1996 by Sun Microsystems, Inc.
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* authencrypt - compute and encrypt the mac field in an NTP packet
*/
#include "ntp_stdlib.h"
/*
* For our purposes an NTP packet looks like:
*
* a variable amount of encrypted data, multiple of 8 bytes, followed by:
* 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;
int
int length; /* length of encrypted portion of packet */
{
register int i;
register int len;
if (keyno == 0) {
} else {
if (keyno != cache_keyid) {
if (!authhavekey(keyno)) {
authnokey++;
return 0;
}
}
}
/*
* Do the encryption. Work our way forward in the packet, eight
* bytes at a time, encrypting as we go. Note that the byte order
* issues are handled by the DES routine itself
*/
for (i = (len/2); i > 0; i--) {
}
if (len & 0x1) {
}
/*
* Space past the keyid and stick the result back in the mac field
*/
pd += NOCRYPT_int32S;
}