Z-Botan-0.1.1.1: Crypto for Haskell
CopyrightDong Han 2021
AnJie Dong 2021
LicenseBSD
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Z.Crypto.PubKey

Description

This module is used for Public Key Cryptography. Public key cryptography (also called asymmetric cryptography) is a collection of techniques allowing for encryption, signatures, and key agreement.

Synopsis

Asymmetric cryptography algorithms

data KeyType Source #

Public Key Cryptography Algorithms.

Constructors

Curve25519 
RSA Word32

RSA key of the given size, namely n bits

XMSS XMSSType

eXtended Merkle Signature Scheme, see https://botan.randombit.net/handbook/api_ref/pubkey.html#extended-merkle-signature-scheme-xmss

Ed25519

Ed25519 high-speed high-security signatures

ECC ECCType ECGroup

Elliptic-curve cryptography, see ECCType

DL DLType DLGroup

Asymmetric algorithm based on the discrete logarithm problem, see DLType

McEliece

McEliece is a cryptographic scheme based on error correcting codes which is thought to be resistant to quantum computers. See https://botan.randombit.net/handbook/api_ref/pubkey.html#mceliece.

Fields

pattern RSADefault :: KeyType Source #

Default RSA Key type(3072 bits).

pattern McElieceDefault :: KeyType Source #

Default McEliece key type.

data ECCType Source #

Algorithms based on elliptic curve.

data DLType Source #

Discrete Logarithm

Constructors

DH

Diffie-Hellman key exchange

DSA

Digital Signature Algorithm

ElGamal 

Key generation and manipulation

newtype PrivKey Source #

An opaque data type for a private-public key pair.

Constructors

PrivKey BotanStruct 

Instances

Instances details
Show PrivKey Source # 
Instance details

Defined in Z.Crypto.PubKey

Generic PrivKey Source # 
Instance details

Defined in Z.Crypto.PubKey

Associated Types

type Rep PrivKey :: Type -> Type #

Methods

from :: PrivKey -> Rep PrivKey x #

to :: Rep PrivKey x -> PrivKey #

Print PrivKey Source # 
Instance details

Defined in Z.Crypto.PubKey

Methods

toUTF8BuilderP :: Int -> PrivKey -> Builder () #

type Rep PrivKey Source # 
Instance details

Defined in Z.Crypto.PubKey

type Rep PrivKey = D1 ('MetaData "PrivKey" "Z.Crypto.PubKey" "Z-Botan-0.1.1.1-6owjsCiiiOqL08hsGvk7Pd" 'True) (C1 ('MetaCons "PrivKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BotanStruct)))

newtype PubKey Source #

A newtype wrapper.

Constructors

PubKey BotanStruct 

Instances

Instances details
Eq PubKey Source # 
Instance details

Defined in Z.Crypto.PubKey

Methods

(==) :: PubKey -> PubKey -> Bool #

(/=) :: PubKey -> PubKey -> Bool #

Ord PubKey Source # 
Instance details

Defined in Z.Crypto.PubKey

Show PubKey Source # 
Instance details

Defined in Z.Crypto.PubKey

Generic PubKey Source # 
Instance details

Defined in Z.Crypto.PubKey

Associated Types

type Rep PubKey :: Type -> Type #

Methods

from :: PubKey -> Rep PubKey x #

to :: Rep PubKey x -> PubKey #

Print PubKey Source # 
Instance details

Defined in Z.Crypto.PubKey

Methods

toUTF8BuilderP :: Int -> PubKey -> Builder () #

type Rep PubKey Source # 
Instance details

Defined in Z.Crypto.PubKey

type Rep PubKey = D1 ('MetaData "PubKey" "Z.Crypto.PubKey" "Z-Botan-0.1.1.1-6owjsCiiiOqL08hsGvk7Pd" 'True) (C1 ('MetaCons "PubKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BotanStruct)))

newPrivKey Source #

Arguments

:: KeyType

Algorithm name and some algorithm specific arguments.

-> RNG 
-> IO PrivKey 

Creating a private key.

Creating a private key requires two things:

  • a source of random numbers
  • some algorithm specific arguments that define the security level of the resulting key.

newKeyPair Source #

Arguments

:: KeyType

Algorithm name and some algorithm specific arguments.

-> RNG 
-> IO (PrivKey, PubKey) 

Creating a new key pair.

privKeyToPubKey :: PrivKey -> PubKey Source #

Export a public key from a given key pair.

loadPrivKey Source #

Arguments

:: RNG 
-> Bytes 
-> CBytes

Password.

-> IO PrivKey 

Load a private key. If the key is encrypted, password will be used to attempt decryption.

privKeyAlgoName :: PrivKey -> IO Bytes Source #

Get the algorithm name of a private key.

privKeyParam Source #

Arguments

:: HasCallStack 
=> PrivKey

key

-> CBytes

field name

-> MPI 

Read an algorithm specific field from the key pair object.

exportPrivKeyDER :: HasCallStack => PrivKey -> Bytes Source #

Export a private key in DER binary format.

exportPrivKeyPEM :: HasCallStack => PrivKey -> Text Source #

Export a private key in PEM textual format.

exportPrivKeyEncryptedDER Source #

Arguments

:: PrivKey 
-> RNG 
-> CBytes

password

-> IO Bytes 

Export a private key with password.

exportPrivKeyEncryptedPEM Source #

Arguments

:: PrivKey 
-> RNG 
-> CBytes

password

-> IO Text 

Export a private key with password in PEM textual format.

loadPubKey :: HasCallStack => Bytes -> IO PubKey Source #

Load a publickey.

pubKeyAlgoName :: PubKey -> CBytes Source #

Get the algorithm name of a public key.

pubKeyParam Source #

Arguments

:: HasCallStack 
=> PubKey

key

-> CBytes

field name

-> MPI 

Read an algorithm specific field from the public key object.

exportPubKeyDER :: HasCallStack => PubKey -> Bytes Source #

Export a public key in DER binary format..

exportPubKeyPEM :: HasCallStack => PubKey -> Text Source #

Export a public key in PEM textual format.

estStrength :: PubKey -> Int Source #

Estimate the strength of a public key.

fingerPrintPubKey :: PubKey -> HashType -> Bytes Source #

Fingerprint a given publickey.

Encrypt & Decrypt

pkEncrypt Source #

Arguments

:: PubKey 
-> EMEPadding 
-> RNG 
-> Bytes

plaintext

-> IO Bytes

ciphertext

Encrypt a message, returning the ciphertext.

Though botan support DLIES and ECIES but only EME are exported via FFI, please use an algorithm that directly support encryption such as RSA and ElGamal.

pkDecrypt Source #

Arguments

:: PrivKey 
-> EMEPadding 
-> Bytes

ciphertext

-> Bytes

plaintext

Decrypt a message, returning the ciphertext.

Though botan support DLIES and ECIES but only EME are exported via FFI, please use an algorithm that directly support decryption such as RSA and ElGamal.

data EMEPadding Source #

Sets of allowed padding schemes for public key types.

The recommended values for eme is EME1_SHA1 or EME1_SHA256. If you need compatibility with protocols using the PKCS #1 v1.5 standard, you can also use EME_PKCS1_v15'.

Constructors

EME_RAW 
EME_PKCS1_v1'5 
EME_OAEP HashType CBytes

hash, label

EME_OAEP' HashType HashType CBytes

hash, mask gen hash, labal

Sign & verify

data EMSA Source #

Currently available values for EMSA, examples are “EMSA1(SHA-1)” and “EMSA4(SHA-256)”.

Currently available values for EMSA include EMSA1, EMSA2, EMSA3, EMSA4, and Raw. All of them, except Raw, take a parameter naming a message digest function to hash the message with. The Raw encoding signs the input directly; if the message is too big, the signing operation will fail. Raw is not useful except in very specialized applications. For RSA, use EMSA4 (also called PSS) unless you need compatibility with software that uses the older PKCS #1 v1.5 standard, in which case use EMSA3 (also called “EMSA-PKCS1-v1_5”). For DSA, ECDSA, ECKCDSA, ECGDSA and GOST 34.10-2001 you should use EMSA1.

Constructors

EMSA1 HashType 
EMSA2 HashType 
EMSA3_RAW (Maybe HashType) 
EMSA3 HashType 
EMSA4_Raw HashType (Maybe Int)

hash, salt size

EMSA4 HashType (Maybe Int)

hash, salt size

ISO_9796_DS2 HashType Bool (Maybe Int)

hash, implicit, salt size

ISO_9796_DS3 HashType Bool

hash, implicit

EMSA_Raw 

data SignFmt Source #

Constructors

DER_SEQUENCE 
IEEE_1363 

Instances

Instances details
Eq SignFmt Source # 
Instance details

Defined in Z.Crypto.PubKey

Methods

(==) :: SignFmt -> SignFmt -> Bool #

(/=) :: SignFmt -> SignFmt -> Bool #

Ord SignFmt Source # 
Instance details

Defined in Z.Crypto.PubKey

Show SignFmt Source # 
Instance details

Defined in Z.Crypto.PubKey

Generic SignFmt Source # 
Instance details

Defined in Z.Crypto.PubKey

Associated Types

type Rep SignFmt :: Type -> Type #

Methods

from :: SignFmt -> Rep SignFmt x #

to :: Rep SignFmt x -> SignFmt #

Print SignFmt Source # 
Instance details

Defined in Z.Crypto.PubKey

Methods

toUTF8BuilderP :: Int -> SignFmt -> Builder () #

type Rep SignFmt Source # 
Instance details

Defined in Z.Crypto.PubKey

type Rep SignFmt = D1 ('MetaData "SignFmt" "Z.Crypto.PubKey" "Z-Botan-0.1.1.1-6owjsCiiiOqL08hsGvk7Pd" 'False) (C1 ('MetaCons "DER_SEQUENCE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IEEE_1363" 'PrefixI 'False) (U1 :: Type -> Type))

newSigner :: PrivKey -> EMSA -> SignFmt -> IO Signer Source #

updateSigner :: Signer -> Bytes -> IO () Source #

finalSigner :: Signer -> RNG -> IO Bytes Source #

Produce a signature over all of the bytes passed to Signer. Afterwards, the sign operator is reset and may be used to sign a new message.

sinkToSigner :: HasCallStack => Signer -> Sink Bytes Source #

Trun Signer to a Bytes sink, update Signer by write bytes to the sink.

sign Source #

Arguments

:: HasCallStack 
=> PrivKey 
-> EMSA 
-> SignFmt 
-> Bytes

input

-> IO Bytes

signature

Directly sign a message, with system RNG.

signChunks :: HasCallStack => PrivKey -> EMSA -> SignFmt -> [Bytes] -> IO Bytes Source #

Directly compute a chunked message's mac with system RNG.

newVerifier :: PubKey -> EMSA -> SignFmt -> IO Verifier Source #

updateVerifier :: Verifier -> Bytes -> IO () Source #

finalVerifier :: Verifier -> Bytes -> IO Bool Source #

sinkToVerifier :: HasCallStack => Verifier -> Sink Bytes Source #

Trun Verifier to a Bytes sink, update Verifier by write bytes to the sink.

verify Source #

Arguments

:: HasCallStack 
=> PubKey 
-> EMSA 
-> SignFmt 
-> Bytes

input

-> Bytes

signature

-> Bool 

Directly sign a message.

verifyChunks Source #

Arguments

:: HasCallStack 
=> PubKey 
-> EMSA 
-> SignFmt 
-> [Bytes] 
-> Bytes

signature

-> Bool 

Directly compute a chunked message's mac.

Key agreement

data KeyAgreement Source #

Key agreement object.

Instances

Instances details
Show KeyAgreement Source # 
Instance details

Defined in Z.Crypto.PubKey

Generic KeyAgreement Source # 
Instance details

Defined in Z.Crypto.PubKey

Associated Types

type Rep KeyAgreement :: Type -> Type #

Print KeyAgreement Source # 
Instance details

Defined in Z.Crypto.PubKey

type Rep KeyAgreement Source # 
Instance details

Defined in Z.Crypto.PubKey

type Rep KeyAgreement = D1 ('MetaData "KeyAgreement" "Z.Crypto.PubKey" "Z-Botan-0.1.1.1-6owjsCiiiOqL08hsGvk7Pd" 'False) (C1 ('MetaCons "KeyAgreement" 'PrefixI 'True) (S1 ('MetaSel ('Just "keyAgreementStruct") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 BotanStruct) :*: S1 ('MetaSel ('Just "keyAgreementSize") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int)))

newKeyAgreement :: PrivKey -> KDFType -> IO KeyAgreement Source #

Create a new key agreement operation with a given key pair and KDF algorithm.

Use a key type that support key agreement, such as DH or ECDH, Botan implements the following key agreement methods: * ECDH over GF(p) Weierstrass curves * ECDH over x25519 * DH over prime fields * McEliece * NewHope

keyAgree Source #

Arguments

:: KeyAgreement 
-> Bytes

other key

-> Bytes

salt

-> IO Bytes 

How key agreement works is that you trade public values with some other party, and then each of you runs a computation with the other’s value and your key (this should return the same result to both parties).

RSA specific

getRSAParams Source #

Arguments

:: PrivKey 
-> (MPI, MPI, MPI, MPI, MPI)

(p, q, n, d, e)

Get RSA parameters

  • Set p to the first RSA prime.
  • Set q to the second RSA prime.
  • Set n to the RSA modulus.
  • Set d to the RSA private exponent.
  • Set e to the RSA public exponent.

newRSAPrivKey :: MPI -> MPI -> MPI -> PrivKey Source #

Initialize a RSA key pair using arguments p, q, and e.

getRSAPubParams Source #

Arguments

:: PubKey 
-> (MPI, MPI)

(n, e)

Get RSA Public parameters

  • Set n to the RSA modulus.
  • Set e to the RSA public exponent.

newRSAPubKey :: MPI -> MPI -> PubKey Source #

Initialize a public RSA key using arguments n and e.

DSA specific

getDSAPrivParams Source #

Arguments

:: PrivKey 
-> (MPI, MPI, MPI, MPI)

(p, q, g, x)

Get DSA parameters

  • Set p, q, g to group parameters
  • Set x to the private key

newDSAPrivKey :: MPI -> MPI -> MPI -> MPI -> PrivKey Source #

Initialize a DSA key pair using arguments p, q, g and x.

getDSAPubParams Source #

Arguments

:: PubKey 
-> (MPI, MPI, MPI, MPI)

(p, q, g, y)

Get DSA parameters

  • Set p, q, g to group parameters
  • Set y to the public key

newDSAPubKey :: MPI -> MPI -> MPI -> MPI -> PubKey Source #

Initialize a DSA public key using arguments p, q, g and y.

ElGamal specific

getElGamalPrivParams Source #

Arguments

:: PrivKey 
-> (MPI, MPI, MPI)

(p, g, x)

Get ElGamal parameters

  • Set p, g to group parameters
  • Set x to the private key

getElGamalPubParams Source #

Arguments

:: PubKey 
-> (MPI, MPI, MPI)

(p, g, y)

Get ElGamal parameters

  • Set p, g to group parameters
  • Set y to the public key

Diffie-Hellman specific

getDHPrivParams Source #

Arguments

:: PrivKey 
-> (MPI, MPI, MPI)

(p, g, x)

Get Diffie-Hellman parameters

  • Set p, g to group parameters
  • Set x to the private key

getDHPubParams Source #

Arguments

:: PubKey 
-> (MPI, MPI, MPI)

(p, g, y)

Get Diffie-Hellman parameters

  • Set p, g to group parameters
  • Set y to the public key

constants

type XMSSType = CBytes Source #

A type wrapper.

type ECGroup = CBytes Source #

An elliptic curve.

type DLGroup = CBytes Source #

Discrete Logarithm Group

re-exports

data HashType Source #

Available Hashs

Constructors

BLAKE2b Int

A recently designed hash function. Very fast on 64-bit processors. Can output a hash of any length between 1 and 64 bytes, this is specified by passing desired byte length.

BLAKE2b256

Alias for Blake2b 32

BLAKE2b512

Alias for Blake2b 64

Keccak1600_224

An older (and incompatible) variant of SHA-3, but sometimes used. Prefer SHA-3 in new code.

Keccak1600_256 
Keccak1600_384 
Keccak1600_512 
MD4

An old hash function that is now known to be trivially breakable. It is very fast, and may still be suitable as a (non-cryptographic) checksum.

MD5

Widely used, now known to be broken.

RIPEMD160

A 160 bit hash function, quite old but still thought to be secure (up to the limit of 2**80 computation required for a collision which is possible with any 160 bit hash function). Somewhat deprecated these days.

SHA160

Widely adopted NSA designed hash function. Starting to show significant signs of weakness, and collisions can now be generated. Avoid in new designs.

SHA256

Relatively fast 256 bit hash function, thought to be secure. Also includes the variant SHA-224. There is no real reason to use SHA-224.

SHA224 
SHA512

SHA-512 is faster than SHA-256 on 64-bit processors. Also includes the truncated variants SHA-384 and SHA-512/256, which have the advantage of avoiding message extension attacks.

SHA384 
SHA512_256 
SHA3_224

The new NIST standard hash. Fairly slow. Supports 224, 256, 384 or 512 bit outputs. SHA-3 is faster with smaller outputs. Use as “SHA3_256” or “SHA3_512”. Plain “SHA-3” selects default 512 bit output.

SHA3_256 
SHA3_384 
SHA3_512 
SHAKE128 Int

These are actually XOFs (extensible output functions) based on SHA-3, which can output a value of any byte length. For example “SHAKE128 @128” will produce 1024 bits of output.

SHAKE256 Int 
SM3

Chinese national hash function, 256 bit output. Widely used in industry there. Fast and seemingly secure, but no reason to prefer it over SHA-2 or SHA-3 unless required.

Skein512 Int CBytes

A contender for the NIST SHA-3 competition. Very fast on 64-bit systems. Can output a hash of any length between 1 and 64 bytes. It also accepts an optional “personalization string” which can create variants of the hash. This is useful for domain separation.

Streebog256

Newly designed Russian national hash function. Due to use of input-dependent table lookups, it is vulnerable to side channels. There is no reason to use it unless compatibility is needed. Warning: The Streebog Sbox has recently been revealed to have a hidden structure which interacts with its linear layer in a way which may provide a backdoor when used in certain ways. Avoid Streebog if at all possible.

Streebog512 
Whirlpool

A 512-bit hash function standardized by ISO and NESSIE. Relatively slow, and due to the table based implementation it is potentially vulnerable to cache based side channels.

Parallel HashType HashType

Parallel simply concatenates multiple hash functions. For example “Parallel SHA256 SHA512 outputs a 256+512 bit hash created by hashing the input with both SHA256 and SHA512 and concatenating the outputs.

Comb4P HashType HashType

This combines two cryptographic hashes in such a way that preimage and collision attacks are provably at least as hard as a preimage or collision attack on the strongest hash.

Adler32

Checksums, not suitable for cryptographic use, but can be used for error checking purposes.

CRC24 
CRC32 

Instances

Instances details
Eq HashType Source # 
Instance details

Defined in Z.Crypto.Hash

Ord HashType Source # 
Instance details

Defined in Z.Crypto.Hash

Read HashType Source # 
Instance details

Defined in Z.Crypto.Hash

Show HashType Source # 
Instance details

Defined in Z.Crypto.Hash

Generic HashType Source # 
Instance details

Defined in Z.Crypto.Hash

Associated Types

type Rep HashType :: Type -> Type #

Methods

from :: HashType -> Rep HashType x #

to :: Rep HashType x -> HashType #

JSON HashType Source # 
Instance details

Defined in Z.Crypto.Hash

Print HashType Source # 
Instance details

Defined in Z.Crypto.Hash

Methods

toUTF8BuilderP :: Int -> HashType -> Builder () #

type Rep HashType Source # 
Instance details

Defined in Z.Crypto.Hash

type Rep HashType = D1 ('MetaData "HashType" "Z.Crypto.Hash" "Z-Botan-0.1.1.1-6owjsCiiiOqL08hsGvk7Pd" 'False) (((((C1 ('MetaCons "BLAKE2b" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :+: C1 ('MetaCons "BLAKE2b256" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "BLAKE2b512" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Keccak1600_224" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "Keccak1600_256" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Keccak1600_384" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Keccak1600_512" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MD4" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: (((C1 ('MetaCons "MD5" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "RIPEMD160" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "SHA160" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SHA256" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "SHA224" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SHA512" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "SHA384" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SHA512_256" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: ((((C1 ('MetaCons "SHA3_224" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SHA3_256" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "SHA3_384" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SHA3_512" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "SHAKE128" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :+: C1 ('MetaCons "SHAKE256" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))) :+: (C1 ('MetaCons "SM3" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Skein512" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CBytes))))) :+: (((C1 ('MetaCons "Streebog256" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Streebog512" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Whirlpool" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Parallel" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HashType) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HashType)))) :+: ((C1 ('MetaCons "Comb4P" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HashType) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HashType)) :+: C1 ('MetaCons "Adler32" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "CRC24" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CRC32" 'PrefixI 'False) (U1 :: Type -> Type))))))

data KDFType Source #

Key derivation functions are used to turn some amount of shared secret material into uniform random keys suitable for use with symmetric algorithms. An example of an input which is useful for a KDF is a shared secret created using Diffie-Hellman key agreement.

Constructors

HKDF MACType 
HKDF_Extract MACType 
HKDF_Expand MACType

Defined in RFC 5869, HKDF uses HMAC to process inputs. Also available are variants HKDF-Extract and HKDF-Expand. HKDF is the combined Extract+Expand operation. Use the combined HKDF unless you need compatibility with some other system.

KDF2 HashType

KDF2 comes from IEEE 1363. It uses a hash function.

KDF1_18033 HashType

KDF1 from ISO 18033-2. Very similar to (but incompatible with) KDF2.

KDF1 HashType

KDF1 from IEEE 1363. It can only produce an output at most the length of the hash function used.

TLS_PRF

A KDF from ANSI X9.42. Sometimes used for Diffie-Hellman.

TLS_12_PRF MACType 
SP800_108_Counter MACType

KDFs from NIST SP 800-108. Variants include “SP800-108-Counter”, “SP800-108-Feedback” and “SP800-108-Pipeline”.

SP800_108_Feedback MACType 
SP800_108_Pipeline MACType 
SP800_56AHash HashType

NIST SP 800-56A KDF using hash function

SP800_56AMAC MACType

NIST SP 800-56A KDF using HMAC

SP800_56C MACType

NIST SP 800-56C KDF using HMAC

internal

withPrivKey :: HasCallStack => PrivKey -> (BotanStructT -> IO r) -> IO r Source #

Pass PrivKey to FFI.

withPubKey :: HasCallStack => PubKey -> (BotanStructT -> IO r) -> IO r Source #

Pass PubKey to FFI.