security

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomNumber

func GenerateRandomNumber() (*big.Int, error)

func GenerateRandomUint8

func GenerateRandomUint8() (uint8, error)

Types

type ChildSA

type ChildSA struct {
	// SPI
	SPI uint32

	// Mark
	Mark *uint32

	// IP addresses
	RemotePublicIPAddr net.IP
	LocalPublicIPAddr  net.IP

	// Traffic
	IPProto  uint8
	TSLocal  *net.IPNet
	TSRemote *net.IPNet

	// Encapsulate
	EnableEncap bool
	LocalPort   int
	RemotePort  int
	// contains filtered or unexported fields
}

func (*ChildSA) CalcKEMaterial

func (childsa *ChildSA) CalcKEMaterial(peerPublicValue []byte) ([]byte, []byte, error)

CalcKEMaterial generates secret and calculate Diffie-Hellman public key exchange material. Peer public value as parameter, return local public value and shared key.

func (*ChildSA) GenerateKey

func (childsa *ChildSA) GenerateKey(prf hash.Hash, dhSharedKey, concatenatedNonce []byte) error

Key Gen for child SA

func (*ChildSA) GenerateXFRMPolicy

func (childsa *ChildSA) GenerateXFRMPolicy(role int) error

func (*ChildSA) GenerateXFRMState

func (childsa *ChildSA) GenerateXFRMState(role int, allocspi bool) error

func (*ChildSA) GetDHTransformID

func (childsa *ChildSA) GetDHTransformID() uint16

func (*ChildSA) SelectProposal

func (childsa *ChildSA) SelectProposal(proposal *message.Proposal) bool

func (*ChildSA) SetProposal

func (childsa *ChildSA) SetProposal(proposal *message.Proposal) bool

func (*ChildSA) SetXFRMState

func (childsa *ChildSA) SetXFRMState(role int) error

func (*ChildSA) ToProposal

func (childsa *ChildSA) ToProposal() *message.Proposal

func (*ChildSA) XFRMRuleAdd

func (childsa *ChildSA) XFRMRuleAdd() error

func (*ChildSA) XFRMRuleFlush

func (childsa *ChildSA) XFRMRuleFlush() error

type IKESA

type IKESA struct {
	// SPI
	RemoteSPI uint64
	LocalSPI  uint64

	// Role
	Role int

	// Security objects
	Prf_d   hash.Hash       // used to derive key for child sa
	Integ_i hash.Hash       // used by initiator for integrity checking
	Integ_r hash.Hash       // used by responder for integrity checking
	Encr_i  types.IKECrypto // used by initiator for encrypting
	Encr_r  types.IKECrypto // used by responder for encrypting
	Prf_i   hash.Hash       // used by initiator for IKE authentication
	Prf_r   hash.Hash       // used by responder for IKE authentication

	// NAT detection
	NATT bool

	// Message ID
	MessageID uint32
	// contains filtered or unexported fields
}

func (*IKESA) CalcIKEChecksum

func (ikesa *IKESA) CalcIKEChecksum(data []byte) error

func (*IKESA) CalcKEMaterial

func (ikesa *IKESA) CalcKEMaterial(peerPublicValue []byte) ([]byte, []byte, error)

CalcKEMaterial generates secret and calculate Diffie-Hellman public key exchange material. Peer public value as parameter, return local public value and shared key.

func (*IKESA) CheckMessageID

func (ikesa *IKESA) CheckMessageID(mID uint32) bool

func (*IKESA) DecryptSKPayload

func (ikesa *IKESA) DecryptSKPayload(data []byte) ([]byte, error)

func (*IKESA) EncryptToSKPayload

func (ikesa *IKESA) EncryptToSKPayload(data []byte) ([]byte, error)

func (*IKESA) GenerateKey

func (ikesa *IKESA) GenerateKey(concatenatedNonce, dhSharedKey, concatenatedSPI []byte) error

func (*IKESA) GetAuth

func (ikesa *IKESA) GetAuth(kn3iwf []byte, signedOctets []byte) []byte

func (*IKESA) GetDHTransformID

func (ikesa *IKESA) GetDHTransformID() uint16

func (*IKESA) SelectProposal

func (ikesa *IKESA) SelectProposal(proposal *message.Proposal) bool

func (*IKESA) SetProposal

func (ikesa *IKESA) SetProposal(proposal *message.Proposal) bool

func (*IKESA) ToProposal

func (ikesa *IKESA) ToProposal() *message.Proposal

func (*IKESA) VerifyIKEChecksum

func (ikesa *IKESA) VerifyIKEChecksum(data []byte) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL