Skip to content

Commit

Permalink
Merge pull request trusteddomainproject#162 from glts/openssl3
Browse files Browse the repository at this point in the history
Upgrade to OpenSSL 3
  • Loading branch information
futatuki committed Apr 24, 2024
2 parents 9113cc5 + 17f3749 commit e8ffa20
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 326 deletions.
7 changes: 3 additions & 4 deletions libopendkim/base32.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,21 @@ dkim_base32_encode(char *buf, size_t *buflen, const void *data, size_t size)

#ifdef TEST
#include <openssl/sha.h>
#include <openssl/evp.h>

int
main(int argc, char **argv)
{
int x;
size_t buflen;
SHA_CTX sha;
char buf[128];
unsigned char shaout[SHA_DIGEST_LENGTH];

memset(buf, '\0', sizeof buf);
buflen = sizeof buf;

SHA1_Init(&sha);
SHA1_Update(&sha, argv[1], strlen(argv[1]));
SHA1_Final(shaout, &sha);
(void) EVP_Digest(argv[1], strlen(argv[1]), shaout, NULL, EVP_sha1(),
NULL);

x = dkim_base32_encode(buf, &buflen, shaout, SHA_DIGEST_LENGTH);

Expand Down
16 changes: 5 additions & 11 deletions libopendkim/dkim-atps.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#else /* USE_GNUTLS */
/* openssl includes */
# include <openssl/sha.h>
# include <openssl/evp.h>
#endif /* USE_GNUTLS */

/* prototypes */
Expand Down Expand Up @@ -113,11 +114,6 @@ dkim_atps_check(DKIM *dkim, DKIM_SIGINFO *sig, struct timeval *timeout,
u_char *eom;
#ifdef USE_GNUTLS
gnutls_hash_hd_t ctx;
#else /* USE_GNUTLS */
SHA_CTX ctx;
# ifdef HAVE_SHA256
SHA256_CTX ctx2;
# endif /* HAVE_SHA256 */
#endif /* USE_GNUTLS */
struct timeval to;
HEADER hdr;
Expand Down Expand Up @@ -198,16 +194,14 @@ dkim_atps_check(DKIM *dkim, DKIM_SIGINFO *sig, struct timeval *timeout,
switch (hash)
{
case DKIM_HASHTYPE_SHA1:
SHA1_Init(&ctx);
SHA1_Update(&ctx, sdomain, strlen(sdomain));
SHA1_Final(digest, &ctx);
(void) EVP_Digest(sdomain, strlen(sdomain), digest,
NULL, EVP_sha1(), NULL);
break;

# ifdef HAVE_SHA256
case DKIM_HASHTYPE_SHA256:
SHA256_Init(&ctx2);
SHA256_Update(&ctx2, sdomain, strlen(sdomain));
SHA256_Final(digest, &ctx2);
(void) EVP_Digest(sdomain, strlen(sdomain), digest,
NULL, EVP_sha256(), NULL);
break;
# endif /* HAVE_SHA256 */

Expand Down
Loading

0 comments on commit e8ffa20

Please sign in to comment.