Keyknox Service

Virgil Keyknox Service helps to safeguard cryptographic keys and secrets of your users in your software. With Vigil Keyknox your users can securely store keys as well as sync and share them between their devices.

Virgil Keyknox is designed so that only your users can have access to their keys. All keys are stored in encrypted format and only the user is able to decrypt them on their own authorized devices.

Virgil Keyknox service can be accessed by using the Virgil Keyknox SDK or Virgil Keyknox API.

Authorization header

Virgil Keyknox Service address:

https://api.virgilsecurity.com/keyknox/v1

All API calls require authentication with Virgil JWT. So all requests go through Virgil API Gateway which bypasses the request with preset HTTP headers: X-Application-Id, X-Virgil-Identity.

Endpoints

The Virgil Keyknox REST API supports the following operations for keyknox object:

OperationsDescription
Create Keyknox RecordCreates a new record, stores it, then returns keyknox value and meta data to the client. If a keyknox record already exists, service creates a new version of the keyknox record. It requires the keyknox/create permissions.
Reset Keyknox RecordThe reset operation changes only meta data of a stored keyknox record. In order to perform this operation, the keyknox record must be already set in the Service.
Note, that the keyknox value itself cannot be changed. This operation requires the keyknox/reset permission.
Get Keyknox RecordThe get operation returns keyknox record for a current user (identity) specified in a JWT. This operation requires the keyknox/get permission.

Create keyknox record

Creates a new record, stores it, then returns keyknox value and meta data to the client. If a keyknox record already exists, service creates a new version of the keyknox record. It requires the keyknox/create permissions.

Request info

HTTP Request method    PUT
Request URL            https://api.virgilsecurity.com/keyknox/v1 HTTP/1.1
Headers                X-Virgil-Identity: {UserIDString}
                       X-Account-Id: {AccountID}
                       X-Application-Id: {ApplicationID}
                       Virgil-Keyknox-Previous-Hash: {KeyknoxPreviousHash}

Click here to see the description of header parameters

The endpoint contains the following header parameters:

ParameterDescription
X-Virgil-IdentityUser identity that was used for a JWT generation
X-Account-IdID of your Virgil Account. Can be found in your profile settings on Virgil Dashboard
X-Application-IdID of your Virgil Application
Virgil-Keyknox-Previous-HashHeader should be obtained from the Virgil-Keyknox-Hash response header of the GET /keyknox endpoint. Header is optional for the case when Keyknox entity is created first time for provided X-Virgil-Identity

Request

{
    "meta": "BASE64_STRING",
    "value": "BASE64_STRING"
}

Response info

HTTP/1.1 200 OK
Content-Type: application/json
Virgil-Keyknox-Hash: kcY8QLKqFu1gScis3fvKXVBtN1Yghm1L7gARqH3iafgYSU0dGxIUWZ1RITaJshiWyOEOT62FUfQzmVUafum7kA==

Response

{
	"meta": "BASE64_STRING",
	"value": "BASE64_STRING",
	"version": "1.0"
}

Click here to see the description of request and response parameters

The endpoint contains the following request and response parameters:

ParameterTypeConstraintsDescription
metaBase6410 kbBase64 encoded meta (of the sensitive data)
valueBase64100 kbBase64 encoded data (encoded sensitive data itself)
version--Version of user's keyknox entity. Read about a version generation rule in a proper chapter here

GET keyknox record

The get operation returns keyknox record for a current user specified in a JWT. This operation requires the keyknox/get permission.

Request info

HTTP Request method    GET
Request URL            https://api.virgilsecurity.com/keyknox/v1 HTTP/1.1
Headers                X-Virgil-Identity: {UserIDString}
                       X-Account-Id: {AccountID}
                       X-Application-Id: {ApplicationID}

Click here to see the description of header parameters

The endpoint contains the following header parameters:

ParameterDescription
X-Virgil-IdentityUser identity that was used for a JWT generation
X-Account-IdID of your Virgil Account. Can be found in your profile settings on Virgil Dashboard
X-Application-IdID of your Virgil Application

Response info

HTTP/1.1 200 OK
Content-Type:         application/json
Virgil-Keyknox-Hash:  kcY8QLKqFu1gScis3fvKXVBtN1Yghm1L7gARqH3iafgYSU0dGxIUWZ1RITaJshiWyOEOT62FUfQzmVUafum7kA==

Response

{
	"meta":  "BASE64_STRING",
	"value": "BASE64_STRING",
	"version": "1.0"
}

Click here to see the description of request and response parameters

The endpoint contains the following request and response parameters:

ParameterTypeConstraintsDescription
metaBase6410 kbBase64 encoded meta (of the sensitive data)
valueBase64100 kbBase64 encoded data (encoded sensitive data itself)
version--Version of user's keyknox entity. Read about a version generation rule in a proper chapter here

Reset keyknox record

The reset operation changes only meta data of a stored keyknox record. In order to perform this operation, the keyknox record must be already set in the Service. Note that the keyknox value itself cannot be changed. This operation requires the keyknox/reset permission.

Request info

HTTP Request method    POST
Request URL            https://api.virgilsecurity.com/keyknox/v1/reset HTTP/1.1
Headers                X-Virgil-Identity: {UserIDString}
                       X-Account-Id: {AccountID}
                       X-Application-Id: {ApplicationID}

Click here to see the description of header parameters

The endpoint contains the following header parameters:

ParameterDescription
X-Virgil-IdentityUser identity that was used for a JWT generation
X-Account-IdID of your Virgil Account. Can be found in your profile settings on Virgil Dashboard.
X-Application-IdID of your Virgil Application

Response info

HTTP/1.1 200 OK
Content-Type:          application/json
Virgil-Keyknox-Hash:   kcY8QLKqFu1gScis3fvKXVBtN1Yghm1L7gARqH3iafgYSU0dGxIUWZ1RITaJshiWyOEOT62FUfQzmVUafum7kA==

Response

{
    "meta":  "",
    "value": "",
    "version": "1.0"
}
  • meta and value properties set to initial state - empty state.
  • version property, major part increment by 1, minor reset to initial state - 0.

Click here to see the description of request and response parameters

Keyknox service endpoints contains the following request and response parameters:

ParameterTypeConstraintsDescription
metaBase6410 kbBase64 encoded meta (of the sensitive data)
valueBase64100 kbBase64 encoded data (encoded sensitive data itself)
version--Version of user's keyknox entity. Read about a version generation rule in a proper chapter here

Errors

HTTP error codes

The Application uses standard HTTP response codes:

Error codeDescription
200Success
201Created
400Request error
404Entity not found
405Method not allowed
500Server error

HTTP 500. Server errors

This status is returned in extremely rare cases of internal application errors

Error codeDescription
50000X-Application-Id header is missing.
50001X-Account-Id header is missing.
50002keyknox entity not found.
50003X-Virgil-Identity header is missing.
50004meta parameter is missing.
50005meta parameter has wrong size. max size is 10kb.
50006value parameter is missing.
50007value parameter has wrong size. max size is 100kb.
50008value parameter was changed without the meta parameter.
50009Virgil-Keyknox-Previous-Hash header is missing.
50010Virgil-Keyknox-Previous-Hash header is invalid.
50011X-Application-Id header is missing.

Version generation rule

  1. When Keyknox record created at the first time, version parameter is set to initial state: 1.0, where the major part of the version belongs to the Keyknox meta part and the minor part of the version belongs to the Keyknox value part.

  2. When Keyknox record already exists and the reset action is performed, then Keyknox version updates by next rules:

  • if only meta part was changed then performs increment minor part of the version by one.
  • if meta + value parts were changed, then performs reset to 0 of the minor part of the version and increment by one the major part of the version.

Service SDK

Virgil Security provides SDKs which allow you to communicate with the Virgil Keyknox Service to upload, download, and synchronize encrypted sensitive data (private keys) between user's devices:

What is next?

For best practice take a look at our use cases which use Virgil Keyknox Service for sharing users' private keys between their devices: