Skip to content

Commit

Permalink
Allow redownloading messages
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocolacio committed Dec 9, 2018
1 parent d19622c commit 38b6fb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 0 additions & 5 deletions crypto/eecdh.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import(
"golang.org/x/crypto/pbkdf2"
"errors"
"math/big"
"fmt"
)

const(
Expand Down Expand Up @@ -63,8 +62,6 @@ func EncryptMessage(clearText, aesKey, nxt []byte, sid, rid int) (msg *Encrypted
return nil, err
}

fmt.Println(nxt)

// Add PKCS7 padding to clearText
paddedClearText, err := PKCS7Pad(clearText, aes.BlockSize)
if err != nil {
Expand Down Expand Up @@ -157,8 +154,6 @@ func (message *EncryptedMessage) Decrypt(aesKey []byte) (clearText, nextKey []by
return
}

fmt.Println(nxt)

return msg, nxt, err
}

Expand Down
6 changes: 6 additions & 0 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,17 @@ func LatestPrivKey(owner, peer string) (id int) {
}

func UploadPubKey(owner, peer string, pubkey []byte, id int) error {
if _, err := LookupPubKey(owner, peer, id); err == nil {
return nil
}
_, err := db.Exec(`INSERT INTO pubkeys (id, owner, peer, pubkey) VALUES (?, ?, ?, ?)`, id, owner, peer, pubkey)
return err
}

func UploadPrivKey(owner, peer string, privkey []byte, id int) error {
if _, err := LookupPrivKey(owner, peer, id); err == nil {
return nil
}
_, err := db.Exec(`INSERT INTO privkeys (id, owner, peer, privkey) VALUES (?, ?, ?, ?)`, id, owner, peer, privkey)
return err
}

0 comments on commit 38b6fb8

Please sign in to comment.