commit - 37df18b613e7509c3960626974187bc8e0ac409e
commit + fddd7e1e21bc87a24aeca4650a48254254e0cdcb
blob - 153f7827cf12557f240963b50c48d147fb242243
blob + b3d4cb83bc6b87b9508a17fdbbac6496b1d7aca9
--- main.c
+++ main.c
static char **sign_headers = dsign_headers;
static size_t nsign_headers = sizeof(dsign_headers) / sizeof(*dsign_headers);
-#define HASH_SHA1 0
-#define HASH_SHA256 1
-static int hashalg = HASH_SHA256;
+static char *hashalg = "sha256";
+static char *cryptalg = "rsa";
-#define CRYPT_RSA 0
-static int cryptalg = CRYPT_RSA;
-
#define CANON_SIMPLE 0
#define CANON_RELAXED 1
static int canonheader = CANON_SIMPLE;
while ((ch = getopt(argc, argv, "a:c:Dd:h:k:s:")) != -1) {
switch (ch) {
case 'a':
- if (strncmp(optarg, "rsa-", 4))
+ if (strncmp(optarg, "rsa-", 4) != 0)
err(1, "invalid algorithm");
- if (strcmp(optarg + 4, "sha256") == 0)
- hashalg = HASH_SHA256;
- else if (strcmp(optarg + 4, "sha1") == 0)
- hashalg = HASH_SHA1;
- else
- err(1, "invalid algorithm");
+ hashalg = optarg + 4;
break;
case 'c':
if (strncmp(optarg, "simple", 6) == 0) {
usage();
}
}
- if (hashalg == HASH_SHA1)
- hash_md = EVP_sha1();
- else
- hash_md = EVP_sha256();
-
log_init(debug, LOG_MAIL);
+
+ OpenSSL_add_all_digests();
+ if ((hash_md = EVP_get_digestbyname(hashalg)) == NULL)
+ fatalx("Can't find hash: %s", hashalg);
+
if (pledge("tmppath stdio", NULL) == -1)
fatal("pledge");
if (!dkim_signature_printf(session,
"DKIM-signature: %s; a=%s-%s; c=%s/%s; d=%s; s=%s; ", "v=1",
- cryptalg == CRYPT_RSA ? "rsa" : "",
- hashalg == HASH_SHA1 ? "sha1" : "sha256",
+ cryptalg,
+ hashalg,
canonheader == CANON_SIMPLE ? "simple" : "relaxed",
canonbody == CANON_SIMPLE ? "simple" : "relaxed",
domain, selector))