Safe Haskell | None |
---|---|
Language | Haskell2010 |
Unauthenticated streaming encryption.
Note: Unauthenticated encryption is insecure in general. Only use the functions from this modules if you know exactly what you are doing. We only provide this module for compatibility with NaCl. @
This is crypto_box_*
from NaCl.
Synopsis
- type Key a = SizedByteArray CRYPTO_STREAM_KEYBYTES a
- toKey :: ByteArrayAccess ba => ba -> Maybe (Key ba)
- type Nonce a = SizedByteArray CRYPTO_STREAM_NONCEBYTES a
- toNonce :: ByteArrayAccess ba => ba -> Maybe (Nonce ba)
- type MaxStreamSize = 18446744073709551615
- generate :: forall n key nonce ct. (ByteArrayAccess key, ByteArrayAccess nonce, ByteArrayN n ct, n <= MaxStreamSize) => Key key -> Nonce nonce -> ct
- xor :: (ByteArrayAccess key, ByteArrayAccess nonce, ByteArrayAccess pt, ByteArray ct) => Key key -> Nonce nonce -> pt -> ct
Documentation
type Key a = SizedByteArray CRYPTO_STREAM_KEYBYTES a Source #
Encryption key that can be used for Stream.
This type is parametrised by the actual data type that contains
bytes. This can be, for example, a ByteString
, but, since this
is a secret key, it is better to use ScrubbedBytes
.
toKey :: ByteArrayAccess ba => ba -> Maybe (Key ba) Source #
Make a Key
from an arbitrary byte array.
This function returns Just
if and only if the byte array has
the right length to be used as a key with a Stream.
type Nonce a = SizedByteArray CRYPTO_STREAM_NONCEBYTES a Source #
Nonce that can be used for Stream.
This type is parametrised by the actual data type that contains
bytes. This can be, for example, a ByteString
.
toNonce :: ByteArrayAccess ba => ba -> Maybe (Nonce ba) Source #
Make a Nonce
from an arbitrary byte array.
This function returns Just
if and only if the byte array has
the right length to be used as a nonce with a Stream.
type MaxStreamSize = 18446744073709551615 Source #
The maximum size of the stream produced by generate
.
:: forall n key nonce ct. (ByteArrayAccess key, ByteArrayAccess nonce, ByteArrayN n ct, n <= MaxStreamSize) | |
=> Key key | Secret key |
-> Nonce nonce | Nonce |
-> ct |
Generate a stream of pseudo-random bytes.
:: (ByteArrayAccess key, ByteArrayAccess nonce, ByteArrayAccess pt, ByteArray ct) | |
=> Key key | Secret key |
-> Nonce nonce | Nonce |
-> pt | Input (plain/cipher) text |
-> ct |
Encrypt/decrypt a message.