From 3fd3fe7a73cd70ab38ca97c2358ca51afbaff28d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 10 Oct 2017 14:34:46 +0200 Subject: [PATCH] Correct documentation mistakes --- cryptoids/changes.md | 3 +++ cryptoids/cryptoids.cabal | 2 +- cryptoids/src/Data/CryptoID/Poly.hs | 17 ++++++++--------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cryptoids/changes.md b/cryptoids/changes.md index e74fd28..04578ea 100644 --- a/cryptoids/changes.md +++ b/cryptoids/changes.md @@ -1,3 +1,6 @@ +# 0.1.0.1 + - Correct mistakes in the documentation + # 0.1.0 - Switch to using 'MonadThrow' instead of 'MonadError' - Introduce 'readKeyFile' diff --git a/cryptoids/cryptoids.cabal b/cryptoids/cryptoids.cabal index f443551..77009d1 100644 --- a/cryptoids/cryptoids.cabal +++ b/cryptoids/cryptoids.cabal @@ -1,5 +1,5 @@ name: cryptoids -version: 0.1.0 +version: 0.1.0.1 synopsis: Reversable and secure encoding of object ids as a bytestring license: BSD3 license-file: LICENSE diff --git a/cryptoids/src/Data/CryptoID/Poly.hs b/cryptoids/src/Data/CryptoID/Poly.hs index 1925c84..0d0f9ea 100644 --- a/cryptoids/src/Data/CryptoID/Poly.hs +++ b/cryptoids/src/Data/CryptoID/Poly.hs @@ -4,14 +4,13 @@ Description: Encryption of bytestrings using a type level nonce for determinism License: BSD3 -Given a value of a serializable type (like 'Int') we perform serialization and -compute a cryptographic hash of the associated namespace (carried as a phantom -type of kind 'Symbol'). -The serialized payload is then encrypted using the symmetric cipher in CBC mode -using the hashed namespace as an initialization vector (IV). +Given a strict 'ByteString' we compute a cryptographic hash of the associated +namespace (carried as a phantom type of kind 'Symbol'). +The payload is then encrypted using the symmetric cipher in CBC mode using the +hashed namespace as an initialization vector (IV). -The probability of detecting a namespace mismatch is thus \(1 - 2^{128-l}\) -where \(l\) is the length of the serialized payload. +The probability of detecting a namespace mismatch is thus the density of valid +payloads within all 'ByteString's of the correct length. -} module Data.CryptoID.Poly ( CryptoID(..) @@ -184,7 +183,7 @@ namespace' p = case makeIV namespaceHash of cryptoFailable :: MonadThrow m => CryptoFailable a -> m a cryptoFailable = either (throwM . AlgorithmError) return . eitherCryptoError --- | Encrypt an arbitrary serializable value +-- | Encrypt a serialized value encrypt :: forall m namespace. ( KnownSymbol namespace , MonadThrow m @@ -195,7 +194,7 @@ encrypt (keyMaterial -> key) plaintext = do return . CryptoID . cbcEncrypt cipher namespace $ pad (blockSize cipher) plaintext --- | Decrypt an arbitrary serializable value +-- | Decrypt a serialized value decrypt :: forall m namespace. ( KnownSymbol namespace , MonadThrow m