Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Implementation of PASETO version 3 (modern NIST cryptography).
Synopsis
- v3LocalTokenHeader :: ByteString
- data EncryptionError
- renderEncryptionError :: EncryptionError -> Text
- encrypt :: SymmetricKey V3 -> Claims -> Maybe Footer -> Maybe ImplicitAssertion -> ExceptT EncryptionError IO (Token V3 Local)
- encryptPure :: ByteString -> SymmetricKey V3 -> Claims -> Maybe Footer -> Maybe ImplicitAssertion -> Either EncryptionError (Token V3 Local)
- data DecryptionError
- = DecryptionInvalidFooterError !(Maybe Footer) !(Maybe Footer)
- | DecryptionInvalidHkdfNonceSizeError !Int
- | DecryptionInvalidHmacSizeError !Int
- | DecryptionInvalidHmacError !ByteString !ByteString
- | DecryptionCryptoError !CryptoError
- | DecryptionInvalidInitializationVectorSizeError !Int !Int
- | DecryptionClaimsDeserializationError !String
- renderDecryptionError :: DecryptionError -> Text
- decrypt :: SymmetricKey V3 -> Token V3 Local -> Maybe Footer -> Maybe ImplicitAssertion -> Either DecryptionError Claims
- v3PublicTokenHeader :: ByteString
- data SigningError = SigningKIsZeroError
- renderSigningError :: SigningError -> Text
- sign :: SigningKey V3 -> Claims -> Maybe Footer -> Maybe ImplicitAssertion -> ExceptT SigningError IO (Token V3 Public)
- signPure :: Integer -> SigningKey V3 -> Claims -> Maybe Footer -> Maybe ImplicitAssertion -> Either SigningError (Token V3 Public)
- data VerificationError
- renderVerificationError :: VerificationError -> Text
- verify :: VerificationKey V3 -> Token V3 Public -> Maybe Footer -> Maybe ImplicitAssertion -> Either VerificationError Claims
Local purpose
data EncryptionError Source #
PASETO version 3 encryption error.
EncryptionCryptoError !CryptoError |
|
EncryptionInvalidInitializationVectorSizeError | Initialization vector is of an invalid size. |
Instances
Show EncryptionError Source # | |
Defined in Crypto.Paseto.Protocol.V3 showsPrec :: Int -> EncryptionError -> ShowS # show :: EncryptionError -> String # showList :: [EncryptionError] -> ShowS # | |
Eq EncryptionError Source # | |
Defined in Crypto.Paseto.Protocol.V3 (==) :: EncryptionError -> EncryptionError -> Bool # (/=) :: EncryptionError -> EncryptionError -> Bool # |
renderEncryptionError :: EncryptionError -> Text Source #
Render an EncryptionError
as Text
.
:: SymmetricKey V3 | Symmetric key. |
-> Claims | Claims to be encrypted. |
-> Maybe Footer | Optional footer to authenticate and encode within the resulting token. |
-> Maybe ImplicitAssertion | Optional implicit assertion to authenticate. |
-> ExceptT EncryptionError IO (Token V3 Local) |
This is an authenticated encryption with associated data (AEAD)
algorithm which combines the AES-256-CTR
block cipher with the
HMAC-SHA384
message authentication code.
Note that this function essentially just calls encryptPure
with a random
32-byte nonce generated from the operating system's CSPRNG.
:: ByteString | Random 32-byte nonce. It is recommended to generate this from the operating system's CSPRNG. |
-> SymmetricKey V3 | Symmetric key. |
-> Claims | Claims to be encrypted. |
-> Maybe Footer | Optional footer to authenticate and encode within the resulting token. |
-> Maybe ImplicitAssertion | Optional implicit assertion to authenticate. |
-> Either EncryptionError (Token V3 Local) |
data DecryptionError Source #
PASETO version 3 decryption error.
DecryptionInvalidFooterError | Invalid token footer. |
DecryptionInvalidHkdfNonceSizeError !Int | Invalid |
DecryptionInvalidHmacSizeError !Int | Invalid |
DecryptionInvalidHmacError | Invalid |
| |
DecryptionCryptoError !CryptoError |
|
DecryptionInvalidInitializationVectorSizeError | Initialization vector is of an invalid size. |
DecryptionClaimsDeserializationError !String | Error deserializing a decrypted collection of claims as JSON. |
Instances
Show DecryptionError Source # | |
Defined in Crypto.Paseto.Protocol.V3 showsPrec :: Int -> DecryptionError -> ShowS # show :: DecryptionError -> String # showList :: [DecryptionError] -> ShowS # | |
Eq DecryptionError Source # | |
Defined in Crypto.Paseto.Protocol.V3 (==) :: DecryptionError -> DecryptionError -> Bool # (/=) :: DecryptionError -> DecryptionError -> Bool # |
renderDecryptionError :: DecryptionError -> Text Source #
Render a DecryptionError
as Text
.
:: SymmetricKey V3 | Symmetric key. |
-> Token V3 Local | Token to decrypt. |
-> Maybe Footer | Optional footer to authenticate. |
-> Maybe ImplicitAssertion | Optional implicit assertion to authenticate. |
-> Either DecryptionError Claims |
Public purpose
data SigningError Source #
PASETO version 3 cryptographic signing error.
SigningKIsZeroError | Random number, |
Instances
Show SigningError Source # | |
Defined in Crypto.Paseto.Protocol.V3 showsPrec :: Int -> SigningError -> ShowS # show :: SigningError -> String # showList :: [SigningError] -> ShowS # | |
Eq SigningError Source # | |
Defined in Crypto.Paseto.Protocol.V3 (==) :: SigningError -> SigningError -> Bool # (/=) :: SigningError -> SigningError -> Bool # |
renderSigningError :: SigningError -> Text Source #
Render a SigningError
as Text
.
:: SigningKey V3 | Signing key. |
-> Claims | Claims to be signed. |
-> Maybe Footer | Optional footer to authenticate and encode within the resulting token. |
-> Maybe ImplicitAssertion | Optional implicit assertion to authenticate. |
-> ExceptT SigningError IO (Token V3 Public) |
PASETO version 3 cryptographic signing.
This implementation produces a token which is signed using ECDSA
over
P-384
and SHA-384
.
Note that this function essentially just calls signPure
with a
randomly-generated scalar multiple, k
.
:: Integer | Explicit |
-> SigningKey V3 | Signing key. |
-> Claims | Claims to be signed. |
-> Maybe Footer | Optional footer to authenticate and encode within the resulting token. |
-> Maybe ImplicitAssertion | Optional implicit assertion to authenticate. |
-> Either SigningError (Token V3 Public) |
data VerificationError Source #
PASETO version 3 signature verification error.
VerificationInvalidFooterError | Invalid token footer. |
VerificationInvalidSignatureSizeError | Signature size is invalid. |
VerificationInvalidSignatureError | Signature verification failed. |
VerificationClaimsDeserializationError !String | Error deserializing a verified collection of claims as JSON. |
Instances
Show VerificationError Source # | |
Defined in Crypto.Paseto.Protocol.V3 showsPrec :: Int -> VerificationError -> ShowS # show :: VerificationError -> String # showList :: [VerificationError] -> ShowS # | |
Eq VerificationError Source # | |
Defined in Crypto.Paseto.Protocol.V3 (==) :: VerificationError -> VerificationError -> Bool # (/=) :: VerificationError -> VerificationError -> Bool # |
renderVerificationError :: VerificationError -> Text Source #
Render a VerificationError
as Text
.
:: VerificationKey V3 | Verification key. |
-> Token V3 Public | Token to verify. |
-> Maybe Footer | Optional footer to authenticate. |
-> Maybe ImplicitAssertion | Optional implicit assertion to authenticate. |
-> Either VerificationError Claims |