From commits-return-64818-archive-asf-public=cust-asf.ponee.io@commons.apache.org Thu Oct 4 18:18:25 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id C3836180658 for ; Thu, 4 Oct 2018 18:18:24 +0200 (CEST) Received: (qmail 50865 invoked by uid 500); 4 Oct 2018 16:18:23 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 50856 invoked by uid 99); 4 Oct 2018 16:18:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Oct 2018 16:18:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9EC19DFF36; Thu, 4 Oct 2018 16:18:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vanzin@apache.org To: commits@commons.apache.org Message-Id: <9dcbafa9d5014e48b112f9ae816b086c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: commons-crypto git commit: CRYPTO-135: Add comment about need for blocking sinks. Date: Thu, 4 Oct 2018 16:18:23 +0000 (UTC) Repository: commons-crypto Updated Branches: refs/heads/master ec4150fe3 -> eee2f509c CRYPTO-135: Add comment about need for blocking sinks. Implementing non-blocking semantics in the WritableByteChannel portion of CryptoOutputStream is non-trivial. The existing options require weird return values and thus require the caller to know they're writing to a CryptoOutputStream and not a regular byte channel. In that case, it's better for the app to just not use the stream implementation and use the ciphers directly, since that gives the code better control of encryption. This change just adds comments to warn API users that the output streams are expected to be used only with blocking I/O. Closes #87 Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/eee2f509 Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/eee2f509 Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/eee2f509 Branch: refs/heads/master Commit: eee2f509cef33ff6d56dc4faaecc551b4e7ce077 Parents: ec4150f Author: Marcelo Vanzin Authored: Wed Oct 3 10:48:14 2018 -0700 Committer: Marcelo Vanzin Committed: Thu Oct 4 09:18:07 2018 -0700 ---------------------------------------------------------------------- .../org/apache/commons/crypto/stream/CryptoOutputStream.java | 4 ++++ .../apache/commons/crypto/stream/CtrCryptoOutputStream.java | 6 ++++++ 2 files changed, 10 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/eee2f509/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java b/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java index 4246713..b92d975 100644 --- a/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java +++ b/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java @@ -43,6 +43,10 @@ import org.apache.commons.crypto.utils.Utils; * {@link CryptoOutputStream} encrypts data and writes to the under layer * output. It supports any mode of operations such as AES CBC/CTR/GCM mode in * concept. It is not thread-safe. + *

+ * This class should only be used with blocking sinks. Using this class to wrap + * a non-blocking sink may lead to high CPU usage. + *

*/ public class CryptoOutputStream extends OutputStream implements http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/eee2f509/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java b/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java index c05b0c0..958d1a5 100644 --- a/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java +++ b/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java @@ -48,7 +48,13 @@ import org.apache.commons.crypto.utils.Utils; * counter = base + pos/(algorithm blocksize); padding = pos%(algorithm * blocksize); *

+ *

* The underlying stream offset is maintained as state. + *

+ *

+ * This class should only be used with blocking sinks. Using this class to wrap + * a non-blocking sink may lead to high CPU usage. + *

*/ public class CtrCryptoOutputStream extends CryptoOutputStream { /**