1*4d7e907cSAndroid Build Coastguard Worker/** 2*4d7e907cSAndroid Build Coastguard Worker * Copyright (C) 2018 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 @1.0::DestinationBuffer; 19*4d7e907cSAndroid Build Coastguard Workerimport @1.0::ICryptoPlugin; 20*4d7e907cSAndroid Build Coastguard Workerimport @1.0::Mode; 21*4d7e907cSAndroid Build Coastguard Workerimport @1.0::Pattern; 22*4d7e907cSAndroid Build Coastguard Workerimport @1.0::SessionId; 23*4d7e907cSAndroid Build Coastguard Workerimport @1.0::SharedBuffer; 24*4d7e907cSAndroid Build Coastguard Workerimport @1.0::SubSample; 25*4d7e907cSAndroid Build Coastguard Worker 26*4d7e907cSAndroid Build Coastguard Worker/** 27*4d7e907cSAndroid Build Coastguard Worker * ICryptoPlugin is the HAL for vendor-provided crypto plugins. 28*4d7e907cSAndroid Build Coastguard Worker * It allows crypto sessions to be opened and operated on, to 29*4d7e907cSAndroid Build Coastguard Worker * load crypto keys for a codec to decrypt protected video content. 30*4d7e907cSAndroid Build Coastguard Worker */ 31*4d7e907cSAndroid Build Coastguard Workerinterface ICryptoPlugin extends @1.0::ICryptoPlugin { 32*4d7e907cSAndroid Build Coastguard Worker 33*4d7e907cSAndroid Build Coastguard Worker /** 34*4d7e907cSAndroid Build Coastguard Worker * Decrypt an array of subsamples from the source memory buffer to the 35*4d7e907cSAndroid Build Coastguard Worker * destination memory buffer. 36*4d7e907cSAndroid Build Coastguard Worker * 37*4d7e907cSAndroid Build Coastguard Worker * decrypt_1_2() only differs from decrypt() in that additional status 38*4d7e907cSAndroid Build Coastguard Worker * codes must be returned. 39*4d7e907cSAndroid Build Coastguard Worker * 40*4d7e907cSAndroid Build Coastguard Worker * @param secure a flag to indicate if a secure decoder is being used. This 41*4d7e907cSAndroid Build Coastguard Worker * enables the plugin to configure buffer modes to work consistently with 42*4d7e907cSAndroid Build Coastguard Worker * a secure decoder. 43*4d7e907cSAndroid Build Coastguard Worker * @param the keyId for the key that is used to do the the decryption. The 44*4d7e907cSAndroid Build Coastguard Worker * keyId refers to a key in the associated MediaDrm instance. 45*4d7e907cSAndroid Build Coastguard Worker * @param iv the initialization vector to use 46*4d7e907cSAndroid Build Coastguard Worker * @param mode the crypto mode to use 47*4d7e907cSAndroid Build Coastguard Worker * @param pattern the crypto pattern to use 48*4d7e907cSAndroid Build Coastguard Worker * @param subSamples a vector of subsamples indicating the number 49*4d7e907cSAndroid Build Coastguard Worker * of clear and encrypted bytes to process. This allows the decrypt 50*4d7e907cSAndroid Build Coastguard Worker * call to operate on a range of subsamples in a single call 51*4d7e907cSAndroid Build Coastguard Worker * @param source the input buffer for the decryption 52*4d7e907cSAndroid Build Coastguard Worker * @param offset the offset of the first byte of encrypted data from 53*4d7e907cSAndroid Build Coastguard Worker * the base of the source buffer 54*4d7e907cSAndroid Build Coastguard Worker * @param destination the output buffer for the decryption 55*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or one 56*4d7e907cSAndroid Build Coastguard Worker * of the following errors: 57*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_NO_LICENSE if no license keys have been loaded 58*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_LICENSE_EXPIRED if the license keys have expired 59*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_RESOURCE_BUSY if the resources required to perform 60*4d7e907cSAndroid Build Coastguard Worker * the decryption are not available 61*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION if required output 62*4d7e907cSAndroid Build Coastguard Worker * protections are not active 63*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INSUFFICIENT_SECURITY if the security level of the 64*4d7e907cSAndroid Build Coastguard Worker * device is not sufficient to meet the requirements in 65*4d7e907cSAndroid Build Coastguard Worker * the license policy 66*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_FRAME_TOO_LARGE if the frame being decrypted into 67*4d7e907cSAndroid Build Coastguard Worker * the secure output buffer exceeds the size of the buffer 68*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_SESSION_NOT_OPENED if the decrypt session is not 69*4d7e907cSAndroid Build Coastguard Worker * opened 70*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_DECRYPT if the decrypt operation fails 71*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the device is in a state where it 72*4d7e907cSAndroid Build Coastguard Worker * is not able to perform decryption 73*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_CANNOT_HANDLE in other failure cases. 74*4d7e907cSAndroid Build Coastguard Worker * 75*4d7e907cSAndroid Build Coastguard Worker * @return bytesWritten the number of bytes output from the decryption 76*4d7e907cSAndroid Build Coastguard Worker * @return detailedError if the error is a vendor-specific error, the 77*4d7e907cSAndroid Build Coastguard Worker * vendor's crypto HAL may provide a detailed error string to help 78*4d7e907cSAndroid Build Coastguard Worker * describe the error. 79*4d7e907cSAndroid Build Coastguard Worker */ 80*4d7e907cSAndroid Build Coastguard Worker decrypt_1_2(bool secure, uint8_t[16] keyId, uint8_t[16] iv, Mode mode, 81*4d7e907cSAndroid Build Coastguard Worker Pattern pattern, vec<SubSample> subSamples, 82*4d7e907cSAndroid Build Coastguard Worker SharedBuffer source, uint64_t offset, DestinationBuffer destination) 83*4d7e907cSAndroid Build Coastguard Worker generates(Status status, uint32_t bytesWritten, string detailedError); 84*4d7e907cSAndroid Build Coastguard Worker}; 85