Documentation
¶
Index ¶
- Constants
- func AEADDecrypt(key []byte, ciphertext []byte) ([]byte, error)
- func AEADEncrypt(key, plaintext []byte) ([]byte, error)
- func KemKDF1(ss_e_ecdh, ss_e_kyber768 []byte) (k1_c2s []byte, k1_s2c []byte, err error)
- func KemKDF2(ecdhSS1, kemSS1, ecdhSS2, kemSS2 []byte) (k2_c2s_key_confirmation, k2_c2s_app_data, k2_s2c_key_confirmation, ... []byte, ...)
- func PostMessage[M any](httpClient *http.Client, url string, requestMessage any) ([]byte, *http.Response, []byte, *M, error)
- type CertData
- type Channel
- func (c *Channel) Decrypt(data []byte, req *http.Request) (*http.Response, error)
- func (c *Channel) DecryptResponse(resp *http.Response, req *http.Request) (*http.Response, error)
- func (c *Channel) Do(req *http.Request) (*http.Response, error)
- func (c *Channel) Encrypt(data []byte) (*EncryptedRequest, error)
- func (c *Channel) EncryptRequest(r *http.Request) (*EncryptedRequest, error)
- func (c *Channel) PostEncryptedRequest(data []byte) (*http.Response, error)
- func (c *Channel) Snapshot() ChannelSnapshot
- type ChannelSnapshot
- type ChannelState
- type Counter
- type ECDHData
- type ECKeyPair
- type EncryptedRequest
- type Env
- type KEMData
- type KEMKeyPair
- type KeyPairs
- type Message1
- type Message2
- type Message3
- type Message3Inner
- type Message4
- type MessageError
- type PublicVAUKeys
- type Server
- func (s *Server) Decapsulate(ecdh_ss1, kem_ss1 []byte, ecdh_ct *ECDHData, kem_ct []byte) (k2_c2s_key_confirmation, k2_c2s_app_data, k2_s2c_key_confirmation, ... []byte, ...)
- func (s *Server) DecryptNestedRequestData(channelState *ChannelState, r *http.Request) ([]byte, error)
- func (s *Server) EncryptNestedResponseData(channelState *ChannelState, data []byte) ([]byte, error)
- func (s *Server) HandleByContentType(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleCertData(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleMessage1(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleMessage3(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleNestedRequest(w http.ResponseWriter, r *http.Request)
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type SignedPublicVAUKeys
- type Status
Constants ¶
const ( Version = byte(0x02) HeaderRequest = byte(0x01) HeaderResponse = byte(0x02) )
Variables ¶
This section is empty.
Functions ¶
func AEADEncrypt ¶
Types ¶
type CertData ¶
type CertData struct {
Cert *x509.Certificate
CACert *x509.Certificate
RCAChain []*x509.Certificate
}
func (*CertData) UnmarshalCBOR ¶
type Channel ¶
type Channel struct {
Env Env
ID string
ChannelURL *url.URL
SignedPublicVAUKeys *SignedPublicVAUKeys
// contains filtered or unexported fields
}
func OpenChannel ¶
func RestoreChannel ¶
func RestoreChannel(state ChannelSnapshot, httpClient *http.Client) (*Channel, error)
RestoreChannel reconstructs a Channel from a previously captured state. The HTTP client is provided by the caller (typically wired with the same cert pool used at handshake time). Subsequent Encrypts will resume from the counters in the state.
func (*Channel) DecryptResponse ¶
func (*Channel) EncryptRequest ¶
func (c *Channel) EncryptRequest(r *http.Request) (*EncryptedRequest, error)
func (*Channel) PostEncryptedRequest ¶
PostEncryptedRequest sends previously encrypted data to the server, returning the raw "outer" response.
func (*Channel) Snapshot ¶
func (c *Channel) Snapshot() ChannelSnapshot
Snapshot returns the current state of the channel suitable for persistence. Counters are read under their respective locks so concurrent senders don't race the snapshotter.
type ChannelSnapshot ¶
type ChannelSnapshot struct {
Env Env `json:"env"`
ID string `json:"id"`
ChannelURL string `json:"channel_url"`
KeyID []byte `json:"key_id"`
K2C2SAppData []byte `json:"k2_c2s_app_data"`
K2C2SAppDataCounter uint64 `json:"k2_c2s_app_data_counter"`
K2S2CAppData []byte `json:"k2_s2c_app_data"`
RequestCounter uint64 `json:"request_counter"`
}
ChannelSnapshot captures everything needed to resume an open VAU channel from a different process. AEAD keys, the channel ID/URL, and both monotonic counters are included; the HTTP client and SignedPublicVAUKeys are intentionally excluded (the client is process-local, the server keys are only used during the initial handshake and are not consulted on subsequent Encrypt/Decrypt).
The receiver of a ChannelSnapshot MUST persist counters at least as often as it sends VAU requests — counter reuse breaks AES-GCM nonce uniqueness AND will be rejected by the server. The simplest correct pattern: snapshot after each successful request, drop the snapshot on any failure, fall back to a fresh handshake.
type ChannelState ¶
type ECDHData ¶
func (*ECDHData) Encapsulate ¶
type ECKeyPair ¶
type ECKeyPair struct {
PublicKey *ecdh.PublicKey
PublicData ECDHData
// contains filtered or unexported fields
}
func GenerateRandomECKeyPair ¶
GenerateRandomECKeyPair generates a random EC key pair
type EncryptedRequest ¶
type KEMData ¶
type KEMData []byte
func (KEMData) Encapsulate ¶
Encapsulate generates a shared secret and a ciphertext
type KEMKeyPair ¶
type KEMKeyPair struct {
PublicData KEMData
// contains filtered or unexported fields
}
func GenerateKEMKeyPair ¶
func GenerateKEMKeyPair(scheme kem.Scheme) (*KEMKeyPair, error)
func (*KEMKeyPair) Decapsulate ¶
func (kp *KEMKeyPair) Decapsulate(ciphertext []byte) ([]byte, error)
type KeyPairs ¶
type KeyPairs struct {
ECKeyPair *ECKeyPair
KEMKeyPair *KEMKeyPair
}
func GenerateKeyPairs ¶
type Message3Inner ¶
type MessageError ¶
type MessageError struct {
MessageType string `cbor:"MessageType"`
ErrorCode uint64 `cbor:"ErrorCode"`
ErrorMessage string `cbor:"ErrorMessage"`
}
MessageError is a CBOR encoded error message
func (*MessageError) Error ¶
func (m *MessageError) Error() string
type PublicVAUKeys ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Decapsulate ¶
func (*Server) DecryptNestedRequestData ¶
func (*Server) EncryptNestedResponseData ¶
func (s *Server) EncryptNestedResponseData(channelState *ChannelState, data []byte) ([]byte, error)
func (*Server) HandleByContentType ¶
func (s *Server) HandleByContentType(w http.ResponseWriter, r *http.Request)
func (*Server) HandleCertData ¶
func (s *Server) HandleCertData(w http.ResponseWriter, r *http.Request)
func (*Server) HandleMessage1 ¶
func (s *Server) HandleMessage1(w http.ResponseWriter, r *http.Request)
func (*Server) HandleMessage3 ¶
func (s *Server) HandleMessage3(w http.ResponseWriter, r *http.Request)
func (*Server) HandleNestedRequest ¶
func (s *Server) HandleNestedRequest(w http.ResponseWriter, r *http.Request)