diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-06-28 13:59:48 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-06-28 13:59:48 +0200 |
commit | 1525eec1426a6a34b84809179d784e5cee3e8bfa (patch) | |
tree | 1e73534e95d14f776085df7ca6154057b8108712 /openpgp/src/crypto/mpis.rs | |
parent | f214d55b7061e9d6006f915ee8fbedf29ddf6078 (diff) |
openpgp: Make struct MPI opaque.
Diffstat (limited to 'openpgp/src/crypto/mpis.rs')
-rw-r--r-- | openpgp/src/crypto/mpis.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/openpgp/src/crypto/mpis.rs b/openpgp/src/crypto/mpis.rs index d93223ca..c1871619 100644 --- a/openpgp/src/crypto/mpis.rs +++ b/openpgp/src/crypto/mpis.rs @@ -23,9 +23,9 @@ use nettle; #[derive(Clone, Hash)] pub struct MPI { /// Length of the integer in bits. - pub bits: usize, + bits: usize, /// Integer value as big-endian. - pub value: Box<[u8]>, + value: Box<[u8]>, } impl From<Vec<u8>> for MPI { @@ -73,6 +73,16 @@ impl MPI { } } + /// Returns the length of the MPI in bits. + pub fn bits(&self) -> usize { + self.bits + } + + /// Returns the value of this MPI. + pub fn value(&self) -> &[u8] { + &self.value + } + /// Update the Hash with a hash of the MPIs. pub fn hash<H: nettle::Hash>(&self, hash: &mut H) { let len = &[(self.bits >> 8) as u8 & 0xFF, self.bits as u8]; |