s/qmail 4.3.21
Next generation secure email transport
Loading...
Searching...
No Matches
srs2.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include <time.h>
#include <sys/types.h>
#include <sys/time.h>
#include <string.h>
#include "srs2.h"
#include "sha1.h"
#include <alloca.h>
Include dependency graph for srs2.c:

Go to the source code of this file.

Macros

#define STRINGP(s)
#define X(e, s)
#define SRS_PARAM_DEFINE(n, t)
#define SRS_TIME_PRECISION   (60 * 60 * 24) /* One day */
#define SRS_TIME_BASEBITS   5 /* 2^5 = 32 = strlen(CHARS) */
#define SRS_TIME_SIZE   2
#define SRS_TIME_SLOTS   (1<<(SRS_TIME_BASEBITS<<(SRS_TIME_SIZE-1)))

Functions

int srs_set_malloc (srs_malloc_t m, srs_realloc_t r, srs_free_t f)
const char * srs_strerror (int code)
srs_tsrs_new ()
void srs_init (srs_t *srs)
void srs_free (srs_t *srs)
int srs_add_secret (srs_t *srs, const char *secret)
const char * srs_get_secret (srs_t *srs, int idx)
int srs_set_separator (srs_t *srs, char value)
char srs_get_separator (srs_t *srs)
int srs_timestamp_create (srs_t *srs, char *buf, time_t now)
int srs_timestamp_check (srs_t *srs, const char *stamp)
int srs_hash_create (srs_t *srs, char *buf, int nargs,...)
int srs_hash_check (srs_t *srs, char *hash, int nargs,...)
int srs_compile_shortcut (srs_t *srs, char *buf, int buflen, char *sendhost, char *senduser, const char *aliashost)
int srs_compile_guarded (srs_t *srs, char *buf, int buflen, char *sendhost, char *senduser, const char *aliashost)
int srs_parse_shortcut (srs_t *srs, char *buf, int buflen, char *senduser)
int srs_parse_guarded (srs_t *srs, char *buf, int buflen, char *senduser)
int srs_forward (srs_t *srs, char *buf, int buflen, const char *sender, const char *alias)
int srs_forward_alloc (srs_t *srs, char **sptr, const char *sender, const char *alias)
int srs_reverse (srs_t *srs, char *buf, int buflen, const char *sender)
int srs_reverse_alloc (srs_t *srs, char **sptr, const char *sender)

Variables

const char * SRS_TIME_BASECHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
const char * SRS_HASH_BASECHARS

Macro Definition Documentation

◆ SRS_PARAM_DEFINE

#define SRS_PARAM_DEFINE ( n,
t )
Value:
int srs_set_ ## n (srs_t *srs, t value) { \
srs->n = value; \
return SRS_SUCCESS; \
} \
t srs_get_ ## n (srs_t *srs) { \
return srs->n; \
}
#define SRS_SUCCESS
Definition srs2.h:40
struct _srs_t srs_t

Definition at line 152 of file srs2.c.

◆ SRS_TIME_BASEBITS

#define SRS_TIME_BASEBITS   5 /* 2^5 = 32 = strlen(CHARS) */

Definition at line 187 of file srs2.c.

◆ SRS_TIME_PRECISION

#define SRS_TIME_PRECISION   (60 * 60 * 24) /* One day */

Definition at line 186 of file srs2.c.

◆ SRS_TIME_SIZE

#define SRS_TIME_SIZE   2

Definition at line 191 of file srs2.c.

◆ SRS_TIME_SLOTS

#define SRS_TIME_SLOTS   (1<<(SRS_TIME_BASEBITS<<(SRS_TIME_SIZE-1)))

Definition at line 192 of file srs2.c.

◆ STRINGP

#define STRINGP ( s)
Value:
((s != NULL) && (*(s) != '\0'))

Definition at line 56 of file srs2.c.

◆ X

#define X ( e,
s )
Value:
if (code == e) return s;
unsigned long code

Definition at line 72 of file srs2.c.

Function Documentation

◆ srs_add_secret()

int srs_add_secret ( srs_t * srs,
const char * secret )

Definition at line 137 of file srs2.c.

Here is the caller graph for this function:

◆ srs_compile_guarded()

int srs_compile_guarded ( srs_t * srs,
char * buf,
int buflen,
char * sendhost,
char * senduser,
const char * aliashost )

Definition at line 392 of file srs2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ srs_compile_shortcut()

int srs_compile_shortcut ( srs_t * srs,
char * buf,
int buflen,
char * sendhost,
char * senduser,
const char * aliashost )

Definition at line 348 of file srs2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ srs_forward()

int srs_forward ( srs_t * srs,
char * buf,
int buflen,
const char * sender,
const char * alias )

Definition at line 528 of file srs2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ srs_forward_alloc()

int srs_forward_alloc ( srs_t * srs,
char ** sptr,
const char * sender,
const char * alias )

Definition at line 570 of file srs2.c.

Here is the call graph for this function:

◆ srs_free()

void srs_free ( srs_t * srs)

Definition at line 126 of file srs2.c.

◆ srs_get_secret()

const char * srs_get_secret ( srs_t * srs,
int idx )

Definition at line 145 of file srs2.c.

◆ srs_get_separator()

char srs_get_separator ( srs_t * srs)

Definition at line 169 of file srs2.c.

◆ srs_hash_check()

int srs_hash_check ( srs_t * srs,
char * hash,
int nargs,
... )

Definition at line 317 of file srs2.c.

Here is the caller graph for this function:

◆ srs_hash_create()

int srs_hash_create ( srs_t * srs,
char * buf,
int nargs,
... )

Definition at line 299 of file srs2.c.

Here is the caller graph for this function:

◆ srs_init()

void srs_init ( srs_t * srs)

Definition at line 114 of file srs2.c.

Here is the caller graph for this function:

◆ srs_new()

srs_t * srs_new ( )

Definition at line 107 of file srs2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ srs_parse_guarded()

int srs_parse_guarded ( srs_t * srs,
char * buf,
int buflen,
char * senduser )

Definition at line 498 of file srs2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ srs_parse_shortcut()

int srs_parse_shortcut ( srs_t * srs,
char * buf,
int buflen,
char * senduser )

Definition at line 460 of file srs2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ srs_reverse()

int srs_reverse ( srs_t * srs,
char * buf,
int buflen,
const char * sender )

Definition at line 599 of file srs2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ srs_reverse_alloc()

int srs_reverse_alloc ( srs_t * srs,
char ** sptr,
const char * sender )

Definition at line 624 of file srs2.c.

Here is the call graph for this function:

◆ srs_set_malloc()

int srs_set_malloc ( srs_malloc_t m,
srs_realloc_t r,
srs_free_t f )

Definition at line 64 of file srs2.c.

◆ srs_set_separator()

int srs_set_separator ( srs_t * srs,
char value )

Definition at line 161 of file srs2.c.

Here is the caller graph for this function:

◆ srs_strerror()

const char * srs_strerror ( int code)

Definition at line 74 of file srs2.c.

Here is the caller graph for this function:

◆ srs_timestamp_check()

int srs_timestamp_check ( srs_t * srs,
const char * stamp )

Definition at line 204 of file srs2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ srs_timestamp_create()

int srs_timestamp_create ( srs_t * srs,
char * buf,
time_t now )

Definition at line 194 of file srs2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ SRS_HASH_BASECHARS

const char* SRS_HASH_BASECHARS
Initial value:
= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/"

Definition at line 232 of file srs2.c.

◆ SRS_TIME_BASECHARS

const char* SRS_TIME_BASECHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"

Definition at line 190 of file srs2.c.