if data is None:
data = secrets.token_bytes(KEY_LEN_BYTES)
- else:
- self.assertEqual(
- KEY_LEN_BYTES,
- len(data),
- f"root key data must be {KEY_LEN_BYTES} bytes",
- )
create_time = current_nt_time = self.current_nt_time()
Algorithm,
Gkid,
KEY_CYCLE_DURATION,
+ KEY_LEN_BYTES,
MAX_CLOCK_SKEW,
NtTime,
NtTimeDelta,
"using a nonâexistent root key should fail with NO_KEY",
)
+ def test_root_key_wrong_length(self):
+ """Attempt to use a root key that is the wrong length."""
+ root_key_id = self.new_root_key(data=bytes(KEY_LEN_BYTES // 2))
+
+ gkid = self.current_gkid()
+
+ with self.assertRaises(GetKeyError) as err:
+ self.get_key(self.get_samdb(), self.gmsa_sd, root_key_id, gkid)
+
+ self.assertEqual(
+ HRES_NTE_BAD_KEY,
+ err.exception.args[0],
+ "using a root key that is the wrong length should fail with BAD_KEY",
+ )
+
+ with self.assertRaises(GetKeyError) as rpc_err:
+ self.rpc_get_key(self.gkdi_conn(), self.gmsa_sd, root_key_id, gkid)
+
+ self.assertEqual(
+ HRES_NTE_BAD_KEY,
+ rpc_err.exception.args[0],
+ "using a root key that is the wrong length should fail with BAD_KEY",
+ )
+
class GkdiImplicitRootKeyTests(GkdiKdcBaseTest):
_root_key: ClassVar[misc.GUID]
^samba\.tests\.krb5\.gkdi_tests\.samba\.tests\.krb5\.gkdi_tests\.GkdiExplicitRootKeyTests\.test_previous_l0_idx\(ad_dc\)$
^samba\.tests\.krb5\.gkdi_tests\.samba\.tests\.krb5\.gkdi_tests\.GkdiExplicitRootKeyTests\.test_root_key_use_start_time_too_low\(ad_dc\)$
^samba\.tests\.krb5\.gkdi_tests\.samba\.tests\.krb5\.gkdi_tests\.GkdiExplicitRootKeyTests\.test_root_key_use_start_time_zero\(ad_dc\)$
+^samba\.tests\.krb5\.gkdi_tests\.samba\.tests\.krb5\.gkdi_tests\.GkdiExplicitRootKeyTests\.test_root_key_wrong_length\(ad_dc\)$
^samba\.tests\.krb5\.gkdi_tests\.samba\.tests\.krb5\.gkdi_tests\.GkdiImplicitRootKeyTests\.test_both_seed_keys\(ad_dc\)$
^samba\.tests\.krb5\.gkdi_tests\.samba\.tests\.krb5\.gkdi_tests\.GkdiImplicitRootKeyTests\.test_l1_seed_key\(ad_dc\)$
^samba\.tests\.krb5\.gkdi_tests\.samba\.tests\.krb5\.gkdi_tests\.GkdiImplicitRootKeyTests\.test_l2_seed_key\(ad_dc\)$