Skip to content

Commit 2d9c7e5

Browse files
author
ortis
committed
Security update: PBKDF2, hash and multiple IV
1 parent 8981434 commit 2d9c7e5

25 files changed

+967
-158
lines changed

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
23
[![GitHub license](https://img.shields.io/github/license/0rtis/jsafebox.svg?style=flat-square)](https://github.com/0rtis/jsafebox/blob/master/LICENSE)
34
[![Build Status](https://img.shields.io/travis/0rtis/jsafebox.svg?style=flat-square)](https://travis-ci.org/0rtis/jsafebox)
45
[![codecov](https://img.shields.io/codecov/c/github/0rtis/jsafebox.svg?style=flat-square)](https://codecov.io/gh/0rtis/jsafebox)
@@ -21,7 +22,7 @@
2122

2223
# JSafebox - A lightweight, portable and cross-platform vault
2324

24-
JSafebox encrypt your file using [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) encryption. It can be used as command line tool or with a _file explorer_ like interface.
25+
JSafebox encrypt your files using [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) encryption. It can be used as command line tool or with a _file explorer_ like interface.
2526

2627
**Decrypted data is never written on the drive** (except during file extraction requested by user).
2728

@@ -34,35 +35,43 @@ JSafebox encrypt your file using [AES](https://en.wikipedia.org/wiki/Advanced_En
3435

3536
### Why JSafebox ?
3637
With the rise of online banking, cryptocurrencies and other digital transformation, it has become mandatory to backup sensitive files.
37-
Those file need to be easily accessible, securely stored and encrypted. But lightweight, portable, cross platform vault software are surprisingly hard to come by. Password protected archive works fine but they let room for file leakage as there is no convenient way of exploring the vault without extracting the whole content. Jsafebox was made to cover these shortfalls.
38+
Those file need to be easily accessible, securely stored and encrypted. But lightweight, portable, cross platform vault software are surprisingly hard to come by. Password protected archive works fine but they let room for file leakage since there is no convenient way of exploring the vault without extracting the whole content. Jsafebox was made to cover these shortfalls.
3839

3940

4041

4142

4243

4344

4445
### JSafebox Protocol
45-
JSafebox is using a very simple protocol so encrypted files can be easily read by another program, as long as you have the encryption password.
46-
Each datagram is preceded by its length stored as a 64 bits (8 bytes) integer (`long` in Java):
46+
JSafebox is using a very simple protocol so encrypted files can be easily read by another program, as long as you have the password. The encryption key is derived from the password using [PBKDF2](https://en.wikipedia.org/wiki/PBKDF2) hashing with 100000 iteration.
47+
48+
A JSafebox file contains a [SHA256](https://en.wikipedia.org/wiki/SHA-2) integrity hash followed by blocks:
49+
50+
integrity hash | block 0 | block 1 | ... | block N
4751

48-
length 0|datagram 0|length 1|datagram 1|length 3|...|datagram N
52+
Each block is stored as followed:
53+
54+
IV | metadata length | metadata | data length | data
4955

50-
The first datagram `datagram 0` is the *header* and is **the only datagram not encrypted**. The *header* contains text entries specified by the user and various additional entries incuding a protocol explanation, the type of encoding and the IV of the encryption. The *header*'s data is stored in JSON format and can be seen by opening the safe file with a basic text editor.
56+
where `IV` is the [Initialization_vector](https://en.wikipedia.org/wiki/Initialization_vector) of the encryption (16 bytes), `metadata` is a JSON string and `length` are 64 bits (8 bytes) integer (`long` in Java).
57+
58+
The first block `block 0` is the *header* and is **the only block not encrypted** and therefore, **the only block without IV**. The *header* only have metadata (`data length` is 0) and contains text entries specified by the user and various additional entries including a protocol explanation, the type of encoding and the parameters of the encryption. The *header*'s metadata is stored as JSON string and can be seen by opening the safe file with a basic text editor.
5159

52-
The second datagram `datagram 1` is the *properties*. It contains encrypted text entries specified by the user.
60+
The second block `block 1` is the *properties*. It is similar to the *header* except that it is encrypted and have an IV. The *properties* contains text entries specified by the user and stored in JSON.
5361

54-
The following datagrams (from 2 to N) are the encrypted files. They work by pair: `datagram i ` contains the metadata of the file as an encrypted JSON text and `datagram i+1` contains the bytes of the encrypted file.
62+
The following blocks (from 2 to N) are the encrypted files.
5563

5664

5765

5866
### TODO
59-
- [x] Command line
67+
- [x] Command line (with the mighty tiny [picocli](https://github.com/remkop/picocli) project)
6068
- [x] Wildcard path support
6169
- [x] File explorer
6270
- [x] Import with Drag & Drop
63-
- [ ] Export with Drag & Drop
71+
- [x] Export ~~with Drag & Drop~~ (Risk of unintentional drag resulting in data leak)
6472
- [x] Text viewer
6573
- [x] Image viewer (zoom and drag)
74+
- [x] Integrity check
6675
- [ ] Interactive shell
6776

6877

@@ -71,7 +80,6 @@ The following datagrams (from 2 to N) are the encrypted files. They work by pair
7180

7281
You can download the latest version of JSafebox [here](https://github.com/0rtis/jsafebox/releases/latest)
7382

74-
*JSafebox is using the mighty tiny [picocli](https://github.com/remkop/picocli)*
7583

7684

7785
### Install

src/main/java/org/ortis/jsafebox/Block.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public class Block implements SafeFile
2525
private final String comparablePath;
2626
private final long offset;
2727
private final long length;
28+
29+
2830
private final long metaOffset;
2931
private final long metaLength;
3032
private final long dataOffset;
@@ -35,17 +37,19 @@ public class Block implements SafeFile
3537
private final Folder parent;
3638

3739
public Block(final String path, final Map<String, String> properties, final long offset, final long length, final long metaOffset, final long metaLength, final long dataOffset,
38-
final long dataLength, final Folder parent)
40+
final long dataLength, final Folder parent)
3941
{
4042
this.path = path;
4143
this.comparablePath = path.toUpperCase(Environment.getLocale());
4244
this.offset = offset;
4345
this.length = length;
46+
4447
this.metaOffset = metaOffset;
4548
this.metaLength = metaLength;
4649
this.dataOffset = dataOffset;
4750
this.dataLength = dataLength;
4851

52+
4953
final Map<String, String> props = new LinkedHashMap<>();
5054
props.putAll(properties);
5155

0 commit comments

Comments
 (0)