Skip to content

Commit b557dee

Browse files
authored
p521: fix size of CompressedPoint (#1652)
1 parent ff2f3c3 commit b557dee

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

p521/src/lib.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use elliptic_curve::{
5353
FieldBytesEncoding,
5454
array::Array,
5555
bigint::{Odd, cpubits},
56-
consts::U66,
56+
consts::{U66, U67},
5757
};
5858

5959
cpubits! {
@@ -106,7 +106,7 @@ impl pkcs8::AssociatedOid for NistP521 {
106106
}
107107

108108
/// Compressed SEC1-encoded NIST P-521 curve point.
109-
pub type CompressedPoint = Array<u8, U66>;
109+
pub type CompressedPoint = Array<u8, U67>;
110110

111111
/// NIST P-521 SEC1 encoded point.
112112
pub type Sec1Point = elliptic_curve::sec1::Sec1Point<NistP521>;
@@ -135,3 +135,19 @@ impl hash2curve::OprfParameters for NistP521 {
135135
/// See <https://www.rfc-editor.org/rfc/rfc9497.html#section-4.5-1>.
136136
const ID: &'static [u8] = b"P521-SHA512";
137137
}
138+
139+
#[cfg(test)]
140+
mod tests {
141+
use super::{CompressedPoint, NistP521};
142+
use core::mem::size_of;
143+
use elliptic_curve::sec1::CompressedPoint as Sec1Compressed;
144+
145+
#[test]
146+
fn compressed_point_size_matches_sec1() {
147+
assert_eq!(size_of::<CompressedPoint>(), 67);
148+
assert_eq!(
149+
size_of::<CompressedPoint>(),
150+
size_of::<Sec1Compressed<NistP521>>(),
151+
);
152+
}
153+
}

0 commit comments

Comments
 (0)