You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by GitBox <gi...@apache.org> on 2020/04/30 07:10:40 UTC

[GitHub] [mina-sshd] lgoldstein commented on a change in pull request #127: [SSHD-987] Correctly generate IV for AES private key obfuscator

lgoldstein commented on a change in pull request #127:
URL: https://github.com/apache/mina-sshd/pull/127#discussion_r417800394



##########
File path: sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AESPrivateKeyObfuscator.java
##########
@@ -56,6 +61,28 @@ public AESPrivateKeyObfuscator() {
         return applyPrivateKeyCipher(bytes, encContext, keyLength, keyValue, encryptIt);
     }
 
+    @Override
+    protected int resolveInitializationVectorLength(PrivateKeyEncryptionContext encContext) throws GeneralSecurityException {
+        int keyLength = resolveKeyLength(encContext);
+        String cipherMode = encContext.getCipherMode();
+        String xformMode = "/" + cipherMode.toUpperCase() + "/";
+        List<CipherInformation> matches = BuiltinCiphers.VALUES.stream()
+                .filter(c -> CIPHER_NAME.equalsIgnoreCase(c.getAlgorithm())
+                        && (keyLength == c.getKeySize())
+                        && c.getTransformation().contains(xformMode))
+                .collect(Collectors.toList());
+        int numMatches = GenericUtils.size(matches);
+        if (numMatches <= 0) {
+            throw new NoSuchAlgorithmException("No match found for " + encContext);
+        }
+        if (numMatches > 1) {

Review comment:
       Good point - changed the code accordingly




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org