From 84e9f37c963fb6251b65b7bd3dbf3879aa072323 Mon Sep 17 00:00:00 2001 From: Alex Bykov Date: Sat, 19 Nov 2022 22:36:17 +0100 Subject: [PATCH] reconsider weird salting --- impl_aes256.go | 13 ++++++------- impl_none.go | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/impl_aes256.go b/impl_aes256.go index ddf7084..bb9979d 100644 --- a/impl_aes256.go +++ b/impl_aes256.go @@ -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 @@ -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 { @@ -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] diff --git a/impl_none.go b/impl_none.go index ea8c03e..5a47bcf 100644 --- a/impl_none.go +++ b/impl_none.go @@ -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 } @@ -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 }