Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Jeff Tinker | da002fe | 2017-01-19 14:41:11 -0800 | [diff] [blame] | 16 | package android.hardware.drm@1.0; |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 17 | |
| 18 | import IDrmPluginListener; |
| 19 | |
| 20 | /** |
| 21 | * Ref: frameworks/native/include/media/drm/DrmAPI.h:DrmPlugin |
| 22 | * |
| 23 | * IDrmPlugin is used to interact with a specific drm plugin that was |
| 24 | * created by IDrm::createPlugin. A drm plugin provides methods for |
| 25 | * obtaining drm keys that may be used by a codec to decrypt protected |
| 26 | * video content. |
| 27 | */ |
| 28 | interface IDrmPlugin { |
| 29 | |
| 30 | /** |
| 31 | * Open a new session with the DrmPlugin object. A session ID is returned |
| 32 | * in the sessionId parameter. |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 33 | * @return status the status of the call. The status must be OK or one of |
| 34 | * the following errors: ERROR_DRM_NOT_PROVISIONED if the device requires |
| 35 | * provisioning before it can open a session, ERROR_DRM_RESOURCE_BUSY if |
| 36 | * there are insufficent resources available to open a session, |
| 37 | * ERROR_DRM_CANNOT_HANDLE, if openSession is not supported at the time of |
| 38 | * the call or ERROR_DRM_INVALID_STATE if the HAL is in a state where a |
| 39 | * session cannot be opened. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 40 | * @return sessionId the session ID for the newly opened session |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 41 | */ |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 42 | openSession() generates (Status status, SessionId sessionId); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Close a session on the DrmPlugin object |
| 46 | * |
| 47 | * @param sessionId the session id the call applies to |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 48 | * @return status the status of the call. The status must be OK or one of |
| 49 | * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not |
| 50 | * opened, BAD_VALUE if the sessionId is invalid or ERROR_DRM_INVALID_STATE |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 51 | * if the HAL is in a state where the session cannot be closed. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 52 | */ |
| 53 | closeSession(SessionId sessionId) generates (Status status); |
| 54 | |
| 55 | /** |
| 56 | * A key request/response exchange occurs between the app and a License |
| 57 | * Server to obtain the keys required to decrypt the content. |
| 58 | * getKeyRequest() is used to obtain an opaque key request blob that is |
| 59 | * delivered to the license server. |
| 60 | * |
| 61 | * @param scope may be a sessionId or a keySetId, depending on the |
| 62 | * specified keyType. When the keyType is OFFLINE or STREAMING, |
| 63 | * scope should be set to the sessionId the keys will be provided to. |
| 64 | * When the keyType is RELEASE, scope should be set to the keySetId |
| 65 | * of the keys being released. |
| 66 | * @param initData container-specific data, its meaning is interpreted |
| 67 | * based on the mime type provided in the mimeType parameter. It could |
| 68 | * contain, for example, the content ID, key ID or other data obtained |
| 69 | * from the content metadata that is required to generate the key request. |
| 70 | * initData may be empty when keyType is RELEASE. |
| 71 | * @param mimeType identifies the mime type of the content |
| 72 | * @param keyType specifies if the keys are to be used for streaming, |
| 73 | * offline or a release |
| 74 | * @param optionalParameters included in the key request message to |
| 75 | * allow a client application to provide additional message parameters to |
| 76 | * the server. |
| 77 | * |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 78 | * @return status the status of the call. The status must be OK or one of |
| 79 | * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not |
| 80 | * opened, ERROR_DRM_NOT_PROVISIONED if the device requires provisioning |
| 81 | * before it can generate a key request, ERROR_DRM_CANNOT_HANDLE if |
| 82 | * getKeyRequest is not supported at the time of the call, BAD_VALUE if any |
| 83 | * parameters are invalid or ERROR_DRM_INVALID_STATE if the HAL is in a state |
| 84 | * where a key request cannot be generated. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 85 | * @return request if successful, the opaque key request blob is returned |
| 86 | * @return requestType indicates type information about the returned |
| 87 | * request. The type may be one of INITIAL, RENEWAL or RELEASE. An |
| 88 | * INITIAL request is the first key request for a license. RENEWAL is a |
| 89 | * subsequent key request used to refresh the keys in a license. RELEASE |
| 90 | * corresponds to a keyType of RELEASE, which indicates keys are being |
| 91 | * released. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 92 | * @return defaultUrl the URL that the request may be sent to, if |
| 93 | * provided by the drm HAL. The app may choose to override this |
| 94 | * URL. |
| 95 | */ |
| 96 | getKeyRequest(vec<uint8_t> scope, vec<uint8_t> initData, |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 97 | string mimeType, KeyType keyType, KeyedVector optionalParameters) |
| 98 | generates (Status status, vec<uint8_t> request, |
| 99 | KeyRequestType requestType, string defaultUrl); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 100 | |
| 101 | /** |
| 102 | * After a key response is received by the app, it is provided to the |
| 103 | * Drm plugin using provideKeyResponse. |
| 104 | * |
| 105 | * @param scope may be a sessionId or a keySetId depending on the type |
| 106 | * of the response. Scope should be set to the sessionId when the response |
| 107 | * is for either streaming or offline key requests. Scope should be set to |
| 108 | * the keySetId when the response is for a release request. |
| 109 | * @param response the response from the key server that is being |
| 110 | * provided to the drm HAL. |
| 111 | * |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 112 | * @return status the status of the call. The status must be OK or one of |
| 113 | * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not |
| 114 | * opened, ERROR_DRM_NOT_PROVISIONED if the device requires provisioning |
| 115 | * before it can handle the key response, ERROR_DRM_DEVICE_REVOKED if the |
| 116 | * device has been disabled by the license policy, ERROR_DRM_CANNOT_HANDLE |
| 117 | * if provideKeyResponse is not supported at the time of the call, BAD_VALUE |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 118 | * if any parameters are invalid or ERROR_DRM_INVALID_STATE if the HAL is |
| 119 | * in a state where a key response cannot be handled. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 120 | * @return keySetId when the response is for an offline key request, a |
| 121 | * keySetId is returned in the keySetId vector parameter that can be used |
| 122 | * to later restore the keys to a new session with the method restoreKeys. |
| 123 | * When the response is for a streaming or release request, no keySetId is |
| 124 | * returned. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 125 | */ |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 126 | provideKeyResponse(vec<uint8_t> scope, vec<uint8_t> response) |
| 127 | generates (Status status, vec<uint8_t> keySetId); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 128 | |
| 129 | /** |
| 130 | * Remove the current keys from a session |
| 131 | * |
| 132 | * @param sessionId the session id the call applies to |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 133 | * @return status the status of the call. The status must be OK or one of |
| 134 | * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not |
| 135 | * opened, BAD_VALUE if the sessionId is invalid or ERROR_DRM_INVALID_STATE |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 136 | * if the HAL is in a state where the keys cannot be removed. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 137 | */ |
| 138 | removeKeys(SessionId sessionId) generates (Status status); |
| 139 | |
| 140 | /** |
| 141 | * Restore persisted offline keys into a new session |
| 142 | * |
| 143 | * @param sessionId the session id the call applies to |
| 144 | * @param keySetId identifies the keys to load, obtained from a prior |
| 145 | * call to provideKeyResponse(). |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 146 | * @return status the status of the call. The status must be OK or one of |
| 147 | * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not |
| 148 | * opened, BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 149 | * if the HAL is in a state where keys cannot be restored. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 150 | */ |
| 151 | restoreKeys(SessionId sessionId, |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 152 | vec<uint8_t> keySetId) generates (Status status); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 153 | |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 154 | /** |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 155 | * Request an informative description of the license for the session. The |
| 156 | * status is in the form of {name, value} pairs. Since DRM license policies |
| 157 | * vary by vendor, the specific status field names are determined by each |
| 158 | * DRM vendor. Refer to your DRM provider documentation for definitions of |
| 159 | * the field names for a particular drm scheme. |
| 160 | * |
| 161 | * @param sessionId the session id the call applies to |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 162 | * @return status the status of the call. The status must be OK or one of |
| 163 | * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not |
| 164 | * opened, BAD_VALUE if the sessionId is invalid or ERROR_DRM_INVALID_STATE |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 165 | * if the HAL is in a state where key status cannot be queried. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 166 | * @return infoList a list of name value pairs describing the license |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 167 | */ |
| 168 | queryKeyStatus(SessionId sessionId) |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 169 | generates (Status status, KeyedVector infoList); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 170 | |
| 171 | /** |
| 172 | * A provision request/response exchange occurs between the app and a |
| 173 | * provisioning server to retrieve a device certificate. getProvisionRequest |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 174 | * is used to obtain an opaque provisioning request blob that is delivered |
| 175 | * to the provisioning server. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 176 | * |
| 177 | * @param certificateType the type of certificate requested, e.g. "X.509" |
| 178 | * @param certificateAuthority identifies the certificate authority. A |
| 179 | * certificate authority (CA) is an entity which issues digital certificates |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 180 | * for use by other parties. It is an example of a trusted third party. |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 181 | * @return status the status of the call. The status must be OK or one of |
| 182 | * the following errors: BAD_VALUE if the sessionId is invalid or |
| 183 | * ERROR_DRM_INVALID_STATE if the HAL is in a state where the provision |
| 184 | * request cannot be generated. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 185 | * @return request if successful the opaque certificate request blob |
| 186 | * is returned |
| 187 | * @return defaultUrl URL that the provisioning request should be |
| 188 | * sent to, if known by the HAL implementation. If the HAL implementation |
| 189 | * does not provide a defaultUrl, the returned string must be empty. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 190 | */ |
| 191 | getProvisionRequest(string certificateType, string certificateAuthority) |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 192 | generates (Status status, vec<uint8_t> request, string defaultUrl); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 193 | |
| 194 | /** |
| 195 | * After a provision response is received by the app from a provisioning |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 196 | * server, it is provided to the Drm HAL using provideProvisionResponse. |
| 197 | * The HAL implementation must receive the provision request and |
| 198 | * store the provisioned credentials. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 199 | * |
| 200 | * @param response the opaque provisioning response received by the |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 201 | * app from a provisioning server. |
| 202 | |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 203 | * @return status the status of the call. The status must be OK or one of |
| 204 | * the following errors: ERROR_DRM_DEVICE_REVOKED if the device has been |
| 205 | * disabled by the license policy, BAD_VALUE if any parameters are invalid |
| 206 | * or ERROR_DRM_INVALID_STATE if the HAL is in a state where the provision |
| 207 | * response cannot be handled. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 208 | * @return certificate the public certificate resulting from the provisioning |
| 209 | * operation, if any. An empty vector indicates that no certificate was |
| 210 | * returned. |
| 211 | * @return wrappedKey an opaque object containing encrypted private key |
| 212 | * material to be used by signRSA when computing an RSA signature on a |
| 213 | * message, see the signRSA method. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 214 | */ |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 215 | provideProvisionResponse(vec<uint8_t> response) generates (Status status, |
| 216 | vec<uint8_t> certificate, vec<uint8_t> wrappedKey); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 217 | |
| 218 | /** |
| 219 | * SecureStop is a way of enforcing the concurrent stream limit per |
| 220 | * subscriber. It can securely monitor the lifetime of sessions across |
| 221 | * device reboots by periodically persisting the session lifetime |
| 222 | * status in secure storage. |
| 223 | * |
| 224 | * A signed version of the sessionID is written to persistent storage on the |
| 225 | * device when each MediaCrypto object is created and periodically during |
| 226 | * playback. The sessionID is signed by the device private key to prevent |
| 227 | * tampering. |
| 228 | * |
| 229 | * When playback is completed the session is destroyed, and the secure |
| 230 | * stops are queried by the app. The app then delivers the secure stop |
| 231 | * message to a server which verifies the signature to confirm that the |
| 232 | * session and its keys have been removed from the device. The persisted |
| 233 | * record on the device is removed after receiving and verifying the |
| 234 | * signed response from the server. |
| 235 | */ |
| 236 | |
| 237 | /** |
| 238 | * Get all secure stops on the device |
| 239 | * |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 240 | * @return status the status of the call. The status must be OK or |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 241 | * ERROR_DRM_INVALID_STATE if the HAL is in a state where the secure stops |
| 242 | * cannot be returned. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 243 | * @return secureStops a list of the secure stop opaque objects |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 244 | */ |
| 245 | getSecureStops() generates |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 246 | (Status status, vec<SecureStop> secureStops); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 247 | |
| 248 | /** |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 249 | * Get all secure stops by secure stop ID |
| 250 | * |
| 251 | * @param secureStopId the ID of the secure stop to return. The |
| 252 | * secure stop ID is delivered by the key server as part of the key |
| 253 | * response and must also be known by the app. |
| 254 | * |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 255 | * @return status the status of the call. The status must be OK or one of |
| 256 | * the following errors: BAD_VALUE if the secureStopId is invalid or |
| 257 | * ERROR_DRM_INVALID_STATE if the HAL is in a state where the secure stop |
| 258 | * cannot be returned. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 259 | * @return secureStop the secure stop opaque object |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 260 | */ |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 261 | |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 262 | getSecureStop(SecureStopId secureStopId) |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 263 | generates (Status status, SecureStop secureStop); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 264 | |
| 265 | /** |
| 266 | * Release all secure stops on the device |
| 267 | * |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 268 | * @return status the status of the call. The status must be OK or |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 269 | * ERROR_DRM_INVALID_STATE if the HAL is in a state where the secure |
| 270 | * stops cannot be released. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 271 | */ |
| 272 | releaseAllSecureStops() generates (Status status); |
| 273 | |
| 274 | /** |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 275 | * Release a secure stop by secure stop ID |
| 276 | * |
| 277 | * @param secureStopId the ID of the secure stop to release. The |
| 278 | * secure stop ID is delivered by the key server as part of the key |
| 279 | * response and must also be known by the app. |
| 280 | * |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 281 | * @return status the status of the call. The status must be OK or one of |
| 282 | * the following errors: BAD_VALUE if the secureStopId is invalid or |
| 283 | * ERROR_DRM_INVALID_STATE if the HAL is in a state where the secure stop |
| 284 | * cannot be released. |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 285 | */ |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 286 | releaseSecureStop(vec<uint8_t> secureStopId) generates (Status status); |
| 287 | |
| 288 | /** |
| 289 | * A drm scheme can have properties that are settable and readable |
| 290 | * by an app. There are a few forms of property access methods, |
| 291 | * depending on the data type of the property. |
| 292 | * |
| 293 | * Property values defined by the public API are: |
| 294 | * "vendor" [string] identifies the maker of the drm scheme |
| 295 | * "version" [string] identifies the version of the drm scheme |
| 296 | * "description" [string] describes the drm scheme |
| 297 | * 'deviceUniqueId' [byte array] The device unique identifier is |
| 298 | * established during device provisioning and provides a means of |
| 299 | * uniquely identifying each device. |
| 300 | * |
| 301 | * Since drm scheme properties may vary, additional field names may be |
| 302 | * defined by each DRM vendor. Refer to your DRM provider documentation |
| 303 | * for definitions of its additional field names. |
| 304 | */ |
| 305 | |
| 306 | /** |
| 307 | * Read a string property value given the property name. |
| 308 | * |
| 309 | * @param propertyName the name of the property |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 310 | * @return status the status of the call. The status must be OK or one of |
| 311 | * the following errors: BAD_VALUE if the property name is invalid, |
| 312 | * ERROR_DRM_CANNOT_HANDLE if the property is not supported, or |
| 313 | * ERROR_DRM_INVALID_STATE if the HAL is in a state where the property |
| 314 | * cannot be obtained. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 315 | * @return value the property value string |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 316 | */ |
| 317 | getPropertyString(string propertyName) |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 318 | generates (Status status, string value); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 319 | |
| 320 | /** |
| 321 | * Read a byte array property value given the property name. |
| 322 | * |
| 323 | * @param propertyName the name of the property |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 324 | * @return status the status of the call. The status must be OK or one of |
| 325 | * the following errors: BAD_VALUE if the property name is invalid, |
| 326 | * ERROR_DRM_CANNOT_HANDLE if the property is not supported, or |
| 327 | * ERROR_DRM_INVALID_STATE if the HAL is in a state where the property |
| 328 | * cannot be obtained. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 329 | * @return value the property value byte array |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 330 | */ |
| 331 | getPropertyByteArray(string propertyName) |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 332 | generates (Status status, vec<uint8_t> value); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 333 | |
| 334 | /** |
| 335 | * Write a property string value given the property name |
| 336 | * |
| 337 | * @param propertyName the name of the property |
| 338 | * @param value the value to write |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 339 | * @return status the status of the call. The status must be OK or one of |
| 340 | * the following errors: BAD_VALUE if the property name is invalid, |
| 341 | * ERROR_DRM_CANNOT_HANDLE if the property is not supported, or |
| 342 | * ERROR_DRM_INVALID_STATE if the HAL is in a state where the property |
| 343 | * cannot be set. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 344 | */ |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 345 | setPropertyString(string propertyName, string value) |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 346 | generates (Status status); |
| 347 | |
| 348 | /** |
| 349 | * Write a property byte array value given the property name |
| 350 | * |
| 351 | * @param propertyName the name of the property |
| 352 | * @param value the value to write |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 353 | * @return status the status of the call. The status must be OK or one of |
| 354 | * the following errors: BAD_VALUE if the property name is invalid, |
| 355 | * ERROR_DRM_CANNOT_HANDLE if the property is not supported, or |
| 356 | * ERROR_DRM_INVALID_STATE if the HAL is in a state where the property |
| 357 | * cannot be set. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 358 | */ |
| 359 | setPropertyByteArray(string propertyName, vec<uint8_t> value ) |
| 360 | generates (Status status); |
| 361 | |
| 362 | /** |
| 363 | * The following methods implement operations on a CryptoSession to support |
| 364 | * encrypt, decrypt, sign verify operations on operator-provided |
| 365 | * session keys. |
| 366 | */ |
| 367 | |
| 368 | /** |
| 369 | * Set the cipher algorithm to be used for the specified session. |
| 370 | * |
| 371 | * @param sessionId the session id the call applies to |
| 372 | * @param algorithm the algorithm to use. The string conforms to JCA |
| 373 | * Standard Names for Cipher Transforms and is case insensitive. An |
| 374 | * example algorithm is "AES/CBC/PKCS5Padding". |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 375 | * @return status the status of the call. The status must be OK or one of |
| 376 | * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not |
| 377 | * opened, BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 378 | * if the HAL is in a state where the algorithm cannot be set. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 379 | */ |
| 380 | setCipherAlgorithm(SessionId sessionId, string algorithm) |
| 381 | generates (Status status); |
| 382 | |
| 383 | /** |
| 384 | * Set the MAC algorithm to be used for computing hashes in a session. |
| 385 | * |
| 386 | * @param sessionId the session id the call applies to |
| 387 | * @param algorithm the algorithm to use. The string conforms to JCA |
| 388 | * Standard Names for Mac Algorithms and is case insensitive. An example MAC |
| 389 | * algorithm string is "HmacSHA256". |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 390 | * @return status the status of the call. The status must be OK or one of the |
| 391 | * following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not |
| 392 | * opened, BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 393 | * if the HAL is in a state where the algorithm cannot be set. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 394 | */ |
| 395 | setMacAlgorithm(SessionId sessionId, string algorithm) |
| 396 | generates (Status status); |
| 397 | |
| 398 | /** |
| 399 | * Encrypt the provided input buffer with the cipher algorithm specified by |
| 400 | * setCipherAlgorithm and the key selected by keyId, and return the |
| 401 | * encrypted data. |
| 402 | * |
| 403 | * @param sessionId the session id the call applies to |
| 404 | * @param keyId the ID of the key to use for encryption |
| 405 | * @param input the input data to encrypt |
| 406 | * @param iv the initialization vector to use for encryption |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 407 | * @return status the status of the call. The status must be OK or one of the |
| 408 | * following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not opened, |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 409 | * BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 410 | * if the HAL is in a state where the encrypt operation cannot be performed. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 411 | * @return output the decrypted data |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 412 | */ |
| 413 | encrypt(SessionId sessionId, vec<uint8_t> keyId, vec<uint8_t> input, |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 414 | vec<uint8_t> iv) generates (Status status, vec<uint8_t> output); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 415 | |
| 416 | /** |
| 417 | * Decrypt the provided input buffer with the cipher algorithm |
| 418 | * specified by setCipherAlgorithm and the key selected by keyId, |
| 419 | * and return the decrypted data. |
| 420 | * |
| 421 | * @param sessionId the session id the call applies to |
| 422 | * @param keyId the ID of the key to use for decryption |
| 423 | * @param input the input data to decrypt |
| 424 | * @param iv the initialization vector to use for decryption |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 425 | * @return status the status of the call. The status must be OK or one of |
| 426 | * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not |
| 427 | * opened, BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 428 | * if the HAL is in a state where the decrypt operation cannot be |
| 429 | * performed. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 430 | * @return output the decrypted data |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 431 | */ |
| 432 | decrypt(SessionId sessionId, vec<uint8_t> keyId, vec<uint8_t> input, |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 433 | vec<uint8_t> iv) generates (Status status, vec<uint8_t> output); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 434 | |
| 435 | /** |
| 436 | * Compute a signature over the provided message using the mac algorithm |
| 437 | * specified by setMacAlgorithm and the key selected by keyId and return |
| 438 | * the signature. |
| 439 | * |
| 440 | * @param sessionId the session id the call applies to |
| 441 | * @param keyId the ID of the key to use for decryption |
| 442 | * @param message the message to compute a signature over |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 443 | * @return status the status of the call. The status must be OK or one of |
| 444 | * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not |
| 445 | * opened, BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 446 | * if the HAL is in a state where the sign operation cannot be |
| 447 | * performed. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 448 | * @return signature the computed signature |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 449 | */ |
| 450 | sign(SessionId sessionId, vec<uint8_t> keyId, vec<uint8_t> message) |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 451 | generates (Status status, vec<uint8_t> signature); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 452 | |
| 453 | /** |
| 454 | * Compute a hash of the provided message using the mac algorithm specified |
| 455 | * by setMacAlgorithm and the key selected by keyId, and compare with the |
| 456 | * expected result. |
| 457 | * |
| 458 | * @param sessionId the session id the call applies to |
| 459 | * @param keyId the ID of the key to use for decryption |
| 460 | * @param message the message to compute a hash of |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 461 | * @param signature the signature to verify |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 462 | * @return status the status of the call. The status must be OK or one of |
| 463 | * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not |
| 464 | * opened, BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 465 | * if the HAL is in a state where the verify operation cannot be |
| 466 | * performed. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 467 | * @return match true if the signature is verified positively, |
| 468 | * false otherwise. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 469 | */ |
| 470 | verify(SessionId sessionId, vec<uint8_t> keyId, vec<uint8_t> message, |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 471 | vec<uint8_t> signature) generates (Status status, bool match); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 472 | |
| 473 | /** |
| 474 | * Compute an RSA signature on the provided message using the specified |
| 475 | * algorithm. |
| 476 | * |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 477 | * @param sessionId the session id the call applies to |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 478 | * @param algorithm the signing algorithm, such as "RSASSA-PSS-SHA1" |
| 479 | * or "PKCS1-BlockType1" |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 480 | * @param message the message to compute the signature on |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 481 | * @param wrappedKey the private key returned during provisioning as |
| 482 | * returned by provideProvisionResponse. |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 483 | * @return status the status of the call. The status must be OK or one of |
| 484 | * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is |
| 485 | * not opened, BAD_VALUE if any parameters are invalid or |
| 486 | * ERROR_DRM_INVALID_STATE if the HAL is in a state where the signRSA |
| 487 | * operation cannot be performed. |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 488 | * @return signature the RSA signature computed over the message |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 489 | */ |
| 490 | signRSA(SessionId sessionId, string algorithm, vec<uint8_t> message, |
| 491 | vec<uint8_t> wrappedkey) |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 492 | generates (Status status, vec<uint8_t> signature); |
| 493 | |
| 494 | /** |
| 495 | * Plugins call the following methods to deliver events to the |
| 496 | * java app. |
| 497 | */ |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 498 | |
| 499 | /** |
| 500 | * Set a listener for a drm session. This allows the drm HAL to |
| 501 | * make asynchronous calls back to the client of IDrm. |
| 502 | * |
| 503 | * @param listener instance of IDrmPluginListener to receive the events |
| 504 | */ |
| 505 | setListener(IDrmPluginListener listener); |
| 506 | |
| 507 | /** |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 508 | * Legacy event sending method, it sends events of various types using a |
| 509 | * single overloaded set of parameters. This form is deprecated. |
| 510 | * |
| 511 | * @param eventType the type of the event |
| 512 | * @param sessionId identifies the session the event originated from |
| 513 | * @param data event-specific data blob |
| 514 | */ |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 515 | sendEvent(EventType eventType, SessionId sessionId, vec<uint8_t> data); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 516 | |
| 517 | /** |
| 518 | * Send a license expiration update to the listener. The expiration |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 519 | * update indicates how long the current license is valid before it |
| 520 | * needs to be renewed. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 521 | * |
| 522 | * @param sessionId identifies the session the event originated from |
| 523 | * @param expiryTimeInMS the time when the keys need to be renewed. |
| 524 | * The time is in milliseconds, relative to the Unix epoch. A time of 0 |
| 525 | * indicates that the keys never expire. |
| 526 | */ |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 527 | sendExpirationUpdate(SessionId sessionId, int64_t expiryTimeInMS); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 528 | |
| 529 | /** |
| 530 | * Send a keys change event to the listener. The keys change event |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 531 | * indicates the status of each key in the session. Keys can be |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 532 | * indicated as being usable, expired, outputnotallowed or statuspending. |
| 533 | * |
| 534 | * @param sessionId identifies the session the event originated from |
| 535 | * @param keyStatusList indicates the status for each key ID in the |
| 536 | * session. |
| 537 | * @param hasNewUsableKey indicates if the event includes at least one |
| 538 | * key that has become usable. |
| 539 | */ |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 540 | sendKeysChange(SessionId sessionId, vec<KeyStatus> keyStatusList, |
| 541 | bool hasNewUsableKey); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 542 | }; |