cryptostore-0.1.0.0: Serialization of cryptographic data types

LicenseBSD-style
MaintainerOlivier Chéron <olivier.cheron@gmail.com>
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell2010

Crypto.Store.PKCS5

Contents

Description

Password-Based Cryptography, aka PKCS #5.

Synopsis

Documentation

type Password = ByteString Source #

A password stored as a sequence of UTF-8 bytes.

Some key-derivation functions add restrictions to what characters are supported.

type EncryptedContent = ByteString Source #

Encrypted content.

High-level API

data PKCS5 Source #

Content encrypted with a Password-Based Encryption Scheme (PBES).

The content will usually be the binary representation of an ASN.1 object, however the transformation may be applied to any bytestring.

Constructors

PKCS5 

Fields

Instances
Eq PKCS5 Source # 
Instance details

Defined in Crypto.Store.PKCS5

Methods

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

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

Show PKCS5 Source # 
Instance details

Defined in Crypto.Store.PKCS5

Methods

showsPrec :: Int -> PKCS5 -> ShowS #

show :: PKCS5 -> String #

showList :: [PKCS5] -> ShowS #

ASN1Object PKCS5 Source # 
Instance details

Defined in Crypto.Store.PKCS5

Methods

toASN1 :: PKCS5 -> ASN1S #

fromASN1 :: [ASN1] -> Either String (PKCS5, [ASN1]) #

encrypt :: EncryptionScheme -> Password -> ByteString -> Either StoreError PKCS5 Source #

Encrypt a bytestring with the specified encryption scheme and password.

decrypt :: PKCS5 -> Password -> Either StoreError ByteString Source #

Decrypt the PKCS #5 content with the specified password.

Encryption schemes

data EncryptionScheme Source #

Password-Based Encryption Scheme (PBES).

Constructors

PBES2 PBES2Parameter

PBES2

PBE_MD5_DES_CBC PBEParameter

pbeWithMD5AndDES-CBC

PBE_SHA1_DES_CBC PBEParameter

pbeWithSHA1AndDES-CBC

PBE_SHA1_RC4_128 PBEParameter

pbeWithSHAAnd128BitRC4

PBE_SHA1_RC4_40 PBEParameter

pbeWithSHAAnd40BitRC4

PBE_SHA1_DES_EDE3_CBC PBEParameter

pbeWithSHAAnd3-KeyTripleDES-CBC

PBE_SHA1_DES_EDE2_CBC PBEParameter

pbeWithSHAAnd2-KeyTripleDES-CBC

PBE_SHA1_RC2_128 PBEParameter

pbeWithSHAAnd128BitRC2-CBC

PBE_SHA1_RC2_40 PBEParameter

pbewithSHAAnd40BitRC2-CBC

data PBEParameter Source #

PBES1 parameters.

Constructors

PBEParameter 

Fields

data PBES2Parameter Source #

PBES2 parameters.

Constructors

PBES2Parameter 

Fields

Key derivation

data KeyDerivationFunc Source #

Key derivation algorithm and associated parameters.

Constructors

PBKDF2

Key derivation with PBKDF2

Fields

Scrypt

Key derivation with Scrypt

Fields

data PBKDF2_PRF Source #

Pseudorandom function used for PBKDF2.

Constructors

PBKDF2_SHA1

hmacWithSHA1

PBKDF2_SHA256

hmacWithSHA256

PBKDF2_SHA512

hmacWithSHA512

type Salt = ByteString Source #

Salt value used for key derivation.

generateSalt :: MonadRandom m => Int -> m Salt Source #

Generate a random salt with the specified length in bytes. To be most effective, the length should be at least 8 bytes.

Content encryption

data ContentEncryptionAlg Source #

Cipher and mode of operation for content encryption.

Constructors

BlockCipher c => ECB (ContentEncryptionCipher c)

Electronic Codebook

BlockCipher c => CBC (ContentEncryptionCipher c)

Cipher Block Chaining

CBC_RC2

RC2 in CBC mode

BlockCipher c => CFB (ContentEncryptionCipher c)

Cipher Feedback

BlockCipher c => CTR (ContentEncryptionCipher c)

Counter

data ContentEncryptionCipher cipher where Source #

CMS content encryption cipher.

Constructors

DES :: ContentEncryptionCipher DES

DES

DES_EDE2 :: ContentEncryptionCipher DES_EDE2

Triple-DES with 2 keys used in alternative direction

DES_EDE3 :: ContentEncryptionCipher DES_EDE3

Triple-DES with 3 keys used in alternative direction

AES128 :: ContentEncryptionCipher AES128

AES with 128-bit key

AES192 :: ContentEncryptionCipher AES192

AES with 192-bit key

AES256 :: ContentEncryptionCipher AES256

AES with 256-bit key

CAST5 :: ContentEncryptionCipher CAST5

CAST5 (aka CAST-128) with key between 40 and 128 bits

Camellia128 :: ContentEncryptionCipher Camellia128

Camellia with 128-bit key

generateEncryptionParams :: MonadRandom m => ContentEncryptionAlg -> m ContentEncryptionParams Source #

Generate random parameters for the specified content encryption algorithm.

Low-level API

pbEncrypt :: EncryptionScheme -> ByteString -> Password -> Either StoreError EncryptedContent Source #

Encrypt a bytestring with the specified encryption scheme and password.

pbDecrypt :: EncryptionScheme -> EncryptedContent -> Password -> Either StoreError ByteString Source #

Decrypt an encrypted bytestring with the specified encryption scheme and password.