From cbb669aa4033331b1f5cccf1c8e43a3a2cd4992f Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Sun, 28 Feb 2016 17:49:21 +0100 Subject: [PATCH] reduced visibility of some classes --- .../cryptomator/crypto/engine/impl/Constants.java | 13 +++++++++++++ .../crypto/engine/impl/FileContentCryptorImpl.java | 10 ++++------ .../engine/impl/FileContentDecryptorImpl.java | 6 +++--- .../engine/impl/FileContentEncryptorImpl.java | 4 ++-- .../blockaligned/BlockAlignedFileSystemFactory.java | 5 +++-- .../cryptomator/filesystem/crypto/CryptoFile.java | 2 +- 6 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/Constants.java diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/Constants.java b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/Constants.java new file mode 100644 index 000000000..5b54a0288 --- /dev/null +++ b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/Constants.java @@ -0,0 +1,13 @@ +package org.cryptomator.crypto.engine.impl; + +public final class Constants { + + private Constants() { + } + + public static final int PAYLOAD_SIZE = 32 * 1024; + public static final int NONCE_SIZE = 16; + public static final int MAC_SIZE = 32; + public static final int CHUNK_SIZE = NONCE_SIZE + PAYLOAD_SIZE + MAC_SIZE; + +} diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FileContentCryptorImpl.java b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FileContentCryptorImpl.java index 2551ddbce..4cb800cda 100644 --- a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FileContentCryptorImpl.java +++ b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FileContentCryptorImpl.java @@ -8,6 +8,9 @@ *******************************************************************************/ package org.cryptomator.crypto.engine.impl; +import static org.cryptomator.crypto.engine.impl.Constants.CHUNK_SIZE; +import static org.cryptomator.crypto.engine.impl.Constants.PAYLOAD_SIZE; + import java.nio.ByteBuffer; import java.security.SecureRandom; import java.util.Optional; @@ -19,12 +22,7 @@ import org.cryptomator.crypto.engine.FileContentCryptor; import org.cryptomator.crypto.engine.FileContentDecryptor; import org.cryptomator.crypto.engine.FileContentEncryptor; -public class FileContentCryptorImpl implements FileContentCryptor { - - public static final int PAYLOAD_SIZE = 32 * 1024; - public static final int NONCE_SIZE = 16; - public static final int MAC_SIZE = 32; - public static final int CHUNK_SIZE = NONCE_SIZE + PAYLOAD_SIZE + MAC_SIZE; +class FileContentCryptorImpl implements FileContentCryptor { private final SecretKey encryptionKey; private final SecretKey macKey; diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FileContentDecryptorImpl.java b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FileContentDecryptorImpl.java index c06013316..e619cddc5 100644 --- a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FileContentDecryptorImpl.java +++ b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FileContentDecryptorImpl.java @@ -8,9 +8,9 @@ *******************************************************************************/ package org.cryptomator.crypto.engine.impl; -import static org.cryptomator.crypto.engine.impl.FileContentCryptorImpl.CHUNK_SIZE; -import static org.cryptomator.crypto.engine.impl.FileContentCryptorImpl.MAC_SIZE; -import static org.cryptomator.crypto.engine.impl.FileContentCryptorImpl.NONCE_SIZE; +import static org.cryptomator.crypto.engine.impl.Constants.CHUNK_SIZE; +import static org.cryptomator.crypto.engine.impl.Constants.MAC_SIZE; +import static org.cryptomator.crypto.engine.impl.Constants.NONCE_SIZE; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FileContentEncryptorImpl.java b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FileContentEncryptorImpl.java index 3f3e623bd..20b2eeea7 100644 --- a/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FileContentEncryptorImpl.java +++ b/main/filesystem-crypto/src/main/java/org/cryptomator/crypto/engine/impl/FileContentEncryptorImpl.java @@ -8,8 +8,8 @@ *******************************************************************************/ package org.cryptomator.crypto.engine.impl; -import static org.cryptomator.crypto.engine.impl.FileContentCryptorImpl.NONCE_SIZE; -import static org.cryptomator.crypto.engine.impl.FileContentCryptorImpl.PAYLOAD_SIZE; +import static org.cryptomator.crypto.engine.impl.Constants.NONCE_SIZE; +import static org.cryptomator.crypto.engine.impl.Constants.PAYLOAD_SIZE; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/blockaligned/BlockAlignedFileSystemFactory.java b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/blockaligned/BlockAlignedFileSystemFactory.java index e6f180233..692668467 100644 --- a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/blockaligned/BlockAlignedFileSystemFactory.java +++ b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/blockaligned/BlockAlignedFileSystemFactory.java @@ -8,10 +8,11 @@ *******************************************************************************/ package org.cryptomator.filesystem.blockaligned; +import static org.cryptomator.crypto.engine.impl.Constants.PAYLOAD_SIZE; + import javax.inject.Inject; import javax.inject.Singleton; -import org.cryptomator.crypto.engine.impl.FileContentCryptorImpl; import org.cryptomator.filesystem.FileSystem; import org.cryptomator.filesystem.Folder; @@ -23,6 +24,6 @@ public class BlockAlignedFileSystemFactory { } public FileSystem get(Folder root) { - return new BlockAlignedFileSystem(root, FileContentCryptorImpl.PAYLOAD_SIZE); + return new BlockAlignedFileSystem(root, PAYLOAD_SIZE); } } diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CryptoFile.java b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CryptoFile.java index dd1863d04..934e31ce3 100644 --- a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CryptoFile.java +++ b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/CryptoFile.java @@ -19,7 +19,7 @@ import org.cryptomator.filesystem.File; import org.cryptomator.filesystem.ReadableFile; import org.cryptomator.filesystem.WritableFile; -public class CryptoFile extends CryptoNode implements File { +class CryptoFile extends CryptoNode implements File { public CryptoFile(CryptoFolder parent, String name, Cryptor cryptor) { super(parent, name, cryptor);