Skip to content

add support for AES-128-GCM and ChaCha20Poly1305 with 128 bit keys#58

Merged
aead merged 1 commit into
masterfrom
aes128
Apr 29, 2026
Merged

add support for AES-128-GCM and ChaCha20Poly1305 with 128 bit keys#58
aead merged 1 commit into
masterfrom
aes128

Conversation

@aead

@aead aead commented Apr 28, 2026

Copy link
Copy Markdown
Member

This commit adds support for AES-128-GCM.
Therefore, this commit changes the public API constant AES_256_GCM to AES_GCM.

When a 128 bit key is provided, AES-GCM is instantiated as AES-128-GCM and for ChaCha20Poly1305, the 128 bit key is simply repeated to make it 256 bit long.

For AES-GCM, this gives a 10% performance improvment.

goos: darwin
goarch: arm64
pkg: github.com/minio/sio
cpu: Apple M4
                     │ /tmp/old.txt │            /tmp/new.txt            │
                     │    sec/op    │    sec/op     vs base              │
DecryptReader_1MB-10   3.064m ± ∞     2.778m ± ∞    -9.32% (p=0.029 n=4)

                     │ /tmp/old.txt  │             /tmp/new.txt             │
                     │      B/s      │      B/s       vs base               │
DecryptReader_1MB-10   15.94Gi ± ∞     17.58Gi ± ∞    +10.28% (p=0.029 n=4)

                     │ /tmp/old.txt  │          /tmp/new.txt          │
                     │     B/op      │     B/op       vs base         │
DecryptReader_1MB-10   15.92Ki ± ∞     15.76Ki ± ∞    ~ (p=0.200 n=4)

                     │ /tmp/old.txt │          /tmp/new.txt          │
                     │  allocs/op   │  allocs/op   vs base           │
DecryptReader_1MB-10    813.0 ± ∞     813.0 ± ∞    ~ (p=1.000 n=4)

@aead aead requested review from shtripat and vadmeste April 28, 2026 12:45
@aead aead force-pushed the aes128 branch 2 times, most recently from 35458b1 to b4decd7 Compare April 28, 2026 12:52

@shtripat shtripat left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@klauspost klauspost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread sio.go
This commit adds support for AES-128-GCM.
Therefore, this commit changes the public API constant
`AES_256_GCM` to `AES_GCM`.

When a 128 bit key is provided, AES-GCM is instantiated as AES-128-GCM
and for ChaCha20Poly1305, the 128 bit key is simply repeated to make
it 256 bit long.

For AES-GCM, this gives a 10% performance improvment.
```
goos: darwin
goarch: arm64
pkg: github.com/minio/sio
cpu: Apple M4
                     │ /tmp/old.txt │            /tmp/new.txt            │
                     │    sec/op    │    sec/op     vs base              │
DecryptReader_1MB-10   3.064m ± ∞     2.778m ± ∞    -9.32% (p=0.029 n=4)

                     │ /tmp/old.txt  │             /tmp/new.txt             │
                     │      B/s      │      B/s       vs base               │
DecryptReader_1MB-10   15.94Gi ± ∞     17.58Gi ± ∞    +10.28% (p=0.029 n=4)

                     │ /tmp/old.txt  │          /tmp/new.txt          │
                     │     B/op      │     B/op       vs base         │
DecryptReader_1MB-10   15.92Ki ± ∞     15.76Ki ± ∞    ~ (p=0.200 n=4)

                     │ /tmp/old.txt │          /tmp/new.txt          │
                     │  allocs/op   │  allocs/op   vs base           │
DecryptReader_1MB-10    813.0 ± ∞     813.0 ± ∞    ~ (p=1.000 n=4)
```

Signed-off-by: Andreas Auernhammer <git@aead.dev>
@aead aead merged commit 9cd8da7 into master Apr 29, 2026
6 checks passed
@aead aead deleted the aes128 branch April 29, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants