Skip to content

pkcs8: Question around decoding PrivateKeyInfo #1749

Closed
@Daaiid

Description

@Daaiid

Is it intended behavior that after calling:

let key_info = PrivateKeyInfo::try_from(key_der_bytes).unwrap();

that the private_key field is still DER encoded?

I had to debug for a few hours until I realized that I didn't get the raw key from the field but that it was still prefixed with the Tag and Length bytes.

I would gladly open a PR to document this behavior but I wanted to first make sure what I'm seeing is as intended.

For anyone finding this in the future: Calling

let private_key: &[u8] = OctetStringRef::from_der(key_info.private_key).unwrap().into();

gave me the actual private key.

Thanks in advance!

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