summaryrefslogtreecommitdiffstats
path: root/openpgp/src
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/src')
-rw-r--r--openpgp/src/crypto/mpi.rs10
1 files changed, 10 insertions, 0 deletions
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.