Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / ntp / dist / libntp / authusekey.c
blob44e7ad891b8d61ceecb53a80ba01ce8c3fff850b
1 /* $NetBSD$ */
3 /*
4 * authusekey - decode a key from ascii and use it
5 */
6 #include <stdio.h>
7 #include <ctype.h>
9 #include "ntp_types.h"
10 #include "ntp_string.h"
11 #include "ntp_stdlib.h"
14 * Types of ascii representations for keys. "Standard" means a 64 bit
15 * hex number in NBS format, i.e. with the low order bit of each byte
16 * a parity bit. "NTP" means a 64 bit key in NTP format, with the
17 * high order bit of each byte a parity bit. "Ascii" means a 1-to-8
18 * character string whose ascii representation is used as the key.
20 int
21 authusekey(
22 keyid_t keyno,
23 int keytype,
24 const u_char *str
27 const u_char *cp;
28 int len;
30 cp = str;
31 len = strlen((const char *)cp);
32 if (len == 0)
33 return 0;
35 MD5auth_setkey(keyno, keytype, str, (int)strlen((const char *)str));
36 return 1;