s/qmail 4.4.12
Next generation secure email transport
Loading...
Searching...
No Matches
Macros | Functions | Variables
srsq.c File Reference

SRS library for s/qmail; refactored from srs2.c from Shevek (srs@a.nosp@m.narr.nosp@m.es.or.nosp@m.g) // the temporal physicist @ Anarres. More...

#include <time.h>
#include <sys/time.h>
#include "str.h"
#include "sha1.h"
#include "byte.h"
#include "case.h"
#include "stralloc.h"
#include "srsq.h"
#include "uint_t.h"
Include dependency graph for srsq.c:

Go to the source code of this file.

Macros

#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

const char * srs_errorstr (int code)
 
int srs_init (srs_ctx *srs)
 
int srs_create_timestamp (char *buf, time_t now)
 
int srs_check_timestamp (srs_ctx *srs, char *stamp)
 
int srs_create_hash (srs_ctx *srs, char *hash, const char *secret, char *one, char *two, char *three)
 
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)
 
int srs_make_guarded (srs_ctx *srs, stralloc *srsaddr, char *sendhost, char *senduser, const char *aliashost)
 
int srs_parse_shortcut (srs_ctx *srs, stralloc *srsaddr, char *senduser)
 
int srs_reverse (srs_ctx *srs, stralloc *srsaddr, char *inaddr)
 
int srs_forward (srs_ctx *srs, stralloc *srsaddr, const char *sender, const char *alias)
 

Variables

stralloc secret = {0}
 
stralloc sendhost = {0}
 
stralloc senduser = {0}
 
const char * SRS_TIME_BASECHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
 
const char * SRS_HASH_BASECHARS
 

Detailed Description

SRS library for s/qmail; refactored from srs2.c from Shevek (srs@a.nosp@m.narr.nosp@m.es.or.nosp@m.g) // the temporal physicist @ Anarres.

SRS0 address format (default delimitor: '='; could be '-,+' as first): SRS0=HHH=TT=orig-domain=orig-local-part@domain-part

Guarded address format: [wrong in SRS.pdf] SRS1=HHH=rewritten-domain-part==HHH=TT=orig-domain-part=orig-local-part@domain-part

Definition in file srsq.c.

Macro Definition Documentation

◆ SRS_TIME_BASEBITS

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

Definition at line 82 of file srsq.c.

◆ SRS_TIME_PRECISION

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

Definition at line 81 of file srsq.c.

◆ SRS_TIME_SIZE

#define SRS_TIME_SIZE   2

Definition at line 86 of file srsq.c.

◆ SRS_TIME_SLOTS

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

Definition at line 87 of file srsq.c.

Function Documentation

◆ srs_check_hash()

int srs_check_hash ( srs_ctx srs,
const char *  hash,
char *  one,
char *  two,
char *  three 
)

Definition at line 186 of file srsq.c.

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

◆ srs_check_timestamp()

int srs_check_timestamp ( srs_ctx srs,
char *  stamp 
)

Definition at line 101 of file srsq.c.

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

◆ srs_create_hash()

int srs_create_hash ( srs_ctx srs,
char *  hash,
const char *  secret,
char *  one,
char *  two,
char *  three 
)

Definition at line 133 of file srsq.c.

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

◆ srs_create_timestamp()

int srs_create_timestamp ( char *  buf,
time_t  now 
)

Definition at line 89 of file srsq.c.

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

◆ srs_errorstr()

const char * srs_errorstr ( int  code)

Definition at line 29 of file srsq.c.

Here is the caller graph for this function:

◆ srs_forward()

int srs_forward ( srs_ctx srs,
stralloc *  srsaddr,
const char *  sender,
const char *  alias 
)

Definition at line 360 of file srsq.c.

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

◆ srs_init()

int srs_init ( srs_ctx srs)

Definition at line 62 of file srsq.c.

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

◆ srs_make_guarded()

int srs_make_guarded ( srs_ctx srs,
stralloc *  srsaddr,
char *  sendhost,
char *  senduser,
const char *  aliashost 
)

Definition at line 243 of file srsq.c.

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

◆ srs_make_shortcut()

int srs_make_shortcut ( srs_ctx srs,
stralloc *  srsaddr,
char *  sendhost,
char *  senduser,
const char *  aliashost 
)

Definition at line 204 of file srsq.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_ctx srs,
stralloc *  srsaddr,
char *  senduser 
)

Definition at line 287 of file srsq.c.

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

◆ srs_reverse()

int srs_reverse ( srs_ctx srs,
stralloc *  srsaddr,
char *  inaddr 
)

Definition at line 324 of file srsq.c.

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

Variable Documentation

◆ secret

stralloc secret = {0}

Definition at line 25 of file srsq.c.

◆ sendhost

stralloc sendhost = {0}

Definition at line 26 of file srsq.c.

◆ senduser

stralloc senduser = {0}

Definition at line 27 of file srsq.c.

◆ SRS_HASH_BASECHARS

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

Definition at line 129 of file srsq.c.

◆ SRS_TIME_BASECHARS

const char* SRS_TIME_BASECHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"

Definition at line 85 of file srsq.c.