# dkimtester
-This was originally where we developed the DKIM code for Citadel
-but it is properly merged into Citadel now. What's left is just
-a test harness.
-
-You must have the `Mail::DKIM::Verifier` perl module installed,
-which can be found on CPAN.
-
-Also it depends on a DKIM record for `dev.citadel.org` which is
-correct at the time I am writing this. Good luck keeping that in
-place.
+This is a test harness for Citadel's DKIM signing code. As this is
+being written, the public DNS for dev.citadel.org has a DKIM record
+that matches the private key in this test program. This is not
+guaranteed to continue and if you want to run this test you might need
+to set things up for yourself.
+
+To run this test, you must have the `Mail::DKIM::Verifier` perl module
+installed, which can be found on CPAN.
// This contains a private key that, at the time of writing, matches the DKIM public key for dev.citadel.org
// We can use the attached test message to validate a signature against that.
-#include <stdlib.h>
-#include <unistd.h>
#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <time.h>
-#include <assert.h>
#include <syslog.h>
#include <libcitadel.h>
-// oof, a prototype where one does not belong hehe
+// This was easier than trying to figure out the header situation
void dkim_sign(StrBuf *email, char *pkey_in, char *domain, char *selector);
int main(int argc, char *argv[]) {
+ // display the greeting
+ fprintf(stderr,
+ "\033[44m\033[1m╔════════════════════════════════════════════════════════════════════════╗\033[0m\n"
+ "\033[44m\033[1m║ DKIM signature test program for Citadel ║\033[0m\n"
+ "\033[44m\033[1m║ Copyright (c) 2024 by citadel.org et al. ║\033[0m\n"
+ "\033[44m\033[1m║ This program is open source software. Use, duplication, or disclosure ║\033[0m\n"
+ "\033[44m\033[1m║ is subject to the terms of the GNU General Public license v3. ║\033[0m\n"
+ "\033[44m\033[1m╚════════════════════════════════════════════════════════════════════════╝\033[0m\n"
+ );
+
openlog("dkim", LOG_PERROR, LOG_USER);
char *private_key =
"-----END PRIVATE KEY-----\n"
;
- // These elements are identical to the ones from previous revisions. Don't change them; we need to compare.
char *domain = "dev.citadel.org";
char *selector = "foo";
FILE *fp;
printf("\033[34m-----\033[0m\n");
- printf("Piping original version to test program...\n");
+ printf("Piping original version to test program (this should pass)\n");
fp = popen("./tester.pl | sed s/pass/\033[32mpass\033[0m/g | sed s/fail/\033[31mfail\033[0m/g", "w");
fwrite((char *)ChrPtr(email), StrLength(email), 1, fp);
pclose(fp);
printf("\033[34m-----\033[0m\n");
- printf("Piping altered version to test program...\n");
+ printf("Piping altered version to test program (this should fail)\n");
fp = popen("sed s/oggs/argh/g | ./tester.pl | sed s/pass/\033[32mpass\033[0m/g | sed s/fail/\033[31mfail\033[0m/g", "w");
fwrite((char *)ChrPtr(email), StrLength(email), 1, fp);
pclose(fp);