diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-01-03 19:04:00 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-02-05 12:59:42 +0100 |
commit | 89d2c5ed7a054bc05a21209d5a9c79ad7151f8f7 (patch) | |
tree | e19022fe717ddfb840599bf68e4c5a9268f8c278 /noise-protocol.go | |
parent | dff424baf8acc4d2a5858d3947761c5090d8e640 (diff) |
Extend structs rather than embed, when possible
Diffstat (limited to 'noise-protocol.go')
-rw-r--r-- | noise-protocol.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/noise-protocol.go b/noise-protocol.go index ff63ce0..c5c6889 100644 --- a/noise-protocol.go +++ b/noise-protocol.go @@ -154,8 +154,8 @@ func init() { func (device *Device) CreateMessageInitiation(peer *Peer) (*MessageInitiation, error) { - device.staticIdentity.mutex.RLock() - defer device.staticIdentity.mutex.RUnlock() + device.staticIdentity.RLock() + defer device.staticIdentity.RUnlock() handshake := &peer.handshake handshake.mutex.Lock() @@ -241,8 +241,8 @@ func (device *Device) ConsumeMessageInitiation(msg *MessageInitiation) *Peer { return nil } - device.staticIdentity.mutex.RLock() - defer device.staticIdentity.mutex.RUnlock() + device.staticIdentity.RLock() + defer device.staticIdentity.RUnlock() mixHash(&hash, &InitialHash, device.staticIdentity.publicKey[:]) mixHash(&hash, &hash, msg.Ephemeral[:]) @@ -423,8 +423,8 @@ func (device *Device) ConsumeMessageResponse(msg *MessageResponse) *Peer { // lock private key for reading - device.staticIdentity.mutex.RLock() - defer device.staticIdentity.mutex.RUnlock() + device.staticIdentity.RLock() + defer device.staticIdentity.RUnlock() // finish 3-way DH @@ -554,8 +554,8 @@ func (peer *Peer) BeginSymmetricSession() error { // rotate key pairs keypairs := &peer.keypairs - keypairs.mutex.Lock() - defer keypairs.mutex.Unlock() + keypairs.Lock() + defer keypairs.Unlock() previous := keypairs.previous next := keypairs.next @@ -586,8 +586,8 @@ func (peer *Peer) ReceivedWithKeypair(receivedKeypair *Keypair) bool { if keypairs.next != receivedKeypair { return false } - keypairs.mutex.Lock() - defer keypairs.mutex.Unlock() + keypairs.Lock() + defer keypairs.Unlock() if keypairs.next != receivedKeypair { return false } |