final touches on dkim test harness master
authorArt Cancro <ajc@citadel.org>
Sat, 11 May 2024 03:15:07 +0000 (03:15 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 11 May 2024 03:15:07 +0000 (03:15 +0000)
citadel/server/modules/smtp/dkim.c
citadel/tests/dkimtester/README.md
citadel/tests/dkimtester/dkimtester.c

index 248a89564182c8a0fb81fdd6a7b7debbbf032c2d..0ee289e73580d2f22009bf0c6e8a8bc8963a2116 100644 (file)
@@ -209,7 +209,7 @@ char *dkim_canonicalize_body(char *body) {
 }
 
 
-// Second step to canonicalize a block of headers as per the "relaxed" algorithm.
+// First step to canonicalize a block of headers as per the "relaxed" algorithm.
 // Unfold all headers onto single lines.
 void dkim_unfold_headers(StrBuf *unfolded_headers) {
        char *headers_start = (char *)ChrPtr(unfolded_headers);
index 4d46b69605d6dbde93be0001df17a74e5ac79aca..54c93c24e97c2b6686cfdd2a411e5af30f6d6560 100644 (file)
@@ -1,13 +1,11 @@
 # 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.
 
index c923bd5d3e5519d05f7259ffbef623eabb19584e..b54c9047a81381870d3b710a1fcb10d81d899e31 100644 (file)
@@ -2,21 +2,25 @@
 // 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 =
@@ -50,7 +54,6 @@ int main(int argc, char *argv[]) {
                "-----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";
 
@@ -77,12 +80,12 @@ int main(int argc, char *argv[]) {
 
        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);