Skip to content

Commit 6dcfe47

Browse files
committed
chore: merge branch 'release/v5.0.0'
2 parents 77a3e96 + a422786 commit 6dcfe47

14 files changed

Lines changed: 125 additions & 68 deletions

File tree

.github/workflows/maven.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
build_in_docker:
5050
services:
5151
kms:
52-
image: cosmian/kms:4.2.0
52+
image: cosmian/kms:4.3.3
5353
env:
5454
COSMIAN_SERVER_URL: http://localhost:9998
5555
KMS_PUBLIC_PATH: /tmp
@@ -94,7 +94,28 @@ jobs:
9494
- run: python3 scripts/get_native_libraries.py
9595

9696
- name: Build with Maven
97-
run: mvn package
97+
run: mvn compile
98+
env:
99+
COSMIAN_SERVER_URL: http://kms:9998
100+
REDIS_HOSTNAME: redis
101+
REDIS_PORT: 6379
102+
LANG: en_US.UTF-8
103+
LANGUAGE: en_US:en
104+
LC_ALL: en_US.UTF-8
105+
106+
- name: Test with Maven
107+
run: mvn test
108+
env:
109+
COSMIAN_SERVER_URL: http://kms:9998
110+
REDIS_HOSTNAME: redis
111+
REDIS_PORT: 6379
112+
LANG: en_US.UTF-8
113+
LANGUAGE: en_US:en
114+
LC_ALL: en_US.UTF-8
115+
116+
- name: Bench with Maven
117+
if: startsWith(github.ref, 'refs/tags/')
118+
run: mvn test -Dtest='TestBenchesCoverCrypt'
98119
env:
99120
COSMIAN_SERVER_URL: http://kms:9998
100121
REDIS_HOSTNAME: redis
@@ -119,7 +140,7 @@ jobs:
119140
with:
120141
branch: develop
121142
target: wasm32-unknown-unknown
122-
kms-version: 4.2.0
143+
kms-version: 4.3.3
123144
copy_fresh_build: false
124145
copy_regression_files: |
125146
cp ./cloudproof_java/non_regression_vector.json tests/data/cover_crypt/non_regression/java_non_regression_vector.json
@@ -131,7 +152,7 @@ jobs:
131152
with:
132153
branch: develop
133154
target: x86_64-unknown-linux-gnu
134-
kms-version: 4.2.0
155+
kms-version: 4.3.3
135156
copy_fresh_build: false
136157
copy_regression_files: |
137158
cp ./cloudproof_java/non_regression_vector.json tests/data/cover_crypt/non_regression/java_non_regression_vector.json
@@ -191,7 +212,7 @@ jobs:
191212
passphrase: ${{ secrets.GPG_PASSPHRASE }}
192213

193214
- name: Maven deploy
194-
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
215+
if: startsWith(github.ref, 'refs/tags/')
195216
run: |
196217
sudo apt-get update
197218
sudo apt-get install -y gnupg2
@@ -211,7 +232,7 @@ jobs:
211232
steps:
212233
- uses: actions/checkout@v1
213234
- name: Release
214-
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
235+
if: startsWith(github.ref, 'refs/tags/')
215236
uses: softprops/action-gh-release@v1
216237

217238
cleanup:

CHANGELOG.md

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

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

5+
---
6+
7+
## [5.0.0] - 2023-03-08
8+
9+
### Features
10+
11+
- Support CoverCrypt 11.0 and Findex 3.0 (#58)
12+
13+
---
14+
515
## [4.1.0] - 2023-03-01
616

717
### Ci

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ This table shows the compatible versions of the various components
9898
| 4.0.1 | 4.2.0 | 10.0.0 | 2.0.1 |
9999
| 4.1.0 | 4.2.0 | 10.0.0 | 2.1.0 |
100100

101+
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`.
102+
103+
| This lib | KMS Server | Cloudproof Rust lib |
104+
|----------|------------|---------------------|
105+
| 5.0.0 | 4.3.3 | 1.0.0 |
106+
101107
## Using in Java projects
102108

103109
This library is open-source software and is available on Maven Central.
@@ -106,7 +112,7 @@ This library is open-source software and is available on Maven Central.
106112
<dependency>
107113
<groupId>com.cosmian</groupId>
108114
<artifactId>cloudproof_java</artifactId>
109-
<version>4.1.0</version>
115+
<version>5.0.0</version>
110116
</dependency>
111117
```
112118

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: cosmian/kms:4.2.0
16+
image: cosmian/kms:4.3.3
1717
environment:
1818
- KMS_HOSTNAME=0.0.0.0
1919
- KMS_PUBLIC_PATH=/tmp

pom.xml

Lines changed: 11 additions & 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>4.1.0</version>
8+
<version>5.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>
@@ -197,6 +197,16 @@
197197
<autoReleaseAfterClose>true</autoReleaseAfterClose>
198198
</configuration>
199199
</plugin>
200+
<plugin>
201+
<groupId>org.apache.maven.plugins</groupId>
202+
<artifactId>maven-surefire-plugin</artifactId>
203+
<version>2.19.1</version>
204+
<configuration>
205+
<excludes>
206+
<exclude>**/*TestBenchesCoverCrypt.java</exclude>
207+
</excludes>
208+
</configuration>
209+
</plugin>
200210
</plugins>
201211
</build>
202212
</project>

scripts/get_native_libraries.py

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,64 @@
55
from os import getenv, path, remove
66

77

8-
def download_native_libraries(name: str, version: str, destination: str) -> bool:
9-
mac = f'{destination}/darwin-x86-64/libcosmian_{name}.dylib'
10-
linux = f'{destination}/linux-x86-64/libcosmian_{name}.so'
11-
windows = f'{destination}/win32-x86-64/cosmian_{name}.dll'
8+
def files_to_be_copied(name: str):
9+
"""
10+
Returns the list of files to be copied
11+
"""
12+
destination = 'src/main/resources'
13+
return {
14+
f'tmp/x86_64-apple-darwin/x86_64-apple-darwin/release/libcloudproof_{name}.dylib': f'{destination}/darwin-x86-64/libcloudproof_{name}.dylib',
15+
f'tmp/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/release/libcloudproof_{name}.so': f'{destination}/linux-x86-64/libcloudproof_{name}.so',
16+
f'tmp/x86_64-pc-windows-gnu/x86_64-pc-windows-gnu/release/cloudproof_{name}.dll': f'{destination}/win32-x86-64/cloudproof_{name}.dll',
17+
}
1218

13-
if not path.exists(mac) or not path.exists(linux) or not path.exists(windows):
14-
print(
15-
f'Missing {name} native library. Copy {name} {version} to {destination}...'
16-
)
1719

18-
url = f'https://package.cosmian.com/{name}/{version}/all.zip'
19-
try:
20-
r = urllib.request.urlopen(url)
21-
if r.getcode() != 200:
22-
print(f'Cannot get {name} {version} (status code: {r.getcode()})')
23-
else:
24-
if path.exists('tmp'):
25-
shutil.rmtree('tmp')
26-
if path.exists('all.zip'):
27-
remove('all.zip')
20+
def download_native_libraries(version: str) -> bool:
21+
"""Download and extract native libraries"""
22+
to_be_copied = files_to_be_copied('findex')
23+
cover_crypt_files = files_to_be_copied('cover_crypt')
24+
to_be_copied.update(cover_crypt_files)
2825

29-
open('all.zip', 'wb').write(r.read())
30-
with zipfile.ZipFile('all.zip', 'r') as zip_ref:
31-
zip_ref.extractall('tmp')
32-
shutil.copyfile(
33-
f'tmp/x86_64-apple-darwin/x86_64-apple-darwin/release/libcosmian_{name}.dylib',
34-
f'{mac}',
35-
)
36-
shutil.copyfile(
37-
f'tmp/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/release/libcosmian_{name}.so',
38-
f'{linux}',
39-
)
40-
shutil.copyfile(
41-
f'tmp/x86_64-pc-windows-gnu/x86_64-pc-windows-gnu/release/cosmian_{name}.dll',
42-
f'{windows}',
26+
missing_files = False
27+
for key, value in to_be_copied.items():
28+
if not path.exists(value):
29+
missing_files = True
30+
break
31+
32+
if missing_files:
33+
url = f'https://package.cosmian.com/cloudproof_rust/{version}/all.zip'
34+
try:
35+
with urllib.request.urlopen(url) as request:
36+
if request.getcode() != 200:
37+
print(
38+
f'Cannot get cloudproof_rust {version} \
39+
(status code: {request.getcode()})'
4340
)
44-
shutil.rmtree('tmp')
45-
remove('all.zip')
46-
except Exception as e:
47-
print(f'Cannot get {name} {version} ({e})')
41+
else:
42+
if path.exists('tmp'):
43+
shutil.rmtree('tmp')
44+
if path.exists('all.zip'):
45+
remove('all.zip')
46+
47+
# pylint: disable=consider-using-with
48+
open('all.zip', 'wb').write(request.read())
49+
50+
with zipfile.ZipFile('all.zip', 'r') as zip_ref:
51+
zip_ref.extractall('tmp')
52+
for key, value in to_be_copied.items():
53+
shutil.copyfile(key, value)
54+
print(f'Copied OK: {value}...')
55+
56+
shutil.rmtree('tmp')
57+
remove('all.zip')
58+
# pylint: disable=broad-except
59+
except Exception as exception:
60+
print(f'Cannot get cloudproof_rust {version} ({exception})')
4861
return False
4962
return True
5063

5164

5265
if __name__ == '__main__':
53-
ret = download_native_libraries('findex', 'v2.1.0', 'src/main/resources')
54-
if ret is False and getenv('GITHUB_ACTIONS'):
55-
download_native_libraries('findex', 'last_build', 'src/main/resources')
56-
57-
ret = download_native_libraries('cover_crypt', 'v10.0.0', 'src/main/resources')
66+
ret = download_native_libraries('v1.0.0')
5867
if ret is False and getenv('GITHUB_ACTIONS'):
59-
download_native_libraries('cover_crypt', 'last_build', 'src/main/resources')
68+
download_native_libraries('last_build/feature/add_findex')

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public class Ffi {
1111

12-
protected static final CoverCryptWrapper instance = (CoverCryptWrapper) Native.load("cosmian_cover_crypt",
12+
protected static final CoverCryptWrapper instance = (CoverCryptWrapper) Native.load("cloudproof_cover_crypt",
1313
CoverCryptWrapper.class);
1414

1515
/**
@@ -52,7 +52,8 @@ public static String get_last_error(int max_len) throws CloudproofException {
5252
IntByReference outputSize = new IntByReference(output.length);
5353
int err = instance.h_get_error(output, outputSize);
5454
if (err == 0) {
55-
return new String(Arrays.copyOfRange(output, 0, outputSize.getValue()), StandardCharsets.UTF_8);
55+
return "FFI error: "
56+
+ new String(Arrays.copyOfRange(output, 0, outputSize.getValue()), StandardCharsets.UTF_8);
5657
}
5758
throw new CloudproofException(
5859
"Failed retrieving the last error with error code '" + err + "'; check the debug logs");

src/main/java/com/cosmian/jna/findex/FindexBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
public class FindexBase {
2626
static final FindexNativeWrapper INSTANCE =
27-
(FindexNativeWrapper) Native.load("cosmian_findex", FindexNativeWrapper.class);
27+
(FindexNativeWrapper) Native.load("cloudproof_findex", FindexNativeWrapper.class);
2828

2929
/**
3030
* Return the last error in a String that does not exceed 1023 bytes

src/test/java/com/cosmian/TestBenchesCoverCrypt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public void testBenchesEncryptionDecryptionWithCache() throws Exception {
201201
}
202202

203203
System.out.println("");
204-
System.out.println("Hrybridized encryption");
204+
System.out.println("Hybridized encryption");
205205
System.out.println("======================");
206206
System.out.println("");
207207

src/test/java/com/cosmian/findex/IndexUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public byte[] hash(byte[] data) throws NoSuchAlgorithmException {
5353
}
5454

5555
public static byte[] generateKey() throws IOException {
56-
// return Base64.getDecoder().decode(Resources.load_resource("findex/key.b64"));
5756
byte[] key = new byte[16];
5857
SecureRandom sr = new SecureRandom();
5958
sr.nextBytes(key);

0 commit comments

Comments
 (0)