1
0
mirror of https://github.com/BitskiCo/jwk-rs synced 2024-12-29 12:08:50 +00:00

Bump version to include x5c fix

This commit is contained in:
Nick Hynes 2021-04-28 10:43:54 -05:00
parent 2cddce0696
commit 952a80199e
No known key found for this signature in database
GPG Key ID: 5B3463E9F1D73C83
3 changed files with 26 additions and 18 deletions

View File

@ -1,10 +1,11 @@
[package]
name = "jsonwebkey"
version = "0.3.1"
version = "0.3.2"
authors = ["Nick Hynes <nhynes@nhynes.com>"]
description = "JSON Web Key (JWK) (de)serialization, generation, and conversion."
readme = "README.md"
repository = "https://github.com/nhynes/jwk-rs"
documentation = "http://docs.rs/jsonwebkey/"
license = "MIT"
edition = "2018"

View File

@ -65,8 +65,7 @@ mod key_ops;
mod tests;
mod utils;
use std::borrow::Cow;
use std::fmt;
use std::{borrow::Cow, fmt};
use generic_array::typenum::U32;
use serde::{Deserialize, Serialize};
@ -193,6 +192,7 @@ impl std::fmt::Display for JsonWebKey {
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kty")]
#[allow(clippy::upper_case_acronyms)]
pub enum Key {
/// An elliptic curve, as per [RFC 7518 §6.2](https://tools.ietf.org/html/rfc7518#section-6.2).
EC {
@ -219,14 +219,17 @@ impl Key {
/// Returns true iff this key only contains private components (i.e. a private asymmetric
/// key or a symmetric key).
pub fn is_private(&self) -> bool {
matches!(self, Self::Symmetric { .. }
| Self::EC {
curve: Curve::P256 { d: Some(_), .. },
..
}
| Self::RSA {
private: Some(_), ..
}
matches!(
self,
Self::Symmetric { .. }
| Self::EC {
curve: Curve::P256 { d: Some(_), .. },
..
}
| Self::RSA {
private: Some(_),
..
}
)
}
@ -533,6 +536,7 @@ pub enum KeyUse {
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[allow(clippy::upper_case_acronyms)]
pub enum Algorithm {
HS256,
RS256,
@ -543,12 +547,12 @@ pub enum Algorithm {
const _IMPL_JWT_CONVERSIONS: () = {
use jsonwebtoken as jwt;
impl Into<jwt::Algorithm> for Algorithm {
fn into(self) -> jsonwebtoken::Algorithm {
match self {
Self::HS256 => jwt::Algorithm::HS256,
Self::ES256 => jwt::Algorithm::ES256,
Self::RS256 => jwt::Algorithm::RS256,
impl From<Algorithm> for jwt::Algorithm {
fn from(alg: Algorithm) -> Self {
match alg {
Algorithm::HS256 => Self::HS256,
Algorithm::ES256 => Self::ES256,
Algorithm::RS256 => Self::RS256,
}
}
}

View File

@ -437,7 +437,10 @@ fn x509_params() {
let jwk = JsonWebKey::from_str(X509_JWK_FIXTURE).unwrap();
assert_eq!(jwk.x5.url.unwrap(), "https://example.com/testing.crt");
assert_eq!(jwk.x5.cert_chain.unwrap(), "---BEGIN CERTIFICATE---...");
assert_eq!(
jwk.x5.cert_chain.unwrap(),
vec!["---BEGIN CERTIFICATE---..."]
);
assert_eq!(
jwk.x5.thumbprint.unwrap(),
"aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"