-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
251 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.0 | ||
1.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
(dirs :standard \ vendor) | ||
(dirs :standard \ vendor _site .bundle) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(lang dune 1.9) | ||
(name nocoiner) | ||
(version 1.0.0) | ||
(version 1.0.1) | ||
(using fmt 1.1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Sys = Core.Sys | ||
module Option = Core.Option | ||
module Int = Core.Int | ||
|
||
let get variable default = | ||
let optional = Sys.getenv variable in | ||
Option.value optional ~default | ||
|
||
|
||
let _KDF_COST = get "NOCOINER_KDF_COST" "8192" |> Int.of_string | ||
|
||
let _KDF_WORKERS = get "NOCOINER_KDF_WORKERS" "2" |> Int.of_string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
val _KDF_COST : int | ||
|
||
val _KDF_WORKERS : int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
module List = Core.List | ||
|
||
let hash data = Cstruct.of_hex @@ Hashing.hash data | ||
let hash data = Cstruct.of_string @@ Hashing.raw_hash data | ||
|
||
let xor = Nocrypto.Uncommon.Cs.xor | ||
|
||
let xor_list = List.reduce_exn ~f:xor | ||
|
||
let id () = | ||
let timestamp = hash @@ string_of_float @@ Unix.gettimeofday () in | ||
let pid = hash @@ string_of_int @@ Unix.getpid () in | ||
let hostname = hash @@ Unix.gethostname () in | ||
let cwd = hash @@ Unix.getcwd () in | ||
let context = | ||
Cstruct.to_string @@ xor_list [ timestamp; pid; hostname; cwd ] | ||
timestamp | ||
|> xor pid | ||
|> xor hostname | ||
|> xor cwd | ||
|> Cstruct.to_string | ||
in | ||
Encoding.encode @@ Hashing.raw_hash context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
open Constants | ||
|
||
let kdf ~size ~salt password = | ||
Scrypt_kdf.scrypt_kdf ~password ~salt ~dk_len:size ~r:8 ~p:2 ~n:8192 | ||
Scrypt_kdf.scrypt_kdf | ||
~password | ||
~salt | ||
~dk_len:size | ||
~r:8 | ||
~p:_KDF_WORKERS | ||
~n:_KDF_COST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
module Blake2B = Digestif.BLAKE2B | ||
|
||
let hash data = Blake2B.to_hex @@ Blake2B.digest_string data | ||
|
||
let raw_hash data = Blake2B.to_raw_string @@ Blake2B.digest_string data | ||
|
||
let mac ~key data = Blake2B.to_hex @@ Blake2B.Keyed.mac_string ~key data | ||
let raw_mac ~key data = Blake2B.to_raw_string @@ Blake2B.Keyed.mac_string ~key data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
val hash : string -> string | ||
|
||
val raw_hash : string -> string | ||
|
||
val mac : key:string -> string -> string | ||
val raw_mac : key:string -> string -> string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.