scram.c File Reference

SCRAM-SHA1 helper functions. More...

## Data Structures

union | common_hash_ctx

## Macros

#define | HMAC_BLOCK_SIZE_MAX 128

## Functions

static void | crypto_HMAC (const struct hash_alg *alg, const uint8_t *key, size_t key_len, const uint8_t *text, size_t len, uint8_t *digest)
static void | SCRAM_Hi (const struct hash_alg *alg, const uint8_t *text, size_t len, const uint8_t *salt, size_t salt_len, uint32_t i, uint8_t *digest)
void | SCRAM_ClientKey (const struct hash_alg *alg, const uint8_t *password, size_t len, const uint8_t *salt, size_t salt_len, uint32_t i, uint8_t *key)
void | SCRAM_ClientSignature (const struct hash_alg *alg, const uint8_t *ClientKey, const uint8_t *AuthMessage, size_t len, uint8_t *sign)
void | SCRAM_ClientProof (const struct hash_alg *alg, const uint8_t *ClientKey, const uint8_t *ClientSignature, uint8_t *proof)

## Variables

static const uint8_t | ipad = 0x36
static const uint8_t | opad = 0x5C
const struct hash_alg | scram_sha1
const struct hash_alg | scram_sha1_plus
const struct hash_alg | scram_sha256
const struct hash_alg | scram_sha256_plus
const struct hash_alg | scram_sha512
const struct hash_alg | scram_sha512_plus
const struct hash_alg * | scram_algs []
const size_t | scram_algs_num = sizeof(scram_algs) / sizeof(scram_algs[0])

## Detailed Description

SCRAM-SHA1 helper functions.

## Macro Definition Documentation

## HMAC_BLOCK_SIZE_MAX

#define HMAC_BLOCK_SIZE_MAX 128

## Function Documentation

## crypto_HMAC()

void crypto_HMAC | ( | const struct hash_alg * | alg,
|  | const uint8_t * | key,
|  | size_t | key_len,
|  | const uint8_t * | text,
|  | size_t | len,
|  | uint8_t * | digest )

static

## SCRAM_Hi()

void SCRAM_Hi | ( | const struct hash_alg * | alg,
|  | const uint8_t * | text,
|  | size_t | len,
|  | const uint8_t * | salt,
|  | size_t | salt_len,
|  | uint32_t | i,
|  | uint8_t * | digest )

static

## SCRAM_ClientKey()

void SCRAM_ClientKey | ( | const struct hash_alg * | alg,
|  | const uint8_t * | password,
|  | size_t | len,
|  | const uint8_t * | salt,
|  | size_t | salt_len,
|  | uint32_t | i,
|  | uint8_t * | key )

## SCRAM_ClientSignature()

void SCRAM_ClientSignature | ( | const struct hash_alg * | alg,
|  | const uint8_t * | ClientKey,
|  | const uint8_t * | AuthMessage,
|  | size_t | len,
|  | uint8_t * | sign )

## SCRAM_ClientProof()

void SCRAM_ClientProof | ( | const struct hash_alg * | alg,
|  | const uint8_t * | ClientKey,
|  | const uint8_t * | ClientSignature,
|  | uint8_t * | proof )

## Variable Documentation

## ipad

const uint8_t ipad = 0x36

static

## opad

const uint8_t opad = 0x5C

static

## scram_sha1

const struct hash_alg scram_sha1

Initial value:
= {
"SCRAM-SHA-1",
SASL_MASK_SCRAMSHA1,
SHA1_DIGEST_SIZE,
(void (*)(const uint8_t *, size_t, uint8_t *))crypto_SHA1,
(void (*)(void *))crypto_SHA1_Init,
(void (*)(void *, const uint8_t *, size_t))crypto_SHA1_Update,
(void (*)(void *, uint8_t *))crypto_SHA1_Final}
SASL_MASK_SCRAMSHA1
#define SASL_MASK_SCRAMSHA1
Definition common.h:177
crypto_SHA1_Update
void crypto_SHA1_Update(SHA1_CTX *context, const uint8_t *data, size_t len)
Definition sha1.c:209
crypto_SHA1_Final
void crypto_SHA1_Final(SHA1_CTX *context, uint8_t *digest)
Definition sha1.c:230
crypto_SHA1
void crypto_SHA1(const uint8_t *data, size_t len, uint8_t *digest)
Definition sha1.c:260
crypto_SHA1_Init
void crypto_SHA1_Init(SHA1_CTX *context)
Definition sha1.c:197
SHA1_DIGEST_SIZE
#define SHA1_DIGEST_SIZE
Definition sha1.h:24

## scram_sha1_plus

const struct hash_alg scram_sha1_plus

Initial value:
= {
"SCRAM-SHA-1-PLUS",
SASL_MASK_SCRAMSHA1_PLUS,
SHA1_DIGEST_SIZE,
(void (*)(const uint8_t *, size_t, uint8_t *))crypto_SHA1,
(void (*)(void *))crypto_SHA1_Init,
(void (*)(void *, const uint8_t *, size_t))crypto_SHA1_Update,
(void (*)(void *, uint8_t *))crypto_SHA1_Final}
SASL_MASK_SCRAMSHA1_PLUS
#define SASL_MASK_SCRAMSHA1_PLUS
Definition common.h:181

## scram_sha256

const struct hash_alg scram_sha256

Initial value:
= {
"SCRAM-SHA-256",
SASL_MASK_SCRAMSHA256,
SHA256_DIGEST_SIZE,
(void (*)(const uint8_t *, size_t, uint8_t *))sha256_hash,
(void (*)(void *))sha256_init,
(void (*)(void *, const uint8_t *, size_t))sha256_process,
(void (*)(void *, uint8_t *))sha256_done}
SASL_MASK_SCRAMSHA256
#define SASL_MASK_SCRAMSHA256
Definition common.h:178
sha256_done
void sha256_done(sha256_context *md, uint8_t *out)
Definition sha256.c:163
sha256_init
void sha256_init(sha256_context *md)
Definition sha256.c:118
sha256_process
void sha256_process(sha256_context *md, const uint8_t *in, size_t inlen)
Definition sha256.c:132
sha256_hash
void sha256_hash(const uint8_t *data, size_t len, uint8_t *digest)
Definition sha256.c:204
SHA256_DIGEST_SIZE
#define SHA256_DIGEST_SIZE
Definition sha256.h:23

## scram_sha256_plus

const struct hash_alg scram_sha256_plus

Initial value:
= {
"SCRAM-SHA-256-PLUS",
SASL_MASK_SCRAMSHA256_PLUS,
SHA256_DIGEST_SIZE,
(void (*)(const uint8_t *, size_t, uint8_t *))sha256_hash,
(void (*)(void *))sha256_init,
(void (*)(void *, const uint8_t *, size_t))sha256_process,
(void (*)(void *, uint8_t *))sha256_done}
SASL_MASK_SCRAMSHA256_PLUS
#define SASL_MASK_SCRAMSHA256_PLUS
Definition common.h:182

## scram_sha512

const struct hash_alg scram_sha512

Initial value:
= {
"SCRAM-SHA-512",
SASL_MASK_SCRAMSHA512,
SHA512_DIGEST_SIZE,
(void (*)(const uint8_t *, size_t, uint8_t *))sha512_hash,
(void (*)(void *))sha512_init,
(void (*)(void *, const uint8_t *, size_t))sha512_process,
(void (*)(void *, uint8_t *))sha512_done}
SASL_MASK_SCRAMSHA512
#define SASL_MASK_SCRAMSHA512
Definition common.h:179
sha512_hash
void sha512_hash(const uint8_t *data, size_t len, uint8_t *digest)
Definition sha512.c:195
sha512_process
void sha512_process(sha512_context *md, const uint8_t *in, size_t inlen)
Definition sha512.c:120
sha512_init
void sha512_init(sha512_context *md)
Definition sha512.c:106
sha512_done
void sha512_done(sha512_context *md, uint8_t *out)
Definition sha512.c:151
SHA512_DIGEST_SIZE
#define SHA512_DIGEST_SIZE
Definition sha512.h:23

## scram_sha512_plus

const struct hash_alg scram_sha512_plus

Initial value:
= {
"SCRAM-SHA-512-PLUS",
SASL_MASK_SCRAMSHA512_PLUS,
SHA512_DIGEST_SIZE,
(void (*)(const uint8_t *, size_t, uint8_t *))sha512_hash,
(void (*)(void *))sha512_init,
(void (*)(void *, const uint8_t *, size_t))sha512_process,
(void (*)(void *, uint8_t *))sha512_done}
SASL_MASK_SCRAMSHA512_PLUS
#define SASL_MASK_SCRAMSHA512_PLUS
Definition common.h:183

## scram_algs

const struct hash_alg* scram_algs[]

Initial value:
= {
&scram_sha512_plus,
&scram_sha256_plus,
&scram_sha1_plus,
&scram_sha512,
&scram_sha256,
&scram_sha1,
}
scram_sha512
const struct hash_alg scram_sha512
Definition scram.c:72
scram_sha1
const struct hash_alg scram_sha1
Definition scram.c:36
scram_sha256_plus
const struct hash_alg scram_sha256_plus
Definition scram.c:63
scram_sha256
const struct hash_alg scram_sha256
Definition scram.c:54
scram_sha1_plus
const struct hash_alg scram_sha1_plus
Definition scram.c:45
scram_sha512_plus
const struct hash_alg scram_sha512_plus
Definition scram.c:81

## scram_algs_num

const size_t scram_algs_num = sizeof(scram_algs) / sizeof(scram_algs[0])