Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Crypto.Paseto.Keys
Description
PASETO cryptographic keys.
Synopsis
- data SymmetricKey v where
- symmetricKeyToBytes :: SymmetricKey v -> ScrubbedBytes
- bytesToSymmetricKeyV3 :: ScrubbedBytes -> Maybe (SymmetricKey V3)
- bytesToSymmetricKeyV4 :: ScrubbedBytes -> Maybe (SymmetricKey V4)
- generateSymmetricKeyV3 :: IO (SymmetricKey V3)
- generateSymmetricKeyV4 :: IO (SymmetricKey V4)
- data SigningKey v where
- SigningKeyV3 :: !PrivateKeyP384 -> SigningKey V3
- SigningKeyV4 :: !SecretKey -> SigningKey V4
- signingKeyToBytes :: SigningKey v -> ScrubbedBytes
- bytesToSigningKeyV3 :: ScrubbedBytes -> Either ScalarDecodingError (SigningKey V3)
- bytesToSigningKeyV4 :: ScrubbedBytes -> Maybe (SigningKey V4)
- generateSigningKeyV3 :: IO (SigningKey V3)
- generateSigningKeyV4 :: IO (SigningKey V4)
- data VerificationKey v where
- verificationKeyToBytes :: VerificationKey v -> ByteString
- bytesToVerificationKeyV3 :: ByteString -> Either PublicKeyP384DecodingError (VerificationKey V3)
- bytesToVerificationKeyV4 :: ByteString -> Maybe (VerificationKey V4)
- fromSigningKey :: SigningKey v -> VerificationKey v
Symmetric keys
data SymmetricKey v where Source #
Symmetric key.
Note that this type's Eq
instance performs a constant-time equality
check.
Constructors
SymmetricKeyV3 :: !ScrubbedBytes32 -> SymmetricKey V3 | Version 3 symmetric key. |
SymmetricKeyV4 :: !ScrubbedBytes32 -> SymmetricKey V4 | Version 4 symmetric key. |
Instances
Eq (SymmetricKey v) Source # | |
Defined in Crypto.Paseto.Keys Methods (==) :: SymmetricKey v -> SymmetricKey v -> Bool # (/=) :: SymmetricKey v -> SymmetricKey v -> Bool # |
symmetricKeyToBytes :: SymmetricKey v -> ScrubbedBytes Source #
Get the raw bytes associated with a symmetric key.
bytesToSymmetricKeyV3 :: ScrubbedBytes -> Maybe (SymmetricKey V3) Source #
Construct a version 3 symmetric key from bytes.
If the provided byte string does not have a length of 32
(256
bits),
Nothing
is returned.
bytesToSymmetricKeyV4 :: ScrubbedBytes -> Maybe (SymmetricKey V4) Source #
Construct a version 4 symmetric key from bytes.
If the provided byte string does not have a length of 32
(256
bits),
Nothing
is returned.
generateSymmetricKeyV3 :: IO (SymmetricKey V3) Source #
Randomly generate a version 3 symmetric key.
generateSymmetricKeyV4 :: IO (SymmetricKey V4) Source #
Randomly generate a version 4 symmetric key.
Asymmetric keys
Signing keys
data SigningKey v where Source #
Signing key (also known as a private/secret key).
Note that this type's Eq
instance performs a constant-time equality
check.
Constructors
SigningKeyV3 :: !PrivateKeyP384 -> SigningKey V3 | Version 3 signing key. |
SigningKeyV4 :: !SecretKey -> SigningKey V4 | Version 3 signing key. |
Instances
Eq (SigningKey v) Source # | |
Defined in Crypto.Paseto.Keys |
signingKeyToBytes :: SigningKey v -> ScrubbedBytes Source #
Get the raw bytes associated with a signing key.
bytesToSigningKeyV3 :: ScrubbedBytes -> Either ScalarDecodingError (SigningKey V3) Source #
Construct a version 3 signing key from bytes.
bytesToSigningKeyV4 :: ScrubbedBytes -> Maybe (SigningKey V4) Source #
Construct a version 4 signing key from bytes.
generateSigningKeyV3 :: IO (SigningKey V3) Source #
Randomly generate a version 3 signing key.
generateSigningKeyV4 :: IO (SigningKey V4) Source #
Randomly generate a version 4 signing key.
Verification keys
data VerificationKey v where Source #
Verification key (also known as a public key).
Constructors
VerificationKeyV3 :: !PublicKeyP384 -> VerificationKey V3 | Version 3 verification key. |
VerificationKeyV4 :: !PublicKey -> VerificationKey V4 | Version 4 verification key. |
Instances
Eq (VerificationKey v) Source # | |
Defined in Crypto.Paseto.Keys Methods (==) :: VerificationKey v -> VerificationKey v -> Bool # (/=) :: VerificationKey v -> VerificationKey v -> Bool # |
verificationKeyToBytes :: VerificationKey v -> ByteString Source #
Get the raw bytes associated with a verification key.
bytesToVerificationKeyV3 :: ByteString -> Either PublicKeyP384DecodingError (VerificationKey V3) Source #
Construct a version 3 verification key from bytes.
The input ByteString
is expected to be formatted as either a compressed
or uncompressed elliptic curve public key as defined by
SEC 1 and
RFC 5480 section 2.2.
bytesToVerificationKeyV4 :: ByteString -> Maybe (VerificationKey V4) Source #
Construct a version 4 verification key from bytes.
fromSigningKey :: SigningKey v -> VerificationKey v Source #
Get the VerificationKey
which corresponds to a given SigningKey
.