PFS Service

Perfect Forward Secrecy (PFS) is a technique, that protects previously intercepted traffic from being decrypted even if the main private key is compromised.

Virgil PFS Service is a standalone web-service that is dedicated to solve the PFS use-case scenario. It works over Virgil Cards PKI infrastructure and heavily uses Virgil Cards as building blocks. Virgil PFS service can be accessed by using the Virgil PFS Service SDK or Virgil PFS API.

Authorization header

Virgil PFS Service address:

https://api.virgilsecurity.com/pfs/v2

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.

Entities

Each recipient is identified by:

ParameterDescription
ICUser's Identity Card. The long-term user's Card registered for the recipient on the Virgil Cards Service. Identity Card contains information about user and his Public Key. Identity Card will never be rotated and has an unlimited lifetime. Identity Card is stored on Virgil Cards Service
LTKLong-Term Key. The Key is rotated periodically (on a daily or monthly basis depending on the application developer's security considerations) and signed with the IC. LTK is created on behalf of the Virgil PFS service.
OTK.One-Time Key. The short-term Key that expired each session (session lifetime is determined on the client side by the Virgil PFS SDK) and are signed with the IC. OTK is created on the behalf of the Virgil PFS service.

Endpoints

The Virgil PFS REST API supports the following operations:

OperationsDescription
Create Keys SetCreates a set of keys (LTK and OTK) for provided ID of the Identity Card (IC).
Get KeysReturns the subset of keys for provided identity.
Validate KeysValidates a list of one-time keys IDs and returns subset of that list with already used one-time keys IDs.
Delete Keys SetDeletes keys entity.

Create keys set

Creates a set of keys for provided ID of the Identity Card .

Request info

HTTP Request method    PUT
Request URL            https://api.virgilsecurity.com/pfs/v2/keys HTTP/1.1
Headers                Authorization: Virgil {JWT Token}

Request

{
    "identity_card_id": "3084dab511135ec...b5db52bca8f7bf6b0b83a7fa4c740a59",
    "long_term_key": {
      "public_key": "BASE64_STRING",
      "signature":  "BASE64_STRING"
    },
    "one_time_keys": [
      "BASE64_STRING",
      "BASE64_STRING",
      "BASE64_STRING",
      "BASE64_STRING"
    ]
}

Response info

HTTP/1.1 200 OK
Content-Type: application/json

Click here to see the description of request parameters

The endpoint contains the following request and response parameters:

ParameterTypeConstraintsDescription
identity_card_idstring-ID of the Identity Card (user Card). the ID had to be available on Card Service and be the same as used in provided JWT token. In case of update operation, parameter is not required.
long_term_keyobject-Long-term public key + its signature created using identity private key (user's private key).
one_time_keysarray-The list of base64 encoded one-time public keys (up to 150 keys in the cloud).

Get keys set for user

Returns the subset of keys for provided identity (user).

Request info

HTTP Request method    POST
Request URL            https://api.virgilsecurity.com/pfs/v2/keys/actions/pick-one HTTP/1.1
Headers                Authorization: Virgil {JWT Token}

Request

{
    "identity": "[email protected]"
}

Response info

HTTP/1.1 200 OK
Content-Type: application/json

Response

{
	"identity_key": "BASE64_STRING",
	"long_term_key": {
	   "public_key": "BASE64_STRING",
	   "signature":  "BASE64_STRING"
	},
	"one_time_key": "BASE64_STRING"
}

Click here to see the description of response parameters

The endpoint contains the following request and response parameters:

ParameterTypeConstraintsDescription
identity_card_idstring-Identity card id that must be available on Card service and be the same as used in provided in JWT token. In case of update operation, parameter is not required.
long_term_keyobject-Long-term public key + its signature created using identity private key (user's private key).
one_time_keysarray-The list of base64 encoded one-time public keys (up to 150 keys in the cloud).

Get keys set for multiple users

Returns the list of subset of keys for provided identities.

Request info

HTTP Request method    POST
Request URL            https://api.virgilsecurity.com/pfs/v2/keys/actions/pick-batch HTTP/1.1
Headers                Authorization: Virgil {JWT Token}

Request

{
    "identities": ["[email protected]", "[email protected]"]
}

identities - number of identities for search should be between 1 and 50.

Response info

HTTP/1.1 200 OK
Content-Type: application/json

Response

[
  {
    "identity": "[email protected]",
    "identity_key": "BASE64_STRING",
    "long_term_key": {
        "public_key": "BASE64_STRING",
        "signature": "BASE64_STRING"
    },
    "one_time_key": "BASE64_STRING"
  },
  {
    "identity": "[email protected]",
    "identity_key": "BASE64_STRING",
    "long_term_key": {
        "public_key": "BASE64_STRING",
        "signature": "BASE64_STRING"
    },
    "one_time_key": "BASE64_STRING"
  }
]

Click here to see the description of response parameters

The endpoint contains the following request and response parameters:

ParameterTypeConstraintsDescription
identity_card_idstring-Identity card id that must be available on Card service and be the same as used in provided in JWT token. In case of update operation, parameter is not required.
long_term_keyobject-Long-term public key + its signature created using identity private key (user's private key).
one_time_keysarray-The list of base64 encoded one-time public keys (up to 150 keys in the cloud).

Validate keys

Validates a list of one-time keys IDs and returns subset of that list with already used one-time keys IDs.

Request info

HTTP Request method    POST
Request URL            https://api.virgilsecurity.com/pfs/v2/keys/actions/validate HTTP/1.1
Headers                Authorization: Virgil {JWT Token}

Request

{
  "long_term_key_id": "BASE64_STRING",
  "one_time_keys_ids": [
      "BASE64_STRING",
      "BASE64_STRING",
      "BASE64_STRING",
      "BASE64_STRING"
  ]
}

Response info

HTTP/1.1 200 OK
Content-Type: application/json

Response

{
  "used_long_term_key_id": "BASE64_STRING",
  "used_one_time_keys_ids": [
      "BASE64_STRING",
      "BASE64_STRING",
      "BASE64_STRING",
      "BASE64_STRING"
  ]
}

Click here to see the description of request and response parameters

The endpoint contains the following request and response parameters:

ParameterTypeConstraintsDescription
identity_card_idstring-ID of Identity card that must be available on Card service and be the same as used in provided in JWT token. In case of update operation, parameter is not required.
long_term_keyobject-Long-term public key + its signature created using identity private key.
one_time_keysarray-The list of base64 encoded one-time public keys (up to 150 keys in the cloud).

Delete keys set

Deletes keys entity from the PFS service.

Request info

HTTP Request method    DELETE
Request URL            https://api.virgilsecurity.com/pfs/v2/keys HTTP/1.1
Headers                Authorization: Virgil {JWT Token}

Response info

HTTP/1.1 200 OK
Content-Type: application/json

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 400. Request errors

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

Error codeDescription
30000Json parsing error.
30001One of fields is not a valid base64 string.
50000X-Application-Id header is missing.
50001X-Account-Id header is missing.
50002X-Virgil-Identity header is missing.
50003identity_card_id parameter is missing.
50005long_term_key parameter is missing.
50006long_term_key.public_key parameter is missing.
50007long_term_key.public_key parameter has wrong length. Allowed key length is up to 32kb.
50008long_term_key.signature parameter is missing.
50009long_term_key.signature parameter is invalid.
50010one_time_keys parameter is missing.
50011one_time_keys parameter has wrong number of keys. Maximum number of keys should be <= 150
50012one_time_keys parameter has wrong number of keys. Maximum allowed number of keys to append is: 2
50013one_time_keys parameter has a key with wrong size. Max size is 32kb.
50015one_time_keys_ids parameter has wrong number of keys id's to validate. Maximum number of keys id's should be <= 150
50016identity parameter is missing.
50017Keys data not found for provided identity.
50018Identity card was not found on Virgil Cards Service.
50019Identity provided in JWT is not the holder of requested card.

Service SDK

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