23static const char *srs_separators =
"=-+";
59 return "Unknown SRS error.";
81#define SRS_TIME_PRECISION (60*60*24)
82#define SRS_TIME_BASEBITS 5
86#define SRS_TIME_SIZE 2
87#define SRS_TIME_SLOTS (1 << (SRS_TIME_BASEBITS << (SRS_TIME_SIZE - 1)))
112 for (sp =
stamp; *sp; sp++) {
115 if (off == str_len(sp))
130 "abcdefghijklmnopqrstuvwxyz"
138 unsigned char *hp = 0;
154 if (three && *three) {
164 hp = (
unsigned char *)srshash;
170 j = (*hp >> 2);
break;
172 j = ((*hp & 0x03) << 4) | ((*(hp + 1) & 0xF0) >> 4); hp++;
break;
174 j = ((*hp & 0x0F) << 2) | ((*(hp + 1) & 0xC0) >> 6); hp++;
break;
176 j = (*hp++ & 0x3F);
break;
207 char *srshash =
hash;
244 char *
senduser,
const char *aliashost)
300 srsstamp = srshash +
j + 1;
334 j = str_chr(inaddr,
'@');
335 if (
j < str_len(inaddr)) inaddr[
j] =
'\0';
337 if (!case_diffb(inaddr,4,
SRS1TAG)) {
338 srshash = inaddr + 5;
368 at = str_chr(alias,
'@');
369 if (at < str_len(alias)) {
375 if (case_equals(
sendhost.s,alias)) {
383 if (at < str_len(
sender)) {
int stralloc_copys(stralloc *, char const *)
void sha1_final(uint8_t hash[SHA1_DIGESTSIZE], sha1_ctx *context)
void sha1_init(sha1_ctx *context)
void sha1_update(sha1_ctx *context, const uint8_t *data, uint32_t len)
char stamp[FMT_ULONG+FMT_ULONG+3]
int srs_create_timestamp(char *buf, time_t now)
#define SRS_TIME_PRECISION
int srs_create_hash(srs_ctx *srs, char *hash, const char *secret, char *one, char *two, char *three)
int srs_parse_shortcut(srs_ctx *srs, stralloc *srsaddr, char *senduser)
int srs_reverse(srs_ctx *srs, stralloc *srsaddr, char *inaddr)
int srs_check_timestamp(srs_ctx *srs, char *stamp)
int srs_forward(srs_ctx *srs, stralloc *srsaddr, const char *sender, const char *alias)
int srs_init(srs_ctx *srs)
int srs_make_guarded(srs_ctx *srs, stralloc *srsaddr, char *sendhost, char *senduser, const char *aliashost)
const char * SRS_TIME_BASECHARS
int srs_check_hash(srs_ctx *srs, const char *hash, char *one, char *two, char *three)
int srs_make_shortcut(srs_ctx *srs, stralloc *srsaddr, char *sendhost, char *senduser, const char *aliashost)
const char * srs_errorstr(int code)
#define SRS_TIME_BASEBITS
const char * SRS_HASH_BASECHARS
#define SRS_ETIMESTAMPOUTOFDATE
#define SRS_ENOSENDERATSIGN
#define SRS_EHASHTOOSHORT
#define SRS_ESEPARATORINVALID
#define SRS_ENOTREWRITTEN
#define SRS_IS_SRS_ADDRESS(x)
#define SRS_EBADTIMESTAMPCHAR
#define SRS_ENOTSRSADDRESS