Safe Haskell | None |
---|---|
Language | Haskell98 |
A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. This module also defines a JSON Web Key Set (JWK Set) JSON data structure for representing a set of JWKs.
- data JWK = JWK KeyMaterial (Maybe KeyUse) (Maybe [KeyOp]) (Maybe JWKAlg) (Maybe String) (Maybe URI) (Maybe (NonEmpty Base64X509)) (Maybe Base64SHA1) (Maybe Base64SHA256)
- jwkMaterial :: Lens' JWK KeyMaterial
- jwkUse :: Lens' JWK (Maybe KeyUse)
- data KeyUse
- jwkKeyOps :: Lens' JWK (Maybe [KeyOp])
- jwkAlg :: Lens' JWK (Maybe JWKAlg)
- jwkKid :: Lens' JWK (Maybe String)
- jwkX5u :: Lens' JWK (Maybe URI)
- jwkX5c :: Lens' JWK (Maybe (NonEmpty Base64X509))
- jwkX5t :: Lens' JWK (Maybe Base64SHA1)
- jwkX5tS256 :: Lens' JWK (Maybe Base64SHA256)
- fromKeyMaterial :: KeyMaterial -> JWK
- genJWK :: MonadRandom m => KeyMaterialGenParam -> m JWK
- fromRSA :: PrivateKey -> JWK
- data JWKAlg
- newtype JWKSet = JWKSet [JWK]
- bestJWSAlg :: (MonadError e m, AsError e) => JWK -> m Alg
- class AsPublicKey k where
- data EC = EC
- data RSA = RSA
- data Oct = Oct
- data Crv
- data ECKeyParameters = ECKeyParameters {
- ecKty :: EC
- ecCrv :: Crv
- ecX :: SizedBase64Integer
- ecY :: SizedBase64Integer
- ecD :: Maybe SizedBase64Integer
- data RSAPrivateKeyOthElem = RSAPrivateKeyOthElem {}
- data RSAPrivateKeyOptionalParameters = RSAPrivateKeyOptionalParameters {}
- data RSAPrivateKeyParameters = RSAPrivateKeyParameters {}
- data RSAKeyParameters = RSAKeyParameters RSA SizedBase64Integer Base64Integer (Maybe RSAPrivateKeyParameters)
- toRSAKeyParameters :: PrivateKey -> RSAKeyParameters
- rsaE :: Lens' RSAKeyParameters Base64Integer
- rsaKty :: Lens' RSAKeyParameters RSA
- rsaN :: Lens' RSAKeyParameters SizedBase64Integer
- rsaPrivateKeyParameters :: Lens' RSAKeyParameters (Maybe RSAPrivateKeyParameters)
- rsaPublicKey :: RSAKeyParameters -> PublicKey
- genRSA :: MonadRandom m => Int -> m RSAKeyParameters
- data OctKeyParameters = OctKeyParameters {
- octKty :: Oct
- octK :: Base64Octets
- data KeyMaterialGenParam
- data KeyMaterial
- genKeyMaterial :: MonadRandom m => KeyMaterialGenParam -> m KeyMaterial
- sign :: (MonadRandom m, MonadError e m, AsError e) => Alg -> KeyMaterial -> ByteString -> m ByteString
- verify :: Alg -> KeyMaterial -> ByteString -> ByteString -> Either Error Bool
- module Crypto.Random
Documentation
JWK §3. JSON Web Key (JWK) Format
JWK KeyMaterial (Maybe KeyUse) (Maybe [KeyOp]) (Maybe JWKAlg) (Maybe String) (Maybe URI) (Maybe (NonEmpty Base64X509)) (Maybe Base64SHA1) (Maybe Base64SHA256) |
JWK §3.2. "use" (Public Key Use) Parameter
jwkX5tS256 :: Lens' JWK (Maybe Base64SHA256) Source #
fromKeyMaterial :: KeyMaterial -> JWK Source #
genJWK :: MonadRandom m => KeyMaterialGenParam -> m JWK Source #
fromRSA :: PrivateKey -> JWK Source #
Convert RSA private key into a JWK
RFC 7517 §4.4. "alg" (Algorithm) Parameter
See also RFC 7518 §6.4. which states that for "oct" keys, an "alg" member SHOULD be present to identify the algorithm intended to be used with the key, unless the application uses another means or convention to determine the algorithm used.
JWK §4. JSON Web Key Set (JWK Set) Format
bestJWSAlg :: (MonadError e m, AsError e) => JWK -> m Alg Source #
Choose the cryptographically strongest JWS algorithm for a given key. The JWK "alg" algorithm parameter is ignored.
Type classes
class AsPublicKey k where Source #
asPublicKey :: Prism' k k Source #
"kty" (Key Type) Parameter Values
Elliptic Curve key type (Recommeded+)
RSA key type (Required)
Octet sequence (symmetric key) key type (Required)
Parameters for Elliptic Curve Keys
"crv" (Curve) Parameter
data ECKeyParameters Source #
Parameters for Elliptic Curve Keys
ECKeyParameters | |
|
Parameters for RSA Keys
data RSAPrivateKeyOthElem Source #
"oth" (Other Primes Info) Parameter
data RSAPrivateKeyOptionalParameters Source #
Optional parameters for RSA private keys
data RSAKeyParameters Source #
Parameters for RSA Keys
genRSA :: MonadRandom m => Int -> m RSAKeyParameters Source #
Parameters for Symmetric Keys
data OctKeyParameters Source #
Symmetric key parameters data.
Key generation
data KeyMaterialGenParam Source #
Keygen parameters.
ECGenParam Crv | Generate an EC key with specified curve. |
RSAGenParam Int | Generate an RSA key with specified size in bytes. |
OctGenParam Int | Generate a symmetric key with specified size in bytes. |
data KeyMaterial Source #
Key material sum type.
genKeyMaterial :: MonadRandom m => KeyMaterialGenParam -> m KeyMaterial Source #
Signing and verification
sign :: (MonadRandom m, MonadError e m, AsError e) => Alg -> KeyMaterial -> ByteString -> m ByteString Source #
verify :: Alg -> KeyMaterial -> ByteString -> ByteString -> Either Error Bool Source #
module Crypto.Random