/* Copyright (c) 2010-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "base64.h"
#include "hex-binary.h"
#include "str.h"
#include "hash-method.h"
#include "hash-format.h"
enum hash_encoding {
};
struct hash_format_list {
void *context;
unsigned int bits;
};
struct hash_format {
const char *str;
unsigned char *digest;
};
static int
const struct hash_method **method_r,
{
/* we should have "hash_name}" or "hash_name:bits}" */
*error_r = "Missing '}'";
return -1;
}
return -1;
}
return -1;
}
if ((bits % 8) != 0) {
*error_r = t_strconcat(
"Currently :bits must be divisible by 8: ",
return -1;
}
}
return 0;
}
static int
const char **error_r)
{
unsigned int i;
for (i = 0; str[i] != '\0'; i++) {
if (str[i] != '%')
continue;
i++;
if (str[i] == 'B') {
i++;
} else if (str[i] == 'X') {
i++;
}
if (str[i++] != '{') {
*error_r = "No '{' after '%'";
return -1;
}
return -1;
}
return 0;
}
const char **error_r)
{
int ret;
T_BEGIN {
error_r);
if (ret < 0)
} T_END;
if (ret < 0) {
pool_unref(&pool);
return -1;
}
return 0;
}
{
}
{
}
}
static void
const unsigned char *digest)
{
case HASH_ENCODING_HEX:
break;
case HASH_ENCODING_HEX_SHORT:
/* drop leading zeros, except if it's the only one */
break;
}
break;
case HASH_ENCODING_BASE64:
/* drop trailing '=' chars */
break;
}
}
{
const char *p;
unsigned int i, max_digest_size = 0;
}
continue;
}
/* we already verified that the string is ok */
}
}
{
}
{
}