Skip to content
Permalink
Browse files

docs: 📖 adding badge for tag version and updating docs

Signed-off-by: Marco Aurélio da Silva <marcoonroad@gmail.com>
  • Loading branch information...
marcoonroad committed Aug 5, 2019
1 parent dad8c2d commit d067785ee7ce7a8480b7bd5d4f8d28d2c3fc49cb
@@ -40,6 +40,12 @@ nocoiner
href="https://github.com/marcoonroad/nocoiner/compare"
title="Interested in contribute with this project?"><img
src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square&logo=github"/></a>
<!-- GitHub latest release/tag -->
<a
style="margin: 0.1em;"
href="https://github.com/marcoonroad/nocoiner/releases"
title="Check the GitHub repository releases here."><img
src="https://img.shields.io/github/tag-date/marcoonroad/nocoiner?logo=github&style=flat-square"></a>
<!-- Donate BTC badge -->
<a
style="margin: 0.1em;"
@@ -92,6 +92,6 @@ <h2>100.00%</h2>
</a>
</div>
</div>
<div id="footer">Generated on 2019-08-04 23:31:08 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<div id="footer">Generated on 2019-08-05 16:21:33 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
</body>
</html>
@@ -26,14 +26,14 @@ <h2>100.00%</h2>
<a id="L6"></a><span > </span>
<a id="L7"></a><span > </span>
<a id="L8"></a><span class="visited"> </span>
<a id="L9"></a><span > </span>
<a id="L9"></a><span class="visited"> </span>
<a id="L10"></a><span class="visited"> </span>
<a id="L11"></a><span > </span>
<a id="L12"></a><span > </span>
<a id="L13"></a><span class="visited"> </span>
<a id="L12"></a><span class="visited"> </span>
<a id="L13"></a><span > </span>
<a id="L14"></a><span > </span>
<a id="L15"></a><span > </span>
<a id="L16"></a><span > </span>
<a id="L16"></a><span class="visited"> </span>
</pre>
</div>
<div id="text-layer">
@@ -58,24 +58,24 @@ <h2>100.00%</h2>
<pre id="code">
module Base64 = Nocrypto.Base64

let encode_blob cstruct = Cstruct.to_string @@ Base64.<span data-count="84">e</span>ncode cstruct
let encode_blob cstruct = <span data-count="64">C</span>struct.to_string @@ Base64.encode cstruct

let encode message = encode_blob @@ Cstruct.of_st<span data-count="28">r</span>ing message
let encode message = <span data-count="24">e</span>ncode_blob @@ Cstruct.of_string message

let decode_as_blob encoded =
let nullable = Base64.decode<span data-count="427"> </span>@@ Cstruct.of_<span data-count="425">s</span>tring encoded in
match nullable with
| Some<span data-count="24"> </span>value -&gt;
<span data-count="405">l</span>et nullable = <span data-count="405">B</span>ase64.decode @@ Cstruct.of_string encoded in
<span data-count="405">m</span>atch nullable with
| <span data-count="403">S</span>ome value -&gt;
value
| None -&gt;
failwith<span data-count="407"> </span>"Failed to decode Base 64 blob!"
| <span data-count="2">N</span>one -&gt;
failwith "Failed to decode Base 64 blob!"


let decode encoded = Cstruct.to_string @@ decode_as_blob encoded
let decode encoded = <span data-count="106">C</span>struct.to_string @@ decode_as_blob encoded
</pre>
</div>
</div>
<div id="footer">Generated on 2019-08-04 23:31:08 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<div id="footer">Generated on 2019-08-05 16:21:33 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<script src="../coverage.js"></script>
</body>
</html>
@@ -26,7 +26,7 @@ <h2>100.00%</h2>
<a id="L6"></a><span class="visited"> </span>
<a id="L7"></a><span class="visited"> </span>
<a id="L8"></a><span class="visited"> </span>
<a id="L9"></a><span > </span>
<a id="L9"></a><span class="visited"> </span>
<a id="L10"></a><span > </span>
<a id="L11"></a><span > </span>
<a id="L12"></a><span class="visited"> </span>
@@ -37,29 +37,29 @@ <h2>100.00%</h2>
<a id="L17"></a><span > </span>
<a id="L18"></a><span > </span>
<a id="L19"></a><span > </span>
<a id="L20"></a><span > </span>
<a id="L21"></a><span > </span>
<a id="L22"></a><span > </span>
<a id="L23"></a><span > </span>
<a id="L24"></a><span > </span>
<a id="L20"></a><span class="visited"> </span>
<a id="L21"></a><span class="visited"> </span>
<a id="L22"></a><span class="visited"> </span>
<a id="L23"></a><span class="visited"> </span>
<a id="L24"></a><span class="visited"> </span>
<a id="L25"></a><span > </span>
<a id="L26"></a><span > </span>
<a id="L27"></a><span > </span>
<a id="L28"></a><span > </span>
<a id="L29"></a><span > </span>
<a id="L26"></a><span class="visited"> </span>
<a id="L27"></a><span class="visited"> </span>
<a id="L28"></a><span class="visited"> </span>
<a id="L29"></a><span class="visited"> </span>
<a id="L30"></a><span > </span>
<a id="L31"></a><span > </span>
<a id="L32"></a><span > </span>
<a id="L33"></a><span > </span>
<a id="L34"></a><span > </span>
<a id="L35"></a><span > </span>
<a id="L36"></a><span > </span>
<a id="L37"></a><span > </span>
<a id="L33"></a><span class="visited"> </span>
<a id="L34"></a><span class="visited"> </span>
<a id="L35"></a><span class="visited"> </span>
<a id="L36"></a><span class="visited"> </span>
<a id="L37"></a><span class="visited"> </span>
<a id="L38"></a><span > </span>
<a id="L39"></a><span > </span>
<a id="L40"></a><span > </span>
<a id="L41"></a><span > </span>
<a id="L42"></a><span > </span>
<a id="L39"></a><span class="visited"> </span>
<a id="L40"></a><span class="visited"> </span>
<a id="L41"></a><span class="visited"> </span>
<a id="L42"></a><span class="visited"> </span>
</pre>
</div>
<div id="text-layer">
@@ -112,48 +112,48 @@ <h2>100.00%</h2>
module AES = Nocrypto.Cipher_block.AES.CBC

let __kdf key =
let aes_salt = Entro<span data-count="71">p</span>y.min_bit<span data-count="71">s</span> (32 * 8) in
let mac<span data-count="71">_</span>salt = Entropy.<span data-count="71">m</span>ax_bits (32 * 8) in
let aes_<span data-count="71">k</span>ey = Hardeni<span data-count="71">n</span>g.kdf ~size:32l ~salt:aes_salt key in
let mac_key = Ha<span data-count="71">r</span>dening.kdf ~size:32l ~salt:mac_salt key in
(aes_key, mac_key)
<span data-count="67">l</span>et aes_salt = <span data-count="67">E</span>ntropy.min_bits (32 * 8) in
<span data-count="67">l</span>et mac_salt = <span data-count="67">E</span>ntropy.max_bits (32 * 8) in
<span data-count="67">l</span>et aes_key = <span data-count="67">H</span>ardening.kdf ~size:32l ~salt:aes_salt key in
<span data-count="67">l</span>et mac_key = <span data-count="67">H</span>ardening.kdf ~size:32l ~salt:mac_salt key in
<span data-count="67">(</span>aes_key, mac_key)


let hash data = C<span data-count="13">s</span>truct.of_<span data-count="72">h</span>ex @@ Hashing.hash @@ <span data-count="72">C</span>struct.to_st<span data-count="72">r</span>ing data
let hash data = <span data-count="67">C</span>struct.of_hex @@ Hashing.hash @@ Cstruct.to_string data

let mac ~key data =
<span data-count="72">l</span>et key', data' = (Cstruct.to_string key, Cst<span data-count="69">r</span>uct.to_string data) in
Cstruct.of_hex @@ Hashing.mac ~key:<span data-count="70">k</span>ey' data'
<span data-count="67">l</span>et key', data' = <span data-count="67">(</span>Cstruct.to_string key, Cstruct.to_string data) in
<span data-count="67">C</span>struct.of_hex @@ Hashing.mac ~key:key' data'


let encrypt ~key ~iv ~metadata ~message:msg =
let aes_key, mac_key = __kdf key in
let aes_key' = AES.of_secret aes_key in
let plaintext = Helpers.pad ~basis:16 @@ Cstruct.to_string msg in
let ciphertext =
AES.encrypt ~iv ~key:aes_key' @@ Cstruct.of_string plaintext
<span data-count="8">l</span>et aes_key, mac_key = <span data-count="8">_</span>_kdf key in
<span data-count="8">l</span>et aes_key' = <span data-count="8">A</span>ES.of_secret aes_key in
<span data-count="8">l</span>et plaintext = <span data-count="8">H</span>elpers.pad ~basis:16 @@ Cstruct.to_string msg in
<span data-count="8">l</span>et ciphertext =
<span data-count="8">A</span>ES.encrypt ~iv ~key:aes_key' @@ Cstruct.of_string plaintext
in
let secret = hash mac_key in
let payload = Cstruct.concat [ metadata; iv; ciphertext ] in
let tag = mac ~key:secret payload in
(ciphertext, tag)
<span data-count="8">l</span>et secret = <span data-count="8">h</span>ash mac_key in
<span data-count="8">l</span>et payload = <span data-count="8">C</span>struct.concat [ metadata; iv; ciphertext ] in
<span data-count="8">l</span>et tag = <span data-count="8">m</span>ac ~key:secret payload in
<span data-count="8">(</span>ciphertext, tag)


let decrypt ~reason ~key ~iv ~metadata ~cipher ~tag =
let aes_key, mac_key = __kdf key in
let secret = hash mac_key in
let payload = Cstruct.concat [ metadata; iv; cipher ] in
let tag' = mac ~key:secret payload in
if Cstruct.equal tag tag'
<span data-count="59">l</span>et aes_key, mac_key = <span data-count="59">_</span>_kdf key in
<span data-count="59">l</span>et secret = <span data-count="59">h</span>ash mac_key in
<span data-count="59">l</span>et payload = <span data-count="59">C</span>struct.concat [ metadata; iv; cipher ] in
<span data-count="59">l</span>et tag' = <span data-count="59">m</span>ac ~key:secret payload in
<span data-count="59">i</span>f Cstruct.equal tag tag'
then
let aes_key' = AES.of_secret aes_key in
let plaintext = AES.decrypt ~iv ~key:aes_key' cipher in
Cstruct.of_string @@ Helpers.unpad @@ Cstruct.to_string plaintext
else raise reason
<span data-count="53">l</span>et aes_key' = <span data-count="53">A</span>ES.of_secret aes_key in
<span data-count="53">l</span>et plaintext = <span data-count="53">A</span>ES.decrypt ~iv ~key:aes_key' cipher in
<span data-count="53">C</span>struct.of_string @@ Helpers.unpad @@ Cstruct.to_string plaintext
else <span data-count="6">r</span>aise reason
</pre>
</div>
</div>
<div id="footer">Generated on 2019-08-04 23:31:08 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<div id="footer">Generated on 2019-08-05 16:21:33 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<script src="../coverage.js"></script>
</body>
</html>
@@ -35,15 +35,15 @@ <h2>100.00%</h2>
<a id="L15"></a><span class="visited"> </span>
<a id="L16"></a><span > </span>
<a id="L17"></a><span > </span>
<a id="L18"></a><span > </span>
<a id="L18"></a><span class="visited"> </span>
<a id="L19"></a><span > </span>
<a id="L20"></a><span > </span>
<a id="L20"></a><span class="visited"> </span>
<a id="L21"></a><span > </span>
<a id="L22"></a><span > </span>
<a id="L22"></a><span class="visited"> </span>
<a id="L23"></a><span > </span>
<a id="L24"></a><span > </span>
<a id="L24"></a><span class="visited"> </span>
<a id="L25"></a><span > </span>
<a id="L26"></a><span > </span>
<a id="L26"></a><span class="visited"> </span>
</pre>
</div>
<div id="text-layer">
@@ -79,33 +79,33 @@ <h2>100.00%</h2>
module RngZ = Nocrypto.Rng.Z
module NumZ = Nocrypto.Numeric.Z

let __gen_min bits = <span data-count="91">"</span>1" ^ Core.String.init (bits - 1) ~f:(Core.const '0')
let __gen_min bits = <span data-count="83">"</span>1" ^ Core.String.init (bits - 1) ~f:(Core.const '0')

let __gen_max bits = <span data-count="91">C</span>ore.String.init bits ~f:(Core.const '1')
let __gen_max bits = <span data-count="83">C</span>ore.String.init bits ~f:(Core.const '1')

let __max_bits bits = Z.of_<span data-count="24">s</span>tring_base 2 @@ _<span data-count="24">_</span>gen_max bits
let __max_bits bits = <span data-count="83">Z</span>.of_string_base 2 @@ __gen_max bits

let __min_bits bits = Z.of_<span data-count="24">s</span>tring_base 2 @@ _<span data-count="91">_</span>gen_min bits
let __min_bits bits = <span data-count="83">Z</span>.of_string_base 2 @@ __gen_min bits

let __random_bits bits =
<span data-count="91">l</span>et _min_random = __min_bits bits in
let _max_random = __max_bits bit<span data-count="20">s</span> in
NumZ.to_cstruct_be @@ Rn<span data-count="20">g</span>Z.gen_r _min_random _max_r<span data-count="81">a</span>ndom
<span data-count="16">l</span>et _min_random = <span data-count="16">_</span>_min_bits bits in
<span data-count="16">l</span>et _max_random = <span data-count="16">_</span>_max_bits bits in
<span data-count="16">N</span>umZ.to_cstruct_be @@ RngZ.gen_r _min_random _max_random


let max_bits bits = NumZ.to_cstruct_be @@ __max_bits bits
let max_bits bits = <span data-count="67">N</span>umZ.to_cstruct_be @@ __max_bits bits

let min_bits bits = NumZ.to_cstruct_be @@ __min_bits bits
let min_bits bits = <span data-count="67">N</span>umZ.to_cstruct_be @@ __min_bits bits

let key () = __random_bits 256
let key () = <span data-count="8">_</span>_random_bits 256

let iv () = __random_bits 128
let iv () = <span data-count="8">_</span>_random_bits 128

let _ = Nocrypto_entropy_unix.initialize ()
let _ = <span data-count="1">N</span>ocrypto_entropy_unix.initialize ()
</pre>
</div>
</div>
<div id="footer">Generated on 2019-08-04 23:31:08 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<div id="footer">Generated on 2019-08-05 16:21:33 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<script src="../coverage.js"></script>
</body>
</html>
@@ -42,7 +42,7 @@ <h2>100.00%</h2>
</pre>
</div>
</div>
<div id="footer">Generated on 2019-08-04 23:31:08 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<div id="footer">Generated on 2019-08-05 16:21:33 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<script src="../coverage.js"></script>
</body>
</html>
@@ -78,7 +78,7 @@ <h2>100.00%</h2>
</pre>
</div>
</div>
<div id="footer">Generated on 2019-08-04 23:31:08 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<div id="footer">Generated on 2019-08-05 16:21:33 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<script src="../coverage.js"></script>
</body>
</html>
@@ -33,7 +33,7 @@ <h2>100.00%</h2>
</pre>
</div>
</div>
<div id="footer">Generated on 2019-08-04 23:31:08 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<div id="footer">Generated on 2019-08-05 16:21:33 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<script src="../coverage.js"></script>
</body>
</html>
@@ -48,7 +48,7 @@ <h2>100.00%</h2>
</pre>
</div>
</div>
<div id="footer">Generated on 2019-08-04 23:31:08 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<div id="footer">Generated on 2019-08-05 16:21:33 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<script src="../coverage.js"></script>
</body>
</html>
@@ -62,23 +62,23 @@ <h2>100.00%</h2>
module String = Core.String
module Char = Core.Char

let __nullchar = <span data-count="15">C</span>har.of_int_exn 0
let __nullchar = <span data-count="1">C</span>har.of_int_exn 0

let pad ~basis msg =
<span data-count="12">l</span>et encoded = <span data-count="12">E</span>ncoding.encode msg in
<span data-count="12">l</span>et length = <span data-count="12">S</span>tring.length encoded in
<span data-count="12">l</span>et remainder = <span data-count="12">I</span>nt.( % ) length basis in
<span data-count="12">l</span>et zerofill = <span data-count="12">S</span>tring.make (basis - remainder) __nullchar in
<span data-count="12">e</span>ncoded ^ zerofill
<span data-count="8">l</span>et encoded = <span data-count="8">E</span>ncoding.encode msg in
<span data-count="8">l</span>et length = <span data-count="8">S</span>tring.length encoded in
<span data-count="8">l</span>et remainder = <span data-count="8">I</span>nt.( % ) length basis in
<span data-count="8">l</span>et zerofill = <span data-count="8">S</span>tring.make (basis - remainder) __nullchar in
<span data-count="8">e</span>ncoded ^ zerofill


let __nonzero char =<span data-count="5952"> </span>char != __nullchar
let __nonzero char = <span data-count="5904">c</span>har != __nullchar

let unpad msg =<span data-count="55"> </span>Encoding.decode @@ String.filter ~f:__nonzero msg
let unpad msg = <span data-count="53">E</span>ncoding.decode @@ String.filter ~f:__nonzero msg
</pre>
</div>
</div>
<div id="footer">Generated on 2019-08-04 23:31:08 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<div id="footer">Generated on 2019-08-05 16:21:33 by <a href="https://github.com/aantron/bisect_ppx">Bisect_ppx</a> 1.4.1</div>
<script src="../coverage.js"></script>
</body>
</html>

0 comments on commit d067785

Please sign in to comment.
You can’t perform that action at this time.