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

Commit 81e0bd44 authored by Jeff Tinker's avatar Jeff Tinker
Browse files

Add signature|system permission to MediaDrm signer APIs

Change-Id: If970e5ff8dcab2e67af2f3376dcd14dca82f2394
related-to-bug: 12702350
parent 68d9d71a
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -28,9 +28,21 @@
#include <media/stagefright/foundation/AString.h>
#include <media/stagefright/foundation/hexdump.h>
#include <media/stagefright/MediaErrors.h>
#include <binder/IServiceManager.h>
#include <binder/IPCThreadState.h>

namespace android {

static bool checkPermission(const char* permissionString) {
#ifndef HAVE_ANDROID_OS
    return true;
#endif
    if (getpid() == IPCThreadState::self()->getCallingPid()) return true;
    bool ok = checkCallingPermission(String16(permissionString));
    if (!ok) ALOGE("Request requires %s", permissionString);
    return ok;
}

KeyedVector<Vector<uint8_t>, String8> Drm::mUUIDToLibraryPathMap;
KeyedVector<String8, wp<SharedLibrary> > Drm::mLibraryPathToOpenLibraryMap;
Mutex Drm::mMapLock;
@@ -608,6 +620,10 @@ status_t Drm::signRSA(Vector<uint8_t> const &sessionId,
        return -EINVAL;
    }

    if (!checkPermission("android.permission.ACCESS_DRM_CERTIFICATES")) {
        return -EPERM;
    }

    return mPlugin->signRSA(sessionId, algorithm, message, wrappedKey, signature);
}