1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 //#define LOG_NDEBUG 0 18 #define LOG_TAG "ClearKeyCryptoPlugin" 19 #include <utils/Log.h> 20 21 #include <utils/Errors.h> 22 #include <utils/StrongPointer.h> 23 24 #include "CryptoFactory.h" 25 26 #include "ClearKeyUUID.h" 27 #include "CryptoPlugin.h" 28 #include "Session.h" 29 #include "SessionLibrary.h" 30 31 namespace clearkeydrm { 32 33 bool CryptoFactory::isCryptoSchemeSupported(const uint8_t uuid[16]) const { 34 return isClearKeyUUID(uuid); 35 } 36 37 android::status_t CryptoFactory::createPlugin( 38 const uint8_t uuid[16], 39 const void* data, size_t size, 40 android::CryptoPlugin** plugin) { 41 if (!isCryptoSchemeSupported(uuid)) { 42 *plugin = NULL; 43 return android::BAD_VALUE; 44 } 45 46 android::sp<Session> session = SessionLibrary::get()->findSession( 47 data, size); 48 *plugin = new CryptoPlugin(session); 49 return android::OK; 50 } 51 52 } // namespace clearkeydrm 53