<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Chosen Plaintext</title>
    <description>Notes on cryptography, programming, and information security.
</description>
    <link>https://www.chosenplaintext.ca/</link>
    <atom:link href="https://www.chosenplaintext.ca/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Fri, 28 Jul 2017 04:22:49 -0400</pubDate>
    <lastBuildDate>Fri, 28 Jul 2017 04:22:49 -0400</lastBuildDate>
    
      <item>
        <title>The radix 2^51 trick</title>
        <pubDate>Thu, 01 Jun 2017 00:00:00 -0400</pubDate>

        
        <description>
          &lt;p&gt;&lt;em&gt;&lt;strong&gt;Faster addition and subtraction on modern CPUs&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Do you remember how to do long addition on paper?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; ¹¹ ¹
  6876
+ 3406
------
 10282
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Starting from the “ones” position, we add 6 + 6 = 12, write down a 2 and carry a 1.
We proceed to the left, one position at a time, until there are no more digits
to add.&lt;/p&gt;

&lt;p&gt;When implementing addition for large integers (e.g. 2&lt;sup&gt;64&lt;/sup&gt; and above), it’s common to write
code that looks quite similar to this algorithm.
Interestingly, there’s a straightforward trick that can speed up this
process enormously on modern CPUs…&lt;/p&gt;


          &lt;p&gt;&lt;a href=&quot;https://www.chosenplaintext.ca/articles/radix-2-51-trick.html&quot;&gt;Continue reading…&lt;/a&gt;&lt;/p&gt;
        </description>
        <link>https://www.chosenplaintext.ca/articles/radix-2-51-trick.html</link>
        <guid isPermaLink="false">https://www.chosenplaintext.ca/2017/06/01/radix-2-51-trick.html</guid>
        

        
        
      </item>
    
      <item>
        <title>A beginner's guide to constant-time cryptography</title>
        <pubDate>Fri, 21 Apr 2017 00:00:00 -0400</pubDate>

        
        <description>
          &lt;p&gt;For programmers new to cryptography, there are plenty of “known unknowns” –
unfamiliar terms like “elliptic curves” and “random oracles”, and unnecessarily
long acronyms (“RSASSA-PKCS-v1_5”, like really?). But what really gives cryptography
its reputation is the unknown unknowns. The things that catch even experienced
developers by surprise.&lt;/p&gt;

&lt;p&gt;Quick, where’s the vulnerability in this code? (I used JavaScript here, but the
same vulnerability would occur in Python, Ruby, and most other languages.)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// Throw an error if inputKey is not correct.
// inputKey and correctKey are both strings
function checkApiKey(inputKey, correctKey) {
	if (inputKey !== correctKey) {
		throw new Error(&quot;wrong key&quot;);
	}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you spotted it, nice work. I’m guessing you have at least a passing interest in cryptography.&lt;/p&gt;

&lt;p&gt;If you didn’t, here’s how the exploit works…&lt;/p&gt;


          &lt;p&gt;&lt;a href=&quot;https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html&quot;&gt;Continue reading…&lt;/a&gt;&lt;/p&gt;
        </description>
        <link>https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html</link>
        <guid isPermaLink="false">https://www.chosenplaintext.ca/2017/04/21/beginners-guide-constant-time-cryptography.html</guid>
        

        
        
      </item>
    
  </channel>
</rss>
