Files
wireguard-go/src/keypair.go
T

38 lines
646 B
Go
Raw Normal View History

2017-06-24 15:34:17 +02:00
package main
import (
"crypto/cipher"
2017-06-26 13:14:02 +02:00
"sync"
2017-06-27 17:33:06 +02:00
"time"
2017-06-24 15:34:17 +02:00
)
type KeyPair struct {
2017-07-10 12:09:19 +02:00
receive cipher.AEAD
replayFilter ReplayFilter
send cipher.AEAD
sendNonce uint64
isInitiator bool
created time.Time
localIndex uint32
remoteIndex uint32
2017-06-26 13:14:02 +02:00
}
type KeyPairs struct {
2017-06-30 14:41:08 +02:00
mutex sync.RWMutex
current *KeyPair
previous *KeyPair
next *KeyPair // not yet "confirmed by transport"
2017-06-26 22:07:29 +02:00
}
func (kp *KeyPairs) Current() *KeyPair {
kp.mutex.RLock()
defer kp.mutex.RUnlock()
return kp.current
2017-06-24 15:34:17 +02:00
}
2017-08-14 17:09:25 +02:00
func (device *Device) DeleteKeyPair(key *KeyPair) {
key.send = nil
key.receive = nil
device.indices.Delete(key.localIndex)
}