rfc5802

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(str string) (string, error)

Normalize runs the SASLprep profile (https://datatracker.ietf.org/doc/html/rfc4013) of the stringprep algorithm (https://datatracker.ietf.org/doc/html/rfc3454). This accepts a standard UTF8 encoded string, unlike other functions which may take an OctetString.

Types

type OctetString

type OctetString []byte

OctetString is equivalent to a byte slice. An octet, as defined in the RFC, is an 8-bit byte. Go only supports 8-bit bytes. Additionally, an octet string is defined as a sequence of octets, which we can represent as a slice.

func Base64ToOctetString

func Base64ToOctetString(base64String string) OctetString

Base64ToOctetString returns the original octet string from its base64 encoded form.

func ClientKey

func ClientKey(saltedPassword OctetString) OctetString

ClientKey returns the client key created using the salted password and a specific constant.

func ClientProof

func ClientProof(clientKey OctetString, clientSignature OctetString) OctetString

ClientProof returns the client proof by xor'ing the client key and client signature.

func ClientSignature

func ClientSignature(storedKey OctetString, authMessage string) OctetString

ClientSignature returns the client signature using the given stored key and auth message.

func H

func H(str OctetString) OctetString

H performs the SHA256 hash function, which is the hash function used by Postgres. The returned OctetString will always have a length of 32.

func HMAC

func HMAC(key OctetString, str OctetString) OctetString

HMAC applies the HMAC keyed hash algorithm on the given octet strings.

func Hi

func Hi(str OctetString, salt OctetString, i uint32) OctetString

Hi is, essentially, PBKDF2 with HMAC as the pseudorandom function.

func SaltedPassword

func SaltedPassword(password string, salt OctetString, i uint32) (OctetString, error)

SaltedPassword returns the salted password. The password should not have been normalized, as it is normalized within the function.

func ServerKey

func ServerKey(saltedPassword OctetString) OctetString

ServerKey returns the server key created using the salted password and a specific constant.

func ServerSignature

func ServerSignature(serverKey OctetString, authMessage string) OctetString

ServerSignature returns the server signature using the given server key and auth message.

func StoredKey

func StoredKey(clientKey OctetString) OctetString

StoredKey returns the stored key created using the client key.

func (OctetString) AppendInteger

func (os OctetString) AppendInteger(val uint32) OctetString

AppendInteger appends the given integer.

func (OctetString) Equals

func (os OctetString) Equals(other OctetString) bool

Equals returns whether the calling octet string is equal to the given octet string.

func (OctetString) ToBase64

func (os OctetString) ToBase64() string

ToBase64 returns the OctetString as a base64 encoded UTF8 string.

func (OctetString) ToHex

func (os OctetString) ToHex() string

ToHex returns the OctetString as a hex encoded UTF8 string (lowercase).

func (OctetString) Xor

func (os OctetString) Xor(other OctetString) OctetString

Xor applies "exclusive or" for every octet between both strings. Assumes that both strings have the same length, so perform any checks before calling this function.

Jump to

Keyboard shortcuts

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