wireguard-go/src/keypair.go

31 lines
483 B
Go
Raw Normal View History

2017-06-24 13:34:17 +00:00
package main
import (
"crypto/cipher"
2017-06-26 11:14:02 +00:00
"sync"
2017-06-27 15:33:06 +00:00
"time"
2017-06-24 13:34:17 +00:00
)
type KeyPair struct {
receive cipher.AEAD
2017-06-27 15:33:06 +00:00
send cipher.AEAD
sendNonce uint64
isInitiator bool
created time.Time
2017-07-02 13:28:38 +00:00
localIndex uint32
remoteIndex uint32
2017-06-26 11:14:02 +00:00
}
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
2017-06-24 13:34:17 +00:00
}