build fixes
- Commit
aee3dd456553d50a612e2510830c4880709dfe46- Author
- vayun-mathur <[email protected]>
- When
- 2026-10-27 04:28 UTC (1 month ago)
- Parents
1073d4e
Diff
communicate/src/main/java/com/vayunmathur/communicate/ui/DialPad.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/ui/DialPad.kt b/communicate/src/main/java/com/vayunmathur/communicate/ui/DialPad.ktnew file mode 100644index 0000000000..7b65fd1436--- /dev/null+++ b/communicate/src/main/java/com/vayunmathur/communicate/ui/DialPad.kt@@ -0,0 +1,134 @@+package com.vayunmathur.communicate.ui++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.vayunmathur.communicate.R+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.library.ui.FilledIconButton+import com.vayunmathur.library.ui.IconBackspace+import com.vayunmathur.library.ui.IconCall+import com.vayunmathur.library.ui.IconPaste+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton++@Composable+fun DialPad(+ number: String,+ onAppend: (String) -> Unit,+ onBackspace: () -> Unit,+ onClear: () -> Unit,+ onPaste: () -> Unit,+ onCall: () -> Unit,+) {+ // Letters are the physical keycap markings from ITU E.161, not translatable copy.+ val keys = listOf(+ listOf("1" to "", "2" to "ABC", "3" to "DEF"),+ listOf("4" to "GHI", "5" to "JKL", "6" to "MNO"),+ listOf("7" to "PQRS", "8" to "TUV", "9" to "WXYZ"),+ listOf("*" to "", "0" to "", "#" to ""),+ )+ Surface(+ tonalElevation = 2.dp,+ modifier = Modifier.fillMaxWidth(),+ ) {+ Column(+ modifier = Modifier+ .fillMaxWidth()+ .padding(horizontal = 16.dp, vertical = 10.dp),+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.spacedBy(6.dp),+ ) {+ Row(+ modifier = Modifier.fillMaxWidth(),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ Text(+ text = number.ifEmpty { stringResource(R.string.phone_number) },+ style = MaterialTheme.typography.headlineSmall,+ color = if (number.isEmpty()) MaterialTheme.colorScheme.onSurfaceVariant else MaterialTheme.colorScheme.onSurface,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ modifier = Modifier.weight(1f),+ textAlign = TextAlign.Center,+ )+ IconButton(onClick = onPaste) {+ IconPaste()+ }+ }+ keys.forEach { row ->+ Row(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ row.forEach { (digit, letters) ->+ DialKey(+ digit = digit,+ letters = letters,+ onClick = { onAppend(digit) },+ modifier = Modifier.weight(1f),+ )+ }+ }+ }+ Row(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(8.dp),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ TextButton(onClick = onClear, enabled = number.isNotEmpty(), modifier = Modifier.weight(1f)) {+ Text(stringResource(UiR.string.clear))+ }+ FilledIconButton(onClick = onCall, enabled = number.isNotBlank(), modifier = Modifier.size(52.dp)) {+ IconCall()+ }+ IconButton(onClick = onBackspace, enabled = number.isNotEmpty(), modifier = Modifier.weight(1f)) {+ IconBackspace()+ }+ }+ }+ }+}++@Composable+private fun DialKey(digit: String, letters: String, onClick: () -> Unit, modifier: Modifier = Modifier) {+ Surface(+ onClick = onClick,+ shape = RoundedCornerShape(14.dp),+ color = MaterialTheme.colorScheme.surfaceVariant,+ modifier = modifier.height(52.dp),+ ) {+ Column(+ modifier = Modifier.fillMaxSize(),+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.Center,+ ) {+ Text(digit, style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.Medium)+ if (letters.isNotEmpty()) {+ Text(+ letters,+ style = MaterialTheme.typography.labelSmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ maxLines = 1,+ )+ }+ }+ }+}
communicate/src/main/java/com/vayunmathur/communicate/ui/DialerContent.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/ui/DialerContent.kt b/communicate/src/main/java/com/vayunmathur/communicate/ui/DialerContent.ktnew file mode 100644index 0000000000..044f64da3a--- /dev/null+++ b/communicate/src/main/java/com/vayunmathur/communicate/ui/DialerContent.kt@@ -0,0 +1,152 @@+package com.vayunmathur.communicate.ui++import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.shape.CircleShape+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.platform.LocalClipboard+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.vayunmathur.communicate.R+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.communicate.data.CommunicateContact+import com.vayunmathur.communicate.data.T9+import com.vayunmathur.library.ui.EmptyState+import com.vayunmathur.library.ui.IconCall+import com.vayunmathur.library.ui.IconContacts+import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.ListItemDefaults+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import kotlinx.coroutines.launch++/**+ * Dialer list plus pad, stateless apart from the entered number: contacts,+ * lines and placement come in as parameters so screenshot previews can render+ * without the SIM/session providers, the role and permission gates, or the+ * contact content provider above.+ */+@Composable+fun DialerContent(+ contacts: List<CommunicateContact>,+ onPlace: (String) -> Unit,+ modifier: Modifier = Modifier,+) {+ var number by remember { mutableStateOf("") }+ val context = LocalContext.current+ val clipboard = LocalClipboard.current+ val scope = rememberCoroutineScope()+ // Keyed on the contact list only: the query must never re-run the provider query.+ val entries = remember(contacts) { contacts.map { T9.entryFor(it.name, it.phoneNumber) } }+ val query = T9.normalizeQuery(number)+ val filtered = remember(contacts, query) {+ if (query.isEmpty()) contacts+ else contacts.filterIndexed { index, _ -> T9.matches(entries[index], query) }+ }+ Column(modifier = modifier.fillMaxSize()) {+ if (contacts.isEmpty()) {+ EmptyState(+ title = stringResource(R.string.empty_contacts),+ icon = { IconContacts() },+ modifier = Modifier.weight(1f),+ )+ } else if (filtered.isEmpty()) {+ EmptyState(+ title = stringResource(R.string.empty_contacts_for_digits),+ icon = { IconContacts() },+ modifier = Modifier.weight(1f),+ )+ } else {+ LazyColumn(+ modifier = Modifier.weight(1f),+ contentPadding = PaddingValues(bottom = 8.dp),+ ) {+ item {+ Text(+ stringResource(UiR.string.contacts),+ modifier = Modifier.padding(horizontal = 20.dp, vertical = 12.dp),+ style = MaterialTheme.typography.titleMedium,+ fontWeight = FontWeight.SemiBold,+ )+ }+ items(filtered, key = { "${it.id}-${it.phoneNumber}" }) { contact ->+ ContactRow(contact) {+ onPlace(contact.phoneNumber)+ }+ }+ }+ }+ DialPad(+ number = number,+ onAppend = { number += it },+ onBackspace = { number = number.dropLast(1) },+ onClear = { number = "" },+ onPaste = {+ scope.launch {+ val pasted = clipboard.getClipEntry()+ ?.clipData+ ?.getItemAt(0)+ ?.coerceToText(context)+ ?.toString()+ .orEmpty()+ .filter { it.isDigit() || it == '+' || it == '*' || it == '#' }+ if (pasted.isNotBlank()) number = pasted+ }+ },+ onCall = { onPlace(number) },+ )+ }+}++@Composable+private fun ContactRow(contact: CommunicateContact, onClick: () -> Unit) {+ ListItem(+ content = {+ Text(+ contact.name,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ fontWeight = FontWeight.Medium,+ )+ },+ supportingContent = { Text("${contact.label} ${contact.phoneNumber}", maxLines = 1) },+ leadingContent = {+ Box(+ modifier = Modifier+ .size(40.dp)+ .clip(CircleShape)+ .background(MaterialTheme.colorScheme.primaryContainer),+ contentAlignment = Alignment.Center,+ ) {+ Text(+ initialsFor(contact.name),+ color = MaterialTheme.colorScheme.onPrimaryContainer,+ fontWeight = FontWeight.SemiBold,+ )+ }+ },+ trailingContent = { IconCall() },+ colors = ListItemDefaults.colors(containerColor = Color.Transparent),+ modifier = Modifier.clickable(onClick = onClick),+ )+}
communicate/src/main/java/com/vayunmathur/communicate/ui/DialerScreen.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/ui/DialerScreen.kt b/communicate/src/main/java/com/vayunmathur/communicate/ui/DialerScreen.ktindex ffd028b030..36d436fca3 100644--- a/communicate/src/main/java/com/vayunmathur/communicate/ui/DialerScreen.kt+++ b/communicate/src/main/java/com/vayunmathur/communicate/ui/DialerScreen.kt@@ -1,72 +1,32 @@ package com.vayunmathur.communicate.ui import android.Manifest-import androidx.compose.foundation.background-import androidx.compose.foundation.clickable-import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.PaddingValues-import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.size-import androidx.compose.foundation.lazy.LazyColumn-import androidx.compose.foundation.lazy.items-import androidx.compose.foundation.shape.CircleShape-import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.produceState import androidx.compose.runtime.remember-import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue-import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier-import androidx.compose.ui.draw.clip-import androidx.compose.ui.graphics.Color-import androidx.compose.ui.platform.LocalClipboard import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource-import androidx.compose.ui.text.font.FontWeight-import androidx.compose.ui.text.style.TextAlign-import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.vayunmathur.communicate.R-import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.communicate.data.CommunicateContact import com.vayunmathur.communicate.data.CommunicateRepository import com.vayunmathur.communicate.data.LineChoice-import com.vayunmathur.communicate.data.T9 import com.vayunmathur.communicate.data.loadContacts import com.vayunmathur.communicate.data.placeCall-import com.vayunmathur.communicate.data.googlevoice.GoogleVoiceSession import com.vayunmathur.communicate.data.googlevoice.call.GoogleVoiceCallManager-import com.vayunmathur.communicate.telephony.GoogleVoiceTelecom import com.vayunmathur.library.ui.EmptyState-import com.vayunmathur.library.ui.FilledIconButton-import com.vayunmathur.library.ui.HorizontalDivider-import com.vayunmathur.library.ui.IconBackspace-import com.vayunmathur.library.ui.IconCall import com.vayunmathur.library.ui.IconContacts-import com.vayunmathur.library.ui.IconPaste-import com.vayunmathur.library.ui.IconButton-import com.vayunmathur.library.ui.ListItem-import com.vayunmathur.library.ui.ListItemDefaults-import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.Surface-import com.vayunmathur.library.ui.Switch-import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.ui.appBarScrollBehavior-import androidx.compose.runtime.collectAsState import kotlinx.coroutines.Dispatchers-import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @Composable@@ -152,218 +112,3 @@ fun DialerScreen() { } } }--/**- * Dialer list plus pad, stateless apart from the entered number: contacts,- * lines and placement come in as parameters so screenshot previews can render- * without the SIM/session providers, the role and permission gates, or the- * contact content provider above.- */-@Composable-fun DialerContent(- contacts: List<CommunicateContact>,- onPlace: (String) -> Unit,- modifier: Modifier = Modifier,-) {- var number by remember { mutableStateOf("") }- val context = LocalContext.current- val clipboard = LocalClipboard.current- val scope = rememberCoroutineScope()- // Keyed on the contact list only: the query must never re-run the provider query.- val entries = remember(contacts) { contacts.map { T9.entryFor(it.name, it.phoneNumber) } }- val query = T9.normalizeQuery(number)- val filtered = remember(contacts, query) {- if (query.isEmpty()) contacts- else contacts.filterIndexed { index, _ -> T9.matches(entries[index], query) }- }- Column(modifier = modifier.fillMaxSize()) {- if (contacts.isEmpty()) {- EmptyState(- title = stringResource(R.string.empty_contacts),- icon = { IconContacts() },- modifier = Modifier.weight(1f),- )- } else if (filtered.isEmpty()) {- EmptyState(- title = stringResource(R.string.empty_contacts_for_digits),- icon = { IconContacts() },- modifier = Modifier.weight(1f),- )- } else {- LazyColumn(- modifier = Modifier.weight(1f),- contentPadding = PaddingValues(bottom = 8.dp),- ) {- item {- Text(- stringResource(UiR.string.contacts),- modifier = Modifier.padding(horizontal = 20.dp, vertical = 12.dp),- style = MaterialTheme.typography.titleMedium,- fontWeight = FontWeight.SemiBold,- )- }- items(filtered, key = { "${it.id}-${it.phoneNumber}" }) { contact ->- ContactRow(contact) {- onPlace(contact.phoneNumber)- }- }- }- }- DialPad(- number = number,- onAppend = { number += it },- onBackspace = { number = number.dropLast(1) },- onClear = { number = "" },- onPaste = {- scope.launch {- val pasted = clipboard.getClipEntry()- ?.clipData- ?.getItemAt(0)- ?.coerceToText(context)- ?.toString()- .orEmpty()- .filter { it.isDigit() || it == '+' || it == '*' || it == '#' }- if (pasted.isNotBlank()) number = pasted- }- },- onCall = { onPlace(number) },- )- }-}--@Composable-private fun DialPad(- number: String,- onAppend: (String) -> Unit,- onBackspace: () -> Unit,- onClear: () -> Unit,- onPaste: () -> Unit,- onCall: () -> Unit,-) {- // Letters are the physical keycap markings from ITU E.161, not translatable copy.- val keys = listOf(- listOf("1" to "", "2" to "ABC", "3" to "DEF"),- listOf("4" to "GHI", "5" to "JKL", "6" to "MNO"),- listOf("7" to "PQRS", "8" to "TUV", "9" to "WXYZ"),- listOf("*" to "", "0" to "", "#" to ""),- )- Surface(- tonalElevation = 2.dp,- modifier = Modifier.fillMaxWidth(),- ) {- Column(- modifier = Modifier- .fillMaxWidth()- .padding(horizontal = 16.dp, vertical = 10.dp),- horizontalAlignment = Alignment.CenterHorizontally,- verticalArrangement = Arrangement.spacedBy(6.dp),- ) {- Row(- modifier = Modifier.fillMaxWidth(),- verticalAlignment = Alignment.CenterVertically,- ) {- Text(- text = number.ifEmpty { stringResource(R.string.phone_number) },- style = MaterialTheme.typography.headlineSmall,- color = if (number.isEmpty()) MaterialTheme.colorScheme.onSurfaceVariant else MaterialTheme.colorScheme.onSurface,- maxLines = 1,- overflow = TextOverflow.Ellipsis,- modifier = Modifier.weight(1f),- textAlign = TextAlign.Center,- )- IconButton(onClick = onPaste) {- IconPaste()- }- }- keys.forEach { row ->- Row(- modifier = Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.spacedBy(8.dp),- ) {- row.forEach { (digit, letters) ->- DialKey(- digit = digit,- letters = letters,- onClick = { onAppend(digit) },- modifier = Modifier.weight(1f),- )- }- }- }- Row(- modifier = Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.spacedBy(8.dp),- verticalAlignment = Alignment.CenterVertically,- ) {- TextButton(onClick = onClear, enabled = number.isNotEmpty(), modifier = Modifier.weight(1f)) {- Text(stringResource(UiR.string.clear))- }- FilledIconButton(onClick = onCall, enabled = number.isNotBlank(), modifier = Modifier.size(52.dp)) {- IconCall()- }- IconButton(onClick = onBackspace, enabled = number.isNotEmpty(), modifier = Modifier.weight(1f)) {- IconBackspace()- }- }- }- }-}--@Composable-private fun DialKey(digit: String, letters: String, onClick: () -> Unit, modifier: Modifier = Modifier) {- Surface(- onClick = onClick,- shape = RoundedCornerShape(14.dp),- color = MaterialTheme.colorScheme.surfaceVariant,- modifier = modifier.height(52.dp),- ) {- Column(- modifier = Modifier.fillMaxSize(),- horizontalAlignment = Alignment.CenterHorizontally,- verticalArrangement = Arrangement.Center,- ) {- Text(digit, style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.Medium)- if (letters.isNotEmpty()) {- Text(- letters,- style = MaterialTheme.typography.labelSmall,- color = MaterialTheme.colorScheme.onSurfaceVariant,- maxLines = 1,- )- }- }- }-}--@Composable-private fun ContactRow(contact: CommunicateContact, onClick: () -> Unit) {- ListItem(- content = {- Text(- contact.name,- maxLines = 1,- overflow = TextOverflow.Ellipsis,- fontWeight = FontWeight.Medium,- )- },- supportingContent = { Text("${contact.label} ${contact.phoneNumber}", maxLines = 1) },- leadingContent = {- Box(- modifier = Modifier- .size(40.dp)- .clip(CircleShape)- .background(MaterialTheme.colorScheme.primaryContainer),- contentAlignment = Alignment.Center,- ) {- Text(- initialsFor(contact.name),- color = MaterialTheme.colorScheme.onPrimaryContainer,- fontWeight = FontWeight.SemiBold,- )- }- },- trailingContent = { IconCall() },- colors = ListItemDefaults.colors(containerColor = Color.Transparent),- modifier = Modifier.clickable(onClick = onClick),- )-}
library/jni-http/src/main/rust/src/lib.rs
diff --git a/library/jni-http/src/main/rust/src/lib.rs b/library/jni-http/src/main/rust/src/lib.rsindex b69e159e6e..4f0d2b6b65 100644--- a/library/jni-http/src/main/rust/src/lib.rs+++ b/library/jni-http/src/main/rust/src/lib.rs@@ -228,7 +228,8 @@ pub fn request_batch(url: &str, ranges: &[String]) -> Result<Vec<ResponseFrame>> let jrange: JString = env .new_string(range) .map_err(|e| Error::Bridge(format!("range: {e}")))?;- env.set_object_array_element(&jranges, i, jrange)+ jranges+ .set_element(env, i, jrange) .map_err(|e| Error::Bridge(format!("ranges: {e}")))?; }
third_party/betocore/crypto_provider_default/src/lib.rs
diff --git a/third_party/betocore/crypto_provider_default/src/lib.rs b/third_party/betocore/crypto_provider_default/src/lib.rsindex 67f3e7d30f..a026d835a9 100644--- a/third_party/betocore/crypto_provider_default/src/lib.rs+++ b/third_party/betocore/crypto_provider_default/src/lib.rs@@ -18,12 +18,8 @@ #![no_std] cfg_if::cfg_if! {- if #[cfg(all(feature = "rustcrypto", feature = "boringssl"))] {- compile_error!("Conflicting crypto_providers specified, must only enable a single crypto provider");- } else if #[cfg(feature = "rustcrypto")] {+ if #[cfg(feature = "rustcrypto")] { pub use crypto_provider_rustcrypto::RustCrypto as CryptoProviderImpl;- } else if #[cfg(feature = "boringssl")] {- pub use crypto_provider_boringssl::Boringssl as CryptoProviderImpl; } else { compile_error!("No crypto_provider feature enabled!"); }
third_party/betocore/crypto_provider_rustcrypto/src/aead/aes_gcm.rs
diff --git a/third_party/betocore/crypto_provider_rustcrypto/src/aead/aes_gcm.rs b/third_party/betocore/crypto_provider_rustcrypto/src/aead/aes_gcm.rsindex 3216eb9d17..28e3a33d5b 100644--- a/third_party/betocore/crypto_provider_rustcrypto/src/aead/aes_gcm.rs+++ b/third_party/betocore/crypto_provider_rustcrypto/src/aead/aes_gcm.rs@@ -41,8 +41,13 @@ impl<A: BlockCipherEncrypt<BlockSize = U16> + KeyInit> crypto_provider::aead::Ae impl<K: crypto_provider::aes::AesKey, A: BlockCipherEncrypt<BlockSize = U16> + KeyInit> AeadInit<K> for AesGcm<A> {+ #[allow(clippy::unwrap_used)] fn new(key: &K) -> Self {- Self(aes_gcm::AesGcm::<A, U12>::new(aes_gcm::Key::<A>::from_slice(key.as_slice())))+ // `try_from(...).unwrap()` preserves the old `from_slice` behavior, which+ // panicked on length mismatch. In practice `K` is always the correctly-sized key.+ Self(aes_gcm::AesGcm::<A, U12>::new(+ <&aes_gcm::Key<A>>::try_from(key.as_slice()).unwrap(),+ )) } } @@ -54,7 +59,7 @@ impl<A: aes::cipher::BlockCipherEncrypt<BlockSize = U16> + KeyInit> Aead for Aes #[cfg(feature = "alloc")] fn encrypt(&self, msg: &[u8], aad: &[u8], nonce: &Self::Nonce) -> Result<Vec<u8>, AeadError> { self.0- .encrypt(aes_gcm::Nonce::from_slice(nonce), Payload { msg, aad })+ .encrypt(<&aes_gcm::Nonce<U12>>::from(nonce), Payload { msg, aad }) .map_err(|_| AeadError) } @@ -67,7 +72,7 @@ impl<A: aes::cipher::BlockCipherEncrypt<BlockSize = U16> + KeyInit> Aead for Aes let tag = self .0 .encrypt_inout_detached(- aes_gcm::Nonce::from_slice(nonce),+ <&aes_gcm::Nonce<U12>>::from(nonce), aad, InOutBuf::from(msg), )@@ -80,7 +85,7 @@ impl<A: aes::cipher::BlockCipherEncrypt<BlockSize = U16> + KeyInit> Aead for Aes #[cfg(feature = "alloc")] fn decrypt(&self, msg: &[u8], aad: &[u8], nonce: &Self::Nonce) -> Result<Vec<u8>, AeadError> { self.0- .decrypt(aes_gcm::Nonce::from_slice(nonce), Payload { msg, aad })+ .decrypt(<&aes_gcm::Nonce<U12>>::from(nonce), Payload { msg, aad }) .map_err(|_| AeadError) } @@ -93,7 +98,7 @@ impl<A: aes::cipher::BlockCipherEncrypt<BlockSize = U16> + KeyInit> Aead for Aes ) -> Result<(), AeadError> { self.0 .decrypt_inout_detached(- aes_gcm::Nonce::from_slice(nonce),+ <&aes_gcm::Nonce<U12>>::from(nonce), aad, InOutBuf::from(msg), tag.into(),
third_party/betocore/crypto_provider_rustcrypto/src/aead/aes_gcm_siv.rs
diff --git a/third_party/betocore/crypto_provider_rustcrypto/src/aead/aes_gcm_siv.rs b/third_party/betocore/crypto_provider_rustcrypto/src/aead/aes_gcm_siv.rsindex 42f4219f7c..f974d5c993 100644--- a/third_party/betocore/crypto_provider_rustcrypto/src/aead/aes_gcm_siv.rs+++ b/third_party/betocore/crypto_provider_rustcrypto/src/aead/aes_gcm_siv.rs@@ -41,8 +41,13 @@ impl<A: BlockCipherEncrypt<BlockSize = U16> + KeyInit> crypto_provider::aead::Ae impl<K: crypto_provider::aes::AesKey, A: BlockCipherEncrypt<BlockSize = U16> + KeyInit> AeadInit<K> for AesGcmSiv<A> {+ #[allow(clippy::unwrap_used)] fn new(key: &K) -> Self {- Self(aes_gcm_siv::AesGcmSiv::<A>::new(aes_gcm_siv::Key::<A>::from_slice(key.as_slice())))+ // `try_from(...).unwrap()` preserves the old `from_slice` behavior, which+ // panicked on length mismatch. In practice `K` is always the correctly-sized key.+ Self(aes_gcm_siv::AesGcmSiv::<A>::new(+ <&aes_gcm_siv::Key<A>>::try_from(key.as_slice()).unwrap(),+ )) } } @@ -54,7 +59,7 @@ impl<A: aes::cipher::BlockCipherEncrypt<BlockSize = U16> + KeyInit> Aead for Aes #[cfg(feature = "alloc")] fn encrypt(&self, msg: &[u8], aad: &[u8], nonce: &Self::Nonce) -> Result<Vec<u8>, AeadError> { self.0- .encrypt(aes_gcm_siv::Nonce::from_slice(nonce), Payload { msg, aad })+ .encrypt(<&aes_gcm_siv::Nonce>::from(nonce), Payload { msg, aad }) .map_err(|_| AeadError) } @@ -67,7 +72,7 @@ impl<A: aes::cipher::BlockCipherEncrypt<BlockSize = U16> + KeyInit> Aead for Aes let tag = self .0 .encrypt_inout_detached(- aes_gcm_siv::Nonce::from_slice(nonce),+ <&aes_gcm_siv::Nonce>::from(nonce), aad, InOutBuf::from(msg), )@@ -80,7 +85,7 @@ impl<A: aes::cipher::BlockCipherEncrypt<BlockSize = U16> + KeyInit> Aead for Aes #[cfg(feature = "alloc")] fn decrypt(&self, msg: &[u8], aad: &[u8], nonce: &Self::Nonce) -> Result<Vec<u8>, AeadError> { self.0- .decrypt(aes_gcm_siv::Nonce::from_slice(nonce), Payload { msg, aad })+ .decrypt(<&aes_gcm_siv::Nonce>::from(nonce), Payload { msg, aad }) .map_err(|_| AeadError) } @@ -93,7 +98,7 @@ impl<A: aes::cipher::BlockCipherEncrypt<BlockSize = U16> + KeyInit> Aead for Aes ) -> Result<(), AeadError> { self.0 .decrypt_inout_detached(- aes_gcm_siv::Nonce::from_slice(nonce),+ <&aes_gcm_siv::Nonce>::from(nonce), aad, InOutBuf::from(msg), tag.into(),
third_party/betocore/crypto_provider_rustcrypto/src/aes_cp/mod.rs
diff --git a/third_party/betocore/crypto_provider_rustcrypto/src/aes_cp/mod.rs b/third_party/betocore/crypto_provider_rustcrypto/src/aes_cp/mod.rsindex 285f6af041..7f911fe394 100644--- a/third_party/betocore/crypto_provider_rustcrypto/src/aes_cp/mod.rs+++ b/third_party/betocore/crypto_provider_rustcrypto/src/aes_cp/mod.rs@@ -55,13 +55,13 @@ impl AesCipher for Aes128Cipher { impl AesEncryptCipher for Aes128Cipher { fn encrypt(&self, block: &mut AesBlock) {- self.0.encrypt_block(Array::from_mut_slice(block.as_mut_slice()));+ self.0.encrypt_block(<&mut Array<_, _>>::from(&mut *block)); } } impl AesDecryptCipher for Aes128Cipher { fn decrypt(&self, block: &mut AesBlock) {- self.0.decrypt_block(Array::from_mut_slice(block.as_mut_slice()))+ self.0.decrypt_block(<&mut Array<_, _>>::from(&mut *block)) } } @@ -78,13 +78,13 @@ impl AesCipher for Aes256Cipher { impl AesEncryptCipher for Aes256Cipher { fn encrypt(&self, block: &mut AesBlock) {- self.0.encrypt_block(Array::from_mut_slice(block.as_mut_slice()));+ self.0.encrypt_block(<&mut Array<_, _>>::from(&mut *block)); } } impl AesDecryptCipher for Aes256Cipher { fn decrypt(&self, block: &mut AesBlock) {- self.0.decrypt_block(Array::from_mut_slice(block.as_mut_slice()))+ self.0.decrypt_block(<&mut Array<_, _>>::from(&mut *block)) } }
third_party/betocore/crypto_provider_rustcrypto/src/ecdsa.rs
diff --git a/third_party/betocore/crypto_provider_rustcrypto/src/ecdsa.rs b/third_party/betocore/crypto_provider_rustcrypto/src/ecdsa.rsindex 556590a66f..ec17aabac9 100644--- a/third_party/betocore/crypto_provider_rustcrypto/src/ecdsa.rs+++ b/third_party/betocore/crypto_provider_rustcrypto/src/ecdsa.rs@@ -24,6 +24,8 @@ use crypto_provider::ecdsa::{ InvalidSignatureBytes, P256EcdsaProvider, VerifyError, PUBLIC_KEY_LENGTH, }; use p256::ecdsa::signature::{Signer, Verifier};+#[cfg(feature = "std")]+use p256::elliptic_curve::Generate; pub struct P256Ecdsa; @@ -70,7 +72,7 @@ impl crypto_provider::ecdsa::KeyPair for P256SigningKey { #[cfg(feature = "std")] fn generate() -> Self { let mut csprng = rand::rngs::ThreadRng::default();- Self(p256::ecdsa::SigningKey::random(&mut csprng))+ Self(p256::ecdsa::SigningKey::generate_from_rng(&mut csprng)) } #[allow(clippy::clone_on_copy)]@@ -91,7 +93,7 @@ impl crypto_provider::ecdsa::PublicKey for P256VerifyingKey { where Self: Sized, {- let encoded_point = p256::Sec1Point::from_bytes(bytes)+ let _encoded_point = p256::Sec1Point::from_bytes(bytes) .map_err(|_| crypto_provider::ecdsa::InvalidPublicKeyBytes)?; // Unwrap is safe here, as we've verified during construction that the public key is // of the correct size and that it is a point on the curve, so this cannot fail.
third_party/betocore/crypto_provider_rustcrypto/src/lib.rs
diff --git a/third_party/betocore/crypto_provider_rustcrypto/src/lib.rs b/third_party/betocore/crypto_provider_rustcrypto/src/lib.rsindex d68f1ea8fd..bd63a5471b 100644--- a/third_party/betocore/crypto_provider_rustcrypto/src/lib.rs+++ b/third_party/betocore/crypto_provider_rustcrypto/src/lib.rs@@ -106,7 +106,6 @@ pub struct RcRng<R>(R); impl<R: rand_core::CryptoRng + Rng + SeedableRng> crypto_provider::CryptoRng for RcRng<R> { fn new() -> Self {- use rand_core::TryRng; let mut sys = rand::rngs::SysRng; Self(R::try_from_rng(&mut sys).unwrap_or_else(|_| R::from_seed(Default::default()))) }
third_party/betocore/crypto_provider_rustcrypto/src/p256.rs
diff --git a/third_party/betocore/crypto_provider_rustcrypto/src/p256.rs b/third_party/betocore/crypto_provider_rustcrypto/src/p256.rsindex 49573f350e..5957337b68 100644--- a/third_party/betocore/crypto_provider_rustcrypto/src/p256.rs+++ b/third_party/betocore/crypto_provider_rustcrypto/src/p256.rs@@ -22,7 +22,7 @@ use crypto_provider::{ use p256::{ elliptic_curve, elliptic_curve::sec1::{FromSec1Point, Sec1Point, ToSec1Point},- elliptic_curve::FieldBytes,+ elliptic_curve::Generate, NistP256, }; use rand::{Rng, SeedableRng};@@ -52,14 +52,14 @@ impl crypto_provider::p256::P256PublicKey for P256PublicKey { fn to_sec1_bytes(&self, point_compression: PointCompression) -> ArrayVec<[u8; 65]> { let mut bytes = ArrayVec::<[u8; 65]>::new(); bytes.extend_from_slice(- self.0.to_encoded_point(point_compression == PointCompression::Compressed).as_bytes(),+ self.0.to_sec1_point(point_compression == PointCompression::Compressed).as_bytes(), ); bytes } #[allow(clippy::expect_used)] fn to_affine_coordinates(&self) -> Result<([u8; 32], [u8; 32]), Self::Error> {- let p256_key = self.0.to_encoded_point(false);+ let p256_key = self.0.to_sec1_point(false); let x: &[u8; 32] = p256_key.x().expect("Generated key should not be on identity point").as_ref(); let y: &[u8; 32] =@@ -68,9 +68,9 @@ impl crypto_provider::p256::P256PublicKey for P256PublicKey { } fn from_affine_coordinates(x: &[u8; 32], y: &[u8; 32]) -> Result<Self, Self::Error> { let key_option: Option<p256::PublicKey> =- p256::PublicKey::from_encoded_point(&Sec1Point::<NistP256>::from_affine_coordinates(- FieldBytes::<NistP256>::from_slice(x),- FieldBytes::<NistP256>::from_slice(y),+ p256::PublicKey::from_sec1_point(&Sec1Point::<NistP256>::from_affine_coordinates(+ x.into(),+ y.into(), false, )) .into();@@ -92,14 +92,14 @@ impl<R: CryptoRng + SeedableRng + Rng + Send> EphemeralSecret<P256> for P256Ephe fn generate_random(rng: &mut Self::Rng) -> Self { Self {- secret: p256::ecdh::EphemeralSecret::random(&mut rng.0),+ secret: p256::ecdh::EphemeralSecret::generate_from_rng(&mut rng.0), _marker: Default::default(), } } fn public_key_bytes(&self) -> Self::EncodedPublicKey { let mut bytes = Self::EncodedPublicKey::new();- bytes.extend_from_slice(self.secret.public_key().to_encoded_point(false).as_bytes());+ bytes.extend_from_slice(self.secret.public_key().to_sec1_point(false).as_bytes()); bytes } @@ -124,9 +124,9 @@ impl<R: CryptoRng + SeedableRng + Rng + Send> _public_key: &P256PublicKey, ) -> Result<Self, Self::Error> { Ok(Self {- secret: p256::ecdh::EphemeralSecret::random(&mut crate::testing::MockCryptoRng {- values: private_bytes.iter(),- }),+ secret: p256::ecdh::EphemeralSecret::generate_from_rng(+ &mut crate::testing::MockCryptoRng { values: private_bytes.iter() },+ ), _marker: Default::default(), }) }
third_party/betocore/np_adv/src/array_vec.rs
diff --git a/third_party/betocore/np_adv/src/array_vec.rs b/third_party/betocore/np_adv/src/array_vec.rsindex 2b62b49699..58c0d95ff2 100644--- a/third_party/betocore/np_adv/src/array_vec.rs+++ b/third_party/betocore/np_adv/src/array_vec.rs@@ -48,7 +48,7 @@ pub type ArrayVecOptionIntoIter<A, const N: usize> = impl<A, const N: usize> ArrayVecOption<A, N> { /// Returns an iterator over this vec.- pub fn iter(&self) -> ArrayVecOptionRefIter<A> {+ pub fn iter(&self) -> ArrayVecOptionRefIter<'_, A> { self.0 .iter() .map(|v| v.as_ref().expect("ArrayVecOption value before .len() should not be None"))
third_party/betocore/np_adv/src/credential/book.rs
diff --git a/third_party/betocore/np_adv/src/credential/book.rs b/third_party/betocore/np_adv/src/credential/book.rsindex 142bb28165..1a411e9375 100644--- a/third_party/betocore/np_adv/src/credential/book.rs+++ b/third_party/betocore/np_adv/src/credential/book.rs@@ -508,7 +508,7 @@ where #[cfg(any(feature = "alloc", test))] fn reference_crypto_and_match_data<C, M: MatchedCredential>( pair_ref: &(C, M),-) -> (&C, ReferencedMatchedCredential<M>) {+) -> (&C, ReferencedMatchedCredential<'_, M>) { let (c, m) = pair_ref; (c, m.into()) }
third_party/betocore/np_adv/src/credential/mod.rs
diff --git a/third_party/betocore/np_adv/src/credential/mod.rs b/third_party/betocore/np_adv/src/credential/mod.rsindex b61106d6c9..f856e657db 100644--- a/third_party/betocore/np_adv/src/credential/mod.rs+++ b/third_party/betocore/np_adv/src/credential/mod.rs@@ -50,7 +50,7 @@ impl<V: ProtocolVersion, M: MatchedCredential> MatchableCredential<V, M> { /// Views this credential as a (borrowed) discovery-credential /// combined with some matched credential data /// (which is copied - see documentation on [`MatchedCredential`])- pub fn as_pair(&self) -> (&V::DiscoveryCredential, ReferencedMatchedCredential<M>) {+ pub fn as_pair(&self) -> (&V::DiscoveryCredential, ReferencedMatchedCredential<'_, M>) { (&self.discovery_credential, ReferencedMatchedCredential::from(&self.match_data)) } }
third_party/betocore/np_adv/src/extended/data_elements/actions.rs
diff --git a/third_party/betocore/np_adv/src/extended/data_elements/actions.rs b/third_party/betocore/np_adv/src/extended/data_elements/actions.rsindex 0d6597f218..12dc65dc75 100644--- a/third_party/betocore/np_adv/src/extended/data_elements/actions.rs+++ b/third_party/betocore/np_adv/src/extended/data_elements/actions.rs@@ -277,7 +277,7 @@ impl<'adv> DeserializedActionsContainer<'adv> { Ok((input, DeserializedActionsContainer { container_type, offset, payload })) } - fn iter_action_ids(&self) -> ActionsContainerIterator {+ fn iter_action_ids(&self) -> ActionsContainerIterator<'_> { ActionsContainerIterator::new(self) } }
third_party/betocore/np_adv/src/extended/deserialize/data_element/mod.rs
diff --git a/third_party/betocore/np_adv/src/extended/deserialize/data_element/mod.rs b/third_party/betocore/np_adv/src/extended/deserialize/data_element/mod.rsindex 85085065d6..650e529139 100644--- a/third_party/betocore/np_adv/src/extended/deserialize/data_element/mod.rs+++ b/third_party/betocore/np_adv/src/extended/deserialize/data_element/mod.rs@@ -482,7 +482,7 @@ pub struct ProtoDataElement<'d> { } impl ProtoDataElement<'_> {- pub(crate) fn parse(input: &[u8]) -> nom::IResult<&[u8], ProtoDataElement> {+ pub(crate) fn parse(input: &[u8]) -> nom::IResult<&[u8], ProtoDataElement<'_>> { let (remaining, header) = DeHeader::parse(input)?; let len = header.contents_len; let de_type = header.de_type;
third_party/betocore/np_adv/src/extended/deserialize/mod.rs
diff --git a/third_party/betocore/np_adv/src/extended/deserialize/mod.rs b/third_party/betocore/np_adv/src/extended/deserialize/mod.rsindex ca6ba7202f..63e40243e2 100644--- a/third_party/betocore/np_adv/src/extended/deserialize/mod.rs+++ b/third_party/betocore/np_adv/src/extended/deserialize/mod.rs@@ -396,7 +396,7 @@ impl<'adv, M: MatchedCredential> V1AdvertisementContents<'adv, M> { } /// The sections that could be successfully deserialized and decrypted- pub fn sections(&self) -> impl ExactSizeIterator<Item = &V1DeserializedSection<M>> {+ pub fn sections(&self) -> impl ExactSizeIterator<Item = &V1DeserializedSection<'_, M>> { self.sections.iter() }
third_party/betocore/np_adv/src/extended/deserialize/section/intermediate/mod.rs
diff --git a/third_party/betocore/np_adv/src/extended/deserialize/section/intermediate/mod.rs b/third_party/betocore/np_adv/src/extended/deserialize/section/intermediate/mod.rsindex 11b0489482..c3fdc22271 100644--- a/third_party/betocore/np_adv/src/extended/deserialize/section/intermediate/mod.rs+++ b/third_party/betocore/np_adv/src/extended/deserialize/section/intermediate/mod.rs@@ -54,7 +54,7 @@ pub(crate) fn parse_sections( adv_header: V1AdvHeader, adv_body: &[u8], ) -> Result<- ArrayVecOption<IntermediateSection, NP_V1_ADV_MAX_SECTION_COUNT>,+ ArrayVecOption<IntermediateSection<'_>, NP_V1_ADV_MAX_SECTION_COUNT>, nom::Err<error::Error<&[u8]>>, > { let mut result = ArrayVecOption::default();
third_party/betocore/np_adv/src/legacy/deserialize/mod.rs
diff --git a/third_party/betocore/np_adv/src/legacy/deserialize/mod.rs b/third_party/betocore/np_adv/src/legacy/deserialize/mod.rsindex 21e9247506..902a70d2ef 100644--- a/third_party/betocore/np_adv/src/legacy/deserialize/mod.rs+++ b/third_party/betocore/np_adv/src/legacy/deserialize/mod.rs@@ -323,7 +323,7 @@ impl DecryptedAdvContents { /// Iterator over the data elements in an advertisement, except for any DEs related to resolving /// the identity or otherwise validating the payload (e.g. any identity DEs like Private /// Identity).- pub fn data_elements(&self) -> DeIterator<Ciphertext> {+ pub fn data_elements(&self) -> DeIterator<'_, Ciphertext> { DeIterator::new(self.data.as_slice()) }
third_party/betocore/ukey2_connections/src/d2d_connection_context_v1.rs
diff --git a/third_party/betocore/ukey2_connections/src/d2d_connection_context_v1.rs b/third_party/betocore/ukey2_connections/src/d2d_connection_context_v1.rsindex 7652f37d68..d2b190ce45 100644--- a/third_party/betocore/ukey2_connections/src/d2d_connection_context_v1.rs+++ b/third_party/betocore/ukey2_connections/src/d2d_connection_context_v1.rs@@ -16,8 +16,6 @@ use std::fmt::Formatter; use bytes::BufMut;-use nom::Parser as _;-use rand::SeedableRng as _; use crypto_provider::aead::Aead; use crypto_provider::{hkdf::Hkdf, hmac::Hmac, sha2::Sha256, CryptoProvider};
third_party/betocore/ukey2_connections/src/d2d_handshake_context.rs
diff --git a/third_party/betocore/ukey2_connections/src/d2d_handshake_context.rs b/third_party/betocore/ukey2_connections/src/d2d_handshake_context.rsindex 8aba53edf4..14134464d4 100644--- a/third_party/betocore/ukey2_connections/src/d2d_handshake_context.rs+++ b/third_party/betocore/ukey2_connections/src/d2d_handshake_context.rs@@ -15,7 +15,6 @@ use crate::d2d_connection_context_v1::D2DConnectionContextV1; use crypto_provider::CryptoProvider;-use rand::SeedableRng as _; use std::{collections::HashSet, mem}; use ukey2_rs::{ CompletedHandshake, HandshakeImplementation, NextProtocol, StateMachine, Ukey2Client,
third_party/betocore/ukey2_connections/src/lib.rs
diff --git a/third_party/betocore/ukey2_connections/src/lib.rs b/third_party/betocore/ukey2_connections/src/lib.rsindex bf76525d07..b93217bc9e 100644--- a/third_party/betocore/ukey2_connections/src/lib.rs+++ b/third_party/betocore/ukey2_connections/src/lib.rs@@ -50,7 +50,6 @@ pub use ukey2_rs::{HandshakeImplementation, NextProtocol}; /// falls back to a fixed seed rather than panicking across JNI. pub(crate) fn os_rng() -> rand::rngs::StdRng { use rand::SeedableRng;- use rand::TryRng; let mut sys = rand::rngs::SysRng; rand::rngs::StdRng::try_from_rng(&mut sys).unwrap_or_else(|_| rand::rngs::StdRng::from_seed([0u8; 32])) }
third_party/betocore/ukey2_rs/src/ukey2_handshake.rs
diff --git a/third_party/betocore/ukey2_rs/src/ukey2_handshake.rs b/third_party/betocore/ukey2_rs/src/ukey2_handshake.rsindex c517600499..c34b30d0dc 100644--- a/third_party/betocore/ukey2_rs/src/ukey2_handshake.rs+++ b/third_party/betocore/ukey2_rs/src/ukey2_handshake.rs@@ -636,7 +636,7 @@ impl CompletedHandshake { } /// Returns an HKDF for the UKEY2 `AUTH_STRING`.- pub fn auth_string<C: CryptoProvider>(&self) -> HandshakeHkdf<C> {+ pub fn auth_string<C: CryptoProvider>(&self) -> HandshakeHkdf<'_, C> { HandshakeHkdf::new( &self.client_init_bytes, &self.server_init_bytes,@@ -645,7 +645,7 @@ impl CompletedHandshake { } /// Returns an HKDF for the UKEY2 `NEXT_SECRET`.- pub fn next_protocol_secret<C: CryptoProvider>(&self) -> HandshakeHkdf<C> {+ pub fn next_protocol_secret<C: CryptoProvider>(&self) -> HandshakeHkdf<'_, C> { HandshakeHkdf::new( &self.client_init_bytes, &self.server_init_bytes,
third_party/betocore/xts_aes/src/lib.rs
diff --git a/third_party/betocore/xts_aes/src/lib.rs b/third_party/betocore/xts_aes/src/lib.rsindex 331ee27bc7..10ad08e331 100644--- a/third_party/betocore/xts_aes/src/lib.rs+++ b/third_party/betocore/xts_aes/src/lib.rs@@ -169,7 +169,7 @@ impl<A: Aes<Key = K::BlockCipherKey>, K: XtsKey> XtsEncrypter<A, K> { } /// Returns an [`XtsEncrypterTweaked`] configured with the specified tweak and a block number of 0.- fn tweaked(&self, tweak: Tweak) -> XtsEncrypterTweaked<A> {+ fn tweaked(&self, tweak: Tweak) -> XtsEncrypterTweaked<'_, A> { let mut bytes = tweak.bytes; self.tweak_encryption_cipher.encrypt(&mut bytes); @@ -260,7 +260,7 @@ impl<A: Aes<Key = K::BlockCipherKey>, K: XtsKey> XtsDecrypter<A, K> { } /// Returns an [`XtsDecrypterTweaked`] configured with the specified tweak and a block number of 0.- fn tweaked(&self, tweak: Tweak) -> XtsDecrypterTweaked<A> {+ fn tweaked(&self, tweak: Tweak) -> XtsDecrypterTweaked<'_, A> { let mut bytes = tweak.bytes; self.tweak_encryption_cipher.encrypt(&mut bytes); @@ -274,7 +274,7 @@ impl<A: Aes<Key = K::BlockCipherKey>, K: XtsKey> XtsDecrypter<A, K> { type DataUnitPartsResult<'a> = Result<(&'a mut [u8], &'a mut [u8], &'a mut [u8]), XtsError>; /// Returns `(standalone blocks, last complete block, partial last block)`.-fn data_unit_parts(data_unit: &mut [u8]) -> DataUnitPartsResult {+fn data_unit_parts(data_unit: &mut [u8]) -> DataUnitPartsResult<'_> { if data_unit.len() < BLOCK_SIZE { return Err(XtsError::DataTooShort); } else if data_unit.len() > MAX_XTS_SIZE {
vpn/src/main/rust/src/crypto.rs
diff --git a/vpn/src/main/rust/src/crypto.rs b/vpn/src/main/rust/src/crypto.rsindex fab8897763..bead0f15c7 100644--- a/vpn/src/main/rust/src/crypto.rs+++ b/vpn/src/main/rust/src/crypto.rs@@ -41,16 +41,17 @@ pub mod aead { pub struct LessSafeKey { inner: ChaCha20Poly1305 } impl LessSafeKey { pub fn new(unbound: UnboundKey) -> Self {- Self { inner: ChaCha20Poly1305::new(CKey::from_slice(&unbound.bytes)) }+ Self { inner: ChaCha20Poly1305::new(&CKey::from(unbound.bytes)) } } pub fn seal_in_place_separate_tag( &self, nonce: Nonce, aad: Aad<&[u8]>, in_out: &mut [u8], ) -> Result<Tag, error::Unspecified> {+ let nonce = chacha20poly1305::Nonce::from(nonce.0); let tag = self .inner .encrypt_inout_detached(- chacha20poly1305::Nonce::from_slice(&nonce.0),+ &nonce, aad.0, InOutBuf::from(in_out), )@@ -67,14 +68,14 @@ pub mod aead { let len = in_out.len(); if len < 16 { return Err(error::Unspecified); } let (ct, tag_bytes) = in_out.split_at_mut(len - 16);- let tag = Tag::from_slice(tag_bytes);+ let tag = Tag::try_from(&*tag_bytes).map_err(|_| error::Unspecified)?; let ct_len = ct.len(); self.inner .decrypt_inout_detached(- chacha20poly1305::Nonce::from_slice(&nonce.0),+ &chacha20poly1305::Nonce::from(nonce.0), aad.0, InOutBuf::from(&mut ct[..]),- tag,+ &tag, ) .map_err(|_| error::Unspecified)?; let plain_len = len - 16;
vpn/src/main/rust/src/lib.rs
diff --git a/vpn/src/main/rust/src/lib.rs b/vpn/src/main/rust/src/lib.rsindex fe7d5e63b5..8e9777e595 100644--- a/vpn/src/main/rust/src/lib.rs+++ b/vpn/src/main/rust/src/lib.rs@@ -47,7 +47,6 @@ fn b64e(k: &[u8]) -> String { use base64::Engine; base64::engine::general_purpos /// so this expect-matches the pre-existing `from_entropy().unwrap()` behavior. pub(crate) fn os_rng() -> rand::rngs::StdRng { use rand::SeedableRng;- use rand_core::TryRng; let mut sys = rand::rngs::SysRng; rand::rngs::StdRng::try_from_rng(&mut sys).expect("OS RNG unavailable") }
vpn/src/main/rust/src/noise/index_table.rs
diff --git a/vpn/src/main/rust/src/noise/index_table.rs b/vpn/src/main/rust/src/noise/index_table.rsindex 65aef5b988..e88ecc43e8 100644--- a/vpn/src/main/rust/src/noise/index_table.rs+++ b/vpn/src/main/rust/src/noise/index_table.rs@@ -1,7 +1,7 @@ use std::collections::HashSet; use std::sync::{Arc, Mutex}; use rand::rngs::StdRng;-use rand::{Rng, SeedableRng};+use rand::SeedableRng; pub struct IndexTable<Rng = StdRng>(Arc<Mutex<(Rng, HashSet<u32>)>>);
vpn/src/main/rust/src/noise/mod.rs
diff --git a/vpn/src/main/rust/src/noise/mod.rs b/vpn/src/main/rust/src/noise/mod.rsindex 10041ee327..926ddfe39a 100644--- a/vpn/src/main/rust/src/noise/mod.rs+++ b/vpn/src/main/rust/src/noise/mod.rs@@ -24,7 +24,7 @@ pub mod rate_limiter; mod session; mod timers; -use rand::{Rng, SeedableRng, rngs::StdRng};+use rand::{SeedableRng, rngs::StdRng}; use crate::noise::errors::WireGuardError; use crate::noise::handshake::Handshake;
vpn/src/main/rust/src/noise/rate_limiter.rs
diff --git a/vpn/src/main/rust/src/noise/rate_limiter.rs b/vpn/src/main/rust/src/noise/rate_limiter.rsindex 5c90ed4b4a..484509aaad 100644--- a/vpn/src/main/rust/src/noise/rate_limiter.rs+++ b/vpn/src/main/rust/src/noise/rate_limiter.rs@@ -3,7 +3,6 @@ use crate::noise::handshake::{LABEL_COOKIE, LABEL_MAC1}; use crate::noise::{TunnResult, WireGuardError}; use crate::packet::{Packet, WgCookieReply, WgHandshakeBase, WgKind}; use constant_time_eq::constant_time_eq;-use rand::Rng; use std::collections::HashMap; use std::net::{IpAddr, SocketAddr}; use std::sync::atomic::{AtomicU64, Ordering};@@ -95,9 +94,9 @@ impl RateLimiter { rep.receiver_idx.set(idx); rep.nonce = self.nonce(); let cipher = XChaCha20Poly1305::new(&self.cookie_key);- let iv = chacha20poly1305::XNonce::from_slice(&rep.nonce);+ let iv = chacha20poly1305::XNonce::from(rep.nonce); rep.encrypted_cookie.encrypted = cookie;- let tag = cipher.encrypt_inout_detached(iv, mac1, InOutBuf::from(&mut rep.encrypted_cookie.encrypted[..]))+ let tag = cipher.encrypt_inout_detached(&iv, mac1, InOutBuf::from(&mut rep.encrypted_cookie.encrypted[..])) .expect("wg_cookie_reply size ok"); rep.encrypted_cookie.tag = tag.into(); rep
weather/src/main/rust/src/lib.rs
diff --git a/weather/src/main/rust/src/lib.rs b/weather/src/main/rust/src/lib.rsindex 80cf57d741..998da70d80 100644--- a/weather/src/main/rust/src/lib.rs+++ b/weather/src/main/rust/src/lib.rs@@ -410,7 +410,7 @@ mod jni_bindings { match env.new_float_array(values.len()) { Ok(arr) => {- if env.set_float_array_region(&arr, 0, &values).is_err() {+ if arr.set_region(env, 0, &values).is_err() { return Ok(null); } Ok(arr.into_raw())
youpipe/src/main/rust/src/lib.rs
diff --git a/youpipe/src/main/rust/src/lib.rs b/youpipe/src/main/rust/src/lib.rsindex 590e60b58d..12d53326fa 100644--- a/youpipe/src/main/rust/src/lib.rs+++ b/youpipe/src/main/rust/src/lib.rs@@ -59,7 +59,7 @@ mod android { } fn text(env: &mut Env<'_>, value: &JString<'_>) -> String {- env.get_string(value).map(Into::into).unwrap_or_default()+ value.try_to_string(env).unwrap_or_default() } /// Optional strings arrive as null; treat empty as absent too.