Export media_cas_packager_sdk
This commit is contained in:
59
common/ecb_util.h
Normal file
59
common/ecb_util.h
Normal file
@@ -0,0 +1,59 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2016 Google LLC.
|
||||
//
|
||||
// This software is licensed under the terms defined in the Widevine Master
|
||||
// License Agreement. For a copy of this agreement, please contact
|
||||
// widevine-licensing@google.com.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Contains ecb crypto routines for widevine protocols. These routines are used
|
||||
// as part of licensing and provisioning request handling.
|
||||
|
||||
#ifndef COMMON_ECB_UTIL_H_
|
||||
#define COMMON_ECB_UTIL_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
namespace widevine {
|
||||
namespace crypto_util {
|
||||
|
||||
// Encrypts |src| into |dst| using 3DES ECB2 mode with the given key. This is
|
||||
// used for protecting content keys on some older Widevine keyboxes, and is not
|
||||
// intended for any other purpose. Returns false and sets *|dst|="" if
|
||||
// unsuccessful. Key should be 16 bytes. The first 8 are key2 of the 3DES key
|
||||
// bundle, and the last 8 bytes are key1 and key3. |src| must be a multiple of
|
||||
// 8 bytes.
|
||||
bool Encrypt3DesEcb(absl::string_view key, absl::string_view src, std::string* dst);
|
||||
|
||||
// Decrypts |src| into |dst| using 3DES ECB2 mode with the given (16-byte)
|
||||
// key. This is used for protecting content keys on some older Widevine
|
||||
// keyboxes, and is not intended for any other purpose.
|
||||
// Returns false and sets *|dst|="" if unsuccessful. Note that it can only
|
||||
// fail if invalid key or data sizes are passed in.
|
||||
// Key should be 16 bytes. The first 8 are key2 of the 3DES key bundle,
|
||||
// and the last 8 bytes are key1 and key3. |src| must be a multiple of
|
||||
// 8 bytes.
|
||||
bool Decrypt3DesEcb(absl::string_view key, absl::string_view src, std::string* dst);
|
||||
|
||||
// Encrypts |src| into |dst| using AES ECB mode with the given
|
||||
// key. This is used for protecting content keys on Widevine devices,
|
||||
// and is not intended for any other purpose.
|
||||
// Returns false and sets *|dst|="" if unsuccessful. Note that it can only
|
||||
// fail if invalid key or data sizes are passed in.
|
||||
// Key must be 16 bytes, and src must be a multiple of 16 bytes.
|
||||
bool EncryptAesEcb(absl::string_view key, absl::string_view src, std::string* dst);
|
||||
|
||||
// Decrypts |src| into |dst| using AES ECB mode with the given
|
||||
// key. This is used for protecting content keys on Widevine devices,
|
||||
// and is not intended for any other purpose.
|
||||
// Returns false and sets *|dst|="" if unsuccessful. Note that it can only
|
||||
// fail if invalid key or data sizes are passed in.
|
||||
// Key must be 16 bytes, and src must be a multiple of 16 bytes.
|
||||
bool DecryptAesEcb(absl::string_view key, absl::string_view src, std::string* dst);
|
||||
|
||||
} // namespace crypto_util
|
||||
} // namespace widevine
|
||||
|
||||
#endif // COMMON_ECB_UTIL_H_
|
||||
Reference in New Issue
Block a user