Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark new AES functions experimental #1417

Merged
merged 1 commit into from
Jun 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs-src/content/functions/crypto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ funcs:
$ gomplate -i '{{ crypto.Bcrypt 4 "foo" }}
$2a$04$zjba3N38sjyYsw0Y7IRCme1H4gD0MJxH8Ixai0/sgsrf7s1MFUK1C
- name: crypto.DecryptAES
experimental: true
description: |
Decrypts the given input using the given key. By default,
uses AES-256-CBC, but supports 128- and 192-bit keys as well.
Expand Down Expand Up @@ -55,6 +56,7 @@ funcs:
$ gomplate -i '{{ base64.Decode "Gp2WG/fKOUsVlhcpr3oqgR+fRUNBcO1eZJ9CW+gDI18=" | crypto.DecryptAES "swordfish" 128 }}'
hello world
- name: crypto.DecryptAESBytes
experimental: true
description: |
Decrypts the given input using the given key. By default,
uses AES-256-CBC, but supports 128- and 192-bit keys as well.
Expand All @@ -81,6 +83,7 @@ funcs:
$ gomplate -i '{{ base64.Decode "Gp2WG/fKOUsVlhcpr3oqgR+fRUNBcO1eZJ9CW+gDI18=" | crypto.DecryptAES "swordfish" 128 }}'
hello world
- name: crypto.EncryptAES
experimental: true
description: |
Encrypts the given input using the given key. By default,
uses AES-256-CBC, but supports 128- and 192-bit keys as well.
Expand Down
15 changes: 12 additions & 3 deletions docs/content/functions/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ $ gomplate -i '{{ crypto.Bcrypt 4 "foo" }}
$2a$04$zjba3N38sjyYsw0Y7IRCme1H4gD0MJxH8Ixai0/sgsrf7s1MFUK1C
```

## `crypto.DecryptAES`
## `crypto.DecryptAES` _(experimental)_
**Experimental:** This function is [_experimental_][experimental] and may be enabled with the [`--experimental`][experimental] flag.

[experimental]: ../config/#experimental

Decrypts the given input using the given key. By default,
uses AES-256-CBC, but supports 128- and 192-bit keys as well.
Expand Down Expand Up @@ -82,7 +85,10 @@ $ gomplate -i '{{ base64.Decode "Gp2WG/fKOUsVlhcpr3oqgR+fRUNBcO1eZJ9CW+gDI18=" |
hello world
```

## `crypto.DecryptAESBytes`
## `crypto.DecryptAESBytes` _(experimental)_
**Experimental:** This function is [_experimental_][experimental] and may be enabled with the [`--experimental`][experimental] flag.

[experimental]: ../config/#experimental

Decrypts the given input using the given key. By default,
uses AES-256-CBC, but supports 128- and 192-bit keys as well.
Expand Down Expand Up @@ -118,7 +124,10 @@ $ gomplate -i '{{ base64.Decode "Gp2WG/fKOUsVlhcpr3oqgR+fRUNBcO1eZJ9CW+gDI18=" |
hello world
```

## `crypto.EncryptAES`
## `crypto.EncryptAES` _(experimental)_
**Experimental:** This function is [_experimental_][experimental] and may be enabled with the [`--experimental`][experimental] flag.

[experimental]: ../config/#experimental

Encrypts the given input using the given key. By default,
uses AES-256-CBC, but supports 128- and 192-bit keys as well.
Expand Down
15 changes: 15 additions & 0 deletions funcs/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,12 @@ func (f *CryptoFuncs) ECDSADerivePublicKey(privateKey string) (string, error) {
}

// EncryptAES -
// Experimental!
func (f *CryptoFuncs) EncryptAES(key string, args ...interface{}) ([]byte, error) {
if err := checkExperimental(f.ctx); err != nil {
return nil, err
}

k, msg, err := parseAESArgs(key, args...)
if err != nil {
return nil, err
Expand All @@ -299,13 +304,23 @@ func (f *CryptoFuncs) EncryptAES(key string, args ...interface{}) ([]byte, error
}

// DecryptAES -
// Experimental!
func (f *CryptoFuncs) DecryptAES(key string, args ...interface{}) (string, error) {
if err := checkExperimental(f.ctx); err != nil {
return "", err
}

out, err := f.DecryptAESBytes(key, args...)
return conv.ToString(out), err
}

// DecryptAESBytes -
// Experimental!
func (f *CryptoFuncs) DecryptAESBytes(key string, args ...interface{}) ([]byte, error) {
if err := checkExperimental(f.ctx); err != nil {
return nil, err
}

k, msg, err := parseAESArgs(key, args...)
if err != nil {
return nil, err
Expand Down