Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ function call, and optimizes EQC tests to make it easier to implement
`largebinary`-support in EQC tests.
- The release also adds an (experimental) scrambling function for
hiding the internal structure of counters. This is based on an
enlarged TEA-cipher by Wheeler and Needham. It is neccessary for
enlarged TEA-cipher by Wheeler and Needham. It is necessary for
correct operation of the CurveCP implementation, which is why it is
included in this library.

Expand Down
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,27 @@ libsodium.

To build the software execute:

make
```sh
make
```

or

rebar compile
```sh
rebar compile
```

To build and run licensed eqc test execute:

make eqc_run
```sh
make eqc_run
```

To build and run eqc-mini version of test execute:

make eqc_mini_run
```sh
make eqc_mini_run
```

## Features

Expand Down Expand Up @@ -62,13 +70,15 @@ place.

In general, consult the libsodium documentation at [Libsodium documentation](https://download.libsodium.org/doc/)

The original NaCl documentation is nowadays largely superceded by the
The original NaCl documentation is nowadays largely superseded by the
libsodium documentation, but it is still worth a visit [NaCl website](https://nacl.cr.yp.to)

but also note that our interface has full Edoc documentation,
generated by executing

rebar3 doc
```sh
rebar3 doc
```

## Hints

Expand All @@ -81,7 +91,7 @@ However, their correct use is still needed in order to be secure:
reuse a nonce, and an attacker figures this out, the system will
leak the XOR difference of messages sent with the same nonce. Given
enough guessing, this can in turn leak the encryption stream of bits
and every message hereafter, sent on the same keypair combination
and every message hereafter, sent on the same key pair combination
and reusing that nonce, will be trivially breakable.
* Use the beforenm/afternm primitives if using the `box` public-key
encryption scheme. Precomputing the Curve25519 operations yields
Expand Down Expand Up @@ -158,7 +168,7 @@ This implements standard Public/Secret key cryptography. The
implementation roughly consists of two major sections:

* *Authenticated encryption:* provides a `box` primitive which
encrypts and then also authenticates a message. The reciever is only
encrypts and then also authenticates a message. The receiver is only
able to open the sealed box if they posses the secret key and the
authentication from the sender is correct.
* *Signatures:* allows one party to sign a message (not encrypting it)
Expand Down
18 changes: 9 additions & 9 deletions src/enacl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ kdf_derive_from_key(MasterKey, Context, Id) ->

%% Public Key Crypto
%% ---------------------
%% @doc box_keypair/0 creates a new Public/Secret keypair.
%% @doc box_keypair/0 creates a new Public/Secret key pair.
%%
%% Generates and returns a new key pair for the Box encryption scheme. The return value is a
%% map in order to avoid using the public key as a secret key and vice versa.
Expand Down Expand Up @@ -566,7 +566,7 @@ box(Msg, Nonce, PK, SK) ->
box_open(CipherText, Nonce, PK, SK) ->
enacl_nif:crypto_box_open([?P_BOXZEROBYTES, CipherText], Nonce, PK, SK).

%% @doc box_beforenm/2 precomputes a box shared key for a PK/SK keypair
%% @doc box_beforenm/2 precomputes a box shared key for a PK/SK key pair
%% @end
-spec box_beforenm(PK, SK) -> binary()
when
Expand Down Expand Up @@ -650,7 +650,7 @@ sign_SECRETBYTES() ->
sign_SEEDBYTES() ->
enacl_nif:crypto_sign_SEEDBYTES().

%% @doc sign_keypair/0 returns a signature keypair for signing
%% @doc sign_keypair/0 returns a signature key pair for signing
%%
%% The returned value is a map in order to make it harder to misuse keys.
%% @end
Expand All @@ -659,7 +659,7 @@ sign_keypair() ->
{PK, SK} = enacl_nif:crypto_sign_keypair(),
#{ public => PK, secret => SK}.

%% @doc sign_seed_keypair/1 returns a signature keypair based on seed for signing
%% @doc sign_seed_keypair/1 returns a signature key pair based on seed for signing
%%
%% The returned value is a map in order to make it harder to misuse keys.
%% @end
Expand Down Expand Up @@ -769,7 +769,7 @@ box_SECRETKEYBYTES() ->
%% @doc seal_box/2 encrypts an anonymous message to another party.
%%
%% Encrypt a `Msg' to a party using his public key, `PK'. This generates an ephemeral
%% keypair and then uses `box'. Ephemeral public key will sent to other party. Returns the
%% key pair and then uses `box'. Ephemeral public key will sent to other party. Returns the
%% enciphered message `SealedCipherText' which includes ephemeral public key at head.
%% @end
-spec box_seal(Msg, PK) -> SealedCipherText
Expand Down Expand Up @@ -998,7 +998,7 @@ auth(Msg, Key) ->
%% @doc auth_verify/3 verifies an authenticator for a message
%%
%% Given an `Authenticator', a `Msg' and a `Key'; verify that the MAC for the pair `{Msg, Key}' is really `Authenticator'. Returns
%% the value `true' if the verfication passes. Upon failure, the function returns `false'.
%% the value `true' if the verification passes. Upon failure, the function returns `false'.
%% @end
-spec auth_verify(Authenticator, Msg, Key) -> boolean()
when
Expand Down Expand Up @@ -1048,7 +1048,7 @@ shorthash(Msg, Key) ->
%% @doc onetime_auth/2 produces a ONE-TIME authenticator for a message
%%
%% This function works like {@link auth/2} except that the key must not be used again for subsequent messages. That is, the pair
%% `{Msg, Key}' is unique and only to be used once. The advantage is noticably faster execution.
%% `{Msg, Key}' is unique and only to be used once. The advantage is noticeably faster execution.
%% @end
-spec onetime_auth(Msg, Key) -> Authenticator
when
Expand Down Expand Up @@ -1124,7 +1124,7 @@ curve25519_scalarmult_base(Secret) ->

%% Ed 25519 Crypto
%% ---------------
%% @doc crypto_sign_ed25519_keypair/0 creates a new Ed 25519 Public/Secret keypair.
%% @doc crypto_sign_ed25519_keypair/0 creates a new Ed 25519 Public/Secret key pair.
%%
%% Generates and returns a new key pair for the Ed 25519 signature scheme. The return value is a
%% map in order to avoid using the public key as a secret key and vice versa.
Expand Down Expand Up @@ -1170,7 +1170,7 @@ crypto_sign_ed25519_secret_size() ->

%% Key exchange functions
%% ----------------------
%% @doc kx_keypair/0 creates a new Public/Secret keypair.
%% @doc kx_keypair/0 creates a new Public/Secret key pair.
%%
%% Generates and returns a new key pair for the key exchange. The return value is a
%% map in order to avoid using the public key as a secret key and vice versa.
Expand Down
2 changes: 1 addition & 1 deletion src/enacl_ext.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ scramble_block_16(Block, Key) ->

%% Curve 25519 Crypto
%% ------------------
%% @doc curve25519_keypair/0 creates a new Public/Secret keypair.
%% @doc curve25519_keypair/0 creates a new Public/Secret key pair.
%%
%% Generates and returns a new key pair for the Curve 25519 encryption scheme. The return value is a
%% map in order to avoid using the public key as a secret key and vice versa.
Expand Down