Skip to content

Commit

Permalink
chore: Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
emgrav committed Oct 30, 2024
1 parent 80a554a commit a71084c
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 32 deletions.
7 changes: 7 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[files]
extend-exclude = ["data/**"]

[default.extend-words]
# Can't change the API surface
encrypter = "encrypter"
deriver = "deriver"
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cargo build --release
```sh
1. Update to vX.X.X on cargo.toml and README.md.
2. Run commnads
2. Run commands
cargo test
cargo publish --dry-run
git tag vX.X.X
Expand Down Expand Up @@ -378,7 +378,7 @@ fn main() -> Result<(), JoseError> {
let signer = HS256.signer_from_bytes(key)?;
let jwt = jwt::encode_with_signer(&payload, &header, &signer)?;

// Verifing JWT
// Verifying JWT
let verifier = HS256.verifier_from_bytes(key)?;
let (payload, header) = jwt::decode_with_verifier(&jwt, &verifier)?;

Expand Down Expand Up @@ -421,7 +421,7 @@ fn main() -> Result<(), JoseError> {
let signer = RS256.signer_from_pem(&private_key)?;
let jwt = jwt::encode_with_signer(&payload, &header, &signer)?;

// Verifing JWT
// Verifying JWT
let public_key = std::fs::read(PUBLIC_KEY).unwrap();
let verifier = RS256.verifier_from_pem(&public_key)?;
let (payload, header) = jwt::decode_with_verifier(&jwt, &verifier)?;
Expand Down Expand Up @@ -475,7 +475,7 @@ fn main() -> Result<(), JoseError> {
let signer = PS256.signer_from_pem(&private_key)?;
let jwt = jwt::encode_with_signer(&payload, &header, &signer)?;

// Verifing JWT
// Verifying JWT
let public_key = std::fs::read(PUBLIC_KEY).unwrap();
let verifier = PS256.verifier_from_pem(&public_key)?;
let (payload, header) = jwt::decode_with_verifier(&jwt, &verifier)?;
Expand Down Expand Up @@ -530,7 +530,7 @@ fn main() -> Result<(), JoseError> {
let signer = ES256.signer_from_pem(&private_key)?;
let jwt = jwt::encode_with_signer(&payload, &header, &signer)?;

// Verifing JWT
// Verifying JWT
let public_key = std::fs::read(PUBLIC_KEY).unwrap();
let verifier = ES256.verifier_from_pem(&public_key)?;
let (payload, header) = jwt::decode_with_verifier(&jwt, &verifier)?;
Expand Down Expand Up @@ -580,7 +580,7 @@ fn main() -> Result<(), JoseError> {
let signer = EdDSA.signer_from_pem(&private_key)?;
let jwt = jwt::encode_with_signer(&payload, &header, &signer)?;

// Verifing JWT
// Verifying JWT
let public_key = std::fs::read(PUBLIC_KEY).unwrap();
let verifier = EdDSA.verifier_from_pem(&public_key)?;
let (payload, header) = jwt::decode_with_verifier(&jwt, &verifier)?;
Expand Down
6 changes: 3 additions & 3 deletions src/jwe/enc/aescbc_hmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl AescbcHmacJweEncryption {
}
}

fn calcurate_tag(
fn calculate_tag(
&self,
aad: &[u8],
iv: Option<&[u8]>,
Expand Down Expand Up @@ -116,7 +116,7 @@ impl JweContentEncryption for AescbcHmacJweEncryption {
})()
.map_err(|err| JoseError::InvalidKeyFormat(err))?;

let tag = self.calcurate_tag(aad, iv, &encrypted_message, mac_key)?;
let tag = self.calculate_tag(aad, iv, &encrypted_message, mac_key)?;

Ok((encrypted_message, Some(tag)))
}
Expand Down Expand Up @@ -155,7 +155,7 @@ impl JweContentEncryption for AescbcHmacJweEncryption {
None => bail!("A tag value is required."),
};

let calc_tag = self.calcurate_tag(aad, iv, &encrypted_message, mac_key)?;
let calc_tag = self.calculate_tag(aad, iv, &encrypted_message, mac_key)?;
if calc_tag.as_slice() != tag {
bail!("The tag doesn't match.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/jwe/jwe_algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub trait JweEncrypter: Debug + Send + Sync {
out_header: &mut JweHeader,
) -> Result<Option<Cow<[u8]>>, JoseError>;

/// Return a encypted key.
/// Return a encrypted key.
///
/// # Arguments
///
Expand Down
20 changes: 10 additions & 10 deletions src/jwe/jwe_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,27 +500,27 @@ impl JweContext {
let (ciphertext, tag) =
cencryption.encrypt(&key, iv.as_deref(), content, full_aad.as_bytes())?;

let mut writed = false;
let mut written = false;
let mut json = String::new();
if let Some(val) = protected_b64 {
json.push_str("{\"protected\":\"");
json.push_str(&val);
json.push_str("\"");
writed = true;
written = true;
}

if let Some(val) = header {
let unprotected_map = val.claims_set(false);
if unprotected_map.len() > 0 {
let unprotected = serde_json::to_string(unprotected_map)?;
json.push_str(if writed { "," } else { "{" });
json.push_str(if written { "," } else { "{" });
json.push_str("\"unprotected\":");
json.push_str(&unprotected);
writed = true;
written = true;
}
}

json.push_str(if writed { "," } else { "{" });
json.push_str(if written { "," } else { "{" });
json.push_str("\"recipients\":[");
for i in 0..recipient_headers.len() {
if i > 0 {
Expand Down Expand Up @@ -751,31 +751,31 @@ impl JweContext {

let (ciphertext, tag) = cencryption.encrypt(&key, iv, content, full_aad.as_bytes())?;

let mut writed = false;
let mut written = false;
let mut json = String::new();
if let Some(val) = protected_b64 {
json.push_str("{\"protected\":\"");
json.push_str(&val);
json.push_str("\"");
writed = true;
written = true;
}

if let Some(val) = header {
let unprotected_map = val.claims_set(false);
if unprotected_map.len() > 0 {
let unprotected = serde_json::to_string(unprotected_map)?;
json.push_str(if writed { "," } else { "{" });
json.push_str(if written { "," } else { "{" });
json.push_str("\"unprotected\":");
json.push_str(&unprotected);
writed = true;
written = true;
}
}

if let Some(val) = recipient_header {
let header_map = val.claims_set();
if header_map.len() > 0 {
let header = serde_json::to_string(header_map)?;
json.push_str(if writed { "," } else { "{" });
json.push_str(if written { "," } else { "{" });
json.push_str("\"header\":");
json.push_str(&header);
}
Expand Down
4 changes: 2 additions & 2 deletions src/jwe/jwe_header_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl JweHeaderSet {
/// # Arguments
///
/// * `value` - a algorithm
/// * `protection` - If it dosen't need protection, set false.
/// * `protection` - If it doesn't need protection, set false.
pub fn set_algorithm(&mut self, value: impl Into<String>, protection: bool) {
let key = "alg";
let value: String = value.into();
Expand All @@ -53,7 +53,7 @@ impl JweHeaderSet {
/// # Arguments
///
/// * `value` - a content encryption
/// * `protection` - If it dosen't need protection, set false.
/// * `protection` - If it doesn't need protection, set false.
pub fn set_content_encryption(&mut self, value: impl Into<String>, protection: bool) {
let key = "enc";
let value: String = value.into();
Expand Down
4 changes: 2 additions & 2 deletions src/jwk/key_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::fmt::Debug;
use crate::jwk::Jwk;

pub trait KeyPair: Debug + Send + Sync {
/// Return the applicatable algorithm.
/// Return the applicable algorithm.
fn algorithm(&self) -> Option<&str>;

/// Return the applicatable key ID.
/// Return the applicable key ID.
fn key_id(&self) -> Option<&str>;

fn to_der_private_key(&self) -> Vec<u8>;
Expand Down
2 changes: 1 addition & 1 deletion src/jws/jws_algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Clone for Box<dyn JwsSigner> {
}

pub trait JwsVerifier: Debug + Send + Sync {
/// Return the source algrithm instance.
/// Return the source algorithm instance.
fn algorithm(&self) -> &dyn JwsAlgorithm;

/// Return the source key ID.
Expand Down
2 changes: 1 addition & 1 deletion src/jws/jws_header_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl JwsHeaderSet {
/// # Arguments
///
/// * `value` - a algorithm
/// * `protection` - If it dosen't need protection, set false.
/// * `protection` - If it doesn't need protection, set false.
pub fn set_algorithm(&mut self, value: impl Into<String>, protection: bool) {
let key = "alg";
let value: String = value.into();
Expand Down
6 changes: 3 additions & 3 deletions src/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{JoseError, JoseHeader};

static DEFAULT_CONTEXT: Lazy<JwtContext> = Lazy::new(|| JwtContext::new());

/// Return the string repsentation of the JWT with a "none" algorithm.
/// Return the string representation of the JWT with a "none" algorithm.
///
/// # Arguments
///
Expand All @@ -30,7 +30,7 @@ pub fn encode_unsecured(payload: &JwtPayload, header: &JwsHeader) -> Result<Stri
DEFAULT_CONTEXT.encode_unsecured(payload, header)
}

/// Return the string repsentation of the JWT with the siginig algorithm.
/// Return the string representation of the JWT with the siginig algorithm.
///
/// # Arguments
///
Expand All @@ -45,7 +45,7 @@ pub fn encode_with_signer(
DEFAULT_CONTEXT.encode_with_signer(payload, header, signer)
}

/// Return the string repsentation of the JWT with the encrypting algorithm.
/// Return the string representation of the JWT with the encrypting algorithm.
///
/// # Arguments
///
Expand Down
6 changes: 3 additions & 3 deletions src/jwt/jwt_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl JwtContext {
self.jwe_context.remove_acceptable_critical(name);
}

/// Return the string repsentation of the JWT with a "none" algorithm.
/// Return the string representation of the JWT with a "none" algorithm.
///
/// # Arguments
///
Expand All @@ -64,7 +64,7 @@ impl JwtContext {
self.encode_with_signer(payload, header, &jwt::None.signer())
}

/// Return the string repsentation of the JWT with the siginig algorithm.
/// Return the string representation of the JWT with the siginig algorithm.
///
/// # Arguments
///
Expand Down Expand Up @@ -96,7 +96,7 @@ impl JwtContext {
})
}

/// Return the string repsentation of the JWT with the encrypting algorithm.
/// Return the string representation of the JWT with the encrypting algorithm.
///
/// # Arguments
///
Expand Down

0 comments on commit a71084c

Please sign in to comment.