From 9190e983315c9421ae4b6829997f161141a733c5 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Wed, 6 Oct 2021 14:31:12 +0200 Subject: openpgp: Add MPI::zero and MPI::is_zero. --- openpgp/src/crypto/mpi.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'openpgp/src') diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs index 9e34f96f..e21ba98a 100644 --- a/openpgp/src/crypto/mpi.rs +++ b/openpgp/src/crypto/mpi.rs @@ -117,6 +117,16 @@ impl MPI { val } + /// Creates a new MPI representing zero. + pub fn zero() -> Self { + Self::new(&[]) + } + + /// Tests whether the MPI represents zero. + pub fn is_zero(&self) -> bool { + self.value().is_empty() + } + /// Returns the length of the MPI in bits. /// /// Leading zero-bits are not included in the returned size. -- cgit v1.2.3