Skip to content

Adapt to nss-rs key_data() returning a slice - #378

Open
mxinden wants to merge 2 commits into
mozilla:ctap2-2021from
mxinden-bot:nss-rs-0.16-key-data
Open

mxinden wants to merge 2 commits into
mozilla:ctap2-2021from
mxinden-bot:nss-rs-0.16-key-data

Conversation

@mxinden

@mxinden mxinden commented Sep 22, 2026

Copy link
Copy Markdown
Member

nss-rs 0.16 changes the public key key_data() accessor to return &[u8] instead of Vec<u8>. Call .to_vec() at the two use sites. This also builds against older nss-rs, where key_data() returns Vec<u8>. In addition nss-rs no longer exposes AES_BLOCK_SIZE. Instead, definition is pulled into authenticator-rs.

For future similar changes in nss-rs, I suggest adding a new method, e.g. key_data_borrowed, leaving the old (here key_data) as is, thus not introducing a breaking change.

Includes a second commit to bump the crate version to v0.6.1. @jschanck let me know if you would prefer a separate pull request.

nss-rs 0.16 changes the public key key_data() accessor to return &[u8]
instead of Vec<u8>, and drops the p11 re-export of AES_BLOCK_SIZE. Call
.to_vec() at the two key_data() sites and use a literal AES block size
(as the openssl backend already does). This builds against both older
and newer nss-rs.
@mxinden
mxinden marked this pull request as ready for review September 22, 2026 11:12
Comment thread src/crypto/nss.rs

// nss-rs exposes these as raw bindgen u32 constants; shadow as usize for ergonomic use.
const AES_BLOCK_SIZE: usize = nss_rs::p11::AES_BLOCK_SIZE as usize;
const AES_BLOCK_SIZE: usize = 16;

@micolous micolous Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I wonder if this is a similar issue to https://bugzilla.mozilla.org/show_bug.cgi?id=2071649, triggered by https://phabricator.services.mozilla.com/D319399, and needs a fix in nss-rs instead?

(Though this would also need an nss-rs release with that fix, so we can accept this for 0.16.1.)

Comment thread Cargo.toml
# Crypto backends
openssl-sys = { version = "0.9", optional = true}
openssl = { version = "0.10", optional = true}
nss-rs = { git = "https://github.com/mozilla/nss-rs", version = ">=0.12", optional = true }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nss-rs dependency specifier needs to be updated as well, ideally pointing at mozilla/nss-rs@ba8a3f6 (the 0.16.1 release), as otherwise it'll pull from HEAD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants