Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3baa30b
squash merge of ML-DSA and ML-KEM testing work
ounsworth Jun 4, 2026
f27f05e
wycheproof tests passing for all of mlsda and mlkem
ounsworth Jun 5, 2026
ee08427
brought 0.1.2alpha todo list from main
ounsworth Jun 7, 2026
8022962
Merging Quant-TheodoreFelix's improvement to ct::Condition<u64>. Clos…
ounsworth Jun 8, 2026
ef214a6
출력 버퍼 zeroize 추가
Quant-TheodoreFelix Jun 9, 2026
c642ef6
리뷰 반영
Quant-TheodoreFelix Jun 10, 2026
b3a22ae
Merge branch 'Quant-TheodoreFelix-qtfelix/0.1.2alpha-zeroize-out-buff…
ounsworth Jun 10, 2026
58d49b8
Merge branch 'Quant-TheodoreFelix-qtfelix/0.1.2alpha-zeroize-out-buff…
ounsworth Jun 10, 2026
8c86076
Merge branch 'release/0.1.2alpha' of git.bouncycastle.org:bc-rust int…
ounsworth Jun 10, 2026
f828c02
tweaked todo list
ounsworth Jun 11, 2026
e7eafba
dir rename to use hyphen instead of underscore
ounsworth Jun 11, 2026
d82041b
Various small refactoring tasks:
ounsworth Jun 22, 2026
e8e6677
improvements to KeyMaterial. Closes #38
ounsworth Jun 22, 2026
a2ecff9
Fixed a couple of minor docs bugs
ounsworth Jun 24, 2026
1dc4f67
rename mut_ref_to_bytes to ref_to_bytes_mut for idiomatic Rust #41
ounsworth Jun 24, 2026
ecced8d
Remove DEFAULT_HASH_NAME constants and eliminate unwrap() in HashFact…
nikolapajkovsky Jun 26, 2026
9091617
Remove DEFAULT_KDF_NAME constants and eliminate unwrap() in KDFFactor…
nikolapajkovsky Jun 26, 2026
bda139f
Remove DEFAULT_KDF_NAME constants and eliminate unwrap() in KDFFactor…
nikolapajkovsky Jun 26, 2026
09b9f53
Eliminate unwrap() and assert!() in ML-DSA signature verification
nikolapajkovsky Jun 26, 2026
ceb471f
Added a closure-based do_hazardous_operations(). Closes #39
ounsworth Jun 26, 2026
6ee1bf7
Removal of .unwrap() and .expect() in library code. Closes #42.
ounsworth Jun 26, 2026
935c5c0
Add missing tests from PR #43
officialfrancismendoza Jun 30, 2026
4035351
Renamed KeyType and deleted KeyMaterial::concatenate. Closes #47
ounsworth Jul 1, 2026
bbfaab3
Merge branch 'release/0.1.2alpha' of ssh://git.bouncycastle.org/bc-ru…
officialfrancismendoza Jul 1, 2026
2d0b7f3
Renamed KeyType and deleted KeyMaterial::concatenate. Closes #47
officialfrancismendoza Jul 1, 2026
19ea35f
initial trait defn for SerializableState
ounsworth Jul 1, 2026
64365de
sha2 impls SerializableState
ounsworth Jul 1, 2026
f75bc5d
rustfmt
ounsworth Jul 1, 2026
54f93f6
Incorporating Nikola and David's feedback
ounsworth Jul 6, 2026
46100d3
An in-progress SHA3 object can now be serialized
ounsworth Jul 6, 2026
6b3ecec
Impl'd SerializableState for MLDSA, and some quality-of-life fixes fo…
ounsworth Jul 6, 2026
d7192dd
rustfmt
ounsworth Jul 6, 2026
45ba742
Impl'd SerializableState for MLDSA-lowmemory.
ounsworth Jul 6, 2026
3e1ce14
Merge branch 'release/0.1.2alpha' into feature/serialize_state
ounsworth Jul 6, 2026
d9b06bd
Impl'd SerializableKeyedState for HMAC.
ounsworth Jul 7, 2026
e464f68
Fixed a bug in HMAC that could cause panics.
ounsworth Jul 7, 2026
937d859
Implemented Suspendable for HKDF and a bunch of other tidy-up.
ounsworth Jul 7, 2026
1dacaa2
rustfmt
ounsworth Jul 8, 2026
07889fc
HMAC now impl's Drop like it should.
ounsworth Jul 8, 2026
3c8d64b
Adjusted the Suspendable version checker to allow future versions fro…
ounsworth Jul 9, 2026
fd17f91
HKDF now explicitly carries a lib_ver tag
ounsworth Jul 9, 2026
03a0d93
Feature branch diversion from feature/serialize_state where we change…
officialfrancismendoza Jul 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions .github/workflows/publish_doc_benches_to_ghpages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,22 @@ jobs:
with:
name: code_quality_stats
path: ./code_stats.txt
run_benches:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- run: cargo bench --all
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: bc-rust-benches
path: ./target/criterion
# the benches run crazy slow on the github agent. So there's really no point because it's not useful data.
# run_benches:
# runs-on: ubuntu-latest
# if: github.ref == 'refs/heads/main'
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - run: cargo bench --all
# - name: Save artifacts
# uses: actions/upload-artifact@v4
# with:
# name: bc-rust-benches
# path: ./target/criterion
collect_ghpages:
if: github.ref == 'refs/heads/main'
needs: [build_docs, code_stats, run_benches]
needs: [build_docs, code_stats]
runs-on: ubuntu-latest
steps:
- run: mkdir ./gh-pages
Expand All @@ -65,11 +66,11 @@ jobs:
with:
name: code_quality_stats
path: ./gh-pages/
- name: Get benches from previous job
uses: actions/download-artifact@v4
with:
name: bc-rust-benches
path: ./gh-pages/benches
# - name: Get benches from previous job
# uses: actions/download-artifact@v4
# with:
# name: bc-rust-benches
# path: ./gh-pages/benches
- name: Archive Compatibility Matrix For Download
uses: actions/upload-pages-artifact@v3
with:
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/rust-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Rust Style

on:
pull_request:

permissions:
contents: read

concurrency:
group: rust-style-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
rustfmt:
if: github.repository == 'bcgit/bc-rust'
name: rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install nightly rustfmt
run: |
rustup toolchain install nightly --profile minimal --component rustfmt
rustup override set nightly

- name: Check formatting
run: cargo fmt --all --check
19 changes: 18 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ before posting anything public. See [Security Policy](SECURITY.md).

If a related discussion or issue doesn't exist, and the issue is not security related, you can [open a new issue](https://github.com/bcgit/bc-java/issues/new). An issue can be converted into a discussion if regarded as one.

## Coding philosophy

> Slow is smooth, smooth is fast.
There is a time and a place for "Move fast and break things", but the source code of a crypto library is not one of them.

This project takes the philosophy that taking the time to do things right pays off in the long run, both in terms of
the runtime and memory footprint of the code, and it terms of the time required for a future maintainer to get up to speed with the code
and avoid introducing bugs due to the code being hard to understand.

Some specifics:

* Respect that the innovative process sometimes requires exploring several dead-ends before you find the most elegant solution.
* Public APIs of a library should be both ergonomic and expressive. When defining a new trait or public function, ask yourself whether a programmer who is new to cryptography is likely to use this in a way that will get them into trouble.
* Variables should be well-named, well-structured, and well-commented (a comment-to-code ration of 1:1 is a goal to be strived for!). Think about memory footprint and, where possible, use unnamed scopes to allow the compiler to pop intermediate value variables off the stack as soon as they are no longer needed.
* Always run your code through `cargo mutants` and get the issue count as low as your can. As a first pass, this forces you to write thorough unit tests. As a second pass, this draws your attention to bits of your code that cannot be tested from the outside. Often this means that the code can be simplified without affecting functionality (as defined by your set of unit tests) -- "simpler code" usually means faster runtime and easier future maintenance.

## Contribute to the code

For substantial, non-trivial contributions, you may be asked to sign a contributor assignment agreement. Optionally, you can also have your name and contact information listed in [Contributors](https://www.bouncycastle.org/contributors.html).
Expand Down Expand Up @@ -56,5 +73,5 @@ Don't forget to self-review. Please follow these simple guidelines:

#### Your pull request is merged

For acceptance, pull requests need to meet specific quality criteria, including tests for anything substantial. Someone on the Bouncy Castle core team will review the pull request when there is time, and let you know if something is missing or suggest improvements. If it is a useful and generic feature it will be integrated in Bouncy Castle to be available in a later release.
Someone on the Bouncy Castle core team will review the pull request when there is time, and let you know if something is missing or suggest improvements. If it is a useful and generic feature it will be integrated in Bouncy Castle to be available in a later release.

38 changes: 22 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = [ "cli", "crypto/*", "mem_usage_benches" ]
members = ["cli", "crypto/*", "mem_usage_benches"]

[workspace.package]
edition = "2024"
Expand All @@ -8,21 +8,24 @@ edition = "2024"

# *** Internal Dependencies ***
bouncycastle = { path = "./", version = "0.1.1" }
bouncycastle-base64 = { path = "./crypto/base64", version = "0.1.1"}
bouncycastle-core = { path = "crypto/core", version = "0.1.1" }
bouncycastle-core-test-framework = { path = "./crypto/core-test-framework", version = "0.1.1"}
bouncycastle-factory = { path = "./crypto/factory", version = "0.1.1"}
bouncycastle-base64 = { path = "./crypto/base64", version = "0.1.1" }
# `default-features = false` here (rather than on each member) is required so that individual
# crates can opt out of the `alloc` feature for `no_std` builds; members re-enable it through
# their own `alloc` feature. Building the whole workspace keeps `alloc` on via feature unification.
bouncycastle-core = { path = "crypto/core", version = "0.1.1", default-features = false }
bouncycastle-core-test-framework = { path = "./crypto/core-test-framework", version = "0.1.1" }
bouncycastle-factory = { path = "./crypto/factory", version = "0.1.1" }
bouncycastle-hex = { path = "./crypto/hex", version = "0.1.1" }
bouncycastle-hkdf = { path = "./crypto/hkdf", version = "0.1.1"}
bouncycastle-hmac = { path = "./crypto/hmac", version = "0.1.1"}
bouncycastle-hkdf = { path = "./crypto/hkdf", version = "0.1.1" }
bouncycastle-hmac = { path = "./crypto/hmac", version = "0.1.1", default-features = false }
bouncycastle-mlkem = { path = "./crypto/mlkem", version = "0.1.2" }
bouncycastle-mlkem-lowmemory = { path = "./crypto/mlkem_lowmemory", version = "0.1.2" }
bouncycastle-mlkem-lowmemory = { path = "./crypto/mlkem-lowmemory", version = "0.1.2" }
bouncycastle-mldsa = { path = "./crypto/mldsa", version = "0.1.2" }
bouncycastle-mldsa-lowmemory = { path = "./crypto/mldsa_lowmemory", version = "0.1.2" }
bouncycastle-mldsa-lowmemory = { path = "./crypto/mldsa-lowmemory", version = "0.1.2" }
bouncycastle-rng = { path = "./crypto/rng", version = "0.1.1" }
bouncycastle-sha2 = { path = "./crypto/sha2", version = "0.1.1"}
bouncycastle-sha3 = { path = "./crypto/sha3", version = "0.1.1"}
bouncycastle-utils = { path = "./crypto/utils", version = "0.1.1"}
bouncycastle-sha2 = { path = "./crypto/sha2", version = "0.1.1", default-features = false }
bouncycastle-sha3 = { path = "./crypto/sha3", version = "0.1.1", default-features = false }
bouncycastle-utils = { path = "./crypto/utils", version = "0.1.1" }


# *** External Dependencies ***
Expand All @@ -39,17 +42,20 @@ name = "bouncycastle"
version = "0.1.2"
edition.workspace = true

# The umbrella crate re-exports the whole library for downstream users who want everything in one
# dependency, so it enables `alloc` on the primitive crates whose workspace deps default it off.
# (base64/hex/hkdf/rng/factory already default `alloc` on.)
[dependencies]
bouncycastle-base64.workspace = true
bouncycastle-core.workspace = true
bouncycastle-core = { workspace = true, features = ["alloc"] }
bouncycastle-factory.workspace = true
bouncycastle-hex.workspace = true
bouncycastle-hkdf.workspace = true
bouncycastle-hmac.workspace = true
bouncycastle-hmac = { workspace = true, features = ["alloc"] }
bouncycastle-mldsa.workspace = true
bouncycastle-mldsa-lowmemory.workspace = true
bouncycastle-mlkem.workspace = true
bouncycastle-mlkem-lowmemory.workspace = true
bouncycastle-rng.workspace = true
bouncycastle-sha2.workspace = true
bouncycastle-sha3.workspace = true
bouncycastle-sha2 = { workspace = true, features = ["alloc"] }
bouncycastle-sha3 = { workspace = true, features = ["alloc"] }
4 changes: 2 additions & 2 deletions INTRODUCTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ While the `KeyMaterial` is fundamentally just a buffer of bytes, it tracks many

The `KeyMaterial` object is used consistently across the library and any functions that manipulate a key material object will properly update the metadata to track any changes made to the key's entropy or security strength. For example, a `KeyMaterial512{ key_type: MACKey, security_strength: _256bit}` will have its security strength downgraded to 128 bit if you pass it through a SHA256-based KDF, indicating that it is no longer sufficient to generate a full-strength AES256 or ML-DSA-87.

Of course, there will always be things developers need to do that the library did not provide a utility function for, for example, you may actually need an all-zero MACKey in order to implement certain standardized MAC algorithms. To the end, the library will allow you to, for example, force a key type to any full-entropy key type and security strength, or even get a direct immutable or mutable reference to the underlying buffer via `.ref_to_bytes()` and `mut_ref_to_bytes()`, but only with use of the `allow_hazardous_operations` flag:
Of course, there will always be things developers need to do that the library did not provide a utility function for, for example, you may actually need an all-zero MACKey in order to implement certain standardized MAC algorithms. To the end, the library will allow you to, for example, force a key type to any full-entropy key type and security strength, or even get a direct immutable or mutable reference to the underlying buffer via `.ref_to_bytes()` and `ref_to_bytes_mut()`, but only with use of the `allow_hazardous_operations` flag:

```rust
key.allow_hazardous_operations();
Expand Down Expand Up @@ -202,4 +202,4 @@ As this is an alpha release, we're eagerly looking for feedback from the communi
You can reach us at <some email address>

Sincerely,
Mike Ounsworth (lead maintainer of BC-Rust), on behalf of the Legion of the Bouncy Castle and the entire Bouncy Castle community
Mike Ounsworth (lead maintainer of BC-Rust), on behalf of the Legion of the Bouncy Castle and the entire Bouncy Castle community
Loading