| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Codec.Encryption.OpenPGP.KeyGeneration
Synopsis
- data KeyGenSpec (v :: KeyVersion) where
- KeyGenRSA :: forall (v :: KeyVersion). RSAKeyVersion v => ThirtyTwoBitTimeStamp -> Int -> KeyGenSpec v
- KeyGenEd25519 :: ThirtyTwoBitTimeStamp -> KeyGenSpec 'V6
- KeyGenEd448 :: ThirtyTwoBitTimeStamp -> KeyGenSpec 'V6
- KeyGenX25519 :: ThirtyTwoBitTimeStamp -> KeyGenSpec 'V6
- KeyGenX448 :: ThirtyTwoBitTimeStamp -> KeyGenSpec 'V6
- generateSecretKey :: forall (v :: KeyVersion) (m :: Type -> Type). MonadRandom m => KeyGenSpec v -> ExceptT String m (SomePKPayload, SKey)
- data Duration
- seconds :: Word32 -> Duration
- minutes :: Word32 -> Duration
- hours :: Word32 -> Duration
- days :: Word32 -> Duration
- weeks :: Word32 -> Duration
- years :: Word32 -> Duration
- data TKGen (m :: Type -> Type) (v :: TKKind) a
- data TKGenState
- data SubkeySpec
- data SignatureSpec
- data TKGenError
- newKey :: forall (m :: Type -> Type). MonadRandom m => PubKeyAlgorithm -> TKGen m 'SecretTK (SomePKPayload, SKey)
- addUID :: forall (m :: Type -> Type). Monad m => Text -> TKGen m 'SecretTK ()
- addUIDWith :: forall (m :: Type -> Type). Monad m => Text -> SignatureSpec -> TKGen m 'SecretTK ()
- addSubkey :: forall (m :: Type -> Type). MonadRandom m => PubKeyAlgorithm -> [KeyFlag] -> TKGen m 'SecretTK (SomePKPayload, SKey)
- setKeySize :: forall (m :: Type -> Type). Monad m => PubKeyAlgorithm -> Int -> TKGen m 'SecretTK ()
- setExpiration :: forall (m :: Type -> Type). Monad m => Duration -> TKGen m 'SecretTK ()
- setSEIPDv1SymmetricPreferences :: forall (m :: Type -> Type). Monad m => [SymmetricAlgorithm] -> TKGen m 'SecretTK ()
- setHashPreferences :: forall (m :: Type -> Type). Monad m => [HashAlgorithm] -> TKGen m 'SecretTK ()
- setCompressionPreferences :: forall (m :: Type -> Type). Monad m => [CompressionAlgorithm] -> TKGen m 'SecretTK ()
- setAEADPreferences :: forall (m :: Type -> Type). Monad m => [(SymmetricAlgorithm, AEADAlgorithm)] -> TKGen m 'SecretTK ()
- setKeyServerPreferences :: forall (m :: Type -> Type). Monad m => Set KSPFlag -> TKGen m 'SecretTK ()
- setFeatures :: forall (m :: Type -> Type). Monad m => Set FeatureFlag -> TKGen m 'SecretTK ()
- runTKGen :: MonadRandom m => (KeyVersion, ThirtyTwoBitTimeStamp) -> TKGen m 'SecretTK a -> m (Either TKGenError (a, TK 'SecretTK))
- runTKGenWithSeed :: ByteString -> (KeyVersion, ThirtyTwoBitTimeStamp) -> TKGen (MonadPseudoRandom ChaChaDRG) 'SecretTK a -> (Either TKGenError (a, TK 'SecretTK), ChaChaDRG)
- withKeyVersionAndTimestamp :: KeyVersion -> IO (KeyVersion, ThirtyTwoBitTimeStamp)
Legacy API (backward compatible)
data KeyGenSpec (v :: KeyVersion) where Source #
Constructors
| KeyGenRSA :: forall (v :: KeyVersion). RSAKeyVersion v => ThirtyTwoBitTimeStamp -> Int -> KeyGenSpec v | |
| KeyGenEd25519 :: ThirtyTwoBitTimeStamp -> KeyGenSpec 'V6 | |
| KeyGenEd448 :: ThirtyTwoBitTimeStamp -> KeyGenSpec 'V6 | |
| KeyGenX25519 :: ThirtyTwoBitTimeStamp -> KeyGenSpec 'V6 | |
| KeyGenX448 :: ThirtyTwoBitTimeStamp -> KeyGenSpec 'V6 |
generateSecretKey :: forall (v :: KeyVersion) (m :: Type -> Type). MonadRandom m => KeyGenSpec v -> ExceptT String m (SomePKPayload, SKey) Source #
Duration DSL
Instances
| Semigroup Duration Source # | |||||
| Data Duration Source # | |||||
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 # | |||||
Defined in Codec.Encryption.OpenPGP.KeyGeneration Associated Types
| |||||
| Show Duration Source # | |||||
| Eq Duration Source # | |||||
| Ord Duration Source # | |||||
Defined in Codec.Encryption.OpenPGP.KeyGeneration | |||||
| type Rep Duration Source # | |||||
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 TKGenState Source #
Instances
data SubkeySpec Source #
Instances
| Data SubkeySpec Source # | |||||
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 # | |||||
Defined in Codec.Encryption.OpenPGP.KeyGeneration Associated Types
| |||||
| Show SubkeySpec Source # | |||||
Defined in Codec.Encryption.OpenPGP.KeyGeneration | |||||
| Eq SubkeySpec Source # | |||||
Defined in Codec.Encryption.OpenPGP.KeyGeneration Methods (==) :: SubkeySpec -> SubkeySpec -> Bool Source # (/=) :: SubkeySpec -> SubkeySpec -> Bool Source # | |||||
| Ord SubkeySpec Source # | |||||
Defined in Codec.Encryption.OpenPGP.KeyGeneration Methods compare :: SubkeySpec -> SubkeySpec -> Ordering Source # (<) :: SubkeySpec -> SubkeySpec -> Bool Source # (<=) :: SubkeySpec -> SubkeySpec -> Bool Source # (>) :: SubkeySpec -> SubkeySpec -> Bool Source # (>=) :: SubkeySpec -> SubkeySpec -> Bool Source # max :: SubkeySpec -> SubkeySpec -> SubkeySpec Source # min :: SubkeySpec -> SubkeySpec -> SubkeySpec Source # | |||||
| type Rep SubkeySpec Source # | |||||
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
| Data SignatureSpec Source # | |||||
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 # | |||||
Defined in Codec.Encryption.OpenPGP.KeyGeneration Associated Types
Methods from :: SignatureSpec -> Rep SignatureSpec x Source # to :: Rep SignatureSpec x -> SignatureSpec Source # | |||||
| Show SignatureSpec Source # | |||||
Defined in Codec.Encryption.OpenPGP.KeyGeneration | |||||
| Eq SignatureSpec Source # | |||||
Defined in Codec.Encryption.OpenPGP.KeyGeneration Methods (==) :: SignatureSpec -> SignatureSpec -> Bool Source # (/=) :: SignatureSpec -> SignatureSpec -> Bool Source # | |||||
| Ord SignatureSpec Source # | |||||
Defined in Codec.Encryption.OpenPGP.KeyGeneration Methods compare :: SignatureSpec -> SignatureSpec -> Ordering Source # (<) :: SignatureSpec -> SignatureSpec -> Bool Source # (<=) :: SignatureSpec -> SignatureSpec -> Bool Source # (>) :: SignatureSpec -> SignatureSpec -> Bool Source # (>=) :: SignatureSpec -> SignatureSpec -> Bool Source # max :: SignatureSpec -> SignatureSpec -> SignatureSpec Source # min :: SignatureSpec -> SignatureSpec -> SignatureSpec Source # | |||||
| type Rep SignatureSpec Source # | |||||
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))))) | |||||
data TKGenError Source #
Constructors
| NoPrimaryKey | |
| KeyGenFailed String | |
| SignatureFailed String | |
| SerializationFailed String | |
| InvalidConfiguration String |
Instances
| Show TKGenError Source # | |
Defined in Codec.Encryption.OpenPGP.KeyGeneration | |
| Eq TKGenError Source # | |
Defined in Codec.Encryption.OpenPGP.KeyGeneration Methods (==) :: TKGenError -> TKGenError -> Bool Source # (/=) :: TKGenError -> TKGenError -> Bool Source # | |
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.