"sync"
"time"
+ "github.com/aead/chacha20"
"github.com/dchest/siphash"
"github.com/flynn/noise"
"github.com/jroimartin/gocui"
"go.stargrave.org/opus/v2"
vors "go.stargrave.org/vors/v3/internal"
"golang.org/x/crypto/blake2s"
- "golang.org/x/crypto/chacha20"
)
type Stream struct {
var keyMACOur []byte
{
var xof blake2s.XOF
- xof, err = blake2s.NewXOF(chacha20.KeySize+16, nil)
+ xof, err = blake2s.NewXOF(vors.ChaCha20KeySize+vors.SipHash24KeySize, nil)
if err != nil {
log.Fatalln(err)
}
xof.Write([]byte(vors.NoisePrologue))
xof.Write(hs.ChannelBinding())
- buf := make([]byte, chacha20.KeySize+16)
+ buf := make([]byte, vors.ChaCha20KeySize+vors.SipHash24KeySize)
if _, err = io.ReadFull(xof, buf); err != nil {
log.Fatalln(err)
}
- keyCiphOur, keyMACOur = buf[:chacha20.KeySize], buf[chacha20.KeySize:]
+ keyCiphOur, keyMACOur = buf[:vors.ChaCha20KeySize], buf[vors.ChaCha20KeySize:]
}
seen := time.Now()
sid := sidRaw[0]
printBell()
log.Println("add", string(name), "sid:", sid)
- keyCiph, keyMAC := key[:chacha20.KeySize], key[chacha20.KeySize:]
+ keyCiph, keyMAC := key[:vors.ChaCha20KeySize], key[vors.ChaCha20KeySize:]
stream := &Stream{
name: string(name),
in: make(chan []byte, 1<<10),
}()
}
- var ciph *chacha20.Cipher
mac := siphash.New(keyMAC)
tag := make([]byte, siphash.Size)
var ctr uint32
stream.stats.bads++
continue
}
- ciph, err = chacha20.NewUnauthenticatedCipher(
- keyCiph, nonce,
- )
- if err != nil {
- log.Fatal(err)
- }
pkt = buf[4+3 : len(buf)-siphash.Size]
- ciph.XORKeyStream(pkt, pkt)
+ chacha20.XORKeyStream(pkt, pkt, nonce, keyCiph)
ctr = binary.BigEndian.Uint32(nonce[len(nonce)-4:])
if lost == -1 {
return
}
<-LoggerReady
- var ciph *chacha20.Cipher
mac := siphash.New(keyMACOur)
tag := make([]byte, siphash.Size)
buf := make([]byte, 2*vors.FrameLen)
incr(nonce[len(nonce)-3:])
copy(buf, nonce[len(nonce)-4:])
copy(buf[4:], actr)
- ciph, err = chacha20.NewUnauthenticatedCipher(keyCiphOur, nonce)
- if err != nil {
- log.Fatal(err)
- }
- ciph.XORKeyStream(
+ chacha20.XORKeyStream(
buf[4+len(actr):4+len(actr)+n],
buf[4+len(actr):4+len(actr)+n],
+ nonce, keyCiphOur,
)
mac.Reset()
if _, err = mac.Write(buf[:4+len(actr)+n]); err != nil {
"github.com/jroimartin/gocui"
vors "go.stargrave.org/vors/v3/internal"
"golang.org/x/crypto/blake2s"
- "golang.org/x/crypto/chacha20"
)
var (
room.peersM.RUnlock()
{
- xof, err := blake2s.NewXOF(chacha20.KeySize+16, nil)
+ xof, err := blake2s.NewXOF(vors.ChaCha20KeySize+vors.SipHash24KeySize, nil)
if err != nil {
log.Fatalln(err)
}
xof.Write([]byte(vors.NoisePrologue))
xof.Write(hs.ChannelBinding())
- peer.key = make([]byte, chacha20.KeySize+16)
+ peer.key = make([]byte, vors.ChaCha20KeySize+vors.SipHash24KeySize)
if _, err = io.ReadFull(xof, peer.key); err != nil {
log.Fatalln(err)
}
- peer.mac = siphash.New(peer.key[chacha20.KeySize:])
+ peer.mac = siphash.New(peer.key[vors.ChaCha20KeySize:])
}
{