summaryrefslogtreecommitdiff
path: root/src/dkimverify.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dkimverify.cpp')
-rw-r--r--src/dkimverify.cpp65
1 files changed, 33 insertions, 32 deletions
diff --git a/src/dkimverify.cpp b/src/dkimverify.cpp
index 6693d8e..334e1b4 100644
--- a/src/dkimverify.cpp
+++ b/src/dkimverify.cpp
@@ -1,23 +1,24 @@
/*****************************************************************************
*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
*
-* http://www.apache.org/licenses/LICENSE-2.0
+* http://www.apache.org/licenses/LICENSE-2.0
*
-* This code incorporates intellectual property owned by Yahoo! and licensed
+* This code incorporates intellectual property owned by Yahoo! and licensed
* pursuant to the Yahoo! DomainKeys Patent License Agreement.
*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
* limitations under the License.
*
* Changes done by ¢feh@fehcom.de obeying the above license
*
*****************************************************************************/
+
#include "dkimverify.h"
#include <assert.h>
@@ -29,6 +30,7 @@
#include "dkim.h"
#include "dnsgettxt.h"
+
extern "C" {
#include "stralloc.h"
@@ -44,10 +46,10 @@ extern "C" {
* a) The 'body hash' => bh=[sha1|sha256]
* b) The signature => b=[RSA-SHA1|RSA-SHA256|PureEd25519]
*
-* Several DKIM headers (=signatures) may be present in the email.
+* Several DKIM headers (=signatures) may be present in the email.
* Here, it is limited to max. Shall we really evaluate all?
*
-* Caution: Using hybrid signatures, calling the destructor will core dump
+* Caution: Using hybrid signatures, calling the destructor will core dump
* given EVP_MD_CTX_free() upon the next call of EVP_DigestInit.
* Using the destructor with EVP_MD_CTX_reset() however works.
*
@@ -55,8 +57,8 @@ extern "C" {
#define _strnicmp strncasecmp
#define _stricmp strcasecmp
-#define MAX_SIGNATURES 10 // maximum number of DKIM signatures to process/message
-#define FDLOG stderr /* writing to another FD requires a method */
+#define MAX_SIGNATURES 10 // maximum number of DKIM signatures to process/message
+#define FDLOG stderr // writing to another FD requires a method
string SigHdr;
size_t m_SigHdr;
@@ -309,13 +311,13 @@ bool ParseTagValueList(char *tagvaluelist, const char *wanted[], char *values[])
////////////////////////////////////////////////////////////////////////////////
char Tohex(char ch)
{
- if (ch >= '0' && ch <= '9')
+ if (ch >= '0' && ch <= '9') {
return (ch - '0');
- else if (ch >= 'A' && ch <= 'F')
+ } else if (ch >= 'A' && ch <= 'F') {
return (ch - 'A' + 10);
- else if (ch >= 'a' && ch <= 'f')
+ } else if (ch >= 'a' && ch <= 'f') {
return (ch - 'a' + 10);
- else {
+ } else {
assert(0);
return 0;
}
@@ -350,18 +352,18 @@ void DecodeQuotedPrintable(char *ptr)
////////////////////////////////////////////////////////////////////////////////
unsigned DecodeBase64(char *ptr)
{
+ // clang-format off
static const char base64_table[256] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6,
- 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
- -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,
+ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,
+ -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ };
+ // clang-format on
unsigned char *s = (unsigned char *)ptr;
unsigned char *d = (unsigned char *)ptr;
@@ -1194,9 +1196,7 @@ SelectorInfo::SelectorInfo(const string& sSelector, const string& sDomain) :
SelectorInfo::~SelectorInfo()
{
- if (PublicKey != NULL) {
- EVP_PKEY_free(PublicKey);
- }
+ if (PublicKey != NULL) EVP_PKEY_free(PublicKey);
}
////////////////////////////////////////////////////////////////////////////////
@@ -1373,8 +1373,9 @@ SelectorInfo& CDKIMVerify::GetSelector(const string& sSelector, const string& sD
if (m_pfnSelectorCallback) {
DNSResult = m_pfnSelectorCallback(sFQDN.c_str(), Buffer, BufLen);
- } else
+ } else {
DNSResult = _DNSGetTXT(sFQDN.c_str(), Buffer, BufLen);
+ }
// Buffer++; BufLen--;