summaryrefslogtreecommitdiff
path: root/libntp/authusekey.c
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-12-02 09:01:21 +0000
committer <>2014-12-04 16:11:25 +0000
commitbdab5265fcbf3f472545073a23f8999749a9f2b9 (patch)
treec6018dd03dea906f8f1fb5f105f05b71a7dc250a /libntp/authusekey.c
downloadntp-dev-4.2.7p482.tar.gz
Imported from /home/lorry/working-area/delta_ntp/ntp-dev-4.2.7p482.tar.gz.ntp-dev-4.2.7p482
Diffstat (limited to 'libntp/authusekey.c')
-rw-r--r--libntp/authusekey.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libntp/authusekey.c b/libntp/authusekey.c
new file mode 100644
index 0000000..c1d0813
--- /dev/null
+++ b/libntp/authusekey.c
@@ -0,0 +1,34 @@
+/*
+ * authusekey - decode a key from ascii and use it
+ */
+#include <config.h>
+#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(
+ keyid_t keyno,
+ int keytype,
+ const u_char *str
+ )
+{
+ int len;
+
+ len = strlen((const char *)str);
+ if (0 == len)
+ return 0;
+
+ MD5auth_setkey(keyno, keytype, str, len);
+ return 1;
+}