You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Aegis/app/src/main/java/com/beemdevelopment/aegis/vault/VaultFileCredentials.java

58 lines
1.6 KiB
Java

package com.beemdevelopment.aegis.vault;
import androidx.annotation.NonNull;
import com.beemdevelopment.aegis.crypto.CryptParameters;
import com.beemdevelopment.aegis.crypto.CryptResult;
import com.beemdevelopment.aegis.crypto.MasterKey;
import com.beemdevelopment.aegis.crypto.MasterKeyException;
import com.beemdevelopment.aegis.util.Cloner;
import com.beemdevelopment.aegis.vault.slots.SlotList;
import java.io.Serializable;
public class VaultFileCredentials implements Serializable {
private MasterKey _key;
private SlotList _slots;
public VaultFileCredentials() {
_key = MasterKey.generate();
_slots = new SlotList();
}
public VaultFileCredentials(MasterKey key, SlotList slots) {
_key = key;
_slots = slots;
}
public CryptResult encrypt(byte[] bytes) throws MasterKeyException {
return _key.encrypt(bytes);
}
public CryptResult decrypt(byte[] bytes, CryptParameters params) throws MasterKeyException {
return _key.decrypt(bytes, params);
}
public MasterKey getKey() {
return _key;
}
public SlotList getSlots() {
return _slots;
}
/**
* Returns a copy of these VaultFileCredentials that is suitable for exporting.
* In case there's a backup password slot, any regular password slots are stripped.
*/
public VaultFileCredentials exportable() {
return new VaultFileCredentials(_key, _slots.exportable());
}
@NonNull
@Override
public VaultFileCredentials clone() {
return Cloner.clone(this);
}
}