This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch 2.0.X
in repository https://gitbox.apache.org/repos/asf/mina.git

commit 8d4a2a39af68338b53a2d3ef5b52b519b6a13e6e
Author: Gary Gregory <garydgreg...@gmail.com>
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);

Reply via email to