paseto - Paseto.Core 0.7.2

A Paseto (Platform-Agnostic Security Tokens) implementation for .NET

PM> Install-Package Paseto.Core -Version 0.7.2 -Source https://www.myget.org/F/paseto/api/v3/index.json

Copy to clipboard

> nuget.exe install Paseto.Core -Version 0.7.2 -Source https://www.myget.org/F/paseto/api/v3/index.json

Copy to clipboard

> dotnet add package Paseto.Core --version 0.7.2 --source https://www.myget.org/F/paseto/api/v3/index.json

Copy to clipboard
<PackageReference Include="Paseto.Core" Version="0.7.2" />
Copy to clipboard
source https://www.myget.org/F/paseto/api/v3/index.json

nuget Paseto.Core  ~> 0.7.2
Copy to clipboard

> choco install Paseto.Core --version 0.7.2 --source https://www.myget.org/F/paseto/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "paseto" -SourceLocation "https://www.myget.org/F/paseto/api/v2"
Install-Module -Name "Paseto.Core" -RequiredVersion "0.7.2" -Repository "paseto" 
Copy to clipboard

Browse the sources in this package using Visual Studio or WinDbg by configuring the following legacy symbol server URL: https://www.myget.org/F/paseto/symbols/


Paseto.NET, a Paseto (Platform-Agnostic Security Tokens) implementation for .NET

CI Maintenance contributions welcome

Features

PASETO protocols

purpose v1 v2 v3 v4
local
public

PASERK extension

type support
lid
local
seal
local-wrap
local-pw
sid
public
pid
secret
secret-wrap
secret-pw

Installation

NuGet

Install the Paseto.Core NuGet package from the .NET CLI using:

dotnet add package Paseto.Core

or from the NuGet package manager:

Install-Package Paseto.Core

Usage

PASETO

The library exposes a Fluent API with several method overloads found in Use(), WithKey(), AddClaim(), AddFooter() and so on to provide the flexibility needed for encoding and decoding PASETO tokens and also for generating the required symmetric or asymmetric key pairs. However, you can use the Protocols and Handlers directly if you like.

Below are a couple of examples for the most common use cases:

Generating a Symmetric Key

var pasetoKey = new PasetoBuilder().Use(version, Purpose.Local)
                                   .GenerateSymmetricKey();

Generating an Asymmetric Key Pair

var pasetoKey = new PasetoBuilder().Use(version, Purpose.Public)
                                   .GenerateAsymmetricKeyPair(seed);

NOTE: A seed is not required for protocol v1.

Generating a Token

var token = new PasetoBuilder().Use(version, purpose)
                               .WithKey(key)
                               .AddClaim("data", "this is a secret message")
                               .Issuer("https://github.com/daviddesmet/paseto-dotnet")
                               .Subject(Guid.NewGuid().ToString())
                               .Audience("https://paseto.io")
                               .NotBefore(DateTime.UtcNow.AddMinutes(5))
                               .IssuedAt(DateTime.UtcNow)
                               .Expiration(DateTime.UtcNow.AddHours(1))
                               .TokenIdentifier("123456ABCD")
                               .AddFooter("arbitrary-string-that-isn't-json")
                               .Encode();

Decoding a Token

var result = new PasetoBuilder().Use(version, purpose)
                                .WithKey(key)
                                .Decode(token);

Or validate the token's payload while decoding (the header and signature is always validated):

var valParams = new PasetoTokenValidationParameters
{
    ValidateLifetime = true,
    ValidateAudience = true,
    ValidateIssuer = true,
    ValidAudience = "https://paseto.io",
    ValidIssuer = "https://github.com/daviddesmet/paseto-dotnet"
};

var result = new PasetoBuilder().Use(version, purpose)
                                .WithKey(key)
                                .Decode(token, valParams);

PASERK

The library also provides the PASERK extension for encoding and decoding a key.

A serialized key in PASERK has the format:

k[version].[type].[data]

Encoding a Key

var paserk = Paserk.Encode(pasetoKey, type);

Decoding a Key

var key = Paserk.Decode(paserk);

Roadmap

  • Add support for remaining PASERK types and its operations.
  • Add support for version detection when decoding.
  • Add support for custom payload validation rules.
  • Improve documentation.
  • Remove dependency on JSON.NET.

Test Coverage

codecov

  • Includes the mandatory test vectors for PASETO and PASERK.

Cryptography

  • Uses Ed25519 (EdDSA over Curve25519) algorithm from CodesInChaos Chaos.NaCl cryptography library.
  • Uses Blake2b cryptographic hash function from Konscious.Security.Cryptography repository.
  • Uses AES-256-CTR, ECDSA over P-384 algorithms from Bouncy Castle cryptography library.
  • Uses XChaCha20-Poly1305 AEAD from NaCl.Core repository.

Learn More

License

  • .NETFramework 4.6
    • NaCl.Core (>= 1.2.0)
    • Newtonsoft.Json (>= 10.0.3)
    • Paseto.Cryptography (>= 0.7.2)
    • System.ValueTuple (>= 4.5.0)
  • .NETFramework 4.7
    • NaCl.Core (>= 1.2.0)
    • Newtonsoft.Json (>= 10.0.3)
    • Paseto.Cryptography (>= 0.7.2)
  • .NETStandard 2.0
    • NaCl.Core (>= 1.2.0)
    • Newtonsoft.Json (>= 10.0.3)
    • Paseto.Cryptography (>= 0.7.2)
  • .NETFramework 4.6: 4.6.0.0
  • .NETFramework 4.7: 4.7.0.0
  • .NETStandard 2.0: 2.0.0.0

                        
Assembly Assembly hash Match
/lib/net47/paseto.dll 0ba49ee856444f778e5e6b3f5257f115FFFFFFFF
/lib/net46/paseto.dll 79e375cb8fad4aceb23fe7ad897be5d1f
/lib/netstandard2.0/paseto.dll ddab728384e445a68cdf5d3f038c3618FFFFFFFF
/lib/net46/paseto.dll 79e375cb8fad4aceb23fe7ad897be5df1

Owners

daviddesmet

Authors

David De Smet

Project URL

https://github.com/idaviddesmet/paseto-dotnet

License

MIT

Tags

paseto dotnet dotnet-core netstandard

Info

34 total downloads
6 downloads for version 0.7.2
Download (40.16 KB)
Download legacy symbols (85.23 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
0.7.2 40.16 KB Tue, 09 Jul 2019 15:16:54 GMT 6
0.7.1 27.41 KB Tue, 05 Feb 2019 04:17:31 GMT 1
0.7.0 27.43 KB Tue, 27 Nov 2018 06:27:57 GMT 2
0.6.1-CI00000 24.86 KB Fri, 06 Apr 2018 04:37:32 GMT 3
0.6.0-CI00001 24.62 KB Fri, 30 Mar 2018 22:41:27 GMT 3
0.6.0-CI00000 24.19 KB Fri, 30 Mar 2018 10:26:45 GMT 1
0.5.5-CI00000 24.18 KB Tue, 20 Mar 2018 17:42:50 GMT 1
0.5.4-CI00001 24.06 KB Mon, 19 Mar 2018 22:29:56 GMT 1
0.5.3-CI00000 12.36 KB Fri, 16 Mar 2018 17:37:10 GMT 2
0.5.2-CI00001 11.99 KB Fri, 16 Mar 2018 16:50:27 GMT 2
0.5.1-CI00000 11.98 KB Fri, 16 Mar 2018 00:19:21 GMT 3
0.5.0-CI00007 11.98 KB Fri, 16 Mar 2018 00:13:48 GMT 1
0.5.0-CI00006 11.95 KB Thu, 15 Mar 2018 23:39:11 GMT 1
0.5.0-CI00005 11.95 KB Thu, 15 Mar 2018 23:32:48 GMT 1
0.5.0-CI00004 11.95 KB Thu, 15 Mar 2018 20:20:59 GMT 2
0.5.0-CI00003 11.95 KB Thu, 15 Mar 2018 19:43:36 GMT 2
0.5.0-CI00002 11.96 KB Thu, 15 Mar 2018 19:30:46 GMT 1
0.5.0-CI00001 11.95 KB Thu, 15 Mar 2018 19:19:22 GMT 1