Skip to content

Commit

Permalink
Updates validation side with AV1 (#279)
Browse files Browse the repository at this point in the history
All normal tests pass, but legacy stream still has no AV1 OBUs.
The legacy validation has been verified to work through manual
tests.

Co-authored-by: bjornvolcker <bjornvolcker@users.noreply.github.com>
  • Loading branch information
bjornvolcker and bjornvolcker authored Dec 17, 2024
1 parent 34961e8 commit 3c32d0b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 40 deletions.
54 changes: 14 additions & 40 deletions tests/check/check_signed_video_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ END_TEST
*/
START_TEST(intact_stream)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
// Create a list of NAL Units given the input string.
test_stream_t *list = create_signed_nalus("IPPIPPIPPIPPIPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPISPPISPPISPPISPPISP");
Expand All @@ -296,6 +295,7 @@ END_TEST

START_TEST(intact_multislice_stream)
{
// For AV1, multi-slices are covered in one single OBU (OBU Frame).
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IiPpPpIiPpPpIiPp", settings[_i]);
test_stream_check_types(list, "IiPpPpIiSPpPpIiSPp");
Expand All @@ -314,7 +314,6 @@ END_TEST

START_TEST(intact_stream_with_splitted_nalus)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
// Create a list of NAL Units given the input string.
test_stream_t *list = create_signed_splitted_nalus("IPPIPPIPPIPPIPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPISPPISPPISPPISPPISP");
Expand All @@ -337,7 +336,6 @@ END_TEST
* SEI(s) before the PPS. */
START_TEST(intact_stream_with_pps_nalu_stream)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("VIPPIPPIP", settings[_i]);
test_stream_check_types(list, "VIPPISPPISP");

Expand All @@ -356,6 +354,7 @@ END_TEST

START_TEST(intact_ms_stream_with_pps_nalu_stream)
{
// For AV1, multi-slices are covered in one single OBU (OBU Frame).
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("VIiPpPpIiPpPpIiPp", settings[_i]);
test_stream_check_types(list, "VIiPpPpIiSPpPpIiSPp");
Expand Down Expand Up @@ -383,7 +382,6 @@ END_TEST
*/
START_TEST(intact_with_undefined_nalu_in_stream)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPXPIPPIP", settings[_i]);
test_stream_check_types(list, "IPXPISPPISP");

Expand All @@ -401,6 +399,7 @@ END_TEST

START_TEST(intact_with_undefined_multislice_nalu_in_stream)
{
// For AV1, multi-slices are covered in one single OBU (OBU Frame).
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IiPpXPpIiPpPpIiPp", settings[_i]);
test_stream_check_types(list, "IiPpXPpIiSPpPpIiSPp");
Expand All @@ -425,7 +424,6 @@ END_TEST
*/
START_TEST(remove_one_p_nalu)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPIPPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPPISPPISP");

Expand Down Expand Up @@ -471,7 +469,6 @@ END_TEST
*/
START_TEST(interchange_two_p_nalus)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPIPPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPPISPPISP");

Expand Down Expand Up @@ -510,7 +507,6 @@ END_TEST
*/
START_TEST(modify_one_p_nalu)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPIPPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPPISPPISP");

Expand Down Expand Up @@ -539,7 +535,6 @@ END_TEST

START_TEST(modify_one_i_nalu)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPIPPPIPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPPISPPISPPISP");

Expand Down Expand Up @@ -576,7 +571,6 @@ END_TEST

START_TEST(modify_one_sei)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPIPPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPPISPPISP");

Expand Down Expand Up @@ -616,7 +610,6 @@ END_TEST
* 3. Check the authentication result */
START_TEST(remove_the_g_nalu)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPIPPIPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPISPPISPPISP");

Expand Down Expand Up @@ -647,7 +640,6 @@ END_TEST

START_TEST(remove_the_i_nalu)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPIPPIPPIPPIPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPISPPISPPISPPISPPISP");

Expand Down Expand Up @@ -681,7 +673,6 @@ END_TEST

START_TEST(remove_the_gi_nalus)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPIPPIPPIPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPISPPISPPISPPISP");

Expand Down Expand Up @@ -724,7 +715,6 @@ END_TEST

START_TEST(two_lost_seis)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPIPPIPPIPPIPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPISPPISPPISPPISPPISP");

Expand Down Expand Up @@ -762,7 +752,6 @@ END_TEST
*/
START_TEST(sei_arrives_late)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPPIPPPIPPPIP", settings[_i]);
test_stream_check_types(list, "IPPPISPPPISPPPISP");

Expand Down Expand Up @@ -831,7 +820,6 @@ generate_delayed_sei_list(struct sv_setting setting, bool extra_delay)
*/
START_TEST(all_seis_arrive_late)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = generate_delayed_sei_list(settings[_i], true);

// IPPPPIPPPIPPSPIPPSPIPPSSPISPISP
Expand Down Expand Up @@ -859,7 +847,6 @@ END_TEST

START_TEST(all_seis_arrive_late_first_gop_scrapped)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = generate_delayed_sei_list(settings[_i], true);

// Remove the first GOP: IPPPP IPPPIPPSPIPPSPIPPSSPISPISP
Expand Down Expand Up @@ -891,7 +878,6 @@ END_TEST

START_TEST(all_seis_arrive_late_two_gops_scrapped)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = generate_delayed_sei_list(settings[_i], true);

// Remove the first two GOPs: IPPPPIPPP IPPSPIPPSPIPPSSPISPISP
Expand Down Expand Up @@ -925,7 +911,6 @@ END_TEST
*/
START_TEST(lost_g_before_late_sei_arrival)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPPIPPPIPPPIPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPPISPPPISPPPISPPISPPISP");

Expand Down Expand Up @@ -967,7 +952,6 @@ END_TEST
*/
START_TEST(lost_g_and_gop_with_late_sei_arrival)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
if (TMP_FIX_TO_ALLOW_TWO_INVALID_SEIS_AT_STARTUP) return;

// TODO: This test is not up-to-date, since it is currently not used.
Expand Down Expand Up @@ -1024,7 +1008,6 @@ END_TEST
* Verify that we can validate authenticity correctly if we lose all NAL Units between two SEIs. */
START_TEST(lost_all_nalus_between_two_seis)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPPIPPPIPPPIPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPPISPPPISPPPISPPISPPISP");

Expand Down Expand Up @@ -1068,21 +1051,26 @@ END_TEST
*/
START_TEST(add_one_sei_nalu_after_signing)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
SignedVideoCodec codec = settings[_i].codec;
test_stream_t *list = create_signed_nalus("IPPIPPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPPISPPISP");

const uint8_t id = 0;
test_stream_item_t *sei = test_stream_item_create_from_type('Z', id, settings[_i].codec);
test_stream_item_t *sei = test_stream_item_create_from_type('Z', id, codec);

// Append the middle 'P' in second GOP: IPPISP P(Z) PISPPISP
const int append_nalu_number = 7;
test_stream_append_item(list, sei, append_nalu_number);
test_stream_check_types(list, "IPPISPPZPISPPISP");

// For AV1 OBU metadata are hashed, hence adding one will break the authenticity.
SignedVideoAuthenticityResult authenticity =
codec != SV_CODEC_AV1 ? SV_AUTH_RESULT_OK : SV_AUTH_RESULT_NOT_OK;
signed_video_accumulated_validation_t final_validation = {
SV_AUTH_RESULT_OK, false, 16, 13, 3, SV_PUBKEY_VALIDATION_NOT_FEASIBLE, true, 0, 0};
const struct validation_stats expected = {.valid_gops = 3,
authenticity, false, 16, 13, 3, SV_PUBKEY_VALIDATION_NOT_FEASIBLE, true, 0, 0};
const struct validation_stats expected = {.valid_gops = codec != SV_CODEC_AV1 ? 3 : 2,
.invalid_gops = codec != SV_CODEC_AV1 ? 0 : 1,
.missed_nalus = codec != SV_CODEC_AV1 ? 0 : -1,
.pending_nalus = 3 + 4,
.unsigned_gops = 1,
.final_validation = &final_validation};
Expand All @@ -1098,7 +1086,6 @@ END_TEST
*/
START_TEST(remove_two_gop_in_start_of_stream)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
// Create a list of NAL Units given the input string.
test_stream_t *list = create_signed_nalus("IPIPIPPPIPPPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPISPISPPPISPPPPISPPISP");
Expand Down Expand Up @@ -1153,7 +1140,6 @@ END_TEST
*/
START_TEST(camera_reset_on_signing_side)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
// Generate 2 GOPs
test_stream_t *list = create_signed_nalus("IPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPISP");
Expand Down Expand Up @@ -1204,7 +1190,6 @@ END_TEST
*/
START_TEST(detect_change_of_public_key)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
// Generate 2 GOPs
test_stream_t *list = create_signed_nalus("IPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPISP");
Expand Down Expand Up @@ -1318,7 +1303,6 @@ mimic_au_fast_forward_and_get_list(signed_video_t *sv, struct sv_setting setting

START_TEST(fast_forward_stream_with_reset)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
// Create a session.
signed_video_t *sv = get_initialized_signed_video(settings[_i], false);
ck_assert(sv);
Expand Down Expand Up @@ -1347,7 +1331,6 @@ END_TEST

START_TEST(fast_forward_stream_without_reset)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
// Create a session.
signed_video_t *sv = get_initialized_signed_video(settings[_i], false);
ck_assert(sv);
Expand Down Expand Up @@ -1416,7 +1399,6 @@ mimic_au_fast_forward_on_late_seis_and_get_list(signed_video_t *sv, struct sv_se

START_TEST(fast_forward_stream_with_delayed_seis)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
// Create a new session.
signed_video_t *sv = get_initialized_signed_video(settings[_i], false);
ck_assert(sv);
Expand Down Expand Up @@ -1510,7 +1492,6 @@ mimic_file_export(struct sv_setting setting, bool delayed_seis)

START_TEST(file_export_with_dangling_end)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = mimic_file_export(settings[_i], false);

// VISPPISPPISPPISPP
Expand All @@ -1534,7 +1515,6 @@ END_TEST

START_TEST(file_export_with_two_useless_seis)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = generate_delayed_sei_list(settings[_i], true);
// Remove the first three GOPs.
// IPPPPIPPPIPPSP IPPSPIPPSSPISPISP
Expand Down Expand Up @@ -1567,7 +1547,6 @@ END_TEST
*/
START_TEST(no_signature)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = test_stream_create("IPPIPPIPPIPPI", settings[_i].codec);
test_stream_check_types(list, "IPPIPPIPPIPPI");

Expand Down Expand Up @@ -1595,6 +1574,7 @@ END_TEST

START_TEST(multislice_no_signature)
{
// For AV1, multi-slices are covered in one single OBU (OBU Frame).
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = test_stream_create("IiPpPpIiPpPpIiPpPpIiPpPpIi", settings[_i].codec);
test_stream_check_types(list, "IiPpPpIiPpPpIiPpPpIiPpPpIi");
Expand Down Expand Up @@ -1633,7 +1613,6 @@ END_TEST
*/
START_TEST(fallback_to_gop_level)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
const size_t kFallbackSize = 10;
signed_video_t *sv = get_initialized_signed_video(settings[_i], false);
ck_assert(sv);
Expand Down Expand Up @@ -1662,7 +1641,6 @@ END_TEST
* APIs in vendors/axis-communications are used and tests both signing and validation parts. */
START_TEST(vendor_axis_communications_operation)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
SignedVideoReturnCode sv_rc;
struct sv_setting setting = settings[_i];
SignedVideoCodec codec = settings[_i].codec;
Expand Down Expand Up @@ -1872,7 +1850,6 @@ validate_public_key_scenario(signed_video_t *sv,
*/
START_TEST(test_public_key_scenarios)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
struct pk_setting {
bool pk_in_sei;
bool use_wrong_pk;
Expand Down Expand Up @@ -1953,7 +1930,6 @@ END_TEST
/* Test description */
START_TEST(no_public_key_in_sei_and_bad_public_key_on_validation_side)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
SignedVideoReturnCode sv_rc;
SignedVideoCodec codec = settings[_i].codec;
test_stream_item_t *i_nalu = test_stream_item_create_from_type('I', 0, codec);
Expand Down Expand Up @@ -2023,6 +1999,7 @@ END_TEST
* the other case is the default and executed for all other tests. */
START_TEST(no_emulation_prevention_bytes)
{
// Emulation prevention does not apply for AV1.
if (settings[_i].codec == SV_CODEC_AV1) return;
struct sv_setting setting = settings[_i];
SignedVideoCodec codec = settings[_i].codec;
Expand Down Expand Up @@ -2154,7 +2131,6 @@ END_TEST
*/
START_TEST(with_blocked_signing)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = create_signed_nalus("IPPIPPIPPIPPIPPIP", settings[_i]);
test_stream_check_types(list, "IPPISPPISPPISPPISPPISP");
test_stream_item_t *sei = test_stream_item_remove(list, 17);
Expand Down Expand Up @@ -2198,7 +2174,6 @@ END_TEST
*/
START_TEST(golden_sei_principle)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
struct sv_setting setting = settings[_i];
setting.with_golden_sei = true;

Expand Down Expand Up @@ -2234,7 +2209,6 @@ END_TEST
*/
START_TEST(legacy_stream)
{
if (settings[_i].codec == SV_CODEC_AV1) return;
test_stream_t *list = get_legacy_stream(_i, settings[_i].codec);
if (!list) return;

Expand Down
8 changes: 8 additions & 0 deletions tests/check/legacy_test_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,14 @@ static const legacy_data_t legacy_data[NUM_SETTINGS][LEGACY_STREAM_LENGTH] = {
// {SV_CODEC_H264, SV_AUTHENTICITY_LEVEL_FRAME, signed_video_generate_ecdsa_private_key, 0,
// "sha512"},
// Not valid for legacy streams.
{{0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL},
{0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}},
// AV1 tests
// TODO: Add test data for AV1.
// {SV_CODEC_AV1, SV_AUTHENTICITY_LEVEL_GOP, true, false, false, 0, NULL, 0, 1, false, false},
{{0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL},
{0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}},
// {SV_CODEC_AV1, SV_AUTHENTICITY_LEVEL_FRAME, true, false, false, 0, NULL, 0, 1, false, false},
{{0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL},
{0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}};
#if 0
Expand Down

0 comments on commit 3c32d0b

Please sign in to comment.