X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/970424a5fbfce9c2cc353a39fd26cd85e4fb6da0..286b9d5fa4344de72fe6575fa089237fd7dbb56f:/src/src/pdkim/pdkim.h diff --git a/src/src/pdkim/pdkim.h b/src/src/pdkim/pdkim.h index 067c574f2..005249d15 100644 --- a/src/src/pdkim/pdkim.h +++ b/src/src/pdkim/pdkim.h @@ -72,14 +72,12 @@ /* Some parameter values */ #define PDKIM_QUERYMETHOD_DNS_TXT 0 +/*#define PDKIM_ALGO_RSA_SHA256 0 */ +/*#define PDKIM_ALGO_RSA_SHA1 1 */ + #define PDKIM_CANON_SIMPLE 0 #define PDKIM_CANON_RELAXED 1 -/*XXX change to enums */ -#define PDKIM_HASH_SHA256 1 - -#define PDKIM_KEYTYPE_RSA 0 - /* -------------------------------------------------------------------------- */ /* Some required forward declarations, please ignore */ typedef struct pdkim_stringlist pdkim_stringlist; @@ -108,10 +106,8 @@ typedef struct pdkim_pubkey { const uschar *granularity; /* g= */ const uschar * hashes; /* h= */ -#ifdef notdef - uschar *keytype; /* k= */ -#endif - const uschar *srvtype; /* s= */ + const uschar * keytype; /* k= */ + const uschar * srvtype; /* s= */ uschar *notes; /* n= */ blob key; /* p= */ @@ -119,6 +115,21 @@ typedef struct pdkim_pubkey { int no_subdomaining; /* t=s */ } pdkim_pubkey; +/* -------------------------------------------------------------------------- */ +/* Body-hash to be calculated */ +typedef struct pdkim_bodyhash { + struct pdkim_bodyhash * next; + int hashtype; + int canon_method; + long bodylength; + + hctx body_hash_ctx; + unsigned long signed_body_bytes; /* done so far */ + int num_buffered_blanklines; + + blob bh; /* completed hash */ +} pdkim_bodyhash; + /* -------------------------------------------------------------------------- */ /* Signature as it appears in a DKIM-Signature header */ typedef struct pdkim_signature { @@ -129,7 +140,8 @@ typedef struct pdkim_signature { /* (v=) The version, as an integer. Currently, always "1" */ int version; - int keytype; /* PDKIM_KEYTYPE_RSA */ + /* (a=) The signature algorithm. Either PDKIM_ALGO_RSA_SHA256 */ + int keytype; /* pdkim_keytypes index */ int hashtype; /* pdkim_hashes index */ /* (c=x/) Header canonicalization method. Either PDKIM_CANON_SIMPLE @@ -236,11 +248,9 @@ typedef struct pdkim_signature { /* Properties below this point are used internally only ------------- */ /* Per-signature helper variables ----------------------------------- */ - hctx body_hash_ctx; + pdkim_bodyhash *calc_body_hash; /* hash to be / being calculated */ - unsigned long signed_body_bytes; /* How many body bytes we hashed */ - int num_buffered_blanklines; - pdkim_stringlist *headers; /* Raw headers included in the sig */ + pdkim_stringlist *headers; /* Raw headers included in the sig */ /* Signing specific ------------------------------------------------- */ uschar * privkey; /* Private key */ @@ -264,8 +274,11 @@ typedef struct pdkim_ctx { /* One (signing) or several chained (verification) signatures */ pdkim_signature *sig; + /* One (signing) or several chained (verification) bodyhashes */ + pdkim_bodyhash *bodyhash; + /* Callback for dns/txt query method (verification only) */ - int(*dns_txt_callback)(char *, char *); + uschar * (*dns_txt_callback)(char *); /* Coder's little helpers */ gstring *cur_header; @@ -287,7 +300,7 @@ extern "C" { void pdkim_init (void); -void pdkim_init_context (pdkim_ctx *, BOOL, int(*)(char *, char *)); +void pdkim_init_context (pdkim_ctx *, BOOL, uschar * (*)(char *)); DLLEXPORT pdkim_signature *pdkim_init_sign (pdkim_ctx *, @@ -295,7 +308,7 @@ pdkim_signature *pdkim_init_sign (pdkim_ctx *, const uschar **); DLLEXPORT -pdkim_ctx *pdkim_init_verify (int(*)(char *, char *), BOOL); +pdkim_ctx *pdkim_init_verify (uschar * (*)(char *), BOOL); DLLEXPORT void pdkim_set_optional (pdkim_signature *, char *, char *,int, int, @@ -303,6 +316,8 @@ void pdkim_set_optional (pdkim_signature *, char *, char *,int, int, unsigned long, unsigned long); +pdkim_bodyhash *pdkim_set_bodyhash(pdkim_ctx *, pdkim_signature *); + DLLEXPORT int pdkim_feed (pdkim_ctx *, uschar *, int); DLLEXPORT