Skip to content

Commit 455dffa

Browse files
authored
Forces verify_without_sei to validate at least one BU (#488)
When trying to synchronize SEIs situations when validating without a SEI to close a gap can occur. In such a case, it should select and validate at least one BU. Otherwise, an endless loop can occur. This commit affects one test, fast_forward_stream_without_reset, which temporarily has been changed until SEI synchronization has been separated from first validation. Co-authored-by: bjornvolcker <[email protected]>
1 parent 5c02dae commit 455dffa

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/src/sv_auth.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,18 +649,24 @@ verify_hashes_without_sei(signed_video_t *self, int num_skips)
649649
// Determine number of items to mark given number of BUs to skip.
650650
int num_marked_items = 0;
651651
int max_marked_items = num_bu_in_first_gop;
652+
int extra_marked_item = 0;
652653
if (num_bu_in_all_gops == num_bu_in_first_gop) {
653654
// Only one GOP present. Skip BUs from first GOP.
654655
max_marked_items -= num_skips;
655656
if (max_marked_items < 0) {
656657
max_marked_items = 0;
658+
// By definition, at least one BU needs to be validated to be able to synchronize
659+
// the SEI.
660+
if (!self->validation_flags.sei_in_sync) {
661+
extra_marked_item = 1;
662+
}
657663
}
658664
}
659665

660666
// Start from the oldest item and mark all pending items as NOT OK ('N') until
661667
// |max_marked_items| have been marked.
662668
item = bu_list->first_item;
663-
while (item && (num_marked_items < max_marked_items)) {
669+
while (item && (num_marked_items < max_marked_items + extra_marked_item)) {
664670
// Skip non-pending items and items already associated with a SEI.
665671
if (item->tmp_validation_status != 'P' || item->associated_sei) {
666672
item = item->next;
@@ -682,7 +688,7 @@ verify_hashes_without_sei(signed_video_t *self, int num_skips)
682688
item = item->next;
683689
}
684690

685-
return (num_marked_items > 0);
691+
return (num_marked_items - extra_marked_item > 0);
686692
}
687693

688694
/* Validates the authenticity using hashes in the |bu_list|.

tests/check/check_signed_video_auth.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,9 +1301,13 @@ START_TEST(fast_forward_stream_without_reset)
13011301
//
13021302
// ISP -> (invalid)
13031303
signed_video_accumulated_validation_t final_validation = {SV_AUTH_RESULT_NOT_OK, false, 8 + 13,
1304-
8 + 10, 3, SV_PUBKEY_VALIDATION_NOT_FEASIBLE, true, 0, 0};
1305-
const struct validation_stats expected = {
1306-
.valid_gops = 1, .invalid_gops = 2, .pending_bu = 3, .final_validation = &final_validation};
1304+
8 + 1, // 10,
1305+
12, // 3,
1306+
SV_PUBKEY_VALIDATION_NOT_FEASIBLE, true, 0, 0};
1307+
const struct validation_stats expected = {.valid_gops = 0, // 1,
1308+
.invalid_gops = 3, // 2,
1309+
.pending_bu = 4, // 3,
1310+
.final_validation = &final_validation};
13071311
validate_stream(sv, list, expected, true);
13081312

13091313
// Free list and session.

0 commit comments

Comments
 (0)