Skip to content

Commit 3eafe95

Browse files
committed
Ctd
1 parent d979aa5 commit 3eafe95

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

phase2-lib/src/main/java/com/helger/phase2/crypto/ECryptoAlgorithmSign.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,57 +55,73 @@
5555
*/
5656
public enum ECryptoAlgorithmSign implements ICryptoAlgorithm
5757
{
58-
/** See compatibility note in RFC 5751, section 3.4.3.1 */
58+
/**
59+
* See compatibility note in RFC 5751, section 3.4.3.1
60+
*/
5961
@Deprecated (forRemoval = false)
6062
@DevelopersNote ("Use DIGEST_MD5 instead")
6163
DIGEST_RSA_MD5("rsa-md5", "md5", PKCSObjectIdentifiers.md5, "MD5WITHRSA"),
6264

63-
/** See compatibility note in RFC 5751, section 3.4.3.1 */
65+
/**
66+
* See compatibility note in RFC 5751, section 3.4.3.1
67+
*/
6468
@Deprecated (forRemoval = false)
6569
@DevelopersNote ("Use DIGEST_SHA1 or DIGEST_SHA_1 instead")
6670
DIGEST_RSA_SHA1("rsa-sha1", "sha1", OIWObjectIdentifiers.idSHA1, "SHA1WITHRSA"),
6771

68-
/** Same for RFC 3851 and RFC 5751 */
72+
/**
73+
* Same for RFC 3851 and RFC 5751
74+
*/
6975
DIGEST_MD5 ("md5", "md5", PKCSObjectIdentifiers.md5, "MD5WITHRSA"),
7076

7177
/**
7278
* Old version as of RFC 3851.
7379
*/
80+
@Deprecated (forRemoval = false)
7481
@DevelopersNote ("Use DIGEST_SHA_1 instead")
7582
DIGEST_SHA1("sha1", "sha1", OIWObjectIdentifiers.idSHA1, "SHA1WITHRSA"),
7683

7784
/**
7885
* Old version as of RFC 3851.
7986
*/
87+
@Deprecated (forRemoval = false)
8088
@DevelopersNote ("Use DIGEST_SHA_256 instead")
8189
DIGEST_SHA256("sha256", "sha256", NISTObjectIdentifiers.id_sha256, "SHA256WITHRSA"),
8290

8391
/**
8492
* Old version as of RFC 3851.
8593
*/
94+
@Deprecated (forRemoval = false)
8695
@DevelopersNote ("Use DIGEST_SHA_384 instead")
8796
DIGEST_SHA384("sha384", "sha384", NISTObjectIdentifiers.id_sha384, "SHA384WITHRSA"),
97+
8898
/**
8999
* Old version as of RFC 3851.
90100
*/
101+
@Deprecated (forRemoval = false)
91102
@DevelopersNote ("Use DIGEST_SHA_512 instead")
92103
DIGEST_SHA512("sha512", "sha512", NISTObjectIdentifiers.id_sha512, "SHA512WITHRSA"),
104+
93105
/**
94106
* New version as of RFC 5751.
95107
*/
96108
DIGEST_SHA_1 ("sha-1", "sha-1", OIWObjectIdentifiers.idSHA1, "SHA1WITHRSA"),
109+
97110
/**
98111
* New version as of RFC 5751.
99112
*/
100113
DIGEST_SHA_224 ("sha-224", "sha-224", NISTObjectIdentifiers.id_sha224, "SHA224WITHRSA"),
114+
101115
/**
102116
* New version as of RFC 5751.
103117
*/
104118
DIGEST_SHA_256 ("sha-256", "sha-256", NISTObjectIdentifiers.id_sha256, "SHA256WITHRSA"),
119+
105120
/**
106121
* New version as of RFC 5751.
107122
*/
108123
DIGEST_SHA_384 ("sha-384", "sha-384", NISTObjectIdentifiers.id_sha384, "SHA384WITHRSA"),
124+
109125
/**
110126
* New version as of RFC 5751.
111127
*/
@@ -117,18 +133,21 @@ public enum ECryptoAlgorithmSign implements ICryptoAlgorithm
117133
* @since 5.0.1 and 5.1.1
118134
*/
119135
DIGEST_SHA2_224 ("sha2_224", "sha-224", NISTObjectIdentifiers.id_sha224, "SHA224WITHRSA"),
136+
120137
/**
121138
* Non-compliant version of SHA-256 algorithm
122139
*
123140
* @since 5.0.1 and 5.1.1
124141
*/
125142
DIGEST_SHA2_256 ("sha2_256", "sha-256", NISTObjectIdentifiers.id_sha256, "SHA256WITHRSA"),
143+
126144
/**
127145
* Non-compliant version of SHA-384 algorithm
128146
*
129147
* @since 5.0.1 and 5.1.1
130148
*/
131149
DIGEST_SHA2_384 ("sha2_384", "sha-384", NISTObjectIdentifiers.id_sha384, "SHA384WITHRSA"),
150+
132151
/**
133152
* Non-compliant version of SHA-512 algorithm
134153
*

phase2-lib/src/main/java/com/helger/phase2/crypto/MIC.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,15 @@ public MIC getClone ()
115115
@Nonnull
116116
private static ECryptoAlgorithmSign _getUnified (@Nonnull final ECryptoAlgorithmSign eAlgorithm)
117117
{
118-
switch (eAlgorithm)
118+
return switch (eAlgorithm)
119119
{
120-
case DIGEST_RSA_MD5:
121-
return ECryptoAlgorithmSign.DIGEST_MD5;
122-
case DIGEST_RSA_SHA1:
123-
case DIGEST_SHA1:
124-
return ECryptoAlgorithmSign.DIGEST_SHA_1;
125-
case DIGEST_SHA256:
126-
return ECryptoAlgorithmSign.DIGEST_SHA_256;
127-
case DIGEST_SHA384:
128-
return ECryptoAlgorithmSign.DIGEST_SHA_384;
129-
case DIGEST_SHA512:
130-
return ECryptoAlgorithmSign.DIGEST_SHA_512;
131-
default:
132-
return eAlgorithm;
133-
}
120+
case DIGEST_RSA_MD5 -> ECryptoAlgorithmSign.DIGEST_MD5;
121+
case DIGEST_RSA_SHA1, DIGEST_SHA1 -> ECryptoAlgorithmSign.DIGEST_SHA_1;
122+
case DIGEST_SHA256 -> ECryptoAlgorithmSign.DIGEST_SHA_256;
123+
case DIGEST_SHA384 -> ECryptoAlgorithmSign.DIGEST_SHA_384;
124+
case DIGEST_SHA512 -> ECryptoAlgorithmSign.DIGEST_SHA_512;
125+
default -> eAlgorithm;
126+
};
134127
}
135128

136129
@Override

phase2-lib/src/main/java/com/helger/phase2/util/AS2Helper.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,12 @@ public static IMessageMDN createSyncMDN (@Nonnull final IAS2Session aSession,
356356
final String sDispositionOptions = aMsg.getHeader (CHttpHeader.DISPOSITION_NOTIFICATION_OPTIONS);
357357
final DispositionOptions aDispositionOptions = DispositionOptions.createFromString (sDispositionOptions);
358358

359-
// Calculate MIC
360-
final MIC aMIC = createMICOnReception (aMsg);
361-
if (aMIC != null)
362-
aMDN.attrs ().putIn (AS2MessageMDN.MDNA_MIC, aMIC.getAsAS2String ());
359+
{
360+
// Calculate MIC
361+
final MIC aMIC = createMICOnReception (aMsg);
362+
if (aMIC != null)
363+
aMDN.attrs ().putIn (AS2MessageMDN.MDNA_MIC, aMIC.getAsAS2String ());
364+
}
363365

364366
boolean bSignMDN = false;
365367
boolean bIncludeCertificateInSignedContent = false;

0 commit comments

Comments
 (0)