X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsrc%2Fpdkim%2Fpdkim.h;h=775581be75f3e5173da49dfb40c7c6f1d9ca87e3;hb=dfbcb5ac660065b097b0ad0cb2c26357899f0c64;hp=a350e6b7e5a8046291be3746c54c495ed39048cc;hpb=9e70917d0aa5e51f584b2af69ce80df458ac5c79;p=exim.git diff --git a/src/src/pdkim/pdkim.h b/src/src/pdkim/pdkim.h index a350e6b7e..775581be7 100644 --- a/src/src/pdkim/pdkim.h +++ b/src/src/pdkim/pdkim.h @@ -2,7 +2,7 @@ * PDKIM - a RFC4871 (DKIM) implementation * * Copyright (C) 2009 - 2012 Tom Kistner - * Copyright (c) 2016 - 2017 Jeremy Harris + * Copyright (c) 2016 - 2018 Jeremy Harris * * http://duncanthrax.net/pdkim/ * @@ -26,6 +26,15 @@ #include "../blob.h" #include "../hash.h" +#define PDKIM_DEFAULT_SIGN_HEADERS "From:Sender:Reply-To:Subject:Date:"\ + "Message-ID:To:Cc:MIME-Version:Content-Type:"\ + "Content-Transfer-Encoding:Content-ID:"\ + "Content-Description:Resent-Date:Resent-From:"\ + "Resent-Sender:Resent-To:Resent-Cc:"\ + "Resent-Message-ID:In-Reply-To:References:"\ + "List-Id:List-Help:List-Unsubscribe:"\ + "List-Subscribe:List-Post:List-Owner:List-Archive" + /* -------------------------------------------------------------------------- */ /* Length of the preallocated buffer for the "answer" from the dns/txt callback function. This should match the maximum RDLENGTH from DNS. */ @@ -48,6 +57,7 @@ #define PDKIM_VERIFY_INVALID 1 #define PDKIM_VERIFY_FAIL 2 #define PDKIM_VERIFY_PASS 3 +#define PDKIM_VERIFY_POLICY BIT(31) #define PDKIM_VERIFY_FAIL_BODY 1 #define PDKIM_VERIFY_FAIL_MESSAGE 2 @@ -63,14 +73,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; @@ -99,10 +107,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= */ @@ -110,6 +116,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 { @@ -120,7 +141,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 @@ -227,11 +249,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 */ @@ -255,14 +275,15 @@ 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 */ - uschar *cur_header; - int cur_header_size; - int cur_header_len; - char *linebuf; + gstring *cur_header; + uschar *linebuf; int linebuf_offset; int num_headers; pdkim_stringlist *headers; /* Raw headers for verification */ @@ -280,7 +301,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 *, @@ -288,7 +309,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, @@ -296,6 +317,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