1 /* $NetBSD: authusekey.c,v 1.1.1.1 2009/12/13 16:55:02 kardel Exp $ */ 2 3 /* 4 * authusekey - decode a key from ascii and use it 5 */ 6 #include <stdio.h> 7 #include <ctype.h> 8 9 #include "ntp_types.h" 10 #include "ntp_string.h" 11 #include "ntp_stdlib.h" 12 13 /* 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. 19 */ 20 int 21 authusekey( 22 keyid_t keyno, 23 int keytype, 24 const u_char *str 25 ) 26 { 27 const u_char *cp; 28 int len; 29 30 cp = str; 31 len = strlen((const char *)cp); 32 if (len == 0) 33 return 0; 34 35 MD5auth_setkey(keyno, keytype, str, (int)strlen((const char *)str)); 36 return 1; 37 } 38