Documentation ¶
Index ¶
- Constants
- Variables
- func ADKGenerateNextProof(secret string) (uint32, error)
- func ADKGenerateProof(secret string) (uint32, error)
- func ADKGenerateProofCustom(secret string, t time.Time) (uint32, error)
- func ADKGenerateSecret() (string, error)
- func ClientIPFromContainer(c tlv.Container) (net.IP, error)
- func ClientIPv4FromContainer(c tlv.Container) (net.IP, error)
- func ClientIPv4ToContainer(c tlv.Container, ip net.IP) error
- func ClientIPv6FromContainer(c tlv.Container) (net.IP, error)
- func ClientIPv6ToContainer(c tlv.Container, ip net.IP) error
- func ClientUUIDDecode(b []byte) (string, error)
- func ClientUUIDEncode(u string) ([]byte, error)
- func ClientUUIDFromContainer(c tlv.Container) (string, error)
- func ClientUUIDToContainer(c tlv.Container, uuid string) error
- func DurationDecode(b []byte) (time.Duration, error)
- func DurationEncode(d time.Duration) ([]byte, error)
- func DurationFromContainer(c tlv.Container) (time.Duration, error)
- func DurationToContainer(c tlv.Container, d time.Duration) error
- func IPv4Decode(b []byte) (net.IP, error)
- func IPv4Encode(ip net.IP) ([]byte, error)
- func IPv6Decode(b []byte) (net.IP, error)
- func IPv6Encode(ip net.IP) ([]byte, error)
- func RandomTransactionID() uint8
- func RandomUUID() string
- func RequestDataToContainer(d RequestData, ed RequestExtendedData) (tlv.Container, error)
- func TLVFromContainer(c tlv.Container, key uint8) (tlv.Container, error)
- func TLVToContainer(parent, child tlv.Container, key uint8) error
- func TargetIPFromContainer(c tlv.Container) (net.IP, error)
- func TargetIPv4FromContainer(c tlv.Container) (net.IP, error)
- func TargetIPv4ToContainer(c tlv.Container, ip net.IP) error
- func TargetIPv6FromContainer(c tlv.Container) (net.IP, error)
- func TargetIPv6ToContainer(c tlv.Container, ip net.IP) error
- func TargetPortEndDecode(b []byte) (int, error)
- func TargetPortEndEncode(p int) ([]byte, error)
- func TargetPortEndFromContainer(c tlv.Container) (int, error)
- func TargetPortEndToContainer(c tlv.Container, p int) error
- func TargetPortStartDecode(b []byte) (int, error)
- func TargetPortStartEncode(p int) ([]byte, error)
- func TargetPortStartFromContainer(c tlv.Container) (int, error)
- func TargetPortStartToContainer(c tlv.Container, p int) error
- func TargetProtocolEncode(p InternetProtocolNumber) (byte, error)
- func TargetProtocolToContainer(c tlv.Container, p InternetProtocolNumber) error
- func TimestampDecode(b []byte) (time.Time, error)
- func TimestampEncode(t time.Time) ([]byte, error)
- func TimestampFromContainer(c tlv.Container) (time.Time, error)
- func TimestampToContainer(c tlv.Container, t time.Time) error
- func Version() string
- type ADKProver
- type Header
- type InternetProtocolNumber
- func InternetProtocolFromNumber(i uint8) (InternetProtocolNumber, error)
- func InternetProtocolFromString(s string) (InternetProtocolNumber, error)
- func InternetProtocolNumberSupported() []InternetProtocolNumber
- func TargetProtocolDecode(b []byte) (InternetProtocolNumber, error)
- func TargetProtocolFromContainer(c tlv.Container) (InternetProtocolNumber, error)
- type PDUType
- type Request
- type RequestData
- type RequestDataOpt
- type RequestExtendedData
- type RequestFirewallData
- type Response
- type ResponseData
- type ResponseExtendedData
Constants ¶
const ( ADKSecretLen = ADKLength // in bytes ADKSecretEncodedLen = 7 )
const ( DefaultServerPort = 22211 MaxPDUSize = 1444 )
const ( TimestampKey uint8 = 1 ClientUUIDKey uint8 = 2 FirewallKey uint8 = 3 )
OpenSPA Packet TLV8 definition keys
const ( TargetProtocolKey uint8 = 1 TargetPortStartKey uint8 = 2 TargetPortEndKey uint8 = 3 ClientIPv4Key uint8 = 4 ClientIPv6Key uint8 = 5 TargetIPv4Key uint8 = 6 TargetIPv6Key uint8 = 7 DurationKey uint8 = 8 )
Firewall TLV8 definition keys
const ( TimestampSize = 8 TargetProtocolSize = 1 TargetPortSize = 2 IPV4Size = 4 IPV6Size = 16 DurationSize = 3 ClientUUIDSize = 16 )
const ( HeaderLength = 8 ADKLength = 4 ProtocolVersion = 2 )
const VersionMajor = 2
const VersionMinor = 0
Variables ¶
var ( ErrInvalidBytes = errors.New("invalid bytes") ErrMissingEntry = errors.New("missing entry") ErrBadInput = errors.New("bad input") ErrViolationOfProtocolSpec = errors.New("violation of protocol spec") ErrCipherSuiteRequired = errors.New("cipher suite required") ErrPDUTooLarge = errors.New("pdu too large") )
var ( ProtocolUndefined = InternetProtocolNumber{ Number: 0, Protocol: "", } ProtocolICMP = InternetProtocolNumber{ Number: 1, Protocol: "ICMP", } ProtocolIPV4 = InternetProtocolNumber{ Number: 4, Protocol: "IPv4", } ProtocolTCP = InternetProtocolNumber{ Number: 6, Protocol: "TCP", } ProtocolUDP = InternetProtocolNumber{ Number: 17, Protocol: "UDP", } ProtocolICMPv6 = InternetProtocolNumber{ Number: 58, Protocol: "ICMPv6", } )
var DurationMax = int(math.Pow(2, 8*DurationSize)) - 1
var ErrADKProofMismatch = errors.New("adk proof mismatch")
Functions ¶
func ADKGenerateNextProof ¶
func ADKGenerateProof ¶
func ADKGenerateProofCustom ¶
func ADKGenerateSecret ¶
func ClientUUIDDecode ¶
func ClientUUIDEncode ¶
func RandomTransactionID ¶
func RandomTransactionID() uint8
func RandomUUID ¶
func RandomUUID() string
func RequestDataToContainer ¶
func RequestDataToContainer(d RequestData, ed RequestExtendedData) (tlv.Container, error)
func TargetPortEndDecode ¶
func TargetPortEndEncode ¶
func TargetPortStartDecode ¶
func TargetPortStartEncode ¶
func TargetProtocolEncode ¶
func TargetProtocolEncode(p InternetProtocolNumber) (byte, error)
func TargetProtocolToContainer ¶
func TargetProtocolToContainer(c tlv.Container, p InternetProtocolNumber) error
Types ¶
type ADKProver ¶
type ADKProver struct {
// contains filtered or unexported fields
}
ADKProver is a cached version of the ADKGenerateProof function, which recalculates the proof when the cached version is older than a second. This avoids calculating the same proof for every single packet and instead calculating the proof at least every second opposed to multiple times per second (when receiving multiple packets with a second). Run the benchmarks to see the speedup numbers for your setup.
func NewADKProver ¶
type Header ¶
type Header struct { Type PDUType Version int TransactionID uint8 CipherSuiteID crypto.CipherSuiteID ADKProof uint32 }
func RequestUnmarshalHeader ¶
func UnmarshalHeader ¶
type InternetProtocolNumber ¶
InternetProtocolNumber is the protocol found in the IPv4 header field Protocol. See: https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
func InternetProtocolFromNumber ¶
func InternetProtocolFromNumber(i uint8) (InternetProtocolNumber, error)
func InternetProtocolFromString ¶
func InternetProtocolFromString(s string) (InternetProtocolNumber, error)
func InternetProtocolNumberSupported ¶
func InternetProtocolNumberSupported() []InternetProtocolNumber
InternetProtocolNumberSupported returns a slice of InternetProtocolNumber that are supported.
func TargetProtocolDecode ¶
func TargetProtocolDecode(b []byte) (InternetProtocolNumber, error)
func TargetProtocolFromContainer ¶
func TargetProtocolFromContainer(c tlv.Container) (InternetProtocolNumber, error)
func (InternetProtocolNumber) String ¶
func (i InternetProtocolNumber) String() string
func (InternetProtocolNumber) ToBin ¶
func (i InternetProtocolNumber) ToBin() byte
type Request ¶
func NewRequest ¶
func NewRequest(d RequestData, c crypto.CipherSuite, opt RequestDataOpt) (*Request, error)
func RequestUnmarshal ¶
func RequestUnmarshal(b []byte, cs crypto.CipherSuite) (*Request, error)
type RequestData ¶
type RequestDataOpt ¶
type RequestDataOpt struct {
ADKSecret string
}
type RequestExtendedData ¶
type RequestFirewallData ¶
type RequestFirewallData struct { Timestamp time.Time ClientUUID string ClientIP net.IP TargetProtocol InternetProtocolNumber TargetIP net.IP TargetPortStart int TargetPortEnd int }
func RequestFirewallDataFromContainer ¶
func RequestFirewallDataFromContainer(c tlv.Container) (RequestFirewallData, error)
type Response ¶
type Response struct { Header Header Body tlv.Container // Metadata is not actually sent, but it is passed to the CipherSuite implementation, so we can provide additional // data that can be used by CipherSuite implementation for security purposes. This data is not packed into OpenSPA // request/responses, it is merely passed along various subsystems. Metadata tlv.Container // contains filtered or unexported fields }
func NewResponse ¶
func NewResponse(d ResponseData, c crypto.CipherSuite) (*Response, error)
func ResponseUnmarshal ¶
func ResponseUnmarshal(b []byte, cs crypto.CipherSuite) (*Response, error)
type ResponseData ¶
type ResponseExtendedData ¶
type ResponseExtendedData struct { }