Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:p_conrad
dkim
libdkim-openssl110.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File libdkim-openssl110.patch of Package dkim
--- libdkim/src/evp_wrapper.h.orig 1970-01-01 01:00:00.000000000 +0100 +++ libdkim/src/evp_wrapper.h 2019-01-12 17:43:54.785582597 +0100 @@ -0,0 +1,20 @@ +#pragma once + +#include <openssl/evp.h> + +class evp_wrapper +{ + EVP_MD_CTX* wrapped; +public: + evp_wrapper() : wrapped(EVP_MD_CTX_new()) {} + ~evp_wrapper() + { + if (wrapped) + EVP_MD_CTX_free(wrapped); + } + + operator EVP_MD_CTX*() { return wrapped; } + operator const EVP_MD_CTX*() const { return wrapped; } + EVP_MD_CTX* operator->() { return wrapped; } + const EVP_MD_CTX* operator->() const { return wrapped; } +}; --- libdkim/src/dkimsign.h.orig 2019-01-12 17:42:08.118669029 +0100 +++ libdkim/src/dkimsign.h 2019-01-12 18:16:50.865497823 +0100 @@ -22,13 +22,13 @@ #define DKIMSIGN_H #include "dkimbase.h" +#include "evp_wrapper.h" class CDKIMSign : public CDKIMBase { public: CDKIMSign(); - ~CDKIMSign(); int Init( DKIMSignOptions* pOptions ); @@ -60,13 +60,13 @@ int AssembleReturnedSig( char* szPrivKey ); - EVP_MD_CTX m_Hdr_ietf_sha1ctx; /* the header hash for ietf sha1 */ - EVP_MD_CTX m_Hdr_ietf_sha256ctx; /* the header hash for ietf sha256 */ + evp_wrapper m_Hdr_ietf_sha1ctx; /* the header hash for ietf sha1 */ + evp_wrapper m_Hdr_ietf_sha256ctx; /* the header hash for ietf sha256 */ - EVP_MD_CTX m_Bdy_ietf_sha1ctx; /* the body hash for ietf sha1 */ - EVP_MD_CTX m_Bdy_ietf_sha256ctx; /* the body hash for ietf sha256 */ + evp_wrapper m_Bdy_ietf_sha1ctx; /* the body hash for ietf sha1 */ + evp_wrapper m_Bdy_ietf_sha256ctx; /* the body hash for ietf sha256 */ - EVP_MD_CTX m_allman_sha1ctx; /* the hash for allman sha1 */ + evp_wrapper m_allman_sha1ctx; /* the hash for allman sha1 */ int m_Canon; // canonization method --- libdkim/src/dkimsign.cpp.orig 2019-01-12 17:56:18.986007788 +0100 +++ libdkim/src/dkimsign.cpp 2019-01-12 18:03:15.057780024 +0100 @@ -41,20 +41,11 @@ m_EmptyLineCount = 0; m_pfnHdrCallback = NULL; - EVP_SignInit( &m_allman_sha1ctx, EVP_sha1() ); - EVP_SignInit( &m_Hdr_ietf_sha1ctx, EVP_sha1() ); - EVP_SignInit( &m_Hdr_ietf_sha256ctx, EVP_sha256() ); - EVP_DigestInit( &m_Bdy_ietf_sha1ctx, EVP_sha1() ); - EVP_DigestInit( &m_Bdy_ietf_sha256ctx, EVP_sha256() ); -} - -CDKIMSign::~CDKIMSign() -{ - EVP_MD_CTX_cleanup( &m_allman_sha1ctx ); - EVP_MD_CTX_cleanup( &m_Hdr_ietf_sha1ctx ); - EVP_MD_CTX_cleanup( &m_Hdr_ietf_sha256ctx ); - EVP_MD_CTX_cleanup( &m_Bdy_ietf_sha1ctx ); - EVP_MD_CTX_cleanup( &m_Bdy_ietf_sha256ctx ); + EVP_SignInit( m_allman_sha1ctx, EVP_sha1() ); + EVP_SignInit( m_Hdr_ietf_sha1ctx, EVP_sha1() ); + EVP_SignInit( m_Hdr_ietf_sha256ctx, EVP_sha256() ); + EVP_DigestInit( m_Bdy_ietf_sha1ctx, EVP_sha1() ); + EVP_DigestInit( m_Bdy_ietf_sha256ctx, EVP_sha256() ); } //////////////////////////////////////////////////////////////////////////////// @@ -150,34 +141,34 @@ { if( m_nIncludeBodyHash & DKIM_BODYHASH_ALLMAN_1 ) { - EVP_SignUpdate( &m_allman_sha1ctx, szBuffer, nBufLength ); + EVP_SignUpdate( m_allman_sha1ctx, szBuffer, nBufLength ); } } else { if( m_nIncludeBodyHash < DKIM_BODYHASH_IETF_1 ) { - EVP_SignUpdate( &m_allman_sha1ctx, szBuffer, nBufLength ); + EVP_SignUpdate( m_allman_sha1ctx, szBuffer, nBufLength ); } else if( m_nIncludeBodyHash & DKIM_BODYHASH_IETF_1 ) { if( m_nIncludeBodyHash & DKIM_BODYHASH_ALLMAN_1 ) { - EVP_SignUpdate( &m_allman_sha1ctx, szBuffer, nBufLength ); + EVP_SignUpdate( m_allman_sha1ctx, szBuffer, nBufLength ); } if( m_nHash & DKIM_HASH_SHA256 ) { if( bHdr ) - EVP_SignUpdate( &m_Hdr_ietf_sha256ctx, szBuffer, nBufLength ); + EVP_SignUpdate( m_Hdr_ietf_sha256ctx, szBuffer, nBufLength ); else - EVP_DigestUpdate( &m_Bdy_ietf_sha256ctx, szBuffer, nBufLength ); + EVP_DigestUpdate( m_Bdy_ietf_sha256ctx, szBuffer, nBufLength ); } if( m_nHash != DKIM_HASH_SHA256 ) { if( bHdr ) - EVP_SignUpdate( &m_Hdr_ietf_sha1ctx, szBuffer, nBufLength ); + EVP_SignUpdate( m_Hdr_ietf_sha1ctx, szBuffer, nBufLength ); else - EVP_DigestUpdate( &m_Bdy_ietf_sha1ctx, szBuffer, nBufLength ); + EVP_DigestUpdate( m_Bdy_ietf_sha1ctx, szBuffer, nBufLength ); } } } @@ -865,7 +856,7 @@ unsigned char Hash[EVP_MAX_MD_SIZE]; unsigned int nHashLen = 0; - EVP_DigestFinal( bUseSha256 ? &m_Bdy_ietf_sha256ctx : &m_Bdy_ietf_sha1ctx, Hash, &nHashLen ); + EVP_DigestFinal( bUseSha256 ? m_Bdy_ietf_sha256ctx : m_Bdy_ietf_sha1ctx, Hash, &nHashLen ); bio = BIO_new(BIO_s_mem()); if (!bio) { @@ -936,11 +927,11 @@ if( bUseIetfBodyHash ) { - EVP_SignUpdate( bUseSha256 ? &m_Hdr_ietf_sha256ctx : &m_Hdr_ietf_sha1ctx, sTemp.c_str(), sTemp.size() ); + EVP_SignUpdate( bUseSha256 ? m_Hdr_ietf_sha256ctx : m_Hdr_ietf_sha1ctx, sTemp.c_str(), sTemp.size() ); } else { - EVP_SignUpdate( &m_allman_sha1ctx, sTemp.c_str(), sTemp.size() ); + EVP_SignUpdate( m_allman_sha1ctx, sTemp.c_str(), sTemp.size() ); } bio = BIO_new_mem_buf(szPrivKey, -1); @@ -967,11 +958,11 @@ if( bUseIetfBodyHash ) { - nSignRet = EVP_SignFinal( bUseSha256 ? &m_Hdr_ietf_sha256ctx : &m_Hdr_ietf_sha1ctx, sig, &siglen, pkey); + nSignRet = EVP_SignFinal( bUseSha256 ? m_Hdr_ietf_sha256ctx : m_Hdr_ietf_sha1ctx, sig, &siglen, pkey); } else { - nSignRet = EVP_SignFinal( &m_allman_sha1ctx, sig, &siglen, pkey); + nSignRet = EVP_SignFinal( m_allman_sha1ctx, sig, &siglen, pkey); } EVP_PKEY_free(pkey); --- libdkim/src/dkimverify.h.orig 2019-01-12 17:42:13.782611339 +0100 +++ libdkim/src/dkimverify.h 2019-01-12 18:16:36.973638731 +0100 @@ -22,6 +22,7 @@ #define DKIMVERIFY_H #include "dkimbase.h" +#include "evp_wrapper.h" #include <vector> #define DKIM_ADSP_UNKNOWN 1 @@ -61,7 +62,6 @@ { public: SignatureInfo(bool SaveCanonicalizedData); - ~SignatureInfo(); void Hash( const char* szBuffer, unsigned nBufLength, bool IsBody=false ); @@ -83,8 +83,8 @@ unsigned VerifiedBodyCount; unsigned UnverifiedBodyCount; - EVP_MD_CTX m_Hdr_ctx; - EVP_MD_CTX m_Bdy_ctx; + evp_wrapper m_Hdr_ctx; + evp_wrapper m_Bdy_ctx; SelectorInfo *m_pSelector; int Status; --- libdkim/src/dkimverify.cpp.orig 2019-01-12 17:56:02.178178575 +0100 +++ libdkim/src/dkimverify.cpp 2019-01-12 18:16:08.037932231 +0100 @@ -43,8 +43,8 @@ { VerifiedBodyCount = 0; UnverifiedBodyCount = 0; - EVP_MD_CTX_init( &m_Hdr_ctx ); - EVP_MD_CTX_init( &m_Bdy_ctx ); + EVP_MD_CTX_init( m_Hdr_ctx ); + EVP_MD_CTX_init( m_Bdy_ctx ); m_pSelector = NULL; Status = DKIM_SUCCESS; m_nHash = 0; @@ -52,13 +52,6 @@ m_SaveCanonicalizedData = s; } -SignatureInfo::~SignatureInfo() -{ - EVP_MD_CTX_cleanup( &m_Hdr_ctx ); - EVP_MD_CTX_cleanup( &m_Bdy_ctx ); -} - - inline bool isswsp(char ch) { return( ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' ); @@ -459,7 +452,7 @@ unsigned char md[EVP_MAX_MD_SIZE]; unsigned len = 0; - int res = EVP_DigestFinal( &i->m_Bdy_ctx, md, &len); + int res = EVP_DigestFinal( i->m_Bdy_ctx, md, &len); if (!res || len != i->BodyHashData.length() || memcmp(i->BodyHashData.data(), md, len) != 0) { @@ -515,7 +508,7 @@ assert( i->m_pSelector != NULL ); - int res = EVP_VerifyFinal( &i->m_Hdr_ctx, (unsigned char *) i->SignatureData.data(), i->SignatureData.length(), i->m_pSelector->PublicKey); + int res = EVP_VerifyFinal( i->m_Hdr_ctx, (unsigned char *) i->SignatureData.data(), i->SignatureData.length(), i->m_pSelector->PublicKey); if (res == 1) { @@ -658,11 +651,11 @@ if (IsBody && !BodyHashData.empty()) { - EVP_DigestUpdate( &m_Bdy_ctx, szBuffer, nBufLength ); + EVP_DigestUpdate( m_Bdy_ctx, szBuffer, nBufLength ); } else { - EVP_VerifyUpdate( &m_Hdr_ctx, szBuffer, nBufLength ); + EVP_VerifyUpdate( m_Hdr_ctx, szBuffer, nBufLength ); } if (m_SaveCanonicalizedData) @@ -741,13 +734,13 @@ // initialize the hashes if (sig.m_nHash == DKIM_HASH_SHA256) { - EVP_VerifyInit( &sig.m_Hdr_ctx, EVP_sha256() ); - EVP_DigestInit( &sig.m_Bdy_ctx, EVP_sha256() ); + EVP_VerifyInit( sig.m_Hdr_ctx, EVP_sha256() ); + EVP_DigestInit( sig.m_Bdy_ctx, EVP_sha256() ); } else { - EVP_VerifyInit( &sig.m_Hdr_ctx, EVP_sha1() ); - EVP_DigestInit( &sig.m_Bdy_ctx, EVP_sha1() ); + EVP_VerifyInit( sig.m_Hdr_ctx, EVP_sha1() ); + EVP_DigestInit( sig.m_Bdy_ctx, EVP_sha1() ); } // compute the hash of the header @@ -1337,7 +1330,7 @@ return DKIM_SELECTOR_PUBLIC_KEY_INVALID; // make sure public key is the correct type (we only support rsa) - if (pkey->type == EVP_PKEY_RSA || pkey->type == EVP_PKEY_RSA2) + if (EVP_PKEY_base_id(pkey) == EVP_PKEY_RSA || EVP_PKEY_base_id(pkey) == EVP_PKEY_RSA2) { PublicKey = pkey; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor