Error when decrypting Widevine PSSH using protobuf

1.3k views Asked by At

I am trying to parse Widevine PSSH data and read its content. This is a PSSH data example taken from https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd

AAAAR3Bzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAACcIARIBMBoNd2lkZXZpbmVfdGVzdCIKMjAxNV90ZWFycyoFQVVESU8=

I create the proto message in this way

syntax = "proto2";

package drm;

option java_package = "com.drm.widevine";
option java_outer_classname = "WidevineCenc";

message WidevinePsshData {
    enum Algorithm {
        UNENCRYPTED = 0 ;
        AESCTR = 1 ;
    };
    optional Algorithm algorithm = 1 ;
    repeated bytes key_id = 2 ;
    // Content provider name.
    optional string provider = 3 ;
    // A content identifier, specified by content provider.
    optional bytes content_id = 4 ;
    // Track type. Acceptable values are SD, HD and AUDIO. Used to
    // differentiate content keys used by an asset.
    optional string track_type = 5 ;
    // The name of a registered policy to be used for this asset.
    optional string policy = 6 ;
    // Crypto period index, for media using key rotation.
    optional uint32 crypto_period_index = 7;
}

And I try to deserialize the pssh-data as following

String psshString = "AAAAR3Bzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAACcIARIBMBoNd2lkZXZpbmVfdGVzdCIKMjAxNV90ZWFycyoFQVVESU8=";
byte[] data = Base64.decode(psshString, Base64.DEFAULT);
WidevineCenc.WidevinePsshData pssh = WidevineCenc.WidevinePsshData.parseFrom(data);

I get this error

com.google.protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero).

0

There are 0 answers