/*
* SCRAM-SHA-1 SASL authentication, see RFC-5802
*
* Copyright (c) 2012 Florian Zeitz <florob@babelmonkeys.de>
*
* This software is released under the MIT license.
*/
#include "lib.h"
#include "safe-memset.h"
#include "base64.h"
#include "buffer.h"
#include "hmac.h"
#include "randgen.h"
#include "sha1.h"
#include "str.h"
#include "password-scheme.h"
/* SCRAM allowed iteration count range. RFC says it SHOULD be at least 4096 */
unsigned char result[SHA1_RESULTLEN])
{
unsigned char U[SHA1_RESULTLEN];
unsigned int j, k;
/* Calculate U1 */
hmac_final(&ctx, U);
/* Calculate U2 to Ui and Hi */
for (j = 2; j <= i; j++) {
hmac_update(&ctx, U, sizeof(U));
hmac_final(&ctx, U);
for (k = 0; k < SHA1_RESULTLEN; k++)
result[k] ^= U[k];
}
}
unsigned int *iter_count_r, const char **salt_r,
unsigned char stored_key_r[],
unsigned char server_key_r[], const char **error_r)
{
const char *const *fields;
/* password string format: iter,salt,stored_key,server_key */
*error_r = "Invalid SCRAM-SHA-1 passdb entry format";
return -1;
}
*error_r = "Invalid SCRAM-SHA-1 iteration count in passdb";
return -1;
}
*error_r = "Invalid SCRAM-SHA-1 StoredKey in passdb";
return -1;
}
buffer_set_used_size(buf, 0);
*error_r = "Invalid SCRAM-SHA-1 ServerKey in passdb";
return -1;
}
return 0;
}
int scram_sha1_verify(const char *plaintext, const struct password_generate_params *params ATTR_UNUSED,
const char **error_r)
{
const char *salt_base64;
unsigned int iter_count;
const unsigned char *salt;
int ret;
server_key, error_r) < 0)
return -1;
/* FIXME: credentials should be SASLprepped UTF8 data here */
/* Calculate ClientKey */
/* Calculate StoredKey */
sizeof(stored_key)) ? 1 : 0;
return ret;
}
void scram_sha1_generate(const char *plaintext, const struct password_generate_params *params ATTR_UNUSED,
{
/* FIXME: credentials should be SASLprepped UTF8 data here */
/* Calculate ClientKey */
/* Calculate StoredKey */
/* Calculate ServerKey */
}