freebsd-skq/contrib/ntp/libntp/authusekey.c
Xin LI 68ba7e87e7 MFV r294491: ntp 4.2.8p6.
Security:	CVE-2015-7973, CVE-2015-7974, CVE-2015-7975
Security:	CVE-2015-7976, CVE-2015-7977, CVE-2015-7978
Security:	CVE-2015-7979, CVE-2015-8138, CVE-2015-8139
Security:	CVE-2015-8140, CVE-2015-8158
With hat:	so
2016-01-22 07:32:39 +00:00

35 lines
748 B
C

/*
* authusekey - decode a key from ascii and use it
*/
#include <config.h>
#include <stdio.h>
#include <ctype.h>
#include "ntp_types.h"
#include "ntp_string.h"
#include "ntp_stdlib.h"
/*
* Types of ascii representations for keys. "Standard" means a 64 bit
* hex number in NBS format, i.e. with the low order bit of each byte
* a parity bit. "NTP" means a 64 bit key in NTP format, with the
* high order bit of each byte a parity bit. "Ascii" means a 1-to-8
* character string whose ascii representation is used as the key.
*/
int
authusekey(
keyid_t keyno,
int keytype,
const u_char *str
)
{
size_t len;
len = strlen((const char *)str);
if (0 == len)
return 0;
MD5auth_setkey(keyno, keytype, str, len, NULL);
return 1;
}