Skip to content

Commit 7415aa4

Browse files
author
Hugo Rosenkranz-Costa
committed
Merge branch 'release/v8.0.0'
2 parents eda9cdc + 31a3540 commit 7415aa4

24 files changed

Lines changed: 795 additions & 273 deletions

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
build_in_docker:
5050
services:
5151
kms:
52-
image: ghcr.io/cosmian/kms:4.10.0
52+
image: ghcr.io/cosmian/kms:4.13.0
5353
ports:
5454
- 9998:9998
5555
findex_cloud:
@@ -161,7 +161,7 @@ jobs:
161161
with:
162162
branch: develop
163163
target: wasm32-unknown-unknown
164-
kms-version: 4.10.0
164+
kms-version: ghcr.io/cosmian/kms:4.13.0
165165
findex-cloud-version: 0.3.1
166166
copy_fresh_build: false
167167
copy_regression_files: |
@@ -174,7 +174,7 @@ jobs:
174174
with:
175175
branch: develop
176176
target: x86_64-unknown-linux-gnu
177-
kms-version: 4.10.0
177+
kms-version: ghcr.io/cosmian/kms:4.13.0
178178
findex-cloud-version: 0.3.1
179179
copy_fresh_build: false
180180
copy_regression_files: |
@@ -185,7 +185,7 @@ jobs:
185185
needs: build_in_docker
186186
uses: Cosmian/reusable_workflows/.github/workflows/cloudproof_flutter.yml@develop
187187
with:
188-
branch: develop
188+
branch: feature/covercrypt_rekey
189189
target: x86_64-unknown-linux-gnu
190190
extension: so
191191
copy_fresh_build: false

.pre-commit-config.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
exclude: src/test/java/com/cosmian/TestUtils.java|src/test/resources
1010
repos:
1111
- repo: https://github.com/compilerla/conventional-pre-commit
12-
rev: v2.1.1
12+
rev: v3.1.0
1313
hooks:
1414
- id: conventional-pre-commit
1515
stages: [commit-msg]
@@ -23,7 +23,7 @@ repos:
2323
- id: markdown-toc
2424

2525
- repo: https://github.com/pre-commit/mirrors-prettier
26-
rev: v3.0.0-alpha.4
26+
rev: v4.0.0-alpha.8
2727
hooks:
2828
- id: prettier
2929
stages: [commit]
@@ -32,7 +32,7 @@ repos:
3232
- markdown
3333

3434
- repo: https://github.com/igorshubovych/markdownlint-cli
35-
rev: v0.32.2
35+
rev: v0.39.0
3636
hooks:
3737
- id: markdownlint-fix
3838
args: [--disable=MD004, --disable=MD013, --disable=MD024, --disable=MD041]
@@ -44,26 +44,26 @@ repos:
4444
args: [-q]
4545

4646
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
47-
rev: 0.2.2
47+
rev: 0.2.3
4848
hooks:
4949
- id: yamlfmt
5050
args: [--mapping, '2', --sequence, '4', --offset, '2']
5151

5252
- repo: https://github.com/crate-ci/typos
53-
rev: v1.13.0
53+
rev: typos-v0.10.21
5454
hooks:
5555
- id: typos
5656

5757
- repo: https://github.com/Lucas-C/pre-commit-hooks
58-
rev: v1.3.1
58+
rev: v1.5.4
5959
hooks:
6060
- id: forbid-crlf
6161
- id: remove-crlf
6262
- id: forbid-tabs
6363
- id: remove-tabs
6464

6565
- repo: https://github.com/sirosen/texthooks
66-
rev: 0.4.0
66+
rev: 0.6.4
6767
hooks:
6868
- id: fix-smartquotes
6969
- id: fix-ligatures
@@ -77,7 +77,7 @@ repos:
7777
- id: shellcheck
7878

7979
- repo: https://github.com/pre-commit/pre-commit-hooks
80-
rev: v4.4.0
80+
rev: v4.5.0
8181
hooks:
8282
- id: check-added-large-files
8383
- id: check-ast
@@ -108,7 +108,7 @@ repos:
108108
- id: trailing-whitespace
109109

110110
- repo: https://github.com/psf/black
111-
rev: 22.12.0
111+
rev: 24.2.0
112112
hooks:
113113
- id: black
114114
# avoid clash with `double-quote-string-fixer`

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [8.0.0] - 2024-03-13
6+
7+
### Features
8+
9+
- Upgrade to CoverCrypt `14.0.0`:
10+
- Support Covercrypt KMS edit policy capability
11+
- Replace policy `rotate` with `rekeyMasterKeys`
12+
513
## [7.0.0] - 2023-12-11
614

715
### Features

README.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Cloudproof Java Library
22

3-
![workflow](https://github.com/Cosmian/cloudproof_java/actions/workflows/maven.yml/badge.svg)
3+
![workflow](https://github.com/Cosmian/cloudproof_java/actions/workflows/ci.yml/badge.svg)
44

55
The Cloudproof Java library provides a Java-friendly API to [Cosmian's Cloudproof Encryption](https://docs.cosmian.com/).
66

@@ -86,26 +86,19 @@ key is half hybridized).
8686

8787
## Versions Correspondence
8888

89-
This library uses the 2 native libraries CoverCrypt and Findex for performance and safe implementation reasons.
89+
This library uses [cloudproof_rust](https://github.com/Cosmian/cloudproof_rust) for both CoverCrypt and Findex FFI interface.
9090

9191
This table shows the compatible versions of the various components
9292

93-
| This lib | KMS Server | CoverCrypt | Findex |
94-
|----------|------------|------------|--------|
95-
| 3.0.0 | 4.0.1 | 8.0.1 | 1.0.1 |
96-
| 3.0.2 | 4.0.1 | 8.0.1 | 2.0.0 |
97-
| 3.0.3 | 4.0.1 | 8.0.2 | 2.0.0 |
98-
| 4.0.0 | 4.2.0 | 10.0.0 | 2.0.1 |
99-
| 4.0.1 | 4.2.0 | 10.0.0 | 2.0.1 |
100-
| 4.1.0 | 4.2.0 | 10.0.0 | 2.1.0 |
101-
10293
From the version 5.0.0, `cloudproof_java` depends on [cloudproof_rust](https://github.com/Cosmian/cloudproof_rust) which wraps the interfaces of `CoverCrypt` and `Findex`.
10394

10495
| This lib | KMS Server | Cloudproof Rust lib |
10596
|----------|------------|---------------------|
10697
| 5.0.0 | 4.3.3 | 1.0.0 |
10798
| 6.0.0 | 4.3.3 | 2.0.1 |
10899
| 7.0.0 | 4.10.0 | 2.4.0 |
100+
| 7.1.0 | 4.11.0 | 2.4.0 |
101+
| 7.2.0 | 4.11.3 | 2.4.0 |
109102

110103
## Using in Java projects
111104

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ services:
1313
- PGDATA=/tmp/postgres2
1414
kms:
1515
container_name: kms
16-
image: ghcr.io/cosmian/kms:4.10.0
16+
image: ghcr.io/cosmian/kms:4.11.3
1717
ports:
1818
- 9998:9998
1919
depends_on:

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.cosmian</groupId>
77
<artifactId>cloudproof_java</artifactId>
8-
<version>7.0.0</version>
8+
<version>8.0.0</version>
99

1010
<name>cloudproof_java</name>
1111
<description>The Cloudproof Java Lib secures data repositories in the cloud with attributes-based access control encryption and encrypted search</description>

scripts/get_native_libraries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ def download_native_libraries(version: str) -> bool:
6262

6363

6464
if __name__ == '__main__':
65-
RET = download_native_libraries('v2.4.0')
65+
RET = download_native_libraries('v3.0.0')
6666
if RET is False and getenv('GITHUB_ACTIONS'):
67-
download_native_libraries('last_build/fix/rename_findex_traits')
67+
download_native_libraries('last_build/feature/covercrypt_rekey')

src/main/java/com/cosmian/jna/covercrypt/ffi/CoverCryptWrapper.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,26 @@ int h_hybrid_decrypt(byte[] plaintext,
141141
byte[] userDecryptionKeyBuffer,
142142
int userDecryptionKeyLength);
143143

144+
int h_rekey_master_keys(byte[] updatedMsk,
145+
IntByReference updatedMskSize,
146+
byte[] updatedMpk,
147+
IntByReference updatedMpkSize,
148+
byte[] currentMsk,
149+
int currentMskLength,
150+
byte[] currentMpk,
151+
int currentMpkLength,
152+
String accessPolicy,
153+
byte[] policyBytes,
154+
int policyBytesSize);
155+
156+
int h_prune_master_secret_key(byte[] updatedMsk,
157+
IntByReference updatedMskSize,
158+
byte[] currentMsk,
159+
int currentMskLength,
160+
String accessPolicy,
161+
byte[] policyBytes,
162+
int policyBytesSize);
163+
144164
//
145165
// Policy APIs
146166
//
@@ -154,12 +174,6 @@ int h_add_policy_axis(byte[] updatedPolicyBuffer,
154174
int currentPolicyBufferSize,
155175
String axis);
156176

157-
int h_rotate_attribute(byte[] updatedPolicyBuffer,
158-
IntByReference updatedPolicyBufferSize,
159-
byte[] currentPolicyBuffer,
160-
int currentPolicyBufferSize,
161-
String attribute);
162-
163177
int h_validate_boolean_expression(String booleanExpression);
164178

165179
int h_validate_attribute(String booleanExpression);

src/main/java/com/cosmian/jna/covercrypt/structs/MasterKeys.java

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package com.cosmian.jna.covercrypt.structs;
22

3-
public class MasterKeys {
3+
import java.util.Arrays;
44

5-
private final byte[] privateKey;
5+
import com.cosmian.utils.CloudproofException;
6+
import com.sun.jna.ptr.IntByReference;
67

7-
private final byte[] publicKey;
8+
public class MasterKeys extends Ffi {
9+
10+
private byte[] privateKey;
11+
12+
private byte[] publicKey;
813

914
public MasterKeys(byte[] privateKey, byte[] publicKey) {
1015
this.privateKey = privateKey;
@@ -18,4 +23,49 @@ public byte[] getPrivateKey() {
1823
public byte[] getPublicKey() {
1924
return publicKey;
2025
}
26+
27+
public void rekeyMasterKeys(String accessPolicy, Policy policy) throws CloudproofException {
28+
// Master Private Key
29+
byte[] updatedMsk = new byte[8 * 1024];
30+
IntByReference updatedMskSize = new IntByReference(updatedMsk.length);
31+
32+
// Master Public Key OUT
33+
byte[] updatedMpk = new byte[8 * 1024];
34+
IntByReference updatedMpkSize = new IntByReference(updatedMpk.length);
35+
36+
int ffiCode = INSTANCE.h_rekey_master_keys(updatedMsk, updatedMskSize,
37+
updatedMpk, updatedMpkSize, privateKey, privateKey.length, publicKey, publicKey.length, accessPolicy, policy.getBytes(), policy.getBytes().length);
38+
39+
if (ffiCode == 1) {
40+
// Retry with correct allocated size
41+
updatedMsk = new byte[updatedMskSize.getValue()];
42+
updatedMpk = new byte[updatedMpkSize.getValue()];
43+
INSTANCE.h_rekey_master_keys(updatedMsk, updatedMskSize,
44+
updatedMpk, updatedMpkSize, privateKey, privateKey.length, publicKey, publicKey.length, accessPolicy, policy.getBytes(), policy.getBytes().length);
45+
} else {
46+
unwrap(ffiCode);
47+
}
48+
49+
this.privateKey = Arrays.copyOfRange(updatedMsk, 0, updatedMskSize.getValue());
50+
this.publicKey = Arrays.copyOfRange(updatedMpk, 0, updatedMpkSize.getValue());
51+
}
52+
53+
public void pruneMasterSecretKey(String accessPolicy, Policy policy) throws CloudproofException {
54+
// Master Private Key
55+
byte[] updatedMsk = new byte[8 * 1024];
56+
IntByReference updatedMskSize = new IntByReference(updatedMsk.length);
57+
58+
int ffiCode = INSTANCE.h_prune_master_secret_key(updatedMsk, updatedMskSize,
59+
privateKey, privateKey.length, accessPolicy, policy.getBytes(), policy.getBytes().length);
60+
61+
if (ffiCode == 1) {
62+
// Retry with correct allocated size
63+
updatedMsk = new byte[updatedMskSize.getValue()];
64+
INSTANCE.h_prune_master_secret_key(updatedMsk, updatedMskSize,
65+
privateKey, privateKey.length, accessPolicy, policy.getBytes(), policy.getBytes().length);
66+
} else {
67+
unwrap(ffiCode);
68+
}
69+
this.privateKey = Arrays.copyOfRange(updatedMsk, 0, updatedMskSize.getValue());
70+
}
2171
}

src/main/java/com/cosmian/jna/covercrypt/structs/Policy.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,6 @@ public static Policy fromAttributes(Attributes attributes) throws CloudproofExce
119119
throw new CloudproofException("No policy available in the vendor attributes");
120120
}
121121

122-
public void rotateAttributes(String[] attributes) throws CloudproofException {
123-
byte[] updatedPolicyBuffer = new byte[8192];
124-
IntByReference updatedPolicyBufferSize = new IntByReference(updatedPolicyBuffer.length);
125-
for (String attr : attributes) {
126-
unwrap(INSTANCE.h_rotate_attribute(updatedPolicyBuffer, updatedPolicyBufferSize, _bytes,
127-
_bytes.length, attr));
128-
_bytes = Arrays.copyOfRange(updatedPolicyBuffer, 0, updatedPolicyBufferSize.getValue());
129-
updatedPolicyBufferSize.setValue(updatedPolicyBuffer.length);
130-
}
131-
}
132-
133122
@Override
134123
public boolean equals(Object o) {
135124
if (o == this)

0 commit comments

Comments
 (0)