unbreak-0.3.1: Secure and resilient remote file storage utility

LicenseAGPL-3
MaintainerKinoru
StabilityProvisional
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Unbreak.Crypto

Description

Simple interface to the cryptographic primitives that are provided by the cryptonite package.

Synopsis

Documentation

getRandomBytes :: Int -> IO ByteString Source

Read bytes from /dev/urandom.

scrypt Source

Arguments

:: ByteString

input

-> ByteString

salt

-> ByteString

output (32 bytes)

The scrypt key derivation function from Crypto.KDF.Scrypt. The parameters are:

  • CPU/memory cost parameter N = 16384 (2^14)
  • SMix function parameter r = 8
  • Parallelization parameter p = 1
  • Intended output length dkLen = 32 (for use in ChaCha20-Poly1305)

encrypt Source

Arguments

:: ByteString

nonce (12 random bytes, must be different each time)

-> ByteString

the secret symmetric key

-> ByteString

the plaintext to be encrypted

-> CryptoFailable ByteString

ciphertext with a 128-bit tag attached

Encrypt the given ByteString using the ChaCha20-Poly1305 scheme from Crypto.Cipher.ChaChaPoly1305. The resulting ByteString is nonce (12 bytes) ++ ciphertext ++ the auth tag (16 bytes).

decrypt Source

Arguments

:: ByteString

the secret symmetric key

-> ByteString

the input (nonce ++ ciphertext ++ tag)

-> CryptoFailable ByteString

the decrypted plaintext

Decrypt a ByteString that is produced by the encrypt function.

encryptFileName Source

Arguments

:: ByteString

file name

-> ByteString

key

-> ByteString 

Encryption of unbreak file names.

decryptFileName :: ByteString -> ByteString -> ByteString Source

Decryption of unbreak file names.