Skip to content

Instantly share code, notes, and snippets.

@josephlr
Created June 19, 2019 21:48
Show Gist options
  • Save josephlr/ab94c1c3060be0b5c13c86b66e5a35dc to your computer and use it in GitHub Desktop.
Save josephlr/ab94c1c3060be0b5c13c86b66e5a35dc to your computer and use it in GitHub Desktop.
Bazel BUILD file for Ring (x86_64-unknown-linux-gnu)
package(default_visibility = ["//visibility:private"])
licenses(["notice"]) # ISC-style
load("@io_bazel_rules_rust//rust:rust.bzl",
"rust_library",
"rust_binary",
"rust_test",
)
## Third Party
cc_library(
name = "fiat",
srcs = glob(["third_party/fiat/*." + ext for ext in ["h", "c"]]),
deps = [":gfp_headers"],
)
filegroup(
name = "nist",
srcs = glob(["third_party/NIST/SHAVS/*.rsp"]),
)
## TODO: BoringSSL-Bazel currently just commits the generated .S files
filegroup(
name = "asm_files",
srcs = glob(["pregenerated/*.S"]),
)
## C Code
cc_library(
name = "gfp_headers",
hdrs = ["crypto/internal.h"] + glob(["include/GFp/*.h"]),
includes = ["include"],
)
cc_library(
name = "crypto",
srcs = [
"crypto/fipsmodule/bn/internal.h",
"crypto/fipsmodule/ec/ecp_nistz256_table.inl",
"crypto/fipsmodule/ec/ecp_nistz384.inl",
"crypto/fipsmodule/ec/ecp_nistz.h",
"crypto/fipsmodule/ec/ecp_nistz384.h",
"crypto/fipsmodule/ec/ecp_nistz256.h",
"crypto/limbs/limbs.h",
"crypto/limbs/limbs.inl",
"crypto/fipsmodule/modes/internal.h",
] + [
"crypto/fipsmodule/bn/generic.c",
"crypto/fipsmodule/bn/montgomery.c",
"crypto/fipsmodule/bn/montgomery_inv.c",
"crypto/crypto.c",
"crypto/fipsmodule/ec/ecp_nistz.c",
"crypto/fipsmodule/ec/ecp_nistz256.c",
"crypto/fipsmodule/ec/gfp_p256.c",
"crypto/fipsmodule/ec/gfp_p384.c",
"crypto/limbs/limbs.c",
"crypto/mem.c",
"crypto/fipsmodule/modes/gcm.c",
"crypto/cpu-intel.c",
] + [
"crypto/constant_time_test.c",
] + [":asm_files"],
deps = [":gfp_headers"],
)
## Rust Code
rust_library(
name = "ring",
srcs = glob(["src/**/*.rs"]),
data = glob(["src/**/*.der"]),
deps = [
":crypto",
":fiat",
"//cargo:lazy_static",
"//cargo:libc",
"//cargo:spin",
"//cargo:untrusted",
],
visibility = ["//visibility:public"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
rust_test(
name = "unit_tests",
crate = ":ring",
data = [
"crypto/fipsmodule/ecdsa/ecdsa_verify_tests.txt",
] + glob(["src/**/*.der", "src/**/*.txt"]),
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
## Integration Tests
rust_test(
name = "aead_tests",
srcs = ["tests/aead_tests.rs"],
data = glob(["tests/aead_*.txt"]),
deps = [":ring"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
rust_test(
name = "agreement_tests",
srcs = ["tests/agreement_tests.rs"],
data = glob(["tests/agreement_*.txt"]),
deps = [":ring"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
rust_test(
name = "digest_tests",
srcs = ["tests/digest_tests.rs"],
data = [":nist"] + glob(["tests/digest_*.txt"]),
deps = [":ring"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
rust_test(
name = "ecdsa_tests",
srcs = ["tests/ecdsa_tests.rs"],
data = glob(["tests/ecdsa_*." + ext for ext in ["der", "p8", "txt"]]),
deps = [":ring", "//cargo:untrusted"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
rust_test(
name = "ed25519_tests",
srcs = ["tests/ed25519_tests.rs"],
data = glob(["tests/ed25519_*." + ext for ext in ["bin", "der", "p8", "txt"]]),
deps = [":ring", "//cargo:untrusted"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
rust_test(
name = "hkdf_tests",
srcs = ["tests/hkdf_tests.rs"],
data = glob(["tests/hkdf_*.txt"]),
deps = [":ring"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
rust_test(
name = "hmac_tests",
srcs = ["tests/hmac_tests.rs"],
data = glob(["tests/hmac_*.txt"]),
deps = [":ring"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
rust_test(
name = "pbkdf2_tests",
srcs = ["tests/pbkdf2_tests.rs"],
data = glob(["tests/pbkdf2_*.txt"]),
deps = [":ring"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
rust_test(
name = "quic_tests",
srcs = ["tests/quic_tests.rs"],
data = glob(["tests/quic_*.txt"]),
deps = [":ring"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
rust_test(
name = "rand_tests",
srcs = ["tests/rand_tests.rs"],
deps = [":ring"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
rust_test(
name = "rsa_tests",
srcs = ["tests/rsa_tests.rs"],
data = glob(["tests/rsa_*." + ext for ext in ["der", "p8", "txt"]]),
deps = [":ring", "//cargo:untrusted"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
rust_test(
name = "signature_tests",
srcs = ["tests/signature_tests.rs"],
deps = [":ring"],
edition = "2018",
crate_features = ["dev_urandom_fallback", "use_heap"],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment