diff --git a/lib/src/sv_auth.c b/lib/src/sv_auth.c index 74ce050f..38801752 100644 --- a/lib/src/sv_auth.c +++ b/lib/src/sv_auth.c @@ -649,18 +649,24 @@ verify_hashes_without_sei(signed_video_t *self, int num_skips) // Determine number of items to mark given number of BUs to skip. int num_marked_items = 0; int max_marked_items = num_bu_in_first_gop; + int extra_marked_item = 0; if (num_bu_in_all_gops == num_bu_in_first_gop) { // Only one GOP present. Skip BUs from first GOP. max_marked_items -= num_skips; if (max_marked_items < 0) { max_marked_items = 0; + // By definition, at least one BU needs to be validated to be able to synchronize + // the SEI. + if (!self->validation_flags.sei_in_sync) { + extra_marked_item = 1; + } } } // Start from the oldest item and mark all pending items as NOT OK ('N') until // |max_marked_items| have been marked. item = bu_list->first_item; - while (item && (num_marked_items < max_marked_items)) { + while (item && (num_marked_items < max_marked_items + extra_marked_item)) { // Skip non-pending items and items already associated with a SEI. if (item->tmp_validation_status != 'P' || item->associated_sei) { item = item->next; @@ -682,7 +688,7 @@ verify_hashes_without_sei(signed_video_t *self, int num_skips) item = item->next; } - return (num_marked_items > 0); + return (num_marked_items - extra_marked_item > 0); } /* Validates the authenticity using hashes in the |bu_list|. diff --git a/tests/check/check_signed_video_auth.c b/tests/check/check_signed_video_auth.c index 6ffc466c..aa84c513 100644 --- a/tests/check/check_signed_video_auth.c +++ b/tests/check/check_signed_video_auth.c @@ -1301,9 +1301,13 @@ START_TEST(fast_forward_stream_without_reset) // // ISP -> (invalid) signed_video_accumulated_validation_t final_validation = {SV_AUTH_RESULT_NOT_OK, false, 8 + 13, - 8 + 10, 3, SV_PUBKEY_VALIDATION_NOT_FEASIBLE, true, 0, 0}; - const struct validation_stats expected = { - .valid_gops = 1, .invalid_gops = 2, .pending_bu = 3, .final_validation = &final_validation}; + 8 + 1, // 10, + 12, // 3, + SV_PUBKEY_VALIDATION_NOT_FEASIBLE, true, 0, 0}; + const struct validation_stats expected = {.valid_gops = 0, // 1, + .invalid_gops = 3, // 2, + .pending_bu = 4, // 3, + .final_validation = &final_validation}; validate_stream(sv, list, expected, true); // Free list and session.