Skip to content

Commit

Permalink
FEATURE: Stores junk data to confuse snoopers
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsnew committed Mar 20, 2013
1 parent 097410a commit 489c07a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion tfh/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io/ioutil"
"kademlia-secure/kademlia"
"math"
"math/rand"
"os"
)
Expand All @@ -29,6 +30,9 @@ func (tfh *TFH) encryptAndStore(filePath, keyFilePath, key string) (returnPath s
encryptedBytes, tk.NumPadBytes = encrypt(fileContents, tk.EncryptKey)

parts := splitBytes(encryptedBytes)
tk.NumRealBytes = len(parts)
numFakeBytes := int(math.Ceil(float64(tk.NumRealBytes) * FAKE_BYTE_RATIO))
parts = addJunk(parts, numFakeBytes)
tk.PartKeys, err = tfh.storeAll(parts)
if err != nil {
return
Expand Down Expand Up @@ -99,10 +103,11 @@ func (tfh *TFH) decryptAndGet(pathToKey string, pathToFile string) (outStr strin
keybytes, _ := hex.DecodeString(key)
tfhkey, _ := unSerialize(keybytes)

bytes, err := tfh.findAll(tfhkey.PartKeys)
allBytes, err := tfh.findAll(tfhkey.PartKeys)
if err != nil {
return
}
bytes := allBytes[:tfhkey.NumRealBytes]
flattened_bytes := flatten(bytes)

decryptBytes := decrypt(flattened_bytes, tfhkey.EncryptKey)
Expand Down
11 changes: 7 additions & 4 deletions tfh/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import (
"encoding/gob"
)

const FAKE_BYTE_RATIO = float64(0.5)

type tfhKey struct {
Hash []byte
EncryptKey []byte
NumPadBytes int
PartKeys [][]byte
Hash []byte
EncryptKey []byte
NumPadBytes int
PartKeys [][]byte
NumRealBytes int
}

func (tfhK tfhKey) serialize() (out []byte, err error) {
Expand Down

0 comments on commit 489c07a

Please sign in to comment.