5 ms·
It is a little mind boggling that support for proper handling of this didn't arrive until c11. For a symmetric cipher without a demanding setup/init phase - wou
by e12e 12y ago
It is a little mind boggling that support for proper handling of this didn't arrive until c11. For a symmetric cipher without a demanding setup/init phase - would it make sense to just do a few rounds on a buffer using the zeroed key? Obviously quite a few more cycles, but should at least be a predictable (constant) overhead?
- maxlybbert 12y agoWhat do you mean? The solution that Percival presents compiles fine on my C89 compiler.
- e12e 12y agoI didn't mean to imply that the solution as presented didn't work, I was just wondering if it would also work simply running the cipher with the zeroed key in order to avoid zeroing the key being optimized away. Obviously that'd be a lot more cycles; I'm just curious if it would be a viable solution ;-)
- maxlybbert 12y agoI was referring to the first sentence ("It is a little mind boggling that support for proper handling of this didn't arrive until c11."). I don't see anything C11-specific in the code Percival posted. I don't know enough to say anything useful about the rest of your comment.
- e12e 12y agoMy point was that this dance around "observed behaviour" isn't needed in C11, as per: "(...) on C11 (are there any fully C11-compliant platforms yet?) you can use the memset_s function. (...) [which is] guaranteed (or at least specified) to write the provided buffer and to not be optimized away." On another note, searching for memset_s and openbsd yielded this hit from 2012: https://mail-index.netbsd.org/tech-security/2012/07/22/msg000540.html https://mail-index.netbsd.org/tech-security/2012/07/22/msg00... Which seems to point back to: https://mail-index.netbsd.org/tech-userlevel/2012/02/25/msg006157.html https://mail-index.netbsd.org/tech-userlevel/2012/02/25/msg0... So I guess the "trick" outlined in the (very lucid) post has been known for a while.
- maxlybbert 12y agoThanks. I had missed the part in the article about the C11 changes.