ohttp

package module
v0.0.0-...-45fb0d0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 13 Imported by: 0

README

Oblivious HTTP Go Library

GoDoc Go Report Card

This library contains an implementation of Oblivious HTTP and binary representations of HTTP messages (RFC9292). Binary HTTP support is limited to known-length messages. Indeterminate-length messages are not currently supported.

Security Disclaimer

🚨 This library is offered as-is, and without a guarantee. Therefore, it is expected that changes in the code, repository, and API occur in the future. We recommend to take caution before using this library in a production application since part of its content is experimental.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Len

func Len(i uint64) int64

Len determines the number of bytes that will be needed to write a number

func Read

func Read(b io.ByteReader) (uint64, error)

Read reads a number in the QUIC varint format

func UnmarshalBinaryRequest

func UnmarshalBinaryRequest(data []byte) (*http.Request, error)

func UnmarshalBinaryResponse

func UnmarshalBinaryResponse(data []byte) (*http.Response, error)

func UnmarshalFrameIndicator

func UnmarshalFrameIndicator(b io.ByteReader) (frameIndicator, error)

func UnmarshalRequestControlData

func UnmarshalRequestControlData(b *bytes.Buffer) (requestControlData, error)

func UnmarshalResponseControlData

func UnmarshalResponseControlData(b *bytes.Buffer) (responseControlData, error)

func Write

func Write(b *bytes.Buffer, i uint64)

Write writes a number in the QUIC varint format

func WriteWithLen

func WriteWithLen(b *bytes.Buffer, i uint64, length int64)

WriteWithLen writes a number in the QUIC varint format, with the desired length.

Types

type BinaryRequest

type BinaryRequest http.Request

func (*BinaryRequest) Marshal

func (r *BinaryRequest) Marshal() ([]byte, error)
Request with Known-Length {
	Framing Indicator (i) = 0,
	Request Control Data (..),
	Known-Length Field Section (..),
	Known-Length Content (..),
	Known-Length Field Section (..),
	Padding (..),
}

type BinaryResponse

type BinaryResponse http.Response

func CreateBinaryResponse

func CreateBinaryResponse(resp *http.Response) BinaryResponse

func (*BinaryResponse) Marshal

func (r *BinaryResponse) Marshal() ([]byte, error)
Response with Known-Length {
	Framing Indicator (i) = 1,
	Known-Length Informational Response (..) ...,
	Final Response Control Data (..),
	Known-Length Field Section (..),
	Known-Length Content (..),
	Known-Length Field Section (..),
	Padding (..),
  }

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewCustomClient

func NewCustomClient(config PublicConfig, requestLabel, responseLabel string) Client

func NewDefaultClient

func NewDefaultClient(config PublicConfig) Client

func (Client) EncapsulateRequest

func (c Client) EncapsulateRequest(request []byte) (EncapsulatedRequest, EncapsulatedRequestContext, error)

type ConfigCipherSuite

type ConfigCipherSuite struct {
	KDFID  hpke.KDF
	AEADID hpke.AEAD
}

type DecapsulateRequestContext

type DecapsulateRequestContext struct {
	// contains filtered or unexported fields
}

func (DecapsulateRequestContext) EncapsulateResponse

func (c DecapsulateRequestContext) EncapsulateResponse(response []byte) (EncapsulatedResponse, error)

type EncapsulatedRequest

type EncapsulatedRequest struct {
	KeyID uint8
	// contains filtered or unexported fields
}

func UnmarshalEncapsulatedRequest

func UnmarshalEncapsulatedRequest(enc []byte) (EncapsulatedRequest, error)

func (EncapsulatedRequest) Marshal

func (r EncapsulatedRequest) Marshal() []byte
Encapsulated Request {
	Key Identifier (8),
	KEM Identifier (16),
	KDF Identifier (16),
	AEAD Identifier (16),
	Encapsulated KEM Shared Secret (8*Nenc),
	AEAD-Protected Request (..),
}

type EncapsulatedRequestContext

type EncapsulatedRequestContext struct {
	// contains filtered or unexported fields
}

func (EncapsulatedRequestContext) DecapsulateResponse

func (c EncapsulatedRequestContext) DecapsulateResponse(response EncapsulatedResponse) ([]byte, error)

type EncapsulatedResponse

type EncapsulatedResponse struct {
	// contains filtered or unexported fields
}

func UnmarshalEncapsulatedResponse

func UnmarshalEncapsulatedResponse(enc []byte) (EncapsulatedResponse, error)

func (EncapsulatedResponse) Marshal

func (r EncapsulatedResponse) Marshal() []byte
Encapsulated Response {
	Nonce (Nk),
	AEAD-Protected Response (..),
}

type EncapsulatedResponseContext

type EncapsulatedResponseContext struct {
}

type Gateway

type Gateway struct {
	// contains filtered or unexported fields
}

func NewCustomGateway

func NewCustomGateway(configs []PrivateConfig, requestLabel, responseLabel string) Gateway

func NewDefaultGateway

func NewDefaultGateway(configs []PrivateConfig) Gateway

func (Gateway) Client

func (g Gateway) Client(keyID uint8) (Client, error)

func (Gateway) Config

func (g Gateway) Config(keyID uint8) (PublicConfig, error)

func (Gateway) DecapsulateRequest

func (s Gateway) DecapsulateRequest(req EncapsulatedRequest) ([]byte, DecapsulateRequestContext, error)

func (Gateway) MarshalConfigs

func (s Gateway) MarshalConfigs() []byte

func (Gateway) MatchesConfig

func (s Gateway) MatchesConfig(req EncapsulatedRequest) bool

type PrivateConfig

type PrivateConfig struct {
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(keyID uint8, kemID hpke.KEM, kdfID hpke.KDF, aeadID hpke.AEAD) (PrivateConfig, error)

func NewConfigFromSeed

func NewConfigFromSeed(keyID uint8, kemID hpke.KEM, kdfID hpke.KDF, aeadID hpke.AEAD, seed []byte) (PrivateConfig, error)

func (PrivateConfig) Config

func (c PrivateConfig) Config() PublicConfig

func (PrivateConfig) PrivateKey

func (c PrivateConfig) PrivateKey() kem.PrivateKey

type PublicConfig

type PublicConfig struct {
	ID             uint8
	KEMID          hpke.KEM
	Suites         []ConfigCipherSuite
	PublicKeyBytes []byte
}

func UnmarshalPublicConfig

func UnmarshalPublicConfig(data []byte) (PublicConfig, error)

func (PublicConfig) IsEqual

func (c PublicConfig) IsEqual(o PublicConfig) bool

func (PublicConfig) Marshal

func (c PublicConfig) Marshal() []byte

Jump to

Keyboard shortcuts

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