This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch 2.2.X
in repository https://gitbox.apache.org/repos/asf/mina.git
The following commit(s) were added to refs/heads/2.2.X by this push:
new 269aef1fa Use stock JRE Charset instead of magic string
269aef1fa is described below
commit 269aef1fa2e2e0b213d6b833ac87011112ff3ec1
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Jul 16 09:01:00 2023 -0400
Use stock JRE Charset instead of magic string
Throw GeneralSecurityException instead of Exception in private method
---
.../org/apache/mina/proxy/handlers/http/ntlm/NTLMResponses.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git
a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/NTLMResponses.java
b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/NTLMResponses.java
index 93f3b9512..bb153ece7 100644
---
a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/NTLMResponses.java
+++
b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/NTLMResponses.java
@@ -19,10 +19,14 @@
*/
package org.apache.mina.proxy.handlers.http.ntlm;
+import java.nio.charset.StandardCharsets;
+import java.security.GeneralSecurityException;
import java.security.Key;
import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
+import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
/**
@@ -179,9 +183,10 @@ public class NTLMResponses {
*
* @return The LM Hash of the given password, used in the calculation
* of the LM Response.
+ * @throws GeneralSecurityException if an encryption problem occurs.
*/
- private static byte[] lmHash(String password) throws Exception {
- byte[] oemPassword = password.toUpperCase().getBytes("US-ASCII");
+ private static byte[] lmHash(String password) throws
GeneralSecurityException{
+ byte[] oemPassword =
password.toUpperCase().getBytes(StandardCharsets.US_ASCII);
int length = Math.min(oemPassword.length, 14);
byte[] keyBytes = new byte[14];
System.arraycopy(oemPassword, 0, keyBytes, 0, length);