|
1 | 1 | # wolfHSM API reference |
| 2 | + |
| 3 | +## Key Revocation |
| 4 | + |
| 5 | +### wh_Client_KeyRevokeRequest |
| 6 | + |
| 7 | +Send a key revocation request to the server (non-blocking). |
| 8 | + |
| 9 | +This function prepares and sends a revoke request for the specified key ID. It |
| 10 | +returns after the request is sent; use `wh_Client_KeyRevokeResponse()` to |
| 11 | +retrieve the result. |
| 12 | + |
| 13 | +Parameters: |
| 14 | + |
| 15 | +- `c`: Client context. |
| 16 | +- `keyId`: Key ID to revoke. |
| 17 | + |
| 18 | +Return values: |
| 19 | + |
| 20 | +- `WH_ERROR_OK` on successful request send. |
| 21 | +- A negative error code on failure. |
| 22 | + |
| 23 | +Error codes: |
| 24 | + |
| 25 | +- `WH_ERROR_BADARGS` if `c` is NULL or `keyId` is invalid. |
| 26 | +- Propagates comm layer errors on send failure. |
| 27 | + |
| 28 | +### wh_Client_KeyRevokeResponse |
| 29 | + |
| 30 | +Receive a key revocation response. |
| 31 | + |
| 32 | +This function polls for the revoke response and returns `WH_ERROR_NOTREADY` |
| 33 | +until the server reply is available. |
| 34 | + |
| 35 | +Parameters: |
| 36 | + |
| 37 | +- `c`: Client context. |
| 38 | + |
| 39 | +Return values: |
| 40 | + |
| 41 | +- `WH_ERROR_OK` on success. |
| 42 | +- `WH_ERROR_NOTREADY` if the response has not arrived. |
| 43 | +- A negative error code on failure. |
| 44 | + |
| 45 | +Error codes: |
| 46 | + |
| 47 | +- `WH_ERROR_BADARGS` if `c` is NULL. |
| 48 | +- Server error codes such as `WH_ERROR_NOTFOUND`. |
| 49 | + |
| 50 | +### wh_Client_KeyRevoke |
| 51 | + |
| 52 | +Revoke a key using a blocking request/response. |
| 53 | + |
| 54 | +This helper sends a revoke request and waits for the response. |
| 55 | + |
| 56 | +Parameters: |
| 57 | + |
| 58 | +- `c`: Client context. |
| 59 | +- `keyId`: Key ID to revoke. |
| 60 | + |
| 61 | +Return values: |
| 62 | + |
| 63 | +- `WH_ERROR_OK` on success. |
| 64 | +- A negative error code on failure. |
| 65 | + |
| 66 | +Error codes: |
| 67 | + |
| 68 | +- Any error code returned by `wh_Client_KeyRevokeRequest()` or |
| 69 | + `wh_Client_KeyRevokeResponse()`. |
| 70 | + |
| 71 | +### wh_Server_KeystoreRevokeKey |
| 72 | + |
| 73 | +Revoke a key by updating its metadata. |
| 74 | + |
| 75 | +This server-side function marks a key as non-modifiable and clears all usage |
| 76 | +flags. If the key exists in NVM, the metadata update is committed so the revoke |
| 77 | +state persists. |
| 78 | + |
| 79 | +Parameters: |
| 80 | + |
| 81 | +- `server`: Server context. |
| 82 | +- `keyId`: Key ID to revoke. |
| 83 | + |
| 84 | +Return values: |
| 85 | + |
| 86 | +- `WH_ERROR_OK` on success. |
| 87 | +- A negative error code on failure. |
| 88 | + |
| 89 | +Error codes: |
| 90 | + |
| 91 | +- `WH_ERROR_BADARGS` if parameters are invalid. |
| 92 | +- `WH_ERROR_NOTFOUND` if the key is missing. |
| 93 | +- Propagates NVM/storage errors (for example `WH_ERROR_NOSPACE`). |
| 94 | + |
| 95 | +## NVM Access and Flag Controls |
| 96 | + |
| 97 | +### whNvmFlags |
| 98 | + |
| 99 | +Policy flags for NVM objects and keys. |
| 100 | + |
| 101 | +Flags include `WH_NVM_FLAGS_NONMODIFIABLE`, `WH_NVM_FLAGS_NONDESTROYABLE`, |
| 102 | +`WH_NVM_FLAGS_NONEXPORTABLE`, and the usage policy flags `WH_NVM_FLAGS_USAGE_*`. |
| 103 | +If no usage flags are set, the key is not permitted for cryptographic use. |
| 104 | + |
| 105 | +### wh_Nvm_AddObjectChecked |
| 106 | + |
| 107 | +Add an NVM object with policy enforcement. |
| 108 | + |
| 109 | +This function applies NVM policy checks (for example non-modifiable objects) |
| 110 | +before writing the object. |
| 111 | + |
| 112 | +Parameters: |
| 113 | + |
| 114 | +- `context`: NVM context. |
| 115 | +- `meta`: Metadata describing the object. |
| 116 | +- `data_len`: Length of object data. |
| 117 | +- `data`: Object data buffer. |
| 118 | + |
| 119 | +Return values: |
| 120 | + |
| 121 | +- `WH_ERROR_OK` on success. |
| 122 | +- A negative error code on failure. |
| 123 | + |
| 124 | +Error codes: |
| 125 | + |
| 126 | +- `WH_ERROR_BADARGS` if parameters are invalid. |
| 127 | +- `WH_ERROR_ACCESS` if the object is non-modifiable. |
| 128 | +- Propagates backend errors (for example `WH_ERROR_NOSPACE`). |
| 129 | + |
| 130 | +### wh_Nvm_ReadChecked |
| 131 | + |
| 132 | +Read an NVM object with policy enforcement. |
| 133 | + |
| 134 | +This function applies NVM policy checks (for example non-exportable objects) |
| 135 | +before reading the object data. |
| 136 | + |
| 137 | +Parameters: |
| 138 | + |
| 139 | +- `context`: NVM context. |
| 140 | +- `id`: Object ID to read. |
| 141 | +- `offset`: Byte offset into the object. |
| 142 | +- `data_len`: Length of data to read. |
| 143 | +- `data`: Output buffer. |
| 144 | + |
| 145 | +Return values: |
| 146 | + |
| 147 | +- `WH_ERROR_OK` on success. |
| 148 | +- A negative error code on failure. |
| 149 | + |
| 150 | +Error codes: |
| 151 | + |
| 152 | +- `WH_ERROR_BADARGS` if parameters are invalid. |
| 153 | +- `WH_ERROR_ACCESS` if the object is non-exportable. |
| 154 | +- `WH_ERROR_NOTFOUND` if the object does not exist. |
| 155 | + |
| 156 | +### wh_Nvm_DestroyObjectsChecked |
| 157 | + |
| 158 | +Destroy NVM objects with policy enforcement. |
| 159 | + |
| 160 | +This function applies NVM policy checks (for example non-destroyable objects) |
| 161 | +before erasing the objects. |
| 162 | + |
| 163 | +Parameters: |
| 164 | + |
| 165 | +- `context`: NVM context. |
| 166 | +- `list_count`: Number of IDs in the list. |
| 167 | +- `id_list`: Array of object IDs to destroy. |
| 168 | + |
| 169 | +Return values: |
| 170 | + |
| 171 | +- `WH_ERROR_OK` on success. |
| 172 | +- A negative error code on failure. |
| 173 | + |
| 174 | +Error codes: |
| 175 | + |
| 176 | +- `WH_ERROR_BADARGS` if parameters are invalid. |
| 177 | +- `WH_ERROR_ACCESS` if any object is non-destroyable or non-modifiable. |
| 178 | +- `WH_ERROR_NOTFOUND` if a listed object is missing. |
0 commit comments