diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ee207a4..f420e10e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -189,6 +189,19 @@ jobs: - uses: actions/checkout@v6 - uses: ./.github/workflows/formatting/rust + #### DEPENDENCY AUDIT #### + cargo_deny: + runs-on: "ubuntu-22.04" + + steps: + - uses: actions/checkout@v6 + + - name: Install cargo-deny + run: cargo install cargo-deny --locked + + - name: Check dependencies + run: cargo deny check + #### FUZZ TESTING #### quick_fuzz: runs-on: "ubuntu-22.04" diff --git a/.github/workflows/formatting/rust/action.yml b/.github/workflows/formatting/rust/action.yml index 66290dac..15ee3319 100644 --- a/.github/workflows/formatting/rust/action.yml +++ b/.github/workflows/formatting/rust/action.yml @@ -20,4 +20,4 @@ runs: - name: Check Clippy working-directory: ./ shell: bash - run: cargo clippy -- --D warnings + run: cargo clippy --workspace --all-targets -- -D warnings diff --git a/Cargo.lock b/Cargo.lock index 777696ad..30d9bb0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,9 +81,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" [[package]] name = "arbitrary" @@ -111,20 +111,20 @@ checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" dependencies = [ "zeroize", ] [[package]] name = "askama" -version = "0.14.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4" +checksum = "f1bf825125edd887a019d0a3a837dcc5499a68b0d034cc3eb594070c3e18addc" dependencies = [ - "askama_derive", + "askama_macros", "itoa", "percent-encoding", "serde", @@ -133,31 +133,42 @@ dependencies = [ [[package]] name = "askama_derive" -version = "0.14.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f" +checksum = "e1c7065972a130eafa84215f21352ae15b4a7393da48c1f5e103904490736738" dependencies = [ "askama_parser", "basic-toml", + "glob", "memchr", "proc-macro2", "quote", "rustc-hash", "serde", "serde_derive", - "syn 2.0.117", + "syn 2.0.118", +] + +[[package]] +name = "askama_macros" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e23b1d2c4bd39a41971f6124cef4cc6fd0540913ecb90919b69ab3bbe44ae1a" +dependencies = [ + "askama_derive", ] [[package]] name = "askama_parser" -version = "0.14.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358" +checksum = "7db09fde9143e7ac4513358fb32ee32847125b63b18ea715afd487956da715da" dependencies = [ - "memchr", + "rustc-hash", "serde", "serde_derive", - "winnow 0.7.15", + "unicode-ident", + "winnow 1.0.3", ] [[package]] @@ -168,7 +179,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -177,12 +188,6 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" -[[package]] -name = "base64" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" - [[package]] name = "base64" version = "0.22.1" @@ -206,9 +211,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "2.11.1" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" [[package]] name = "blahaj" @@ -258,9 +263,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be" +checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" dependencies = [ "hybrid-array", ] @@ -288,33 +293,34 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.11.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +checksum = "8ae3f5d315924270530207e2a68396c3cc547f6dca3fbdca317cfb1a51edb593" [[package]] name = "camino" -version = "1.2.2" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e629a66d692cb9ff1a1c664e41771b3dcaf961985a9774c0eb0bd1b51cf60a48" +checksum = "5f2d30e4173c4026932d51d31d6b0613b1fd3014bf3f9f8943d4ba139c437ba0" dependencies = [ "serde_core", ] [[package]] name = "cargo-platform" -version = "0.1.9" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +checksum = "dd0061da739915fae12ea00e16397555ed4371a6bb285431aab930f61b0aa4ba" dependencies = [ "serde", + "serde_core", ] [[package]] name = "cargo_metadata" -version = "0.19.2" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" +checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9" dependencies = [ "camino", "cargo-platform", @@ -341,9 +347,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.63" +version = "1.2.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556e016178bb5662a08681bbe0f00f8e17631781a4dfc8c45e466e4b185ec27f" +checksum = "e228eec9be7c17ccb640b59b36a5cd805ea2a564a4c5e162c2f659fea30d3b96" dependencies = [ "find-msvc-tools", "jobserver", @@ -370,9 +376,9 @@ dependencies = [ [[package]] name = "chacha20" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" +checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" dependencies = [ "cfg-if", "cpufeatures 0.3.0", @@ -409,7 +415,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" dependencies = [ - "block-buffer 0.12.0", + "block-buffer 0.12.1", "crypto-common 0.2.2", "inout 0.2.2", ] @@ -445,7 +451,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -561,7 +567,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -593,7 +599,7 @@ checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -603,7 +609,7 @@ dependencies = [ "aead", "aes", "arbitrary 1.4.2", - "base64 0.22.1", + "base64", "blahaj", "blake3", "byteorder", @@ -613,13 +619,13 @@ dependencies = [ "dyn-clone", "ed25519-dalek", "getrandom 0.2.17", - "getrandom 0.4.2", + "getrandom 0.4.3", "hmac", "js-sys", "num_enum", "paste", "pbkdf2", - "rand 0.10.1", + "rand 0.10.2", "rand 0.8.6", "rust-argon2", "scrypt", @@ -639,7 +645,6 @@ dependencies = [ name = "devolutions-crypto-cli" version = "0.10.1" dependencies = [ - "base64 0.11.0", "clap", "devolutions-crypto", ] @@ -648,7 +653,7 @@ dependencies = [ name = "devolutions-crypto-ffi" version = "0.10.1" dependencies = [ - "base64 0.22.1", + "base64", "devolutions-crypto", "zeroize", ] @@ -694,7 +699,7 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ - "block-buffer 0.12.0", + "block-buffer 0.12.1", "const-oid 0.10.2", "crypto-common 0.2.2", "ctutils", @@ -773,9 +778,9 @@ checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] name = "fs-err" -version = "2.11.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +checksum = "73fde052dbfc920003cfd2c8e2c6e6d4cc7c1091538c3a24226cec0665ab08c0" dependencies = [ "autocfg", ] @@ -841,17 +846,15 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", "js-sys", "libc", "r-efi 6.0.0", "rand_core 0.10.1", - "wasip2", - "wasip3", "wasm-bindgen", ] @@ -906,19 +909,13 @@ dependencies = [ [[package]] name = "hybrid-array" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9155a582abd142abc056962c29e3ce5ff2ad5469f4246b537ed42c5deba857da" +checksum = "818356c5132c1fede50f837ca96afbe78ff42413047f4abb886217845e1b6c8c" dependencies = [ "typenum", ] -[[package]] -name = "id-arena" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" - [[package]] name = "indexmap" version = "2.14.0" @@ -974,22 +971,15 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.99" +version = "0.3.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142bc4740e452c1e57ade0cbc129f139c9093e354346f0872ef985f4f5cf5f11" +checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102" dependencies = [ "cfg-if", "futures-util", - "once_cell", "wasm-bindgen", ] -[[package]] -name = "leb128fmt" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" - [[package]] name = "libc" version = "0.2.186" @@ -998,9 +988,9 @@ checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" [[package]] name = "libfuzzer-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12a681b7dd8ce12bff52488013ba614b869148d54dd79836ab85aafdd53f08d" +checksum = "a9fd2f41a1cba099f79a0b6b6c35656cf7c03351a7bae8ff0f28f25270f929d2" dependencies = [ "arbitrary 1.4.2", "cc", @@ -1020,15 +1010,15 @@ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "log" -version = "0.4.30" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616ec5685824bcc94416c6d4a7a446eea774a31efd7062c8480ba6fd06d7a6e5" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" [[package]] name = "memchr" -version = "2.8.1" +version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8" +checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4" [[package]] name = "minicov" @@ -1094,7 +1084,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1185,16 +1175,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn 2.0.117", -] - [[package]] name = "proc-macro-crate" version = "3.5.0" @@ -1215,9 +1195,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.45" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" dependencies = [ "proc-macro2", ] @@ -1247,12 +1227,12 @@ dependencies = [ [[package]] name = "rand" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" dependencies = [ - "chacha20 0.10.0", - "getrandom 0.4.2", + "chacha20 0.10.1", + "getrandom 0.4.3", "rand_core 0.10.1", ] @@ -1287,16 +1267,16 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ae76b7506744d254fd0eb2c0ff5c5d108201ccbb083111ac04a44eeda105680" dependencies = [ - "base64 0.22.1", + "base64", "blake2b_simd", "constant_time_eq", ] [[package]] name = "rustc-hash" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" [[package]] name = "rustc_version" @@ -1362,7 +1342,7 @@ checksum = "1783eabc414609e28a5ba76aee5ddd52199f7107a0b24c2e9746a1ecc34a683d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1425,7 +1405,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1501,9 +1481,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smawk" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" +checksum = "e8e2fb0f499abb4d162f2bedad68f5ef91a1682b5a03596ddb67efd37768d100" [[package]] name = "spki" @@ -1545,7 +1525,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1567,9 +1547,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.117" +version = "2.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" dependencies = [ "proc-macro2", "quote", @@ -1583,7 +1563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.4.2", + "getrandom 0.4.3", "once_cell", "rustix", "windows-sys", @@ -1615,7 +1595,7 @@ checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1695,7 +1675,7 @@ checksum = "076a02dc54dd46795c2e9c8282ed40bcfb1e22747e955de9389a1de28190fb26" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1710,17 +1690,11 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - [[package]] name = "uniffi" -version = "0.31.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc5f2297ee5b893405bed1a6929faec4713a061df158ecf5198089f23910d470" +checksum = "a782a48d72cfd7a2d65cfc7c691dbf5375c43104b3c195f7eccc716dcc3540c8" dependencies = [ "anyhow", "camino", @@ -1741,9 +1715,9 @@ dependencies = [ [[package]] name = "uniffi_bindgen" -version = "0.31.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bc0c60a9607e7ab77a2ad47ec5530178015014839db25af7512447d2238016c" +checksum = "533b0312c73e3b54eb78a4b257ceae390962dd4767995778309a74644643f9ac" dependencies = [ "anyhow", "askama", @@ -1767,9 +1741,9 @@ dependencies = [ [[package]] name = "uniffi_core" -version = "0.31.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77baf5d539fe2e1ad6805e942dbc5dbdeb2b83eb5f2b3a6535d422ca4b02a12f" +checksum = "8e32e261c5b0dfaba6488f536e71957dddd6b1a498ac7eb791bee56b60a086be" dependencies = [ "anyhow", "bytes", @@ -1779,22 +1753,22 @@ dependencies = [ [[package]] name = "uniffi_internal_macros" -version = "0.31.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b42137524f4be6400fcaca9d02c1d4ecb6ad917e4013c0b93235526d8396e5" +checksum = "84ae78069a5e6772ef694fd5bdb628532c88d2c2f0e7142bf6a384636eadb1af" dependencies = [ "anyhow", "indexmap", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "uniffi_macros" -version = "0.31.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9273ec45330d8fe9a3701b7b983cea7a4e218503359831967cb95d26b873561" +checksum = "330be6770532e86320df31f54c70bb0be67588594e8e77fa56e9083a3fed5d0d" dependencies = [ "camino", "fs-err", @@ -1802,16 +1776,16 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.117", + "syn 2.0.118", "toml", "uniffi_meta", ] [[package]] name = "uniffi_meta" -version = "0.31.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "431d2f443e7828a6c29d188de98b6771a6491ee98bba2d4372643bf93f988a18" +checksum = "78de021f5547e56ab16c665a49d67d4fd3d31e77422f7739a2e9359d328cd9e7" dependencies = [ "anyhow", "siphasher", @@ -1821,9 +1795,9 @@ dependencies = [ [[package]] name = "uniffi_pipeline" -version = "0.31.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "761ef74f6175e15603d0424cc5f98854c5baccfe7bf4ccb08e5816f9ab8af689" +checksum = "3f8201bb1907ed8a42d80e11cbc25c8a033e7a31c3cff1d911f56eedb81d4948" dependencies = [ "anyhow", "heck", @@ -1834,9 +1808,9 @@ dependencies = [ [[package]] name = "uniffi_udl" -version = "0.31.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68773ec0e1c067b6505a73bbf6a5782f31a7f9209333a0df97b87565c46bf370" +checksum = "a6e57996bc58009cc29bf04845d627ae313c2547b87171c1c349d6c51a1656c0" dependencies = [ "anyhow", "textwrap", @@ -1884,27 +1858,18 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasip2" -version = "1.0.3+wasi-0.2.9" +version = "1.0.4+wasi-0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" dependencies = [ - "wit-bindgen 0.57.1", -] - -[[package]] -name = "wasip3" -version = "0.4.0+wasi-0.3.0-rc-2026-01-06" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" -dependencies = [ - "wit-bindgen 0.51.0", + "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.122" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed04576f974d2b2fba0f38c51dbc5518011e38c36bf1143164be765528fd409" +checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4" dependencies = [ "cfg-if", "once_cell", @@ -1915,9 +1880,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.72" +version = "0.4.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9473dbd2991ae90b6291c3c32c30c6187ac49aa32f9905d1cce280ec1e110b0f" +checksum = "c62df1340f32221cb9c54d6a27b030e3dba64361d4a95bed55f9aacb44da291d" dependencies = [ "js-sys", "wasm-bindgen", @@ -1925,9 +1890,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.122" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "916151b09da36bd82f6615cbf3a419e2f0ba23a03c6160e8e92eb6bd4aa1dec6" +checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1935,31 +1900,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.122" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "299047362ccbfce148b67ab7e73349f77748e00c8296f9542adfad2ad82c5c5e" +checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.122" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a929b2c61f11ba3e9bc35b50c1f25cb38e0e892c0c231ae2b8cf78d5dad4437" +checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-bindgen-test" -version = "0.3.72" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74fde991ccdc895cb7fbaa14b137d62af74d9011be67b71c694bfc40edd3119c" +checksum = "2a0d555ca874445df8d314f94f5c948a4e74e5418f332c89f660a3d8310a96f4" dependencies = [ "async-trait", "cast", @@ -1979,54 +1944,20 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.72" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e925354648d2a4d1bf205412e36d520a800280622eef4719678d268e5d40e978" +checksum = "94eb68555b95bcea5e8cf4abe280b529049479fa995bfc23734af96a6aedc120" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "wasm-bindgen-test-shared" -version = "0.2.122" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "684365b586a9a6256c1cc3544eee8680de48d6041142f581776ec7b139622ae9" - -[[package]] -name = "wasm-encoder" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" -dependencies = [ - "leb128fmt", - "wasmparser", -] - -[[package]] -name = "wasm-metadata" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" -dependencies = [ - "anyhow", - "indexmap", - "wasm-encoder", - "wasmparser", -] - -[[package]] -name = "wasmparser" -version = "0.244.0" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" -dependencies = [ - "bitflags", - "hashbrown 0.15.5", - "indexmap", - "semver", -] +checksum = "c31d56021e873866c968588ed85ccdf56db5c426e44afdb4618c39895104b920" [[package]] name = "weedle2" @@ -2066,9 +1997,6 @@ name = "winnow" version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" -dependencies = [ - "memchr", -] [[package]] name = "winnow" @@ -2079,100 +2007,12 @@ dependencies = [ "memchr", ] -[[package]] -name = "wit-bindgen" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" -dependencies = [ - "wit-bindgen-rust-macro", -] - [[package]] name = "wit-bindgen" version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" -[[package]] -name = "wit-bindgen-core" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" -dependencies = [ - "anyhow", - "heck", - "wit-parser", -] - -[[package]] -name = "wit-bindgen-rust" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" -dependencies = [ - "anyhow", - "heck", - "indexmap", - "prettyplease", - "syn 2.0.117", - "wasm-metadata", - "wit-bindgen-core", - "wit-component", -] - -[[package]] -name = "wit-bindgen-rust-macro" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" -dependencies = [ - "anyhow", - "prettyplease", - "proc-macro2", - "quote", - "syn 2.0.117", - "wit-bindgen-core", - "wit-bindgen-rust", -] - -[[package]] -name = "wit-component" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" -dependencies = [ - "anyhow", - "bitflags", - "indexmap", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-encoder", - "wasm-metadata", - "wasmparser", - "wit-parser", -] - -[[package]] -name = "wit-parser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" -dependencies = [ - "anyhow", - "id-arena", - "indexmap", - "log", - "semver", - "serde", - "serde_derive", - "serde_json", - "unicode-xid", - "wasmparser", -] - [[package]] name = "x25519-dalek" version = "2.0.1" @@ -2187,42 +2027,42 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.50" +version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b065d4f0e55f82fae73202e189638116a87c55ab6b8e6c2721e13dd9d854ad1" +checksum = "ce1022995ff5ff5d841ad7d994facc23098cd40152f2c1d11cd607c6f530653f" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.50" +version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b631b19d36a892ab55420c92dbc83ccd79274f25be714855d3074aa71cab639" +checksum = "1ae7f38b72ec2a254e2b87ef277cf2cd4fb97cbebf944faa6f33354da0867930" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "zeroize" -version = "1.8.2" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85a5b4158499876c763cb03bc4e49185d3cccbabb15b33c627f7884f43db852e" +checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index cb7ec070..15ed3a12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ default-members = [ ] [workspace.dependencies] -uniffi = "0.31.1" +uniffi = "0.32.0" rust-argon2 = { version = "3.0", default-features = false } [package] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 10121639..0f105c5c 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -9,4 +9,3 @@ edition = "2018" [dependencies] devolutions-crypto = {path = ".."} clap = { version = "4", features = ["derive"] } -base64 = "0.11.0" diff --git a/cli/src/main.rs b/cli/src/main.rs index 28feaa08..06e97161 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,4 +1,5 @@ use clap::{Parser, Subcommand}; +use devolutions_crypto::utils::{base64_decode, base64_encode}; use devolutions_crypto::DEFAULT_PBKDF2_ITERATIONS; use std::{borrow::Borrow, convert::TryFrom}; @@ -238,7 +239,7 @@ fn generate_key() { use devolutions_crypto::key::{generate_secret_key, KeyVersion}; let key: Vec = generate_secret_key(KeyVersion::Latest).into(); - println!("{}", base64::encode(&key)); + println!("{}", base64_encode(&key)); } fn generate_argon2parameters( @@ -266,7 +267,7 @@ fn generate_argon2parameters( }; let parameters: Vec = parameters.borrow().into(); - println!("{}", base64::encode(¶meters)); + println!("{}", base64_encode(¶meters)); } fn derive_key(data: String, salt: Option, iterations: Option) { @@ -286,8 +287,8 @@ fn derive_key(data: String, salt: Option, iterations: Option) { let params_bytes: Vec = params.into(); let key_bytes: Vec = secret_key.into(); - println!("Key: {}", base64::encode(&key_bytes)); - println!("DerivationParameters: {}", base64::encode(¶ms_bytes)); + println!("Key: {}", base64_encode(&key_bytes)); + println!("DerivationParameters: {}", base64_encode(¶ms_bytes)); } fn derive_and_encrypt_password(data: String, password: String, version: Option) { @@ -302,7 +303,7 @@ fn derive_and_encrypt_password(data: String, password: String, version: Option String { } fn decode_base64_arg(arg_name: &str, value: &str) -> Vec { - base64::decode(value).unwrap_or_else(|_| { + base64_decode(value).unwrap_or_else(|_| { eprintln!("Error: '{}' is not valid base64.", arg_name); std::process::exit(1); }) @@ -383,7 +384,7 @@ fn encrypt(data: String, key: String, version: Option) { let data: Vec = encrypt_with_secret_key(data.as_bytes(), &key, version) .unwrap() .into(); - println!("{}", base64::encode(&data)); + println!("{}", base64_encode(&data)); } fn encrypt_asymmetric(data: String, key: String, version: Option) { @@ -405,7 +406,7 @@ fn encrypt_asymmetric(data: String, key: String, version: Option) { devolutions_crypto::ciphertext::encrypt_asymmetric(data.as_bytes(), &key, version) .unwrap() .into(); - println!("{}", base64::encode(&data)); + println!("{}", base64_encode(&data)); } fn decrypt(data: String, key: String) { @@ -491,12 +492,12 @@ fn hash_password(password: String, params: Option) { } .unwrap() .into(); - println!("{}", base64::encode(&hash)); + println!("{}", base64_encode(&hash)); } fn verify_password(hash: String, password: String) { let hash = devolutions_crypto::password_hash::PasswordHash::try_from( - base64::decode(&hash).unwrap().as_slice(), + base64_decode(&hash).unwrap().as_slice(), ) .unwrap(); @@ -508,22 +509,22 @@ fn generate_keypair() { println!( "Private Key: {}\nPublic Key: {}", - base64::encode(&Vec::::from(keypair.private_key)), - base64::encode(&Vec::::from(keypair.public_key)) + base64_encode(&Vec::::from(keypair.private_key)), + base64_encode(&Vec::::from(keypair.public_key)) ); } fn mix_key_exchange(private: String, public: String) { let private = - devolutions_crypto::key::PrivateKey::try_from(base64::decode(&private).unwrap().as_slice()) + devolutions_crypto::key::PrivateKey::try_from(base64_decode(&private).unwrap().as_slice()) .unwrap(); let public = - devolutions_crypto::key::PublicKey::try_from(base64::decode(&public).unwrap().as_slice()) + devolutions_crypto::key::PublicKey::try_from(base64_decode(&public).unwrap().as_slice()) .unwrap(); println!( "{}", - base64::encode(&devolutions_crypto::key::mix_key_exchange(&private, &public).unwrap()) + base64_encode(&devolutions_crypto::key::mix_key_exchange(&private, &public).unwrap()) ) } @@ -539,7 +540,7 @@ fn generate_shared_key(shares: u8, threshold: u8, length: Option) { .unwrap(); for (i, s) in shares.into_iter().map(Into::>::into).enumerate() { - let s = base64::encode(&s); + let s = base64_encode(&s); println!("Share {}: {}", i, s); } } @@ -549,18 +550,18 @@ fn join_shares(shares: Vec) { .into_iter() .map(|s| { devolutions_crypto::secret_sharing::Share::try_from( - base64::decode(&s).unwrap().as_slice(), + base64_decode(&s).unwrap().as_slice(), ) .unwrap() }) .collect(); let secret_key = devolutions_crypto::secret_sharing::join_shares(&shares).unwrap(); - println!("{}", base64::encode(&secret_key)); + println!("{}", base64_encode(&secret_key)); } fn print_header(data: String) { - let data = base64::decode(&data).unwrap(); + let data = base64_decode(&data).unwrap(); match devolutions_crypto::DataType::try_from(data[2] as u16) { Ok(devolutions_crypto::DataType::Ciphertext) => { diff --git a/deny.toml b/deny.toml index 06315dca..9cf7f902 100644 --- a/deny.toml +++ b/deny.toml @@ -1,156 +1,51 @@ -# This template contains all of the possible sections and their default values - -# Note that all fields that take a lint level have these possible values: -# * deny - An error will be produced and the check will fail -# * warn - A warning will be produced, but the check will not fail -# * allow - No warning or error will be produced, though in some cases a note -# will be - -# The values provided in this template are the default values that will be used -# when any section or field is not specified in your own configuration - -# If 1 or more target triples (and optionally, target_features) are specified, -# only the specified targets will be checked when running `cargo deny check`. -# This means, if a particular package is only ever used as a target specific -# dependency, such as, for example, the `nix` crate only being used via the -# `target_family = "unix"` configuration, that only having windows targets in -# this list would mean the nix crate, as well as any of its exclusive -# dependencies not shared by any other crates, would be ignored, as the target -# list here is effectively saying which targets you are building for. -targets = [ - # The triple can be any string, but only the target triples built in to - # rustc (as of 1.40) can be checked against actual config expressions - #{ triple = "x86_64-unknown-linux-musl" }, - # You can also specify which target_features you promise are enabled for a - # particular target. target_features are currently not validated against - # the actual valid features supported by the target architecture. - #{ triple = "wasm32-unknown-unknown", features = ["atomics"] }, -] +# cargo-deny configuration +# Documentation: https://embarkstudios.github.io/cargo-deny/ # This section is considered when running `cargo deny check advisories` -# More documentation for the advisories section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html [advisories] # The path where the advisory database is cloned/fetched into db-path = "~/.cargo/advisory-db" # The url(s) of the advisory databases to use db-urls = ["https://github.com/rustsec/advisory-db"] -# The lint level for security vulnerabilities -vulnerability = "deny" -# The lint level for unmaintained crates -unmaintained = "warn" # The lint level for crates that have been yanked from their source registry yanked = "warn" -# The lint level for crates with security notices. Note that as of -# 2019-12-17 there are no security notice advisories in -# https://github.com/rustsec/advisory-db -notice = "warn" # A list of advisory IDs to ignore. Note that ignored advisories will still # output a note when they are encountered. ignore = [ - #"RUSTSEC-0000-0000", + # `paste` is archived/unmaintained. It is a small proc-macro with no runtime + # code. Tracked for replacement (e.g. `pastey`). + "RUSTSEC-2024-0436", ] -# Threshold for security vulnerabilities, any vulnerability with a CVSS score -# lower than the range specified will be ignored. Note that ignored advisories -# will still output a note when they are encountered. -# * None - CVSS Score 0.0 -# * Low - CVSS Score 0.1 - 3.9 -# * Medium - CVSS Score 4.0 - 6.9 -# * High - CVSS Score 7.0 - 8.9 -# * Critical - CVSS Score 9.0 - 10.0 -#severity-threshold = - -# If this is true, then cargo deny will use the git executable to fetch advisory database. -# If this is false, then it uses a built-in git library. -# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support. -# See Git Authentication for more information about setting up git authentication. -#git-fetch-with-cli = true # This section is considered when running `cargo deny check licenses` -# More documentation for the licenses section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html [licenses] -# The lint level for crates which do not have a detectable license -unlicensed = "deny" # List of explicitly allowed licenses # See https://spdx.org/licenses/ for list of possible licenses -# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. allow = [ "MIT", "BSD-2-Clause", "BSD-3-Clause", "Apache-2.0", - "Unicode-DFS-2016", + "Unicode-3.0", "CC0-1.0", + "Zlib", ] -# List of explicitly disallowed licenses -# See https://spdx.org/licenses/ for list of possible licenses -# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. -deny = [ - #"Nokia", -] -# Lint level for licenses considered copyleft -#copyleft = "warn" -# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses -# * both - The license will be approved if it is both OSI-approved *AND* FSF -# * either - The license will be approved if it is either OSI-approved *OR* FSF -# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF -# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved -# * neither - This predicate is ignored and the default lint level is used -allow-osi-fsf-free = "neither" -# Lint level used when no other predicates are matched -# 1. License isn't in the allow or deny lists -# 2. License isn't copyleft -# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither" -default = "deny" # The confidence threshold for detecting a license from license text. -# The higher the value, the more closely the license text must be to the -# canonical license text of a valid SPDX license file. -# [possible values: any between 0.0 and 1.0]. confidence-threshold = 0.8 # Allow 1 or more licenses on a per-crate basis, so that particular licenses # aren't accepted for every possible crate as with the normal allow list exceptions = [ - # Each entry is the crate and version constraint, and its specific allow - # list #{ allow = ["Zlib"], name = "adler32", version = "*" }, ] -# Some crates don't have (easily) machine readable licensing information, -# adding a clarification entry for it allows you to manually specify the -# licensing information -#[[licenses.clarify]] -# The name of the crate the clarification applies to -#name = "ring" -# The optional version constraint for the crate -#version = "*" -# The SPDX expression for the license requirements of the crate -#expression = "MIT AND ISC AND OpenSSL" -# One or more files in the crate's source used as the "source of truth" for -# the license expression. If the contents match, the clarification will be used -# when running the license check, otherwise the clarification will be ignored -# and the crate will be checked normally, which may produce warnings or errors -# depending on the rest of your configuration -#license-files = [ - # Each entry is a crate relative path, and the (opaque) hash of its contents - #{ path = "LICENSE", hash = 0xbd0eed23 } -#] - [licenses.private] # If true, ignores workspace crates that aren't published, or are only # published to private registries. -# To see how to mark a crate as unpublished (to the official registry), -# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field. ignore = false -# One or more private registries that you might publish crates to, if a crate -# is only published to private registries, and ignore is true, the crate will -# not have its license(s) checked -registries = [ - #"https://sekretz.com/registry -] -# This section is considered when running `cargo deny check bans`. -# More documentation about the 'bans' section can be found here: +# This section is considered when running `cargo deny check bans` # https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html [bans] # Lint level for when multiple versions of the same crate are detected @@ -159,38 +54,18 @@ multiple-versions = "warn" wildcards = "allow" # The graph highlighting used when creating dotgraphs for crates # with multiple versions -# * lowest-version - The path to the lowest versioned duplicate is highlighted -# * simplest-path - The path to the version with the fewest edges is highlighted -# * all - Both lowest-version and simplest-path are used highlight = "all" # List of crates that are allowed. Use with care! -allow = [ - #{ name = "ansi_term", version = "=0.11.0" }, -] +allow = [] # List of crates to deny -deny = [ - # Each entry the name of a crate and a version range. If version is - # not specified, all versions will be matched. - #{ name = "ansi_term", version = "=0.11.0" }, - # - # Wrapper crates can optionally be specified to allow the crate when it - # is a direct dependency of the otherwise banned crate - #{ name = "ansi_term", version = "=0.11.0", wrappers = [] }, -] +deny = [] # Certain crates/versions that will be skipped when doing duplicate detection. -skip = [ - #{ name = "ansi_term", version = "=0.11.0" }, -] +skip = [] # Similarly to `skip` allows you to skip certain crates during duplicate -# detection. Unlike skip, it also includes the entire tree of transitive -# dependencies starting at the specified crate, up to a certain depth, which is -# by default infinite -skip-tree = [ - #{ name = "ansi_term", version = "=0.11.0", depth = 20 }, -] +# detection, including the entire tree of transitive dependencies. +skip-tree = [] -# This section is considered when running `cargo deny check sources`. -# More documentation about the 'sources' section can be found here: +# This section is considered when running `cargo deny check sources` # https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html [sources] # Lint level for what to happen when a crate from a crate registry that is not @@ -200,15 +75,6 @@ unknown-registry = "warn" # in the allow list is encountered unknown-git = "warn" # List of URLs for allowed crate registries. Defaults to the crates.io index -# if not specified. If it is specified but empty, no registries are allowed. allow-registry = ["https://github.com/rust-lang/crates.io-index"] # List of URLs for allowed Git repositories allow-git = [] - -[sources.allow-org] -# 1 or more github.com organizations to allow git sources for -#github = [""] -# 1 or more gitlab.com organizations to allow git sources for -#gitlab = [""] -# 1 or more bitbucket.org organizations to allow git sources for -#bitbucket = [""] diff --git a/ffi/src/lib.rs b/ffi/src/lib.rs index 2dc2dfe3..8f88765d 100644 --- a/ffi/src/lib.rs +++ b/ffi/src/lib.rs @@ -66,11 +66,11 @@ pub const PASSWORD_HASH_V2: u16 = 2; /// * `key` - Pointer to the key to use to encrypt. /// * `key_length` - Length of the key to use to encrypt. /// * `aad` - Pointer to additionnal data to authenticate alongside the ciphertext. -/// Pass null if there is not additionnal data to authenticate. +/// Pass null if there is not additionnal data to authenticate. /// * `aad_length` - Length of the additionnal data to authenticate. Pass 0 if there is no data. /// * `result` - Pointer to the buffer to write the ciphertext to. /// * `result_length` - Length of the buffer to write the ciphertext to. You can get the value by -/// calling EncryptSize() beforehand. +/// calling EncryptSize() beforehand. /// * `version` - Version to use. Use 0 for the latest one. /// # Returns /// This returns the length of the ciphertext. If there is an error, it will return the @@ -130,11 +130,11 @@ pub unsafe extern "C" fn Encrypt( /// * `public_key` - Pointer to the public key to use to encrypt. /// * `public_key_length` - Length of the public key to use to encrypt. /// * `aad` - Pointer to additionnal data to authenticate alongside the ciphertext. -/// Pass null if there is not additionnal data to authenticate. +/// Pass null if there is not additionnal data to authenticate. /// * `aad_length` - Length of the additionnal data to authenticate. Pass 0 if there is no data. /// * `result` - Pointer to the buffer to write the ciphertext to. /// * `result_length` - Length of the buffer to write the ciphertext to. You can get the value by -/// calling EncryptAsymmetricSize() beforehand. +/// calling EncryptAsymmetricSize() beforehand. /// * `version` - Version to use. Use 0 for the latest one. /// # Returns /// This returns the length of the asymmetric ciphertext. If there is an error, it will return the @@ -515,11 +515,11 @@ pub unsafe extern "C" fn DeriveDecryptData( /// * `key` - Pointer to the key to use to decrypt. /// * `key_length` - Length of the key to use to decrypt. /// * `aad` - Pointer to additionnal data to authenticate alongside the ciphertext. -/// Pass null if there is not additionnal data to authenticate. +/// Pass null if there is not additionnal data to authenticate. /// * `aad_length` - Length of the additionnal data to authenticate. Pass 0 if there is no data. /// * `result` - Pointer to the buffer to write the plaintext to. /// * `result_length` - Length of the buffer to write the plaintext to. -/// The safest size is the same size as the ciphertext. +/// The safest size is the same size as the ciphertext. /// # Returns /// This returns the length of the plaintext. If there is an error, it will return the /// appropriate error code defined in DevoCryptoError. @@ -576,11 +576,11 @@ pub unsafe extern "C" fn Decrypt( /// * `private_key` - Pointer to the private key to use to decrypt. /// * `private_key_length` - Length of the private key to use to decrypt. /// * `aad` - Pointer to additionnal data to authenticate alongside the ciphertext. -/// Pass null if there is not additionnal data to authenticate. +/// Pass null if there is not additionnal data to authenticate. /// * `aad_length` - Length of the additionnal data to authenticate. Pass 0 if there is no data. /// * `result` - Pointer to the buffer to write the plaintext to. /// * `result_length` - Length of the buffer to write the plaintext to. -/// The safest size is the same size as the ciphertext. +/// The safest size is the same size as the ciphertext. /// # Returns /// This returns the length of the plaintext. If there is an error, it will return the /// appropriate error code defined in DevoCryptoError. @@ -643,7 +643,7 @@ pub unsafe extern "C" fn DecryptAsymmetric( /// * `keypair_length` - Length of the keypair to use to sign the data. /// * `result` - Pointer to the buffer to write the signature to. /// * `result_length` - Length of the buffer to write the signature to. You can get the value by -/// calling SignSize() beforehand. +/// calling SignSize() beforehand. /// # Returns /// This returns 0 if the operation worked. If there is an error, it will return the /// appropriate error code defined in DevoCryptoError. @@ -747,7 +747,7 @@ pub extern "C" fn SignSize(_version: u16) -> i64 { /// * `password_length` - Length of the password to hash. /// * `result` - Pointer to the buffer to write the hash to. /// * `result_length` - Length of the buffer to write the hash to. You can get the value by -/// calling HashPasswordLength(version) beforehand. +/// calling HashPasswordLength(version) beforehand. /// * `version` - Version to use. Use PASSWORD_HASH_LATEST for the latest one. /// # Returns /// This returns the length of the hash. If there is an error, it will return the @@ -924,10 +924,10 @@ pub unsafe extern "C" fn VerifyPassword( /// # Arguments /// * `private` - Pointer to the buffer to write the private key to. /// * `private_length` - Length of the buffer to write the private key to. -/// You can get the value by calling `GenerateKeyPairSize()` beforehand. +/// You can get the value by calling `GenerateKeyPairSize()` beforehand. /// * `public` - Pointer to the buffer to write the public key to. /// * `public_length` - Length of the buffer to write the public key to. -/// You can get the value by calling `GenerateKeyPairSize()` beforehand. +/// You can get the value by calling `GenerateKeyPairSize()` beforehand. /// # Returns /// Returns 0 if the generation worked. If there is an error, /// it will return the appropriate error code defined in DevoCryptoError. @@ -967,7 +967,7 @@ pub unsafe extern "C" fn GenerateKeyPair( /// # Arguments /// * `keypair` - Pointer to the buffer to write the keypair to. /// * `keypair_length` - Length of the buffer to write the keypair to. -/// You can get the value by calling `GenerateSigningKeyPairSize()` beforehand. +/// You can get the value by calling `GenerateSigningKeyPairSize()` beforehand. /// * `version` - Version to use. Use 0 for the latest one. /// # Returns /// Returns 0 if the generation worked. If there is an error, @@ -1010,7 +1010,7 @@ pub unsafe extern "C" fn GenerateSigningKeyPair( /// * `keypair_length` - Length of the buffer containing the keypair. /// * `public` - Pointer to the buffer to write the public key to. /// * `public_length` - Length of the buffer to write the public key to. -/// You can get the value by calling `GetSigningPublicKeySize()` beforehand. +/// You can get the value by calling `GetSigningPublicKeySize()` beforehand. /// # Safety /// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] @@ -1056,7 +1056,7 @@ pub extern "C" fn GenerateKeyPairSize() -> i64 { /// # Arguments /// * `result` - Pointer to the buffer to write the secret key to. /// * `result_length` - Length of the buffer to write the secret key to. -/// You can get the value by calling `GenerateSecretKeySize()` beforehand. +/// You can get the value by calling `GenerateSecretKeySize()` beforehand. /// # Returns /// Returns 0 if the generation worked. If there is an error, /// it will return the appropriate error code defined in DevoCryptoError. @@ -1092,7 +1092,7 @@ pub extern "C" fn GenerateSecretKeySize() -> i64 { /// Get the size of the keypair used for signing. /// # Returns /// Returns the length of the keypair to input as `keypair_length` -/// in `GenerateSigningKeyPair()`. +/// in `GenerateSigningKeyPair()`. #[no_mangle] pub extern "C" fn GenerateSigningKeyPairSize(_version: u16) -> i64 { 8 + 64 // header + keypair length @@ -1101,7 +1101,7 @@ pub extern "C" fn GenerateSigningKeyPairSize(_version: u16) -> i64 { /// Get the size of the public key used for signing. /// # Returns /// Returns the length of the public key to input as `public_length` -/// in `GetSigningPublicKey()`. +/// in `GetSigningPublicKey()`. #[no_mangle] pub extern "C" fn GetSigningPublicKeySize(_keypair: *const u8, _keypair_length: usize) -> i64 { 8 + 32 // header + public key length @@ -1262,6 +1262,20 @@ pub unsafe extern "C" fn JoinShares( } } +/// Creates a new online (chunked) encryptor and writes an opaque handle to it in `output`. +/// # Arguments +/// * `key` - Pointer to the symmetric key or, if `asymmetric` is true, the public key. +/// * `key_size` - Length of the key. +/// * `aad` - Pointer to additionnal data to authenticate alongside the ciphertext. +/// * `aad_size` - Length of the additionnal data to authenticate. Pass 0 if there is no data. +/// * `chunk_size` - Size of the chunks to encrypt. +/// * `asymmetric` - Whether to use asymmetric encryption. +/// * `version` - Version to use. Use 0 for the latest one. +/// * `output` - Pointer receiving the opaque encryptor handle. Free it with `OnlineEncryptorLastChunk` or `FreeOnlineEncryptor`. +/// # Returns +/// 0 on success, otherwise the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] pub unsafe extern "C" fn NewOnlineEncryptor( key: *const u8, @@ -1303,6 +1317,20 @@ pub unsafe extern "C" fn NewOnlineEncryptor( 0 } +/// Creates a new online (chunked) decryptor from a serialized header and writes an opaque handle to it in `output`. +/// # Arguments +/// * `key` - Pointer to the symmetric key or, if `asymmetric` is true, the private key. +/// * `key_size` - Length of the key. +/// * `aad` - Pointer to the additionnal data to authenticate alongside the ciphertext. +/// * `aad_size` - Length of the additionnal data to authenticate. Pass 0 if there is no data. +/// * `header` - Pointer to the serialized online ciphertext header. +/// * `header_size` - Length of the serialized header. +/// * `asymmetric` - Whether to use asymmetric encryption. +/// * `output` - Pointer receiving the opaque decryptor handle. Free it with `OnlineDecryptorLastChunk` or `FreeOnlineDecryptor`. +/// # Returns +/// 0 on success, otherwise the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] pub unsafe extern "C" fn NewOnlineDecryptor( key: *const u8, @@ -1350,6 +1378,15 @@ pub unsafe extern "C" fn NewOnlineDecryptor( 0 } +/// Writes the serialized header of the encryptor to the result buffer. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineEncryptor`. +/// * `result` - Pointer to the buffer to write the serialized header to. +/// * `result_size` - Length of the buffer. Must be `OnlineEncryptorGetHeaderSize()` bytes. +/// # Returns +/// The length of the serialized header, or the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] pub unsafe extern "C" fn OnlineEncryptorGetHeader( ptr: *const c_void, @@ -1370,11 +1407,20 @@ pub unsafe extern "C" fn OnlineEncryptorGetHeader( return Error::InvalidOutputLength.error_code(); } - result.copy_from(header.as_slice().as_ptr() as *const u8, result_size); + result.copy_from(header.as_slice().as_ptr(), result_size); result_size as i64 } +/// Writes the serialized header of the decryptor to the result buffer. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineDecryptor`. +/// * `result` - Pointer to the buffer to write the serialized header to. +/// * `result_size` - Length of the buffer. Must be `OnlineDecryptorGetHeaderSize()` bytes. +/// # Returns +/// The length of the serialized header, or the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] pub unsafe extern "C" fn OnlineDecryptorGetHeader( ptr: *const c_void, @@ -1395,11 +1441,24 @@ pub unsafe extern "C" fn OnlineDecryptorGetHeader( return Error::InvalidOutputLength.error_code(); } - result.copy_from(header.as_slice().as_ptr() as *const u8, result_size); + result.copy_from(header.as_slice().as_ptr(), result_size); result_size as i64 } +/// Encrypts the next chunk of data. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineEncryptor`. +/// * `data` - Pointer to the chunk to encrypt. +/// * `data_size` - Length of the chunk to encrypt. +/// * `aad` - Pointer to additionnal data to authenticate alongside this chunk. +/// * `aad_size` - Length of the additionnal data to authenticate. Pass 0 if there is no data. +/// * `result` - Pointer to the buffer to write the encrypted chunk to. +/// * `result_size` - Length of the buffer to write the encrypted chunk to. +/// # Returns +/// The length of the encrypted chunk, or the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] pub unsafe extern "C" fn OnlineEncryptorNextChunk( ptr: *mut c_void, @@ -1414,7 +1473,7 @@ pub unsafe extern "C" fn OnlineEncryptorNextChunk( return Error::NullPointer.error_code(); }; - let encryptor = &mut *(ptr as *mut Mutex); + let encryptor = &*(ptr as *const Mutex); let mut encryptor = match encryptor.lock() { Ok(c) => c, Err(_) => return Error::PoisonedMutex.error_code(), @@ -1432,11 +1491,24 @@ pub unsafe extern "C" fn OnlineEncryptorNextChunk( return Error::InvalidOutputLength.error_code(); } - result.copy_from(encrypted.as_slice().as_ptr() as *const u8, result_size); + result.copy_from(encrypted.as_slice().as_ptr(), result_size); result_size as i64 } +/// Decrypts the next chunk of data. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineDecryptor`. +/// * `data` - Pointer to the chunk to decrypt. +/// * `data_size` - Length of the chunk to decrypt. +/// * `aad` - Pointer to the additionnal data to authenticate alongside this chunk. +/// * `aad_size` - Length of the additionnal data to authenticate. Pass 0 if there is no data. +/// * `result` - Pointer to the buffer to write the decrypted chunk to. +/// * `result_size` - Length of the buffer to write the decrypted chunk to. +/// # Returns +/// The length of the decrypted chunk, or the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] pub unsafe extern "C" fn OnlineDecryptorNextChunk( ptr: *mut c_void, @@ -1451,7 +1523,7 @@ pub unsafe extern "C" fn OnlineDecryptorNextChunk( return Error::NullPointer.error_code(); }; - let decryptor = &mut *(ptr as *mut Mutex); + let decryptor = &*(ptr as *const Mutex); let mut decryptor = match decryptor.lock() { Ok(c) => c, Err(_) => return Error::PoisonedMutex.error_code(), @@ -1469,11 +1541,25 @@ pub unsafe extern "C" fn OnlineDecryptorNextChunk( return Error::InvalidOutputLength.error_code(); } - result.copy_from(decrypted.as_slice().as_ptr() as *const u8, result_size); + result.copy_from(decrypted.as_slice().as_ptr(), result_size); result_size as i64 } +/// Encrypts the last chunk of data and consumes the encryptor. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineEncryptor`. +/// * `data` - Pointer to the chunk to encrypt. +/// * `data_size` - Length of the chunk to encrypt. +/// * `aad` - Pointer to additionnal data to authenticate alongside this chunk. +/// * `aad_size` - Length of the additionnal data to authenticate. Pass 0 if there is no data. +/// * `result` - Pointer to the buffer to write the encrypted chunk to. +/// * `result_size` - Length of the buffer to write the encrypted chunk to. +/// # Returns +/// The length of the encrypted chunk, or the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. +/// This call frees the encryptor: `ptr` must not be used again afterwards. #[no_mangle] pub unsafe extern "C" fn OnlineEncryptorLastChunk( ptr: *mut c_void, @@ -1507,11 +1593,25 @@ pub unsafe extern "C" fn OnlineEncryptorLastChunk( return Error::InvalidOutputLength.error_code(); } - result.copy_from(encrypted.as_slice().as_ptr() as *const u8, encrypted.len()); + result.copy_from(encrypted.as_slice().as_ptr(), encrypted.len()); encrypted.len() as i64 } +/// Decrypts the last chunk of data and consumes the decryptor. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineDecryptor`. +/// * `data` - Pointer to the chunk to decrypt. +/// * `data_size` - Length of the chunk to decrypt. +/// * `aad` - Pointer to the additionnal data to authenticate alongside this chunk. +/// * `aad_size` - Length of the additionnal data to authenticate. Pass 0 if there is no data. +/// * `result` - Pointer to the buffer to write the decrypted chunk to. +/// * `result_size` - Length of the buffer to write the decrypted chunk to. +/// # Returns +/// The length of the decrypted chunk, or the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. +/// This call frees the decryptor: `ptr` must not be used again afterwards. #[no_mangle] pub unsafe extern "C" fn OnlineDecryptorLastChunk( ptr: *mut c_void, @@ -1544,11 +1644,18 @@ pub unsafe extern "C" fn OnlineDecryptorLastChunk( return Error::InvalidOutputLength.error_code(); } - result.copy_from(decrypted.as_slice().as_ptr() as *const u8, decrypted.len()); + result.copy_from(decrypted.as_slice().as_ptr(), decrypted.len()); decrypted.len() as i64 } +/// The size, in bytes, of the encryptor's serialized header. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineEncryptor`. +/// # Returns +/// The length of the serialized header, or the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] pub unsafe extern "C" fn OnlineEncryptorGetHeaderSize(ptr: *const c_void) -> i64 { if ptr.is_null() { @@ -1564,6 +1671,13 @@ pub unsafe extern "C" fn OnlineEncryptorGetHeaderSize(ptr: *const c_void) -> i64 header.get_serialized_size() as i64 } +/// The size, in bytes, of the decryptor's serialized header. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineDecryptor`. +/// # Returns +/// The length of the serialized header, or the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] pub unsafe extern "C" fn OnlineDecryptorGetHeaderSize(ptr: *const c_void) -> i64 { if ptr.is_null() { @@ -1579,6 +1693,13 @@ pub unsafe extern "C" fn OnlineDecryptorGetHeaderSize(ptr: *const c_void) -> i64 header.get_serialized_size() as i64 } +/// The size, in bytes, of the chunks the encryptor works with. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineEncryptor`. +/// # Returns +/// The chunk size, or the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] pub unsafe extern "C" fn OnlineEncryptorGetChunkSize(ptr: *const c_void) -> i64 { if ptr.is_null() { @@ -1592,6 +1713,13 @@ pub unsafe extern "C" fn OnlineEncryptorGetChunkSize(ptr: *const c_void) -> i64 } } +/// The size, in bytes, of the chunks the decryptor works with. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineDecryptor`. +/// # Returns +/// The chunk size, or the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] pub unsafe extern "C" fn OnlineDecryptorGetChunkSize(ptr: *const c_void) -> i64 { if ptr.is_null() { @@ -1605,6 +1733,13 @@ pub unsafe extern "C" fn OnlineDecryptorGetChunkSize(ptr: *const c_void) -> i64 } } +/// The size, in bytes, of the authentication tag appended to each chunk by the encryptor. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineEncryptor`. +/// # Returns +/// The tag size, or the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] pub unsafe extern "C" fn OnlineEncryptorGetTagSize(ptr: *const c_void) -> i64 { if ptr.is_null() { @@ -1618,6 +1753,13 @@ pub unsafe extern "C" fn OnlineEncryptorGetTagSize(ptr: *const c_void) -> i64 { } } +/// The size, in bytes, of the authentication tag expected at the end of each chunk by the decryptor. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineDecryptor`. +/// # Returns +/// The tag size, or the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. #[no_mangle] pub unsafe extern "C" fn OnlineDecryptorGetTagSize(ptr: *const c_void) -> i64 { if ptr.is_null() { @@ -1631,6 +1773,14 @@ pub unsafe extern "C" fn OnlineDecryptorGetTagSize(ptr: *const c_void) -> i64 { } } +/// Frees an encryptor without finalizing the encryption. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineEncryptor`. +/// # Returns +/// 0 on success, otherwise the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. +/// `ptr` must not be used again afterwards. #[no_mangle] pub unsafe extern "C" fn FreeOnlineEncryptor(ptr: *mut c_void) -> i64 { if ptr.is_null() { @@ -1642,6 +1792,14 @@ pub unsafe extern "C" fn FreeOnlineEncryptor(ptr: *mut c_void) -> i64 { 0 } +/// Frees a decryptor without finalizing the decryption. +/// # Arguments +/// * `ptr` - Opaque handle returned by `NewOnlineDecryptor`. +/// # Returns +/// 0 on success, otherwise the appropriate error code defined in DevoCryptoError. +/// # Safety +/// This method is made to be called by C, so it is therefore unsafe. The caller should make sure it passes the right pointers and sizes. +/// `ptr` must not be used again afterwards. #[no_mangle] pub unsafe extern "C" fn FreeOnlineDecryptor(ptr: *mut c_void) -> i64 { if ptr.is_null() { @@ -1787,10 +1945,10 @@ pub unsafe extern "C" fn DeriveKeyPbkdf2( /// * password_length - Length of the password to derive. /// * iterations - Number of PBKDF2 iterations. /// * secret_key - Pointer to the buffer to write the derived SecretKey to. -/// Must be `GenerateSecretKeySize()` bytes. +/// Must be `GenerateSecretKeySize()` bytes. /// * secret_key_length - Length of the secret key output buffer. /// * params_out - Pointer to the buffer to write the DerivationParameters to. -/// Must be `DeriveSecretKeyPbkdf2Size()` bytes. +/// Must be `DeriveSecretKeyPbkdf2Size()` bytes. /// * params_out_length - Length of the params output buffer. /// # Returns /// Returns 0 if the operation is successful. If there is an error, @@ -1851,10 +2009,10 @@ pub extern "C" fn DeriveSecretKeyPbkdf2Size() -> i64 { /// * argon2_parameters - Pointer to the buffer containing the serialized Argon2Parameters. /// * argon2_parameters_length - Length of the Argon2Parameters buffer. /// * secret_key - Pointer to the buffer to write the derived SecretKey to. -/// Must be `GenerateSecretKeySize()` bytes. +/// Must be `GenerateSecretKeySize()` bytes. /// * secret_key_length - Length of the secret key output buffer. /// * params_out - Pointer to the buffer to write the DerivationParameters to. -/// Must be `DeriveSecretKeyArgon2ParametersSize(argon2_parameters_length)` bytes. +/// Must be `DeriveSecretKeyArgon2ParametersSize(argon2_parameters_length)` bytes. /// * params_out_length - Length of the params output buffer. /// # Returns /// Returns 0 if the operation is successful. If there is an error, @@ -1924,10 +2082,10 @@ pub unsafe extern "C" fn DeriveSecretKeyArgon2( /// * salt - Pointer to the salt to use for derivation. /// * salt_length - Length of the salt. /// * secret_key - Pointer to the buffer to write the derived SecretKey to. -/// Must be `GenerateSecretKeySize()` bytes. +/// Must be `GenerateSecretKeySize()` bytes. /// * secret_key_length - Length of the secret key output buffer. /// * params_out - Pointer to the buffer to write the DerivationParameters to. -/// Must be `DeriveSecretKeyPbkdf2WithSaltSize(salt_length)` bytes. +/// Must be `DeriveSecretKeyPbkdf2WithSaltSize(salt_length)` bytes. /// * params_out_length - Length of the params output buffer. /// # Returns /// Returns 0 if the operation is successful. If there is an error, @@ -2010,7 +2168,7 @@ pub extern "C" fn GetArgon2DerivationParametersSize(argon2_parameters_length: us /// * `argon2_parameters` - Pointer to the serialized `Argon2Parameters`. /// * `argon2_parameters_length` - Length of the `Argon2Parameters` buffer. /// * `result` - Pointer to the output buffer. -/// Must be `GetArgon2DerivationParametersSize(argon2_parameters_length)` bytes. +/// Must be `GetArgon2DerivationParametersSize(argon2_parameters_length)` bytes. /// * `result_length` - Length of the output buffer. /// # Returns /// Returns the number of bytes written, or a negative error code. @@ -2055,7 +2213,7 @@ pub extern "C" fn GetPbkdf2DerivationParametersSize() -> i64 { /// # Arguments /// * `iterations` - Number of PBKDF2 iterations. /// * `result` - Pointer to the output buffer. -/// Must be `GetPbkdf2DerivationParametersSize()` bytes. +/// Must be `GetPbkdf2DerivationParametersSize()` bytes. /// * `result_length` - Length of the output buffer. /// # Returns /// Returns the number of bytes written, or a negative error code. @@ -2505,7 +2663,7 @@ fn test_get_default_argon2parameters() { #[test] fn test_decode() { fn get_decoded_base64_string_length(base64: &str) -> usize { - if base64.is_empty() || base64.len() % 4 != 0 { + if base64.is_empty() || !base64.len().is_multiple_of(4) { return 0; }