a_md512crypt.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright (c) 1996 by Sun Microsystems, Inc.
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* md5crypt - MD5 based authentication routines
*/
#include "ntp_types.h"
#include "ntp_string.h"
#include <md5.h>
#include "ntp_stdlib.h"
extern u_int32 cache_keyid;
extern char *cache_key;
extern int cache_keylen;
#ifndef HAVE_MEMMOVE
#endif
/*
* Stat counters, imported from data base module
*/
extern u_int32 authencryptions;
extern u_int32 authdecryptions;
extern u_int32 authkeyuncached;
/*
* 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 16
/*
* Do first stage of a two stage authenticator generation.
*/
void
int length; /* length of all encrypted data */
{
if (keyno != cache_keyid) {
if (!authhavekey(keyno)) {
authnokey++;
return;
}
}
#ifdef SYS_SOLARIS
#else
#endif
/* just leave the partially computed value in the static MD5_CTX */
}
/*
* Do second state of a two stage authenticator generation.
*/
int
int length; /* total length of encrypted area */
{
#if defined(__NetBSD__) || defined(SYS_SOLARIS)
unsigned char hash[16];
#endif
/*
* Don't bother checking the keys. The first stage would have
* handled that. Finish up the generation by also including the
* last 8 bytes of the data area.
*/
#if defined(__NetBSD__) || defined(SYS_SOLARIS)
#else
#endif
#if defined(__NetBSD__) || defined(SYS_SOLARIS)
(char *) hash,
#else
#endif
return (4 + BLOCK_OCTETS);
}