s/qmail 4.3.17
Next generation secure email transport
Loading...
Searching...
No Matches
dkimsign.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 DKIMSIGN_H
23#define DKIMSIGN_H
24
25#include "dkim.h"
26#include "dkimbase.h"
27
28class CDKIMSign : public CDKIMBase
29{
30public:
31 CDKIMSign();
32 ~CDKIMSign();
33
34 //int Init() = delete;
35 int Init(DKIMSignOptions* pOptions);
36 int GetSig2(char* szRSAPrivKey,char* szECCPrivKey,char** pszSignature);
37
38 virtual int ProcessHeaders(void) override;
39 virtual int ProcessBody(char* szBuffer,int nBufLength,bool bEOF) override;
40
42
43 void Hash(const char* szBuffer,int nBufLength,bool bHdr);
44
45protected:
46
47 bool SignThisTag(const string& sTag);
48 void GetHeaderParams(const string& sHdr);
49 void ProcessHeader(const string& sHdr);
50 bool ParseFromAddress(void);
51
52 void InitSig(void);
53 void AddTagToSig(const char* const Tag,const string &sValue,char cbrk,bool bFold);
54 void AddTagToSig(const char* const Tag,unsigned long nValue);
55 void AddInterTagSpace(int nSizeOfNextTag);
56 void AddFoldedValueToSig(const string &sValue,char cbrk);
57
58 bool IsRequiredHeader(const string& sTag);
59 int ConstructSignature(char* szSignKey,int nSigAlg);
60
61 int AssembleReturnedSig(char* szRSAPrivKey,char* szECCPrivKey);
62
63 EVP_MD_CTX *m_Hdr_sha1ctx; /* the RSA SHA1 signature */
64 EVP_MD_CTX *m_Hdr_sha256ctx; /* the RSA SHA256 signature */
65 EVP_MD_CTX *m_Hdr_ed25519ctx; /* the PureEd25519 signature */
66
67 EVP_MD_CTX *m_Bdy_sha1ctx; /* the SHA1 digest */
68 EVP_MD_CTX *m_Bdy_sha256ctx; /* the SHA256 digest for RSA */
69 EVP_MD_CTX *m_Edy_sha256ctx; /* the SHA256 digest for Ed25519 */
70
71 int m_Canon; /* canonization method */
72
74
75 string hParam;
76 string sFrom;
77 string sSender;
78 string sSelector;
79 string eSelector; /* Used for Ed25519 signatures */
80 string sDomain;
81 string sIdentity; /* for i= tag, if empty tag will not be included in sig */
83
87 int m_nIncludeTimeStamp; // 0 = don't include t= tag, 1 = include t= tag
88 int m_nIncludeQueryMethod; // 0 = don't include q= tag, 1 = include q= tag
89 int m_nHash; // use one of the DKIM_HASH_xx constants here
90 int m_nIncludeCopiedHeaders; // 0 = don't include z= tag, 1 = include z= tag
91
93
94 string m_sSig; // DKIM-Signature ....
96
99
101
102 string SigHdrs;
104};
105
106#endif // DKIMSIGN_H
int Init(void)
Definition: dkimbase.cpp:49
string m_sSig
Definition: dkimsign.h:94
DKIMHEADERCALLBACK m_pfnHdrCallback
Definition: dkimsign.h:92
EVP_MD_CTX * m_Hdr_ed25519ctx
Definition: dkimsign.h:65
int GetSig2(char *szRSAPrivKey, char *szECCPrivKey, char **pszSignature)
Definition: dkimsign.cpp:681
bool ParseFromAddress(void)
Definition: dkimsign.cpp:510
int m_nIncludeCopiedHeaders
Definition: dkimsign.h:90
int m_nBodyLength
Definition: dkimsign.h:85
string hParam
Definition: dkimsign.h:75
string sDomain
Definition: dkimsign.h:80
void AddInterTagSpace(int nSizeOfNextTag)
Definition: dkimsign.cpp:603
void ProcessHeader(const string &sHdr)
Definition: dkimsign.cpp:428
void InitSig(void)
Definition: dkimsign.cpp:553
time_t m_ExpireTime
Definition: dkimsign.h:86
EVP_MD_CTX * m_Edy_sha256ctx
Definition: dkimsign.h:69
bool IsRequiredHeader(const string &sTag)
Definition: dkimsign.cpp:708
string sFrom
Definition: dkimsign.h:76
void GetHeaderParams(const string &sHdr)
Definition: dkimsign.cpp:306
EVP_MD_CTX * m_Hdr_sha1ctx
Definition: dkimsign.h:63
bool m_IncludeBodyLengthTag
Definition: dkimsign.h:84
int m_nHash
Definition: dkimsign.h:89
int m_nSigPos
Definition: dkimsign.h:95
EVP_MD_CTX * m_Hdr_sha256ctx
Definition: dkimsign.h:64
string SigHdrs
Definition: dkimsign.h:102
string eSelector
Definition: dkimsign.h:79
int m_SigHdrs
Definition: dkimsign.h:103
virtual int ProcessBody(char *szBuffer, int nBufLength, bool bEOF) override
Definition: dkimsign.cpp:460
EVP_MD_CTX * m_Bdy_sha256ctx
Definition: dkimsign.h:68
int m_EmptyLineCount
Definition: dkimsign.h:73
void AddTagToSig(const char *const Tag, const string &sValue, char cbrk, bool bFold)
Definition: dkimsign.cpp:566
int ConstructSignature(char *szSignKey, int nSigAlg)
Definition: dkimsign.cpp:741
string sIdentity
Definition: dkimsign.h:81
EVP_MD_CTX * m_Bdy_sha1ctx
Definition: dkimsign.h:67
void AddFoldedValueToSig(const string &sValue, char cbrk)
Definition: dkimsign.cpp:621
bool m_bReturnedSigAssembled
Definition: dkimsign.h:98
int AssembleReturnedSig(char *szRSAPrivKey, char *szECCPrivKey)
Definition: dkimsign.cpp:967
virtual int ProcessHeaders(void) override
Definition: dkimsign.cpp:338
string m_sCopiedHeaders
Definition: dkimsign.h:100
bool SignThisTag(const string &sTag)
Definition: dkimsign.cpp:264
string sRequiredHeaders
Definition: dkimsign.h:82
void Hash(const char *szBuffer, int nBufLength, bool bHdr)
Definition: dkimsign.cpp:213
int m_nIncludeTimeStamp
Definition: dkimsign.h:87
string sSelector
Definition: dkimsign.h:78
int m_nIncludeQueryMethod
Definition: dkimsign.h:88
string m_sReturnedSig
Definition: dkimsign.h:97
string sSender
Definition: dkimsign.h:77
int m_Canon
Definition: dkimsign.h:71
CKDKIMConstants
Definition: dkimsign.h:41
@ OptimalHeaderLineLength
Definition: dkimsign.h:41
int(* DKIMHEADERCALLBACK)(const char *szHeader)
Definition: dkim.h:86