diff options
Diffstat (limited to 'openpgp/src/types/mod.rs')
-rw-r--r-- | openpgp/src/types/mod.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/openpgp/src/types/mod.rs b/openpgp/src/types/mod.rs index 6f05f513..88f82107 100644 --- a/openpgp/src/types/mod.rs +++ b/openpgp/src/types/mod.rs @@ -1452,6 +1452,20 @@ impl HashAlgorithm { } } + /// Returns the salt size for this algorithm. + /// + /// Version 6 signatures salt the hash, and the size of the hash + /// is dependent on the hash algorithm. + pub fn salt_size(&self) -> Result<usize> { + match self { + HashAlgorithm::SHA256 => Ok(16), + HashAlgorithm::SHA384 => Ok(24), + HashAlgorithm::SHA512 => Ok(32), + HashAlgorithm::SHA224 => Ok(16), + _ => Err(Error::UnsupportedHashAlgorithm(*self).into()), + } + } + /// Returns an iterator over all valid variants. /// /// Returns an iterator over all known variants. This does not |