diff options
author | Corey Hulen <corey@hulen.com> | 2015-07-06 11:24:06 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-07-06 11:24:06 -0800 |
commit | 3dec509899f60ca0d2eadfcc192ccc49969852ef (patch) | |
tree | a86552979d6fab4dbe336171ade9d3e69b64fff0 /store/sql_store.go | |
parent | 10b625ba1740c6177cfe5c06484f4a14867523bd (diff) | |
parent | 34fb817a4a4cd2761ba35a2c94f9d0eb79d06244 (diff) | |
download | chat-3dec509899f60ca0d2eadfcc192ccc49969852ef.tar.gz chat-3dec509899f60ca0d2eadfcc192ccc49969852ef.tar.bz2 chat-3dec509899f60ca0d2eadfcc192ccc49969852ef.zip |
Merge pull request #131 from mattermost/mm-1391
Fixes mm-1391 adding travis CI
Diffstat (limited to 'store/sql_store.go')
-rw-r--r-- | store/sql_store.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/store/sql_store.go b/store/sql_store.go index bef8b4867..a0a1a9f23 100644 --- a/store/sql_store.go +++ b/store/sql_store.go @@ -8,9 +8,9 @@ import ( "crypto/aes" "crypto/cipher" "crypto/hmac" + crand "crypto/rand" "crypto/sha256" "crypto/sha512" - crand "crypto/rand" dbsql "database/sql" "encoding/base64" "encoding/json" @@ -362,21 +362,21 @@ func decrypt(key []byte, cryptoText string) (string, error) { ciphertext, err := base64.URLEncoding.DecodeString(cryptoText) if err != nil { - return "", err + return "", err } skey := sha512.Sum512(key) ekey, akey := skey[:32], skey[32:] macfn := hmac.New(sha256.New, akey) if len(ciphertext) < aes.BlockSize+macfn.Size() { - return "", errors.New("short ciphertext") + return "", errors.New("short ciphertext") } macfn.Write(ciphertext[aes.BlockSize+macfn.Size():]) expectedMac := macfn.Sum(nil) - mac := ciphertext[aes.BlockSize:aes.BlockSize+macfn.Size()] + mac := ciphertext[aes.BlockSize : aes.BlockSize+macfn.Size()] if hmac.Equal(expectedMac, mac) != true { - return "", errors.New("Incorrect MAC for the given ciphertext") + return "", errors.New("Incorrect MAC for the given ciphertext") } block, err := aes.NewCipher(ekey) |