[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mina-dev
Subject:    =?utf-8?q?=5BGitHub=5D_=5Bmina-sshd=5D_tomaswolf_commented_on_a_change_in_pu?= =?utf-8?q?ll_request_
From:       GitBox <git () apache ! org>
Date:       2020-04-29 21:03:38
Message-ID: 158819421858.26397.6376347429947065209.asfpy () gitbox ! apache ! org
[Download RAW message or body]


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



##########
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:
       The code works, but I don't understand why you even check this. It would \
indicate a coding error in BuiltinCiphers. If that enum has duplicate \
algorithm/keySize values, it would we a bug in the source. It's the kind of test that \
I'd do in a unit test, not at runtime. I'd just take the first match to determine the \
IV size.




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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic