postgleam/auth/scram

Types

State maintained across SCRAM message exchanges

pub type ScramState {
  ScramState(
    client_nonce: String,
    salt: BitArray,
    iterations: Int,
    auth_message: String,
    client_key: BitArray,
    server_key: BitArray,
  )
}

Constructors

  • ScramState(
      client_nonce: String,
      salt: BitArray,
      iterations: Int,
      auth_message: String,
      client_key: BitArray,
      server_key: BitArray,
    )

Values

pub fn client_final(
  server_first: BitArray,
  client_first_bare: String,
  password: String,
) -> Result(#(BitArray, ScramState), String)

Process the server-first message and produce the client-final message. Returns (client_final_bytes, scram_state) or an error.

pub fn client_first() -> #(String, BitArray)

Generate the client-first message for SCRAM-SHA-256 auth. Returns (mechanism, initial_response_data)

pub fn extract_client_first_bare(
  client_first_data: BitArray,
) -> Result(String, Nil)

Extract the client-first-bare from a client-first message. The client-first message is “n,,n=,r=” — the bare part is “n=,r=

pub fn verify_server(
  server_final: BitArray,
  state: ScramState,
) -> Result(Nil, String)

Verify the server-final message

Search Document