# Cryptoki Bridge

## Usage

The library must be configured with individual applications manually.

### SSH Authentication Example

The following description assumes you have created an authentication group on the MeeSign server.
If not, please follow the description in the main README file.

1. Get the configured group public key in the OpenSSH format and store it in a file

```bash
ssh-keygen -D /usr/lib/libcryptoki-bridge.so -e > id_ecdsa.pub
```

2. Authorize logins using the acquired public key on a remote server  
   _Note: you can use the ssh server running in the Bridge Box Virtualbox_

```bash
ssh-copy-id -f -i id_ecdsa.pub <user@server>
```

3. Authenticate using meesign

```bash
ssh -I /usr/lib/libcryptoki-bridge.so <user@server>
```

## Configuration

1. Using Bridge Controller, or
2. Using ENV Variables
   - _COMMUNICATOR_HOSTNAME_ - sets the meesign hostname, e.g., `meesign.crocs.fi.muni.cz` (required)
   - _COMMUNICATOR_CERTIFICATE_PATH_ - provides the library with the path to the CA certificate (required)
   - _GROUP_ID_ - sets the signing group (optional). If not set, all groups present on the communicator are available.

## Installation

### Debian-Based Distributions

_Already install in Bridge Box_

1. Install the cryptoki-bridge package

### All Linux-Based Distributions

The built shared library can be manually copied to `/usr/lib/`.

## Build

### Build Requirements

_(Already installed in the devcontainer)_

- [rust](https://www.rust-lang.org/tools/install)
- [protocol buffer compiler](https://grpc.io/docs/protoc-installation/)

### Production Build

- Update submodules

  ```bash
  git submodule update --init --recursive
  ```

- Build the library

  ```bash
  cargo build --release
  ```

- The build is located in the `target/release/` directory
