Unit test script and end-to-end license/decrypt test update
Does not affect any production code, only unit tests Makes the end-to-end license/decrypt test compatible with the fix for b/8604068 (merged). related-to-bug: 8604068 Merge of https://widevine-internal-review.googlesource.com/#/c/4982/ from widevine cdm repository to android repository. Change-Id: Ic5739c9de0cd385a672311ec87b9a475e367121a
This commit is contained in:
@@ -35,7 +35,7 @@ cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine/oemcrypto/test
|
|||||||
pwd
|
pwd
|
||||||
mm
|
mm
|
||||||
|
|
||||||
cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine/test
|
cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine/test/unit
|
||||||
pwd
|
pwd
|
||||||
mm
|
mm
|
||||||
|
|
||||||
@@ -46,14 +46,13 @@ mm
|
|||||||
echo "waiting for device"
|
echo "waiting for device"
|
||||||
adb root && adb wait-for-device remount && adb sync
|
adb root && adb wait-for-device remount && adb sync
|
||||||
|
|
||||||
|
|
||||||
adb shell /system/bin/request_license_test
|
adb shell /system/bin/request_license_test
|
||||||
adb shell /system/bin/policy_engine_unittest
|
adb shell /system/bin/policy_engine_unittest
|
||||||
adb shell /system/bin/libwvdrmmediacrypto_test
|
adb shell /system/bin/libwvdrmmediacrypto_test
|
||||||
adb shell /system/bin/libwvdrmdrmplugin_test
|
adb shell /system/bin/libwvdrmdrmplugin_test
|
||||||
adb shell /system/bin/http_socket_test
|
|
||||||
adb shell /system/bin/cdm_engine_test
|
adb shell /system/bin/cdm_engine_test
|
||||||
adb shell /system/bin/oemcrypto_test
|
adb shell /system/bin/oemcrypto_test
|
||||||
|
adb shell LD_LIBRARY_PATH=/system/vendor/lib/mediadrm/ /system/bin/libwvdrmengine_test
|
||||||
|
|
||||||
adb shell am start com.widevine.test/com.widevine.test.MediaDrmAPITest
|
adb shell am start com.widevine.test/com.widevine.test.MediaDrmAPITest
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import java.util.UUID;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
import java.util.Random;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -258,40 +259,49 @@ public class MediaDrmAPITest extends TabActivity {
|
|||||||
}
|
}
|
||||||
Log.i(TAG, "Got index " + index);
|
Log.i(TAG, "Got index " + index);
|
||||||
|
|
||||||
|
final int kMaxSubsamplesPerSample = 10;
|
||||||
|
final int kMaxSampleSize = 128 * 1024;
|
||||||
|
;
|
||||||
|
int clearSizes[] = new int[kMaxSubsamplesPerSample];
|
||||||
|
int encryptedSizes[] = new int[kMaxSubsamplesPerSample];
|
||||||
|
|
||||||
LinkedList<TestVector> vectors = TestVectors.GetTestVectors();
|
LinkedList<TestVector> vectors = TestVectors.GetTestVectors();
|
||||||
ListIterator<TestVector> iter = vectors.listIterator(0);
|
ListIterator<TestVector> iter = vectors.listIterator(0);
|
||||||
|
|
||||||
|
ByteBuffer refBuffer = ByteBuffer.allocate(kMaxSampleSize);
|
||||||
|
|
||||||
|
Random rand = new Random();
|
||||||
|
|
||||||
|
byte iv[] = null;
|
||||||
|
byte keyID[] = null;
|
||||||
|
|
||||||
|
int numSubSamples = 0;
|
||||||
|
int sampleSize = 0;
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
TestVector tv = iter.next();
|
TestVector tv = iter.next();
|
||||||
|
if (tv.mByteOffset == 0) {
|
||||||
|
// start of a new sample
|
||||||
|
|
||||||
|
if (numSubSamples > 0) {
|
||||||
|
// send the sample we have
|
||||||
CryptoInfo info = new CryptoInfo();
|
CryptoInfo info = new CryptoInfo();
|
||||||
int clearSizes[] = { tv.mByteOffset };
|
info.set(numSubSamples, clearSizes, encryptedSizes, keyID, iv,
|
||||||
int encryptedSizes[] = { tv.mEncryptedBuf.length };
|
|
||||||
|
|
||||||
info.set(1, clearSizes, encryptedSizes, tv.mKeyID, tv.mIV,
|
|
||||||
MediaCodec.CRYPTO_MODE_AES_CTR);
|
MediaCodec.CRYPTO_MODE_AES_CTR);
|
||||||
|
|
||||||
byte clearBuf[] = new byte[tv.mByteOffset];
|
|
||||||
for (int i = 0; i < clearBuf.length; i++) {
|
|
||||||
clearBuf[i] = (byte)i;
|
|
||||||
}
|
|
||||||
|
|
||||||
inputBuffers[index].clear();
|
|
||||||
inputBuffers[index].put(clearBuf, 0, clearBuf.length);
|
|
||||||
inputBuffers[index].put(tv.mEncryptedBuf, 0, tv.mEncryptedBuf.length);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Log.i(TAG,"Sending " + sampleSize + " bytes, numSubSamples=" + numSubSamples);
|
||||||
codec.queueSecureInputBuffer(index, 0 /* offset */, info,
|
codec.queueSecureInputBuffer(index, 0 /* offset */, info,
|
||||||
0 /* sampleTime */, 0 /* flags */);
|
0 /* sampleTime */, 0 /* flags */);
|
||||||
} catch (CryptoException e) {
|
} catch (CryptoException e) {
|
||||||
ByteBuffer refBuffer = ByteBuffer.allocate(clearBuf.length + tv.mClearBuf.length);
|
Log.i(TAG,"Checking " + sampleSize + " bytes");
|
||||||
refBuffer.put(clearBuf, 0, clearBuf.length);
|
|
||||||
refBuffer.put(tv.mClearBuf, 0, tv.mClearBuf.length);
|
|
||||||
|
|
||||||
// in test mode, the WV CryptoPlugin throws a CryptoException where the
|
// in test mode, the WV CryptoPlugin throws a CryptoException where the
|
||||||
// message string contains a SHA256 hash of the decrypted data, for verification
|
// message string contains a SHA256 hash of the decrypted data, for verification
|
||||||
// purposes.
|
// purposes.
|
||||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||||
byte[] sha256 = digest.digest(refBuffer.array());
|
byte buf[] = Arrays.copyOf(refBuffer.array(), sampleSize);
|
||||||
|
byte[] sha256 = digest.digest(buf);
|
||||||
if (Arrays.equals(sha256, hex2ba(e.getMessage()))) {
|
if (Arrays.equals(sha256, hex2ba(e.getMessage()))) {
|
||||||
Log.i(TAG, "sha256: " + e.getMessage() + " matches OK");
|
Log.i(TAG, "sha256: " + e.getMessage() + " matches OK");
|
||||||
} else {
|
} else {
|
||||||
@@ -302,6 +312,34 @@ public class MediaDrmAPITest extends TabActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear buffers for next sample
|
||||||
|
numSubSamples = 0;
|
||||||
|
sampleSize = 0;
|
||||||
|
inputBuffers[index].clear();
|
||||||
|
refBuffer.clear();
|
||||||
|
}
|
||||||
|
keyID = tv.mKeyID;
|
||||||
|
iv = tv.mIV;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add this subsample vector to the list
|
||||||
|
int clearSize = rand.nextInt(100);
|
||||||
|
byte clearBuf[] = new byte[clearSize];
|
||||||
|
for (int i = 0; i < clearBuf.length; i++) {
|
||||||
|
clearBuf[i] = (byte)i;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearSizes[numSubSamples] = clearSize;
|
||||||
|
encryptedSizes[numSubSamples] = tv.mEncryptedBuf.length;
|
||||||
|
numSubSamples++;
|
||||||
|
|
||||||
|
inputBuffers[index].put(clearBuf, 0, clearBuf.length);
|
||||||
|
inputBuffers[index].put(tv.mEncryptedBuf, 0, tv.mEncryptedBuf.length);
|
||||||
|
|
||||||
|
refBuffer.put(clearBuf, 0, clearBuf.length);
|
||||||
|
refBuffer.put(tv.mClearBuf, 0, tv.mClearBuf.length);
|
||||||
|
sampleSize += clearSize + tv.mEncryptedBuf.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
codec.stop();
|
codec.stop();
|
||||||
|
|||||||
Reference in New Issue
Block a user