-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve intermittent getAsInputStream close issue
* Resolve getAsInputStream close issue * put things back in order and only read this.hmac.getMacSize() bytes * put the HMAC debug log back where it was * comment about retry bytes check and retry bytes addition check * Revert CTR-only fixes * Fixes #250 and adds unit tests. * Rename context value names to conform to other names * Commit failing test cases * Rename hmacBytes context values and add expected size since multiple digest sizes are possible * Update CHANGELOG for #254 and #250
- Loading branch information
Showing
4 changed files
with
209 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...ta-client/src/test/java/com/joyent/manta/client/crypto/IncompleteByteReadInputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2017, Joyent, Inc. All rights reserved. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.joyent.manta.client.crypto; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* {@link java.io.InputStream} implementation that will always read one byte | ||
* less than the length specified in a {@link InputStream#read(byte[], int, int)} | ||
* method invocation. | ||
* | ||
* @author <a href="https://github.com/dekobon">Elijah Zupancic</a> | ||
* @since 3.1.1 | ||
*/ | ||
public class IncompleteByteReadInputStream extends InputStream { | ||
private final InputStream wrapped; | ||
|
||
public IncompleteByteReadInputStream(final InputStream wrapped) { | ||
this.wrapped = wrapped; | ||
} | ||
|
||
@Override | ||
public int read() throws IOException { | ||
return wrapped.read(); | ||
} | ||
|
||
@Override | ||
public int read(final byte[] b) throws IOException { | ||
return read(b, 0, b.length); | ||
} | ||
|
||
@Override | ||
public int read(byte[] b, int off, int len) throws IOException { | ||
if (len > 1 && len - off - 1 > 0) { | ||
return wrapped.read(b, off, len - 1); | ||
} else { | ||
return wrapped.read(b, off, len); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters