@@ -82,8 +82,9 @@ def test_get_signature_status_no_role(self):
8282 # Should verify we are not adding a duplicate signature
8383 # when doing the following action. Here we know 'signable'
8484 # has only one signature so it's okay.
85+ signed = securesystemslib .formats .encode_canonical (signable ['signed' ]).encode ('utf-8' )
8586 signable ['signatures' ].append (securesystemslib .keys .create_signature (
86- KEYS [0 ], signable [ ' signed' ] ))
87+ KEYS [0 ], signed ))
8788
8889 tuf .keydb .add_key (KEYS [0 ])
8990
@@ -101,9 +102,10 @@ def test_get_signature_status_no_role(self):
101102
102103 def test_get_signature_status_bad_sig (self ):
103104 signable = {'signed' : 'test' , 'signatures' : []}
105+ signed = securesystemslib .formats .encode_canonical (signable ['signed' ]).encode ('utf-8' )
104106
105107 signable ['signatures' ].append (securesystemslib .keys .create_signature (
106- KEYS [0 ], signable [ ' signed' ] ))
108+ KEYS [0 ], signed ))
107109 signable ['signed' ] += 'signature no longer matches signed data'
108110
109111 tuf .keydb .add_key (KEYS [0 ])
@@ -133,9 +135,10 @@ def test_get_signature_status_bad_sig(self):
133135
134136 def test_get_signature_status_unknown_signing_scheme (self ):
135137 signable = {'signed' : 'test' , 'signatures' : []}
138+ signed = securesystemslib .formats .encode_canonical (signable ['signed' ]).encode ('utf-8' )
136139
137140 signable ['signatures' ].append (securesystemslib .keys .create_signature (
138- KEYS [0 ], signable [ ' signed' ] ))
141+ KEYS [0 ], signed ))
139142
140143 valid_scheme = KEYS [0 ]['scheme' ]
141144 KEYS [0 ]['scheme' ] = 'unknown_signing_scheme'
@@ -168,9 +171,10 @@ def test_get_signature_status_unknown_signing_scheme(self):
168171
169172 def test_get_signature_status_single_key (self ):
170173 signable = {'signed' : 'test' , 'signatures' : []}
174+ signed = securesystemslib .formats .encode_canonical (signable ['signed' ]).encode ('utf-8' )
171175
172176 signable ['signatures' ].append (securesystemslib .keys .create_signature (
173- KEYS [0 ], signable [ ' signed' ] ))
177+ KEYS [0 ], signed ))
174178
175179 threshold = 1
176180
@@ -209,9 +213,10 @@ def test_get_signature_status_single_key(self):
209213
210214 def test_get_signature_status_below_threshold (self ):
211215 signable = {'signed' : 'test' , 'signatures' : []}
216+ signed = securesystemslib .formats .encode_canonical (signable ['signed' ]).encode ('utf-8' )
212217
213218 signable ['signatures' ].append (securesystemslib .keys .create_signature (
214- KEYS [0 ], signable [ ' signed' ] ))
219+ KEYS [0 ], signed ))
215220
216221 tuf .keydb .add_key (KEYS [0 ])
217222 threshold = 2
@@ -243,12 +248,13 @@ def test_get_signature_status_below_threshold(self):
243248
244249 def test_get_signature_status_below_threshold_unrecognized_sigs (self ):
245250 signable = {'signed' : 'test' , 'signatures' : []}
251+ signed = securesystemslib .formats .encode_canonical (signable ['signed' ]).encode ('utf-8' )
246252
247253 # Two keys sign it, but only one of them will be trusted.
248254 signable ['signatures' ].append (securesystemslib .keys .create_signature (
249- KEYS [0 ], signable [ ' signed' ] ))
255+ KEYS [0 ], signed ))
250256 signable ['signatures' ].append (securesystemslib .keys .create_signature (
251- KEYS [2 ], signable [ ' signed' ] ))
257+ KEYS [2 ], signed ))
252258
253259 tuf .keydb .add_key (KEYS [0 ])
254260 tuf .keydb .add_key (KEYS [1 ])
@@ -282,13 +288,13 @@ def test_get_signature_status_below_threshold_unrecognized_sigs(self):
282288
283289 def test_get_signature_status_below_threshold_unauthorized_sigs (self ):
284290 signable = {'signed' : 'test' , 'signatures' : []}
285-
291+ signed = securesystemslib . formats . encode_canonical ( signable [ 'signed' ]). encode ( 'utf-8' )
286292 # Two keys sign it, but one of them is only trusted for a different
287293 # role.
288294 signable ['signatures' ].append (securesystemslib .keys .create_signature (
289- KEYS [0 ], signable [ ' signed' ] ))
295+ KEYS [0 ], signed ))
290296 signable ['signatures' ].append (securesystemslib .keys .create_signature (
291- KEYS [1 ], signable [ ' signed' ] ))
297+ KEYS [1 ], signed ))
292298
293299 tuf .keydb .add_key (KEYS [0 ])
294300 tuf .keydb .add_key (KEYS [1 ])
@@ -334,9 +340,10 @@ def test_get_signature_status_below_threshold_unauthorized_sigs(self):
334340
335341 def test_check_signatures_no_role (self ):
336342 signable = {'signed' : 'test' , 'signatures' : []}
343+ signed = securesystemslib .formats .encode_canonical (signable ['signed' ]).encode ('utf-8' )
337344
338345 signable ['signatures' ].append (securesystemslib .keys .create_signature (
339- KEYS [0 ], signable [ ' signed' ] ))
346+ KEYS [0 ], signed ))
340347
341348 tuf .keydb .add_key (KEYS [0 ])
342349
@@ -353,8 +360,10 @@ def test_check_signatures_no_role(self):
353360
354361 def test_verify_single_key (self ):
355362 signable = {'signed' : 'test' , 'signatures' : []}
363+ signed = securesystemslib .formats .encode_canonical (signable ['signed' ]).encode ('utf-8' )
364+
356365 signable ['signatures' ].append (securesystemslib .keys .create_signature (
357- KEYS [0 ], signable [ ' signed' ] ))
366+ KEYS [0 ], signed ))
358367
359368 tuf .keydb .add_key (KEYS [0 ])
360369 threshold = 1
@@ -377,12 +386,13 @@ def test_verify_single_key(self):
377386
378387 def test_verify_unrecognized_sig (self ):
379388 signable = {'signed' : 'test' , 'signatures' : []}
389+ signed = securesystemslib .formats .encode_canonical (signable ['signed' ]).encode ('utf-8' )
380390
381391 # Two keys sign it, but only one of them will be trusted.
382392 signable ['signatures' ].append (securesystemslib .keys .create_signature (
383- KEYS [0 ], signable [ ' signed' ] ))
393+ KEYS [0 ], signed ))
384394 signable ['signatures' ].append (securesystemslib .keys .create_signature (
385- KEYS [2 ], signable [ ' signed' ] ))
395+ KEYS [2 ], signed ))
386396
387397 tuf .keydb .add_key (KEYS [0 ])
388398 tuf .keydb .add_key (KEYS [1 ])
@@ -408,9 +418,10 @@ def test_verify_unrecognized_sig(self):
408418
409419 def test_generate_rsa_signature (self ):
410420 signable = {'signed' : 'test' , 'signatures' : []}
421+ signed = securesystemslib .formats .encode_canonical (signable ['signed' ]).encode ('utf-8' )
411422
412423 signable ['signatures' ].append (securesystemslib .keys .create_signature (
413- KEYS [0 ], signable [ ' signed' ] ))
424+ KEYS [0 ], signed ))
414425
415426 self .assertEqual (1 , len (signable ['signatures' ]))
416427 signature = signable ['signatures' ][0 ]
@@ -420,7 +431,7 @@ def test_generate_rsa_signature(self):
420431 self .assertTrue (securesystemslib .formats .SIGNATURE_SCHEMA .matches (returned_signature ))
421432
422433 signable ['signatures' ].append (securesystemslib .keys .create_signature (
423- KEYS [1 ], signable [ ' signed' ] ))
434+ KEYS [1 ], signed ))
424435
425436 self .assertEqual (2 , len (signable ['signatures' ]))
426437 signature = signable ['signatures' ][1 ]
@@ -431,9 +442,10 @@ def test_generate_rsa_signature(self):
431442 def test_may_need_new_keys (self ):
432443 # One untrusted key in 'signable'.
433444 signable = {'signed' : 'test' , 'signatures' : []}
445+ signed = securesystemslib .formats .encode_canonical (signable ['signed' ]).encode ('utf-8' )
434446
435447 signable ['signatures' ].append (securesystemslib .keys .create_signature (
436- KEYS [0 ], signable [ ' signed' ] ))
448+ KEYS [0 ], signed ))
437449
438450 tuf .keydb .add_key (KEYS [1 ])
439451 threshold = 1
0 commit comments