@@ -211,15 +211,6 @@ def change_assertion_statement(manifest: tdfs.Manifest) -> tdfs.Manifest:
211
211
return manifest
212
212
213
213
214
- def change_assertion_binding (manifest : tdfs .Manifest ) -> tdfs .Manifest :
215
- assert manifest .assertions
216
- assertion = manifest .assertions [0 ]
217
- altered_binding = base64 .b64encode (change_last_three (base64 .b64decode (assertion .binding .signature )))
218
- assertion .binding .signature = altered_binding
219
- manifest .assertions [0 ] = assertion
220
- return manifest
221
-
222
-
223
214
## TAMPER TESTS
224
215
225
216
@@ -293,21 +284,21 @@ def test_tdf_with_altered_seg_sig(
293
284
assert b"tamper" in exc .output or b"IntegrityError" in exc .output
294
285
295
286
296
- # def test_tdf_with_altered_seg_size(
297
- # encrypt_sdk: tdfs.sdk_type, decrypt_sdk: tdfs.sdk_type, pt_file: str, tmp_dir: str
298
- # ):
299
- # skip_hexless_skew(encrypt_sdk, decrypt_sdk)
300
- # ct_file = do_encrypt_with(pt_file, encrypt_sdk, "ztdf", tmp_dir)
301
- # assert os.path.isfile(ct_file)
302
- # b_file = tdfs.update_manifest("broken_seg_size", ct_file, change_segment_size)
303
- # fname = os.path.basename(b_file).split(".")[0]
304
- # rt_file = f"{tmp_dir}test-{fname}.untdf"
305
- # try:
306
- # tdfs.decrypt(decrypt_sdk, b_file, rt_file, "ztdf")
307
- # assert False, "decrypt succeeded unexpectedly"
308
- # except subprocess.CalledProcessError as exc:
309
- # assert b"segment" in exc.output
310
- # assert b"tamper" in exc.output or b"IntegrityError" in exc.output
287
+ def test_tdf_with_altered_seg_size (
288
+ encrypt_sdk : tdfs .sdk_type , decrypt_sdk : tdfs .sdk_type , pt_file : str , tmp_dir : str
289
+ ):
290
+ skip_hexless_skew (encrypt_sdk , decrypt_sdk )
291
+ ct_file = do_encrypt_with (pt_file , encrypt_sdk , "ztdf" , tmp_dir )
292
+ assert os .path .isfile (ct_file )
293
+ b_file = tdfs .update_manifest ("broken_seg_size" , ct_file , change_segment_size )
294
+ fname = os .path .basename (b_file ).split ("." )[0 ]
295
+ rt_file = f"{ tmp_dir } test-{ fname } .untdf"
296
+ try :
297
+ tdfs .decrypt (decrypt_sdk , b_file , rt_file , "ztdf" )
298
+ assert False , "decrypt succeeded unexpectedly"
299
+ except subprocess .CalledProcessError as exc :
300
+ assert b"segment" in exc .output
301
+ assert b"tamper" in exc .output or b"IntegrityError" in exc .output
311
302
312
303
313
304
def test_tdf_with_altered_enc_seg_size (
@@ -428,12 +419,13 @@ def test_tdf_with_altered_assertion_statement(
428
419
assert b"tamper" in exc .output or b"IntegrityError" in exc .output
429
420
430
421
431
- def test_tdf_with_altered_assertion_sig (
422
+ def test_tdf_with_altered_assertion_with_keys (
432
423
encrypt_sdk : tdfs .sdk_type ,
433
424
decrypt_sdk : tdfs .sdk_type ,
434
425
pt_file : str ,
435
426
tmp_dir : str ,
436
- assertion_file_no_keys : str ,
427
+ assertion_file_rs_and_hs_keys : str ,
428
+ assertion_verification_file_rs_and_hs_keys : str ,
437
429
):
438
430
skip_hexless_skew (encrypt_sdk , decrypt_sdk )
439
431
if not tdfs .supports (encrypt_sdk , "assertions" ):
@@ -445,17 +437,23 @@ def test_tdf_with_altered_assertion_sig(
445
437
encrypt_sdk ,
446
438
"ztdf" ,
447
439
tmp_dir ,
448
- scenario = "assertions" ,
449
- az = assertion_file_no_keys ,
440
+ scenario = "assertions-keys-roundtrip " ,
441
+ az = assertion_file_rs_and_hs_keys ,
450
442
)
451
443
assert os .path .isfile (ct_file )
452
444
b_file = tdfs .update_manifest (
453
- "altered_assertion_binding " , ct_file , change_assertion_binding
445
+ "altered_assertion_statement " , ct_file , change_assertion_statement
454
446
)
455
447
fname = os .path .basename (b_file ).split ("." )[0 ]
456
448
rt_file = f"{ tmp_dir } test-{ fname } .untdf"
457
449
try :
458
- tdfs .decrypt (decrypt_sdk , b_file , rt_file , "ztdf" )
450
+ tdfs .decrypt (
451
+ decrypt_sdk ,
452
+ b_file ,
453
+ rt_file ,
454
+ "ztdf" ,
455
+ assertion_verification_file_rs_and_hs_keys ,
456
+ )
459
457
assert False , "decrypt succeeded unexpectedly"
460
458
except subprocess .CalledProcessError as exc :
461
459
assert b"assertion" in exc .output
0 commit comments