1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50

media / cdm / cenc_decryptor.h [blame]

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_CDM_CENC_DECRYPTOR_H_
#define MEDIA_CDM_CENC_DECRYPTOR_H_

#include "base/containers/span.h"
#include "base/memory/scoped_refptr.h"
#include "media/base/media_export.h"

namespace crypto {
class SymmetricKey;
}

namespace media {
class DecoderBuffer;

// This class implements 'cenc' AES-CTR scheme as specified by
// ISO/IEC 23001-7:2016, section 10.1 (https://www.iso.org). Decryption
// uses the Advanced Encryption Standard specified by AES [FIPS-197,
// https://www.nist.gov] using 128-bit keys in Counter Mode (AES-CTR-128),
// as specified in Block Cipher Modes [NIST 800-38A, https://www.nist.gov].
//
// Each input buffer is divided into one or more contiguous subsamples. Each
// subsample has an unprotected part (unencrypted) followed by a protected part
// (encrypted), only one of which may be zero bytes in length. For example:
//   |                DecoderBuffer.data()              |
//   |  Subsample#1   |   Subsample#2   |  Subsample#3  |
//   |uuuuu|eeeeeeeeee|uuuu|eeeeeeeeeeee|uu|eeeeeeeeeeee|
// Subsample encryption encrypts all the bytes in the protected part of the
// sample. The protected byte sequences of all subsamples is treated as a
// logically continuous chain of 16 byte cipher blocks, even when they are
// separated by unprotected data.
//
// If no subsamples are specified, the whole input buffer will be treated as
// protected data.

// Decrypts the encrypted buffer |input| using |key| and values found in
// |input|->DecryptConfig. The key size must be 128 bits.
MEDIA_EXPORT scoped_refptr<DecoderBuffer> DecryptCencBuffer(
    const DecoderBuffer& input,
    const crypto::SymmetricKey& key);
MEDIA_EXPORT scoped_refptr<DecoderBuffer> DecryptCencBuffer(
    const DecoderBuffer& input,
    base::span<const uint8_t> key);

}  // namespace media

#endif  // MEDIA_CDM_CENC_DECRYPTOR_H_