Skip to content

Commit 6c9cb4b

Browse files
committed
MessageEncryptionMechanism: Add factory method for SED data, toString() implementation
1 parent b3d23e3 commit 6c9cb4b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pg/src/main/java/org/bouncycastle/openpgp/api/MessageEncryptionMechanism.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ public static MessageEncryptionMechanism unencrypted()
5757
SymmetricKeyAlgorithmTags.NULL, none);
5858
}
5959

60+
@Deprecated
61+
public static MessageEncryptionMechanism legacyEncryptedNonIntegrityProtected(int symmetricKeyAlgorithm)
62+
{
63+
int none = 0;
64+
return new MessageEncryptionMechanism(EncryptedDataPacketType.SED, symmetricKeyAlgorithm, none);
65+
}
66+
6067
/**
6168
* The data will be encrypted and integrity protected using a SEIPDv1 packet.
6269
*
@@ -137,4 +144,15 @@ public boolean equals(Object obj)
137144
&& getSymmetricKeyAlgorithm() == m.getSymmetricKeyAlgorithm()
138145
&& getAeadAlgorithm() == m.getAeadAlgorithm();
139146
}
147+
148+
@Override
149+
public String toString()
150+
{
151+
String out = mode.name() + "[cipher: " + symmetricKeyAlgorithm;
152+
if (mode == EncryptedDataPacketType.SEIPDv2 || mode == EncryptedDataPacketType.LIBREPGP_OED)
153+
{
154+
out += " aead: " + aeadAlgorithm;
155+
}
156+
return out + "]";
157+
}
140158
}

0 commit comments

Comments
 (0)