Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src-draft/trunk]: src/sys/dev Specify which cgd self-test failed and dump th...



details:   https://anonhg.NetBSD.org/src-all/rev/1ed75769a84a
branches:  trunk
changeset: 934424:1ed75769a84a
user:      Taylor R Campbell <riastradh%NetBSD.org@localhost>
date:      Fri Jun 12 04:34:15 2020 +0000

description:
Specify which cgd self-test failed and dump the mismatch.

diffstat:

 sys/dev/cgd.c |  16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r 53e5160f7e9d -r 1ed75769a84a sys/dev/cgd.c
--- a/sys/dev/cgd.c     Fri Jun 05 16:59:07 2020 +0000
+++ b/sys/dev/cgd.c     Fri Jun 12 04:34:15 2020 +0000
@@ -1635,13 +1635,21 @@
 
                cgd_cipher(&sc, buf, buf, txtlen, selftests[i].blkno,
                                selftests[i].secsize, CGD_CIPHER_ENCRYPT);
-               if (memcmp(buf, selftests[i].ctxt, txtlen) != 0)
-                       panic("encryption is broken");
+               if (memcmp(buf, selftests[i].ctxt, txtlen) != 0) {
+                       hexdump(printf, "was", buf, txtlen);
+                       hexdump(printf, "exp", selftests[i].ctxt, txtlen);
+                       panic("cgd %s encryption is broken [%zu]",
+                           selftests[i].alg, i);
+               }
 
                cgd_cipher(&sc, buf, buf, txtlen, selftests[i].blkno,
                                selftests[i].secsize, CGD_CIPHER_DECRYPT);
-               if (memcmp(buf, selftests[i].ptxt, txtlen) != 0)
-                       panic("decryption is broken");
+               if (memcmp(buf, selftests[i].ptxt, txtlen) != 0) {
+                       hexdump(printf, "was", buf, txtlen);
+                       hexdump(printf, "exp", selftests[i].ptxt, txtlen);
+                       panic("cgd %s decryption is broken [%zu]",
+                           selftests[i].alg, i);
+               }
 
                kmem_free(buf, txtlen);
                sc.sc_cfuncs->cf_destroy(sc.sc_cdata.cf_priv);



Home | Main Index | Thread Index | Old Index