Skip to content

Updated signed_video_set_private_key#402

Closed
mithydolphin wants to merge 13 commits intomasterfrom
update-set_private_key-for-onvif
Closed

Updated signed_video_set_private_key#402
mithydolphin wants to merge 13 commits intomasterfrom
update-set_private_key-for-onvif

Conversation

@mithydolphin
Copy link
Contributor

Updated signed_video_set_private_key to work with ONVIF. Added getter
functions for the private key and certificate chain. Included a test
to verify the signing functionality.

Describe your changes

Please include a summary of the change, a relevant motivation and context.

Issue ticket number and link

  • Fixes #(issue)

Checklist before requesting a review

  • I have performed a self-review of my own code
  • I have verified that the code builds perfectly fine on my local system
  • I have added tests that prove my fix is effective or that my feature works
  • I have commented my code, particularly in hard-to-understand areas
  • I have verified that my code follows the style already available in the repository
  • I have made corresponding changes to the documentation

Updated signed_video_set_private_key to work with ONVIF. Added getter
functions for the private key and certificate chain. Included a test
to verify the signing functionality.
Copy link
Contributor

@bjornvolcker bjornvolcker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial comments

Change-Id: If5540f944d12920de0daf890cd79427aa8eb45be
Change-Id: I3145e9824128a31f63e5c8a47f692855bbc56695
Copy link
Contributor

@bjornvolcker bjornvolcker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still a bunch of unanswered review questions.

Also, have you verified that it works to use the reconstructed key on a device?

Change-Id: Ib332af2a44b5136a0cda361aa9da7ccaf7c53e70
Copy link
Contributor

@bjornvolcker bjornvolcker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a few old review comments to address. And a few new ones.

@bjornvolcker
Copy link
Contributor

This PR is quite large. Is it possible to split it into a series of 5-10 separate PRs. It will make reviewing much easier.

Copy link

@lusikamalo2 lusikamalo2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No extra comments from my side so far.

Change-Id: I6dc497e6681719abeef1477cec9c416a5439f777
Copy link
Contributor

@bjornvolcker bjornvolcker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still doesn't work. How are you testing the various cases?

  • order of operations
  • number of signing plugins
  • fallback to signed video upon failure

I still suggest that splitting this PR into smaller pieces will help you test and solve these.

* retrieving the private key and certificate chain from the signed video object,
* and setting the ONVIF signing key pair.
* and setting the ONVIF signing key pair. The function will free the ONVIF object
* on failure, allowing the framework to continue with the signed video.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the desired behavior, but is that really what happens with your implementation?
Have you tested/verified that?

// Try to initialize ONVIF; if it is not available or cannot be initialized,
// fallback to Signed Video signing plugin.
initialize_onvif(self);
if (!self->onvif) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now when ONVIF signing plugin is called through the Axis signing plugin (see other PR) you need to remove the if-statement


return status;
self->private_key = NULL;
if (status != SV_OK && self->onvif != NULL) assert(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, you should also check the opposite. I only gave you an example. And also shouldn't it be false in assert?

assert((status == SV_OK && !self->onvif) || (status != SV_OK && self->onvif));

// Sanity check ONVIF object.
if(!self->onvif) {
return SV_INVALID_PARAMETER;
if (!self->onvif) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also check if private_key exists

// Temporally turn the PEM |private_key| into an EVP_PKEY and allocate memory for signatures.
SV_THROW(openssl_private_key_malloc(self->sign_data, private_key, private_key_size));
SV_THROW(openssl_read_pubkey_from_private_key(self->sign_data, &self->pem_public_key));
self->private_key = private_key;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to set private_key_size

if (status == SV_OK) {
return status;
}
if (sv->sign_data && sv->sign_data->key && sv->onvif) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for if-statement. The check should be inside initilaize_onvif()

// For signing plugin
void *plugin_handle;
sign_or_verify_data_t *sign_data; // Pointer to all necessary information to sign in a plugin.
const char *private_key;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment what this is used for. A reader might assume that this is the signing key used during the session, but it is not.

self->private_key = private_key;

// Try to initialize ONVIF; if it is not available or cannot be initialized,
// fallback to Signed Video signing plugin.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment about "fallback" should be inside initialize_onvif since you do not take any actions regarding that out here.


sv_vendor_axis_communications_t *self = (sv_vendor_axis_communications_t *)handle;

// Return the certificate chain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant comment. I think the reader is clever enough to understand that from the line below.

@mithydolphin mithydolphin deleted the update-set_private_key-for-onvif branch March 18, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants