Skip to content

Commit

Permalink
Merge pull request #73 from skit-ai/fix_get_byte_string
Browse files Browse the repository at this point in the history
Perform Base64 decode of static data key
  • Loading branch information
joelmathew-vai authored Jun 14, 2024
2 parents 921d98c + d2a2ecd commit b0f60fe
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions crypto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"crypto/aes"
"crypto/cipher"
"encoding/base64"
"fmt"
"os"

"github.com/hashicorp/vault/api"
Expand All @@ -24,7 +23,6 @@ var vault_data_key_name string = os.Getenv("VAULT_DATA_KEY_NAME")
var encrypted_data_key string = os.Getenv("ENCRYPTED_DATA_KEY")
var use_static_data_key bool = env.Bool("USE_STATIC_DATA_KEY", false)
var static_data_key string = env.String("STATIC_DATA_KEY", "")
var log_crypto_internal_info bool = env.Bool("LOG_CRYPTO_INTERNAL_INFO", false)

// Other Global Variables

Expand All @@ -37,7 +35,8 @@ func isValidBase64(static_data_key string) bool {
}

func getByteString(static_data_key string) []byte {
return []byte(static_data_key)
data_key_, _ := base64.StdEncoding.DecodeString(static_data_key)
return data_key_
}

// Vault functions
Expand Down Expand Up @@ -158,10 +157,6 @@ func newCipherAESGCMObject(data_key_b64_str string, clientId string) (gcm cipher
data_key = getDataKey(data_key_b64_str, clientId)
}

if log_crypto_internal_info {
fmt.Printf("Data Key obtained - %s", data_key)
}

// Generate new aes cipher using our 32 byte key
c, err := aes.NewCipher(data_key)
if err != nil {
Expand Down

0 comments on commit b0f60fe

Please sign in to comment.