// 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. #ifdef UNSAFE_BUFFERS_BUILD // TODO(crbug.com/40285824): Remove this and convert code to safer constructs. #pragma allow_unsafe_buffers #endif #include "media/cdm/cenc_decryptor.h" #include <stdint.h> #include <memory> #include <string> #include <string_view> #include <vector> #include "base/containers/heap_array.h" #include "base/containers/span.h" #include "base/logging.h" #include "crypto/encryptor.h" #include "crypto/symmetric_key.h" #include "media/base/decoder_buffer.h" #include "media/base/decrypt_config.h" #include "media/base/subsample_entry.h" namespace media { namespace { enum ClearBytesBufferSel { … }; // Copy the cypher bytes as specified by |subsamples| from |src| to |dst|. // If |sel| == kSrcContainsClearBytes, then |src| is expected to contain any // clear bytes specified by |subsamples| and will be skipped. This is used // when copying all the protected data out of a sample. If |sel| == // kDstContainsClearBytes, then any clear bytes mentioned in |subsamples| // will be skipped in |dst|. This is used when copying the decrypted bytes // back into the buffer, replacing the encrypted portions. // // TODO(crbug.com/40284755): This function is not bounds-safe. Make this // span-based instead. void CopySubsamples(const std::vector<SubsampleEntry>& subsamples, const ClearBytesBufferSel sel, const uint8_t* src, uint8_t* dst) { … } // TODO(crbug.com/40575437): This should be done in DecoderBuffer so that // additional fields are more easily handled. void CopyExtraSettings(const DecoderBuffer& input, DecoderBuffer* output) { … } } // namespace scoped_refptr<DecoderBuffer> DecryptCencBuffer( const DecoderBuffer& input, const crypto::SymmetricKey& key) { … } } // namespace media