Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create fingerprint() method and display its results #147

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions client/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ func (c *cliClient) showIdentity() {
heading: "Identity",
rows: []cliRow{
cliRow{cols: []string{"Server", terminalEscape(c.server, false)}},
cliRow{cols: []string{"Fingerprint", fmt.Sprintf("%d", c.fingerprint())}},
cliRow{cols: []string{"Public identity", fmt.Sprintf("%x", c.identityPublic[:])}},
cliRow{cols: []string{"Public key", fmt.Sprintf("%x", c.pub[:])}},
cliRow{cols: []string{"State file", terminalEscape(c.stateFilename, false)}},
Expand Down Expand Up @@ -1858,9 +1859,10 @@ func (c *cliClient) showContact(contact *Contact) {
rows: []cliRow{
cliRow{cols: []string{"Name", terminalEscape(contact.name, false)}},
cliRow{cols: []string{"Server", terminalEscape(contact.theirServer, false)}},
cliRow{cols: []string{"Generation", fmt.Sprintf("%d", contact.generation)}},
cliRow{cols: []string{"Fingerprint", fmt.Sprintf("%d", contact.fingerprint())}},
cliRow{cols: []string{"Public Identity key", fmt.Sprintf("%x", contact.theirIdentityPublic[:])}},
cliRow{cols: []string{"Public key", fmt.Sprintf("%x", contact.theirPub[:])}},
cliRow{cols: []string{"Identity key", fmt.Sprintf("%x", contact.theirIdentityPublic[:])}},
cliRow{cols: []string{"Generation", fmt.Sprintf("%d", contact.generation)}},
cliRow{cols: []string{"Client version", fmt.Sprintf("%d", contact.supportedVersion)}},
},
}
Expand Down
9 changes: 9 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,15 @@ type Contact struct {
cliId cliId
}

func (contact *Contact) fingerprint() []byte {
if contact.isPending { return []byte{} }
return fingerprint(contact.theirPub[:],contact.theirIdentityPublic[:],nil)
}

func (c *client) fingerprint() []byte {
return fingerprint(c.pub[:],c.identityPublic[:],nil)
}

// Event represents a log entry. This does not apply to the global log, which
// is quite chatty, but rather to significant events related to a given
// contact. These events are surfaced in the UI and recorded in the statefile.
Expand Down
23 changes: 18 additions & 5 deletions client/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,7 @@ func nameValuesLHS(entries []nvEntry) Grid {
func (c *guiClient) identityUI() interface{} {
entries := nameValuesLHS([]nvEntry{
{"SERVER", c.server},
{"FINGERPRINT", fmt.Sprintf("%x", c.fingerprint())},
{"PUBLIC IDENTITY", fmt.Sprintf("%x", c.identityPublic[:])},
{"PUBLIC KEY", fmt.Sprintf("%x", c.pub[:])},
{"STATE FILE", c.stateFilename},
Expand Down Expand Up @@ -2048,6 +2049,13 @@ func (c *guiClient) identityUI() interface{} {
panic("unreachable")
}

func allBytesZero(bs []byte) bool {
for _,b := range bs {
if b != 0 { return false }
}
return true
}

func (c *guiClient) showContact(id uint64) interface{} {
contact := c.contacts[id]
if contact.isPending && len(contact.pandaKeyExchange) == 0 && len(contact.pandaResult) == 0 {
Expand All @@ -2058,13 +2066,18 @@ func (c *guiClient) showContact(id uint64) interface{} {
entries := []nvEntry{
{"NAME", ""},
{"SERVER", contact.theirServer},
{"PUBLIC IDENTITY", fmt.Sprintf("%x", contact.theirIdentityPublic[:])},
{"FINGERPRINT", fmt.Sprintf("%x", contact.fingerprint())},
{"PUBLIC IDENTITY KEY", fmt.Sprintf("%x", contact.theirIdentityPublic[:])},
{"PUBLIC KEY", fmt.Sprintf("%x", contact.theirPub[:])},
{"LAST DH", fmt.Sprintf("%x", contact.theirLastDHPublic[:])},
{"CURRENT DH", fmt.Sprintf("%x", contact.theirCurrentDHPublic[:])},
{"GROUP GENERATION", fmt.Sprintf("%d", contact.generation)},
{"CLIENT VERSION", fmt.Sprintf("%d", contact.supportedVersion)},
}
if ! allBytesZero(contact.theirLastDHPublic[:]) {
entries = append(entries,
nvEntry{"LAST DH", fmt.Sprintf("%x", contact.theirLastDHPublic[:])},
nvEntry{"CURRENT DH", fmt.Sprintf("%x", contact.theirCurrentDHPublic[:])} )
}
entries = append(entries,
nvEntry{"GROUP GENERATION", fmt.Sprintf("%d", contact.generation)},
nvEntry{"CLIENT VERSION", fmt.Sprintf("%d", contact.supportedVersion)} )

var pandaMessage string

Expand Down
9 changes: 9 additions & 0 deletions client/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ func tooLarge(msg *queuedMessage) bool {
return len(messageBytes) > pond.MaxSerializedMessage
}

func fingerprint(a,b,c []byte) []byte {
sha := sha256.New()
sha.Write(a)
sha.Write(b)
digest := sha.Sum(c)
sha.Reset()
return digest
}

// processSigningRequest is run on the main goroutine in response to a request
// from the network thread to apply a group signature to a message that is just
// about to be sent to the destination server.
Expand Down