Skip to content

Comments

update policy config api#790

Draft
pabuhler wants to merge 1 commit intocisco:mainfrom
pabuhler:policy-api
Draft

update policy config api#790
pabuhler wants to merge 1 commit intocisco:mainfrom
pabuhler:policy-api

Conversation

@pabuhler
Copy link
Member

@pabuhler pabuhler commented Feb 8, 2026

As part of the API changes for 3.0, would like to simplify the policy API as well as making it easier to extend in the future. The current API has far to many details and can be cumbersome to set up and validate.

Main changes:

  • move from a public struct to a opaque handle
  • use profiles to initialize crypto policy
  • remove detailed config options, can be added if needed
  • use explicit key size's
  • remove policy list
  • add tests

Either a single policy can be used with srtp_create() or else multiple policies can be used with multiple calls to srtp_add_stream() .

A minimal example would be

srtp_policy_t policy;
srtp_policy_create(&policy);
srtp_policy_set_ssrc(policy, (srtp_ssrc_t){ ssrc_any_outbound, 0 });
srtp_policy_set_profile(policy, srtp_profile_aes128_cm_sha1_80);
srtp_policy_set_key(policy, master_key, sizeof(master_key), master_salt, sizeof(master_salt));
srtp_create(&srtp, policy); 

It could be nice to remove the set_ssrc() function if a suitable default behavior could be found.

Includes a minima implementation and unit tests.
@pabuhler pabuhler added this to the Version 3.0 milestone Feb 8, 2026
@pabuhler
Copy link
Member Author

pabuhler commented Feb 8, 2026

The implementation is currently just a new front end to the existing srtp_policy_t API, the intention would be to eventually remove the old structure and functions from the public API.

@pabuhler pabuhler mentioned this pull request Feb 8, 2026
16 tasks
Copy link
Contributor

@paulej paulej left a comment

Choose a reason for hiding this comment

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

Initial review

return srtp_err_status_bad_param;
}

p = (srtp_policy2_t)srtp_crypto_alloc(sizeof(*p));
Copy link
Contributor

Choose a reason for hiding this comment

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

p is a pointer and not yet assigned, right? If so, *p is an invalid pointer dereference.

Copy link
Member Author

Choose a reason for hiding this comment

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

compile time only ... but I get your point

return srtp_err_status_ok;
}

srtp_err_status_t srtp_policy2_set_key(srtp_policy2_t policy,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't fully understand the point of this one

Copy link
Member Author

Choose a reason for hiding this comment

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

no, I started with this then did add_key, probably add_key is enough

Copy link
Contributor

@paulej paulej left a comment

Choose a reason for hiding this comment

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

Initial review

Copy link
Contributor

@paulej paulej left a comment

Choose a reason for hiding this comment

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

Initial review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants