mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Use fnv1-a to construct the SPI
Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
253c103b8c
commit
ddff1b5a87
1 changed files with 8 additions and 7 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"hash/fnv"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
@ -353,13 +354,13 @@ func spExists(sp *netlink.XfrmPolicy) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildSPI(src, dst net.IP, st uint32) int {
|
func buildSPI(src, dst net.IP, st uint32) int {
|
||||||
spi := int(st)
|
b := make([]byte, 4)
|
||||||
f := src[len(src)-4:]
|
binary.BigEndian.PutUint32(b, st)
|
||||||
t := dst[len(dst)-4:]
|
h := fnv.New32a()
|
||||||
for i := 0; i < 4; i++ {
|
h.Write(src)
|
||||||
spi = spi ^ (int(f[i])^int(t[3-i]))<<uint32(8*i)
|
h.Write(b)
|
||||||
}
|
h.Write(dst)
|
||||||
return spi
|
return int(binary.BigEndian.Uint32(h.Sum(nil)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildAeadAlgo(k *key, s int) *netlink.XfrmStateAlgo {
|
func buildAeadAlgo(k *key, s int) *netlink.XfrmStateAlgo {
|
||||||
|
|
Loading…
Reference in a new issue