-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Currently, the HeaderBuilder has:
/// Set the algorithm.
#[must_use]
pub fn algorithm(mut self, alg: iana::Algorithm) -> Self {
self.0.alg = Some(Algorithm::Assigned(alg));
self
}
Cose allows Private Use values (integers less than -65536), for non standardized algorithms. This can be useful for adopting algorithms widely regarded as safe and in certain contexts superior to the existing options (for example, XChaCha20, which has not been adopted into an RFC, but provides a clear benefit w.r.t. the nonce size).
This currently has to be represented as:
let mut protected_header = coset::HeaderBuilder::new().build();
protected_header.alg = Some(coset::Algorithm::PrivateUse(XCHACHA20_POLY1305));
not allowing to make use of the builder pattern.
My proposal is to add another option to the builder, along the lines of:
/// Set the algorithm.
#[must_use]
pub fn private_algorithm(mut self, alg: i64) -> Self {
self.0.alg = Some(Algorithm::PrivateUse(alg));
self
}
Unless there are concerns with this approach, I'm happy to send a PR adding this.
Metadata
Metadata
Assignees
Labels
No labels