ohttp

package
v0.0.0-...-9b7c71c Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SessionIDLength represents the lenght of the session ID.
	SessionIDLength = 32

	// ErrorBadPasswordLikely represents an when when the password is wrong.
	ErrorBadPasswordLikely = "Server provided a bad envelope. This likely indicates a mistyped password."
	// ErrorUsernameTaken represents an error when the username is already taken.
	ErrorUsernameTaken = "Username already registered. Try again with a new username."
	// ErrorUsernameNotRegistered represents and error when the username is not yet registered.
	ErrorUsernameNotRegistered = "Username not registered. Register your username before logging in."
	// ErrorGeneric represents a generic error.
	ErrorGeneric = "Something went wrong. Try again."

	// SuccessLogin represents a message for when the login is successful.
	SuccessLogin = "Login successful!"
	// SuccessRegistration represents a message for when the registration is successful.
	SuccessRegistration = "Registration successful!"

	// LocalDomain represents the domain for local view.
	LocalDomain = "127.0.0.1:8080"
)

Variables

This section is empty.

Functions

func RunOpaqueServer

func RunOpaqueServer() error

RunOpaqueServer runs the OPAQUE server.

Types

type ClientConfig

type ClientConfig struct {
	Domain      string
	Ciphersuite oprf.SuiteID
	Logger      *log.Logger
}

ClientConfig represents a client configuration for http.

func (*ClientConfig) AddError

func (c *ClientConfig) AddError(err error)

AddError adds a library error.

func (*ClientConfig) AddMessage

func (c *ClientConfig) AddMessage(title string, msg interface{})

AddMessage adds a message to the DOM.

func (*ClientConfig) AddTitle

func (c *ClientConfig) AddTitle(title string)

AddTitle adds a title to the string.

func (*ClientConfig) Get

func (c *ClientConfig) Get(endpoint string) (*http.Response, error)

Get gets an http Response.

func (*ClientConfig) ParseConfigMsg

func (c *ClientConfig) ParseConfigMsg(r *http.Response) error

ParseConfigMsg parses the config message for a Client.

func (*ClientConfig) ParseExporterKeyMsg

func (c *ClientConfig) ParseExporterKeyMsg(r *http.Response) (expauth.ExportedKeyGetter, crypto.Hash, error)

ParseExporterKeyMsg parses into a ExportedKey.

func (*ClientConfig) Post

func (c *ClientConfig) Post(endpoint string, request []byte) (*http.Response, error)

Post gets an http post response.

func (*ClientConfig) RequestCiphersuite

func (c *ClientConfig) RequestCiphersuite() error

RequestCiphersuite request a ciphersuite for a Client.

func (*ClientConfig) RequestExportedKeys

func (c *ClientConfig) RequestExportedKeys() (expauth.ExportedKeyGetter, crypto.Hash, error)

RequestExportedKeys requests the exported keys.

func (*ClientConfig) RunOpaqueLoginClient

func (c *ClientConfig) RunOpaqueLoginClient(username, password string, getExportedKey expauth.ExportedKeyGetter,
	authHash crypto.Hash) error

RunOpaqueLoginClient runs an opaque login client.

func (*ClientConfig) RunOpaqueRegisterClient

func (c *ClientConfig) RunOpaqueRegisterClient(username, password string) error

RunOpaqueRegisterClient runs an opaque register client.

func (*ClientConfig) SendLoginRequest

func (c *ClientConfig) SendLoginRequest(client *opaqueea.Client, sessionID []byte, password string) (*http.Response, error)

SendLoginRequest sends a login request.

func (*ClientConfig) SendLoginResponse

func (c *ClientConfig) SendLoginResponse(client *opaqueea.Client, sessionID []byte, httpResponse *http.Response) (*http.Response, error)

SendLoginResponse sends a client login response.

func (*ClientConfig) SendRegisterRequest

func (c *ClientConfig) SendRegisterRequest(client *opaqueea.Client, sessionID []byte, password string) (*http.Response, error)

SendRegisterRequest sends a client register request.

func (*ClientConfig) SendRegisterResponse

func (c *ClientConfig) SendRegisterResponse(client *opaqueea.Client, sessionID []byte, httpResponse *http.Response) (*http.Response, error)

SendRegisterResponse sends a client register response.

func (*ClientConfig) SetupClient

func (c *ClientConfig) SetupClient(username string, getExportedKey expauth.ExportedKeyGetter,
	authHash crypto.Hash) (*opaqueea.Client, error)

SetupClient sets up a client.

type HTTPMessage

type HTTPMessage struct {
	RequestID   []byte
	RequestBody []byte
}

HTTPMessage represents an HTTP Message.

type OPAQUEAuth

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

OPAQUEAuth represents an OPAQUE authentication struct.

func (*OPAQUEAuth) AddSession

func (oa *OPAQUEAuth) AddSession(ctx []byte, session *opaqueea.Server) error

AddSession adds a session to the OPAQUEAuth.

func (*OPAQUEAuth) CloseSession

func (oa *OPAQUEAuth) CloseSession(ctx []byte)

CloseSession closes/deletes a session from the OPAQUE Auth.

func (*OPAQUEAuth) HandleAuthRequest

func (oa *OPAQUEAuth) HandleAuthRequest(w http.ResponseWriter, req *http.Request)

HandleAuthRequest handles an auth request.

func (*OPAQUEAuth) HandleAuthResponse

func (oa *OPAQUEAuth) HandleAuthResponse(w http.ResponseWriter, req *http.Request)

HandleAuthResponse handles an auth response.

func (*OPAQUEAuth) HandleConfigRequest

func (oa *OPAQUEAuth) HandleConfigRequest(w http.ResponseWriter, req *http.Request)

HandleConfigRequest handles a request for config.

func (*OPAQUEAuth) HandleExportedKeyRequest

func (oa *OPAQUEAuth) HandleExportedKeyRequest(w http.ResponseWriter, req *http.Request)

HandleExportedKeyRequest handles an exported key request.

func (*OPAQUEAuth) HandleExportedKeyTestRequest

func (oa *OPAQUEAuth) HandleExportedKeyTestRequest(w http.ResponseWriter, req *http.Request)

HandleExportedKeyTestRequest handles an exported key test request.

func (*OPAQUEAuth) HandleRegistrationRequest

func (oa *OPAQUEAuth) HandleRegistrationRequest(w http.ResponseWriter, req *http.Request)

HandleRegistrationRequest handles a registration request.

func (*OPAQUEAuth) HandleRegistrationUpload

func (oa *OPAQUEAuth) HandleRegistrationUpload(w http.ResponseWriter, req *http.Request)

HandleRegistrationUpload handles a registration upload.

func (*OPAQUEAuth) NewSession

func (oa *OPAQUEAuth) NewSession(ctx []byte, connState *tls.ConnectionState) (*opaqueea.Server, error)

NewSession creates a new session and adds it to the OPAQUE Auth.

func (*OPAQUEAuth) Populate

func (oa *OPAQUEAuth) Populate(domain string) error

Populate populates the OPAQUEAuth with the needed fields.

func (*OPAQUEAuth) RetrieveSession

func (oa *OPAQUEAuth) RetrieveSession(ctx []byte) (*opaqueea.Server, error)

RetrieveSession retrieves a session from the OPAQUE Auth.

Jump to

Keyboard shortcuts

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