diff options
author | Jakob Unterwurzacher | 2015-10-03 13:36:49 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2015-10-03 19:16:34 +0200 |
commit | 79870ab0960febcbc82e32d632ed4a9ea99b6f03 (patch) | |
tree | e9af1bb576b40eef5214278e27bcb0fecb20aa3c /cryptfs/cryptfs_content.go | |
parent | 38bf8a2fcfe0b7260c08d49ed04c9667871f0992 (diff) |
debug: log inode number instead of encrypted filename
Makes the log output smaller and more readable.
Diffstat (limited to 'cryptfs/cryptfs_content.go')
-rw-r--r-- | cryptfs/cryptfs_content.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/cryptfs/cryptfs_content.go b/cryptfs/cryptfs_content.go index e42011a..a4dc78a 100644 --- a/cryptfs/cryptfs_content.go +++ b/cryptfs/cryptfs_content.go @@ -7,8 +7,22 @@ import ( "os" "errors" "crypto/cipher" + "crypto/md5" + "encoding/hex" ) +const ( + // A block of 4124 zero bytes has this md5 + ZeroBlockMd5 = "64331af89bd15a987b39855338336237" +) + +// md5sum - debug helper, return md5 hex string +func md5sum(buf []byte) string { + rawHash := md5.Sum(buf) + hash := hex.EncodeToString(rawHash[:]) + return hash +} + type CryptFile struct { file *os.File gcm cipher.AEAD @@ -55,6 +69,7 @@ func (be *CryptFS) DecryptBlock(ciphertext []byte) ([]byte, error) { // Extract nonce nonce := ciphertext[:NONCE_LEN] + ciphertextOrig := ciphertext ciphertext = ciphertext[NONCE_LEN:] // Decrypt @@ -63,7 +78,7 @@ func (be *CryptFS) DecryptBlock(ciphertext []byte) ([]byte, error) { plaintext, err := be.gcm.Open(plaintext, nonce, ciphertext, nil) if err != nil { - Warn.Printf("DecryptBlock: %s\n", err.Error()) + Warn.Printf("DecryptBlock: %s, len=%d, md5=%s\n", err.Error(), len(ciphertextOrig), Warn.Md5sum(ciphertextOrig)) return nil, err } |