diff options
author | Frank Denis | 2025-03-12 00:54:35 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2025-03-12 20:43:23 +0100 |
commit | d5d26d75247d4fcc269cd0494cb85c7e62618c89 (patch) | |
tree | 5b1409763bf2b03fdbf859e3169732157e704615 /internal/stupidgcm/aegis.go | |
parent | e3e76e275d8edf294a4a64897f44a5ef0b70bfeb (diff) |
Move aegis out of stupidgcm
Diffstat (limited to 'internal/stupidgcm/aegis.go')
-rw-r--r-- | internal/stupidgcm/aegis.go | 57 |
1 files changed, 0 insertions, 57 deletions
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() -} |