Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add coverage reports

  • Loading branch information...
commit 3071abce8fc15c72cf9dc3bb8043298356dbf062 1 parent e914029
@thoughtpolice authored
View
42 cov/hpc_index.html
@@ -0,0 +1,42 @@
+<html><style type="text/css">table.bar { background-color: #f25913; }
+td.bar { background-color: #60de51; }
+td.invbar { background-color: #f25913; }
+table.dashboard { border-collapse: collapse ; border: solid 1px black }
+.dashboard td { border: solid 1px black }
+.dashboard th { border: solid 1px black }
+</style>
+<table class="dashboard" width="100%" border=1>
+<tr><th rowspan=2><a href="hpc_index.html">module</a></th><th colspan=3><a href="hpc_index_fun.html">Top Level Definitions</a></th><th colspan=3><a href="hpc_index_alt.html">Alternatives</a></th><th colspan=3><a href="hpc_index_exp.html">Expressions</a></th></tr><tr><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th></tr><tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Auth.Auth.hs.html">salt-0.0/Crypto.NaCl.Auth.Auth</a></tt></td>
+<td align="right">100%</td><td>4/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">100%</td><td>49/49</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Auth.OneTimeAuth.hs.html">salt-0.0/Crypto.NaCl.Auth.OneTimeAuth</a></tt></td>
+<td align="right">100%</td><td>4/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">100%</td><td>49/49</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Encrypt.PublicKey.hs.html">salt-0.0/Crypto.NaCl.Encrypt.PublicKey</a></tt></td>
+<td align="right">80%</td><td>17/21</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="80%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>3/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">98%</td><td>294/298</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="98%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Encrypt.SecretKey.hs.html">salt-0.0/Crypto.NaCl.Encrypt.SecretKey</a></tt></td>
+<td align="right">61%</td><td>8/13</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="61%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>2/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">96%</td><td>113/117</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="96%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Encrypt.Stream.hs.html">salt-0.0/Crypto.NaCl.Encrypt.Stream</a></tt></td>
+<td align="right">75%</td><td>9/12</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="75%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>3/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">92%</td><td>77/83</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="92%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Hash.hs.html">salt-0.0/Crypto.NaCl.Hash</a></tt></td>
+<td align="right">100%</td><td>2/2</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">100%</td><td>34/34</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Key.hs.html">salt-0.0/Crypto.NaCl.Key</a></tt></td>
+<td align="right">0%</td><td>0/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="invbar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Nonce.hs.html">salt-0.0/Crypto.NaCl.Nonce</a></tt></td>
+<td align="right">100%</td><td>4/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>2/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">94%</td><td>70/74</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="94%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Random.hs.html">salt-0.0/Crypto.NaCl.Random</a></tt></td>
+<td align="right">100%</td><td>1/1</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>1/2</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">87%</td><td>14/16</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="87%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Sign.hs.html">salt-0.0/Crypto.NaCl.Sign</a></tt></td>
+<td align="right">100%</td><td>6/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>1/2</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">98%</td><td>104/106</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="98%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr></tr><tr style="background: #e0e0e0">
+<th align=left>&nbsp;&nbsp;Program Coverage Total</tt></th>
+<td align="right">77%</td><td>55/71</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="77%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>12/24</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">97%</td><td>804/826</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="97%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+</table></html>
View
42 cov/hpc_index_alt.html
@@ -0,0 +1,42 @@
+<html><style type="text/css">table.bar { background-color: #f25913; }
+td.bar { background-color: #60de51; }
+td.invbar { background-color: #f25913; }
+table.dashboard { border-collapse: collapse ; border: solid 1px black }
+.dashboard td { border: solid 1px black }
+.dashboard th { border: solid 1px black }
+</style>
+<table class="dashboard" width="100%" border=1>
+<tr><th rowspan=2><a href="hpc_index.html">module</a></th><th colspan=3><a href="hpc_index_fun.html">Top Level Definitions</a></th><th colspan=3><a href="hpc_index_alt.html">Alternatives</a></th><th colspan=3><a href="hpc_index_exp.html">Expressions</a></th></tr><tr><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th></tr><tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Sign.hs.html">salt-0.0/Crypto.NaCl.Sign</a></tt></td>
+<td align="right">100%</td><td>6/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>1/2</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">98%</td><td>104/106</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="98%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Random.hs.html">salt-0.0/Crypto.NaCl.Random</a></tt></td>
+<td align="right">100%</td><td>1/1</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>1/2</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">87%</td><td>14/16</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="87%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Nonce.hs.html">salt-0.0/Crypto.NaCl.Nonce</a></tt></td>
+<td align="right">100%</td><td>4/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>2/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">94%</td><td>70/74</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="94%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Encrypt.Stream.hs.html">salt-0.0/Crypto.NaCl.Encrypt.Stream</a></tt></td>
+<td align="right">75%</td><td>9/12</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="75%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>3/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">92%</td><td>77/83</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="92%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Encrypt.SecretKey.hs.html">salt-0.0/Crypto.NaCl.Encrypt.SecretKey</a></tt></td>
+<td align="right">61%</td><td>8/13</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="61%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>2/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">96%</td><td>113/117</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="96%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Encrypt.PublicKey.hs.html">salt-0.0/Crypto.NaCl.Encrypt.PublicKey</a></tt></td>
+<td align="right">80%</td><td>17/21</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="80%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>3/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">98%</td><td>294/298</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="98%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Key.hs.html">salt-0.0/Crypto.NaCl.Key</a></tt></td>
+<td align="right">0%</td><td>0/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="invbar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Hash.hs.html">salt-0.0/Crypto.NaCl.Hash</a></tt></td>
+<td align="right">100%</td><td>2/2</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">100%</td><td>34/34</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Auth.OneTimeAuth.hs.html">salt-0.0/Crypto.NaCl.Auth.OneTimeAuth</a></tt></td>
+<td align="right">100%</td><td>4/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">100%</td><td>49/49</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Auth.Auth.hs.html">salt-0.0/Crypto.NaCl.Auth.Auth</a></tt></td>
+<td align="right">100%</td><td>4/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">100%</td><td>49/49</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr></tr><tr style="background: #e0e0e0">
+<th align=left>&nbsp;&nbsp;Program Coverage Total</tt></th>
+<td align="right">77%</td><td>55/71</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="77%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>12/24</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">97%</td><td>804/826</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="97%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+</table></html>
View
42 cov/hpc_index_exp.html
@@ -0,0 +1,42 @@
+<html><style type="text/css">table.bar { background-color: #f25913; }
+td.bar { background-color: #60de51; }
+td.invbar { background-color: #f25913; }
+table.dashboard { border-collapse: collapse ; border: solid 1px black }
+.dashboard td { border: solid 1px black }
+.dashboard th { border: solid 1px black }
+</style>
+<table class="dashboard" width="100%" border=1>
+<tr><th rowspan=2><a href="hpc_index.html">module</a></th><th colspan=3><a href="hpc_index_fun.html">Top Level Definitions</a></th><th colspan=3><a href="hpc_index_alt.html">Alternatives</a></th><th colspan=3><a href="hpc_index_exp.html">Expressions</a></th></tr><tr><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th></tr><tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Hash.hs.html">salt-0.0/Crypto.NaCl.Hash</a></tt></td>
+<td align="right">100%</td><td>2/2</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">100%</td><td>34/34</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Auth.OneTimeAuth.hs.html">salt-0.0/Crypto.NaCl.Auth.OneTimeAuth</a></tt></td>
+<td align="right">100%</td><td>4/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">100%</td><td>49/49</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Auth.Auth.hs.html">salt-0.0/Crypto.NaCl.Auth.Auth</a></tt></td>
+<td align="right">100%</td><td>4/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">100%</td><td>49/49</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Sign.hs.html">salt-0.0/Crypto.NaCl.Sign</a></tt></td>
+<td align="right">100%</td><td>6/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>1/2</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">98%</td><td>104/106</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="98%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Encrypt.PublicKey.hs.html">salt-0.0/Crypto.NaCl.Encrypt.PublicKey</a></tt></td>
+<td align="right">80%</td><td>17/21</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="80%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>3/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">98%</td><td>294/298</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="98%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Encrypt.SecretKey.hs.html">salt-0.0/Crypto.NaCl.Encrypt.SecretKey</a></tt></td>
+<td align="right">61%</td><td>8/13</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="61%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>2/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">96%</td><td>113/117</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="96%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Nonce.hs.html">salt-0.0/Crypto.NaCl.Nonce</a></tt></td>
+<td align="right">100%</td><td>4/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>2/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">94%</td><td>70/74</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="94%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Encrypt.Stream.hs.html">salt-0.0/Crypto.NaCl.Encrypt.Stream</a></tt></td>
+<td align="right">75%</td><td>9/12</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="75%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>3/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">92%</td><td>77/83</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="92%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Random.hs.html">salt-0.0/Crypto.NaCl.Random</a></tt></td>
+<td align="right">100%</td><td>1/1</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>1/2</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">87%</td><td>14/16</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="87%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Key.hs.html">salt-0.0/Crypto.NaCl.Key</a></tt></td>
+<td align="right">0%</td><td>0/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="invbar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td></tr>
+<tr></tr><tr style="background: #e0e0e0">
+<th align=left>&nbsp;&nbsp;Program Coverage Total</tt></th>
+<td align="right">77%</td><td>55/71</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="77%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>12/24</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">97%</td><td>804/826</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="97%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+</table></html>
View
42 cov/hpc_index_fun.html
@@ -0,0 +1,42 @@
+<html><style type="text/css">table.bar { background-color: #f25913; }
+td.bar { background-color: #60de51; }
+td.invbar { background-color: #f25913; }
+table.dashboard { border-collapse: collapse ; border: solid 1px black }
+.dashboard td { border: solid 1px black }
+.dashboard th { border: solid 1px black }
+</style>
+<table class="dashboard" width="100%" border=1>
+<tr><th rowspan=2><a href="hpc_index.html">module</a></th><th colspan=3><a href="hpc_index_fun.html">Top Level Definitions</a></th><th colspan=3><a href="hpc_index_alt.html">Alternatives</a></th><th colspan=3><a href="hpc_index_exp.html">Expressions</a></th></tr><tr><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th></tr><tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Sign.hs.html">salt-0.0/Crypto.NaCl.Sign</a></tt></td>
+<td align="right">100%</td><td>6/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>1/2</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">98%</td><td>104/106</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="98%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Random.hs.html">salt-0.0/Crypto.NaCl.Random</a></tt></td>
+<td align="right">100%</td><td>1/1</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>1/2</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">87%</td><td>14/16</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="87%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Nonce.hs.html">salt-0.0/Crypto.NaCl.Nonce</a></tt></td>
+<td align="right">100%</td><td>4/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>2/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">94%</td><td>70/74</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="94%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Hash.hs.html">salt-0.0/Crypto.NaCl.Hash</a></tt></td>
+<td align="right">100%</td><td>2/2</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">100%</td><td>34/34</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Auth.OneTimeAuth.hs.html">salt-0.0/Crypto.NaCl.Auth.OneTimeAuth</a></tt></td>
+<td align="right">100%</td><td>4/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">100%</td><td>49/49</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Auth.Auth.hs.html">salt-0.0/Crypto.NaCl.Auth.Auth</a></tt></td>
+<td align="right">100%</td><td>4/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">100%</td><td>49/49</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Encrypt.PublicKey.hs.html">salt-0.0/Crypto.NaCl.Encrypt.PublicKey</a></tt></td>
+<td align="right">80%</td><td>17/21</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="80%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>3/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">98%</td><td>294/298</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="98%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Encrypt.Stream.hs.html">salt-0.0/Crypto.NaCl.Encrypt.Stream</a></tt></td>
+<td align="right">75%</td><td>9/12</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="75%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>3/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">92%</td><td>77/83</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="92%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Encrypt.SecretKey.hs.html">salt-0.0/Crypto.NaCl.Encrypt.SecretKey</a></tt></td>
+<td align="right">61%</td><td>8/13</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="61%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>2/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">96%</td><td>113/117</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="96%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+<tr>
+<td>&nbsp;&nbsp;<tt>module <a href="salt-0.0/Crypto.NaCl.Key.hs.html">salt-0.0/Crypto.NaCl.Key</a></tt></td>
+<td align="right">0%</td><td>0/4</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="100%"><tr><td height=12 class="invbar"></td></tr></table></td></tr></table></td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td><td align="right">-&nbsp;</td><td>0/0</td><td width=100>&nbsp;</td></tr>
+<tr></tr><tr style="background: #e0e0e0">
+<th align=left>&nbsp;&nbsp;Program Coverage Total</tt></th>
+<td align="right">77%</td><td>55/71</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="77%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">50%</td><td>12/24</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="50%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">97%</td><td>804/826</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="97%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>
+</table></html>
View
96 cov/salt-0.0/Crypto.NaCl.Auth.Auth.hs.html
@@ -0,0 +1,96 @@
+<html><style type="text/css">
+span.lineno { color: white; background: #aaaaaa; border-right: solid white 12px }
+span.nottickedoff { background: yellow}
+span.istickedoff { background: white }
+span.tickonlyfalse { margin: -1px; border: 1px solid #f20913; background: #f20913 }
+span.tickonlytrue { margin: -1px; border: 1px solid #60de51; background: #60de51 }
+span.funcount { font-size: small; color: orange; z-index: 2; position: absolute; right: 20 }
+span.decl { font-weight: bold }
+span.spaces { background: white }
+</style>
+<pre>
+<span class="lineno"> 1 </span>{-# LANGUAGE CPP #-}
+<span class="lineno"> 2 </span>-- |
+<span class="lineno"> 3 </span>-- Module : Crypto.NaCl.Auth.Auth
+<span class="lineno"> 4 </span>-- Copyright : (c) Austin Seipp 2011-2012
+<span class="lineno"> 5 </span>-- License : MIT
+<span class="lineno"> 6 </span>--
+<span class="lineno"> 7 </span>-- Maintainer : mad.one@gmail.com
+<span class="lineno"> 8 </span>-- Stability : experimental
+<span class="lineno"> 9 </span>-- Portability : portable
+<span class="lineno"> 10 </span>--
+<span class="lineno"> 11 </span>-- Fast, cryptographically strong authentication.
+<span class="lineno"> 12 </span>--
+<span class="lineno"> 13 </span>module Crypto.NaCl.Auth.Auth
+<span class="lineno"> 14 </span> ( authenticate -- :: ByteString -&gt; ByteString -&gt; ByteString
+<span class="lineno"> 15 </span> , verify -- :: ByteString -&gt; ByteString -&gt; ByteString -&gt; Bool
+<span class="lineno"> 16 </span> , authKeyLength -- :: Int
+<span class="lineno"> 17 </span> ) where
+<span class="lineno"> 18 </span>import Foreign.Ptr
+<span class="lineno"> 19 </span>import Foreign.C.Types
+<span class="lineno"> 20 </span>import Data.Word
+<span class="lineno"> 21 </span>import Control.Monad (void)
+<span class="lineno"> 22 </span>
+<span class="lineno"> 23 </span>import System.IO.Unsafe (unsafePerformIO)
+<span class="lineno"> 24 </span>
+<span class="lineno"> 25 </span>import Data.ByteString as S
+<span class="lineno"> 26 </span>import Data.ByteString.Internal as SI
+<span class="lineno"> 27 </span>import Data.ByteString.Unsafe as SU
+<span class="lineno"> 28 </span>
+<span class="lineno"> 29 </span>import Crypto.NaCl.Key
+<span class="lineno"> 30 </span>
+<span class="lineno"> 31 </span>#include &lt;crypto_auth.h&gt;
+<span class="lineno"> 32 </span>
+<span class="lineno"> 33 </span>authenticate :: SecretKey
+<span class="lineno"> 34 </span> -- ^ Secret key
+<span class="lineno"> 35 </span> -&gt; ByteString
+<span class="lineno"> 36 </span> -- ^ Message
+<span class="lineno"> 37 </span> -&gt; ByteString
+<span class="lineno"> 38 </span> -- ^ Authenticator
+<span class="lineno"> 39 </span><span class="decl"><span class="istickedoff">authenticate (SecretKey k) msg = </span>
+<span class="lineno"> 40 </span><span class="spaces"> </span><span class="istickedoff">unsafePerformIO . SI.create auth_BYTES $ \out -&gt;</span>
+<span class="lineno"> 41 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCStringLen msg $ \(cstr, clen) -&gt;</span>
+<span class="lineno"> 42 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString k $ \pk -&gt;</span>
+<span class="lineno"> 43 </span><span class="spaces"> </span><span class="istickedoff">void $ c_crypto_auth out cstr (fromIntegral clen) pk</span></span>
+<span class="lineno"> 44 </span>{-# INLINEABLE authenticate #-}
+<span class="lineno"> 45 </span>
+<span class="lineno"> 46 </span>verify :: SecretKey
+<span class="lineno"> 47 </span> -- ^ Key
+<span class="lineno"> 48 </span> -&gt; ByteString
+<span class="lineno"> 49 </span> -- ^ Authenticator returned via 'authenticate'
+<span class="lineno"> 50 </span> -&gt; ByteString
+<span class="lineno"> 51 </span> -- ^ Message
+<span class="lineno"> 52 </span> -&gt; Bool
+<span class="lineno"> 53 </span> -- ^ Result: @True@ if properly verified, @False@ otherwise
+<span class="lineno"> 54 </span><span class="decl"><span class="istickedoff">verify (SecretKey k) auth msg =</span>
+<span class="lineno"> 55 </span><span class="spaces"> </span><span class="istickedoff">unsafePerformIO $ SU.unsafeUseAsCString auth $ \pauth -&gt;</span>
+<span class="lineno"> 56 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCStringLen msg $ \(cstr, clen) -&gt;</span>
+<span class="lineno"> 57 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString k $ \pk -&gt; do</span>
+<span class="lineno"> 58 </span><span class="spaces"> </span><span class="istickedoff">b &lt;- c_crypto_auth_verify pauth cstr (fromIntegral clen) pk</span>
+<span class="lineno"> 59 </span><span class="spaces"> </span><span class="istickedoff">return (b == 0)</span></span>
+<span class="lineno"> 60 </span>{-# INLINEABLE verify #-}
+<span class="lineno"> 61 </span>
+<span class="lineno"> 62 </span>--
+<span class="lineno"> 63 </span>-- FFI
+<span class="lineno"> 64 </span>--
+<span class="lineno"> 65 </span>
+<span class="lineno"> 66 </span>-- | @authKeyLength@ is the required key length for a key given
+<span class="lineno"> 67 </span>-- to 'authenticate' or 'verify'. Using any other key length will
+<span class="lineno"> 68 </span>-- result in error.
+<span class="lineno"> 69 </span>authKeyLength :: Int
+<span class="lineno"> 70 </span><span class="decl"><span class="istickedoff">authKeyLength = #{</span></span>const crypto_auth_KEYBYTES}
+<span class="lineno"> 71 </span>
+<span class="lineno"> 72 </span>auth_BYTES :: Int
+<span class="lineno"> 73 </span><span class="decl"><span class="istickedoff">auth_BYTES = #{</span></span>const crypto_auth_BYTES}
+<span class="lineno"> 74 </span>
+<span class="lineno"> 75 </span>
+<span class="lineno"> 76 </span>foreign import ccall unsafe &quot;glue_crypto_auth&quot;
+<span class="lineno"> 77 </span> c_crypto_auth :: Ptr Word8 -&gt; Ptr CChar -&gt; CULLong -&gt;
+<span class="lineno"> 78 </span> Ptr CChar -&gt; IO Int
+<span class="lineno"> 79 </span>
+<span class="lineno"> 80 </span>foreign import ccall unsafe &quot;glue_crypto_auth_verify&quot;
+<span class="lineno"> 81 </span> c_crypto_auth_verify :: Ptr CChar -&gt; Ptr CChar -&gt; CULLong -&gt;
+<span class="lineno"> 82 </span> Ptr CChar -&gt; IO Int
+
+</pre>
+</html>
View
95 cov/salt-0.0/Crypto.NaCl.Auth.OneTimeAuth.hs.html
@@ -0,0 +1,95 @@
+<html><style type="text/css">
+span.lineno { color: white; background: #aaaaaa; border-right: solid white 12px }
+span.nottickedoff { background: yellow}
+span.istickedoff { background: white }
+span.tickonlyfalse { margin: -1px; border: 1px solid #f20913; background: #f20913 }
+span.tickonlytrue { margin: -1px; border: 1px solid #60de51; background: #60de51 }
+span.funcount { font-size: small; color: orange; z-index: 2; position: absolute; right: 20 }
+span.decl { font-weight: bold }
+span.spaces { background: white }
+</style>
+<pre>
+<span class="lineno"> 1 </span>{-# LANGUAGE CPP #-}
+<span class="lineno"> 2 </span>-- |
+<span class="lineno"> 3 </span>-- Module : Crypto.NaCl.Auth.OneTimeAuth
+<span class="lineno"> 4 </span>-- Copyright : (c) Austin Seipp 2011-2012
+<span class="lineno"> 5 </span>-- License : MIT
+<span class="lineno"> 6 </span>--
+<span class="lineno"> 7 </span>-- Maintainer : mad.one@gmail.com
+<span class="lineno"> 8 </span>-- Stability : experimental
+<span class="lineno"> 9 </span>-- Portability : portable
+<span class="lineno"> 10 </span>--
+<span class="lineno"> 11 </span>-- Fast, cryptographically strong one-time authentication
+<span class="lineno"> 12 </span>--
+<span class="lineno"> 13 </span>module Crypto.NaCl.Auth.OneTimeAuth
+<span class="lineno"> 14 </span> ( authenticateOnce -- :: ByteString -&gt; ByteString -&gt; ByteString
+<span class="lineno"> 15 </span> , verifyOnce -- :: ByteString -&gt; ByteString -&gt; ByteString -&gt; Bool
+<span class="lineno"> 16 </span> , oneTimeAuthKeyLength -- :: Int
+<span class="lineno"> 17 </span> ) where
+<span class="lineno"> 18 </span>import Foreign.Ptr
+<span class="lineno"> 19 </span>import Foreign.C.Types
+<span class="lineno"> 20 </span>import Data.Word
+<span class="lineno"> 21 </span>import Control.Monad (void)
+<span class="lineno"> 22 </span>
+<span class="lineno"> 23 </span>import System.IO.Unsafe (unsafePerformIO)
+<span class="lineno"> 24 </span>
+<span class="lineno"> 25 </span>import Data.ByteString as S
+<span class="lineno"> 26 </span>import Data.ByteString.Internal as SI
+<span class="lineno"> 27 </span>import Data.ByteString.Unsafe as SU
+<span class="lineno"> 28 </span>
+<span class="lineno"> 29 </span>import Crypto.NaCl.Key
+<span class="lineno"> 30 </span>
+<span class="lineno"> 31 </span>#include &lt;crypto_onetimeauth.h&gt;
+<span class="lineno"> 32 </span>
+<span class="lineno"> 33 </span>authenticateOnce :: SecretKey
+<span class="lineno"> 34 </span> -- ^ Secret key
+<span class="lineno"> 35 </span> -&gt; ByteString
+<span class="lineno"> 36 </span> -- ^ Message
+<span class="lineno"> 37 </span> -&gt; ByteString
+<span class="lineno"> 38 </span> -- ^ Authenticator
+<span class="lineno"> 39 </span><span class="decl"><span class="istickedoff">authenticateOnce (SecretKey k) msg = </span>
+<span class="lineno"> 40 </span><span class="spaces"> </span><span class="istickedoff">unsafePerformIO . SI.create auth_BYTES $ \out -&gt;</span>
+<span class="lineno"> 41 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCStringLen msg $ \(cstr, clen) -&gt;</span>
+<span class="lineno"> 42 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString k $ \pk -&gt;</span>
+<span class="lineno"> 43 </span><span class="spaces"> </span><span class="istickedoff">void $ c_crypto_onetimeauth out cstr (fromIntegral clen) pk</span></span>
+<span class="lineno"> 44 </span>{-# INLINEABLE authenticateOnce #-}
+<span class="lineno"> 45 </span>
+<span class="lineno"> 46 </span>verifyOnce :: SecretKey
+<span class="lineno"> 47 </span> -- ^ Secret key
+<span class="lineno"> 48 </span> -&gt; ByteString
+<span class="lineno"> 49 </span> -- ^ Authenticator returned via 'authenticateOnce'
+<span class="lineno"> 50 </span> -&gt; ByteString
+<span class="lineno"> 51 </span> -- ^ Message
+<span class="lineno"> 52 </span> -&gt; Bool
+<span class="lineno"> 53 </span> -- ^ Result: @True@ if verified, @False@ otherwise
+<span class="lineno"> 54 </span><span class="decl"><span class="istickedoff">verifyOnce (SecretKey k) auth msg =</span>
+<span class="lineno"> 55 </span><span class="spaces"> </span><span class="istickedoff">unsafePerformIO $ SU.unsafeUseAsCString auth $ \pauth -&gt;</span>
+<span class="lineno"> 56 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCStringLen msg $ \(cstr, clen) -&gt;</span>
+<span class="lineno"> 57 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString k $ \pk -&gt; do</span>
+<span class="lineno"> 58 </span><span class="spaces"> </span><span class="istickedoff">b &lt;- c_crypto_onetimeauth_verify pauth cstr (fromIntegral clen) pk</span>
+<span class="lineno"> 59 </span><span class="spaces"> </span><span class="istickedoff">return (b == 0)</span></span>
+<span class="lineno"> 60 </span>{-# INLINEABLE verifyOnce #-}
+<span class="lineno"> 61 </span>
+<span class="lineno"> 62 </span>--
+<span class="lineno"> 63 </span>-- FFI
+<span class="lineno"> 64 </span>--
+<span class="lineno"> 65 </span>-- | @oneTimeAuthKeyLength@ is the required key length for a key given
+<span class="lineno"> 66 </span>-- to 'authenticateOnce' or 'verifyOnce'. Using any other key length
+<span class="lineno"> 67 </span>-- will result in error.
+<span class="lineno"> 68 </span>oneTimeAuthKeyLength :: Int
+<span class="lineno"> 69 </span><span class="decl"><span class="istickedoff">oneTimeAuthKeyLength = #{</span></span>const crypto_onetimeauth_KEYBYTES}
+<span class="lineno"> 70 </span>
+<span class="lineno"> 71 </span>auth_BYTES :: Int
+<span class="lineno"> 72 </span><span class="decl"><span class="istickedoff">auth_BYTES = #{</span></span>const crypto_onetimeauth_BYTES}
+<span class="lineno"> 73 </span>
+<span class="lineno"> 74 </span>
+<span class="lineno"> 75 </span>foreign import ccall unsafe &quot;glue_crypto_onetimeauth&quot;
+<span class="lineno"> 76 </span> c_crypto_onetimeauth :: Ptr Word8 -&gt; Ptr CChar -&gt; CULLong -&gt;
+<span class="lineno"> 77 </span> Ptr CChar -&gt; IO Int
+<span class="lineno"> 78 </span>
+<span class="lineno"> 79 </span>foreign import ccall unsafe &quot;glue_crypto_onetimeauth_verify&quot;
+<span class="lineno"> 80 </span> c_crypto_onetimeauth_verify :: Ptr CChar -&gt; Ptr CChar -&gt; CULLong -&gt;
+<span class="lineno"> 81 </span> Ptr CChar -&gt; IO Int
+
+</pre>
+</html>
View
292 cov/salt-0.0/Crypto.NaCl.Encrypt.PublicKey.hs.html
@@ -0,0 +1,292 @@
+<html><style type="text/css">
+span.lineno { color: white; background: #aaaaaa; border-right: solid white 12px }
+span.nottickedoff { background: yellow}
+span.istickedoff { background: white }
+span.tickonlyfalse { margin: -1px; border: 1px solid #f20913; background: #f20913 }
+span.tickonlytrue { margin: -1px; border: 1px solid #60de51; background: #60de51 }
+span.funcount { font-size: small; color: orange; z-index: 2; position: absolute; right: 20 }
+span.decl { font-weight: bold }
+span.spaces { background: white }
+</style>
+<pre>
+<span class="lineno"> 1 </span>{-# LANGUAGE CPP #-}
+<span class="lineno"> 2 </span>-- |
+<span class="lineno"> 3 </span>-- Module : Crypto.NaCl.Encrypt.PublicKey
+<span class="lineno"> 4 </span>-- Copyright : (c) Austin Seipp 2011-2012
+<span class="lineno"> 5 </span>-- License : MIT
+<span class="lineno"> 6 </span>--
+<span class="lineno"> 7 </span>-- Maintainer : mad.one@gmail.com
+<span class="lineno"> 8 </span>-- Stability : experimental
+<span class="lineno"> 9 </span>-- Portability : portable
+<span class="lineno"> 10 </span>--
+<span class="lineno"> 11 </span>-- Public-key encryption.
+<span class="lineno"> 12 </span>--
+<span class="lineno"> 13 </span>module Crypto.NaCl.Encrypt.PublicKey
+<span class="lineno"> 14 </span> ( -- * Types
+<span class="lineno"> 15 </span> PKNonce -- :: *
+<span class="lineno"> 16 </span> -- * Keypair creation
+<span class="lineno"> 17 </span> , createKeypair -- :: IO KeyPair
+<span class="lineno"> 18 </span> -- * Encryption, Decryption
+<span class="lineno"> 19 </span> , encrypt -- :: Nonce -&gt; ByteString -&gt; PublicKey -&gt; SecretKey -&gt; ByteString
+<span class="lineno"> 20 </span> , decrypt -- :: Nonce -&gt; ByteString -&gt; PublicKey -&gt; SecretKey -&gt; Maybe ByteString
+<span class="lineno"> 21 </span>
+<span class="lineno"> 22 </span> -- * Precomputation interface
+<span class="lineno"> 23 </span> -- $precomp
+<span class="lineno"> 24 </span> , NM -- :: *
+<span class="lineno"> 25 </span> , createNM -- :: KeyPair -&gt; NM
+<span class="lineno"> 26 </span> , encryptNM -- :: NM -&gt; Nonce -&gt; ByteString -&gt; ByteString
+<span class="lineno"> 27 </span> , decryptNM -- :: NM -&gt; Nonce -&gt; ByteString -&gt; Maybe ByteString
+<span class="lineno"> 28 </span>
+<span class="lineno"> 29 </span> -- * Miscellaneous
+<span class="lineno"> 30 </span> , publicKeyLength -- :: Int
+<span class="lineno"> 31 </span> , secretKeyLength -- :: Int
+<span class="lineno"> 32 </span> , nmLength -- :: Int
+<span class="lineno"> 33 </span> ) where
+<span class="lineno"> 34 </span>import Foreign.Ptr
+<span class="lineno"> 35 </span>import Foreign.C.Types
+<span class="lineno"> 36 </span>import Foreign.ForeignPtr (withForeignPtr, ForeignPtr)
+<span class="lineno"> 37 </span>import Data.Word
+<span class="lineno"> 38 </span>import Data.Tagged
+<span class="lineno"> 39 </span>import Control.Monad (void)
+<span class="lineno"> 40 </span>
+<span class="lineno"> 41 </span>import System.IO.Unsafe (unsafePerformIO)
+<span class="lineno"> 42 </span>
+<span class="lineno"> 43 </span>import Data.ByteString as S
+<span class="lineno"> 44 </span>import Data.ByteString.Internal as SI
+<span class="lineno"> 45 </span>import Data.ByteString.Unsafe as SU
+<span class="lineno"> 46 </span>
+<span class="lineno"> 47 </span>import Crypto.NaCl.Nonce
+<span class="lineno"> 48 </span>
+<span class="lineno"> 49 </span>import Crypto.NaCl.Key
+<span class="lineno"> 50 </span>
+<span class="lineno"> 51 </span>#include &lt;crypto_box.h&gt;
+<span class="lineno"> 52 </span>
+<span class="lineno"> 53 </span>newtype PKNonce = PKNonce ByteString deriving (<span class="decl"><span class="nottickedoff"><span class="decl"><span class="nottickedoff">Show</span></span></span></span>, Eq)
+<span class="lineno"> 54 </span>instance Nonce PKNonce where
+<span class="lineno"> 55 </span> {-# SPECIALIZE instance Nonce PKNonce #-}
+<span class="lineno"> 56 </span> <span class="decl"><span class="istickedoff">size = Tagged nonceLength</span></span>
+<span class="lineno"> 57 </span> <span class="decl"><span class="istickedoff">toBS (PKNonce b) = b</span></span>
+<span class="lineno"> 58 </span> <span class="decl"><span class="istickedoff">fromBS x</span>
+<span class="lineno"> 59 </span><span class="spaces"> </span><span class="istickedoff">| <span class="tickonlytrue">S.length x == nonceLength</span> = Just (PKNonce x)</span>
+<span class="lineno"> 60 </span><span class="spaces"> </span><span class="istickedoff">| <span class="nottickedoff">otherwise</span> = <span class="nottickedoff">Nothing</span></span></span>
+<span class="lineno"> 61 </span>
+<span class="lineno"> 62 </span>
+<span class="lineno"> 63 </span>-- TODO:
+<span class="lineno"> 64 </span>-- * internal refactors (try to reduce boilerplate)
+<span class="lineno"> 65 </span>
+<span class="lineno"> 66 </span>-- | Randomly generate a public and private key
+<span class="lineno"> 67 </span>-- for doing authenticated encryption.
+<span class="lineno"> 68 </span>createKeypair :: IO KeyPair
+<span class="lineno"> 69 </span><span class="decl"><span class="istickedoff">createKeypair = do</span>
+<span class="lineno"> 70 </span><span class="spaces"> </span><span class="istickedoff">pk &lt;- SI.mallocByteString publicKeyLength</span>
+<span class="lineno"> 71 </span><span class="spaces"> </span><span class="istickedoff">sk &lt;- SI.mallocByteString secretKeyLength</span>
+<span class="lineno"> 72 </span><span class="spaces"></span><span class="istickedoff"></span>
+<span class="lineno"> 73 </span><span class="spaces"> </span><span class="istickedoff">void $ withForeignPtr pk $ \ppk -&gt;</span>
+<span class="lineno"> 74 </span><span class="spaces"> </span><span class="istickedoff">void $ withForeignPtr sk $ \psk -&gt;</span>
+<span class="lineno"> 75 </span><span class="spaces"> </span><span class="istickedoff">c_crypto_box_keypair ppk psk</span>
+<span class="lineno"> 76 </span><span class="spaces"> </span><span class="istickedoff"></span>
+<span class="lineno"> 77 </span><span class="spaces"> </span><span class="istickedoff">return (PublicKey $ SI.fromForeignPtr pk 0 publicKeyLength, </span>
+<span class="lineno"> 78 </span><span class="spaces"> </span><span class="istickedoff">SecretKey $ SI.fromForeignPtr sk 0 secretKeyLength)</span></span>
+<span class="lineno"> 79 </span>
+<span class="lineno"> 80 </span>encrypt :: PKNonce
+<span class="lineno"> 81 </span> -- ^ Nonce
+<span class="lineno"> 82 </span> -&gt; ByteString
+<span class="lineno"> 83 </span> -- ^ Message
+<span class="lineno"> 84 </span> -&gt; PublicKey
+<span class="lineno"> 85 </span> -- ^ Recievers public key
+<span class="lineno"> 86 </span> -&gt; SecretKey
+<span class="lineno"> 87 </span> -- ^ Senders secret key
+<span class="lineno"> 88 </span> -&gt; ByteString
+<span class="lineno"> 89 </span> -- ^ Ciphertext
+<span class="lineno"> 90 </span><span class="decl"><span class="istickedoff">encrypt (PKNonce n) msg (PublicKey pk) (SecretKey sk) = unsafePerformIO $ do</span>
+<span class="lineno"> 91 </span><span class="spaces"> </span><span class="istickedoff">(c, m) &lt;- prepEnc msg</span>
+<span class="lineno"> 92 </span><span class="spaces"> </span><span class="istickedoff">let mlen = S.length m</span>
+<span class="lineno"> 93 </span><span class="spaces"> </span><span class="istickedoff"></span>
+<span class="lineno"> 94 </span><span class="spaces"> </span><span class="istickedoff">-- as you can tell, this is unsafe</span>
+<span class="lineno"> 95 </span><span class="spaces"> </span><span class="istickedoff">void $ withForeignPtr c $ \pc -&gt;</span>
+<span class="lineno"> 96 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString m $ \pm -&gt;</span>
+<span class="lineno"> 97 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString n $ \pn -&gt; </span>
+<span class="lineno"> 98 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString pk $ \ppk -&gt;</span>
+<span class="lineno"> 99 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString sk $ \psk -&gt;</span>
+<span class="lineno"> 100 </span><span class="spaces"> </span><span class="istickedoff">c_crypto_box pc pm (fromIntegral mlen) pn ppk psk</span>
+<span class="lineno"> 101 </span><span class="spaces"> </span><span class="istickedoff"></span>
+<span class="lineno"> 102 </span><span class="spaces"> </span><span class="istickedoff">let r = SI.fromForeignPtr c 0 mlen</span>
+<span class="lineno"> 103 </span><span class="spaces"> </span><span class="istickedoff">return $ SU.unsafeDrop msg_BOXZEROBYTES r</span></span>
+<span class="lineno"> 104 </span>{-# INLINEABLE encrypt #-}
+<span class="lineno"> 105 </span>
+<span class="lineno"> 106 </span>decrypt :: PKNonce
+<span class="lineno"> 107 </span> -- ^ Nonce
+<span class="lineno"> 108 </span> -&gt; ByteString
+<span class="lineno"> 109 </span> -- ^ Input ciphertext
+<span class="lineno"> 110 </span> -&gt; PublicKey
+<span class="lineno"> 111 </span> -- ^ Senders public key
+<span class="lineno"> 112 </span> -&gt; SecretKey
+<span class="lineno"> 113 </span> -- ^ Recievers secret key
+<span class="lineno"> 114 </span> -&gt; Maybe ByteString -- ^ Ciphertext
+<span class="lineno"> 115 </span><span class="decl"><span class="istickedoff">decrypt (PKNonce n) cipher (PublicKey pk) (SecretKey sk) = unsafePerformIO $ do</span>
+<span class="lineno"> 116 </span><span class="spaces"> </span><span class="istickedoff">(m, c) &lt;- prepDec cipher</span>
+<span class="lineno"> 117 </span><span class="spaces"> </span><span class="istickedoff">let clen = S.length c</span>
+<span class="lineno"> 118 </span><span class="spaces"> </span><span class="istickedoff"></span>
+<span class="lineno"> 119 </span><span class="spaces"> </span><span class="istickedoff">-- as you can tell, this is unsafe</span>
+<span class="lineno"> 120 </span><span class="spaces"> </span><span class="istickedoff">r &lt;- withForeignPtr m $ \pm -&gt;</span>
+<span class="lineno"> 121 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString c $ \pc -&gt;</span>
+<span class="lineno"> 122 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString n $ \pn -&gt; </span>
+<span class="lineno"> 123 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString pk $ \ppk -&gt;</span>
+<span class="lineno"> 124 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString sk $ \psk -&gt;</span>
+<span class="lineno"> 125 </span><span class="spaces"> </span><span class="istickedoff">c_crypto_box_open pm pc (fromIntegral clen) pn ppk psk</span>
+<span class="lineno"> 126 </span><span class="spaces"></span><span class="istickedoff"></span>
+<span class="lineno"> 127 </span><span class="spaces"> </span><span class="istickedoff">return $ if <span class="tickonlyfalse">r /= 0</span> then <span class="nottickedoff">Nothing</span></span>
+<span class="lineno"> 128 </span><span class="spaces"> </span><span class="istickedoff">else</span>
+<span class="lineno"> 129 </span><span class="spaces"> </span><span class="istickedoff">let bs = SI.fromForeignPtr m 0 clen</span>
+<span class="lineno"> 130 </span><span class="spaces"> </span><span class="istickedoff">in Just $ SU.unsafeDrop msg_ZEROBYTES bs</span></span>
+<span class="lineno"> 131 </span>{-# INLINEABLE decrypt #-}
+<span class="lineno"> 132 </span>
+<span class="lineno"> 133 </span>
+<span class="lineno"> 134 </span>--
+<span class="lineno"> 135 </span>-- Precomputation interface
+<span class="lineno"> 136 </span>--
+<span class="lineno"> 137 </span>
+<span class="lineno"> 138 </span>{- $precomp
+<span class="lineno"> 139 </span>
+<span class="lineno"> 140 </span>If you send many messages to the same receiver, or receive many
+<span class="lineno"> 141 </span>messages from the same sender, you can gain speed increases by instead
+<span class="lineno"> 142 </span>using the following precomputation interface, which splits the
+<span class="lineno"> 143 </span>encryption and decryption steps into two parts.
+<span class="lineno"> 144 </span>
+<span class="lineno"> 145 </span>For encryption, you first create an 'NM' by using 'createNM', using
+<span class="lineno"> 146 </span>the senders secret key, and receivers public key. You can then use
+<span class="lineno"> 147 </span>'encryptNM' to encrypt data.
+<span class="lineno"> 148 </span>
+<span class="lineno"> 149 </span>For decryption, you first create an 'NM' by using 'createNM', using
+<span class="lineno"> 150 </span>the recievers secret key, and the senders publickey. You can then use
+<span class="lineno"> 151 </span>'decryptNM' to decrypt data.
+<span class="lineno"> 152 </span>
+<span class="lineno"> 153 </span>-}
+<span class="lineno"> 154 </span>
+<span class="lineno"> 155 </span>-- | An 'NM' is intermediate data computed by 'createNM' given a
+<span class="lineno"> 156 </span>-- public and private key which can be used to encrypt/decrypt
+<span class="lineno"> 157 </span>-- information via 'encryptNM' or 'decryptNM'.
+<span class="lineno"> 158 </span>--
+<span class="lineno"> 159 </span>-- An 'NM' can be re-used between two communicators for any number of
+<span class="lineno"> 160 </span>-- messages.
+<span class="lineno"> 161 </span>--
+<span class="lineno"> 162 </span>-- Its name is not particularly enlightening as to its purpose, it is merely the same
+<span class="lineno"> 163 </span>-- identifier used in the NaCl source code for this interface.
+<span class="lineno"> 164 </span>newtype NM = NM ByteString deriving (Eq, <span class="decl"><span class="nottickedoff"><span class="decl"><span class="nottickedoff">Show</span></span></span></span>)
+<span class="lineno"> 165 </span>
+<span class="lineno"> 166 </span>-- | Creates an intermediate piece of 'NM' data for sending/receiving
+<span class="lineno"> 167 </span>-- messages to/from the same person. The resulting 'NM' can be used for
+<span class="lineno"> 168 </span>-- any number of messages between client/server.
+<span class="lineno"> 169 </span>createNM :: KeyPair -&gt; NM
+<span class="lineno"> 170 </span><span class="decl"><span class="istickedoff">createNM (PublicKey pk, SecretKey sk) = unsafePerformIO $ do</span>
+<span class="lineno"> 171 </span><span class="spaces"> </span><span class="istickedoff">nm &lt;- SI.mallocByteString nmLength</span>
+<span class="lineno"> 172 </span><span class="spaces"> </span><span class="istickedoff">void $ withForeignPtr nm $ \pnm -&gt;</span>
+<span class="lineno"> 173 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString pk $ \ppk -&gt;</span>
+<span class="lineno"> 174 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString sk $ \psk -&gt;</span>
+<span class="lineno"> 175 </span><span class="spaces"> </span><span class="istickedoff">c_crypto_box_beforenm pnm ppk psk</span>
+<span class="lineno"> 176 </span><span class="spaces"> </span><span class="istickedoff">return $ NM $ SI.fromForeignPtr nm 0 nmLength</span></span>
+<span class="lineno"> 177 </span>{-# INLINEABLE createNM #-}
+<span class="lineno"> 178 </span>
+<span class="lineno"> 179 </span>-- | Encrypt data from a specific sender to a specific receiver with
+<span class="lineno"> 180 </span>-- some precomputed 'NM' data.
+<span class="lineno"> 181 </span>encryptNM :: NM -&gt; PKNonce -&gt; ByteString -&gt; ByteString
+<span class="lineno"> 182 </span><span class="decl"><span class="istickedoff">encryptNM (NM nm) (PKNonce n) msg = unsafePerformIO $ do</span>
+<span class="lineno"> 183 </span><span class="spaces"> </span><span class="istickedoff">(c, m) &lt;- prepEnc msg</span>
+<span class="lineno"> 184 </span><span class="spaces"> </span><span class="istickedoff">let mlen = S.length m</span>
+<span class="lineno"> 185 </span><span class="spaces"></span><span class="istickedoff"></span>
+<span class="lineno"> 186 </span><span class="spaces"> </span><span class="istickedoff">-- as you can tell, this is unsafe</span>
+<span class="lineno"> 187 </span><span class="spaces"> </span><span class="istickedoff">void $ withForeignPtr c $ \pc -&gt;</span>
+<span class="lineno"> 188 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString m $ \pm -&gt;</span>
+<span class="lineno"> 189 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString n $ \pn -&gt; </span>
+<span class="lineno"> 190 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString nm $ \pnm -&gt;</span>
+<span class="lineno"> 191 </span><span class="spaces"> </span><span class="istickedoff">c_crypto_box_afternm pc pm (fromIntegral mlen) pn pnm</span>
+<span class="lineno"> 192 </span><span class="spaces"> </span><span class="istickedoff"></span>
+<span class="lineno"> 193 </span><span class="spaces"> </span><span class="istickedoff">let r = SI.fromForeignPtr c 0 mlen</span>
+<span class="lineno"> 194 </span><span class="spaces"> </span><span class="istickedoff">return $ SU.unsafeDrop msg_BOXZEROBYTES r</span></span>
+<span class="lineno"> 195 </span>{-# INLINEABLE encryptNM #-}
+<span class="lineno"> 196 </span>
+<span class="lineno"> 197 </span>-- | Decrypt data from a specific sender for a specific receiver with
+<span class="lineno"> 198 </span>-- some precomputed 'NM' data.
+<span class="lineno"> 199 </span>decryptNM :: NM -&gt; PKNonce -&gt; ByteString -&gt; Maybe ByteString
+<span class="lineno"> 200 </span><span class="decl"><span class="istickedoff">decryptNM (NM nm) n cipher = unsafePerformIO $ do</span>
+<span class="lineno"> 201 </span><span class="spaces"> </span><span class="istickedoff">(m, c) &lt;- prepDec cipher</span>
+<span class="lineno"> 202 </span><span class="spaces"> </span><span class="istickedoff">let clen = S.length c</span>
+<span class="lineno"> 203 </span><span class="spaces"> </span><span class="istickedoff"></span>
+<span class="lineno"> 204 </span><span class="spaces"> </span><span class="istickedoff">-- as you can tell, this is unsafe</span>
+<span class="lineno"> 205 </span><span class="spaces"> </span><span class="istickedoff">r &lt;- withForeignPtr m $ \pm -&gt;</span>
+<span class="lineno"> 206 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString c $ \pc -&gt;</span>
+<span class="lineno"> 207 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString (toBS n) $ \pn -&gt; </span>
+<span class="lineno"> 208 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString nm $ \pnm -&gt;</span>
+<span class="lineno"> 209 </span><span class="spaces"> </span><span class="istickedoff">c_crypto_box_open_afternm pm pc (fromIntegral clen) pn pnm</span>
+<span class="lineno"> 210 </span><span class="spaces"></span><span class="istickedoff"></span>
+<span class="lineno"> 211 </span><span class="spaces"> </span><span class="istickedoff">return $ if <span class="tickonlyfalse">r /= 0</span> then <span class="nottickedoff">Nothing</span></span>
+<span class="lineno"> 212 </span><span class="spaces"> </span><span class="istickedoff">else</span>
+<span class="lineno"> 213 </span><span class="spaces"> </span><span class="istickedoff">let bs = SI.fromForeignPtr m 0 clen</span>
+<span class="lineno"> 214 </span><span class="spaces"> </span><span class="istickedoff">in Just $ SU.unsafeDrop msg_ZEROBYTES bs</span></span>
+<span class="lineno"> 215 </span>{-# INLINEABLE decryptNM #-}
+<span class="lineno"> 216 </span>
+<span class="lineno"> 217 </span>--
+<span class="lineno"> 218 </span>-- Inputs to encrypt/decrypt must be padded
+<span class="lineno"> 219 </span>--
+<span class="lineno"> 220 </span>
+<span class="lineno"> 221 </span>prepEnc :: ByteString -&gt; IO (ForeignPtr Word8, ByteString)
+<span class="lineno"> 222 </span><span class="decl"><span class="istickedoff">prepEnc bs = do</span>
+<span class="lineno"> 223 </span><span class="spaces"> </span><span class="istickedoff">c &lt;- SI.mallocByteString (S.length bs + msg_ZEROBYTES)</span>
+<span class="lineno"> 224 </span><span class="spaces"> </span><span class="istickedoff">return $! (c, S.replicate msg_ZEROBYTES 0x0 `S.append` bs)</span></span>
+<span class="lineno"> 225 </span>
+<span class="lineno"> 226 </span>prepDec :: ByteString -&gt; IO (ForeignPtr Word8, ByteString)
+<span class="lineno"> 227 </span><span class="decl"><span class="istickedoff">prepDec bs = do</span>
+<span class="lineno"> 228 </span><span class="spaces"> </span><span class="istickedoff">c &lt;- SI.mallocByteString (S.length bs + msg_BOXZEROBYTES)</span>
+<span class="lineno"> 229 </span><span class="spaces"> </span><span class="istickedoff">return $! (c, S.replicate msg_BOXZEROBYTES 0x0 `S.append` bs)</span></span>
+<span class="lineno"> 230 </span>
+<span class="lineno"> 231 </span>
+<span class="lineno"> 232 </span>--
+<span class="lineno"> 233 </span>-- FFI
+<span class="lineno"> 234 </span>--
+<span class="lineno"> 235 </span>
+<span class="lineno"> 236 </span>-- | Length of a Nonce
+<span class="lineno"> 237 </span>nonceLength :: Int
+<span class="lineno"> 238 </span><span class="decl"><span class="istickedoff">nonceLength = #{</span></span>const crypto_box_NONCEBYTES}
+<span class="lineno"> 239 </span>
+<span class="lineno"> 240 </span>-- | Length of a 'PublicKey' in bytes.
+<span class="lineno"> 241 </span>publicKeyLength :: Int
+<span class="lineno"> 242 </span><span class="decl"><span class="istickedoff">publicKeyLength = #{</span></span>const crypto_box_PUBLICKEYBYTES}
+<span class="lineno"> 243 </span>
+<span class="lineno"> 244 </span>-- | Length of a 'SecretKey' in bytes.
+<span class="lineno"> 245 </span>secretKeyLength :: Int
+<span class="lineno"> 246 </span><span class="decl"><span class="istickedoff">secretKeyLength = #{</span></span>const crypto_box_SECRETKEYBYTES}
+<span class="lineno"> 247 </span>
+<span class="lineno"> 248 </span>-- | Length of the intermediate 'NM' data used by the precomputation
+<span class="lineno"> 249 </span>-- interface.
+<span class="lineno"> 250 </span>nmLength :: Int
+<span class="lineno"> 251 </span><span class="decl"><span class="istickedoff">nmLength = #{</span></span>const crypto_box_BEFORENMBYTES}
+<span class="lineno"> 252 </span>
+<span class="lineno"> 253 </span>msg_ZEROBYTES,msg_BOXZEROBYTES :: Int
+<span class="lineno"> 254 </span><span class="decl"><span class="istickedoff">msg_ZEROBYTES = #{</span></span>const crypto_box_ZEROBYTES}
+<span class="lineno"> 255 </span><span class="decl"><span class="istickedoff">msg_BOXZEROBYTES = #{</span></span>const crypto_box_BOXZEROBYTES}
+<span class="lineno"> 256 </span>
+<span class="lineno"> 257 </span>
+<span class="lineno"> 258 </span>foreign import ccall unsafe &quot;glue_crypto_box_keypair&quot;
+<span class="lineno"> 259 </span> c_crypto_box_keypair :: Ptr Word8 -&gt; Ptr Word8 -&gt; IO Int
+<span class="lineno"> 260 </span>
+<span class="lineno"> 261 </span>foreign import ccall unsafe &quot;glue_crypto_box&quot;
+<span class="lineno"> 262 </span> c_crypto_box :: Ptr Word8 -&gt; Ptr CChar -&gt; CULLong -&gt;
+<span class="lineno"> 263 </span> Ptr CChar -&gt; Ptr CChar -&gt; Ptr CChar -&gt; IO Int
+<span class="lineno"> 264 </span>
+<span class="lineno"> 265 </span>foreign import ccall unsafe &quot;glue_crypto_box_open&quot;
+<span class="lineno"> 266 </span> c_crypto_box_open :: Ptr Word8 -&gt; Ptr CChar -&gt; CULLong -&gt;
+<span class="lineno"> 267 </span> Ptr CChar -&gt; Ptr CChar -&gt; Ptr CChar -&gt; IO Int
+<span class="lineno"> 268 </span>
+<span class="lineno"> 269 </span>foreign import ccall unsafe &quot;glue_crypto_box_beforenm&quot;
+<span class="lineno"> 270 </span> c_crypto_box_beforenm :: Ptr Word8 -&gt; Ptr CChar -&gt; Ptr CChar -&gt; IO Int
+<span class="lineno"> 271 </span>
+<span class="lineno"> 272 </span>foreign import ccall unsafe &quot;glue_crypto_box_afternm&quot;
+<span class="lineno"> 273 </span> c_crypto_box_afternm :: Ptr Word8 -&gt; Ptr CChar -&gt; CULLong -&gt;
+<span class="lineno"> 274 </span> Ptr CChar -&gt; Ptr CChar -&gt; IO Int
+<span class="lineno"> 275 </span>
+<span class="lineno"> 276 </span>foreign import ccall unsafe &quot;glue_crypto_box_open_afternm&quot;
+<span class="lineno"> 277 </span> c_crypto_box_open_afternm :: Ptr Word8 -&gt; Ptr CChar -&gt; CULLong -&gt;
+<span class="lineno"> 278 </span> Ptr CChar -&gt; Ptr CChar -&gt; IO Int
+
+</pre>
+</html>
View
143 cov/salt-0.0/Crypto.NaCl.Encrypt.SecretKey.hs.html
@@ -0,0 +1,143 @@
+<html><style type="text/css">
+span.lineno { color: white; background: #aaaaaa; border-right: solid white 12px }
+span.nottickedoff { background: yellow}
+span.istickedoff { background: white }
+span.tickonlyfalse { margin: -1px; border: 1px solid #f20913; background: #f20913 }
+span.tickonlytrue { margin: -1px; border: 1px solid #60de51; background: #60de51 }
+span.funcount { font-size: small; color: orange; z-index: 2; position: absolute; right: 20 }
+span.decl { font-weight: bold }
+span.spaces { background: white }
+</style>
+<pre>
+<span class="lineno"> 1 </span>{-# LANGUAGE CPP #-}
+<span class="lineno"> 2 </span>-- |
+<span class="lineno"> 3 </span>-- Module : Crypto.NaCl.Encrypt.SecretKey
+<span class="lineno"> 4 </span>-- Copyright : (c) Austin Seipp 2011-2012
+<span class="lineno"> 5 </span>-- License : MIT
+<span class="lineno"> 6 </span>--
+<span class="lineno"> 7 </span>-- Maintainer : mad.one@gmail.com
+<span class="lineno"> 8 </span>-- Stability : experimental
+<span class="lineno"> 9 </span>-- Portability : portable
+<span class="lineno"> 10 </span>--
+<span class="lineno"> 11 </span>-- Authenticated, secret-key encryption.
+<span class="lineno"> 12 </span>--
+<span class="lineno"> 13 </span>module Crypto.NaCl.Encrypt.SecretKey
+<span class="lineno"> 14 </span> ( -- * Types
+<span class="lineno"> 15 </span> SKNonce -- :: *
+<span class="lineno"> 16 </span> -- * Encryption/decryption
+<span class="lineno"> 17 </span> , encrypt
+<span class="lineno"> 18 </span> , decrypt
+<span class="lineno"> 19 </span> -- * Misc
+<span class="lineno"> 20 </span> , keyLength
+<span class="lineno"> 21 </span> ) where
+<span class="lineno"> 22 </span>import Foreign.Ptr
+<span class="lineno"> 23 </span>import Foreign.C.Types
+<span class="lineno"> 24 </span>import Foreign.ForeignPtr (withForeignPtr)
+<span class="lineno"> 25 </span>import Data.Tagged
+<span class="lineno"> 26 </span>import Data.Word
+<span class="lineno"> 27 </span>import Control.Monad (void)
+<span class="lineno"> 28 </span>
+<span class="lineno"> 29 </span>import System.IO.Unsafe (unsafePerformIO)
+<span class="lineno"> 30 </span>
+<span class="lineno"> 31 </span>import Data.ByteString as S
+<span class="lineno"> 32 </span>import Data.ByteString.Internal as SI
+<span class="lineno"> 33 </span>import Data.ByteString.Unsafe as SU
+<span class="lineno"> 34 </span>
+<span class="lineno"> 35 </span>import Crypto.NaCl.Nonce
+<span class="lineno"> 36 </span>
+<span class="lineno"> 37 </span>import Crypto.NaCl.Key
+<span class="lineno"> 38 </span>
+<span class="lineno"> 39 </span>#include &lt;crypto_secretbox.h&gt;
+<span class="lineno"> 40 </span>
+<span class="lineno"> 41 </span>data SKNonce = SKNonce ByteString deriving (<span class="decl"><span class="nottickedoff"><span class="decl"><span class="nottickedoff">Show</span></span></span></span>, <span class="decl"><span class="nottickedoff"><span class="decl"><span class="nottickedoff">Eq</span></span></span></span>)
+<span class="lineno"> 42 </span>instance Nonce SKNonce where
+<span class="lineno"> 43 </span> {-# SPECIALIZE instance Nonce SKNonce #-}
+<span class="lineno"> 44 </span> <span class="decl"><span class="istickedoff">size = Tagged nonceLength</span></span>
+<span class="lineno"> 45 </span> <span class="decl"><span class="nottickedoff">toBS (SKNonce b) = b</span></span>
+<span class="lineno"> 46 </span> <span class="decl"><span class="istickedoff">fromBS x</span>
+<span class="lineno"> 47 </span><span class="spaces"> </span><span class="istickedoff">| <span class="tickonlytrue">S.length x == nonceLength</span> = Just (SKNonce x)</span>
+<span class="lineno"> 48 </span><span class="spaces"> </span><span class="istickedoff">| <span class="nottickedoff">otherwise</span> = <span class="nottickedoff">Nothing</span></span></span>
+<span class="lineno"> 49 </span>
+<span class="lineno"> 50 </span>
+<span class="lineno"> 51 </span>encrypt :: SKNonce
+<span class="lineno"> 52 </span> -- ^ Nonce
+<span class="lineno"> 53 </span> -&gt; ByteString
+<span class="lineno"> 54 </span> -- ^ Input
+<span class="lineno"> 55 </span> -&gt; SecretKey
+<span class="lineno"> 56 </span> -- ^ Secret key
+<span class="lineno"> 57 </span> -&gt; ByteString
+<span class="lineno"> 58 </span> -- ^ Ciphertext
+<span class="lineno"> 59 </span><span class="decl"><span class="istickedoff">encrypt (SKNonce n) msg (SecretKey k) = unsafePerformIO $ do</span>
+<span class="lineno"> 60 </span><span class="spaces"> </span><span class="istickedoff">let mlen = S.length msg + msg_ZEROBYTES</span>
+<span class="lineno"> 61 </span><span class="spaces"> </span><span class="istickedoff">c &lt;- SI.mallocByteString mlen</span>
+<span class="lineno"> 62 </span><span class="spaces"> </span><span class="istickedoff"></span>
+<span class="lineno"> 63 </span><span class="spaces"> </span><span class="istickedoff">-- inputs to crypto_box must be padded</span>
+<span class="lineno"> 64 </span><span class="spaces"> </span><span class="istickedoff">let m = S.replicate msg_ZEROBYTES 0x0 `S.append` msg</span>
+<span class="lineno"> 65 </span><span class="spaces"> </span><span class="istickedoff"></span>
+<span class="lineno"> 66 </span><span class="spaces"> </span><span class="istickedoff">-- as you can tell, this is unsafe</span>
+<span class="lineno"> 67 </span><span class="spaces"> </span><span class="istickedoff">void $ withForeignPtr c $ \pc -&gt;</span>
+<span class="lineno"> 68 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString m $ \pm -&gt;</span>
+<span class="lineno"> 69 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString n $ \pn -&gt; </span>
+<span class="lineno"> 70 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString k $ \pk -&gt;</span>
+<span class="lineno"> 71 </span><span class="spaces"> </span><span class="istickedoff">c_crypto_secretbox pc pm (fromIntegral mlen) pn pk</span>
+<span class="lineno"> 72 </span><span class="spaces"> </span><span class="istickedoff"></span>
+<span class="lineno"> 73 </span><span class="spaces"> </span><span class="istickedoff">let r = SI.fromForeignPtr c 0 mlen</span>
+<span class="lineno"> 74 </span><span class="spaces"> </span><span class="istickedoff">return $ SU.unsafeDrop msg_BOXZEROBYTES r</span></span>
+<span class="lineno"> 75 </span>{-# INLINEABLE encrypt #-}
+<span class="lineno"> 76 </span>
+<span class="lineno"> 77 </span>decrypt :: SKNonce
+<span class="lineno"> 78 </span> -- ^ Nonce
+<span class="lineno"> 79 </span> -&gt; ByteString
+<span class="lineno"> 80 </span> -- ^ Input
+<span class="lineno"> 81 </span> -&gt; SecretKey
+<span class="lineno"> 82 </span> -- ^ Secret key
+<span class="lineno"> 83 </span> -&gt; Maybe ByteString
+<span class="lineno"> 84 </span> -- ^ Ciphertext
+<span class="lineno"> 85 </span><span class="decl"><span class="istickedoff">decrypt (SKNonce n) cipher (SecretKey k) = unsafePerformIO $ do</span>
+<span class="lineno"> 86 </span><span class="spaces"> </span><span class="istickedoff">let clen = S.length cipher + msg_BOXZEROBYTES</span>
+<span class="lineno"> 87 </span><span class="spaces"> </span><span class="istickedoff">m &lt;- SI.mallocByteString clen</span>
+<span class="lineno"> 88 </span><span class="spaces"> </span><span class="istickedoff"></span>
+<span class="lineno"> 89 </span><span class="spaces"> </span><span class="istickedoff">-- inputs to crypto_box must be padded</span>
+<span class="lineno"> 90 </span><span class="spaces"> </span><span class="istickedoff">let c = S.replicate msg_BOXZEROBYTES 0x0 `S.append` cipher</span>
+<span class="lineno"> 91 </span><span class="spaces"> </span><span class="istickedoff"></span>
+<span class="lineno"> 92 </span><span class="spaces"> </span><span class="istickedoff">-- as you can tell, this is unsafe</span>
+<span class="lineno"> 93 </span><span class="spaces"> </span><span class="istickedoff">r &lt;- withForeignPtr m $ \pm -&gt;</span>
+<span class="lineno"> 94 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString c $ \pc -&gt;</span>
+<span class="lineno"> 95 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString n $ \pn -&gt; </span>
+<span class="lineno"> 96 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString k $ \pk -&gt;</span>
+<span class="lineno"> 97 </span><span class="spaces"> </span><span class="istickedoff">c_crypto_secretbox_open pm pc (fromIntegral clen) pn pk</span>
+<span class="lineno"> 98 </span><span class="spaces"> </span><span class="istickedoff"></span>
+<span class="lineno"> 99 </span><span class="spaces"> </span><span class="istickedoff">return $ if <span class="tickonlyfalse">r /= 0</span> then <span class="nottickedoff">Nothing</span></span>
+<span class="lineno"> 100 </span><span class="spaces"> </span><span class="istickedoff">else</span>
+<span class="lineno"> 101 </span><span class="spaces"> </span><span class="istickedoff">let bs = SI.fromForeignPtr m 0 clen</span>
+<span class="lineno"> 102 </span><span class="spaces"> </span><span class="istickedoff">in Just $ SU.unsafeDrop msg_ZEROBYTES bs</span></span>
+<span class="lineno"> 103 </span>{-# INLINEABLE decrypt #-}
+<span class="lineno"> 104 </span>
+<span class="lineno"> 105 </span>--
+<span class="lineno"> 106 </span>-- FFI
+<span class="lineno"> 107 </span>--
+<span class="lineno"> 108 </span>
+<span class="lineno"> 109 </span>-- | Length of a 'Nonce' needed for encryption/decryption
+<span class="lineno"> 110 </span>nonceLength :: Int
+<span class="lineno"> 111 </span><span class="decl"><span class="istickedoff">nonceLength = #{</span></span>const crypto_secretbox_NONCEBYTES}
+<span class="lineno"> 112 </span>
+<span class="lineno"> 113 </span>-- | Length of a 'SecretKey' needed for encryption/decryption.
+<span class="lineno"> 114 </span>keyLength :: Int
+<span class="lineno"> 115 </span><span class="decl"><span class="istickedoff">keyLength = #{</span></span>const crypto_secretbox_KEYBYTES}
+<span class="lineno"> 116 </span>
+<span class="lineno"> 117 </span>
+<span class="lineno"> 118 </span>msg_ZEROBYTES,msg_BOXZEROBYTES :: Int
+<span class="lineno"> 119 </span><span class="decl"><span class="istickedoff">msg_ZEROBYTES = #{</span></span>const crypto_secretbox_ZEROBYTES}
+<span class="lineno"> 120 </span><span class="decl"><span class="istickedoff">msg_BOXZEROBYTES = #{</span></span>const crypto_secretbox_BOXZEROBYTES}
+<span class="lineno"> 121 </span>
+<span class="lineno"> 122 </span>
+<span class="lineno"> 123 </span>foreign import ccall unsafe &quot;glue_crypto_secretbox&quot;
+<span class="lineno"> 124 </span> c_crypto_secretbox :: Ptr Word8 -&gt; Ptr CChar -&gt; CULLong -&gt;
+<span class="lineno"> 125 </span> Ptr CChar -&gt; Ptr CChar -&gt; IO Int
+<span class="lineno"> 126 </span>
+<span class="lineno"> 127 </span>foreign import ccall unsafe &quot;glue_crypto_secretbox_open&quot;
+<span class="lineno"> 128 </span> c_crypto_secretbox_open :: Ptr Word8 -&gt; Ptr CChar -&gt; CULLong -&gt;
+<span class="lineno"> 129 </span> Ptr CChar -&gt; Ptr CChar -&gt; IO Int
+
+</pre>
+</html>
View
141 cov/salt-0.0/Crypto.NaCl.Encrypt.Stream.hs.html
@@ -0,0 +1,141 @@
+<html><style type="text/css">
+span.lineno { color: white; background: #aaaaaa; border-right: solid white 12px }
+span.nottickedoff { background: yellow}
+span.istickedoff { background: white }
+span.tickonlyfalse { margin: -1px; border: 1px solid #f20913; background: #f20913 }
+span.tickonlytrue { margin: -1px; border: 1px solid #60de51; background: #60de51 }
+span.funcount { font-size: small; color: orange; z-index: 2; position: absolute; right: 20 }
+span.decl { font-weight: bold }
+span.spaces { background: white }
+</style>
+<pre>
+<span class="lineno"> 1 </span>{-# LANGUAGE CPP #-}
+<span class="lineno"> 2 </span>-- |
+<span class="lineno"> 3 </span>-- Module : Crypto.NaCl.Encrypt.Stream
+<span class="lineno"> 4 </span>-- Copyright : (c) Austin Seipp 2011-2012
+<span class="lineno"> 5 </span>-- License : MIT
+<span class="lineno"> 6 </span>--
+<span class="lineno"> 7 </span>-- Maintainer : mad.one@gmail.com
+<span class="lineno"> 8 </span>-- Stability : experimental
+<span class="lineno"> 9 </span>-- Portability : portable
+<span class="lineno"> 10 </span>--
+<span class="lineno"> 11 </span>-- Fast stream encryption.
+<span class="lineno"> 12 </span>--
+<span class="lineno"> 13 </span>module Crypto.NaCl.Encrypt.Stream
+<span class="lineno"> 14 </span> ( -- * Types
+<span class="lineno"> 15 </span> StreamNonce -- :: * -&gt; *
+<span class="lineno"> 16 </span> -- * Stream generation
+<span class="lineno"> 17 </span> , streamGen -- :: Nonce -&gt; SecretKey -&gt; ByteString
+<span class="lineno"> 18 </span> -- * Encryption and decryption
+<span class="lineno"> 19 </span> , encrypt -- :: Nonce -&gt; ByteString -&gt; SecretKey -&gt; ByteString
+<span class="lineno"> 20 </span> , decrypt -- :: Nonce -&gt; ByteString -&gt; SecretKey -&gt; ByteString
+<span class="lineno"> 21 </span> -- * Misc
+<span class="lineno"> 22 </span> , keyLength -- :: Int
+<span class="lineno"> 23 </span> ) where
+<span class="lineno"> 24 </span>import Foreign.Ptr
+<span class="lineno"> 25 </span>import Foreign.C.Types
+<span class="lineno"> 26 </span>import Data.Word
+<span class="lineno"> 27 </span>import Data.Tagged
+<span class="lineno"> 28 </span>import Control.Monad (void)
+<span class="lineno"> 29 </span>
+<span class="lineno"> 30 </span>import System.IO.Unsafe (unsafePerformIO)
+<span class="lineno"> 31 </span>
+<span class="lineno"> 32 </span>import Data.ByteString as S
+<span class="lineno"> 33 </span>import Data.ByteString.Internal as SI
+<span class="lineno"> 34 </span>import Data.ByteString.Unsafe as SU
+<span class="lineno"> 35 </span>
+<span class="lineno"> 36 </span>import Crypto.NaCl.Nonce
+<span class="lineno"> 37 </span>
+<span class="lineno"> 38 </span>import Crypto.NaCl.Key
+<span class="lineno"> 39 </span>
+<span class="lineno"> 40 </span>#include &lt;crypto_stream_xsalsa20.h&gt;
+<span class="lineno"> 41 </span>
+<span class="lineno"> 42 </span>data StreamNonce = StreamNonce ByteString deriving (<span class="decl"><span class="nottickedoff"><span class="decl"><span class="nottickedoff">Show</span></span></span></span>, <span class="decl"><span class="istickedoff"><span class="decl"><span class="nottickedoff">Eq</span></span></span></span>)
+<span class="lineno"> 43 </span>instance Nonce StreamNonce where
+<span class="lineno"> 44 </span> {-# SPECIALIZE instance Nonce StreamNonce #-}
+<span class="lineno"> 45 </span> <span class="decl"><span class="istickedoff">size = Tagged nonceLength</span></span>
+<span class="lineno"> 46 </span> <span class="decl"><span class="istickedoff">toBS (StreamNonce b) = b</span></span>
+<span class="lineno"> 47 </span> <span class="decl"><span class="istickedoff">fromBS x</span>
+<span class="lineno"> 48 </span><span class="spaces"> </span><span class="istickedoff">| <span class="tickonlytrue">S.length x == nonceLength</span> = Just (StreamNonce x)</span>
+<span class="lineno"> 49 </span><span class="spaces"> </span><span class="istickedoff">| <span class="nottickedoff">otherwise</span> = <span class="nottickedoff">Nothing</span></span></span>
+<span class="lineno"> 50 </span>
+<span class="lineno"> 51 </span>-- | Given a 'Nonce' @n@, size @s@ and 'SecretKey' @sk@, @streamGen n
+<span class="lineno"> 52 </span>-- s sk@ generates a cryptographic stream of length @s@.
+<span class="lineno"> 53 </span>streamGen :: StreamNonce
+<span class="lineno"> 54 </span> -- ^ Nonce
+<span class="lineno"> 55 </span> -&gt; Int
+<span class="lineno"> 56 </span> -- ^ Size
+<span class="lineno"> 57 </span> -&gt; SecretKey
+<span class="lineno"> 58 </span> -- ^ Input
+<span class="lineno"> 59 </span> -&gt; ByteString
+<span class="lineno"> 60 </span> -- ^ Resulting crypto stream
+<span class="lineno"> 61 </span><span class="decl"><span class="istickedoff">streamGen (StreamNonce n) sz (SecretKey sk)</span>
+<span class="lineno"> 62 </span><span class="spaces"> </span><span class="istickedoff">| <span class="tickonlyfalse">S.length sk /= keyLength</span></span>
+<span class="lineno"> 63 </span><span class="spaces"> </span><span class="istickedoff">= <span class="nottickedoff">error &quot;Crypto.NaCl.Encrypt.Stream.XSalsa20.streamGen: bad key length&quot;</span></span>
+<span class="lineno"> 64 </span><span class="spaces"> </span><span class="istickedoff">| <span class="tickonlytrue">otherwise</span></span>
+<span class="lineno"> 65 </span><span class="spaces"> </span><span class="istickedoff">= unsafePerformIO . SI.create sz $ \out -&gt;</span>
+<span class="lineno"> 66 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString n $ \pn -&gt;</span>
+<span class="lineno"> 67 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString sk $ \psk -&gt;</span>
+<span class="lineno"> 68 </span><span class="spaces"> </span><span class="istickedoff">void $ c_crypto_stream_xsalsa20 out (fromIntegral sz) pn psk</span></span>
+<span class="lineno"> 69 </span>{-# INLINEABLE streamGen #-}
+<span class="lineno"> 70 </span>
+<span class="lineno"> 71 </span>-- | Given a 'Nonce' @n@, plaintext @p@ and 'SecretKey' @sk@, @encrypt n p sk@ encrypts the message @p@ using 'SecretKey' @sk@ and returns the result.
+<span class="lineno"> 72 </span>--
+<span class="lineno"> 73 </span>-- 'encrypt' guarantees the resulting ciphertext is the plaintext
+<span class="lineno"> 74 </span>-- bitwise XOR'd with the result of 'streamGen'. As a result,
+<span class="lineno"> 75 </span>-- 'encrypt' can also be used to decrypt messages.
+<span class="lineno"> 76 </span>encrypt :: StreamNonce
+<span class="lineno"> 77 </span> -- ^ Nonce
+<span class="lineno"> 78 </span> -&gt; ByteString
+<span class="lineno"> 79 </span> -- ^ Input plaintext
+<span class="lineno"> 80 </span> -&gt; SecretKey
+<span class="lineno"> 81 </span> -- ^ Secret key
+<span class="lineno"> 82 </span> -&gt; ByteString
+<span class="lineno"> 83 </span> -- ^ Ciphertext
+<span class="lineno"> 84 </span><span class="decl"><span class="istickedoff">encrypt (StreamNonce n) msg (SecretKey sk)</span>
+<span class="lineno"> 85 </span><span class="spaces"> </span><span class="istickedoff">| <span class="tickonlyfalse">S.length sk /= keyLength</span></span>
+<span class="lineno"> 86 </span><span class="spaces"> </span><span class="istickedoff">= <span class="nottickedoff">error &quot;Crypto.NaCl.Encrypt.Stream.XSalsa20.encrypt: bad key length&quot;</span></span>
+<span class="lineno"> 87 </span><span class="spaces"> </span><span class="istickedoff">| <span class="tickonlytrue">otherwise</span></span>
+<span class="lineno"> 88 </span><span class="spaces"> </span><span class="istickedoff">= let l = S.length msg</span>
+<span class="lineno"> 89 </span><span class="spaces"> </span><span class="istickedoff">in unsafePerformIO . SI.create l $ \out -&gt;</span>
+<span class="lineno"> 90 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString msg $ \cstr -&gt; </span>
+<span class="lineno"> 91 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString n $ \pn -&gt;</span>
+<span class="lineno"> 92 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCString sk $ \psk -&gt;</span>
+<span class="lineno"> 93 </span><span class="spaces"> </span><span class="istickedoff">void $ c_crypto_stream_xsalsa20_xor out cstr (fromIntegral l) pn psk</span></span>
+<span class="lineno"> 94 </span>{-# INLINEABLE encrypt #-}
+<span class="lineno"> 95 </span>
+<span class="lineno"> 96 </span>-- | Simple alias for 'encrypt'.
+<span class="lineno"> 97 </span>decrypt :: StreamNonce
+<span class="lineno"> 98 </span> -- ^ Nonce
+<span class="lineno"> 99 </span> -&gt; ByteString
+<span class="lineno"> 100 </span> -- ^ Input ciphertext
+<span class="lineno"> 101 </span> -&gt; SecretKey
+<span class="lineno"> 102 </span> -- ^ Secret key
+<span class="lineno"> 103 </span> -&gt; ByteString
+<span class="lineno"> 104 </span> -- ^ Plaintext
+<span class="lineno"> 105 </span><span class="decl"><span class="istickedoff">decrypt n c sk = encrypt n c sk</span></span>
+<span class="lineno"> 106 </span>{-# INLINEABLE decrypt #-}
+<span class="lineno"> 107 </span>
+<span class="lineno"> 108 </span>
+<span class="lineno"> 109 </span>--
+<span class="lineno"> 110 </span>-- FFI
+<span class="lineno"> 111 </span>--
+<span class="lineno"> 112 </span>
+<span class="lineno"> 113 </span>-- | Length of a 'SecretKey' needed for encryption/decryption.
+<span class="lineno"> 114 </span>keyLength :: Int
+<span class="lineno"> 115 </span><span class="decl"><span class="istickedoff">keyLength = #{</span></span>const crypto_stream_xsalsa20_KEYBYTES}
+<span class="lineno"> 116 </span>
+<span class="lineno"> 117 </span>-- | Length of a 'Nonce' needed for encryption/decryption.
+<span class="lineno"> 118 </span>nonceLength :: Int
+<span class="lineno"> 119 </span><span class="decl"><span class="istickedoff">nonceLength = #{</span></span>const crypto_stream_xsalsa20_NONCEBYTES}
+<span class="lineno"> 120 </span>
+<span class="lineno"> 121 </span>foreign import ccall unsafe &quot;glue_crypto_stream_xsalsa20&quot;
+<span class="lineno"> 122 </span> c_crypto_stream_xsalsa20 :: Ptr Word8 -&gt; CULLong -&gt; Ptr CChar -&gt;
+<span class="lineno"> 123 </span> Ptr CChar -&gt; IO Int
+<span class="lineno"> 124 </span>
+<span class="lineno"> 125 </span>foreign import ccall unsafe &quot;glue_crypto_stream_xsalsa20_xor&quot;
+<span class="lineno"> 126 </span> c_crypto_stream_xsalsa20_xor :: Ptr Word8 -&gt; Ptr CChar -&gt;
+<span class="lineno"> 127 </span> CULLong -&gt; Ptr CChar -&gt; Ptr CChar -&gt; IO Int
+
+</pre>
+</html>
View
67 cov/salt-0.0/Crypto.NaCl.Hash.hs.html
@@ -0,0 +1,67 @@
+<html><style type="text/css">
+span.lineno { color: white; background: #aaaaaa; border-right: solid white 12px }
+span.nottickedoff { background: yellow}
+span.istickedoff { background: white }
+span.tickonlyfalse { margin: -1px; border: 1px solid #f20913; background: #f20913 }
+span.tickonlytrue { margin: -1px; border: 1px solid #60de51; background: #60de51 }
+span.funcount { font-size: small; color: orange; z-index: 2; position: absolute; right: 20 }
+span.decl { font-weight: bold }
+span.spaces { background: white }
+</style>
+<pre>
+<span class="lineno"> 1 </span>-- |
+<span class="lineno"> 2 </span>-- Module : Crypto.NaCl.Hash
+<span class="lineno"> 3 </span>-- Copyright : (c) Austin Seipp 2011-2012
+<span class="lineno"> 4 </span>-- License : MIT
+<span class="lineno"> 5 </span>--
+<span class="lineno"> 6 </span>-- Maintainer : mad.one@gmail.com
+<span class="lineno"> 7 </span>-- Stability : experimental
+<span class="lineno"> 8 </span>-- Portability : portable
+<span class="lineno"> 9 </span>--
+<span class="lineno"> 10 </span>-- Fast, cryptographically strong hashing functions. Currently
+<span class="lineno"> 11 </span>-- only provides SHA-512 and SHA-256.
+<span class="lineno"> 12 </span>--
+<span class="lineno"> 13 </span>module Crypto.NaCl.Hash
+<span class="lineno"> 14 </span> ( sha512 -- :: ByteString -&gt; ByteString
+<span class="lineno"> 15 </span> , sha256 -- :: ByteString -&gt; ByteString
+<span class="lineno"> 16 </span> ) where
+<span class="lineno"> 17 </span>import Foreign.C
+<span class="lineno"> 18 </span>import Foreign.Ptr
+<span class="lineno"> 19 </span>import Control.Monad (void)
+<span class="lineno"> 20 </span>import Data.Word
+<span class="lineno"> 21 </span>import System.IO.Unsafe (unsafePerformIO)
+<span class="lineno"> 22 </span>
+<span class="lineno"> 23 </span>import Data.ByteString as S
+<span class="lineno"> 24 </span>import Data.ByteString.Internal as SI
+<span class="lineno"> 25 </span>import Data.ByteString.Unsafe as SU
+<span class="lineno"> 26 </span>
+<span class="lineno"> 27 </span>sha512 :: ByteString -&gt; ByteString
+<span class="lineno"> 28 </span><span class="decl"><span class="istickedoff">sha512 xs =</span>
+<span class="lineno"> 29 </span><span class="spaces"> </span><span class="istickedoff">-- The default primitive of SHA512 has 64 bytes of output. </span>
+<span class="lineno"> 30 </span><span class="spaces"> </span><span class="istickedoff">unsafePerformIO . SI.create 64 $ \out -&gt;</span>
+<span class="lineno"> 31 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCStringLen xs $ \(cstr,clen) -&gt;</span>
+<span class="lineno"> 32 </span><span class="spaces"> </span><span class="istickedoff">void $ c_crypto_hash_sha512 out cstr (fromIntegral clen)</span></span>
+<span class="lineno"> 33 </span>{-# INLINEABLE sha512 #-}
+<span class="lineno"> 34 </span>
+<span class="lineno"> 35 </span>sha256 :: ByteString -&gt; ByteString
+<span class="lineno"> 36 </span><span class="decl"><span class="istickedoff">sha256 xs =</span>
+<span class="lineno"> 37 </span><span class="spaces"> </span><span class="istickedoff">-- SHA256 has 32 bytes of output</span>
+<span class="lineno"> 38 </span><span class="spaces"> </span><span class="istickedoff">unsafePerformIO . SI.create 32 $ \out -&gt;</span>
+<span class="lineno"> 39 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCStringLen xs $ \(cstr,clen) -&gt;</span>
+<span class="lineno"> 40 </span><span class="spaces"> </span><span class="istickedoff">void $ c_crypto_hash_sha256 out cstr (fromIntegral clen)</span></span>
+<span class="lineno"> 41 </span>{-# INLINEABLE sha256 #-}
+<span class="lineno"> 42 </span>
+<span class="lineno"> 43 </span>--
+<span class="lineno"> 44 </span>-- FFI
+<span class="lineno"> 45 </span>--
+<span class="lineno"> 46 </span>
+<span class="lineno"> 47 </span>type HashFunc = Ptr Word8 -&gt; Ptr CChar -&gt; CULLong -&gt; IO CInt
+<span class="lineno"> 48 </span>
+<span class="lineno"> 49 </span>foreign import ccall unsafe &quot;glue_crypto_hash_sha512&quot;
+<span class="lineno"> 50 </span> c_crypto_hash_sha512 :: HashFunc
+<span class="lineno"> 51 </span>
+<span class="lineno"> 52 </span>foreign import ccall unsafe &quot;glue_crypto_hash_sha256&quot;
+<span class="lineno"> 53 </span> c_crypto_hash_sha256 :: HashFunc
+
+</pre>
+</html>
View
42 cov/salt-0.0/Crypto.NaCl.Key.hs.html
@@ -0,0 +1,42 @@
+<html><style type="text/css">
+span.lineno { color: white; background: #aaaaaa; border-right: solid white 12px }
+span.nottickedoff { background: yellow}
+span.istickedoff { background: white }
+span.tickonlyfalse { margin: -1px; border: 1px solid #f20913; background: #f20913 }
+span.tickonlytrue { margin: -1px; border: 1px solid #60de51; background: #60de51 }
+span.funcount { font-size: small; color: orange; z-index: 2; position: absolute; right: 20 }
+span.decl { font-weight: bold }
+span.spaces { background: white }
+</style>
+<pre>
+<span class="lineno"> 1 </span>-- |
+<span class="lineno"> 2 </span>-- Module : Crypto.NaCl.Key
+<span class="lineno"> 3 </span>-- Copyright : (c) Austin Seipp 2011-2012
+<span class="lineno"> 4 </span>-- License : MIT
+<span class="lineno"> 5 </span>--
+<span class="lineno"> 6 </span>-- Maintainer : mad.one@gmail.com
+<span class="lineno"> 7 </span>-- Stability : experimental
+<span class="lineno"> 8 </span>-- Portability : portable
+<span class="lineno"> 9 </span>--
+<span class="lineno"> 10 </span>-- This module exports two simple types, 'PublicKey' and 'SecretKey'
+<span class="lineno"> 11 </span>-- which are merely @newtype@s for 'ByteString'. This is for type safety
+<span class="lineno"> 12 </span>-- so you never confuse your keys or accidentally give them 'ByteString's
+<span class="lineno"> 13 </span>-- when you shouldn't have.
+<span class="lineno"> 14 </span>module Crypto.NaCl.Key
+<span class="lineno"> 15 </span> ( -- * Types
+<span class="lineno"> 16 </span> PublicKey(..)
+<span class="lineno"> 17 </span> , SecretKey(..)
+<span class="lineno"> 18 </span> , KeyPair
+<span class="lineno"> 19 </span> ) where
+<span class="lineno"> 20 </span>import Data.ByteString
+<span class="lineno"> 21 </span>
+<span class="lineno"> 22 </span>newtype PublicKey = PublicKey { unPublicKey :: ByteString }
+<span class="lineno"> 23 </span> deriving (Eq, <span class="decl"><span class="nottickedoff"><span class="decl"><span class="nottickedoff">Show</span></span></span></span>)
+<span class="lineno"> 24 </span>
+<span class="lineno"> 25 </span>newtype SecretKey = SecretKey { unSecretKey :: ByteString }
+<span class="lineno"> 26 </span> deriving (Eq, <span class="decl"><span class="nottickedoff"><span class="decl"><span class="nottickedoff">Show</span></span></span></span>)
+<span class="lineno"> 27 </span>
+<span class="lineno"> 28 </span>type KeyPair = (PublicKey, SecretKey)
+
+</pre>
+</html>
View
104 cov/salt-0.0/Crypto.NaCl.Nonce.hs.html
@@ -0,0 +1,104 @@
+<html><style type="text/css">
+span.lineno { color: white; background: #aaaaaa; border-right: solid white 12px }
+span.nottickedoff { background: yellow}
+span.istickedoff { background: white }
+span.tickonlyfalse { margin: -1px; border: 1px solid #f20913; background: #f20913 }
+span.tickonlytrue { margin: -1px; border: 1px solid #60de51; background: #60de51 }
+span.funcount { font-size: small; color: orange; z-index: 2; position: absolute; right: 20 }
+span.decl { font-weight: bold }
+span.spaces { background: white }
+</style>
+<pre>
+<span class="lineno"> 1 </span>{-# LANGUAGE ScopedTypeVariables #-}
+<span class="lineno"> 2 </span>-- |
+<span class="lineno"> 3 </span>-- Module : Crypto.NaCl.Nonce
+<span class="lineno"> 4 </span>-- Copyright : (c) Austin Seipp 2011-2012
+<span class="lineno"> 5 </span>-- License : MIT
+<span class="lineno"> 6 </span>--
+<span class="lineno"> 7 </span>-- Maintainer : mad.one@gmail.com
+<span class="lineno"> 8 </span>-- Stability : experimental
+<span class="lineno"> 9 </span>-- Portability : GHC (ScopedTypeVariables)
+<span class="lineno"> 10 </span>--
+<span class="lineno"> 11 </span>-- Simple API for cryptographic nonces.
+<span class="lineno"> 12 </span>--
+<span class="lineno"> 13 </span>module Crypto.NaCl.Nonce
+<span class="lineno"> 14 </span> ( -- * Nonce class
+<span class="lineno"> 15 </span> Nonce, size, toBS, fromBS
+<span class="lineno"> 16 </span> , createZeroNonce -- :: Nonce k =&gt; k
+<span class="lineno"> 17 </span> , createRandomNonce -- :: Nonce k =&gt; IO k
+<span class="lineno"> 18 </span> , clearBytes -- :: Nonce k =&gt; Int -&gt; k -&gt; k
+<span class="lineno"> 19 </span> , incNonce -- :: Nonce k =&gt; k -&gt; k
+<span class="lineno"> 20 </span> ) where
+<span class="lineno"> 21 </span>import Foreign.Ptr
+<span class="lineno"> 22 </span>import Foreign.C.Types
+<span class="lineno"> 23 </span>import Control.Monad (liftM)
+<span class="lineno"> 24 </span>import Data.Word
+<span class="lineno"> 25 </span>import Data.Maybe
+<span class="lineno"> 26 </span>import Data.Tagged
+<span class="lineno"> 27 </span>import Data.ByteString as S
+<span class="lineno"> 28 </span>import Data.ByteString.Internal as SI
+<span class="lineno"> 29 </span>import Data.ByteString.Unsafe as SU
+<span class="lineno"> 30 </span>
+<span class="lineno"> 31 </span>import Crypto.NaCl.Random (randomBytes)
+<span class="lineno"> 32 </span>
+<span class="lineno"> 33 </span>class Nonce k where
+<span class="lineno"> 34 </span> size :: Tagged k Int
+<span class="lineno"> 35 </span> toBS :: k -&gt; ByteString
+<span class="lineno"> 36 </span> fromBS :: ByteString -&gt; (Maybe k)
+<span class="lineno"> 37 </span>
+<span class="lineno"> 38 </span> -- | Create an empty nonce of length @n@ where all the bytes are zero.
+<span class="lineno"> 39 </span> createZeroNonce :: k
+<span class="lineno"> 40 </span> <span class="decl"><span class="istickedoff">createZeroNonce</span>
+<span class="lineno"> 41 </span><span class="spaces"> </span><span class="istickedoff">= fromJust . fromBS $ S.replicate sz 0x0</span>
+<span class="lineno"> 42 </span><span class="spaces"> </span><span class="istickedoff">where sz = unTagged (size :: Tagged k Int)</span></span>
+<span class="lineno"> 43 </span> {-# INLINEABLE createZeroNonce #-}
+<span class="lineno"> 44 </span>
+<span class="lineno"> 45 </span> -- | Create a random nonce, seeded by @/dev/urandom@.
+<span class="lineno"> 46 </span> createRandomNonce :: IO k
+<span class="lineno"> 47 </span> <span class="decl"><span class="istickedoff">createRandomNonce</span>
+<span class="lineno"> 48 </span><span class="spaces"> </span><span class="istickedoff">= (fromJust . fromBS) `liftM` randomBytes sz</span>
+<span class="lineno"> 49 </span><span class="spaces"> </span><span class="istickedoff">where sz = unTagged (size :: Tagged k Int)</span></span>
+<span class="lineno"> 50 </span> {-# INLINEABLE createRandomNonce #-}
+<span class="lineno"> 51 </span>
+<span class="lineno"> 52 </span> -- | @clearBytes n nonce@ clears the last @n@ bytes of the Nonce and
+<span class="lineno"> 53 </span> -- makes them all 0. This is useful for the pattern of generating a
+<span class="lineno"> 54 </span> -- cryptographic nonce randomly, clearing the last @n@ bytes, and then
+<span class="lineno"> 55 </span> -- using 'incNonce' to increment the 'Nonce' for communication with
+<span class="lineno"> 56 </span> -- another party.
+<span class="lineno"> 57 </span> --
+<span class="lineno"> 58 </span> -- Invariants:
+<span class="lineno"> 59 </span> --
+<span class="lineno"> 60 </span> -- * @n@ must be less than the size of the @nonce@
+<span class="lineno"> 61 </span> --
+<span class="lineno"> 62 </span> -- Properties:
+<span class="lineno"> 63 </span> --
+<span class="lineno"> 64 </span> -- &gt; clearBytes (nonceLen nonce) nonce == createZeroNonce (nonceLen nonce)
+<span class="lineno"> 65 </span> --
+<span class="lineno"> 66 </span> clearBytes :: Int -&gt; k -&gt; k
+<span class="lineno"> 67 </span> <span class="decl"><span class="istickedoff">clearBytes n x</span>
+<span class="lineno"> 68 </span><span class="spaces"> </span><span class="istickedoff">| <span class="tickonlyfalse">n &gt; l</span> = <span class="nottickedoff">error &quot;Crypto.NaCl.Nonce.clearBytes: n &gt; length of nonce&quot;</span></span>
+<span class="lineno"> 69 </span><span class="spaces"> </span><span class="istickedoff">| <span class="tickonlyfalse">n &lt; 0</span> = <span class="nottickedoff">error &quot;Crypto.NaCl.Nonce.clearBytes: n &lt; 0&quot;</span> </span>
+<span class="lineno"> 70 </span><span class="spaces"> </span><span class="istickedoff">| n == 0 = x</span>
+<span class="lineno"> 71 </span><span class="spaces"> </span><span class="istickedoff">| <span class="tickonlytrue">otherwise</span> = (fromJust . fromBS) $! S.take (l - n) (toBS x) `S.append` S.replicate n 0x0</span>
+<span class="lineno"> 72 </span><span class="spaces"> </span><span class="istickedoff">where l = unTagged (size :: Tagged k Int)</span></span>
+<span class="lineno"> 73 </span> {-# INLINEABLE clearBytes #-}
+<span class="lineno"> 74 </span>
+<span class="lineno"> 75 </span> -- | Increment a Nonce by 1.
+<span class="lineno"> 76 </span> incNonce :: k -&gt; k
+<span class="lineno"> 77 </span> <span class="decl"><span class="istickedoff">incNonce n =</span>
+<span class="lineno"> 78 </span><span class="spaces"> </span><span class="istickedoff">(fromJust . fromBS) $ SI.unsafeCreate l $ \out -&gt; do</span>
+<span class="lineno"> 79 </span><span class="spaces"> </span><span class="istickedoff">SU.unsafeUseAsCStringLen (toBS n) $ \(b,blen) -&gt;</span>
+<span class="lineno"> 80 </span><span class="spaces"> </span><span class="istickedoff">SI.memcpy out (castPtr b) (fromIntegral blen)</span>
+<span class="lineno"> 81 </span><span class="spaces"> </span><span class="istickedoff">c_incnonce out (fromIntegral l)</span>
+<span class="lineno"> 82 </span><span class="spaces"> </span><span class="istickedoff">where l = unTagged (size :: Tagged k Int)</span></span>
+<span class="lineno"> 83 </span> {-# INLINEABLE incNonce #-}
+<span class="lineno"> 84 </span>
+<span class="lineno"> 85 </span>
+<span class="lineno"> 86 </span>--
+<span class="lineno"> 87 </span>-- FFI
+<span class="lineno"> 88 </span>--
+<span class="lineno"> 89 </span>foreign import ccall unsafe &quot;glue_incnonce&quot;
+<span class="lineno"> 90 </span> c_incnonce :: Ptr Word8 -&gt; CSize -&gt; IO ()
+
+</pre>
+</html>
View
53 cov/salt-0.0/Crypto.NaCl.Random.hs.html
@@ -0,0 +1,53 @@
+<html><style type="text/css">
+span.lineno { color: white; background: #aaaaaa; border-right: solid white 12px }
+span.nottickedoff { background: yellow}
+span.istickedoff { background: white }
+span.tickonlyfalse { margin: -1px; border: 1px solid #f20913; background: #f20913 }
+span.tickonlytrue { margin: -1px; border: 1px solid #60de51; background: #60de51 }
+span.funcount { font-size: small; color: orange; z-index: 2; position: absolute; right: 20 }
+span.decl { font-weight: bold }
+span.spaces { background: white }