-
Notifications
You must be signed in to change notification settings - Fork 2
fix: audit and common fixes #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
705f2c6
40635f8
84407e6
f07a884
83c0ac5
7a62f03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| name: Differential Tests | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
| jobs: | ||
| differential-tests: | ||
| name: differential | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout pinned mfkdf2.rs commit | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: 7c33c7164d6e40a26c0899f19b8f9ad9b9f0c029 | ||
|
|
||
| - name: Install Rust | ||
| uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: stable | ||
| targets: wasm32-unknown-unknown | ||
|
|
||
| - name: Rust Cache | ||
| uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| key: typescript/differential | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
| cache: "npm" | ||
| cache-dependency-path: mfkdf2-web/package-lock.json | ||
|
|
||
| - name: Install wasm-bindgen-cli | ||
| uses: taiki-e/install-action@v2 | ||
| with: | ||
| tool: wasm-bindgen-cli | ||
|
|
||
| - name: Cache node_modules | ||
| id: cache-node-modules | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: mfkdf2-web/node_modules | ||
| key: ${{ runner.os }}-node-modules-${{ hashFiles('mfkdf2-web/package-lock.json') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-node-modules- | ||
|
|
||
| - name: Install mfkdf2-web dependencies | ||
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | ||
| working-directory: mfkdf2-web | ||
| run: npm ci | ||
|
|
||
| - name: Generate TypeScript bindings for differential tests | ||
| working-directory: mfkdf2-web | ||
| run: npm run ubrn:web:differential:release | ||
|
|
||
| - name: Copy index.web.ts implementation | ||
| run: cp mfkdf2-web/src/index.ts mfkdf2-web/src/index.web.ts | ||
|
|
||
| - name: Verify bindings were generated | ||
| run: | | ||
| if [ ! -d "mfkdf2-web/src/generated" ] || [ -z "$(ls -A mfkdf2-web/src/generated)" ]; then | ||
| echo "Error: mfkdf2-web/src/generated does not exist or is empty" | ||
| exit 1 | ||
| fi | ||
| if [ ! -d "mfkdf2-web/rust_modules" ]; then | ||
| echo "Error: mfkdf2-web/rust_modules does not exist" | ||
| exit 1 | ||
| fi | ||
| echo "✓ TypeScript bindings verified" | ||
|
|
||
| - name: Run differential tests | ||
| working-directory: mfkdf2-web | ||
| run: npm run test:differential | ||
|
|
||
|
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -276,6 +276,8 @@ a Shamir‑style secret sharing scheme, one share per factor. During derive, any | |||||
| that supplies at least `threshold` valid shares can reconstruct the same secret and therefore | ||||||
| the same derived key. | ||||||
|
|
||||||
| **Note**: MFKDF2 provides no mechanism to invalidate old policies. When threshold is increased via [reconstitution](`crate::definitions::mfkdf_derived_key::reconstitution`), old policies can still be used to derive keys. | ||||||
|
|
||||||
| ## Setup: configuring a 2‑of‑3 recovery policy | ||||||
|
|
||||||
| The snippet below constructs a 2‑of‑3 key from a password, an HOTP soft token, and a UUID | ||||||
|
|
@@ -463,6 +465,13 @@ let derived = derive::key( | |||||
| The same outer key can also be derived with only `password3` by supplying a single password | ||||||
| factor keyed by `"password3"` to [setup key](`crate::derive::key`). | ||||||
|
|
||||||
| # Integrity Protetion | ||||||
|
||||||
| # Integrity Protetion | |
| # Integrity Protection |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,15 @@ | ||
| use crate::error::MFKDF2Result; | ||
|
|
||
| impl crate::definitions::MFKDF2DerivedKey { | ||
| /// Returns an HKDF-SHA256 derived key for the given purpose and salt. | ||
| pub fn get_subkey(&self, purpose: Option<&str>, salt: Option<&[u8]>) -> [u8; 32] { | ||
| pub fn get_subkey(&self, purpose: Option<&str>, salt: Option<&[u8]>) -> MFKDF2Result<[u8; 32]> { | ||
| let salt = salt.unwrap_or(&[]); | ||
| let purpose = purpose.unwrap_or(""); | ||
| crate::crypto::hkdf_sha256_with_info(&self.key, salt, purpose.as_bytes()) | ||
|
|
||
| // derive internal key | ||
| let internal_key = self.derive_internal_key()?; | ||
| // derive subkey | ||
| Ok(crate::crypto::hkdf_sha256_with_info(&internal_key, salt, purpose.as_bytes())) | ||
|
Comment on lines
+5
to
+12
|
||
| } | ||
| } | ||
|
|
||
|
|
@@ -13,8 +19,8 @@ fn derived_key_get_subkey( | |
| derived_key: &crate::definitions::MFKDF2DerivedKey, | ||
| purpose: Option<String>, | ||
| salt: Option<Vec<u8>>, | ||
| ) -> Vec<u8> { | ||
| ) -> MFKDF2Result<Vec<u8>> { | ||
| let purpose = purpose.as_deref(); | ||
| let salt = salt.as_deref(); | ||
| derived_key.get_subkey(purpose, salt).to_vec() | ||
| Ok(derived_key.get_subkey(purpose, salt)?.to_vec()) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.