Skip to content

x509-cert: incorrect bit tests for KeyUsage #992

Description

@stormshield-guillaumed

The recently added bit tests method on KeyUsage doesn't give the expected result.

Reproduction

let key_usage = KeyUsage(KeyUsages::KeyEncipherment.into());

println!("{}", key_usage.digital_signature());
println!("{}", key_usage.0.contains(KeyUsages::DigitalSignature));

Output

true
false

Expected

false
false

This is due to the usage of KeyUsages::X as u16 which is not the same as the flag value. I'm preparing a PR. Would you like to keep the same API or have a wrapper function fn contains(&self, rhs: impl Into<FlagSet<KeyUsages>>) or maybe both ?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions