Skip to content

Commit

Permalink
reconsider weird salting
Browse files Browse the repository at this point in the history
  • Loading branch information
bykovme committed Nov 19, 2022
1 parent 3a19afe commit 84e9f37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 6 additions & 7 deletions impl_aes256.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import (
const cCryptIDAES25601 = "8GA63DMN"
const cAES256TextDescription = "AES256V1"
const cAESKeyLength = 32 // AES-256
const cPassSalt = "DJLiw3;!"
const cLoops = 32768 // Increase it with computer power
const cLoops = 32768 // Increase it with computer power

type cipherAES256 struct {
passwordKey []byte
Expand Down Expand Up @@ -46,11 +45,11 @@ func (cipher256 *cipherAES256) SetPassword(password string) (err error) {
}

func (cipher256 *cipherAES256) makePasswordKey(password string) (keyDataOut []byte) {
passWithSalt := password + cPassSalt
for len(passWithSalt) < cAESKeyLength {
passWithSalt += passWithSalt

for len(password) < cAESKeyLength {
password += password
}
return []byte(passWithSalt)
return []byte(password)
}

func (cipher256 *cipherAES256) GetPasswordKey() []byte {
Expand Down Expand Up @@ -163,7 +162,7 @@ func (cipher256 *cipherAES256) DecryptBIN(dataIn []byte) (dataOut []byte, err er

if len(dataIn) < aes.BlockSize {
cipher256.cachedFinalKey = nil // Clear cache in case of failure
return nil, errors.New("Cipher text is too short for AES")
return nil, errors.New("cipher text is too short for AES")
}

iv := dataIn[:aes.BlockSize]
Expand Down
6 changes: 3 additions & 3 deletions impl_none.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ type cypherNONE struct {
func (cypher *cypherNONE) CleanAndInit() {
}

func (cypher cypherNONE) GetCryptID() string {
func (cypher *cypherNONE) GetCryptID() string {
return cryptIDNONE
}

func (cypher cypherNONE) GetCipherName() string {
func (cypher *cypherNONE) GetCipherName() string {
return humanCryptNone
}

Expand All @@ -27,7 +27,7 @@ func (cypher *cypherNONE) SetPasswordKey(passKey []byte) error {
cypher.passwordKey = passKey
return nil
}
func (cypher cypherNONE) IsPasswordSet() bool {
func (cypher *cypherNONE) IsPasswordSet() bool {
return true
}

Expand Down

0 comments on commit 84e9f37

Please sign in to comment.