<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 3, 2015, at 11:41 AM, Tony Arcieri <<a href="mailto:bascule@gmail.com" class="">bascule@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 3, 2015 at 11:35 AM, Irene Knapp <span dir="ltr" class=""><<a href="mailto:ireneista@gmail.com" target="_blank" class="">ireneista@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><span style="font-size:19.7999992370605px;line-height:23.7600002288818px" class="">Surely, what you are describing is a lightweight tool that either generates LLVM bitcode, or hooks into the LLVM backends at a slightly lower level than that to output particular instructions when that's what you really, really want - but I suspect its hinting system already makes that unnecessary for this use-case. LLVM bitcode is precisely this "mostly concrete assembly" concept that you're describing.</span></div></blockquote><div class=""><br class=""></div><div class="">The problem with using LLVM in this context is robust cryptographic implementations need to follow a very specific set of rules to avoid cache timing attacks, and LLVM is not designed to follow these rules:</div><div class=""><br class=""></div><div class=""><a href="https://cryptocoding.net/index.php/Coding_rules" class="">https://cryptocoding.net/index.php/Coding_rules</a></div><div class=""><br class=""></div><div class="">LLVM has not been designed to support the generation of constant time code and is instead rather eager to do things like insert branches in otherwise branch free code if it thinks the code can be better optimized. </div></div><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature">Tony Arcieri</div></div></div></div></blockquote><br class=""></div><div>It may be that if your tool chooses carefully the optimization passes — or even avoids most of them entirely — you could get constant-time operation. But I don’t know enough about LLVM’s codegen to be sure one way or the other. At least until recently, though, it was absolutely terrible at things like add-with-carry intrinsics. (Not necessarily making them variable time, but lowering add; addc to add; setc; zext; add; add.)</div><div><br class=""></div><div>— Mike</div></body></html>