ake

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ake provides high-level functions for the 3DH AKE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyGen

func KeyGen(id group.Group) (privateKey, publicKey []byte)

KeyGen returns private and public keys in the group.

Types

type Client

type Client struct {
	Ke1 []byte
	// contains filtered or unexported fields
}

Client exposes the client's AKE functions and holds its state.

func NewClient

func NewClient() *Client

NewClient returns a new, empty, 3DH client.

func (*Client) Finalize

func (c *Client) Finalize(
	conf *internal.Configuration,
	identities *Identities,
	clientSecretKey *group.Scalar,
	serverPublicKey *group.Element,
	ke2 *message.KE2,
) (*message.KE3, error)

Finalize verifies and responds to KE3. If the handshake is successful, the session key is stored and this functions returns a KE3 message.

func (*Client) Flush added in v0.10.0

func (c *Client) Flush()

Flush sets all the client's session related internal AKE values to nil.

func (*Client) GetEphemeralSecretKey added in v0.10.0

func (v *Client) GetEphemeralSecretKey() *group.Scalar

GetEphemeralSecretKey returns the state's ephemeral secret key.

func (*Client) GetNonce added in v0.10.0

func (v *Client) GetNonce() []byte

GetNonce returns the secret nonce.

func (*Client) SessionKey

func (c *Client) SessionKey() []byte

SessionKey returns the secret shared session key if a previous call to Finalize() was successful.

func (*Client) Start

func (c *Client) Start(cs group.Group, options Options) *message.KE1

Start initiates the 3DH protocol, and returns a KE1 message with clientInfo.

type Identities added in v0.9.1

type Identities struct {
	ClientIdentity []byte
	ServerIdentity []byte
}

Identities holds the client and server identities.

func (*Identities) SetIdentities added in v0.9.1

func (id *Identities) SetIdentities(clientPublicKey *group.Element, serverPublicKey []byte) *Identities

SetIdentities sets the client and server identities to their respective public key if not set.

type Options added in v0.9.1

type Options struct {
	// EphemeralSecretKey: optional
	EphemeralSecretKey *group.Scalar
	// Nonce: optional
	Nonce []byte
	// NonceLength: optional
	NonceLength uint
}

Options enables setting optional ephemeral values, which default to secure random values if not set.

type Server

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

Server exposes the server's AKE functions and holds its state.

func NewServer

func NewServer() *Server

NewServer returns a new, empty, 3DH server.

func (*Server) ExpectedMAC

func (s *Server) ExpectedMAC() []byte

ExpectedMAC returns the expected client MAC if a previous call to Response() was successful.

func (*Server) Finalize

func (s *Server) Finalize(conf *internal.Configuration, ke3 *message.KE3) bool

Finalize verifies the authentication tag contained in ke3.

func (*Server) Flush added in v0.10.0

func (s *Server) Flush()

Flush sets all the server's session related internal AKE values to nil.

func (*Server) GetEphemeralSecretKey added in v0.10.0

func (v *Server) GetEphemeralSecretKey() *group.Scalar

GetEphemeralSecretKey returns the state's ephemeral secret key.

func (*Server) GetNonce added in v0.10.0

func (v *Server) GetNonce() []byte

GetNonce returns the secret nonce.

func (*Server) Response

func (s *Server) Response(
	conf *internal.Configuration,
	identities *Identities,
	serverSecretKey *group.Scalar,
	clientPublicKey *group.Element,
	ke1 *message.KE1,
	response *message.CredentialResponse,
	options Options,
) *message.KE2

Response produces a 3DH server response message.

func (*Server) SerializeState

func (s *Server) SerializeState() []byte

SerializeState will return a []byte containing internal state of the Server.

func (*Server) SessionKey

func (s *Server) SessionKey() []byte

SessionKey returns the secret shared session key if a previous call to Response() was successful.

func (*Server) SetState

func (s *Server) SetState(clientMac, sessionSecret []byte) error

SetState will set the given clientMac and sessionSecret in the server's internal state.

Jump to

Keyboard shortcuts

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