freebsd-dev/contrib/ntp/libntp/authusekey.c

35 lines
748 B
C
Raw Normal View History

1999-12-09 13:01:21 +00:00
/*
* authusekey - decode a key from ascii and use it
*/
#include <config.h>
1999-12-09 13:01:21 +00:00
#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(
2001-08-29 14:35:15 +00:00
keyid_t keyno,
1999-12-09 13:01:21 +00:00
int keytype,
const u_char *str
)
{
2016-01-08 08:06:14 +00:00
size_t len;
1999-12-09 13:01:21 +00:00
len = strlen((const char *)str);
if (0 == len)
1999-12-09 13:01:21 +00:00
return 0;
2016-01-21 08:50:56 +00:00
MD5auth_setkey(keyno, keytype, str, len, NULL);
1999-12-09 13:01:21 +00:00
return 1;
}