Trying to find out what causes this variable to change or not to change

Programming, for all ages and all languages.
Post Reply
Ethin
Member
Member
Posts: 625
Joined: Sun Jun 23, 2019 5:36 pm
Location: North Dakota, United States

Trying to find out what causes this variable to change or not to change

Post by Ethin »

So I'm not sure if anyone here is knowledgeable with cryptography/cryptographic protocols and the noise protocol in particular, but I thought I would ask because this bug is bothering me and I can't seem to figure out what the problem is (and yeah, I've tried using watchpoints, but for some reason GDB uses software ones even though it's free to use hardware ones and I haven't told it otherwise). So I thought I'd ask if anyone might be able to give me a helping hand.

In my implementation, the NN handshake pattern (no static key for initiator or responder) works perfectly fine. However, if I try the XX pattern (or, really, any other pattern), it breaks and gives me an invalid MAC exception. From my debugging so far I've determined that the additional data mismatches with what it should really be, and I can't tell if something is being copied where it shouldn't, or if something isn't being copied where it should be, etc., and comparing against what the Noise protocol spec requires makes it look like what I've done is correct (even though it obviously isn't). Specifically, the failure occurs when the initiator attempts to read the message from the responder. The failure case is in examples/Noise_XX_25519_ChaChaPoly_Blake2b.cpp if anyone does wish to take a look. I use the monocypher crypto library, in monocypher.c/h and monocypher-ed25519.c/h, and I know those aren't the problem because the NN pattern works fine and I imagine if it was the problem those would break either spuriously or all the time. The actual code of the lib is in noise.cpp/h and uses some modern C++20 features.

I hope this isn't a long-shot, but if it is, at least I did ask. :) I would appreciate any help/suggestions/tips that anyone could provide, because my debugging knowledge is failing me here, and I'm not sure what to try next. I've gone so far as to look at other implementations of the specification (like Dissononce in Python) but from what I can tell I'm not doing anything substantially different from what others are doing, at least those that I've checked.
Post Reply