Files
wireguard-go/src/keypair.go
Mathias Hall-Andersen 44c9896883 Added replay protection
2017-07-10 12:09:19 +02:00

32 lines
517 B
Go

package main
import (
"crypto/cipher"
"sync"
"time"
)
type KeyPair struct {
receive cipher.AEAD
replayFilter ReplayFilter
send cipher.AEAD
sendNonce uint64
isInitiator bool
created time.Time
localIndex uint32
remoteIndex uint32
}
type KeyPairs struct {
mutex sync.RWMutex
current *KeyPair
previous *KeyPair
next *KeyPair // not yet "confirmed by transport"
}
func (kp *KeyPairs) Current() *KeyPair {
kp.mutex.RLock()
defer kp.mutex.RUnlock()
return kp.current
}