From d5d26d75247d4fcc269cd0494cb85c7e62618c89 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 12 Mar 2025 00:54:35 +0100 Subject: Move aegis out of stupidgcm --- internal/stupidgcm/aegis.go | 57 --------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 internal/stupidgcm/aegis.go (limited to 'internal/stupidgcm/aegis.go') diff --git a/internal/stupidgcm/aegis.go b/internal/stupidgcm/aegis.go deleted file mode 100644 index 8975055..0000000 --- a/internal/stupidgcm/aegis.go +++ /dev/null @@ -1,57 +0,0 @@ -//go:build !without_aegis && cgo -// +build !without_aegis,cgo - -package stupidgcm - -import ( - "crypto/cipher" - "log" - - "github.com/aegis-aead/go-libaegis/aegis128x2" - "github.com/aegis-aead/go-libaegis/common" -) - -const ( - // BuiltWithoutAegis indicates if aegis been disabled at compile-time - BuiltWithoutAegis = !common.Available - - // Aegis supports 16 and 32 bit tags - AegisTagLen = 16 -) - -type stupidAegis struct { - aead cipher.AEAD -} - -// Verify that we satisfy the cipher.AEAD interface -var _ cipher.AEAD = &stupidAegis{} - -func (*stupidAegis) NonceSize() int { - return aegis128x2.NonceSize -} - -func (*stupidAegis) Overhead() int { - return AegisTagLen -} - -func NewAegis(key []byte) cipher.AEAD { - aead, err := aegis128x2.New(key, AegisTagLen) - if err != nil { - log.Panic(err) - } - return &stupidAegis{ - aead: aead, - } -} - -func (x *stupidAegis) Seal(dst, nonce, plaintext, additionalData []byte) []byte { - return x.aead.Seal(dst, nonce, plaintext, additionalData) -} - -func (x *stupidAegis) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error) { - return x.aead.Open(dst, nonce, ciphertext, additionalData) -} - -func (x *stupidAegis) Wipe() { - x.aead.(*aegis128x2.Aegis128X2).Wipe() -} -- cgit v1.2.3