Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation about RSA private keys #179

Merged
merged 2 commits into from
Nov 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/jws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,54 @@ pub enum Secret {
/// -out public_key.der
/// ```
///
/// Note that the underlying crate (ring) does not support the format used
/// by OpenSSL. You can check the format using
///
/// ```sh
/// openssl asn1parse -inform DER -in public_key.der
/// ```
///
/// It should output something like
///
/// ```sh
/// 0:d=0 hl=4 l= 290 cons: SEQUENCE
/// 4:d=1 hl=2 l= 13 cons: SEQUENCE
/// 6:d=2 hl=2 l= 9 prim: OBJECT :rsaEncryption
/// 17:d=2 hl=2 l= 0 prim: NULL
/// 19:d=1 hl=4 l= 271 prim: BIT STRING
/// ```
///
/// There is a header here that indicates the content of the file
/// (a public key for `rsaEncryption`). The actual key is contained
/// within the BIT STRING at the end. The bare public key can be
/// extracted with
///
/// ```sh
/// openssl asn1parse -inform DER \
/// -in public_key.der \
/// -offset 24 \
/// -out public_key_extracted.der
/// ```
///
/// Run the following to verify that the key is in the right format
///
/// ```sh
/// openssl asn1parse -inform DER -in public_key_extracted.der
/// ```
///
/// The right format looks like this (the `<>` elements show the actual
/// numbers)
///
/// ```sh
/// 0:d=0 hl=4 l= 266 cons: SEQUENCE
/// 4:d=1 hl=4 l= 257 prim: INTEGER :<public key modulus>
/// 265:d=1 hl=2 l= 3 prim: INTEGER :<public key exponent>
/// ```
///
/// Every other format will be rejected by ring with an unspecified error.
/// Note that OpenSSL is no longer able to interpret this file as a public key,
/// since it no longer contains the expected header.
///
/// # Examples
/// ```
/// use biscuit::jws::Secret;
Expand Down