1*4d7e907cSAndroid Build Coastguard Worker/* 2*4d7e907cSAndroid Build Coastguard Worker * Copyright (C) 2016 The Android Open Source Project 3*4d7e907cSAndroid Build Coastguard Worker * 4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*4d7e907cSAndroid Build Coastguard Worker * 8*4d7e907cSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*4d7e907cSAndroid Build Coastguard Worker * 10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License. 15*4d7e907cSAndroid Build Coastguard Worker */ 16*4d7e907cSAndroid Build Coastguard Workerpackage [email protected]; 17*4d7e907cSAndroid Build Coastguard Worker 18*4d7e907cSAndroid Build Coastguard Workerimport [email protected]::types; 19*4d7e907cSAndroid Build Coastguard Worker 20*4d7e907cSAndroid Build Coastguard Worker/** 21*4d7e907cSAndroid Build Coastguard Worker * Ref: frameworks/native/include/media/hardware/CryptoAPI.h:CryptoPlugin 22*4d7e907cSAndroid Build Coastguard Worker * 23*4d7e907cSAndroid Build Coastguard Worker * ICryptoPlugin is the HAL for vendor-provided crypto plugins. 24*4d7e907cSAndroid Build Coastguard Worker * It allows crypto sessions to be opened and operated on, to 25*4d7e907cSAndroid Build Coastguard Worker * load crypto keys for a codec to decrypt protected video content. 26*4d7e907cSAndroid Build Coastguard Worker */ 27*4d7e907cSAndroid Build Coastguard Workerinterface ICryptoPlugin { 28*4d7e907cSAndroid Build Coastguard Worker /** 29*4d7e907cSAndroid Build Coastguard Worker * Check if the specified mime-type requires a secure decoder 30*4d7e907cSAndroid Build Coastguard Worker * component. 31*4d7e907cSAndroid Build Coastguard Worker * 32*4d7e907cSAndroid Build Coastguard Worker * @param mime The content mime-type 33*4d7e907cSAndroid Build Coastguard Worker * @return secureRequired must be true only if a secure decoder is required 34*4d7e907cSAndroid Build Coastguard Worker * for the specified mime-type 35*4d7e907cSAndroid Build Coastguard Worker */ 36*4d7e907cSAndroid Build Coastguard Worker requiresSecureDecoderComponent(string mime) 37*4d7e907cSAndroid Build Coastguard Worker generates(bool secureRequired); 38*4d7e907cSAndroid Build Coastguard Worker 39*4d7e907cSAndroid Build Coastguard Worker /** 40*4d7e907cSAndroid Build Coastguard Worker * Notify a plugin of the currently configured resolution 41*4d7e907cSAndroid Build Coastguard Worker * 42*4d7e907cSAndroid Build Coastguard Worker * @param width - the display resolutions's width 43*4d7e907cSAndroid Build Coastguard Worker * @param height - the display resolution's height 44*4d7e907cSAndroid Build Coastguard Worker */ 45*4d7e907cSAndroid Build Coastguard Worker notifyResolution(uint32_t width, uint32_t height); 46*4d7e907cSAndroid Build Coastguard Worker 47*4d7e907cSAndroid Build Coastguard Worker /** 48*4d7e907cSAndroid Build Coastguard Worker * Associate a mediadrm session with this crypto session 49*4d7e907cSAndroid Build Coastguard Worker * 50*4d7e907cSAndroid Build Coastguard Worker * @param sessionId the MediaDrm session ID to associate with this crypto 51*4d7e907cSAndroid Build Coastguard Worker * session 52*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call, status must be 53*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_SESSION_NOT_OPENED if the session is not opened, or 54*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_CANNOT_HANDLE if the operation is not supported by the drm 55*4d7e907cSAndroid Build Coastguard Worker * scheme. 56*4d7e907cSAndroid Build Coastguard Worker */ 57*4d7e907cSAndroid Build Coastguard Worker setMediaDrmSession(vec<uint8_t> sessionId) generates(Status status); 58*4d7e907cSAndroid Build Coastguard Worker 59*4d7e907cSAndroid Build Coastguard Worker /** 60*4d7e907cSAndroid Build Coastguard Worker * Set a shared memory base for subsequent decrypt operations. The buffer 61*4d7e907cSAndroid Build Coastguard Worker * base is a hidl_memory which maps shared memory in the HAL module. 62*4d7e907cSAndroid Build Coastguard Worker * After the shared buffer base is established, the decrypt() method 63*4d7e907cSAndroid Build Coastguard Worker * receives SharedBuffer instances which specify the buffer address range 64*4d7e907cSAndroid Build Coastguard Worker * for decrypt source and destination addresses. 65*4d7e907cSAndroid Build Coastguard Worker * 66*4d7e907cSAndroid Build Coastguard Worker * There can be multiple shared buffers per crypto plugin. The buffers 67*4d7e907cSAndroid Build Coastguard Worker * are distinguished by the bufferId. 68*4d7e907cSAndroid Build Coastguard Worker * 69*4d7e907cSAndroid Build Coastguard Worker * @param base the base IMemory of the memory buffer identified by 70*4d7e907cSAndroid Build Coastguard Worker * bufferId 71*4d7e907cSAndroid Build Coastguard Worker * @param bufferId identifies the specific shared buffer for which 72*4d7e907cSAndroid Build Coastguard Worker * the base is being set. 73*4d7e907cSAndroid Build Coastguard Worker */ 74*4d7e907cSAndroid Build Coastguard Worker setSharedBufferBase(memory base, uint32_t bufferId); 75*4d7e907cSAndroid Build Coastguard Worker 76*4d7e907cSAndroid Build Coastguard Worker /** 77*4d7e907cSAndroid Build Coastguard Worker * Decrypt an array of subsamples from the source memory buffer to the 78*4d7e907cSAndroid Build Coastguard Worker * destination memory buffer. 79*4d7e907cSAndroid Build Coastguard Worker * 80*4d7e907cSAndroid Build Coastguard Worker * @param secure a flag to indicate if a secure decoder is being used. This 81*4d7e907cSAndroid Build Coastguard Worker * enables the plugin to configure buffer modes to work consistently with 82*4d7e907cSAndroid Build Coastguard Worker * a secure decoder. 83*4d7e907cSAndroid Build Coastguard Worker * @param the keyId for the key that should be used to do the 84*4d7e907cSAndroid Build Coastguard Worker * the decryption. The keyId refers to a key in the associated 85*4d7e907cSAndroid Build Coastguard Worker * MediaDrm instance. 86*4d7e907cSAndroid Build Coastguard Worker * @param iv the initialization vector to use 87*4d7e907cSAndroid Build Coastguard Worker * @param mode the crypto mode to use 88*4d7e907cSAndroid Build Coastguard Worker * @param pattern the crypto pattern to use 89*4d7e907cSAndroid Build Coastguard Worker * @param subSamples a vector of subsamples indicating the number 90*4d7e907cSAndroid Build Coastguard Worker * of clear and encrypted bytes to process. This allows the decrypt 91*4d7e907cSAndroid Build Coastguard Worker * call to operate on a range of subsamples in a single call 92*4d7e907cSAndroid Build Coastguard Worker * @param source the input buffer for the decryption 93*4d7e907cSAndroid Build Coastguard Worker * @param offset the offset of the first byte of encrypted data from 94*4d7e907cSAndroid Build Coastguard Worker * the base of the source buffer 95*4d7e907cSAndroid Build Coastguard Worker * @param destination the output buffer for the decryption 96*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or one of 97*4d7e907cSAndroid Build Coastguard Worker * the following errors: ERROR_DRM_NO_LICENSE if no license keys have been 98*4d7e907cSAndroid Build Coastguard Worker * loaded, ERROR_DRM_LICENSE_EXPIRED if the license keys have expired, 99*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_RESOURCE_BUSY if the resources required to perform the 100*4d7e907cSAndroid Build Coastguard Worker * decryption are not available, ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION 101*4d7e907cSAndroid Build Coastguard Worker * if required output protections are not active, 102*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_SESSION_NOT_OPENED if the decrypt session is not opened, 103*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_DECRYPT if the decrypt operation fails, and 104*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_CANNOT_HANDLE in other failure cases. 105*4d7e907cSAndroid Build Coastguard Worker * @return bytesWritten the number of bytes output from the decryption 106*4d7e907cSAndroid Build Coastguard Worker * @return detailedError if the error is a vendor-specific error, the 107*4d7e907cSAndroid Build Coastguard Worker * vendor's crypto HAL may provide a detailed error string to help 108*4d7e907cSAndroid Build Coastguard Worker * describe the error. 109*4d7e907cSAndroid Build Coastguard Worker */ 110*4d7e907cSAndroid Build Coastguard Worker decrypt(bool secure, uint8_t[16] keyId, uint8_t[16] iv, Mode mode, 111*4d7e907cSAndroid Build Coastguard Worker Pattern pattern, vec<SubSample> subSamples, 112*4d7e907cSAndroid Build Coastguard Worker SharedBuffer source, uint64_t offset, DestinationBuffer destination) 113*4d7e907cSAndroid Build Coastguard Worker generates(Status status, uint32_t bytesWritten, string detailedError); 114*4d7e907cSAndroid Build Coastguard Worker}; 115