Added stuff
This commit is contained in:
parent
00406867f4
commit
00c343e673
13
README.md
13
README.md
|
@ -1,2 +1,15 @@
|
|||
# CrystalKeep
|
||||
|
||||
A comprehensive solution for encrypted data storage.
|
||||
|
||||
# Features
|
||||
|
||||
- Simple Key -> Value storage
|
||||
- Username / password logins
|
||||
- Files / Directories
|
||||
|
||||
# Design
|
||||
|
||||
CrystalKeep makes use of _Shards_ as the most basic form of encrypted data storage. A shard is a single data item, like login credentials, an image, or some text. One or more shards are stored in a _Cluster_, which is essentially a collection of shards (and possibly nested clusters). Top-level clusters (not nested inside another) can be encrypted and saved with a secret key passphrase.
|
||||
|
||||
With this approach, the user minimizes the amount of data that is accessible to an attacker in the event that the attacker gets access to the system while the contents of a cluster are unencrypted in memory, since only one cluster may be actively open at a time.
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>nl.andrewlalis</groupId>
|
||||
<artifactId>crystalkeep</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<javafx.version>16</javafx.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<version>0.0.4</version>
|
||||
<configuration>
|
||||
<mainClass>nl.andrewlalis.crystalkeep.CrystalKeep</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.20</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,7 @@
|
|||
package nl.andrewlalis.crystalkeep;
|
||||
|
||||
public class CrystalKeep {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package nl.andrewlalis.crystalkeep.model;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
public class Cluster {
|
||||
private final Set<Shard> shards;
|
||||
private final Set<Cluster> clusters;
|
||||
private final Cluster parent;
|
||||
|
||||
public Cluster(Set<Shard> shards, Set<Cluster> clusters, Cluster parent) {
|
||||
this.shards = shards;
|
||||
this.clusters = clusters;
|
||||
this.parent = parent;
|
||||
if (this.parent != null) {
|
||||
this.parent.addCluster(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Cluster() {
|
||||
this(new HashSet<>(), new HashSet<>(), null);
|
||||
}
|
||||
|
||||
public void addShard(Shard shard) {
|
||||
if (!this.equals(shard.getCluster())) {
|
||||
throw new IllegalArgumentException("Shard must have correct cluster set before adding it to shard.");
|
||||
}
|
||||
this.shards.add(shard);
|
||||
}
|
||||
|
||||
public void addCluster(Cluster cluster) {
|
||||
if (!this.equals(cluster.getParent())) {
|
||||
throw new IllegalArgumentException("Cluster must have correct parent set before adding it to cluster.");
|
||||
}
|
||||
this.clusters.add(cluster);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package nl.andrewlalis.crystalkeep.model;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class ClusterSerializer {
|
||||
public byte[] toBytes(Cluster cluster) throws IOException {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
bos.write(this.toBytes(cluster.getClusters().size()));
|
||||
for (Cluster child : cluster.getClusters()) {
|
||||
bos.write(this.toBytes(child));
|
||||
}
|
||||
bos.write(this.toBytes(cluster.getShards().size()));
|
||||
for (Shard shard : cluster.getShards()) {
|
||||
bos.write(shard.toBytes());
|
||||
}
|
||||
return bos.toByteArray();
|
||||
}
|
||||
|
||||
public Cluster fromBytes(ByteArrayInputStream bis, Cluster parent) throws IOException {
|
||||
Cluster cluster = new Cluster(new HashSet<>(), new HashSet<>(), parent);
|
||||
int childCount = this.toInt(bis.readNBytes(4));
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
cluster.addCluster(this.fromBytes(bis, cluster));
|
||||
}
|
||||
int shardCount = this.toInt(bis.readNBytes(4));
|
||||
for (int i = 0; i < shardCount; i++) {
|
||||
cluster.addShard(Shard.fromBytes(bis));
|
||||
}
|
||||
return cluster;
|
||||
}
|
||||
|
||||
public byte[] toBytes(int x) {
|
||||
return ByteBuffer.allocate(4).putInt(x).array();
|
||||
}
|
||||
|
||||
public int toInt(byte[] bytes) {
|
||||
assert(bytes.length == 4);
|
||||
return ByteBuffer.wrap(bytes).getInt();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package nl.andrewlalis.crystalkeep.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
public abstract class Shard implements Comparable<Shard> {
|
||||
private final Cluster cluster;
|
||||
@Setter
|
||||
private String name;
|
||||
private final LocalDateTime createdAt;
|
||||
|
||||
public Shard(Cluster cluster, String name, LocalDateTime createdAt) {
|
||||
this.cluster = cluster;
|
||||
this.cluster.addShard(this);
|
||||
this.name = name;
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Shard o) {
|
||||
int r = this.getName().compareTo(o.getName());
|
||||
if (r != 0) return r;
|
||||
return this.getCreatedAt().compareTo(o.getCreatedAt());
|
||||
}
|
||||
|
||||
public byte[] toBytes() {
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
public static Shard fromBytes(ByteArrayInputStream bis) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package nl.andrewlalis.crystalkeep.model.shards;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import nl.andrewlalis.crystalkeep.model.Cluster;
|
||||
import nl.andrewlalis.crystalkeep.model.Shard;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class LoginCredentialsShard extends Shard {
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public LoginCredentialsShard(Cluster cluster, String name, LocalDateTime createdAt, String username, String password) {
|
||||
super(cluster, name, createdAt);
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package nl.andrewlalis.crystalkeep.model.shards;
|
||||
|
||||
import nl.andrewlalis.crystalkeep.model.Cluster;
|
||||
import nl.andrewlalis.crystalkeep.model.Shard;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class TextShard extends Shard {
|
||||
private String text;
|
||||
|
||||
public TextShard(Cluster cluster, String name, LocalDateTime createdAt, String text) {
|
||||
super(cluster, name, createdAt);
|
||||
this.text = text;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
|
||||
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<center>
|
||||
<TabPane prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" BorderPane.alignment="CENTER">
|
||||
<tabs>
|
||||
<Tab text="Shards" />
|
||||
<Tab text="Untitled Tab 2" />
|
||||
</tabs>
|
||||
</TabPane>
|
||||
</center>
|
||||
</BorderPane>
|
Loading…
Reference in New Issue