Skip to content

Commit

Permalink
Document most of the xwt-cert-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
MOZGIII committed Feb 2, 2024
1 parent 5381346 commit d62685c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crates/xwt-cert-utils/src/digest.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Digest computation.
/// Compute a SHA256 digest for the given data.
///
/// Pass DER certificate here to compute its digest.
Expand Down
2 changes: 2 additions & 0 deletions crates/xwt-cert-utils/src/fingerprint.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Fingerprint computation.
/// RFC7469 fingerprint.
#[cfg(feature = "fingerprint-rfc7469")]
pub fn rfc7469(cert: &rcgen::Certificate) -> String {
Expand Down
4 changes: 4 additions & 0 deletions crates/xwt-cert-utils/src/gen.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Certificate generation facilities.
/// The params for certificate generation.
#[allow(missing_docs)]
pub struct Params<'a> {
pub common_name: &'a str,
pub subject_alt_names: &'a [&'a str],
Expand All @@ -9,6 +11,7 @@ pub struct Params<'a> {

#[cfg(feature = "rcgen")]
impl<'a> Params<'a> {
/// Convert params into [`rcgen::CertificateParams`].
pub fn into_rcgen_params(
self,
key_alg: &'static rcgen::SignatureAlgorithm,
Expand Down Expand Up @@ -42,6 +45,7 @@ impl<'a> Params<'a> {
cert_params
}

/// Convert params into [`rcgen::Certificate`].
pub fn into_rcgen_cert(
self,
key_alg: &'static rcgen::SignatureAlgorithm,
Expand Down
2 changes: 0 additions & 2 deletions crates/xwt-cert-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Certificate utils and tooling.
#![allow(missing_docs, clippy::missing_docs_in_private_items)]

pub mod digest;
pub mod fingerprint;
pub mod gen;
Expand Down
3 changes: 3 additions & 0 deletions crates/xwt-cert-utils/src/pem.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Support for the PEM data-encoding format.
/// A type that represents a PEM-encoded private key.
pub struct PrivateKey(pub String);

Expand All @@ -11,6 +13,7 @@ pub fn parse(data: &str) -> Result<Vec<u8>, pem::PemError> {
Ok(data)
}

/// Serialize [`rcgen::Certificate`] into PEM format.
#[cfg(feature = "rcgen")]
pub fn from_rcgen(cert: &rcgen::Certificate) -> (PrivateKey, Certificate) {
let key_pem = cert.serialize_private_key_pem();
Expand Down

0 comments on commit d62685c

Please sign in to comment.