Sync usage with man page.
[netbsd-mini2440.git] / dist / ntp / libntp / authusekey.c
blob47fb2744ed1d7e639d0d3755416689387325bd0f
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.
21 #define KEY_TYPE_MD5 4
23 int
24 authusekey(
25 keyid_t keyno,
26 int keytype,
27 const u_char *str
30 const u_char *cp;
31 int len;
33 cp = str;
34 len = strlen((const char *)cp);
35 if (len == 0)
36 return 0;
38 switch(keytype) {
39 case KEY_TYPE_MD5:
40 MD5auth_setkey(keyno, str, (int)strlen((const char *)str));
41 break;
43 default:
44 /* Oh, well */
45 return 0;
48 return 1;