summaryrefslogtreecommitdiffstats
path: root/vendor/crypto-bigint/src/uint/array.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/crypto-bigint/src/uint/array.rs
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/crypto-bigint/src/uint/array.rs')
-rw-r--r--vendor/crypto-bigint/src/uint/array.rs42
1 files changed, 23 insertions, 19 deletions
diff --git a/vendor/crypto-bigint/src/uint/array.rs b/vendor/crypto-bigint/src/uint/array.rs
index cba2b3716..36f165e23 100644
--- a/vendor/crypto-bigint/src/uint/array.rs
+++ b/vendor/crypto-bigint/src/uint/array.rs
@@ -1,4 +1,4 @@
-//! `generic-array` integration with `UInt`.
+//! `generic-array` integration with `Uint`.
// TODO(tarcieri): completely phase out `generic-array` when const generics are powerful enough
use crate::{ArrayDecoding, ArrayEncoding, ByteArray};
@@ -7,7 +7,6 @@ use generic_array::{typenum, GenericArray};
macro_rules! impl_uint_array_encoding {
($(($uint:ident, $bytes:path)),+) => {
$(
- #[cfg_attr(docsrs, doc(cfg(feature = "generic-array")))]
impl ArrayEncoding for super::$uint {
type ByteSize = $bytes;
@@ -36,7 +35,6 @@ macro_rules! impl_uint_array_encoding {
}
}
- #[cfg_attr(docsrs, doc(cfg(feature = "generic-array")))]
impl ArrayDecoding for GenericArray<u8, $bytes> {
type Output = super::$uint;
@@ -75,33 +73,39 @@ impl_uint_array_encoding! {
(U8192, typenum::U1024)
}
+#[cfg(target_pointer_width = "32")]
+impl_uint_array_encoding! {
+ (U224, typenum::U28), // For NIST P-224
+ (U544, typenum::U68) // For NIST P-521
+}
+
#[cfg(test)]
mod tests {
use crate::{ArrayDecoding, ArrayEncoding, Limb};
use hex_literal::hex;
#[cfg(target_pointer_width = "32")]
- use crate::U64 as UIntEx;
+ use crate::U64 as UintEx;
#[cfg(target_pointer_width = "64")]
- use crate::U128 as UIntEx;
+ use crate::U128 as UintEx;
- /// Byte array that corresponds to `UIntEx`
- type ByteArray = crate::ByteArray<UIntEx>;
+ /// Byte array that corresponds to `UintEx`
+ type ByteArray = crate::ByteArray<UintEx>;
#[test]
#[cfg(target_pointer_width = "32")]
fn from_be_byte_array() {
- let n = UIntEx::from_be_byte_array(hex!("0011223344556677").into());
- assert_eq!(n.limbs(), &[Limb(0x44556677), Limb(0x00112233)]);
+ let n = UintEx::from_be_byte_array(hex!("0011223344556677").into());
+ assert_eq!(n.as_limbs(), &[Limb(0x44556677), Limb(0x00112233)]);
}
#[test]
#[cfg(target_pointer_width = "64")]
fn from_be_byte_array() {
- let n = UIntEx::from_be_byte_array(hex!("00112233445566778899aabbccddeeff").into());
+ let n = UintEx::from_be_byte_array(hex!("00112233445566778899aabbccddeeff").into());
assert_eq!(
- n.limbs(),
+ n.as_limbs(),
&[Limb(0x8899aabbccddeeff), Limb(0x0011223344556677)]
);
}
@@ -109,16 +113,16 @@ mod tests {
#[test]
#[cfg(target_pointer_width = "32")]
fn from_le_byte_array() {
- let n = UIntEx::from_le_byte_array(hex!("7766554433221100").into());
- assert_eq!(n.limbs(), &[Limb(0x44556677), Limb(0x00112233)]);
+ let n = UintEx::from_le_byte_array(hex!("7766554433221100").into());
+ assert_eq!(n.as_limbs(), &[Limb(0x44556677), Limb(0x00112233)]);
}
#[test]
#[cfg(target_pointer_width = "64")]
fn from_le_byte_array() {
- let n = UIntEx::from_le_byte_array(hex!("ffeeddccbbaa99887766554433221100").into());
+ let n = UintEx::from_le_byte_array(hex!("ffeeddccbbaa99887766554433221100").into());
assert_eq!(
- n.limbs(),
+ n.as_limbs(),
&[Limb(0x8899aabbccddeeff), Limb(0x0011223344556677)]
);
}
@@ -127,7 +131,7 @@ mod tests {
#[cfg(target_pointer_width = "32")]
fn to_be_byte_array() {
let expected_bytes = ByteArray::from(hex!("0011223344556677"));
- let actual_bytes = UIntEx::from_be_byte_array(expected_bytes).to_be_byte_array();
+ let actual_bytes = UintEx::from_be_byte_array(expected_bytes).to_be_byte_array();
assert_eq!(expected_bytes, actual_bytes);
}
@@ -135,7 +139,7 @@ mod tests {
#[cfg(target_pointer_width = "64")]
fn to_be_byte_array() {
let expected_bytes = ByteArray::from(hex!("00112233445566778899aabbccddeeff"));
- let actual_bytes = UIntEx::from_be_byte_array(expected_bytes).to_be_byte_array();
+ let actual_bytes = UintEx::from_be_byte_array(expected_bytes).to_be_byte_array();
assert_eq!(expected_bytes, actual_bytes);
}
@@ -143,7 +147,7 @@ mod tests {
#[cfg(target_pointer_width = "32")]
fn to_le_byte_array() {
let expected_bytes = ByteArray::from(hex!("7766554433221100"));
- let actual_bytes = UIntEx::from_le_byte_array(expected_bytes).to_le_byte_array();
+ let actual_bytes = UintEx::from_le_byte_array(expected_bytes).to_le_byte_array();
assert_eq!(expected_bytes, actual_bytes);
}
@@ -151,7 +155,7 @@ mod tests {
#[cfg(target_pointer_width = "64")]
fn to_le_byte_array() {
let expected_bytes = ByteArray::from(hex!("ffeeddccbbaa99887766554433221100"));
- let actual_bytes = UIntEx::from_le_byte_array(expected_bytes).to_le_byte_array();
+ let actual_bytes = UintEx::from_le_byte_array(expected_bytes).to_le_byte_array();
assert_eq!(expected_bytes, actual_bytes);
}