Documentation
¶
Index ¶
- Constants
- Variables
- type Ciphersuite
- type Options
- type SPAKE2
- func (s *SPAKE2) Confirm(clientConfirmation []byte) ([]byte, error)
- func (s *SPAKE2) Exchange(clientMessage []byte) ([]byte, error)
- func (s *SPAKE2) Finish(serverMessage []byte) ([]byte, error)
- func (s *SPAKE2) SharedKey() ([]byte, error)
- func (s *SPAKE2) Start() ([]byte, error)
- func (s *SPAKE2) Verify(serverConfirmation []byte) error
- type State
- type Transcript
Constants ¶
const ( P256_M_HEX = "02886e2f97ace46e55ba9dd7242579f2993b64e16ef3dcab95afd497333d8fa12f" P256_N_HEX = "03d8bbd6c639c62937b04d997f38c3770719c629d7014d49a24b4f98baa1292b49" )
const ( // DefaultKeySize is the default key size for derived keys DefaultKeySize = 32 // ProtocolRoleClient represents the "A" role in the SPAKE2 protocol ProtocolRoleClient = "A" // ProtocolRoleServer represents the "B" role in the SPAKE2 protocol ProtocolRoleServer = "B" )
Variables ¶
var ( // ErrInvalidMessage indicates that the received message is invalid ErrInvalidMessage = errors.New("invalid message format") // ErrInvalidConfirmation indicates that the confirmation message is invalid ErrInvalidConfirmation = errors.New("invalid confirmation message") // ErrProtocolIncomplete indicates that the protocol is not completed yet ErrProtocolIncomplete = errors.New("protocol not completed") // ErrPasswordMismatch indicates that the calculated shared secret doesn't match ErrPasswordMismatch = errors.New("password mismatch") )
Functions ¶
This section is empty.
Types ¶
type Ciphersuite ¶
type Ciphersuite struct { // Hash function used in the protocol Hash func() hash.Hash // Group specific operations Group crypto.Group // Key derivation function KDF func(ikm, salt, info []byte, l int) []byte // Message authentication code MAC func(key, message []byte) []byte }
Ciphersuite represents a complete set of algorithms for the SPAKE2 protocol
func DefaultCiphersuite ¶
func DefaultCiphersuite() *Ciphersuite
DefaultCiphersuite returns the default ciphersuite using P256 curve and SHA256
type Options ¶
type Options struct { // The ciphersuite to use Ciphersuite *Ciphersuite // Identity of party A (client) IdentityA []byte // Identity of party B (server) IdentityB []byte // Additional authenticated data AAD []byte // Whether to use the symmetric variant with M=N SymmetricMode bool // contains filtered or unexported fields }
Options represents configuration options for SPAKE2 protocol
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns the default options for SPAKE2
type SPAKE2 ¶
type SPAKE2 struct {
// contains filtered or unexported fields
}
SPAKE2 implements the SPAKE2 password-authenticated key exchange protocol
func (*SPAKE2) Confirm ¶
Confirm processes the client's confirmation message and returns the server's confirmation
func (*SPAKE2) Exchange ¶
Exchange processes the client's message and generates the server's response
func (*SPAKE2) Finish ¶
Finish processes the server's message for the client and returns the confirmation message
type Transcript ¶
type Transcript struct { IdentityA []byte IdentityB []byte MessageA []byte MessageB []byte K []byte Password []byte AAD []byte }
Transcript represents the protocol transcript used to derive keys
func NewTranscript ¶
func NewTranscript(identityA, identityB, messageA, messageB, k []byte, password []byte, aad []byte) *Transcript
NewTranscript creates a new protocol transcript
func (*Transcript) Bytes ¶
func (t *Transcript) Bytes() []byte
Bytes returns the byte representation of the transcript as specified in RFC 9382
TT = len(A) || A || len(B) || B || len(pA) || pA || len(pB) || pB || len(K) || K || len(w) || w