spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vanzin <>
Subject [GitHub] spark pull request #15172: [SPARK-13331] AES support for over-the-wire encry...
Date Mon, 24 Oct 2016 20:40:08 GMT
Github user vanzin commented on a diff in the pull request:
    --- Diff: common/network-common/src/main/java/org/apache/spark/network/sasl/aes/
    @@ -0,0 +1,340 @@
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +import java.nio.ByteBuffer;
    +import java.nio.channels.ReadableByteChannel;
    +import java.nio.channels.WritableByteChannel;
    +import java.util.HashMap;
    +import java.util.Properties;
    +import javax.crypto.spec.SecretKeySpec;
    +import javax.crypto.spec.IvParameterSpec;
    +import io.netty.buffer.ByteBuf;
    +import io.netty.buffer.Unpooled;
    +import io.netty.util.AbstractReferenceCounted;
    +import org.apache.commons.crypto.cipher.CryptoCipherFactory;
    +import org.apache.commons.crypto.random.CryptoRandom;
    +import org.apache.commons.crypto.random.CryptoRandomFactory;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    + * AES cipher for encryption and decryption.
    + */
    +public class AesCipher {
    +  private static final Logger logger = LoggerFactory.getLogger(AesCipher.class);
    +  public static final String ENCRYPTION_HANDLER_NAME = "AesEncryption";
    +  public static final String DECRYPTION_HANDLER_NAME = "AesDecryption";
    +  private final SecretKeySpec inKeySpec;
    +  private final IvParameterSpec inIvSpec;
    +  private final SecretKeySpec outKeySpec;
    +  private final IvParameterSpec outIvSpec;
    +  private Properties properties;
    +  private HashMap<ReadableByteChannel, CryptoInputStream> inputStreamMap;
    --- End diff --
    Could you change the code so that these maps are not necessary?
    You have a single `AesCipher` instance for each channel. So having a map here is already
weird since this class won't ever have to deal with more than a single channel. You seem to
be using it as a cache so you don't have to figure out how to propagate the input streams
to the channel handlers; instead, just have the channel handlers hold a reference to the stream
    (BTW I already asked for this in my previous review. In fact, you don't need this map
at all currently for the output stream since you already did some of that work.)

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message