blob: 083b3115d3a7620d64e41591cfcd1ece71bdf27b [file] [log] [blame]
Jeff Tinker53b52fe2016-12-01 18:12:56 -08001/**
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 Tinkerda002fe2017-01-19 14:41:11 -080016package android.hardware.drm@1.0;
Jeff Tinker53b52fe2016-12-01 18:12:56 -080017
18import 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 */
28interface IDrmPlugin {
29
30 /**
31 * Open a new session with the DrmPlugin object. A session ID is returned
32 * in the sessionId parameter.
Jeff Tinkerb3a16722016-12-30 19:03:17 -080033 * @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 Tinkerb075caa2016-12-06 23:15:20 -080040 * @return sessionId the session ID for the newly opened session
Jeff Tinker53b52fe2016-12-01 18:12:56 -080041 */
Jeff Tinkerb075caa2016-12-06 23:15:20 -080042 openSession() generates (Status status, SessionId sessionId);
Jeff Tinker53b52fe2016-12-01 18:12:56 -080043
44 /**
45 * Close a session on the DrmPlugin object
46 *
47 * @param sessionId the session id the call applies to
Jeff Tinkerb3a16722016-12-30 19:03:17 -080048 * @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 Tinker35594ec2016-12-14 09:55:22 -080051 * if the HAL is in a state where the session cannot be closed.
Jeff Tinker53b52fe2016-12-01 18:12:56 -080052 */
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 Tinkerb3a16722016-12-30 19:03:17 -080078 * @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 Tinkerb075caa2016-12-06 23:15:20 -080085 * @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 Tinker53b52fe2016-12-01 18:12:56 -080092 * @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 Tinkerb075caa2016-12-06 23:15:20 -080097 string mimeType, KeyType keyType, KeyedVector optionalParameters)
98 generates (Status status, vec<uint8_t> request,
99 KeyRequestType requestType, string defaultUrl);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800100
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 Tinkerb3a16722016-12-30 19:03:17 -0800112 * @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 Tinker35594ec2016-12-14 09:55:22 -0800118 * 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 Tinkerb075caa2016-12-06 23:15:20 -0800120 * @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 Tinker53b52fe2016-12-01 18:12:56 -0800125 */
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800126 provideKeyResponse(vec<uint8_t> scope, vec<uint8_t> response)
127 generates (Status status, vec<uint8_t> keySetId);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800128
129 /**
130 * Remove the current keys from a session
131 *
132 * @param sessionId the session id the call applies to
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800133 * @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 Tinker35594ec2016-12-14 09:55:22 -0800136 * if the HAL is in a state where the keys cannot be removed.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800137 */
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 Tinkerb3a16722016-12-30 19:03:17 -0800146 * @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 Tinker35594ec2016-12-14 09:55:22 -0800149 * if the HAL is in a state where keys cannot be restored.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800150 */
151 restoreKeys(SessionId sessionId,
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800152 vec<uint8_t> keySetId) generates (Status status);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800153
Jeff Tinker35594ec2016-12-14 09:55:22 -0800154 /**
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800155 * 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 Tinkerb3a16722016-12-30 19:03:17 -0800162 * @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 Tinker35594ec2016-12-14 09:55:22 -0800165 * if the HAL is in a state where key status cannot be queried.
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800166 * @return infoList a list of name value pairs describing the license
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800167 */
168 queryKeyStatus(SessionId sessionId)
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800169 generates (Status status, KeyedVector infoList);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800170
171 /**
172 * A provision request/response exchange occurs between the app and a
173 * provisioning server to retrieve a device certificate. getProvisionRequest
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800174 * is used to obtain an opaque provisioning request blob that is delivered
175 * to the provisioning server.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800176 *
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 Tinkerb075caa2016-12-06 23:15:20 -0800180 * for use by other parties. It is an example of a trusted third party.
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800181 * @return status the status of the call. The status must be OK or one of
Jeff Tinker7e0a4e52017-03-06 17:08:19 -0800182 * the following errors: BAD_VALUE if the sessionId is invalid,
183 * ERROR_DRM_CANNOT_HANDLE if the drm scheme does not require provisioning
184 * or ERROR_DRM_INVALID_STATE if the HAL is in a state where the provision
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800185 * request cannot be generated.
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800186 * @return request if successful the opaque certificate request blob
187 * is returned
188 * @return defaultUrl URL that the provisioning request should be
189 * sent to, if known by the HAL implementation. If the HAL implementation
190 * does not provide a defaultUrl, the returned string must be empty.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800191 */
192 getProvisionRequest(string certificateType, string certificateAuthority)
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800193 generates (Status status, vec<uint8_t> request, string defaultUrl);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800194
195 /**
196 * After a provision response is received by the app from a provisioning
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800197 * server, it is provided to the Drm HAL using provideProvisionResponse.
198 * The HAL implementation must receive the provision request and
199 * store the provisioned credentials.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800200 *
201 * @param response the opaque provisioning response received by the
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800202 * app from a provisioning server.
203
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800204 * @return status the status of the call. The status must be OK or one of
205 * the following errors: ERROR_DRM_DEVICE_REVOKED if the device has been
206 * disabled by the license policy, BAD_VALUE if any parameters are invalid
207 * or ERROR_DRM_INVALID_STATE if the HAL is in a state where the provision
208 * response cannot be handled.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800209 * @return certificate the public certificate resulting from the provisioning
210 * operation, if any. An empty vector indicates that no certificate was
211 * returned.
212 * @return wrappedKey an opaque object containing encrypted private key
213 * material to be used by signRSA when computing an RSA signature on a
214 * message, see the signRSA method.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800215 */
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800216 provideProvisionResponse(vec<uint8_t> response) generates (Status status,
217 vec<uint8_t> certificate, vec<uint8_t> wrappedKey);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800218
219 /**
220 * SecureStop is a way of enforcing the concurrent stream limit per
221 * subscriber. It can securely monitor the lifetime of sessions across
222 * device reboots by periodically persisting the session lifetime
223 * status in secure storage.
224 *
225 * A signed version of the sessionID is written to persistent storage on the
226 * device when each MediaCrypto object is created and periodically during
227 * playback. The sessionID is signed by the device private key to prevent
228 * tampering.
229 *
230 * When playback is completed the session is destroyed, and the secure
231 * stops are queried by the app. The app then delivers the secure stop
232 * message to a server which verifies the signature to confirm that the
233 * session and its keys have been removed from the device. The persisted
234 * record on the device is removed after receiving and verifying the
235 * signed response from the server.
236 */
237
238 /**
239 * Get all secure stops on the device
240 *
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800241 * @return status the status of the call. The status must be OK or
Jeff Tinker35594ec2016-12-14 09:55:22 -0800242 * ERROR_DRM_INVALID_STATE if the HAL is in a state where the secure stops
243 * cannot be returned.
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800244 * @return secureStops a list of the secure stop opaque objects
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800245 */
246 getSecureStops() generates
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800247 (Status status, vec<SecureStop> secureStops);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800248
249 /**
Jeff Tinker35594ec2016-12-14 09:55:22 -0800250 * Get all secure stops by secure stop ID
251 *
252 * @param secureStopId the ID of the secure stop to return. The
253 * secure stop ID is delivered by the key server as part of the key
254 * response and must also be known by the app.
255 *
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800256 * @return status the status of the call. The status must be OK or one of
257 * the following errors: BAD_VALUE if the secureStopId is invalid or
258 * ERROR_DRM_INVALID_STATE if the HAL is in a state where the secure stop
259 * cannot be returned.
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800260 * @return secureStop the secure stop opaque object
Jeff Tinker35594ec2016-12-14 09:55:22 -0800261 */
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800262
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800263 getSecureStop(SecureStopId secureStopId)
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800264 generates (Status status, SecureStop secureStop);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800265
266 /**
267 * Release all secure stops on the device
268 *
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800269 * @return status the status of the call. The status must be OK or
Jeff Tinker35594ec2016-12-14 09:55:22 -0800270 * ERROR_DRM_INVALID_STATE if the HAL is in a state where the secure
271 * stops cannot be released.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800272 */
273 releaseAllSecureStops() generates (Status status);
274
275 /**
Jeff Tinker35594ec2016-12-14 09:55:22 -0800276 * Release a secure stop by secure stop ID
277 *
278 * @param secureStopId the ID of the secure stop to release. The
279 * secure stop ID is delivered by the key server as part of the key
280 * response and must also be known by the app.
281 *
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800282 * @return status the status of the call. The status must be OK or one of
283 * the following errors: BAD_VALUE if the secureStopId is invalid or
284 * ERROR_DRM_INVALID_STATE if the HAL is in a state where the secure stop
285 * cannot be released.
Jeff Tinker35594ec2016-12-14 09:55:22 -0800286 */
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800287 releaseSecureStop(vec<uint8_t> secureStopId) generates (Status status);
288
289 /**
290 * A drm scheme can have properties that are settable and readable
291 * by an app. There are a few forms of property access methods,
292 * depending on the data type of the property.
293 *
294 * Property values defined by the public API are:
295 * "vendor" [string] identifies the maker of the drm scheme
296 * "version" [string] identifies the version of the drm scheme
297 * "description" [string] describes the drm scheme
298 * 'deviceUniqueId' [byte array] The device unique identifier is
299 * established during device provisioning and provides a means of
300 * uniquely identifying each device.
301 *
302 * Since drm scheme properties may vary, additional field names may be
303 * defined by each DRM vendor. Refer to your DRM provider documentation
304 * for definitions of its additional field names.
305 */
306
307 /**
308 * Read a string property value given the property name.
309 *
310 * @param propertyName the name of the property
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800311 * @return status the status of the call. The status must be OK or one of
312 * the following errors: BAD_VALUE if the property name is invalid,
313 * ERROR_DRM_CANNOT_HANDLE if the property is not supported, or
314 * ERROR_DRM_INVALID_STATE if the HAL is in a state where the property
315 * cannot be obtained.
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800316 * @return value the property value string
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800317 */
318 getPropertyString(string propertyName)
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800319 generates (Status status, string value);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800320
321 /**
322 * Read a byte array property value given the property name.
323 *
324 * @param propertyName the name of the property
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800325 * @return status the status of the call. The status must be OK or one of
326 * the following errors: BAD_VALUE if the property name is invalid,
327 * ERROR_DRM_CANNOT_HANDLE if the property is not supported, or
328 * ERROR_DRM_INVALID_STATE if the HAL is in a state where the property
329 * cannot be obtained.
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800330 * @return value the property value byte array
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800331 */
332 getPropertyByteArray(string propertyName)
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800333 generates (Status status, vec<uint8_t> value);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800334
335 /**
336 * Write a property string value given the property name
337 *
338 * @param propertyName the name of the property
339 * @param value the value to write
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800340 * @return status the status of the call. The status must be OK or one of
341 * the following errors: BAD_VALUE if the property name is invalid,
342 * ERROR_DRM_CANNOT_HANDLE if the property is not supported, or
343 * ERROR_DRM_INVALID_STATE if the HAL is in a state where the property
344 * cannot be set.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800345 */
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800346 setPropertyString(string propertyName, string value)
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800347 generates (Status status);
348
349 /**
350 * Write a property byte array value given the property name
351 *
352 * @param propertyName the name of the property
353 * @param value the value to write
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800354 * @return status the status of the call. The status must be OK or one of
355 * the following errors: BAD_VALUE if the property name is invalid,
356 * ERROR_DRM_CANNOT_HANDLE if the property is not supported, or
357 * ERROR_DRM_INVALID_STATE if the HAL is in a state where the property
358 * cannot be set.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800359 */
360 setPropertyByteArray(string propertyName, vec<uint8_t> value )
361 generates (Status status);
362
363 /**
364 * The following methods implement operations on a CryptoSession to support
365 * encrypt, decrypt, sign verify operations on operator-provided
366 * session keys.
367 */
368
369 /**
370 * Set the cipher algorithm to be used for the specified session.
371 *
372 * @param sessionId the session id the call applies to
373 * @param algorithm the algorithm to use. The string conforms to JCA
374 * Standard Names for Cipher Transforms and is case insensitive. An
375 * example algorithm is "AES/CBC/PKCS5Padding".
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800376 * @return status the status of the call. The status must be OK or one of
377 * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not
378 * opened, BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE
Jeff Tinker35594ec2016-12-14 09:55:22 -0800379 * if the HAL is in a state where the algorithm cannot be set.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800380 */
381 setCipherAlgorithm(SessionId sessionId, string algorithm)
382 generates (Status status);
383
384 /**
385 * Set the MAC algorithm to be used for computing hashes in a session.
386 *
387 * @param sessionId the session id the call applies to
388 * @param algorithm the algorithm to use. The string conforms to JCA
389 * Standard Names for Mac Algorithms and is case insensitive. An example MAC
390 * algorithm string is "HmacSHA256".
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800391 * @return status the status of the call. The status must be OK or one of the
392 * following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not
393 * opened, BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE
Jeff Tinker35594ec2016-12-14 09:55:22 -0800394 * if the HAL is in a state where the algorithm cannot be set.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800395 */
396 setMacAlgorithm(SessionId sessionId, string algorithm)
397 generates (Status status);
398
399 /**
400 * Encrypt the provided input buffer with the cipher algorithm specified by
401 * setCipherAlgorithm and the key selected by keyId, and return the
402 * encrypted data.
403 *
404 * @param sessionId the session id the call applies to
405 * @param keyId the ID of the key to use for encryption
406 * @param input the input data to encrypt
407 * @param iv the initialization vector to use for encryption
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800408 * @return status the status of the call. The status must be OK or one of the
409 * following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not opened,
Jeff Tinker35594ec2016-12-14 09:55:22 -0800410 * BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800411 * if the HAL is in a state where the encrypt operation cannot be performed.
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800412 * @return output the decrypted data
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800413 */
414 encrypt(SessionId sessionId, vec<uint8_t> keyId, vec<uint8_t> input,
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800415 vec<uint8_t> iv) generates (Status status, vec<uint8_t> output);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800416
417 /**
418 * Decrypt the provided input buffer with the cipher algorithm
419 * specified by setCipherAlgorithm and the key selected by keyId,
420 * and return the decrypted data.
421 *
422 * @param sessionId the session id the call applies to
423 * @param keyId the ID of the key to use for decryption
424 * @param input the input data to decrypt
425 * @param iv the initialization vector to use for decryption
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800426 * @return status the status of the call. The status must be OK or one of
427 * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not
428 * opened, BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE
Jeff Tinker35594ec2016-12-14 09:55:22 -0800429 * if the HAL is in a state where the decrypt operation cannot be
430 * performed.
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800431 * @return output the decrypted data
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800432 */
433 decrypt(SessionId sessionId, vec<uint8_t> keyId, vec<uint8_t> input,
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800434 vec<uint8_t> iv) generates (Status status, vec<uint8_t> output);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800435
436 /**
437 * Compute a signature over the provided message using the mac algorithm
438 * specified by setMacAlgorithm and the key selected by keyId and return
439 * the signature.
440 *
441 * @param sessionId the session id the call applies to
442 * @param keyId the ID of the key to use for decryption
443 * @param message the message to compute a signature over
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800444 * @return status the status of the call. The status must be OK or one of
445 * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not
446 * opened, BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE
Jeff Tinker35594ec2016-12-14 09:55:22 -0800447 * if the HAL is in a state where the sign operation cannot be
448 * performed.
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800449 * @return signature the computed signature
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800450 */
451 sign(SessionId sessionId, vec<uint8_t> keyId, vec<uint8_t> message)
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800452 generates (Status status, vec<uint8_t> signature);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800453
454 /**
455 * Compute a hash of the provided message using the mac algorithm specified
456 * by setMacAlgorithm and the key selected by keyId, and compare with the
457 * expected result.
458 *
459 * @param sessionId the session id the call applies to
460 * @param keyId the ID of the key to use for decryption
461 * @param message the message to compute a hash of
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800462 * @param signature the signature to verify
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800463 * @return status the status of the call. The status must be OK or one of
464 * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is not
465 * opened, BAD_VALUE if any parameters are invalid or ERROR_DRM_INVALID_STATE
Jeff Tinker35594ec2016-12-14 09:55:22 -0800466 * if the HAL is in a state where the verify operation cannot be
467 * performed.
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800468 * @return match true if the signature is verified positively,
469 * false otherwise.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800470 */
471 verify(SessionId sessionId, vec<uint8_t> keyId, vec<uint8_t> message,
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800472 vec<uint8_t> signature) generates (Status status, bool match);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800473
474 /**
475 * Compute an RSA signature on the provided message using the specified
476 * algorithm.
477 *
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800478 * @param sessionId the session id the call applies to
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800479 * @param algorithm the signing algorithm, such as "RSASSA-PSS-SHA1"
480 * or "PKCS1-BlockType1"
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800481 * @param message the message to compute the signature on
Jeff Tinker35594ec2016-12-14 09:55:22 -0800482 * @param wrappedKey the private key returned during provisioning as
483 * returned by provideProvisionResponse.
Jeff Tinkerb3a16722016-12-30 19:03:17 -0800484 * @return status the status of the call. The status must be OK or one of
485 * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is
486 * not opened, BAD_VALUE if any parameters are invalid or
487 * ERROR_DRM_INVALID_STATE if the HAL is in a state where the signRSA
488 * operation cannot be performed.
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800489 * @return signature the RSA signature computed over the message
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800490 */
491 signRSA(SessionId sessionId, string algorithm, vec<uint8_t> message,
492 vec<uint8_t> wrappedkey)
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800493 generates (Status status, vec<uint8_t> signature);
494
495 /**
496 * Plugins call the following methods to deliver events to the
497 * java app.
498 */
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800499
500 /**
501 * Set a listener for a drm session. This allows the drm HAL to
502 * make asynchronous calls back to the client of IDrm.
503 *
504 * @param listener instance of IDrmPluginListener to receive the events
505 */
506 setListener(IDrmPluginListener listener);
507
508 /**
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800509 * Legacy event sending method, it sends events of various types using a
510 * single overloaded set of parameters. This form is deprecated.
511 *
512 * @param eventType the type of the event
513 * @param sessionId identifies the session the event originated from
514 * @param data event-specific data blob
515 */
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800516 sendEvent(EventType eventType, SessionId sessionId, vec<uint8_t> data);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800517
518 /**
519 * Send a license expiration update to the listener. The expiration
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800520 * update indicates how long the current license is valid before it
521 * needs to be renewed.
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800522 *
523 * @param sessionId identifies the session the event originated from
524 * @param expiryTimeInMS the time when the keys need to be renewed.
525 * The time is in milliseconds, relative to the Unix epoch. A time of 0
526 * indicates that the keys never expire.
527 */
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800528 sendExpirationUpdate(SessionId sessionId, int64_t expiryTimeInMS);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800529
530 /**
531 * Send a keys change event to the listener. The keys change event
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800532 * indicates the status of each key in the session. Keys can be
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800533 * indicated as being usable, expired, outputnotallowed or statuspending.
534 *
535 * @param sessionId identifies the session the event originated from
536 * @param keyStatusList indicates the status for each key ID in the
537 * session.
538 * @param hasNewUsableKey indicates if the event includes at least one
539 * key that has become usable.
540 */
Jeff Tinkerb075caa2016-12-06 23:15:20 -0800541 sendKeysChange(SessionId sessionId, vec<KeyStatus> keyStatusList,
542 bool hasNewUsableKey);
Jeff Tinker53b52fe2016-12-01 18:12:56 -0800543};