[Git][NTPsec/ntpsec][master] 3 commits: Typos

Eric S. Raymond gitlab at mg.gitlab.com
Wed Nov 9 02:52:51 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
b609b52f by Matt Selsky at 2016-11-08T21:40:53-05:00
Typos

- - - - -
a8ce3f90 by Eric S. Raymond at 2016-11-08T21:41:17-05:00
First cut at authenticating SNTP responses.

- - - - -
cfe0fa93 by Eric S. Raymond at 2016-11-08T21:52:12-05:00
Address two minor tracker issues.

- - - - -


7 changed files:

- attic/README
- docs/driver_magnavox.txt
- docs/includes/ntpq-body.txt
- include/ntp.h
- ntpdig/pyntpdig
- ntpq/ntpq
- pylib/packet.py


Changes:

=====================================
attic/README
=====================================
--- a/attic/README
+++ b/attic/README
@@ -1,6 +1,6 @@
 = README file for directory attic/ =
 
-This is a dusty attic containg code we have not quite decided to
+This is a dusty attic containing code we have not quite decided to
 discard.  Programs in it are not installed by default. Not much
 documentation, alas.  Read the header comments.
 


=====================================
docs/driver_magnavox.txt
=====================================
--- a/docs/driver_magnavox.txt
+++ b/docs/driver_magnavox.txt
@@ -19,7 +19,7 @@ please make this known to us.
 This driver supports the Magnavox MX4200 Navigation Receiver adapted to
 precision timing applications. It also supports all compatible
 receivers such as the 6-channel MX4200, MX4200D, and the 12-channel
-MX9212, MX9012R, abd MX9112.
+MX9212, MX9012R, and MX9112.
 
 image:pic/9400n.jpg["MX9400N",float="left",caption="Leica MX9400N Navigator"]
 https://web.archive.org/web/19971014210945/http://www.leica-gps.com/[Leica


=====================================
docs/includes/ntpq-body.txt
=====================================
--- a/docs/includes/ntpq-body.txt
+++ b/docs/includes/ntpq-body.txt
@@ -409,7 +409,7 @@ a control key declared in ntp.conf for these commands to work.
 
 If you are running as root or otherwise have read access to the
 authkey and ntp.conf file, ntpq will mine the required credentials
-for you. Otherwise you will be prompted to enter a key ID abd password.
+for you. Otherwise you will be prompted to enter a key ID and password.
 
 Credentials, once entered, are retained and used for the duration
 of your ntpq session.


=====================================
include/ntp.h
=====================================
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -404,6 +404,8 @@ struct peer {
  */
 #define	MODE_BCLIENT	6	/* broadcast client mode */
 
+#define	LEN_PKT_NOMAC	48 /* min header length */
+
 /* pythonize-header: start ignoring */
 
 /*
@@ -449,8 +451,6 @@ struct peer {
  */
 #define REFIDLEN	sizeof(uint32_t)
 
-#define	LEN_PKT_NOMAC	48 /* min header length */
-
 /* This is the new, sane way of representing packets. All fields are
    in host byte order, and the fixed-point time fields are just integers,
    with uints of 2^-16 or 2^-32 seconds as appropriate. */


=====================================
ntpdig/pyntpdig
=====================================
--- a/ntpdig/pyntpdig
+++ b/ntpdig/pyntpdig
@@ -136,7 +136,7 @@ def queryhost(server, concurrent, timeout=5, port=123):
         def read_append(s, packets):
             d, a = s.recvfrom(1024)
             if debug >= 2:
-                print("Received:")
+                print("Received: (%d bytes)" % len(d))
                 ntp.packet.dump_hex_printable(d)
             if credentials:
                 if not ntp.packet.Authenticator.have_mac(d):


=====================================
ntpq/ntpq
=====================================
--- a/ntpq/ntpq
+++ b/ntpq/ntpq
@@ -154,6 +154,7 @@ class Ntpq(cmd.Cmd):
         self.debug = 0
         self.pktversion = NTP_OLDVERSION + 1
         self.uservars = collections.OrderedDict()
+        self.ai_family = socket.AF_UNSPEC
 
     def emptyline(self):
         "Called when an empty line is entered in response to the prompt."
@@ -442,7 +443,7 @@ usage: help [ command ]
         text = text.replace("'", '"')
         self.say(text)
 
-    def __dolist(self, varlist, associd, op, type):
+    def __dolist(self, varlist, associd, op, type, quiet):
         "List variables associated with a specified peer."
         try:
             variables = self.session.readvar(associd, varlist, op)
@@ -1311,7 +1312,7 @@ usage: reslist
             ("precision",	"log2 precision:   ", NTP_INT),
             ("rootdelay",	"root delay:       ", NTP_FLOAT),
             ("rootdisp",	"root dispersion:  ", NTP_FLOAT),
-            ("refid",		"reference ID:     ", NTP_ADDR),
+            ("refid",		"reference ID:     ", NTP_ADD),
             ("reftime",		"reference time:   ", NTP_LFP),
             ("sys_jitter",	"system jitter:    ", NTP_FLOAT),
             ("clk_jitter",	"clock jitter:     ", NTP_FLOAT),


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -1040,6 +1040,7 @@ DEFAULT_KEYFILE = "/usr/local/etc/ntp.keys"
 
 class Authenticator:
     "MAC authentication manager for NTP packets."
+    HASHLEN = 20	# True for both MD5 and SHA1 hashes
     def __init__(self, keyfile=None):
         # We allow I/O and permission errors upward deliberately
         self.passwords = {}
@@ -1088,9 +1089,20 @@ class Authenticator:
         # According to RFC5909 7.5 the MAC is always present when an extension
         # field is present. Note: this crude test will fail on Mode 6 packets.
         # On those you have to go in and look at the count.
-        return len(packet) > 48
+        return len(packet) > LEN_PKT_NOMAC
     def verify_mac(self, packet):
         "Does the MAC on this packet verify according to credentials we have?"
-        return True
+        payload = packet[-Authenticator.HASHLEN-4:]
+        keyid = packet[-Authenticator.HASHLEN-4:-Authenticator.HASHLEN]
+        mac = packet[:-Authenticator.HASHLEN]
+        (keyid,) = struct.unpack("!I", keyid)
+        print("I see: %d" % keyid)
+        if keyid not in self.passwords:
+            return False
+        (keytype, passwd) = self.passwords[keyid]
+        hasher = hashlib.new(keytype)
+        hasher.update(passwd)
+        hasher.update(payload)
+        return hasher.digest() == mac
 
 # end



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/2327e294970396b4f594917eab054f10eae58291...cfe0fa9322758e5abb1184f1b4a99993344e7fad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161109/a9f8b70f/attachment.html>


More information about the vc mailing list