1 /*
2 * authusekey - decode a key from ascii and use it
3 */
4 #include <config.h>
5 #include <stdio.h>
6 #include <ctype.h>
7
8 #include "ntp_types.h"
9 #include "ntp_string.h"
10 #include "ntp_stdlib.h"
11
12 /*
13 * Types of ascii representations for keys. "Standard" means a 64 bit
14 * hex number in NBS format, i.e. with the low order bit of each byte
15 * a parity bit. "NTP" means a 64 bit key in NTP format, with the
16 * high order bit of each byte a parity bit. "Ascii" means a 1-to-8
17 * character string whose ascii representation is used as the key.
18 */
19 int
authusekey(keyid_t keyno,int keytype,const u_char * str)20 authusekey(
21 keyid_t keyno,
22 int keytype,
23 const u_char *str
24 )
25 {
26 size_t len;
27
28 len = strlen((const char *)str);
29 if (0 == len)
30 return 0;
31
32 MD5auth_setkey(keyno, keytype, str, len, NULL);
33 return 1;
34 }
35