forked from msgboxio/ike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsa.go
41 lines (37 loc) · 1011 Bytes
/
sa.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package ike
import (
"math/big"
"github.com/msgboxio/ike/platform"
)
// ni, nr, dhShared can either be from the original Tkm
// or from the rekeyed Tkm when Perfect Forward Secrecy is used
func addSaParams(tkm *Tkm,
ni, nr, dhShared *big.Int,
espSpiI, espSpiR []byte,
cfg *Config) *platform.SaParams {
// sa processing
espEi, espAi, espEr, espAr := tkm.IpsecSaKeys(ni, nr, dhShared)
SpiI := SpiToInt32(espSpiI)
SpiR := SpiToInt32(espSpiR)
return &platform.SaParams{
PolicyParams: cfg.Policy(),
EspEi: espEi,
EspAi: espAi,
EspEr: espEr,
EspAr: espAr,
SpiI: int(SpiI),
SpiR: int(SpiR),
EspTransforms: cfg.ProposalEsp,
}
}
func removeSaParams(espSpiI, espSpiR []byte, cfg *Config) *platform.SaParams {
// sa processing
SpiI := SpiToInt32(espSpiI)
SpiR := SpiToInt32(espSpiR)
return &platform.SaParams{
PolicyParams: cfg.Policy(),
SpiI: int(SpiI),
SpiR: int(SpiR),
EspTransforms: cfg.ProposalEsp,
}
}