Skip to content

Commit

Permalink
Update deps and bump to 0.0.8 (#94)
Browse files Browse the repository at this point in the history
* Bump non-breaking crates

* Bump data-encoding

* Bump to 0.0.8
  • Loading branch information
lawliet89 authored Feb 14, 2018
1 parent 2c7452b commit 6e6c7d2
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 34 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## Version 0.0.8 (2018-02-14)

There are breaking changes in this release:

- `ring` was upgraded to 0.12. Until [#619](https://github.com/briansmith/ring/pull/619) lands,
this crate will now be incompatible with all other crates that uses a different version of `ring`.
- `jwa::rng` is no longer public
- [#84](https://github.com/lawliet89/biscuit/pull/84) All AES GCM encryption now requires a user
provided nonce. See [this example](https://lawliet89.github.io/biscuit/biscuit/type.JWE.html).
- `SignatureAlgorithm::verify` now returns `Result<(), Error>` instead of `Result<bool, Error>`.
- Bumped various dependencies, although they should not break any user facing code: `lazy_static`,
`data-encoding`.

Other non-breaking changes include:

- New helper
[function](https://lawliet89.github.io/biscuit/biscuit/jwk/struct.JWKSet.html#method.find) in `JWKSet` to find key by Key ID
- [New helper functions](https://github.com/lawliet89/biscuit/pull/88) in `jws::Compact` to retrieve
parts without signature verification.


## Version 0.0.7 (2017-07-19)

There are no breaking changes in this release.
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "biscuit"
version = "0.0.7"
version = "0.0.8"
authors = ["Yong Wen Chua <[email protected]>", "Vincent Prouillet <[email protected]>"]
license = "MIT"
readme = "README.md"
Expand All @@ -24,14 +24,14 @@ doc = true

[dependencies]
chrono = "0.4"
data-encoding = "1.2.0"
lazy_static = "0.2"
data-encoding = "2.1.1"
lazy_static = "1.0.0"
num = "0.1.37"
ring = { version = "0.12.1", features = ["rsa_signing"] }
serde = "1.0"
serde_derive = "1.0"
serde_json = { version = "1.0", features = ["preserve_order"] }
untrusted = "0.5"
untrusted = "0.5.1"
url = "^1.0"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This was based off [`Keats/rust-jwt`](https://github.com/Keats/rust-jwt).
Add the following to Cargo.toml:

```toml
biscuit = "0.0.7"
biscuit = "0.0.8"
```

To use the latest `master` branch, for example:
Expand Down
4 changes: 2 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub enum Error {
/// Error during the serialization or deserialization of tokens
JsonError(serde_json::error::Error),
/// Error during base64 encoding or decoding
DecodeBase64(data_encoding::decode::Error),
DecodeBase64(data_encoding::DecodeError),
/// Error when decoding bytes to UTF8 string
Utf8(str::Utf8Error),
/// Errors related to IO
Expand Down Expand Up @@ -80,7 +80,7 @@ macro_rules! impl_from_error {

impl_from_error!(String, Error::GenericError);
impl_from_error!(serde_json::error::Error, Error::JsonError);
impl_from_error!(data_encoding::decode::Error, Error::DecodeBase64);
impl_from_error!(data_encoding::DecodeError, Error::DecodeBase64);
impl_from_error!(str::Utf8Error, Error::Utf8);
impl_from_error!(ValidationError, Error::ValidationError);
impl_from_error!(io::Error, Error::IOError);
Expand Down
16 changes: 8 additions & 8 deletions src/jwa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ mod tests {
/// The base64 encoding from this command will be in `STANDARD` form and not URL_SAFE.
#[test]
fn verify_ps256() {
use data_encoding::base64;
use data_encoding::BASE64;

let payload = "payload".to_string();
let payload_bytes = payload.as_bytes();
Expand All @@ -821,7 +821,7 @@ mod tests {
tFNPZpz4/3pYQdxco/n6DpaR5206wsur/8H0FwoyiFKanhqLb1SgZqyc+SXRPepjKc28wzBnfWl4\
mmlZcJ2xk8O2/t1Y1/m/4G7drBwOItNl7EadbMVCetYnc9EILv39hjcL9JvaA9q0M2RB75DIu8SF\
9Kr/l+wzUJjWAHthgqSBpe15jLkpO8tvqR89fw==";
let signature_bytes: Vec<u8> = not_err!(base64::decode(signature.as_bytes()));
let signature_bytes: Vec<u8> = not_err!(BASE64.decode(signature.as_bytes()));
let public_key = Secret::public_key_from_file("test/fixtures/rsa_public_key.der").unwrap();
not_err!(SignatureAlgorithm::PS256.verify(signature_bytes.as_slice(), payload_bytes, &public_key,));
}
Expand All @@ -841,32 +841,32 @@ mod tests {
/// Test case from https://github.com/briansmith/ring/blob/a13b8e2/src/ec/suite_b/ecdsa_verify_fixed_tests.txt
#[test]
fn verify_es256() {
use data_encoding::hex;
use data_encoding::HEXUPPER;

let payload_bytes = Vec::<u8>::new();
let public_key = "0430345FD47EA21A11129BE651B0884BFAC698377611ACC9F689458E13B9ED7D4B9D7599\
A68DCF125E7F31055CCB374CD04F6D6FD2B217438A63F6F667D50EF2F0";
let public_key = Secret::PublicKey(not_err!(hex::decode(public_key.as_bytes())));
let public_key = Secret::PublicKey(not_err!(HEXUPPER.decode(public_key.as_bytes())));
let signature = "341F6779B75E98BB42E01095DD48356CBF9002DC704AC8BD2A8240B88D3796C6555843B1B\
4E264FE6FFE6E2B705A376C05C09404303FFE5D2711F3E3B3A010A1";
let signature_bytes: Vec<u8> = not_err!(hex::decode(signature.as_bytes()));
let signature_bytes: Vec<u8> = not_err!(HEXUPPER.decode(signature.as_bytes()));
not_err!(SignatureAlgorithm::ES256.verify(signature_bytes.as_slice(), &payload_bytes, &public_key,));
}

/// Test case from https://github.com/briansmith/ring/blob/a13b8e2/src/ec/suite_b/ecdsa_verify_fixed_tests.txt
#[test]
fn verify_es384() {
use data_encoding::hex;
use data_encoding::HEXUPPER;

let payload_bytes = Vec::<u8>::new();
let public_key = "045C5E788A805C77D34128B8401CB59B2373B8B468336C9318252BF39FD31D2507557987\
A5180A9435F9FB8EB971C426F1C485170DCB18FB688A257F89387A09FC4C5B8BD4B320616\
B54A0A7B1D1D7C6A0C59F6DFF78C78AD4E3D6FCA9C9A17B96";
let public_key = Secret::PublicKey(not_err!(hex::decode(public_key.as_bytes())));
let public_key = Secret::PublicKey(not_err!(HEXUPPER.decode(public_key.as_bytes())));
let signature = "85AC708D4B0126BAC1F5EEEBDF911409070A286FDDE5649582611B60046DE353761660DD0\
3903F58B44148F25142EEF8183475EC1F1392F3D6838ABC0C01724709C446888BED7F2CE4\
642C6839DC18044A2A6AB9DDC960BFAC79F6988E62D452";
let signature_bytes: Vec<u8> = not_err!(hex::decode(signature.as_bytes()));
let signature_bytes: Vec<u8> = not_err!(HEXUPPER.decode(signature.as_bytes()));
not_err!(SignatureAlgorithm::ES384.verify(signature_bytes.as_slice(), &payload_bytes, &public_key,));
}

Expand Down
4 changes: 2 additions & 2 deletions src/jws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ mod tests {

#[test]
fn compact_jws_verify_es256() {
use data_encoding::hex;
use data_encoding::HEXUPPER;

// This is a ECDSA Public key in `SubjectPublicKey` form.
// Conversion is not available in `ring` yet.
Expand All @@ -696,7 +696,7 @@ mod tests {
eyJ0b2tlbl90eXBlIjoic2VydmljZSIsImlhdCI6MTQ5MjkzODU4OH0.\
do_XppIOFthPWlTXL95CIBfgRdyAxbcIsUfM0YxMjCjqvp4ehHFA3I-JasABKzC8CAy4ndhCHsZdpAtK\
kqZMEA";
let signing_secret = Secret::PublicKey(not_err!(hex::decode(public_key.as_bytes())));
let signing_secret = Secret::PublicKey(not_err!(HEXUPPER.decode(public_key.as_bytes())));

let token = Compact::<ClaimsSet<serde_json::Value>, ::Empty>::new_encoded(jwt);
let _ = not_err!(token.into_decoded(&signing_secret, SignatureAlgorithm::ES256));
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! Add the following to Cargo.toml:
//!
//! ```toml
//! biscuit = "0.0.7"
//! biscuit = "0.0.8"
//! ```
//!
//! To use the latest `master` branch, for example:
Expand Down Expand Up @@ -84,7 +84,7 @@ use std::ops::Deref;
use std::str::{self, FromStr};

use chrono::{DateTime, NaiveDateTime, Utc};
use data_encoding::base64url;
use data_encoding::BASE64URL_NOPAD;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::de::{self, DeserializeOwned};

Expand Down Expand Up @@ -361,14 +361,14 @@ pub trait CompactPart {
where
Self: Sized,
{
let decoded = base64url::decode_nopad(encoded.as_ref())?;
let decoded = BASE64URL_NOPAD.decode(encoded.as_ref())?;
Self::from_bytes(&decoded)
}

/// Serialize `Self` to some form and then base64URL Encode
fn to_base64(&self) -> Result<Base64Url, Error> {
let bytes = self.to_bytes()?;
Ok(Base64Url(base64url::encode_nopad(bytes.as_ref())))
Ok(Base64Url(BASE64URL_NOPAD.encode(bytes.as_ref())))
}
}

Expand Down Expand Up @@ -444,7 +444,7 @@ impl Borrow<str> for Base64Url {

impl CompactPart for Base64Url {
fn to_bytes(&self) -> Result<Vec<u8>, Error> {
Ok(base64url::decode_nopad(self.as_ref())?)
Ok(BASE64URL_NOPAD.decode(self.as_ref())?)
}

/// Convert a sequence of bytes into Self
Expand Down
6 changes: 3 additions & 3 deletions src/serde_custom/base64_url_uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! The integers are first converted into bytes in big-endian form and then base64 encoded.
use std::fmt;

use data_encoding::base64url;
use data_encoding::BASE64URL_NOPAD;
use num::BigUint;
use serde::{Deserializer, Serializer};
use serde::de;
Expand All @@ -14,7 +14,7 @@ where
S: Serializer,
{
let bytes = value.to_bytes_be();
let base64 = base64url::encode_nopad(bytes.as_slice());
let base64 = BASE64URL_NOPAD.encode(bytes.as_slice());
serializer.serialize_str(&base64)
}

Expand All @@ -36,7 +36,7 @@ where
where
E: de::Error,
{
let bytes = base64url::decode_nopad(value.as_bytes()).map_err(E::custom)?;
let bytes = BASE64URL_NOPAD.decode(value.as_bytes()).map_err(E::custom)?;
Ok(BigUint::from_bytes_be(&bytes))
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/serde_custom/byte_sequence.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Serialize a sequence of bytes as base64 URL encoding vice-versa for deserialization
use std::fmt;

use data_encoding::base64url;
use data_encoding::BASE64URL_NOPAD;
use serde::{Deserializer, Serializer};
use serde::de;

Expand All @@ -10,7 +10,7 @@ pub fn serialize<S>(value: &[u8], serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let base64 = base64url::encode_nopad(value);
let base64 = BASE64URL_NOPAD.encode(value);
serializer.serialize_str(&base64)
}

Expand All @@ -32,7 +32,7 @@ where
where
E: de::Error,
{
let bytes = base64url::decode_nopad(value.as_bytes()).map_err(E::custom)?;
let bytes = BASE64URL_NOPAD.decode(value.as_bytes()).map_err(E::custom)?;
Ok(bytes)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/serde_custom/option_base64_url_uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! The integers are first converted into bytes in big-endian form and then base64 encoded.
use std::fmt;

use data_encoding::base64url;
use data_encoding::BASE64URL_NOPAD;
use num::BigUint;
use serde::{Deserializer, Serializer};
use serde::de;
Expand All @@ -16,7 +16,7 @@ where
match *value {
Some(ref value) => {
let bytes = value.to_bytes_be();
let base64 = base64url::encode_nopad(bytes.as_slice());
let base64 = BASE64URL_NOPAD.encode(bytes.as_slice());
serializer.serialize_some(&base64)
}
None => serializer.serialize_none(),
Expand Down Expand Up @@ -55,7 +55,7 @@ where
where
E: de::Error,
{
let bytes = base64url::decode_nopad(value.as_bytes()).map_err(E::custom)?;
let bytes = BASE64URL_NOPAD.decode(value.as_bytes()).map_err(E::custom)?;
Ok(Some(BigUint::from_bytes_be(&bytes)))
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/serde_custom/option_byte_sequence.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Serialize or deserialize an `Option<Vec<u8>>`
use std::fmt;

use data_encoding::base64url;
use data_encoding::BASE64URL_NOPAD;
use serde::{Deserializer, Serializer};
use serde::de;

Expand All @@ -12,7 +12,7 @@ where
{
match *value {
Some(ref value) => {
let base64 = base64url::encode_nopad(value.as_slice());
let base64 = BASE64URL_NOPAD.encode(value.as_slice());
serializer.serialize_some(&base64)
}
None => serializer.serialize_none(),
Expand Down Expand Up @@ -51,7 +51,7 @@ where
where
E: de::Error,
{
let bytes = base64url::decode_nopad(value.as_bytes()).map_err(E::custom)?;
let bytes = BASE64URL_NOPAD.decode(value.as_bytes()).map_err(E::custom)?;
Ok(Some(bytes))
}
}
Expand Down

0 comments on commit 6e6c7d2

Please sign in to comment.