github.com/opentofu/opentofu@v1.7.1/internal/encryption/method/aesgcm/descriptor.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package aesgcm 7 8 import ( 9 "github.com/opentofu/opentofu/internal/encryption/keyprovider" 10 "github.com/opentofu/opentofu/internal/encryption/method" 11 ) 12 13 // Descriptor integrates the method.Descriptor and provides a TypedConfig for easier configuration. 14 type Descriptor interface { 15 method.Descriptor 16 17 // TypedConfig returns a config typed for this method. 18 TypedConfig() *Config 19 } 20 21 // New creates a new descriptor for the AES-GCM encryption method, which requires a 32-byte key. 22 func New() Descriptor { 23 return &descriptor{} 24 } 25 26 type descriptor struct { 27 } 28 29 func (f *descriptor) TypedConfig() *Config { 30 return &Config{ 31 Keys: keyprovider.Output{}, 32 AAD: nil, 33 } 34 } 35 36 func (f *descriptor) ID() method.ID { 37 return "aes_gcm" 38 } 39 40 func (f *descriptor) ConfigStruct() method.Config { 41 return f.TypedConfig() 42 }