orc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prasanthj <...@git.apache.org>
Subject [GitHub] orc pull request #278: ORC-251: Extend InStream and OutStream to support enc...
Date Thu, 12 Jul 2018 21:51:06 GMT
Github user prasanthj commented on a diff in the pull request:

    https://github.com/apache/orc/pull/278#discussion_r202187998
  
    --- Diff: java/core/src/java/org/apache/orc/impl/InStream.java ---
    @@ -173,33 +203,208 @@ private static ByteBuffer allocateBuffer(int size, boolean isDirect)
{
         }
       }
     
    +  /**
    +   * Manage the state of the decryption, including the ability to seek.
    +   */
    +  static class EncryptionState {
    +    private final String name;
    +    private final EncryptionAlgorithm algorithm;
    +    private final Key key;
    +    private final byte[] iv;
    +    private final Cipher cipher;
    +    private ByteBuffer decrypted;
    +
    +    EncryptionState(String name, StreamOptions options) {
    +      this.name = name;
    +      algorithm = options.algorithm;
    +      key = options.key;
    +      iv = options.iv;
    +      cipher = algorithm.createCipher();
    +    }
    +
    +    /**
    +     * We are seeking to a new range, so update the cipher to change the IV
    +     * to match. This code assumes that we only support encryption in CTR mode.
    +     * @param offset where we are seeking to in the stream
    +     */
    +    void changeIv(long offset) {
    +      int blockSize = cipher.getBlockSize();
    +      long encryptionBlocks = offset / blockSize;
    --- End diff --
    
    Add +1 if there is extra?


---

Mime
View raw message