summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-08-11 11:16:34 +0200
committerJustus Winter <justus@sequoia-pgp.org>2020-08-11 14:32:13 +0200
commitc325bd5eee79cd83cc844e2dc7957aac4897ca61 (patch)
tree0ea0ad7df00bbdbd47f00af97fb6cf1d8ffc1d90
parentdbed49a39a5e175d21902e63f9a6adf8ac9b848c (diff)
openpgp: Mark S2K::Simple and S2K::Salted as deprecated.
-rw-r--r--openpgp/src/crypto/s2k.rs6
-rw-r--r--openpgp/src/message/mod.rs1
-rw-r--r--openpgp/src/packet/skesk.rs1
-rw-r--r--openpgp/src/parse.rs1
-rw-r--r--openpgp/src/serialize.rs2
-rw-r--r--tool/src/commands/dump.rs1
6 files changed, 12 insertions, 0 deletions
diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs
index c09fe75c..10dd9440 100644
--- a/openpgp/src/crypto/s2k.rs
+++ b/openpgp/src/crypto/s2k.rs
@@ -29,11 +29,13 @@ use rand::Rng;
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub enum S2K {
/// Simply hashes the password.
+ #[deprecated(since = "rfc4880", note = "Use `S2K::Iterated`.")]
Simple {
/// Hash used for key derivation.
hash: HashAlgorithm
},
/// Hashes the password with a public `salt` value.
+ #[deprecated(note = "Use `S2K::Iterated`.")]
Salted {
/// Hash used for key derivation.
hash: HashAlgorithm,
@@ -79,6 +81,7 @@ impl S2K {
/// Convert the string to a key using the S2K's parameters.
pub fn derive_key(&self, password: &Password, key_size: usize)
-> Result<SessionKey> {
+ #[allow(deprecated)]
match self {
&S2K::Simple { hash } | &S2K::Salted { hash, .. }
| &S2K::Iterated { hash, .. } => password.map(|string| {
@@ -236,6 +239,7 @@ impl S2K {
impl fmt::Display for S2K {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ #[allow(deprecated)]
match *self {
S2K::Simple{ hash } =>
f.write_fmt(format_args!("Simple S2K with {}", hash)),
@@ -267,6 +271,7 @@ impl fmt::Display for S2K {
#[cfg(any(test, feature = "quickcheck"))]
impl Arbitrary for S2K {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
+ #[allow(deprecated)]
match g.gen_range(0, 5) {
0 => S2K::Simple{ hash: HashAlgorithm::arbitrary(g) },
1 => S2K::Salted{
@@ -312,6 +317,7 @@ mod tests {
// SK-ESK packet when invoked with -c, but not -e. (When
// invoked with -c and -e, it generates SK-ESK packets that
// include an encrypted session key.)
+ #[allow(deprecated)]
let tests = [
Test {
filename: "mode-0-password-1234.gpg",
diff --git a/openpgp/src/message/mod.rs b/openpgp/src/message/mod.rs
index b0763669..65b6d34c 100644
--- a/openpgp/src/message/mod.rs
+++ b/openpgp/src/message/mod.rs
@@ -1053,6 +1053,7 @@ mod tests {
// => bad.
let mut packets : Vec<Packet> = Vec::new();
let sk = crate::crypto::SessionKey::new(8);
+ #[allow(deprecated)]
packets.push(SKESK4::with_password(
SymmetricAlgorithm::AES256,
S2K::Simple { hash: HashAlgorithm::SHA256 },
diff --git a/openpgp/src/packet/skesk.rs b/openpgp/src/packet/skesk.rs
index ad907abe..0b9de42b 100644
--- a/openpgp/src/packet/skesk.rs
+++ b/openpgp/src/packet/skesk.rs
@@ -191,6 +191,7 @@ impl SKESK4 {
} else {
// No ESK, we return the derived key.
+ #[allow(deprecated)]
match self.s2k {
S2K::Simple{ .. } =>
Err(Error::InvalidOperation(
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index c54db561..6db6a4d7 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -1058,6 +1058,7 @@ impl S2K {
fn parse<T: BufferedReader<Cookie>>(php: &mut PacketHeaderParser<T>) -> Result<Self>
{
let s2k = php.parse_u8("s2k_type")?;
+ #[allow(deprecated)]
let ret = match s2k {
0 => S2K::Simple {
hash: HashAlgorithm::from(php.parse_u8("s2k_hash_algo")?),
diff --git a/openpgp/src/serialize.rs b/openpgp/src/serialize.rs
index 2f8cbed4..8dc45808 100644
--- a/openpgp/src/serialize.rs
+++ b/openpgp/src/serialize.rs
@@ -1240,6 +1240,7 @@ impl MarshalInto for crypto::mpi::Signature {
impl Marshal for S2K {
fn serialize(&self, w: &mut dyn std::io::Write) -> Result<()> {
+ #[allow(deprecated)]
match self {
&S2K::Simple{ hash } => {
w.write_all(&[0, hash.into()])?;
@@ -1264,6 +1265,7 @@ impl Marshal for S2K {
impl MarshalInto for S2K {
fn serialized_len(&self) -> usize {
+ #[allow(deprecated)]
match self {
&S2K::Simple{ .. } => 2,
&S2K::Salted{ .. } => 2 + 8,
diff --git a/tool/src/commands/dump.rs b/tool/src/commands/dump.rs
index a1ddb043..e99990ee 100644
--- a/tool/src/commands/dump.rs
+++ b/tool/src/commands/dump.rs
@@ -865,6 +865,7 @@ impl PacketDumper {
fn dump_s2k(&self, output: &mut dyn io::Write, i: &str, s2k: &S2K)
-> Result<()> {
use self::S2K::*;
+ #[allow(deprecated)]
match s2k {
Simple { hash } => {
writeln!(output, "Simple")?;