mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 06:39:54 +01:00
Add javadocs.
This commit is contained in:
@@ -132,6 +132,9 @@ public interface CryptoComponent {
|
|||||||
* storage. The encryption and authentication keys are derived from the
|
* storage. The encryption and authentication keys are derived from the
|
||||||
* given password. The ciphertext will be decryptable using the same
|
* given password. The ciphertext will be decryptable using the same
|
||||||
* password after the app restarts.
|
* password after the app restarts.
|
||||||
|
*
|
||||||
|
* @param keyStoreConfig Configures the use of a stored key to strengthen
|
||||||
|
* the password-based key. If null, no stored key will be used
|
||||||
*/
|
*/
|
||||||
byte[] encryptWithPassword(byte[] plaintext, String password,
|
byte[] encryptWithPassword(byte[] plaintext, String password,
|
||||||
@Nullable KeyStoreConfig keyStoreConfig);
|
@Nullable KeyStoreConfig keyStoreConfig);
|
||||||
@@ -141,6 +144,10 @@ public interface CryptoComponent {
|
|||||||
* storage. The encryption and authentication keys are derived from the
|
* storage. The encryption and authentication keys are derived from the
|
||||||
* given password. Returns null if the ciphertext cannot be decrypted and
|
* given password. Returns null if the ciphertext cannot be decrypted and
|
||||||
* authenticated (for example, if the password is wrong).
|
* authenticated (for example, if the password is wrong).
|
||||||
|
*
|
||||||
|
* @param keyStoreConfig Configures the use of a stored key to strengthen
|
||||||
|
* the password-based key. If null, or if no stored key was used when
|
||||||
|
* encrypting the ciphertext, then no stored key will be used
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
byte[] decryptWithPassword(byte[] ciphertext, String password,
|
byte[] decryptWithPassword(byte[] ciphertext, String password,
|
||||||
|
|||||||
@@ -4,12 +4,20 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|||||||
|
|
||||||
import java.security.spec.AlgorithmParameterSpec;
|
import java.security.spec.AlgorithmParameterSpec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the use of a stored key to strengthen password-based encryption.
|
||||||
|
* The key may be stored in a hardware security module, but this is not
|
||||||
|
* guaranteed. See
|
||||||
|
* {@link CryptoComponent#encryptWithPassword(byte[], String, KeyStoreConfig)}
|
||||||
|
* and
|
||||||
|
* {@link CryptoComponent#decryptWithPassword(byte[], String, KeyStoreConfig)}.
|
||||||
|
*/
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public interface KeyStoreConfig {
|
public interface KeyStoreConfig {
|
||||||
|
|
||||||
String getKeyStoreType();
|
String getKeyStoreType();
|
||||||
|
|
||||||
String getAlias();
|
String getKeyAlias();
|
||||||
|
|
||||||
String getProviderName();
|
String getProviderName();
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,20 @@ import javax.annotation.Nullable;
|
|||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public interface DatabaseConfig {
|
public interface DatabaseConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the directory where the database stores its data.
|
||||||
|
*/
|
||||||
File getDatabaseDirectory();
|
File getDatabaseDirectory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the directory where the encrypted database key is stored.
|
||||||
|
*/
|
||||||
File getDatabaseKeyDirectory();
|
File getDatabaseKeyDirectory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link KeyStoreConfig} for strengthening the encryption of the
|
||||||
|
* database key, or null if no keystore should be used.
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
KeyStoreConfig getKeyStoreConfig();
|
KeyStoreConfig getKeyStoreConfig();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ class CryptoComponentImpl implements CryptoComponent {
|
|||||||
ks.load(null);
|
ks.load(null);
|
||||||
// Load or generate the stored key
|
// Load or generate the stored key
|
||||||
javax.crypto.SecretKey storedKey;
|
javax.crypto.SecretKey storedKey;
|
||||||
Entry e = ks.getEntry(config.getAlias(), null);
|
Entry e = ks.getEntry(config.getKeyAlias(), null);
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
if (!generateIfMissing) {
|
if (!generateIfMissing) {
|
||||||
LOG.warning("Key not found in keystore");
|
LOG.warning("Key not found in keystore");
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class AndroidKeyStoreConfig implements KeyStoreConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAlias() {
|
public String getKeyAlias() {
|
||||||
return "db";
|
return "db";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user