mgo.v2: Index | Files

package scram

import ""

Pacakage scram implements a SCRAM-{SHA-1,etc} client per RFC5802.


Package Files


type Client Uses

type Client struct {
    // contains filtered or unexported fields

Client implements a SCRAM-* client (SCRAM-SHA-1, SCRAM-SHA-256, etc).

A Client may be used within a SASL conversation with logic resembling:

var in []byte
var client = scram.NewClient(sha1.New, user, pass)
for client.Step(in) {
        out := client.Out()
        // send out to server
        in := serverOut
if client.Err() != nil {
        // auth failed

func NewClient Uses

func NewClient(newHash func() hash.Hash, user, pass string) *Client

NewClient returns a new SCRAM-* client with the provided hash algorithm.

For SCRAM-SHA-1, for example, use:

client := scram.NewClient(sha1.New, user, pass)

func (*Client) Err Uses

func (c *Client) Err() error

Err returns the error that ocurred, or nil if there were no errors.

func (*Client) Out Uses

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

Out returns the data to be sent to the server in the current step.

func (*Client) SetNonce Uses

func (c *Client) SetNonce(nonce []byte)

SetNonce sets the client nonce to the provided value. If not set, the nonce is generated automatically out of crypto/rand on the first step.

func (*Client) Step Uses

func (c *Client) Step(in []byte) bool

Step processes the incoming data from the server and makes the next round of data for the server available via Client.Out. Step returns false if there are no errors and more data is still expected.

Package scram imports 8 packages (graph) and is imported by 24 packages. Updated 2019-08-16. Refresh now. Tools for package owners.