s/qmail 4.3.17
Next generation secure email transport
Loading...
Searching...
No Matches
dkimverify.h
Go to the documentation of this file.
1/*****************************************************************************
2* Copyright 2005 Alt-N Technologies, Ltd.
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* This code incorporates intellectual property owned by Yahoo! and licensed
11* pursuant to the Yahoo! DomainKeys Patent License Agreement.
12*
13* Unless required by applicable law or agreed to in writing, software
14* distributed under the License is distributed on an "AS IS" BASIS,
15* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16* See the License for the specific language governing permissions and
17* limitations under the License.
18*
19* Changes done by ¢feh@fehcom.de obeying the above license
20*
21*****************************************************************************/
22#ifndef DKIMVERIFY_H
23#define DKIMVERIFY_H
24
25#include "dkim.h"
26#include "dkimbase.h"
27#include <vector>
28
29/* not used anymore
30#define DKIM_ADSP_UNKNOWN 1
31#define DKIM_ADSP_ALL 2
32#define DKIM_ADSP_DISCARDABLE 3
33*/
34
35#define DKIM_POLICY_DOMAIN_NAME_TOO_LONG -50 // internal error
36#define DKIM_POLICY_DNS_TEMP_FAILURE -51 // internal error
37#define DKIM_POLICY_DNS_PERM_FAILURE -52 // internal error
38#define DKIM_POLICY_INVALID -53 // internal error
39
40/* dito
41#define DKIM_SIG_VERSION_PRE_02 0
42#define DKIM_SIG_VERSION_02_PLUS 1
43*/
44
46{
47public:
48 SelectorInfo(const string &sSelector,const string &sDomain);
50
51 string Domain;
52 string Selector;
56 EVP_PKEY *PublicKey; /* the public key */
57 bool Testing;
59
60 int Status;
61
62 int Parse(char* Buffer);
63};
64
66{
67public:
68 SignatureInfo(bool SaveCanonicalizedData);
70
71 void Hash(const char* szBuffer,unsigned nBufLength,bool IsBody=false);
72
73 string Header;
74 unsigned Version;
75 string Domain;
76 string Selector;
82 vector<string> SignedHeaders;
83 unsigned BodyLength;
86 unsigned ExpireTime;
87
90
91 EVP_MD_CTX *m_Hdr_ctx;
92 EVP_MD_CTX *m_Bdy_ctx;
93 EVP_MD_CTX *m_Msg_ctx;
94
96
97 int Status;
98 int m_nHash; // use one of the DKIM_HASH_xxx constants here
101};
102
103class CDKIMVerify : public CDKIMBase
104{
105public:
106
107 CDKIMVerify();
108 ~CDKIMVerify();
109// virtual ~CDKIMVerify() = 0;
110
111 int Init(DKIMVerifyOptions* pOptions);
112
113 int GetResults(void);
114 int GetDetails(int* nSigCount,DKIMVerifyDetails** pDetails);
115// int _DNSGetTXT(const char* szFQDN,char* Buffer,int nBufLen);
116
117 virtual int ProcessHeaders(void);
118 virtual int ProcessBody(char* szBuffer,int nBufLength,bool bEOF);
119
120 const char* GetPractices() { return Practices.c_str(); }
121
122protected:
123
124 int ParseDKIMSignature(const string& sHeader,SignatureInfo &sig);
125
126 SelectorInfo& GetSelector(const string &sSelector,const string &sDomain);
127
128// int GetADSP(const string &sDomain,int &iADSP);
129
130 list<SignatureInfo> Signatures;
131 list<SelectorInfo> Selectors;
132
133 DKIMDNSCALLBACK m_pfnSelectorCallback; // selector record callback
134// DKIMDNSCALLBACK m_pfnPracticesCallback; // ADSP record callback
135
141
142 vector<DKIMVerifyDetails> Details;
143 string Practices;
144};
145
146#endif //DKIMVERIFY_H
int Init(void)
Definition: dkimbase.cpp:49
DKIMDNSCALLBACK m_pfnSelectorCallback
Definition: dkimverify.h:133
bool m_CheckPractices
Definition: dkimverify.h:137
bool m_SubjectIsRequired
Definition: dkimverify.h:138
SelectorInfo & GetSelector(const string &sSelector, const string &sDomain)
vector< DKIMVerifyDetails > Details
Definition: dkimverify.h:142
const char * GetPractices()
Definition: dkimverify.h:120
int GetResults(void)
Definition: dkimverify.cpp:559
string Practices
Definition: dkimverify.h:143
bool m_AllowUnsignedFromHeaders
Definition: dkimverify.h:140
bool m_SaveCanonicalizedData
Definition: dkimverify.h:139
int GetDetails(int *nSigCount, DKIMVerifyDetails **pDetails)
int ParseDKIMSignature(const string &sHeader, SignatureInfo &sig)
Definition: dkimverify.cpp:933
list< SelectorInfo > Selectors
Definition: dkimverify.h:131
virtual int ProcessHeaders(void)
Definition: dkimverify.cpp:758
virtual int ProcessBody(char *szBuffer, int nBufLength, bool bEOF)
bool m_HonorBodyLengthTag
Definition: dkimverify.h:136
list< SignatureInfo > Signatures
Definition: dkimverify.h:130
int Parse(char *Buffer)
string Selector
Definition: dkimverify.h:52
bool Testing
Definition: dkimverify.h:57
EVP_PKEY * PublicKey
Definition: dkimverify.h:56
string Granularity
Definition: dkimverify.h:53
string Domain
Definition: dkimverify.h:51
bool AllowSHA256
Definition: dkimverify.h:55
bool SameDomain
Definition: dkimverify.h:58
bool AllowSHA1
Definition: dkimverify.h:54
string Selector
Definition: dkimverify.h:76
string SignatureData
Definition: dkimverify.h:77
EVP_MD_CTX * m_Hdr_ctx
Definition: dkimverify.h:91
vector< string > SignedHeaders
Definition: dkimverify.h:82
unsigned EmptyLineCount
Definition: dkimverify.h:99
unsigned HeaderCanonicalization
Definition: dkimverify.h:84
unsigned ExpireTime
Definition: dkimverify.h:86
EVP_MD_CTX * m_Bdy_ctx
Definition: dkimverify.h:92
bool m_SaveCanonicalizedData
Definition: dkimverify.h:100
unsigned UnverifiedBodyCount
Definition: dkimverify.h:89
string Domain
Definition: dkimverify.h:75
unsigned BodyCanonicalization
Definition: dkimverify.h:85
unsigned Version
Definition: dkimverify.h:74
string IdentityLocalPart
Definition: dkimverify.h:79
void Hash(const char *szBuffer, unsigned nBufLength, bool IsBody=false)
Definition: dkimverify.cpp:712
string CanonicalizedData
Definition: dkimverify.h:81
EVP_MD_CTX * m_Msg_ctx
Definition: dkimverify.h:93
string BodyHashData
Definition: dkimverify.h:78
string IdentityDomain
Definition: dkimverify.h:80
string Header
Definition: dkimverify.h:73
unsigned VerifiedBodyCount
Definition: dkimverify.h:88
unsigned BodyLength
Definition: dkimverify.h:83
SelectorInfo * m_pSelector
Definition: dkimverify.h:95
int(* DKIMDNSCALLBACK)(const char *szFQDN, char *szBuffer, int nBufLen)
Definition: dkim.h:89