38e56b
diff -up firefox-91.2.0/Cargo.toml.fips-quic firefox-91.2.0/Cargo.toml
38e56b
--- firefox-91.2.0/Cargo.toml.fips-quic	2021-10-21 09:40:17.235999423 +0200
38e56b
+++ firefox-91.2.0/Cargo.toml	2021-10-21 11:21:06.746558028 +0200
38e56b
@@ -109,3 +109,12 @@ path = "third_party/rust/failure"
38e56b
 
38e56b
 [patch.crates-io.prost-derive]
38e56b
 path = "third_party/rust/prost-derive"
38e56b
+
38e56b
+[patch."https://github.com/mozilla/neqo"]
38e56b
+neqo-crypto = { path = "third_party/rust/neqo-crypto" }
38e56b
+neqo-transport = { path = "third_party/rust/neqo-transport" }
38e56b
+neqo-qpack = { path = "third_party/rust/neqo-qpack" }
38e56b
+neqo-common = { path = "third_party/rust/neqo-common" }
38e56b
+
38e56b
+
38e56b
+
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-crypto/bindings/bindings.toml.fips-quic firefox-91.2.0/third_party/rust/neqo-crypto/bindings/bindings.toml
38e56b
--- firefox-91.2.0/third_party/rust/neqo-crypto/bindings/bindings.toml.fips-quic	2021-09-28 18:41:34.000000000 +0200
38e56b
+++ firefox-91.2.0/third_party/rust/neqo-crypto/bindings/bindings.toml	2021-10-21 08:49:01.762221759 +0200
38e56b
@@ -163,7 +163,7 @@ functions = [
38e56b
     "PK11_GetKeyData",
38e56b
     "PK11_GetMechanism",
38e56b
     "PK11_HPKE_Serialize",
38e56b
-    "PK11_ImportSymKey",
38e56b
+    "PK11_ImportDataKey",
38e56b
     "PK11_ReadRawAttribute",
38e56b
     "PK11_ReferenceSymKey",
38e56b
     "SECITEM_FreeItem",
38e56b
@@ -196,11 +196,10 @@ variables = [
38e56b
     "CKM_AES_ECB",
38e56b
     "CKM_AES_GCM",
38e56b
     "CKM_EC_KEY_PAIR_GEN",
38e56b
+    "CKM_HKDF_DERIVE",
38e56b
     "CKM_INVALID_MECHANISM",
38e56b
     "CKM_NSS_CHACHA20_CTR",
38e56b
     "CKM_NSS_CHACHA20_POLY1305",
38e56b
-    "CKM_NSS_HKDF_SHA256",
38e56b
-    "CKM_NSS_HKDF_SHA384",
38e56b
     "PK11_ATTR_INSENSITIVE",
38e56b
     "PK11_ATTR_PRIVATE",
38e56b
     "PK11_ATTR_PUBLIC",
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-crypto/Cargo.toml.fips-quic firefox-91.2.0/third_party/rust/neqo-crypto/Cargo.toml
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-crypto/src/hkdf.rs.fips-quic firefox-91.2.0/third_party/rust/neqo-crypto/src/hkdf.rs
38e56b
--- firefox-91.2.0/third_party/rust/neqo-crypto/src/hkdf.rs.fips-quic	2021-09-28 18:41:44.000000000 +0200
38e56b
+++ firefox-91.2.0/third_party/rust/neqo-crypto/src/hkdf.rs	2021-10-21 08:49:01.763221763 +0200
38e56b
@@ -10,8 +10,8 @@ use crate::constants::{
38e56b
 };
38e56b
 use crate::err::{Error, Res};
38e56b
 use crate::p11::{
38e56b
-    random, Item, PK11Origin, PK11SymKey, PK11_ImportSymKey, Slot, SymKey, CKA_DERIVE,
38e56b
-    CKM_NSS_HKDF_SHA256, CKM_NSS_HKDF_SHA384, CK_ATTRIBUTE_TYPE, CK_MECHANISM_TYPE,
38e56b
+    random, Item, PK11Origin, PK11SymKey, PK11_ImportDataKey, Slot, SymKey, CKA_DERIVE,
38e56b
+    CKM_HKDF_DERIVE, CK_ATTRIBUTE_TYPE, CK_MECHANISM_TYPE,
38e56b
 };
38e56b
 
38e56b
 use std::convert::TryFrom;
38e56b
@@ -52,27 +52,22 @@ fn key_size(version: Version, cipher: Ci
38e56b
 /// # Errors
38e56b
 /// Only if NSS fails.
38e56b
 pub fn generate_key(version: Version, cipher: Cipher) -> Res<SymKey> {
38e56b
-    import_key(version, cipher, &random(key_size(version, cipher)?))
38e56b
+    import_key(version, &random(key_size(version, cipher)?))
38e56b
 }
38e56b
 
38e56b
 /// Import a symmetric key for use with HKDF.
38e56b
 ///
38e56b
 /// # Errors
38e56b
 /// Errors returned if the key buffer is an incompatible size or the NSS functions fail.
38e56b
-pub fn import_key(version: Version, cipher: Cipher, buf: &[u8]) -> Res<SymKey> {
38e56b
+pub fn import_key(version: Version, buf: &[u8]) -> Res<SymKey> {
38e56b
     if version != TLS_VERSION_1_3 {
38e56b
         return Err(Error::UnsupportedVersion);
38e56b
     }
38e56b
-    let mech = match cipher {
38e56b
-        TLS_AES_128_GCM_SHA256 | TLS_CHACHA20_POLY1305_SHA256 => CKM_NSS_HKDF_SHA256,
38e56b
-        TLS_AES_256_GCM_SHA384 => CKM_NSS_HKDF_SHA384,
38e56b
-        _ => return Err(Error::UnsupportedCipher),
38e56b
-    };
38e56b
     let slot = Slot::internal()?;
38e56b
     let key_ptr = unsafe {
38e56b
-        PK11_ImportSymKey(
38e56b
+        PK11_ImportDataKey(
38e56b
             *slot,
38e56b
-            CK_MECHANISM_TYPE::from(mech),
38e56b
+            CK_MECHANISM_TYPE::from(CKM_HKDF_DERIVE),
38e56b
             PK11Origin::PK11_OriginUnwrap,
38e56b
             CK_ATTRIBUTE_TYPE::from(CKA_DERIVE),
38e56b
             &mut Item::wrap(buf),
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-crypto/src/selfencrypt.rs.fips-quic firefox-91.2.0/third_party/rust/neqo-crypto/src/selfencrypt.rs
38e56b
--- firefox-91.2.0/third_party/rust/neqo-crypto/src/selfencrypt.rs.fips-quic	2021-09-28 18:41:41.000000000 +0200
38e56b
+++ firefox-91.2.0/third_party/rust/neqo-crypto/src/selfencrypt.rs	2021-10-21 08:49:01.763221763 +0200
38e56b
@@ -41,7 +41,7 @@ impl SelfEncrypt {
38e56b
 
38e56b
     fn make_aead(&self, k: &SymKey, salt: &[u8]) -> Res<Aead> {
38e56b
         debug_assert_eq!(salt.len(), Self::SALT_LENGTH);
38e56b
-        let salt = hkdf::import_key(self.version, self.cipher, salt)?;
38e56b
+        let salt = hkdf::import_key(self.version, salt)?;
38e56b
         let secret = hkdf::extract(self.version, self.cipher, Some(&salt), k)?;
38e56b
         Aead::new(self.version, self.cipher, &secret, "neqo self")
38e56b
     }
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-crypto/tests/aead.rs.fips-quic firefox-91.2.0/third_party/rust/neqo-crypto/tests/aead.rs
38e56b
--- firefox-91.2.0/third_party/rust/neqo-crypto/tests/aead.rs.fips-quic	2021-09-28 18:41:35.000000000 +0200
38e56b
+++ firefox-91.2.0/third_party/rust/neqo-crypto/tests/aead.rs	2021-10-21 08:49:01.764221767 +0200
38e56b
@@ -26,7 +26,6 @@ fn make_aead(cipher: Cipher) -> Aead {
38e56b
 
38e56b
     let secret = hkdf::import_key(
38e56b
         TLS_VERSION_1_3,
38e56b
-        cipher,
38e56b
         &[
38e56b
             0x47, 0xb2, 0xea, 0xea, 0x6c, 0x26, 0x6e, 0x32, 0xc0, 0x69, 0x7a, 0x9e, 0x2a, 0x89,
38e56b
             0x8b, 0xdf, 0x5c, 0x4f, 0xb3, 0xe5, 0xac, 0x34, 0xf0, 0xe5, 0x49, 0xbf, 0x2c, 0x58,
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-crypto/tests/hkdf.rs.fips-quic firefox-91.2.0/third_party/rust/neqo-crypto/tests/hkdf.rs
38e56b
--- firefox-91.2.0/third_party/rust/neqo-crypto/tests/hkdf.rs.fips-quic	2021-09-28 18:41:44.000000000 +0200
38e56b
+++ firefox-91.2.0/third_party/rust/neqo-crypto/tests/hkdf.rs	2021-10-21 08:49:01.764221767 +0200
38e56b
@@ -38,8 +38,8 @@ fn cipher_hash_len(cipher: Cipher) -> us
38e56b
 fn import_keys(cipher: Cipher) -> (SymKey, SymKey) {
38e56b
     let l = cipher_hash_len(cipher);
38e56b
     (
38e56b
-        hkdf::import_key(TLS_VERSION_1_3, cipher, &SALT[0..l]).expect("import salt"),
38e56b
-        hkdf::import_key(TLS_VERSION_1_3, cipher, &IKM[0..l]).expect("import IKM"),
38e56b
+        hkdf::import_key(TLS_VERSION_1_3, &SALT[0..l]).expect("import salt"),
38e56b
+        hkdf::import_key(TLS_VERSION_1_3, &IKM[0..l]).expect("import IKM"),
38e56b
     )
38e56b
 }
38e56b
 
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-crypto/tests/hp.rs.fips-quic firefox-91.2.0/third_party/rust/neqo-crypto/tests/hp.rs
38e56b
--- firefox-91.2.0/third_party/rust/neqo-crypto/tests/hp.rs.fips-quic	2021-09-28 18:41:44.000000000 +0200
38e56b
+++ firefox-91.2.0/third_party/rust/neqo-crypto/tests/hp.rs	2021-10-21 08:49:01.764221767 +0200
38e56b
@@ -9,7 +9,7 @@ use neqo_crypto::hp::HpKey;
38e56b
 use test_fixture::fixture_init;
38e56b
 
38e56b
 fn make_hp(cipher: Cipher) -> HpKey {
38e56b
-    let ikm = hkdf::import_key(TLS_VERSION_1_3, cipher, &[;; 16]).expect("import IKM");
38e56b
+    let ikm = hkdf::import_key(TLS_VERSION_1_3, &[;; 16]).expect("import IKM");
38e56b
     let prk = hkdf::extract(TLS_VERSION_1_3, cipher, None, &ikm).expect("extract works");
38e56b
     HpKey::extract(TLS_VERSION_1_3, cipher, &prk, "hp").expect("extract label works")
38e56b
 }
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-http3/Cargo.toml.fips-quic firefox-91.2.0/third_party/rust/neqo-http3/Cargo.toml
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-qpack/Cargo.toml.fips-quic firefox-91.2.0/third_party/rust/neqo-qpack/Cargo.toml
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-transport/Cargo.toml.fips-quic firefox-91.2.0/third_party/rust/neqo-transport/Cargo.toml
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-transport/src/crypto.rs.fips-quic firefox-91.2.0/third_party/rust/neqo-transport/src/crypto.rs
38e56b
--- firefox-91.2.0/third_party/rust/neqo-transport/src/crypto.rs.fips-quic	2021-09-28 18:41:44.000000000 +0200
38e56b
+++ firefox-91.2.0/third_party/rust/neqo-transport/src/crypto.rs	2021-10-21 08:49:01.765221771 +0200
38e56b
@@ -432,14 +432,8 @@ impl CryptoDxState {
38e56b
         let initial_secret = hkdf::extract(
38e56b
             TLS_VERSION_1_3,
38e56b
             cipher,
38e56b
-            Some(
38e56b
-                hkdf::import_key(TLS_VERSION_1_3, cipher, salt)
38e56b
-                    .as_ref()
38e56b
-                    .unwrap(),
38e56b
-            ),
38e56b
-            hkdf::import_key(TLS_VERSION_1_3, cipher, dcid)
38e56b
-                .as_ref()
38e56b
-                .unwrap(),
38e56b
+            Some(hkdf::import_key(TLS_VERSION_1_3, salt).as_ref().unwrap()),
38e56b
+            hkdf::import_key(TLS_VERSION_1_3, dcid).as_ref().unwrap(),
38e56b
         )
38e56b
         .unwrap();
38e56b
 
38e56b
@@ -1094,8 +1088,7 @@ impl CryptoStates {
38e56b
         let app_read = |epoch| CryptoDxAppData {
38e56b
             dx: read(epoch),
38e56b
             cipher: TLS_AES_128_GCM_SHA256,
38e56b
-            next_secret: hkdf::import_key(TLS_VERSION_1_3, TLS_AES_128_GCM_SHA256, &[0xaa; 32])
38e56b
-                .unwrap(),
38e56b
+            next_secret: hkdf::import_key(TLS_VERSION_1_3, &[0xaa; 32]).unwrap(),
38e56b
         };
38e56b
         Self {
38e56b
             initial: Some(CryptoState {
38e56b
@@ -1120,8 +1113,7 @@ impl CryptoStates {
38e56b
             0x00, 0xa1, 0x54, 0x43, 0xf1, 0x82, 0x03, 0xa0, 0x7d, 0x60, 0x60, 0xf6, 0x88, 0xf3,
38e56b
             0x0f, 0x21, 0x63, 0x2b,
38e56b
         ];
38e56b
-        let secret =
38e56b
-            hkdf::import_key(TLS_VERSION_1_3, TLS_CHACHA20_POLY1305_SHA256, SECRET).unwrap();
38e56b
+        let secret = hkdf::import_key(TLS_VERSION_1_3, SECRET).unwrap();
38e56b
         let app_read = |epoch| CryptoDxAppData {
38e56b
             dx: CryptoDxState {
38e56b
                 direction: CryptoDxDirection::Read,
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-transport/src/packet/retry.rs.fips-quic firefox-91.2.0/third_party/rust/neqo-transport/src/packet/retry.rs
38e56b
--- firefox-91.2.0/third_party/rust/neqo-transport/src/packet/retry.rs.fips-quic	2021-09-28 18:41:34.000000000 +0200
38e56b
+++ firefox-91.2.0/third_party/rust/neqo-transport/src/packet/retry.rs	2021-10-21 08:49:01.766221775 +0200
38e56b
@@ -28,7 +28,7 @@ fn make_aead(secret: &[u8]) -> Aead {
38e56b
     #[cfg(debug_assertions)]
38e56b
     ::neqo_crypto::assert_initialized();
38e56b
 
38e56b
-    let secret = hkdf::import_key(TLS_VERSION_1_3, TLS_AES_128_GCM_SHA256, secret).unwrap();
38e56b
+    let secret = hkdf::import_key(TLS_VERSION_1_3, secret).unwrap();
38e56b
     Aead::new(TLS_VERSION_1_3, TLS_AES_128_GCM_SHA256, &secret, "quic ").unwrap()
38e56b
 }
38e56b
 thread_local!(static RETRY_AEAD_29: RefCell<Aead> = RefCell::new(make_aead(RETRY_SECRET_29)));
38e56b
diff -up firefox-91.2.0/third_party/rust/neqo-transport/tests/common/mod.rs.fips-quic firefox-91.2.0/third_party/rust/neqo-transport/tests/common/mod.rs
38e56b
--- firefox-91.2.0/third_party/rust/neqo-transport/tests/common/mod.rs.fips-quic	2021-09-28 18:41:34.000000000 +0200
38e56b
+++ firefox-91.2.0/third_party/rust/neqo-transport/tests/common/mod.rs	2021-10-21 08:49:01.766221775 +0200
38e56b
@@ -121,13 +121,11 @@ pub fn client_initial_aead_and_hp(dcid:
38e56b
         TLS_VERSION_1_3,
38e56b
         TLS_AES_128_GCM_SHA256,
38e56b
         Some(
38e56b
-            hkdf::import_key(TLS_VERSION_1_3, TLS_AES_128_GCM_SHA256, INITIAL_SALT)
38e56b
+            hkdf::import_key(TLS_VERSION_1_3, INITIAL_SALT)
38e56b
                 .as_ref()
38e56b
                 .unwrap(),
38e56b
         ),
38e56b
-        hkdf::import_key(TLS_VERSION_1_3, TLS_AES_128_GCM_SHA256, dcid)
38e56b
-            .as_ref()
38e56b
-            .unwrap(),
38e56b
+        hkdf::import_key(TLS_VERSION_1_3, dcid).as_ref().unwrap(),
38e56b
     )
38e56b
     .unwrap();
38e56b