block

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package block provides routines for manipulating End to End blocks.

Index

Constants

View Source
const (
	// MessageIDLength is the length of a message ID in bytes.
	MessageIDLength = 16
)

Variables

View Source
var (
	// BlockCiphertextLength is the length of a BlockCiphertext in bytes.
	BlockCiphertextLength = constants.UserForwardPayloadLength

	// BlockPayloadLength is the maximum user payload length in a Block.
	BlockPayloadLength = BlockCiphertextLength - (blockCiphertextOverhead + blockOverhead)
)

Functions

func EncryptMessage

func EncryptMessage(msgID *[MessageIDLength]byte, msg []byte, sender *ecdh.PrivateKey, recipient *ecdh.PublicKey) ([][]byte, error)

EncryptMessage encrypts a message after fragmenting it into blocks, and returns a vector of byte serialized ciphertexts.

Types

type Block

type Block struct {
	MessageID   [MessageIDLength]byte
	TotalBlocks uint16
	BlockID     uint16
	BlockLength uint32
	Payload     []byte
}

Block is a Katzenpost end to end Block (plaintext).

func DecryptBlock

func DecryptBlock(b []byte, recipient *ecdh.PrivateKey) (*Block, *ecdh.PublicKey, error)

DecryptBlock authenticates and decrypts a encrypted Block, and returns the Block and sender's static PublicKey.

func (*Block) FromBytes

func (b *Block) FromBytes(buf []byte) error

FromBytes deserializes bytes into the Block.

func (*Block) ToBytes

func (b *Block) ToBytes() ([]byte, error)

ToBytes serializes a Block into bytes.

Jump to

Keyboard shortcuts

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