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

Commit 0fe78078 authored by Greg Kaiser's avatar Greg Kaiser
Browse files

MockDrmCryptoPlugin: Don't truncate log output

A function argument which is an array with a fixed size is not
actually a fixed size array, but rather just a pointer.  Thus,
when we were using sizeof() for 'key' and 'iv', we were mostly
likely only logging the first 4 or 8 bytes of the array, and
not all 16.

We change this code so we're at least passing the correct size
to the arrayToString method, and thus logging all the bytes.

This API is still fragile, as there is nothing which assures
callers to decrypt are passing in arrays which are exactly 16
bytes.  However, this API is equivalent to before, so we aren't
introducing any compatibility issues.

The compiler gave a warning about this.

Test: Compiled and confirmed there's no longer this compiler warning.
Change-Id: Ie3a32eef0882ea95bccc3e22ffcab7336779bd4c
parent c11caab9
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -791,8 +791,9 @@ namespace android {
    }

    ssize_t
    MockCryptoPlugin::decrypt(bool secure, const uint8_t key[16], const uint8_t iv[16],
            Mode mode, const Pattern &pattern, const void *srcPtr,
    MockCryptoPlugin::decrypt(bool secure, const uint8_t key[DECRYPT_KEY_SIZE],
            const uint8_t iv[DECRYPT_KEY_SIZE], Mode mode,
            const Pattern &pattern, const void *srcPtr,
            const SubSample *subSamples, size_t numSubSamples,
            void *dstPtr, AString * /* errorDetailMsg */)
    {
@@ -800,8 +801,8 @@ namespace android {
              "pattern:{encryptBlocks=%d, skipBlocks=%d} src=%p, "
              "subSamples=%s, dst=%p)",
              (int)secure,
              arrayToString(key, sizeof(key)).string(),
              arrayToString(iv, sizeof(iv)).string(),
              arrayToString(key, DECRYPT_KEY_SIZE).string(),
              arrayToString(iv, DECRYPT_KEY_SIZE).string(),
              (int)mode, pattern.mEncryptBlocks, pattern.mSkipBlocks, srcPtr,
              subSamplesToString(subSamples, numSubSamples).string(),
              dstPtr);
+5 −2
Original line number Diff line number Diff line
@@ -157,9 +157,12 @@ namespace android {

        bool requiresSecureDecoderComponent(const char *mime) const;

        static constexpr size_t DECRYPT_KEY_SIZE = 16;

        ssize_t decrypt(bool secure,
            const uint8_t key[16], const uint8_t iv[16],
            Mode mode, const Pattern &pattern, const void *srcPtr,
            const uint8_t key[DECRYPT_KEY_SIZE],
            const uint8_t iv[DECRYPT_KEY_SIZE], Mode mode,
            const Pattern &pattern, const void *srcPtr,
            const SubSample *subSamples, size_t numSubSamples,
            void *dstPtr, AString *errorDetailMsg);
    private: