Documentation ¶
Index ¶
- Constants
- func BinIPAddressToIP(binIp []byte) (net.IP, error)
- func IPAddressToBinIP(ip net.IP) ([]byte, error)
- type New
- type Packet
- func (p *Packet) AddEncryptionData(ciphertext []byte) error
- func (p *Packet) AddSignature(signature []byte) error
- func (p *Packet) Encrypt_RSA_2048_With_AES_256_CBC(pubKey *rsa.PublicKey) error
- func (p *Packet) EncryptionPlaintext() ([]byte, error)
- func (p *Packet) Export() ([]byte, error)
- func (p *Packet) Sign_RSA_SHA256(privKey *rsa.PrivateKey) error
- func (p *Packet) SignatureData() ([]byte, error)
- type PacketPayload
Constants ¶
const ( PacketBodySize_184 = 440 PacketBodySize_64 = 376 PacketBodySize_192 = 448 PacketPayloadSize = 192 // bytes PacketPayloadSize_64 = 120 PacketPayloadSize_184 = 184 PacketPayloadSize_192 = 192 MaxSize = 1232 // bytes )
Variables ¶
This section is empty.
Functions ¶
func BinIPAddressToIP ¶
Returns a net.IP type from the provided byte slice. The inputted byte slice needs to be 16 bytes long and can be a IPv6 binary address or an IPv4 binary address mapped as an IPv6 address specified by RFC 4291 "IPv4-Mapped IPv6 Address".
func IPAddressToBinIP ¶
Returns a byte slice 16 bytes long which represents an IPv4 or IPv6 address (depending on the inputted IP address). In case the inputted address is IPv4 we will follow RFC 4291 "IPv4-Mapped IPv6 address" specification for the binary representation of the address.
Types ¶
type New ¶
type Packet ¶
type Packet struct { Header header.Header Payload PacketPayload PacketPayloadLen int Signature []byte ByteData []byte // header + payload encoded Encrypted []byte }
func Decode ¶
func Decode(data []byte, serverPrivKey *rsa.PrivateKey) (Packet, error)
Decodes an encrypted OpenSPA request packet and returns a Packet struct. If we are unable to decode the packet we will return an error.
func (*Packet) AddEncryptionData ¶
Adds encrypted data to the packet.
func (*Packet) AddSignature ¶
Adds to a packet the callers packet signature
func (*Packet) Encrypt_RSA_2048_With_AES_256_CBC ¶
Encrypts the byte data using 2048 bit RSA with AES 256-bit CBC mode and adds it to the packet.
func (*Packet) EncryptionPlaintext ¶
Returns the plaintext that we will encrypt.
func (*Packet) Sign_RSA_SHA256 ¶
func (p *Packet) Sign_RSA_SHA256(privKey *rsa.PrivateKey) error
Signs the packet using a RSA private key, by taking a SHA-256 digest of the packet signature data.
func (*Packet) SignatureData ¶
Returns the signature data to sign (header+payload).
type PacketPayload ¶
type PacketPayload struct { Timestamp time.Time ClientDeviceID string Nonce []byte ClientType byte ClientVersion string SignatureMethod byte ClientPublicIP net.IP ServerPublicIP net.IP }
func (*PacketPayload) ClientTypeToString ¶
func (pp *PacketPayload) ClientTypeToString() string
func (*PacketPayload) Encode ¶
func (p *PacketPayload) Encode() ([]byte, error)
Encodes the packet payload according to the OpenSPA specification for request packet payload.
func (*PacketPayload) SignatureMethodToString ¶
func (pp *PacketPayload) SignatureMethodToString() string
Returns the signature method as a string
func (*PacketPayload) TimestampToString ¶
func (pp *PacketPayload) TimestampToString() string
Returns the timestamp as a string