|
| 1 | +# DStack Tappd RPC API Documentation (Legacy) |
| 2 | + |
| 3 | +This document describes the legacy REST API endpoints for the DStack Tappd service. These APIs are deprecated as of version 0.4.2. For newer versions, please refer to [api.md](api.md) which contains the current API documentation. |
| 4 | + |
| 5 | +## Base URL |
| 6 | + |
| 7 | +The DStack Tappd service listens on a Unix domain socket at `/var/run/tappd.sock`. All API requests should be made to this socket using the `--unix-socket` flag with curl. |
| 8 | + |
| 9 | +Make sure to map the Unix socket in your Docker Compose file: |
| 10 | + |
| 11 | +```yaml |
| 12 | +services: |
| 13 | + jupyter: |
| 14 | + image: quay.io/jupyter/base-notebook |
| 15 | + volumes: |
| 16 | + - /var/run/tappd.sock:/var/run/tappd.sock |
| 17 | +``` |
| 18 | +
|
| 19 | +## Endpoints |
| 20 | +
|
| 21 | +### 1. Derive Key |
| 22 | +
|
| 23 | +Derives a cryptographic key from the specified key path and returns it along with its certificate chain. |
| 24 | +
|
| 25 | +**Endpoint:** `/prpc/Tappd.DeriveKey` |
| 26 | + |
| 27 | +**Request Parameters:** |
| 28 | + |
| 29 | +| Field | Type | Description | Example | |
| 30 | +|-------|------|-------------|----------| |
| 31 | +| `path` | string | Path used to derive the private key | `"my/key/path"` | |
| 32 | +| `subject` | string | The subject name for the certificate | `"example.com"` | |
| 33 | +| `alt_names` | array of strings | List of Subject Alternative Names (SANs) for the certificate | `["www.example.com", "api.example.com"]` | |
| 34 | +| `usage_ra_tls` | boolean | Whether to include quote in the certificate for RA-TLS | `true` | |
| 35 | +| `usage_server_auth` | boolean | Enable certificate for server authentication | `true` | |
| 36 | +| `usage_client_auth` | boolean | Enable certificate for client authentication | `false` | |
| 37 | +| `random_seed` | boolean | Derive from random seed | `false` | |
| 38 | + |
| 39 | +**Example:** |
| 40 | +```bash |
| 41 | +curl --unix-socket /var/run/tappd.sock -X POST \ |
| 42 | + http://localhost/prpc/Tappd.DeriveKey \ |
| 43 | + -H 'Content-Type: application/json' \ |
| 44 | + -d '{ |
| 45 | + "path": "my/key/path", |
| 46 | + "subject": "example.com", |
| 47 | + "alt_names": ["www.example.com", "api.example.com"], |
| 48 | + "usage_ra_tls": true, |
| 49 | + "usage_server_auth": true, |
| 50 | + "usage_client_auth": false, |
| 51 | + "random_seed": false |
| 52 | + }' |
| 53 | +``` |
| 54 | + |
| 55 | +**Response:** |
| 56 | +```json |
| 57 | +{ |
| 58 | + "key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----", |
| 59 | + "certificate_chain": [ |
| 60 | + "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----", |
| 61 | + "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----" |
| 62 | + ] |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +### 2. Derive K256 Key |
| 67 | + |
| 68 | +Derives a new ECDSA key with k256 EC curve. |
| 69 | + |
| 70 | +**Endpoint:** `/prpc/Tappd.DeriveK256Key` |
| 71 | + |
| 72 | +**Request Parameters:** |
| 73 | + |
| 74 | +| Field | Type | Description | Example | |
| 75 | +|-------|------|-------------|----------| |
| 76 | +| `path` | string | Path to the key to derive | `"my/key/path"` | |
| 77 | +| `purpose` | string | Purpose of the key | `"signing"` | |
| 78 | + |
| 79 | +**Example:** |
| 80 | +```bash |
| 81 | +curl --unix-socket /var/run/tappd.sock -X POST \ |
| 82 | + http://localhost/prpc/Tappd.DeriveK256Key \ |
| 83 | + -H 'Content-Type: application/json' \ |
| 84 | + -d '{ |
| 85 | + "path": "my/key/path", |
| 86 | + "purpose": "signing" |
| 87 | + }' |
| 88 | +``` |
| 89 | + |
| 90 | +**Response:** |
| 91 | +```json |
| 92 | +{ |
| 93 | + "k256_key": "<hex-encoded-key>", |
| 94 | + "k256_signature_chain": [ |
| 95 | + "<hex-encoded-signature-1>", |
| 96 | + "<hex-encoded-signature-2>" |
| 97 | + ] |
| 98 | +} |
| 99 | +``` |
| 100 | + |
| 101 | +### 3. TDX Quote |
| 102 | + |
| 103 | +Generates a TDX quote with report data. |
| 104 | + |
| 105 | +**Endpoint:** `/prpc/Tappd.TdxQuote` |
| 106 | + |
| 107 | +**Request Parameters:** |
| 108 | + |
| 109 | +| Field | Type | Description | Example | |
| 110 | +|-------|------|-------------|----------| |
| 111 | +| `report_data` | string | Report data to be included in the quote | `"1234deadbeaf"` | |
| 112 | +| `hash_algorithm` | string | Hash algorithm to process the report data. Default is `sha512`. Options: `sha256`, `sha384`, `sha512`, `sha3-256`, `sha3-384`, `sha3-512`, `keccak256`, `keccak384`, `keccak512`, `raw` | `"sha512"` | |
| 113 | +| `prefix` | string | Custom prefix to prepend to report data before hashing. Defaults to 'app-data:' when hash_algorithm is not 'raw' | `"app-data:"` | |
| 114 | + |
| 115 | +**Example:** |
| 116 | +```bash |
| 117 | +curl --unix-socket /var/run/tappd.sock -X POST \ |
| 118 | + http://localhost/prpc/Tappd.TdxQuote \ |
| 119 | + -H 'Content-Type: application/json' \ |
| 120 | + -d '{ |
| 121 | + "report_data": "1234deadbeaf", |
| 122 | + "hash_algorithm": "sha512", |
| 123 | + "prefix": "app-data:" |
| 124 | + }' |
| 125 | +``` |
| 126 | + |
| 127 | +**Response:** |
| 128 | +```json |
| 129 | +{ |
| 130 | + "quote": "<hex-encoded-quote>", |
| 131 | + "event_log": "quote generation log", |
| 132 | + "hash_algorithm": "sha512", |
| 133 | + "prefix": "app-data:" |
| 134 | +} |
| 135 | +``` |
| 136 | + |
| 137 | +### 4. Raw Quote |
| 138 | + |
| 139 | +Generates a TDX quote with raw report data. This is a low-level API that should be used with caution. |
| 140 | + |
| 141 | +**Endpoint:** `/prpc/Tappd.RawQuote` |
| 142 | + |
| 143 | +**Request Parameters:** |
| 144 | + |
| 145 | +| Field | Type | Description | Example | |
| 146 | +|-------|------|-------------|----------| |
| 147 | +| `report_data` | string | 64 bytes of raw report data(hex encoded)| `"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"` | |
| 148 | + |
| 149 | +**Example:** |
| 150 | +```bash |
| 151 | +curl --unix-socket /var/run/tappd.sock -X POST \ |
| 152 | + http://localhost/prpc/Tappd.RawQuote \ |
| 153 | + -H 'Content-Type: application/json' \ |
| 154 | + -d '{ |
| 155 | + "report_data": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" |
| 156 | + }' |
| 157 | +``` |
| 158 | + |
| 159 | +Or |
| 160 | + |
| 161 | +```bash |
| 162 | +curl --unix-socket /var/run/tappd.sock http://localhost/prpc/Tappd.RawQuote?report_data=00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |
| 163 | +``` |
| 164 | + |
| 165 | +**Response:** |
| 166 | +```json |
| 167 | +{ |
| 168 | + "quote": "<hex-encoded-quote>", |
| 169 | + "event_log": "quote generation log" |
| 170 | +} |
| 171 | +``` |
| 172 | + |
| 173 | +### 5. Info |
| 174 | + |
| 175 | +Retrieves worker information. |
| 176 | + |
| 177 | +**Endpoint:** `/prpc/Tappd.Info` |
| 178 | + |
| 179 | +**Example:** |
| 180 | +```bash |
| 181 | +curl --unix-socket /var/run/tappd.sock http://localhost/prpc/Tappd.Info |
| 182 | +``` |
| 183 | + |
| 184 | +**Response:** |
| 185 | +```json |
| 186 | +{ |
| 187 | + "app_id": "<hex-encoded-app-id>", |
| 188 | + "instance_id": "<hex-encoded-instance-id>", |
| 189 | + "app_cert": "<certificate-string>", |
| 190 | + "tcb_info": "<tcb-info-string>", |
| 191 | + "app_name": "my-app", |
| 192 | + "public_logs": true, |
| 193 | + "public_sysinfo": true, |
| 194 | + "device_id": "<hex-encoded-device-id>", |
| 195 | + "mr_aggregated": "<hex-encoded-mr-aggregated>", |
| 196 | + "mr_image": "<hex-encoded-mr-image>", |
| 197 | + "mr_key_provider": "<hex-encoded-mr-key-provider>", |
| 198 | + "key_provider_info": "<key-provider-info-string>", |
| 199 | + "compose_hash": "<hex-encoded-compose-hash>" |
| 200 | +} |
| 201 | +``` |
| 202 | + |
| 203 | +## Error Responses |
| 204 | + |
| 205 | +All endpoints may return the following HTTP status codes: |
| 206 | + |
| 207 | +- `200 OK`: Request successful |
| 208 | +- `400 Bad Request`: Invalid request parameters |
| 209 | +- `500 Internal Server Error`: Server-side error |
| 210 | + |
| 211 | +Error responses will include a JSON body with error details: |
| 212 | +```json |
| 213 | +{ |
| 214 | + "error": "Error description" |
| 215 | +} |
| 216 | +``` |
0 commit comments