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/28dde22c49fd
branches:  trunk
changeset: 934494:28dde22c49fd
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 c22672298342 -r 28dde22c49fd sys/dev/cgd.c
--- a/sys/dev/cgd.c     Fri May 29 20:34:04 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