andrei-ivanov commented on code in PR #1645:
URL: https://github.com/apache/cxf/pull/1645#discussion_r1450806303


##########
rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/PbesHmacAesWrapKeyEncryptionAlgorithm.java:
##########
@@ -129,19 +128,23 @@ static int getKeySize(String keyAlgoJwt) {
     }
     static byte[] createDerivedKey(String keyAlgoJwt, int keySize,
                                    byte[] password, byte[] saltInput, int 
pbesCount) {
-        byte[] saltValue = createSaltValue(keyAlgoJwt, saltInput);
-        final Digest digest;
-        int macSigSize = PBES_HMAC_MAP.get(keyAlgoJwt);
-        if (macSigSize == 256) {
-            digest = new SHA256Digest();
-        } else if (macSigSize == 384) {
-            digest = new SHA384Digest();
-        } else {
-            digest = new SHA512Digest();
+        try {
+            byte[] saltValue = createSaltValue(keyAlgoJwt, saltInput);
+            int macSigSize = PBES_HMAC_MAP.get(keyAlgoJwt);
+                
+            String algorithm = "PBKDF2WithHmacSHA" + macSigSize;
+            PBEKeySpec pbeSpec = new PBEKeySpec(new 
String(password).toCharArray(), saltValue, pbesCount, keySize * 8);
+            SecretKeyFactory keyFact = 
SecretKeyFactory.getInstance(algorithm); 
+            Key sKey = keyFact.generateSecret(pbeSpec);
+            byte[] ret = new byte[keySize];
+            byte[] key = sKey.getEncoded();
+            System.arraycopy(key, 0, ret, 0, keySize);
+            return ret;
+           
+        } catch (Exception ex) {
+            ex.printStackTrace();

Review Comment:
   should this be here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to