rusty_paserk

An extension of rusty_paseto adding the Platform Agnostic Serializable Keys specifications on top.

Examples

Local Wrapping

```rust use rustypaserk::wrap::{Pie, LocalWrapperExt}; use rustypaseto::core::{PasetoSymmetricKey, V4, Local, Key};

let wrappingkey = PasetoSymmetricKey::::from(Key::trynew_random().unwrap());

let localkey = PasetoSymmetricKey::from(Key::trynewrandom().unwrap()); let nonce = Key::trynewrandom().unwrap(); let wrappedlocal = Pie::wraplocal(&localkey, &wrappingkey, &nonce); // => "k4.local-wrap.pie.RcAvOxHI0H-0uMsIl6KGcplHtDlOhW1omFwXltZCiynHeRNH0hmn28AkN516h3WHuAReH3CvQ2SZ6mevnTquPETSd3XnlcbRWACT5GLWcus3BsD4IFWm9wFZgNF7C_E"

let mut wrappedlocal = wrappedlocal.intobytes(); let localkey2 = Pie::unwraplocal(&mut wrappedlocal, &wrappingkey).unwrap(); asserteq!(localkey.asref(), localkey2.asref()); ```

Secret Wrapping

```rust use rustypaserk::wrap::{Pie, SecretWrapperExt}; use rustypaseto::core::{PasetoSymmetricKey, PasetoAsymmetricPrivateKey, V4, Key};

let wrappingkey = PasetoSymmetricKey::from(Key::trynew_random().unwrap());

let secretkey = Key::trynewrandom().unwrap(); let secretkey = PasetoAsymmetricPrivateKey::from(&secretkey); let nonce = Key::trynewrandom().unwrap(); let wrappedsecret = Pie::wrapsecret(&secretkey, &wrappingkey, &nonce); // => "k4.secret-wrap.pie.cTTnZwzBA3AKBugQCzmctv5R9CjyPOlelG9SLZrhupDwk6vYx-3UQFCZ7x4d57KU4K4U1qJeFP6ELzkMJ0s8qHt0hsQkW14Ni6TJ89MRzEqglUgI6hJD-EF2E9kIFO5YuC5MHwXN7WivG1S3L-OoTjZgTZJ_8T7SJhvYLodo"

let mut wrappedsecret = wrappedsecret.intobytes(); let secretkey2 = Pie::unwrapsecret(&mut wrappedsecret, &wrappingkey).unwrap(); asserteq!(secretkey.asref(), secretkey2.asref()); ```

Local IDs

```rust use rustypaserk::id::EncodeId; use rustypaseto::core::{PasetoSymmetricKey, V4, Local, Key};

let localkey = PasetoSymmetricKey::::from(Key::trynewrandom().unwrap()); let kid = localkey.encode_id(); // => "k4.lid.XxPub51WIAEmbVTmrs-lFoFodxTSKk8RuYEJk3gl-DYB" ```

Secret IDs

```rust use rustypaserk::id::EncodeId; use rustypaseto::core::{PasetoAsymmetricPrivateKey, V4, Public, Key};

let secretkey = Key::trynewrandom().unwrap(); let secretkey = PasetoAsymmetricPrivateKey::::from(&secretkey); let kid = secretkey.encode_id(); // => "k4.sid.p26RNihDPsk2QbglGMTmwMMqLYyeLY25UOQZXQDXwn61" ```

Public IDs

```rust use rustypaserk::id::EncodeId; use rustypaseto::core::{PasetoAsymmetricPublicKey, V4, Public, Key};

let publickey = Key::trynewrandom().unwrap(); let publickey = PasetoAsymmetricPublicKey::::from(&publickey); let kid = publickey.encodeid(); // => "k4.pid.yMgldRRLHBLkhmcp8NG8yZrtyldbYoAjQWPvMa1rzRu" ```