Skip to content

crypto: Add SipHash MAC support#11242

Open
ausimian wants to merge 1 commit into
erlang:masterfrom
ausimian:crypto/siphash
Open

crypto: Add SipHash MAC support#11242
ausimian wants to merge 1 commit into
erlang:masterfrom
ausimian:crypto/siphash

Conversation

@ausimian

Copy link
Copy Markdown
Contributor

Summary

Adds SipHash as a MAC in the crypto application, exposed through the existing
MAC API (crypto:mac/3,4, crypto:macN/4,5, and the streaming
crypto:mac_init/2,3 + mac_update/2 + mac_final/1).

Two algorithm atoms are added, following crypto's size-in-the-name convention
and the SipHash reference implementation's own naming:

Atom Algorithm Key Output
siphash SipHash-2-4 16 bytes 8 bytes
siphash128 SipHash-2-4 16 bytes 16 bytes
1> crypto:mac(siphash, Key, Data).
2> crypto:mac_final(crypto:mac_update(crypto:mac_init(siphash128, Key), Data)).

Design

  • Both variants go through the cryptolib EVP_MAC interface, like the other
    MACs. poly1305 is the closest analog: a key-only MAC with no SubType.
  • The output size is set with the EVP_MAC "size" parameter. siphash128 is
    not a truncation of siphash (they differ in finalization), so the two are
    exposed as separate algorithms rather than derived from each other with
    macN.
  • Requires OpenSSL 3.0 or later. On older cryptolibs the names are absent from
    crypto:supports(macs) and return notsup.

Testing

New crypto_SUITE groups siphash and siphash128 check one-shot and
streaming computation against the SipHash-2-4 reference vectors, with FIPS
negative groups. The existing MACs are unaffected, and Build and check Erlang/OTP passes.

Add the siphash and siphash128 MAC types, available through the
crypto:mac/3,4, crypto:macN/4,5 and the streaming crypto:mac_init/2,3
functions:

    siphash     - SipHash-2-4, 64-bit MAC
    siphash128  - SipHash-2-4, 128-bit MAC

SipHash is a fast keyed MAC widely used for hash-table keying and for
authenticating short messages. Both variants take a 16 byte key and go
through the cryptolib EVP_MAC interface, like the other MACs.

The output size is selected with the EVP_MAC "size" parameter. As
siphash128 is not a truncation of siphash (they differ in finalization),
the two are exposed as separate algorithms rather than derived from each
other with macN.

Requires OpenSSL 3.0.
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

CT Test Results

  2 files   14 suites   5m 5s ⏱️
196 tests 176 ✅  20 💤 0 ❌
484 runs  339 ✅ 145 💤 0 ❌

Results for commit f504609.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@Mikaka27 Mikaka27 self-assigned this Jun 17, 2026
@Mikaka27 Mikaka27 added the team:PS Assigned to OTP team PS label Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team:PS Assigned to OTP team PS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants