From 806334eacf2e50d712844761aca2b11014ec99df Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 23 Aug 2021 22:10:23 +0200 Subject: cryptocore: add NonceSize to AEADTypeEnum Have the information in one centralized place, and access it from main as needed. --- internal/configfile/config_file.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'internal/configfile/config_file.go') diff --git a/internal/configfile/config_file.go b/internal/configfile/config_file.go index dba6c47..c1f93af 100644 --- a/internal/configfile/config_file.go +++ b/internal/configfile/config_file.go @@ -325,3 +325,18 @@ func getKeyEncrypter(scryptHash []byte, useHKDF bool) *contentenc.ContentEnc { ce := contentenc.New(cc, 4096, false) return ce } + +// ContentEncryption tells us which content encryption algorithm is selected +func (cf *ConfFile) ContentEncryption() (algo cryptocore.AEADTypeEnum, err error) { + if err := cf.Validate(); err != nil { + return cryptocore.AEADTypeEnum{}, err + } + if cf.IsFeatureFlagSet(FlagXChaCha20Poly1305) { + return cryptocore.BackendXChaCha20Poly1305, nil + } + if cf.IsFeatureFlagSet(FlagAESSIV) { + return cryptocore.BackendAESSIV, nil + } + // If neither AES-SIV nor XChaCha are selected, we must be using AES-GCM + return cryptocore.BackendGoGCM, nil +} -- cgit v1.2.3