response

package
v0.0.0-...-4d93f28 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: LGPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PacketPayloadSize = 16   // bytes
	MaxSize           = 1232 // bytes

)

Variables

This section is empty.

Functions

This section is empty.

Types

type New

type New struct {
	Duration         uint16
	SignatureMethod  byte
	EncryptionMethod byte
}

func (*New) Create

func (n *New) Create() (Packet, error)

Creates a response packet struct and uses the fields of the New struct for the packet payload.

type Packet

type Packet struct {
	Header    header.Header
	Payload   packetPayload
	Signature []byte
	ByteData  []byte // header + payload encoded
	Encrypted []byte
}

func Decode

func Decode(data []byte, privKey *rsa.PrivateKey) (Packet, error)

Decodes an encrypted OpenSPA response packet and returns a Packet struct. If we are unable to decode the packet we will return an error.

func (*Packet) AddEncryptionData

func (p *Packet) AddEncryptionData(ciphertext []byte) error

Adds encrypted data to the packet.

func (*Packet) AddSignature

func (p *Packet) AddSignature(signature []byte) error

Adds to a packet the callers packet signature

func (*Packet) Encrypt_RSA_2048_With_AES_256_CBC

func (p *Packet) Encrypt_RSA_2048_With_AES_256_CBC(pubKey *rsa.PublicKey) error

Encrypts the byte data using 2048 bit RSA with AES 256-bit CBC mode and adds it to the packet.

func (*Packet) EncryptionPlaintext

func (p *Packet) EncryptionPlaintext() ([]byte, error)

Returns the plaintext that we will encrypt.

func (*Packet) Export

func (p *Packet) Export() ([]byte, error)

Returns the encrypted byte content of the packet

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

func (p *Packet) SignatureData() ([]byte, error)

Returns the signature data to sign (header+payload).

Jump to

Keyboard shortcuts

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