зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1487416 - Read pattern information in Sinf parser. r=jya
Differential Revision: https://phabricator.services.mozilla.com/D15873 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
84526df4e5
Коммит
1db6ef799b
|
@ -55,12 +55,40 @@ Result<Ok, nsresult> SinfParser::ParseTenc(Box& aBox) {
|
|||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
MOZ_TRY(reader->ReadU32()); // flags -- ignore
|
||||
uint32_t flags;
|
||||
MOZ_TRY_VAR(flags, reader->ReadU32());
|
||||
uint8_t version = flags >> 24;
|
||||
|
||||
uint32_t isEncrypted;
|
||||
MOZ_TRY_VAR(isEncrypted, reader->ReadU24());
|
||||
// Skip reserved byte
|
||||
MOZ_TRY(reader->ReadU8());
|
||||
if (version >= 1) {
|
||||
uint8_t pattern;
|
||||
MOZ_TRY_VAR(pattern, reader->ReadU8());
|
||||
mSinf.mDefaultCryptByteBlock = pattern >> 4;
|
||||
mSinf.mDefaultSkipByteBlock = pattern & 0x0f;
|
||||
} else {
|
||||
// Reserved if version is less than 1
|
||||
MOZ_TRY(reader->ReadU8());
|
||||
mSinf.mDefaultCryptByteBlock = 0;
|
||||
mSinf.mDefaultSkipByteBlock = 0;
|
||||
}
|
||||
|
||||
uint8_t isEncrypted;
|
||||
MOZ_TRY_VAR(isEncrypted, reader->ReadU8());
|
||||
MOZ_TRY_VAR(mSinf.mDefaultIVSize, reader->ReadU8());
|
||||
memcpy(mSinf.mDefaultKeyID, reader->Read(16), 16);
|
||||
|
||||
if (isEncrypted && mSinf.mDefaultIVSize == 0) {
|
||||
uint8_t defaultConstantIVSize;
|
||||
MOZ_TRY_VAR(defaultConstantIVSize, reader->ReadU8());
|
||||
if (!mSinf.mDefaultConstantIV.SetLength(defaultConstantIVSize,
|
||||
mozilla::fallible)) {
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
for (uint8_t i = 0; i < defaultConstantIVSize; i++) {
|
||||
MOZ_TRY_VAR(mSinf.mDefaultConstantIV.ElementAt(i), reader->ReadU8());
|
||||
}
|
||||
}
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,16 +15,25 @@ class Box;
|
|||
|
||||
class Sinf : public Atom {
|
||||
public:
|
||||
Sinf() : mDefaultIVSize(0), mDefaultEncryptionType() {}
|
||||
Sinf()
|
||||
: mDefaultIVSize(0),
|
||||
mDefaultEncryptionType(),
|
||||
mDefaultCryptByteBlock(0),
|
||||
mDefaultSkipByteBlock(0) {}
|
||||
explicit Sinf(Box& aBox);
|
||||
|
||||
virtual bool IsValid() override {
|
||||
return !!mDefaultIVSize && !!mDefaultEncryptionType;
|
||||
bool IsValid() override {
|
||||
return !!mDefaultEncryptionType && // Should have an encryption scheme
|
||||
(mDefaultIVSize > 0 || // and either a default IV size
|
||||
mDefaultConstantIV.Length() > 0); // or a constant IV.
|
||||
}
|
||||
|
||||
uint8_t mDefaultIVSize;
|
||||
AtomType mDefaultEncryptionType;
|
||||
uint8_t mDefaultKeyID[16];
|
||||
uint8_t mDefaultCryptByteBlock;
|
||||
uint8_t mDefaultSkipByteBlock;
|
||||
nsTArray<uint8_t> mDefaultConstantIV;
|
||||
};
|
||||
|
||||
class SinfParser {
|
||||
|
|
Загрузка…
Ссылка в новой задаче