Random identifiers and hex encoding for TURN credential challenges.
What problem this solves
Long-term STUN/TURN authentication needs unpredictable nonces and usernames on the wire. This module produces lowercase hex strings from cryptographically random bytes and time-prefixed nonce material without an external UUID library.
Internal: called by Auth.NonceStore and Auth.Client during credential
provisioning and 401 challenge issuance.
RFCs
Summary
Functions
Returns 32 lowercase hex characters from 16 cryptographically random bytes.
Maps a nibble (0-15) to its lowercase hex ASCII code.
Hex-encodes a binary, byte list, or empty list to lowercase ASCII char codes.
Returns a time-prefixed nonce binary for credential challenges.
Functions
Returns 32 lowercase hex characters from 16 cryptographically random bytes.
Maps a nibble (0-15) to its lowercase hex ASCII code.
Parameters
n- integer from0to15
Examples
iex> Xirsys.XTurn.Auth.UUID.to_digit(9)
57
iex> Xirsys.XTurn.Auth.UUID.to_digit(10)
97
Hex-encodes a binary, byte list, or empty list to lowercase ASCII char codes.
Examples
iex> Xirsys.XTurn.Auth.UUID.to_hex(<<0xAB, 0x0C>>)
~c"ab0c"
iex> Xirsys.XTurn.Auth.UUID.to_hex([])
[]
Returns a time-prefixed nonce binary for credential challenges.
The prefix is 14 uppercase hex digits of microseconds since the Unix epoch, followed by 18 lowercase hex characters from 9 random bytes.