hOpenPGP-3.5: native Haskell implementation of OpenPGP (RFC9580)
Safe HaskellNone
LanguageHaskell2010

Codec.Encryption.OpenPGP.KeyGeneration

Synopsis

Legacy API (backward compatible)

Duration DSL

data Duration Source #

Instances

Instances details
Semigroup Duration Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Data Duration Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Duration -> c Duration Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Duration Source #

toConstr :: Duration -> Constr Source #

dataTypeOf :: Duration -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Duration) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Duration) Source #

gmapT :: (forall b. Data b => b -> b) -> Duration -> Duration Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Duration -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Duration -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Duration -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Duration -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Duration -> m Duration Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Duration -> m Duration Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Duration -> m Duration Source #

Generic Duration Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Associated Types

type Rep Duration 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

type Rep Duration = D1 ('MetaData "Duration" "Codec.Encryption.OpenPGP.KeyGeneration" "hOpenPGP-3.5-H4QBbxh6ZI1Fo0Apmu90CQ" 'True) (C1 ('MetaCons "Duration" 'PrefixI 'True) (S1 ('MetaSel ('Just "toThirtyTwoBitDuration") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ThirtyTwoBitDuration)))
Show Duration Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Eq Duration Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Ord Duration Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

type Rep Duration Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

type Rep Duration = D1 ('MetaData "Duration" "Codec.Encryption.OpenPGP.KeyGeneration" "hOpenPGP-3.5-H4QBbxh6ZI1Fo0Apmu90CQ" 'True) (C1 ('MetaCons "Duration" 'PrefixI 'True) (S1 ('MetaSel ('Just "toThirtyTwoBitDuration") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ThirtyTwoBitDuration)))

TK Generation DSL

data TKGen (m :: Type -> Type) (v :: TKKind) a Source #

Instances

Instances details
Monad m => Applicative (TKGen m v) Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Methods

pure :: a -> TKGen m v a Source #

(<*>) :: TKGen m v (a -> b) -> TKGen m v a -> TKGen m v b Source #

liftA2 :: (a -> b -> c) -> TKGen m v a -> TKGen m v b -> TKGen m v c Source #

(*>) :: TKGen m v a -> TKGen m v b -> TKGen m v b Source #

(<*) :: TKGen m v a -> TKGen m v b -> TKGen m v a Source #

Functor m => Functor (TKGen m v) Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Methods

fmap :: (a -> b) -> TKGen m v a -> TKGen m v b Source #

(<$) :: a -> TKGen m v b -> TKGen m v a Source #

Monad m => Monad (TKGen m v) Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Methods

(>>=) :: TKGen m v a -> (a -> TKGen m v b) -> TKGen m v b Source #

(>>) :: TKGen m v a -> TKGen m v b -> TKGen m v b Source #

return :: a -> TKGen m v a Source #

data TKGenState Source #

Instances

Instances details
Monoid TKGenState Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Semigroup TKGenState Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Data TKGenState Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TKGenState -> c TKGenState Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TKGenState Source #

toConstr :: TKGenState -> Constr Source #

dataTypeOf :: TKGenState -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TKGenState) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TKGenState) Source #

gmapT :: (forall b. Data b => b -> b) -> TKGenState -> TKGenState Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TKGenState -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TKGenState -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TKGenState -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TKGenState -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TKGenState -> m TKGenState Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TKGenState -> m TKGenState Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TKGenState -> m TKGenState Source #

Generic TKGenState Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Associated Types

type Rep TKGenState 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Show TKGenState Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Eq TKGenState Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Ord TKGenState Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

type Rep TKGenState Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

data SubkeySpec Source #

Instances

Instances details
Data SubkeySpec Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SubkeySpec -> c SubkeySpec Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SubkeySpec Source #

toConstr :: SubkeySpec -> Constr Source #

dataTypeOf :: SubkeySpec -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SubkeySpec) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SubkeySpec) Source #

gmapT :: (forall b. Data b => b -> b) -> SubkeySpec -> SubkeySpec Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SubkeySpec -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SubkeySpec -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> SubkeySpec -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SubkeySpec -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SubkeySpec -> m SubkeySpec Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SubkeySpec -> m SubkeySpec Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SubkeySpec -> m SubkeySpec Source #

Generic SubkeySpec Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Associated Types

type Rep SubkeySpec 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

type Rep SubkeySpec = D1 ('MetaData "SubkeySpec" "Codec.Encryption.OpenPGP.KeyGeneration" "hOpenPGP-3.5-H4QBbxh6ZI1Fo0Apmu90CQ" 'False) (C1 ('MetaCons "SubkeySpec" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_subkeyPayload") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SomePKPayload) :*: S1 ('MetaSel ('Just "_subkeySKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SKey)) :*: (S1 ('MetaSel ('Just "_subkeyUsage") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set KeyFlag)) :*: S1 ('MetaSel ('Just "_subkeyTimestamp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ThirtyTwoBitTimeStamp)))))
Show SubkeySpec Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Eq SubkeySpec Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Ord SubkeySpec Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

type Rep SubkeySpec Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

type Rep SubkeySpec = D1 ('MetaData "SubkeySpec" "Codec.Encryption.OpenPGP.KeyGeneration" "hOpenPGP-3.5-H4QBbxh6ZI1Fo0Apmu90CQ" 'False) (C1 ('MetaCons "SubkeySpec" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_subkeyPayload") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SomePKPayload) :*: S1 ('MetaSel ('Just "_subkeySKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SKey)) :*: (S1 ('MetaSel ('Just "_subkeyUsage") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set KeyFlag)) :*: S1 ('MetaSel ('Just "_subkeyTimestamp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ThirtyTwoBitTimeStamp)))))

data SignatureSpec Source #

Instances

Instances details
Data SignatureSpec Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SignatureSpec -> c SignatureSpec Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SignatureSpec Source #

toConstr :: SignatureSpec -> Constr Source #

dataTypeOf :: SignatureSpec -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SignatureSpec) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SignatureSpec) Source #

gmapT :: (forall b. Data b => b -> b) -> SignatureSpec -> SignatureSpec Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SignatureSpec -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SignatureSpec -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> SignatureSpec -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SignatureSpec -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SignatureSpec -> m SignatureSpec Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SignatureSpec -> m SignatureSpec Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SignatureSpec -> m SignatureSpec Source #

Generic SignatureSpec Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Associated Types

type Rep SignatureSpec 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

type Rep SignatureSpec = D1 ('MetaData "SignatureSpec" "Codec.Encryption.OpenPGP.KeyGeneration" "hOpenPGP-3.5-H4QBbxh6ZI1Fo0Apmu90CQ" 'False) (C1 ('MetaCons "SignatureSpec" 'PrefixI 'True) (S1 ('MetaSel ('Just "_sigSpecExpiration") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Duration)) :*: S1 ('MetaSel ('Just "_sigSpecKeyFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Set KeyFlag)))))
Show SignatureSpec Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Eq SignatureSpec Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

Ord SignatureSpec Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

type Rep SignatureSpec Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.KeyGeneration

type Rep SignatureSpec = D1 ('MetaData "SignatureSpec" "Codec.Encryption.OpenPGP.KeyGeneration" "hOpenPGP-3.5-H4QBbxh6ZI1Fo0Apmu90CQ" 'False) (C1 ('MetaCons "SignatureSpec" 'PrefixI 'True) (S1 ('MetaSel ('Just "_sigSpecExpiration") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Duration)) :*: S1 ('MetaSel ('Just "_sigSpecKeyFlags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Set KeyFlag)))))

newKey :: forall (m :: Type -> Type). MonadRandom m => PubKeyAlgorithm -> TKGen m 'SecretTK (SomePKPayload, SKey) Source #

Generate the primary key pair using the key version and timestamp from the Reader. Uses a default RSA key size of 4096 bits for RSA keys.

addUID :: forall (m :: Type -> Type). Monad m => Text -> TKGen m 'SecretTK () Source #

Append a user ID to the certificate.

addUIDWith :: forall (m :: Type -> Type). Monad m => Text -> SignatureSpec -> TKGen m 'SecretTK () Source #

Append a user ID with an explicit SignatureSpec override.

addSubkey :: forall (m :: Type -> Type). MonadRandom m => PubKeyAlgorithm -> [KeyFlag] -> TKGen m 'SecretTK (SomePKPayload, SKey) Source #

Generate a subkey (same key version as the primary) with the specified key flags. Uses a default RSA key size of 4096 bits for RSA keys.

setKeySize :: forall (m :: Type -> Type). Monad m => PubKeyAlgorithm -> Int -> TKGen m 'SecretTK () Source #

Set the key size for a variable-size algorithm (currently only RSA). Calling this for a fixed-size algorithm (Ed25519, X25519, Ed448, X448, etc.) will fail with InvalidConfiguration.

setExpiration :: forall (m :: Type -> Type). Monad m => Duration -> TKGen m 'SecretTK () Source #

Set a creation-time expiration for the whole certificate (relative to the primary key's creation time). Omit the call entirely for a non-expiring certificate.

setSEIPDv1SymmetricPreferences :: forall (m :: Type -> Type). Monad m => [SymmetricAlgorithm] -> TKGen m 'SecretTK () Source #

Attach symmetric algorithm preferences for SEIPDv1 that flow into every binding signature.

setHashPreferences :: forall (m :: Type -> Type). Monad m => [HashAlgorithm] -> TKGen m 'SecretTK () Source #

Attach hash algorithm preferences that flow into every binding signature.

setCompressionPreferences :: forall (m :: Type -> Type). Monad m => [CompressionAlgorithm] -> TKGen m 'SecretTK () Source #

Attach compression algorithm preferences that flow into every binding signature.

setAEADPreferences :: forall (m :: Type -> Type). Monad m => [(SymmetricAlgorithm, AEADAlgorithm)] -> TKGen m 'SecretTK () Source #

Attach AEAD ciphersuite preferences that flow into every binding signature.

setKeyServerPreferences :: forall (m :: Type -> Type). Monad m => Set KSPFlag -> TKGen m 'SecretTK () Source #

Attach key server preferences that flow into every binding signature.

setFeatures :: forall (m :: Type -> Type). Monad m => Set FeatureFlag -> TKGen m 'SecretTK () Source #

Attach feature flags that flow into every binding signature.

runTKGen :: MonadRandom m => (KeyVersion, ThirtyTwoBitTimeStamp) -> TKGen m 'SecretTK a -> m (Either TKGenError (a, TK 'SecretTK)) Source #

Run a key-generation action with the given key version and timestamp.

The base monad m must satisfy MonadRandom because key material and signature salts are drawn from it. No explicit seed is required; the caller is responsible for providing a suitable random source (e.g. IO).

runTKGenWithSeed :: ByteString -> (KeyVersion, ThirtyTwoBitTimeStamp) -> TKGen (MonadPseudoRandom ChaChaDRG) 'SecretTK a -> (Either TKGenError (a, TK 'SecretTK), ChaChaDRG) Source #

Run a key-generation action with a deterministic seed.

This is useful for testing, where reproducible key material is required. The seed is used to initialize a ChaChaDRG, and the final DRG state is returned alongside the result so that the random sequence can be continued if needed.

withKeyVersionAndTimestamp :: KeyVersion -> IO (KeyVersion, ThirtyTwoBitTimeStamp) Source #

Obtain the current creation time paired with a chosen KeyVersion.

Call this at the application boundary before runTKGen.