python:gkdi: Add helper methods returning previous and next GKIDs
authorJo Sutton <josutton@catalyst.net.nz>
Wed, 24 Apr 2024 00:42:40 +0000 (12:42 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 24 Apr 2024 05:16:29 +0000 (05:16 +0000)
Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/gkdi.py

index 22890c83ff3a2db4b9639423ab732bcfa2ca785e..6d29b5d8d2b7b2302b12c6be066935e36e13fda9 100644 (file)
@@ -289,6 +289,12 @@ class Gkid:
 
         return start_time
 
+    def previous(self) -> "Gkid":
+        return Gkid.from_nt_time(NtTime(self.start_nt_time() - KEY_CYCLE_DURATION))
+
+    def next(self) -> "Gkid":
+        return Gkid.from_nt_time(NtTime(self.start_nt_time() + KEY_CYCLE_DURATION))
+
     @staticmethod
     def from_key_envelope(env: gkdi.KeyEnvelope) -> "Gkid":
         return Gkid(env.l0_index, env.l1_index, env.l2_index)