1
0
mirror of https://github.com/bitwarden/server synced 2026-01-04 01:23:25 +00:00

Speed up KDF

This commit is contained in:
Hinton
2025-07-31 16:39:12 +02:00
parent 3132e09e21
commit 3ad308138e
7 changed files with 23 additions and 19 deletions

View File

@@ -10,17 +10,17 @@
</PropertyGroup>
<ItemGroup>
<Content Include="rust/target/debug/libsdk.dylib">
<Content Include="rust/target/release/libsdk.dylib">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<PackageCopyToOutput>true</PackageCopyToOutput>
<Link>runtimes/osx-arm64/native/libsdk.dylib</Link>
</Content>
<Content Include="./rust/target/debug/libsdk.so">
<Content Include="./rust/target/release/libsdk.so">
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
<Content Include="./rust/target/debug/libsdk.dll">
<Content Include="./rust/target/release/libsdk.dll">
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
</ItemGroup>
</Project>
</Project>

View File

@@ -20,3 +20,14 @@ serde_json = "=1.0.141"
[build-dependencies]
csbindgen = "=1.9.3"
# Compile all dependencies with some optimizations when building this crate on debug
# This slows down clean builds by about 50%, but the resulting binaries can be orders of magnitude faster
# As clean builds won't occur very often, this won't slow down the development process
[profile.dev.package."*"]
opt-level = 2
[profile.release]
codegen-units = 1
lto = true
opt-level = 3

View File

@@ -11,11 +11,6 @@ use bitwarden_crypto::{
SpkiPublicKeyBytes, SymmetricCryptoKey, UnsignedSharedKey, UserKey,
};
#[no_mangle]
pub extern "C" fn my_add(x: i32, y: i32) -> i32 {
x + y
}
#[no_mangle]
pub unsafe extern "C" fn generate_user_keys(
email: *const c_char,
@@ -23,7 +18,7 @@ pub unsafe extern "C" fn generate_user_keys(
) -> *const c_char {
// TODO: We might want to make KDF configurable in the future.
let kdf = Kdf::PBKDF2 {
iterations: NonZeroU32::new(600_000).unwrap(),
iterations: NonZeroU32::new(5_000).unwrap(),
};
let email = CStr::from_ptr(email).to_str().unwrap();