Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
fix: Corrected names of some incorrectly named methods and variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Schwab committed Jan 4, 2021
1 parent 2f09f78 commit ed95f10
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [5.4.2] - 2021-01-04

### Changed
- Corrected names of some incorrectly named methods and variables.

## [5.4.1] - 2020-12-30

### Changed
Expand Down
23 changes: 12 additions & 11 deletions src/de/db/bcm/tupw/crypto/SplitKeyEncryption.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, DB Systel GmbH
* Copyright (c) 2021, DB Systel GmbH
* All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -65,6 +65,7 @@
* 2020-12-04: V5.3.1: Corrected several SonarLint findings. fhs
* 2020-12-29: V5.4.0: Made thread safe. fhs
* 2020-12-30: V5.4.1: Removed synchronization where it was not necessary. fhs
* 2021-01-04: V5.4.2: Corrected wrong method and variable names. fhs
*/
package de.db.bcm.tupw.crypto;

Expand All @@ -90,7 +91,7 @@
* Implement encryption by key generated from several source bytes and a key
*
* @author Frank Schwab, DB Systel GmbH
* @version 5.4.1
* @version 5.4.2
*/

public class SplitKeyEncryption implements AutoCloseable {
Expand Down Expand Up @@ -747,18 +748,18 @@ private EncryptionParts getPartsFromPrintableString(final String encryptionText)
}

/**
* Return unpadded string bytes depending on format id
* Return unpadded data bytes depending on format id
*
* @param formatId Format id of data
* @param paddedDecryptedStringBytes Byte array of padded decrypted bytes
* @param formatId Format id of data
* @param paddedDecryptedDataBytes Byte array of padded decrypted bytes
* @return Unpadded decrypted bytes
*/
private byte[] getUnpaddedStringBytes(final byte formatId, final byte[] paddedDecryptedStringBytes) {
private byte[] getUnpaddedDataBytes(final byte formatId, final byte[] paddedDecryptedDataBytes) {
// Formats 1 and 2 use padding. Starting from format 3 blinding is used.
if (formatId >= FORMAT_ID_USE_BLINDING)
return ByteArrayBlinding.unBlindByteArray(paddedDecryptedStringBytes);
return ByteArrayBlinding.unBlindByteArray(paddedDecryptedDataBytes);
else
return ArbitraryTailPadding.removePadding(paddedDecryptedStringBytes);
return ArbitraryTailPadding.removePadding(paddedDecryptedDataBytes);
}

/**
Expand Down Expand Up @@ -891,13 +892,13 @@ private byte[] rawDataDecryption(final EncryptionParts encryptionParts, final by

aesCipher.init(Cipher.DECRYPT_MODE, decryptionKey, new IvParameterSpec(encryptionParts.iv));

final byte[] paddedDecryptedStringBytes = aesCipher.doFinal(encryptionParts.encryptedData);
final byte[] paddedDecryptedDataBytes = aesCipher.doFinal(encryptionParts.encryptedData);

decryptionKey.close();

final byte[] result = getUnpaddedStringBytes(encryptionParts.formatId, paddedDecryptedStringBytes);
final byte[] result = getUnpaddedDataBytes(encryptionParts.formatId, paddedDecryptedDataBytes);

Arrays.fill(paddedDecryptedStringBytes, FILL_BYTE);
Arrays.fill(paddedDecryptedDataBytes, FILL_BYTE);

return result;
}
Expand Down

0 comments on commit ed95f10

Please sign in to comment.