Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6fdbe863 authored by Jeff Tinker's avatar Jeff Tinker
Browse files

Add missing 'offset' parameter to decrypt.

Required for functionality

Test: gtests passing

Change-Id: I9e368c146092512dfa42230be0e05848044d2df5
related-to-bug: 32815560
parent 2d386381
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ interface ICryptoPlugin {
     * of clear and encrypted bytes to process. This allows the decrypt
     * call to operate on a range of subsamples in a single call
     * @param source the input buffer for the decryption
     * @param offset the offset of the first byte of encrypted data from
     * the base of the source buffer
     * @param destination the output buffer for the decryption
     * @return status the status of the call. The status must be OK or one of
     * the following errors: ERROR_DRM_NO_LICENSE if no license keys have been
@@ -89,6 +91,6 @@ interface ICryptoPlugin {
     */
    decrypt(bool secure, uint8_t[16] keyId, uint8_t[16] iv, Mode mode,
        Pattern pattern, vec<SubSample> subSamples,
            memory source, DestinationBuffer destination)
            memory source, uint32_t offset, DestinationBuffer destination)
        generates(Status status, uint32_t bytesWritten, string detailedError);
};
+10 −4
Original line number Diff line number Diff line
@@ -54,7 +54,8 @@ namespace implementation {
            const hidl_array<uint8_t, 16>& keyId,
            const hidl_array<uint8_t, 16>& iv, Mode mode,
            const Pattern& pattern, const hidl_vec<SubSample>& subSamples,
            const hidl_memory& source, const DestinationBuffer& destination,
            const hidl_memory& source, uint32_t offset,
            const DestinationBuffer& destination,
            decrypt_cb _hidl_cb) {

        android::CryptoPlugin::Mode legacyMode;
@@ -88,9 +89,14 @@ namespace implementation {

        AString detailMessage;

        void *destPtr = NULL;
        sp<IMemory> sharedSourceMemory = mapMemory(source);

        void *srcPtr = static_cast<void *>(sharedSourceMemory->getPointer());
        uint8_t *offsetSrc = static_cast<uint8_t *>(srcPtr) + offset;
        srcPtr = static_cast<void *>(offsetSrc);

        sp<IMemory> sharedDestinationMemory;
        void *destPtr = NULL;

        if (destination.type == BufferType::SHARED_MEMORY) {
            sharedDestinationMemory = mapMemory(destination.nonsecureMemory);
@@ -102,8 +108,8 @@ namespace implementation {
            destPtr = static_cast<void *>(handle);
        }
        ssize_t result = mLegacyPlugin->decrypt(secure, keyId.data(), iv.data(),
                legacyMode, legacyPattern, sharedSourceMemory->getPointer(),
                legacySubSamples, subSamples.size(), destPtr, &detailMessage);
                legacyMode, legacyPattern, srcPtr, legacySubSamples,
                subSamples.size(), destPtr, &detailMessage);

        if (destination.type == BufferType::SHARED_MEMORY) {
            sharedDestinationMemory->commit();
+2 −1
Original line number Diff line number Diff line
@@ -59,7 +59,8 @@ struct CryptoPlugin : public ICryptoPlugin {
    Return<void> decrypt(bool secure, const hidl_array<uint8_t, 16>& keyId,
            const hidl_array<uint8_t, 16>& iv, Mode mode, const Pattern& pattern,
            const hidl_vec<SubSample>& subSamples, const hidl_memory& source,
            const DestinationBuffer& destination, decrypt_cb _hidl_cb) override;
            uint32_t offset, const DestinationBuffer& destination,
            decrypt_cb _hidl_cb) override;

private:
    android::CryptoPlugin *mLegacyPlugin;