diff --git a/Cargo.lock b/Cargo.lock index 7e0d4e8..c8ebe3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,9 +1,11 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "aho-corasick" -version = "0.5.3" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -16,26 +18,17 @@ dependencies = [ [[package]] name = "base64" -version = "0.9.0" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "bitflags" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "byteorder" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "cc" -version = "1.0.9" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -60,7 +53,7 @@ dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -81,25 +74,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "env_logger" -version = "0.3.5" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "error-chain" -version = "0.11.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "flate2" version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -122,20 +118,21 @@ version = "0.3.54" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "itertools" -version = "0.7.8" +name = "getrandom" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)", + "wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "kernel32-sys" -version = "0.2.2" +name = "itertools" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -154,25 +151,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "1.0.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.40" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "log" -version = "0.4.1" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -180,11 +169,8 @@ dependencies = [ [[package]] name = "memchr" -version = "0.1.11" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "memoffset" @@ -212,11 +198,11 @@ dependencies = [ [[package]] name = "miniz-sys" -version = "0.1.10" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -229,9 +215,14 @@ name = "num_cpus" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ppv-lite86" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "protobuf" version = "1.5.1" @@ -239,12 +230,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quickcheck" -version = "0.4.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -253,7 +245,7 @@ version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -263,8 +255,45 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ppv-lite86 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -281,27 +310,26 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "0.1.80" +version = "1.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.13 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.3.9" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -311,7 +339,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -320,42 +348,29 @@ dependencies = [ name = "rusty_secrets" version = "0.2.3-pre" dependencies = [ - "base64 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "merkle_sigs 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "quickcheck 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quickcheck 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "safemem" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "thread-id" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "thread_local" -version = "0.2.7" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -364,29 +379,24 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "utf8-ranges" -version = "0.1.3" +name = "version_check" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "winapi" -version = "0.2.8" +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.4" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -398,55 +408,55 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] -"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" +"checksum aho-corasick 0.7.13 (registry+https://github.com/rust-lang/crates.io-index)" = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" -"checksum base64 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "229d032f1a99302697f10b27167ae6d03d49d032e6a8e2550e8d3fc13356d2b4" +"checksum base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" "checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" -"checksum byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "73b5bdfe7ee3ad0b99c9801d58807a9dbc9e09196365b0203853b99889ab3c87" -"checksum cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "2b4911e4bdcb4100c7680e7e854ff38e23f1b34d4d9e079efae3da2801341ffc" +"checksum cc 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" -"checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" -"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" +"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +"checksum error-chain 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" "checksum flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "e6234dd4468ae5d1e2dbb06fe2b058696fdc50a339c68a393aefbf00bc81e423" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" -"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +"checksum itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" "checksum lamport_sigs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5dff26ae558be16afda65815c847447c81eede19c639982e49e33bd15973d857" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" -"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" -"checksum libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "6fd41f331ac7c5b8ac259b8bf82c75c0fb2e469bbf37d2becbba9a6a2221965b" -"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" -"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" +"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +"checksum libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum merkle 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6311caa1c5c71548021dfc5f6113fca485d453185fdc44da92bafe266f6a5fe" "checksum merkle_sigs 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94367864019d3b781c28c67d0a7057da0df498525982869c47ecfd73ece29f26" -"checksum miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4" +"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" +"checksum ppv-lite86 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" "checksum protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40e2484e639dcae0985fc483ad76ce7ad78ee5aa092751d7d538f0b20d76486b" -"checksum quickcheck 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "02c2411d418cea2364325b18a205664f9ef8252e06b2e911db97c0b0d98b1406" +"checksum quickcheck 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f" "checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" +"checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +"checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b614fe08b6665cb9a231d07ac1364b0ef3cb3698f1239ee0c4c3a88a524f54c8" "checksum rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d24ad214285a7729b174ed6d3bcfcb80177807f959d95fafd5bfc5c4f201ac8" -"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" -"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" +"checksum regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" +"checksum regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)" = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" "checksum ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6f7d28b30a72c01b458428e0ae988d4149c20d902346902be881e3edc4bb325c" -"checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" -"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" -"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" +"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" "checksum untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f392d7819dbe58833e26872f5f6f0d68b7bbbe90fc3667e98731c4a15ad9a7ae" -"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 6b5581b..fa40a1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rusty_secrets" +name = "rusty_secrets" version = "0.2.3-pre" authors = [ "Frederic Jacobs ", @@ -8,62 +8,62 @@ authors = [ "Noah Vesely ", "sellibitze" ] -description = "Implementation of threshold Shamir's secret sharing in the Rust programming language." -homepage = "https://github.com/freedomofpress/RustySecrets" -license = "BSD-3-Clause" -readme = "README.md" -build = "build.rs" -exclude = ["Cargo.lock"] +description = "Implementation of threshold Shamir's secret sharing in the Rust programming language." +homepage = "https://github.com/freedomofpress/RustySecrets" +license = "BSD-3-Clause" +readme = "README.md" +build = "build.rs" +edition = "2018" +exclude = ["Cargo.lock"] [badges] travis-ci = { repository = "SpinResearch/RustySecrets", branch = "master" } coveralls = { repository = "SpinResearch/RustySecrets", branch = "master", service = "github" } [features] -default = [] -dss = [] +default = ["dss"] +dss = [] [dependencies] -base64 = "0.9.0" -rand = "^0.4.2" -ring = "^0.12" -merkle_sigs = "^1.4" -protobuf = ">= 1.4, < 1.6" +base64 = "0.12" +rand = "0.7" +ring = "0.12" +merkle_sigs = "1.4" +protobuf = ">= 1.4, < 1.6" +rand_chacha = "0.2.2" [dependencies.error-chain] -version = "0.11.0" +version = "0.12.0" default-features = false [dev-dependencies] -itertools = "^0.7" -quickcheck = "^0.4" -flate2 = "^0.2" -rand = "^0.4.2" +itertools = "0.9" +quickcheck = "0.9" +flate2 = "0.2" [profile.bench] -opt-level = 3 -debug = false -rpath = false -lto = true +opt-level = 3 +debug = false +rpath = false +lto = true debug-assertions = false -codegen-units = 1 +codegen-units = 1 [profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true +opt-level = 3 +debug = false +rpath = false +lto = true debug-assertions = false -codegen-units = 1 +codegen-units = 1 [package.metadata.release] -sign-commit = true -upload-doc = true -doc-branch = "gh-pages" -pre-release-commit-message = "Release version {{version}}." -pro-release-commit-message = "Start next development iteration {{version}}." -tag-prefix = "v" -tag-message = "Release version {{version}}." -doc-commit-message = "Update documentation." -dev-version-ext = "pre" +sign-commit = true +sign-tag = true +pre-release-commit-message = "Release version {{version}}." +post-release-commit-message = "Start next development iteration {{version}}." +tag-prefix = "v" +tag-message = "Release version {{version}}." +doc-commit-message = "Update documentation." +dev-version-ext = "pre" diff --git a/benches/ss1.rs b/benches/ss1.rs index f6e993a..feef865 100644 --- a/benches/ss1.rs +++ b/benches/ss1.rs @@ -8,9 +8,9 @@ extern crate test; mod shared; mod ss1 { + use super::shared; use rusty_secrets::dss::ss1; - use shared; use test::{black_box, Bencher}; macro_rules! bench_generate { @@ -26,7 +26,8 @@ mod ss1 { &secret, ss1::Reproducibility::reproducible(), &None, - ).unwrap(); + ) + .unwrap(); black_box(shares); }); } @@ -56,5 +57,4 @@ mod ss1 { bench_generate!(generate_1kb_10_25, 10, 25, secret_1kb); bench_recover!(recover_1kb_10_25, 10, 25, secret_1kb); - } diff --git a/benches/sss.rs b/benches/sss.rs index 65ead56..b7de1f2 100644 --- a/benches/sss.rs +++ b/benches/sss.rs @@ -7,9 +7,9 @@ extern crate test; mod shared; mod sss { + use super::shared; use rusty_secrets::sss; - use shared; use test::{black_box, Bencher}; macro_rules! bench_generate { @@ -53,5 +53,4 @@ mod sss { bench_generate!(generate_1kb_10_25_signed, 10, 25, secret_1kb, true); bench_recover!(recover_1kb_10_25_signed, 10, 25, secret_1kb, true); - } diff --git a/benches/thss.rs b/benches/thss.rs index c4dd97d..97bb71d 100644 --- a/benches/thss.rs +++ b/benches/thss.rs @@ -8,9 +8,9 @@ extern crate test; mod shared; mod thss { + use super::shared; use rusty_secrets::dss::thss; - use shared; use test::{black_box, Bencher}; macro_rules! bench_generate { @@ -48,5 +48,4 @@ mod thss { bench_generate!(generate_1kb_10_25, 10, 25, secret_1kb); bench_recover!(recover_1kb_10_25, 10, 25, secret_1kb); - } diff --git a/benches/wrapped_secrets.rs b/benches/wrapped_secrets.rs index af57141..6a53f80 100644 --- a/benches/wrapped_secrets.rs +++ b/benches/wrapped_secrets.rs @@ -7,9 +7,9 @@ extern crate test; mod shared; mod wrapped_secrets { + use super::shared; use rusty_secrets::wrapped_secrets; - use shared; use test::{black_box, Bencher}; macro_rules! bench_generate { @@ -55,5 +55,4 @@ mod wrapped_secrets { bench_generate!(generate_1kb_10_25_signed, 10, 25, secret_1kb, true); bench_recover!(recover_1kb_10_25_signed, 10, 25, secret_1kb, true); - } diff --git a/build.rs b/build.rs index a4d5019..ddc3100 100644 --- a/build.rs +++ b/build.rs @@ -25,6 +25,7 @@ struct Tables { log: [u8; 256], } +#[allow(clippy::match_wild_err_arm)] fn generate_tables(mut file: &File) { let mut tabs = Tables { exp: [0; 256], @@ -46,10 +47,10 @@ fn generate_tables(mut file: &File) { } fn farray(array: [u8; 256], f: &mut fmt::Formatter) -> fmt::Result { - for (index, value) in array.into_iter().enumerate() { - try!(write!(f, "{}", value)); + for (index, value) in array.iter().enumerate() { + write!(f, "{}", value)?; if index != array.len() - 1 { - try!(write!(f, ",")); + write!(f, ",")?; } } Ok(()) @@ -57,13 +58,13 @@ fn farray(array: [u8; 256], f: &mut fmt::Formatter) -> fmt::Result { impl fmt::Display for Tables { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - try!(write!(f, "Tables {{\n")); - try!(write!(f, " exp: [")); - try!(farray(self.exp, f)); - try!(write!(f, "],\n")); - try!(write!(f, " log: [")); - try!(farray(self.log, f)); - try!(write!(f, "]\n")); + writeln!(f, "Tables {{")?; + write!(f, " exp: [")?; + farray(self.exp, f)?; + writeln!(f, "],")?; + write!(f, " log: [")?; + farray(self.log, f)?; + writeln!(f, "]")?; write!(f, "}};") } } diff --git a/rust-toolchain b/rust-toolchain index f9e8384..d724e43 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.24.1 +1.44.1 diff --git a/src/dss/format.rs b/src/dss/format.rs index c4d0386..d0c491e 100644 --- a/src/dss/format.rs +++ b/src/dss/format.rs @@ -1,10 +1,7 @@ -use std::error::Error; - -use base64; use protobuf::{self, Message}; -use errors::*; -use proto::dss::ShareProto; +use crate::errors::*; +use crate::proto::dss::ShareProto; const BASE64_CONFIG: base64::Config = base64::STANDARD_NO_PAD; @@ -24,7 +21,7 @@ pub(crate) fn parse_share_protobuf(raw: &str) -> Result { let share_proto = protobuf::parse_from_bytes::(data.as_slice()).map_err(|e| { ErrorKind::ShareParsingError(format!( "Protobuf decoding of data block failed with error: {} .", - e.description() + e )) })?; diff --git a/src/dss/random.rs b/src/dss/random.rs index a09a0ec..66ab557 100644 --- a/src/dss/random.rs +++ b/src/dss/random.rs @@ -1,6 +1,4 @@ -use std; - -use errors::*; +use crate::errors::*; use ring::error::Unspecified; use ring::rand::SecureRandom; @@ -23,7 +21,7 @@ pub(crate) fn random_bytes_count(threshold: u8, message_size: usize) -> usize { } /// Attempts to read `count` random bytes from the given secure random generator. -pub(crate) fn random_bytes(random: &SecureRandom, count: usize) -> Result> { +pub(crate) fn random_bytes(random: &dyn SecureRandom, count: usize) -> Result> { if count == 0 { return Ok(Vec::new()); } diff --git a/src/dss/ss1/mod.rs b/src/dss/ss1/mod.rs index 18a4b06..781d723 100644 --- a/src/dss/ss1/mod.rs +++ b/src/dss/ss1/mod.rs @@ -21,7 +21,7 @@ //! //! - *New Directions in Secret Sharing* (TODO: Full reference) -use errors::*; +use crate::errors::*; mod serialize; @@ -32,7 +32,7 @@ mod scheme; pub use self::scheme::Reproducibility; use self::scheme::SS1; -use dss::AccessStructure; +use crate::dss::AccessStructure; /// Performs threshold k-out-of-n deterministic secret sharing. /// @@ -185,10 +185,8 @@ mod tests { let seed = vec![1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16u8]; let shares_1 = split_secret(7, 10, &secret, Reproducibility::seeded(seed.clone()), &None).unwrap(); - let shares_2 = - split_secret(7, 10, &secret, Reproducibility::seeded(seed.clone()), &None).unwrap(); + let shares_2 = split_secret(7, 10, &secret, Reproducibility::seeded(seed), &None).unwrap(); assert_eq!(shares_1, shares_2); } - } diff --git a/src/dss/ss1/scheme.rs b/src/dss/ss1/scheme.rs index 49c9e4e..2305a3e 100644 --- a/src/dss/ss1/scheme.rs +++ b/src/dss/ss1/scheme.rs @@ -1,18 +1,18 @@ use std::collections::HashSet; -use rand::{ChaChaRng, Rng, SeedableRng}; +use rand::{RngCore, SeedableRng}; +use rand_chacha::ChaCha20Rng; use ring::digest::{Context, SHA256}; use ring::rand::{SecureRandom, SystemRandom}; use ring::{hkdf, hmac}; use super::share::*; -use dss::random::{random_bytes_count, FixedRandom, MAX_MESSAGE_SIZE}; -use dss::thss::{MetaData, ThSS}; -use dss::utils; -use dss::{thss, AccessStructure}; -use errors::*; -use share::validation::{validate_share_count, validate_shares}; -use vol_hash::VOLHash; +use crate::dss::random::{random_bytes_count, FixedRandom, MAX_MESSAGE_SIZE}; +use crate::dss::thss::{MetaData, ThSS}; +use crate::dss::{thss, AccessStructure}; +use crate::errors::*; +use crate::share::validation::{validate_share_count, validate_shares}; +use crate::vol_hash::VOLHash; /// We bound the message size at about 16MB to avoid overflow in `random_bytes_count`. /// Moreover, given the current performances, it is almost unpractical to run @@ -175,7 +175,7 @@ impl SS1 { shares_count: share.shares_count, data: share.data, hash: hash.to_vec(), - metadata: share.metadata.clone(), + metadata: share.metadata, }) .collect(); @@ -198,14 +198,14 @@ impl SS1 { } Reproducibility::Reproducible => { let seed = self.generate_seed(DEFAULT_PRESEED, secret, metadata); - let mut rng = ChaChaRng::from_seed(&seed); + let mut rng = ChaCha20Rng::from_seed(seed); let mut result = vec![0u8; self.random_padding_len]; rng.fill_bytes(result.as_mut_slice()); Ok(result) } Reproducibility::Seeded(preseed) => { let seed = self.generate_seed(&preseed, secret, metadata); - let mut rng = ChaChaRng::from_seed(&seed); + let mut rng = ChaCha20Rng::from_seed(seed); let mut result = vec![0u8; self.random_padding_len]; rng.fill_bytes(result.as_mut_slice()); Ok(result) @@ -222,7 +222,7 @@ impl SS1 { preseed: &[u8], secret: &[u8], metadata: &Option, - ) -> Vec { + ) -> [u8; 32] { let mut ctx = Context::new(&SHA256); ctx.update(preseed); ctx.update(secret); @@ -232,14 +232,9 @@ impl SS1 { let preseed_hash = ctx.finish(); let salt = hmac::SigningKey::new(&SHA256, &[]); - let mut seed_bytes = vec![0u8; 32]; + let mut seed_bytes = [0u8; 32]; hkdf::extract_and_expand(&salt, preseed_hash.as_ref(), &[], &mut seed_bytes); - - // We can safely call `utils::slice_u8_to_slice_u32` because - // the `digest` produced with `SHA256` is 256 bits long, as is - // `seed_bytes`, and the latter can thus be represented both as a - // slice of 32 bytes or as a slice of 8 32-bit words. - utils::slice_u8_to_slice_u32(&seed_bytes).to_vec() + seed_bytes } /// Recover the secret from the given set of shares diff --git a/src/dss/ss1/serialize.rs b/src/dss/ss1/serialize.rs index 15b48d9..8e2e4ef 100644 --- a/src/dss/ss1/serialize.rs +++ b/src/dss/ss1/serialize.rs @@ -1,8 +1,8 @@ use super::{MetaData, Share}; -use dss::format::{format_share_protobuf, parse_share_protobuf}; -use dss::utils::{btreemap_to_hashmap, hashmap_to_btreemap}; -use errors::*; -use proto::dss::{MetaDataProto, ShareProto}; +use crate::dss::format::{format_share_protobuf, parse_share_protobuf}; +use crate::dss::utils::{btreemap_to_hashmap, hashmap_to_btreemap}; +use crate::errors::*; +use crate::proto::dss::{MetaDataProto, ShareProto}; pub(crate) fn share_to_string(share: Share) -> String { let proto = share_to_protobuf(share); diff --git a/src/dss/ss1/share.rs b/src/dss/ss1/share.rs index d1f6fcc..fcc27b8 100644 --- a/src/dss/ss1/share.rs +++ b/src/dss/ss1/share.rs @@ -1,8 +1,8 @@ use super::serialize::{share_from_string, share_to_string}; -use errors::*; -use share::IsShare; +use crate::errors::*; +use crate::share::IsShare; -pub use dss::metadata::MetaData; +pub use crate::dss::metadata::MetaData; /// A share identified by an `id`, a threshold `k`, a number of total shares `n`, /// the `data` held in the share, and the share's `metadata`. diff --git a/src/dss/thss/encode.rs b/src/dss/thss/encode.rs index 01fbc59..0b0efbe 100644 --- a/src/dss/thss/encode.rs +++ b/src/dss/thss/encode.rs @@ -1,5 +1,5 @@ -use gf256::Gf256; -use poly::Poly; +use crate::gf256::Gf256; +use crate::poly::Poly; /// Encode the given `secret` using the `ThSS[N].Share` algorithm described /// in the *New directions in Secret Sharing* paper. @@ -7,7 +7,7 @@ use poly::Poly; /// Reference: Figure 7 from the *New Directions in Secret Sharing* paper. pub(crate) fn encode_secret(secret: &[u8], k: u8, share_id: u8, rands: &[u8]) -> Vec { secret - .into_iter() + .iter() .enumerate() .map(|(i, m)| { let k_pred = (k - 1) as usize; diff --git a/src/dss/thss/mod.rs b/src/dss/thss/mod.rs index 4c3534b..b38ca92 100644 --- a/src/dss/thss/mod.rs +++ b/src/dss/thss/mod.rs @@ -12,7 +12,7 @@ //! **ErrDet** | Yes | An inauthentic set of shares produced by an adversary will be flagged as such when fed to the recovery algorithm. //! **Repro** | No | Share reproducible: The scheme can produce shares in a deterministic way. -use errors::*; +use crate::errors::*; mod encode; mod serialize; @@ -23,7 +23,7 @@ pub use self::share::*; mod scheme; pub(crate) use self::scheme::ThSS; -use dss::AccessStructure; +use crate::dss::AccessStructure; /// Performs threshold k-out-of-n secret sharing using the `ThSS` scheme. /// diff --git a/src/dss/thss/scheme.rs b/src/dss/thss/scheme.rs index e7d0d1e..c9210be 100644 --- a/src/dss/thss/scheme.rs +++ b/src/dss/thss/scheme.rs @@ -4,15 +4,15 @@ use std::fmt; use ring::rand::{SecureRandom, SystemRandom}; -use dss::random::{random_bytes, random_bytes_count, MAX_MESSAGE_SIZE}; -use errors::*; -use gf256::Gf256; -use lagrange; -use share::validation::{validate_share_count, validate_shares}; +use crate::dss::random::{random_bytes, random_bytes_count, MAX_MESSAGE_SIZE}; +use crate::errors::*; +use crate::gf256::Gf256; +use crate::lagrange; +use crate::share::validation::{validate_share_count, validate_shares}; -use super::AccessStructure; use super::encode::encode_secret; use super::share::*; +use super::AccessStructure; /// We bound the message size at about 16MB to avoid overflow in `random_bytes_count`. /// Moreover, given the current performances, it is almost unpractical to run @@ -23,7 +23,7 @@ const MAX_SECRET_SIZE: usize = MAX_MESSAGE_SIZE; #[allow(missing_debug_implementations)] pub(crate) struct ThSS { /// The randomness source - random: Box, + random: Box, } impl fmt::Debug for ThSS { @@ -40,7 +40,7 @@ impl Default for ThSS { impl ThSS { /// Constructs a new sharing scheme - pub fn new(random: Box) -> Self { + pub fn new(random: Box) -> Self { Self { random } } @@ -124,7 +124,7 @@ impl ThSS { .collect(); let access_structure = AccessStructure { - threshold: threshold, + threshold, shares_count: shares.first().unwrap().shares_count, }; diff --git a/src/dss/thss/serialize.rs b/src/dss/thss/serialize.rs index 1111f55..87bbc90 100644 --- a/src/dss/thss/serialize.rs +++ b/src/dss/thss/serialize.rs @@ -1,8 +1,8 @@ use super::{MetaData, Share}; -use dss::format::{format_share_protobuf, parse_share_protobuf}; -use dss::utils::{btreemap_to_hashmap, hashmap_to_btreemap}; -use errors::*; -use proto::dss::{MetaDataProto, ShareProto}; +use crate::dss::format::{format_share_protobuf, parse_share_protobuf}; +use crate::dss::utils::{btreemap_to_hashmap, hashmap_to_btreemap}; +use crate::errors::*; +use crate::proto::dss::{MetaDataProto, ShareProto}; pub(crate) fn share_to_string(share: Share) -> String { let proto = share_to_protobuf(share); diff --git a/src/dss/thss/share.rs b/src/dss/thss/share.rs index f68bf15..8cdab5d 100644 --- a/src/dss/thss/share.rs +++ b/src/dss/thss/share.rs @@ -1,8 +1,8 @@ use super::serialize::{share_from_string, share_to_string}; -use errors::*; -use share::IsShare; +use crate::errors::*; +use crate::share::IsShare; -pub use dss::metadata::MetaData; +pub use crate::dss::metadata::MetaData; /// A share identified by an `id`, a threshold `k`, a number of total shares `n`, /// the `data` held in the share, and the share's `metadata`. diff --git a/src/dss/utils.rs b/src/dss/utils.rs index 20a0fed..a7fe5be 100644 --- a/src/dss/utils.rs +++ b/src/dss/utils.rs @@ -1,18 +1,6 @@ -use std; - use std::collections::{BTreeMap, HashMap}; use std::hash::Hash; -/// Transmutes a `&[u8]` into a `&[u32]`. -/// Despite `std::mem::transmute` being very unsafe in -/// general, this should actually be safe as long as -/// `input` contains a multiple of 4 bytes. -#[allow(unsafe_code)] -pub(crate) fn slice_u8_to_slice_u32(input: &[u8]) -> &[u32] { - assert_eq!(input.len() % 4, 0); - unsafe { std::mem::transmute(input) } -} - /// Creates a `HashMap` from a `BTreeMap` pub(crate) fn btreemap_to_hashmap(btree: BTreeMap) -> HashMap { let mut hash = HashMap::new(); diff --git a/src/errors.rs b/src/errors.rs index 1fbe12b..fa08e5d 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,12 +1,12 @@ //! Define the various error kinds specific to deterministic secret sharing. -#![allow(unknown_lints, missing_docs)] +#![allow(unknown_lints, missing_docs, unused_doc_comments)] use std::collections::HashSet; use std::fmt; #[cfg(feature = "dss")] -use dss::ss1; +use crate::dss::ss1; /// Minimum allowed number of shares (n) pub(crate) static MIN_SHARES: u8 = 2; @@ -17,7 +17,7 @@ pub(crate) static MAX_SHARES: u8 = 255; /// SSS Shares should be structured as k-n-data hence 3 parts pub(crate) static SSS_SHARE_PARTS_COUNT: usize = 3; -/// Create the Error, ErrorKind, ResultExt, and Result types +// Create the Error, ErrorKind, ResultExt, and Result types error_chain! { errors { ThresholdTooBig(k: u8, n: u8) { @@ -126,7 +126,7 @@ error_chain! { InconsistentSecretLengths(id: u8, slen_: usize, ids: Vec, slen: usize) { description("The shares are incompatible with each other because they do not all have the same secret length.") - display("The share identifier {} had secret length {}, while the secret length {} was found for share identifier(s): {}.", id, slen_, slen, no_more_than_five(ids)) + display("The share identifier {} had secret length {}, while the secret length {} was found for share identifier(s): {}.", id, slen_, slen, no_more_than_five(&ids)) } InconsistentShares { @@ -148,8 +148,8 @@ error_chain! { } /// Takes a `Vec` and formats it like the normal `fmt::Debug` implementation, unless it has more -//than five elements, in which case the rest are replaced by ellipsis. -fn no_more_than_five(vec: &Vec) -> String { +/// than five elements, in which case the rest are replaced by ellipsis. +fn no_more_than_five(vec: &[T]) -> String { let len = vec.len(); if len > 5 { let mut string = String::from("["); diff --git a/src/gf256.rs b/src/gf256.rs index 49ad57e..fe68a5a 100644 --- a/src/gf256.rs +++ b/src/gf256.rs @@ -1,6 +1,8 @@ //! This module provides the Gf256 type which is used to represent //! elements of a finite field with 256 elements. +#![allow(clippy::misrefactored_assign_op)] + use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; include!(concat!(env!("OUT_DIR"), "/nothinghardcoded.rs")); @@ -46,6 +48,8 @@ impl Gf256 { Some(tabs.log[self.poly as usize]) } } + + #[allow(clippy::assign_op_pattern)] pub fn pow(&self, mut exp: u8) -> Gf256 { let mut base = *self; let mut acc = Self::one(); @@ -68,7 +72,9 @@ impl Gf256 { impl Add for Gf256 { type Output = Gf256; + #[inline] + #[allow(clippy::suspicious_arithmetic_impl)] fn add(self, rhs: Gf256) -> Gf256 { Gf256::from_byte(self.poly ^ rhs.poly) } @@ -83,7 +89,9 @@ impl AddAssign for Gf256 { impl Sub for Gf256 { type Output = Gf256; + #[inline] + #[allow(clippy::suspicious_arithmetic_impl)] fn sub(self, rhs: Gf256) -> Gf256 { Gf256::from_byte(self.poly ^ rhs.poly) } @@ -231,6 +239,7 @@ mod tests { (a + b) + c == a + (b + c) } + #[allow(clippy::eq_op)] fn law_commutativity(a: Gf256, b: Gf256) -> bool { a + b == b + a } @@ -257,6 +266,7 @@ mod tests { (a * b) * c == a * (b * c) } + #[allow(clippy::eq_op)] fn law_commutativity(a: Gf256, b: Gf256) -> bool { a * b == b * a } @@ -280,7 +290,5 @@ mod tests { TestResult::from_bool(left && right) } } - } - } diff --git a/src/lagrange.rs b/src/lagrange.rs index b49a91f..41367d2 100644 --- a/src/lagrange.rs +++ b/src/lagrange.rs @@ -1,5 +1,5 @@ -use gf256::Gf256; -use poly::Poly; +use crate::gf256::Gf256; +use crate::poly::Poly; /// Evaluates an interpolated polynomial at `Gf256::zero()` where /// the polynomial is determined using barycentric Lagrange @@ -27,7 +27,8 @@ fn barycentric_interpolate_at(k: usize, points: &[(u8, u8)]) -> u8 { let delta = x[j] - x[i]; assert_ne!(delta.poly, 0, "Duplicate shares"); w[j] /= delta; - w[i] -= w[j]; + let wj = w[j]; + w[i] -= wj; } } @@ -73,7 +74,8 @@ pub(crate) fn interpolate(points: &[(Gf256, Gf256)]) -> Poly { } } - poly = poly.iter() + poly = poly + .iter() .zip(coeffs.iter()) .map(|(&old_coeff, &add)| old_coeff + add / prod) .collect(); @@ -87,9 +89,8 @@ pub(crate) fn interpolate(points: &[(Gf256, Gf256)]) -> Poly { mod tests { use super::*; - use gf256::*; + use crate::gf256::*; use quickcheck::*; - use std; quickcheck! { @@ -137,5 +138,4 @@ mod tests { } } - } diff --git a/src/lib.rs b/src/lib.rs index 90d5c3c..95e555e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,19 @@ //! `RustySecrets` implements Shamir's secret sharing in Rust. It provides the possibility to sign shares. -#![deny(missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, - unused_qualifications)] -#![cfg_attr(feature = "cargo-clippy", allow(doc_markdown))] -// `error_chain!` can recurse deeply -#![recursion_limit = "1024"] +#![allow(renamed_and_removed_lints)] +#![deny( + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, + unused_qualifications +)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::doc_markdown))] +#![recursion_limit = "1024"] // `error_chain!` can recurse deeply #[macro_use] extern crate error_chain; @@ -38,5 +46,4 @@ extern crate itertools; extern crate flate2; #[cfg(test)] -#[macro_use] extern crate quickcheck; diff --git a/src/poly.rs b/src/poly.rs index aaee0b5..fde76d4 100644 --- a/src/poly.rs +++ b/src/poly.rs @@ -1,4 +1,4 @@ -use gf256::Gf256; +use crate::gf256::Gf256; static MAX_COEFFS: usize = 256; diff --git a/src/proto/dss/metadata.rs b/src/proto/dss/metadata.rs index 0b27f5d..e43138a 100644 --- a/src/proto/dss/metadata.rs +++ b/src/proto/dss/metadata.rs @@ -3,7 +3,7 @@ // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] @@ -161,13 +161,13 @@ impl ::protobuf::Message for MetaDataProto { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: Box) -> ::std::boxed::Box { self } diff --git a/src/proto/dss/secret.rs b/src/proto/dss/secret.rs index 7b7a4c0..43473f1 100644 --- a/src/proto/dss/secret.rs +++ b/src/proto/dss/secret.rs @@ -3,7 +3,7 @@ // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] @@ -257,13 +257,13 @@ impl ::protobuf::Message for SecretProto { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: Box) -> ::std::boxed::Box { self } diff --git a/src/proto/dss/share.rs b/src/proto/dss/share.rs index 4eb8e40..a8b8315 100644 --- a/src/proto/dss/share.rs +++ b/src/proto/dss/share.rs @@ -3,7 +3,7 @@ // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] @@ -349,13 +349,13 @@ impl ::protobuf::Message for ShareProto { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: Box) -> ::std::boxed::Box { self } diff --git a/src/proto/version.rs b/src/proto/version.rs index 9680b35..d85af26 100644 --- a/src/proto/version.rs +++ b/src/proto/version.rs @@ -3,7 +3,7 @@ // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] diff --git a/src/proto/wrapped/secret.rs b/src/proto/wrapped/secret.rs index 3906856..96cb6e0 100644 --- a/src/proto/wrapped/secret.rs +++ b/src/proto/wrapped/secret.rs @@ -3,7 +3,7 @@ // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] @@ -216,13 +216,13 @@ impl ::protobuf::Message for SecretProto { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: Box) -> ::std::boxed::Box { self } diff --git a/src/proto/wrapped/share.rs b/src/proto/wrapped/share.rs index 3bbdbb6..6661264 100644 --- a/src/proto/wrapped/share.rs +++ b/src/proto/wrapped/share.rs @@ -3,7 +3,7 @@ // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] @@ -222,13 +222,13 @@ impl ::protobuf::Message for ShareProto { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: Box) -> ::std::boxed::Box { self } diff --git a/src/share/mod.rs b/src/share/mod.rs index beb1c5c..e709883 100644 --- a/src/share/mod.rs +++ b/src/share/mod.rs @@ -3,7 +3,7 @@ //! These traits are currently not exposed, but this might //! change in the future. -use errors::*; +use crate::errors::*; pub(crate) mod validation; diff --git a/src/share/validation.rs b/src/share/validation.rs index 1b894cf..c5dbe5d 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -1,5 +1,5 @@ -use errors::*; -use share::{IsShare, IsSignedShare}; +use crate::errors::*; +use crate::share::{IsShare, IsSignedShare}; // The order of validation that we think makes the most sense is the following: // 1) Validate shares individually @@ -9,7 +9,7 @@ use share::{IsShare, IsSignedShare}; /// TODO: Doc pub(crate) fn validate_signed_shares( - shares: &Vec, + shares: &[S], verify_signatures: bool, ) -> Result<(u8, usize)> { let result = validate_shares(shares)?; @@ -22,7 +22,7 @@ pub(crate) fn validate_signed_shares( } /// TODO: Doc -pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize)> { +pub(crate) fn validate_shares(shares: &[S]) -> Result<(u8, usize)> { if shares.is_empty() { bail!(ErrorKind::EmptyShares); } @@ -57,10 +57,7 @@ pub(crate) fn validate_shares(shares: &Vec) -> Result<(u8, usize) threshold = threshold_; } else if threshold_ != threshold { bail!(ErrorKind::InconsistentThresholds( - id, - threshold_, - ids, - threshold + id, threshold_, ids, threshold )) } diff --git a/src/sss/encode.rs b/src/sss/encode.rs index abfe549..fc363c5 100644 --- a/src/sss/encode.rs +++ b/src/sss/encode.rs @@ -1,4 +1,4 @@ -use gf256::Gf256; +use crate::gf256::Gf256; use std::io; use std::io::prelude::*; diff --git a/src/sss/format.rs b/src/sss/format.rs index e6cb2a7..9f2523b 100644 --- a/src/sss/format.rs +++ b/src/sss/format.rs @@ -1,10 +1,9 @@ -use base64; -use errors::*; +use crate::errors::*; +use crate::proto::wrapped::ShareProto; +use crate::sss::{Share, HASH_ALGO}; + use merkle_sigs::{MerklePublicKey, Proof, PublicKey}; -use proto::wrapped::ShareProto; use protobuf::{self, Message, RepeatedField}; -use sss::{Share, HASH_ALGO}; -use std::error::Error; const BASE64_CONFIG: base64::Config = base64::STANDARD_NO_PAD; @@ -17,8 +16,7 @@ pub(crate) fn share_to_string( let mut share_protobuf = ShareProto::new(); share_protobuf.set_shamir_data(share); - if signature_pair.is_some() { - let (signature, proof) = signature_pair.unwrap(); + if let Some((signature, proof)) = signature_pair { share_protobuf.set_signature(RepeatedField::from_vec(signature)); share_protobuf.set_proof(proof.write_to_bytes().unwrap()); } @@ -65,7 +63,7 @@ pub(crate) fn share_from_string(s: &str, is_signed: bool) -> Result { protobuf::parse_from_bytes::(raw_data.as_slice()).map_err(|e| { ErrorKind::ShareParsingError(format!( "Protobuf decoding of data block failed with error: {} .", - e.description() + e )) })?; diff --git a/src/sss/mod.rs b/src/sss/mod.rs index 1cb8f3a..6c8fdfe 100644 --- a/src/sss/mod.rs +++ b/src/sss/mod.rs @@ -1,6 +1,6 @@ //! SSS provides Shamir's secret sharing with raw data. -use errors::*; +use crate::errors::*; mod share; pub(crate) use self::share::*; @@ -13,13 +13,14 @@ pub(crate) use self::scheme::*; mod encode; -use rand::{OsRng, Rng}; +use rand::{rngs::OsRng, Rng}; use ring::digest::{Algorithm, SHA512}; -static HASH_ALGO: &'static Algorithm = &SHA512; + +static HASH_ALGO: &Algorithm = &SHA512; /// Performs threshold k-out-of-n Shamir's secret sharing. /// -/// Uses a `rand::OsRng` as a source of entropy. +/// Uses a `rand::rngs::OsRng` as a source of entropy. /// /// # Examples /// @@ -40,7 +41,7 @@ static HASH_ALGO: &'static Algorithm = &SHA512; /// ``` pub fn split_secret(k: u8, n: u8, secret: &[u8], sign_shares: bool) -> Result> { SSS::default() - .split_secret(&mut OsRng::new()?, k, n, secret, sign_shares) + .split_secret(&mut OsRng, k, n, secret, sign_shares) .map(|shares| shares.into_iter().map(Share::into_string).collect()) } @@ -50,14 +51,14 @@ pub fn split_secret(k: u8, n: u8, secret: &[u8], sign_shares: bool) -> Result ChaChaRng { -/// # let mut rng = ChaChaRng::new_unseeded(); -/// # rng.set_counter(42, 42); -/// # rng +/// # let seed = [42u8; 32]; +/// # ChaChaRng::from_seed(seed) /// # } /// # /// # fn main() { diff --git a/src/sss/scheme.rs b/src/sss/scheme.rs index 3cbc8e6..abd20dc 100644 --- a/src/sss/scheme.rs +++ b/src/sss/scheme.rs @@ -3,11 +3,11 @@ use merkle_sigs::sign_data_vec; use rand::Rng; -use errors::*; -use lagrange::interpolate_at; -use share::validation::{validate_share_count, validate_signed_shares}; -use sss::format::format_share_for_signing; -use sss::{Share, HASH_ALGO}; +use crate::errors::*; +use crate::lagrange::interpolate_at; +use crate::share::validation::{validate_share_count, validate_signed_shares}; +use crate::sss::format::format_share_for_signing; +use crate::sss::{Share, HASH_ALGO}; use super::encode::encode_secret_byte; diff --git a/src/sss/share.rs b/src/sss/share.rs index e3ff1ca..f9d8f9c 100644 --- a/src/sss/share.rs +++ b/src/sss/share.rs @@ -1,12 +1,11 @@ use std::collections::{HashMap, HashSet}; -use std::error::Error; use merkle_sigs::verify_data_vec_signature; use merkle_sigs::{MerklePublicKey, Proof}; -use errors::*; -use share::{IsShare, IsSignedShare}; -use sss::format::{format_share_for_signing, share_from_string, share_to_string}; +use crate::errors::*; +use crate::share::{IsShare, IsSignedShare}; +use crate::sss::format::{format_share_for_signing, share_from_string, share_to_string}; /// A share identified by an `id`, a threshold `k`, a number of total shares `n`, /// the `data` held in the share, and the share's `metadata`. @@ -35,7 +34,7 @@ impl Share { /// Attempts to parse all the given strings into shares. /// Calls out to `Share::from_string`. pub(crate) fn parse_all(raws: &[String], is_signed: bool) -> Result> { - raws.into_iter() + raws.iter() .map(|raw| Self::from_string(raw, is_signed)) .collect() } @@ -104,7 +103,8 @@ impl IsSignedShare for Share { format_share_for_signing(share.threshold, share.id, share.data.as_slice()), &(signature.to_vec(), proof.clone()), root_hash, - ).map_err(|e| ErrorKind::InvalidSignature(share.id, String::from(e.description())))?; + ) + .map_err(|e| ErrorKind::InvalidSignature(share.id, e.to_string()))?; rh_compatibility_sets .entry(root_hash) diff --git a/src/vol_hash.rs b/src/vol_hash.rs index 1db0310..976cb5a 100644 --- a/src/vol_hash.rs +++ b/src/vol_hash.rs @@ -1,4 +1,3 @@ -use std; use std::mem::transmute; use ring::digest::{Algorithm, Context}; diff --git a/src/wrapped_secrets/mod.rs b/src/wrapped_secrets/mod.rs index 5be7e08..3098c84 100644 --- a/src/wrapped_secrets/mod.rs +++ b/src/wrapped_secrets/mod.rs @@ -1,16 +1,16 @@ //! (Beta) `wrapped_secrets` provides Shamir's secret sharing with a wrapped secret. It currently offers versioning and MIME information about the data. -use errors::*; -use proto::wrapped::SecretProto; +use crate::errors::*; +use crate::proto::wrapped::SecretProto; -use rand::{OsRng, Rng}; +use rand::{rngs::OsRng, Rng}; mod scheme; pub(crate) use self::scheme::*; /// Performs threshold k-out-of-n Shamir's secret sharing. /// -/// Uses an `OsRng` as a source of entropy. +/// Uses a `rand::rngs::OsRng` as a source of entropy. /// /// # Examples /// @@ -45,7 +45,7 @@ pub fn split_secret( sign_shares: bool, ) -> Result> { WrappedSecrets::default() - .split_secret(&mut OsRng::new()?, k, n, secret, mime_type, sign_shares) + .split_secret(&mut OsRng, k, n, secret, mime_type, sign_shares) .map(|shares| shares.into_iter().map(Share::into_string).collect()) } @@ -55,17 +55,21 @@ pub fn split_secret( /// /// ``` /// # extern crate rusty_secrets; -/// # extern crate rand; +/// # extern crate rand_chacha; /// # /// # fn main() { /// use rusty_secrets::wrapped_secrets::split_secret_rng; -/// use rand::ChaChaRng; +/// use rand_chacha::ChaChaRng; +/// use rand_chacha::rand_core::SeedableRng; +/// +/// let seed = [42u8; 32]; // REPLACE WITH PROPER SEED +/// let mut rng = ChaChaRng::from_seed(seed); /// /// let secret = "These programs were never about terrorism: they’re about economic spying, \ /// social control, and diplomatic manipulation. They’re about power."; /// /// let result = split_secret_rng( -/// &mut ChaChaRng::new_unseeded(), +/// &mut rng, /// 7, /// 10, /// &secret.as_bytes(), diff --git a/src/wrapped_secrets/scheme.rs b/src/wrapped_secrets/scheme.rs index a704e39..7cfb0b0 100644 --- a/src/wrapped_secrets/scheme.rs +++ b/src/wrapped_secrets/scheme.rs @@ -1,12 +1,12 @@ -use errors::*; -use proto::VersionProto; -use proto::wrapped::SecretProto; -use protobuf; +use crate::errors::*; +use crate::proto::wrapped::SecretProto; +use crate::proto::VersionProto; +use crate::sss::SSS; + use protobuf::Message; use rand::Rng; -use sss::SSS; -pub(crate) use sss::Share; +pub(crate) use crate::sss::Share; #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)] pub(crate) struct WrappedSecrets; diff --git a/tests/recovery_errors.rs b/tests/recovery_errors.rs index 0e1e8f5..34a3be4 100644 --- a/tests/recovery_errors.rs +++ b/tests/recovery_errors.rs @@ -121,16 +121,15 @@ fn test_recover_too_few_shares_bug() { let mut share_1 = shares[0].clone().into_bytes(); let mut share_2 = shares[3].clone().into_bytes(); - share_1[0] = '2' as u8; - share_2[0] = '2' as u8; + share_1[0] = b'2'; + share_2[0] = b'2'; let sub_shares = vec![ String::from_utf8_lossy(&share_1).into_owned(), String::from_utf8_lossy(&share_2).into_owned(), ]; - match recover_secret(&sub_shares, false) { - Err(_) => assert!(true), - Ok(recovered) => assert_ne!(original, recovered), + if let Ok(recovered) = recover_secret(&sub_shares, false) { + assert_ne!(original, recovered); } } diff --git a/tests/ss1_recovery_errors.rs b/tests/ss1_recovery_errors.rs index 1ad4d11..44eb5fa 100644 --- a/tests/ss1_recovery_errors.rs +++ b/tests/ss1_recovery_errors.rs @@ -17,7 +17,8 @@ fn get_test_hash() -> Vec { TEST_SECRET, TEST_REPRODUCIBILITY, &None, - ).unwrap(); + ) + .unwrap(); good_shares[0].hash.clone() } @@ -47,7 +48,7 @@ fn test_recover_2_parts_share() { threshold: TEST_THRESHOLD, shares_count: TEST_SHARES_COUNT, data: "".to_string().into_bytes(), - hash: hash.clone(), + hash, metadata: None, }; @@ -74,7 +75,7 @@ fn test_recover_0_share_num() { threshold: TEST_THRESHOLD, shares_count: TEST_SHARES_COUNT, data: "YJZQDGm22Y77Gw".to_string().into_bytes(), - hash: hash.clone(), + hash, metadata: None, }; @@ -126,7 +127,7 @@ fn test_recover_duplicate_shares_number() { threshold: TEST_THRESHOLD, shares_count: TEST_SHARES_COUNT, data: "YJZQDGm22Y77Gw".to_string().into_bytes(), - hash: hash.clone(), + hash, metadata: None, }; @@ -152,7 +153,7 @@ fn test_recover_too_few_shares() { threshold: TEST_THRESHOLD + 1, shares_count: TEST_SHARES_COUNT + 1, data: "YJZQDGm22Y77Gw".to_string().into_bytes(), - hash: hash.clone(), + hash, metadata: None, };