Java Client Library for CYBERCRYPT D1
Java client libraries for
Usage
In order to use the client you will need credentials for the D1 Generic server. When setting up the server the first time, you need to bootstrap an initial user with credentials either through the executable as described here. Subsequent users can be created through the API as described here.
A new D1 Generic client can be created by creating an instance of the D1GenericClient
class as shown below.
// Create a new D1 Generic client, providing the hostname, a root CA certificate, and user
// credentials.
var client = new D1GenericClient("localhost:9000", "user id", "password", "./ca.crt");
// Encrypt sensitive data.
var plaintext = "plaintext".getBytes();
var associatedData = "associatedData".getBytes();
var encryptResponse = client.encrypt(plaintext, associatedData);
// Decrypt the response.
var decryptResponse = client.decrypt(encryptResponse.getObjectId(), encryptResponse.getCiphertext(), encryptResponse.getAssociatedData());
The process is the same for D1 Storage:
// Create a new D1 Generic client, providing the hostname, a root CA certificate, and user
// credentials.
var client = new D1StorageClient("localhost:9000", "user id", "password", "./ca.crt");
// Store sensitive data in encrypted form.
var plaintext = "plaintext".getBytes();
var associatedData = "associatedData".getBytes();
var storeResponse = client.store(plaintext, associatedData);
// Retrieve the stored data.
var retrieveResponse = client.retrieve(storeResponse.getObjectId());
For more information, see the documentation.
Development
Make targets are provided for various tasks. To get an overview run make help
.
To build the clients run make build
. Note that the D1 Generic and Storage repositories
must be located in the same folder as this repository in order to build.
The Generic and Storage clients can be tested against a docker deployment of the services by running
make docker-generic-test
and make docker-storage-test
.