aboutsummaryrefslogtreecommitdiff
path: root/internal/configfile
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-08-23 22:10:23 +0200
committerJakob Unterwurzacher2021-08-23 22:10:23 +0200
commit806334eacf2e50d712844761aca2b11014ec99df (patch)
tree5d531146e92f7770a02e03107afdcb2fcc7a0ab1 /internal/configfile
parentb12ad292d4dfef1c00567fe3def7e73461d3c217 (diff)
cryptocore: add NonceSize to AEADTypeEnum
Have the information in one centralized place, and access it from main as needed.
Diffstat (limited to 'internal/configfile')
-rw-r--r--internal/configfile/config_file.go15
1 files changed, 15 insertions, 0 deletions
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
+}