Skip to content

Commit 95da026

Browse files
overvenusti-chi-bot[bot]LykxSassinator
authored
*: use OpenSSL for crypto RNG (tikv#16170)
ref tikv#15982 To comply with FIPS 140-2 requirements, it's essential to choose an RNG that meets these specifications. This commit replaces the `rand` crate with OpenSSL for cryptographic random number generation. Signed-off-by: Neil Shen <[email protected]> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> Co-authored-by: lucasliang <[email protected]>
1 parent a07db9f commit 95da026

File tree

28 files changed

+119
-120
lines changed

28 files changed

+119
-120
lines changed

Cargo.lock

Lines changed: 15 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ coprocessor_plugin_api = { workspace = true }
6868
crc32fast = "1.2"
6969
crc64fast = "0.1"
7070
crossbeam = "0.8"
71+
crypto = { workspace = true }
7172
dashmap = "5"
7273
encryption_export = { workspace = true }
7374
engine_panic = { workspace = true }
@@ -78,7 +79,6 @@ engine_traits_tests = { workspace = true }
7879
error_code = { workspace = true }
7980
fail = "0.5"
8081
file_system = { workspace = true }
81-
fips = { workspace = true }
8282
flate2 = { version = "1.0", default-features = false, features = ["zlib"] }
8383
futures = { version = "0.3", features = ["thread-pool", "compat"] }
8484
futures-executor = "0.3.1"
@@ -243,6 +243,7 @@ members = [
243243
"components/collections",
244244
"components/concurrency_manager",
245245
"components/coprocessor_plugin_api",
246+
"components/crypto",
246247
"components/encryption",
247248
"components/encryption/export",
248249
"components/engine_rocks_helper",
@@ -252,7 +253,6 @@ members = [
252253
"components/error_code",
253254
"components/external_storage",
254255
"components/file_system",
255-
"components/fips",
256256
"components/into_other",
257257
"components/keys",
258258
"components/log_wrappers",
@@ -328,7 +328,7 @@ engine_traits_tests = { path = "components/engine_traits_tests", default-feature
328328
error_code = { path = "components/error_code" }
329329
external_storage = { path = "components/external_storage" }
330330
file_system = { path = "components/file_system" }
331-
fips = { path = "components/fips" }
331+
crypto = { path = "components/crypto" }
332332
gcp = { path = "components/cloud/gcp" }
333333
into_other = { path = "components/into_other" }
334334
keys = { path = "components/keys" }

cmd/tikv-ctl/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ clap = "2.32"
4949
collections = { workspace = true }
5050
concurrency_manager = { workspace = true }
5151
crossbeam = "0.8"
52+
crypto = { workspace = true }
5253
encryption_export = { workspace = true }
5354
engine_rocks = { workspace = true }
5455
engine_traits = { workspace = true }
5556
error_code = { workspace = true }
5657
file_system = { workspace = true }
57-
fips = { workspace = true }
5858
futures = "0.3"
5959
gag = "1.0"
6060
grpcio = { workspace = true }
@@ -72,7 +72,6 @@ raft-engine = { git = "https://github.com/tikv/raft-engine.git" }
7272
raft-engine-ctl = { git = "https://github.com/tikv/raft-engine.git" }
7373
raft_log_engine = { workspace = true }
7474
raftstore = { workspace = true }
75-
rand = "0.8"
7675
regex = "1"
7776
security = { workspace = true }
7877
serde_json = "1.0"

cmd/tikv-ctl/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use std::{
2020
};
2121

2222
use collections::HashMap;
23+
use crypto::fips;
2324
use encryption_export::{
2425
create_backend, data_key_manager_from_config, DataKeyManager, DecrypterReader, Iv,
2526
};

cmd/tikv-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ pprof-fp = ["tikv/pprof-fp"]
3434

3535
[dependencies]
3636
clap = "2.32"
37+
crypto = { workspace = true }
3738
encryption_export = { workspace = true }
3839
engine_traits = { workspace = true }
39-
fips = { workspace = true }
4040
keys = { workspace = true }
4141
kvproto = { workspace = true }
4242
raft-engine = { git = "https://github.com/tikv/raft-engine.git" }

cmd/tikv-server/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use std::{path::Path, process};
66

77
use clap::{crate_authors, App, Arg};
8+
use crypto::fips;
89
use serde_json::{Map, Value};
910
use server::setup::{ensure_no_unrecognized_config, validate_and_persist_config};
1011
use tikv::{

components/backup-stream/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ prometheus-static-metric = "0.5"
5757
protobuf = { version = "2.8", features = ["bytes"] }
5858
raft = { workspace = true }
5959
raftstore = { workspace = true }
60-
rand = "0.8.0"
6160
regex = "1"
6261
resolved_ts = { workspace = true }
6362
security = { path = "../security" }
@@ -83,6 +82,7 @@ engine_test = { workspace = true }
8382
grpcio = { workspace = true }
8483
hex = "0.4"
8584
protobuf = { version = "2.8", features = ["bytes"] }
85+
rand = "0.8.0"
8686
tempdir = "0.3"
8787
tempfile = "3.0"
8888
test_pd = { workspace = true }

components/backup/src/writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<W: SstWriter + 'static> Writer<W> {
121121
.with_label_values(&[cf.into()])
122122
.inc_by(self.total_kvs);
123123
let file_name = format!("{}_{}.sst", name, cf);
124-
let iv = Iv::new_ctr();
124+
let iv = Iv::new_ctr().map_err(|e| Error::Other(box_err!("new IV error: {:?}", e)))?;
125125
let encrypter_reader =
126126
EncrypterReader::new(sst_reader, cipher.cipher_type, &cipher.cipher_key, iv)
127127
.map_err(|e| Error::Other(box_err!("new EncrypterReader error: {:?}", e)))?;

components/fips/Cargo.toml renamed to components/crypto/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "fips"
2+
name = "crypto"
33
version = "0.0.1"
44
edition = "2021"
55
publish = false
File renamed without changes.

0 commit comments

Comments
 (0)