Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dev committed Jan 25, 2024
1 parent 36c6b02 commit 3c5cc4f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
26 changes: 26 additions & 0 deletions encryption_aead/encryption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/bloom42/stdx/crypto/chacha20"
"github.com/bloom42/stdx/crypto/chacha20blake3"
"github.com/bloom42/stdx/crypto/xchacha20sha256"
"github.com/bloom42/stdx/crypto/zchacha20blake3"
"github.com/skerkour/go-benchmarks/utils"
"golang.org/x/crypto/chacha20poly1305"
)
Expand Down Expand Up @@ -56,6 +57,7 @@ func BenchmarkEncryptAEAD(b *testing.B) {
benchmarkEncrypt(b, size, "AES_256_GCM", newAesGcmCipher(b, aes256GcmKey), aes256GcmNonce, additionalData)
benchmarkEncrypt(b, size, "AES_128_GCM", newAesGcmCipher(b, aes128GcmKey), aes128GcmNonce, additionalData)
benchmarkEncrypt(b, size, "BChaCha20_BLAKE3", newBChaCha20Blake3Cipher(b, xChaCha20Key), bChaCha20Nonce, additionalData)
benchmarkEncrypt(b, size, "ZChaCha20_BLAKE3", newZChaCha20Blake3Cipher(b, xChaCha20Key), bChaCha20Nonce, additionalData)
benchmarkEncrypt(b, size, "XChaCha20_SHA256", newXChaCha20Sha256Cipher(b, xChaCha20Key), xChaCha20Nonce, additionalData)
}
}
Expand Down Expand Up @@ -84,6 +86,7 @@ func BenchmarkDecryptAEAD(b *testing.B) {
benchmarkDecrypt(b, size, "AES_256_GCM", newAesGcmCipher(b, aes256GcmKey), aes256GcmNonce, additionalData)
benchmarkDecrypt(b, size, "AES_128_GCM", newAesGcmCipher(b, aes128GcmKey), aes128GcmNonce, additionalData)
benchmarkDecrypt(b, size, "BChaCha20_BLAKE3", newBChaCha20Blake3Cipher(b, xChaCha20Key), bChaCha20Nonce, additionalData)
benchmarkDecrypt(b, size, "ZChaCha20_BLAKE3", newZChaCha20Blake3Cipher(b, xChaCha20Key), bChaCha20Nonce, additionalData)
benchmarkDecrypt(b, size, "XChaCha20_SHA256", newXChaCha20Sha256Cipher(b, xChaCha20Key), xChaCha20Nonce, additionalData)
}
}
Expand Down Expand Up @@ -162,6 +165,29 @@ func (cipher bChaCha20Blake3Cipher) Decrypt(dst, nonce, ciphertext, additionalDa
_, _ = cipher.cipher.Open(dst, nonce, ciphertext, additionalData)
}

type zChaCha20Blake3Cipher struct {
cipher cipher.AEAD
}

func newZChaCha20Blake3Cipher(b *testing.B, key []byte) zChaCha20Blake3Cipher {
cipher, err := zchacha20blake3.New(key)
if err != nil {
b.Error(err)
}

return zChaCha20Blake3Cipher{
cipher: cipher,
}
}

func (cipher zChaCha20Blake3Cipher) Encrypt(dst, nonce, plaintext, additionalData []byte) []byte {
return cipher.cipher.Seal(dst, nonce, plaintext, additionalData)
}

func (cipher zChaCha20Blake3Cipher) Decrypt(dst, nonce, ciphertext, additionalData []byte) {
_, _ = cipher.cipher.Open(dst, nonce, ciphertext, additionalData)
}

type xChaCha20Poly1305Cipher struct {
cipher cipher.AEAD
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
require (
github.com/DataDog/zstd v1.5.5
github.com/akamensky/base58 v0.0.0-20210829145138-ce8bf8802e8f
github.com/bloom42/stdx v0.0.0-20240125071537-f166452c9078
github.com/bloom42/stdx v0.0.0-20240125075028-c2849fb3a76f
github.com/cespare/xxhash/v2 v2.2.0
github.com/golang/snappy v0.0.4
github.com/jotfs/fastcdc-go v0.2.0
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ=
github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/akamensky/base58 v0.0.0-20210829145138-ce8bf8802e8f h1:z8MkSJCUyTmW5YQlxsMLBlwA7GmjxC7L4ooicxqnhz8=
github.com/akamensky/base58 v0.0.0-20210829145138-ce8bf8802e8f/go.mod h1:UdUwYgAXBiL+kLfcqxoQJYkHA/vl937/PbFhZM34aZs=
github.com/bloom42/stdx v0.0.0-20240124120249-bb22673ca845 h1:BrWxBn1TvA47JGwouMnTLQ8PO79UBEDCUbtXlw9QuAw=
github.com/bloom42/stdx v0.0.0-20240124120249-bb22673ca845/go.mod h1:zZWdLGQq1BX7GoDuZZPyyE0WUTy5MmNtPB6+8TB6Mf0=
github.com/bloom42/stdx v0.0.0-20240125071537-f166452c9078 h1:OpeiWgGDbeSUNgd1lOeoKZeXp2ukgtwDHSNiqIYMbEM=
github.com/bloom42/stdx v0.0.0-20240125071537-f166452c9078/go.mod h1:zZWdLGQq1BX7GoDuZZPyyE0WUTy5MmNtPB6+8TB6Mf0=
github.com/bloom42/stdx v0.0.0-20240125075028-c2849fb3a76f h1:CYuhypHgsGcO7Ih0mRlm1b+YkBzh7Awuc0HL1rRFSHM=
github.com/bloom42/stdx v0.0.0-20240125075028-c2849fb3a76f/go.mod h1:zZWdLGQq1BX7GoDuZZPyyE0WUTy5MmNtPB6+8TB6Mf0=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
Expand Down

0 comments on commit 3c5cc4f

Please sign in to comment.