-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove reset_gop_hash and update_gop_hash APIs #265
Merged
mithydolphin
merged 2 commits into
master
from
Remove_reset_gop_hash_and_update_gop_hash
Dec 6, 2024
+7
−45
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,18 +271,6 @@ set_hash_list_size(gop_info_t *gop_info, size_t hash_list_size) | |
return SV_OK; | ||
} | ||
|
||
svrc_t | ||
reset_gop_hash(signed_video_t *self) | ||
{ | ||
if (!self) return SV_INVALID_PARAMETER; | ||
|
||
gop_info_t *gop_info = self->gop_info; | ||
assert(gop_info); | ||
|
||
gop_info->num_nalus_in_gop_hash = 0; | ||
return openssl_hash_data(self->crypto_handle, &gop_info->gop_hash_init, 1, gop_info->gop_hash); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should write a ticket to init the new gop hash computation with gop_hash_init. |
||
} | ||
|
||
/** | ||
* Checks a pointer to member in struct if it's allocated, and correct size, then copies over the | ||
* data to that member. | ||
|
@@ -837,23 +825,6 @@ update_num_nalus_in_gop_hash(signed_video_t *self, const h26x_nalu_t *nalu) | |
} | ||
} | ||
|
||
svrc_t | ||
update_gop_hash(void *crypto_handle, gop_info_t *gop_info) | ||
{ | ||
if (!gop_info) return SV_INVALID_PARAMETER; | ||
|
||
size_t hash_size = openssl_get_hash_size(crypto_handle); | ||
svrc_t status = SV_UNKNOWN_FAILURE; | ||
SV_TRY() | ||
// Update the gop_hash, that is, hash the memory (both hashes) in hashes = [gop_hash, latest | ||
// nalu_hash] and replace the gop_hash part with the new hash. | ||
SV_THROW(openssl_hash_data(crypto_handle, gop_info->hashes, 2 * hash_size, gop_info->gop_hash)); | ||
SV_CATCH() | ||
SV_DONE(status) | ||
|
||
return status; | ||
} | ||
|
||
/* Initializes and updates the GOP hash regardless of available space. If there is enough | ||
* room, copies the |hash| and updates |list_idx|. Otherwise, sets |list_idx| to -1. | ||
*/ | ||
|
@@ -1070,7 +1041,6 @@ hash_and_add(signed_video_t *self, const h26x_nalu_t *nalu) | |
if (nalu->is_last_nalu_part) { | ||
// The end of the NALU has been reached. Update hash list and GOP hash. | ||
check_and_copy_hash_to_hash_list(self, nalu_hash, hash_size); | ||
SV_THROW(update_gop_hash(self->crypto_handle, gop_info)); | ||
update_num_nalus_in_gop_hash(self, nalu); | ||
} | ||
SV_CATCH() | ||
|
@@ -1171,8 +1141,7 @@ signed_video_create(SignedVideoCodec codec) | |
|
||
self->gop_info = gop_info_create(); | ||
SV_THROW_IF_WITH_MSG(!self->gop_info, SV_MEMORY, "Could not allocate gop_info"); | ||
SV_THROW_WITH_MSG(reset_gop_hash(self), "Could not reset gop_hash"); | ||
|
||
self->gop_info->num_nalus_in_gop_hash = 0; | ||
// Setup vendor handle. | ||
#ifdef SV_VENDOR_AXIS_COMMUNICATIONS | ||
self->vendor_handle = sv_vendor_axis_communications_setup(); | ||
|
@@ -1250,7 +1219,7 @@ signed_video_reset(signed_video_t *self) | |
self->last_nalu->is_last_nalu_part = true; | ||
SV_THROW(openssl_init_hash(self->crypto_handle, false)); | ||
|
||
SV_THROW(reset_gop_hash(self)); | ||
self->gop_info->num_nalus_in_gop_hash = 0; | ||
SV_CATCH() | ||
SV_DONE(status) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
#include "signed_video_authenticity.h" // allocate_memory_and_copy_string | ||
#include "signed_video_defines.h" // svrc_t, sv_tlv_tag_t | ||
#include "signed_video_h26x_internal.h" // parse_nalu_info() | ||
#include "signed_video_internal.h" // gop_info_t, reset_gop_hash() | ||
#include "signed_video_internal.h" // gop_info_t | ||
#include "signed_video_openssl_internal.h" | ||
#include "signed_video_tlv.h" // tlv_list_encode_or_get_size() | ||
|
||
|
@@ -354,8 +354,8 @@ generate_sei_nalu(signed_video_t *self, uint8_t **payload, uint8_t **payload_sig | |
memcpy(sign_data->hash, gop_info->gop_hash, hash_size); | ||
} | ||
|
||
// Reset the gop_hash since we start a new GOP. | ||
SV_THROW(reset_gop_hash(self)); | ||
// Reset the |num_nalus_in_gop_hash| since we start a new GOP. | ||
self->gop_info->num_nalus_in_gop_hash = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You already got "gop_info" from row 350. |
||
// Reset the |hash_list| by rewinding the |list_idx| since we start a new GOP. | ||
gop_info->list_idx = 0; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove space.