Skip to content

Commit 444146a

Browse files
committed
There was a bug in the parseVersion code. Before it was converting the version to a ciphertext type and deserialzing it
when all it needed to do was compare the bytes.
1 parent 2031e39 commit 444146a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/com/amazonaws/encryptionsdk/model/CiphertextHeaders.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public Boolean isComplete() {
180180
*/
181181
private int parseVersion(final byte[] b, final int off) throws ParseException {
182182
version_ = PrimitivesParser.parseByte(b, off);
183-
if (CiphertextType.deserialize(version_).getValue() != VersionInfo.CURRENT_CIPHERTEXT_VERSION) {
183+
if (version_ != VersionInfo.CURRENT_CIPHERTEXT_VERSION) {
184184
throw new BadCiphertextException("Invalid version type.");
185185
}
186186
return 1;

src/test/java/com/amazonaws/encryptionsdk/model/CiphertextHeadersTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ public void invalidVersion(){
323323
final byte[] headerBytes = ciphertextHeaders.toByteArray();
324324
final ByteBuffer headerBuff = ByteBuffer.wrap(headerBytes);
325325

326-
readUptoType(headerBuff);
326+
readUptoVersion(headerBuff);
327327

328-
//set version to invalid value of 0.
328+
//set version to invalid type of 0.
329329
headerBuff.put((byte) 0);
330330

331331
final CiphertextHeaders reconstructedHeaders = new CiphertextHeaders();

0 commit comments

Comments
 (0)