Skip to content

Commit

Permalink
Rename enctype in encstring
Browse files Browse the repository at this point in the history
  • Loading branch information
quexten committed Jan 9, 2024
1 parent 63ca3f2 commit efa509f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions agent/bitwarden/crypto/encstring.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func DecryptWith(s EncString, key SymmetricEncryptionKey) ([]byte, error) {
return dst, nil
}

func EncryptWith(data []byte, typ EncStringType, key SymmetricEncryptionKey) (EncString, error) {
func EncryptWith(data []byte, encType EncStringType, key SymmetricEncryptionKey) (EncString, error) {
encKeyData, err := key.EncryptionKeyBytes()
if err != nil {
return EncString{}, err
Expand All @@ -183,12 +183,12 @@ func EncryptWith(data []byte, typ EncStringType, key SymmetricEncryptionKey) (En
}

s := EncString{}
switch typ {
switch encType {
case AesCbc256_B64, AesCbc256_HmacSha256_B64:
default:
return s, fmt.Errorf("encrypt: unsupported cipher type %q", s.Type)
}
s.Type = typ
s.Type = encType
data = padPKCS7(data, aes.BlockSize)

block, err := aes.NewCipher(encKeyData)
Expand All @@ -203,7 +203,7 @@ func EncryptWith(data []byte, typ EncStringType, key SymmetricEncryptionKey) (En
mode := cipher.NewCBCEncrypter(block, s.IV)
mode.CryptBlocks(s.CT, data)

if typ == AesCbc256_HmacSha256_B64 {
if encType == AesCbc256_HmacSha256_B64 {
if len(macKeyData) == 0 {
return s, fmt.Errorf("encrypt: cipher string type expects a MAC")
}
Expand Down

0 comments on commit efa509f

Please sign in to comment.