View Source fast_scram (fast_scram v0.6.1)

SCRAM implementation, see the README for details.

Summary

Types

Configuration for SCRAM, see the README for details.

See client-final-message and server-final-message at https://datatracker.ietf.org/doc/html/rfc5802#section-7.

Callback to extract the configuration given a username.

Supported underlying hashing algorithms.

Username for the algorithm.

Types

auth_data/0

-type auth_data() :: #{auth_keys() => binary()}.

auth_keys/0

-type auth_keys() :: password | salted_password | client_key | stored_key | server_key.

challenge/0

-type challenge() :: #challenge{salt :: binary(), it_count :: pos_integer()}.

channel_binding/0

-type channel_binding() :: #channel_binding{variant :: fast_scram:plus_variant(), data :: binary()}.

configuration/0

-type configuration() :: #{entity := client | server, hash_method := sha_type(), _ => _}.

Configuration for SCRAM, see the README for details.

definitions/0

-type definitions() ::
          #scram_definitions{hash_method :: fast_scram:sha_type(),
                             salted_password :: binary(),
                             client_key :: binary(),
                             stored_key :: binary(),
                             auth_message :: binary(),
                             client_signature :: binary(),
                             client_proof :: binary(),
                             server_key :: binary(),
                             server_signature :: binary()}.

error_message/0

-type error_message() :: binary().

See server-error-message at https://datatracker.ietf.org/doc/html/rfc5802#section-7.

final_message/0

-type final_message() :: binary().

See client-final-message and server-final-message at https://datatracker.ietf.org/doc/html/rfc5802#section-7.

next_message/0

-type next_message() :: binary().

nonce/0

-type nonce() :: #nonce{client :: binary(), server :: binary()}.

See c-nonce and s-nonce at https://datatracker.ietf.org/doc/html/rfc5802#section-7.

plus_variant/0

-type plus_variant() :: undefined | none | binary().

retrieve_mechanism/0

-type retrieve_mechanism() ::
          fun((username()) -> configuration()) |
          fun((username(), state()) -> {configuration(), state()}).

Callback to extract the configuration given a username.

Required for the server.

sha_type/0

-type sha_type() :: crypto:sha1() | crypto:sha2().

Supported underlying hashing algorithms.

state/0

-type state() ::
          #fast_scram_state{step :: 1..6,
                            nonce :: fast_scram:nonce(),
                            challenge :: fast_scram:challenge(),
                            channel_binding :: fast_scram:channel_binding(),
                            scram_definitions :: fast_scram:definitions(),
                            data :: map()}.

username/0

-type username() :: binary().

Username for the algorithm.

Required for a client.

username_to_config/0

-type username_to_config() :: fun((username()) -> configuration()).

username_to_state/0

-type username_to_state() :: fun((username(), state()) -> {configuration(), state()}).

Functions

client_key(Sha, SaltedPassword)

-spec client_key(sha_type(), binary()) -> binary().

client_proof(ClientKey, ClientSignature)

-spec client_proof(binary(), binary()) -> binary().

client_signature(Sha, StoredKey, AuthMessage)

-spec client_signature(sha_type(), binary(), binary()) -> binary().

hi(Hash, Password, Salt, IterationCount)

-spec hi(sha_type(), binary(), binary(), non_neg_integer()) -> binary().

See Hi(str, salt, i) at https://datatracker.ietf.org/doc/html/rfc5802#section-2.2

mech_get(Key, Fast_scram_state)

-spec mech_get(term(), state()) -> term().

mech_get(Key, Fast_scram_state, Default)

-spec mech_get(term(), state(), term()) -> term().

mech_new(Config)

-spec mech_new(configuration()) -> {ok, state()} | {error, term()}.

mech_set(Key, Value, Fast_scram_state)

-spec mech_set(term(), term(), state()) -> state().

mech_step(Fast_scram_state, ServerIn)

-spec mech_step(state(), binary()) ->
                   {ok, final_message(), state()} |
                   {continue, next_message(), state()} |
                   {error, error_message(), state()}.

salted_password(Sha, Password, Salt, IterationCount)

-spec salted_password(sha_type(), binary(), binary(), non_neg_integer()) -> binary().

server_key(Sha, SaltedPassword)

-spec server_key(sha_type(), binary()) -> binary().

server_signature(Sha, ServerKey, AuthMessage)

-spec server_signature(sha_type(), binary(), binary()) -> binary().

stored_key(Sha, ClientKey)

-spec stored_key(sha_type(), binary()) -> binary().