Source release v3.5.0
This commit is contained in:
File diff suppressed because it is too large
Load Diff
29
oemcrypto/include/level3_file_system.h
Normal file
29
oemcrypto/include/level3_file_system.h
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved
|
||||
|
||||
/*********************************************************************
|
||||
* level3_file_system.h
|
||||
*
|
||||
* File system for OEMCrypto Level3 file operations.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef LEVEL3_FILE_SYSTEM_H_
|
||||
#define LEVEL3_FILE_SYSTEM_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace wvoec3 {
|
||||
|
||||
class OEMCrypto_Level3FileSystem {
|
||||
public:
|
||||
virtual ~OEMCrypto_Level3FileSystem() {}
|
||||
virtual ssize_t Read(const char *filename, void *buffer, size_t size) = 0;
|
||||
virtual ssize_t Write(const char *filename, const void *buffer,
|
||||
size_t size) = 0;
|
||||
virtual bool Exists(const char *filename) = 0;
|
||||
virtual ssize_t FileSize(const char *filename) = 0;
|
||||
virtual bool Remove(const char *filename) = 0;
|
||||
};
|
||||
|
||||
} // namespace wvoec3
|
||||
|
||||
#endif
|
||||
22
oemcrypto/include/level3_file_system_factory.h
Normal file
22
oemcrypto/include/level3_file_system_factory.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved
|
||||
|
||||
/*********************************************************************
|
||||
* level3_file_system_factory.h
|
||||
*
|
||||
* Creates a single OEMCrypto_Level3FileSystem.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef LEVEL3_FILE_SYSTEM_FACTORY_H_
|
||||
#define LEVEL3_FILE_SYSTEM_FACTORY_H_
|
||||
|
||||
#include "level3_file_system.h"
|
||||
|
||||
namespace wvoec3 {
|
||||
|
||||
OEMCrypto_Level3FileSystem* createLevel3FileSystem();
|
||||
|
||||
void deleteLevel3FileSystem(OEMCrypto_Level3FileSystem* file_system);
|
||||
|
||||
}
|
||||
|
||||
#endif // LEVEL3_FILE_SYSTEM_FACTORY_H_
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "log.h"
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "log.h"
|
||||
|
||||
namespace wvoec_mock {
|
||||
|
||||
@@ -20,13 +20,14 @@ namespace wvoec_mock {
|
||||
// LogCategoryEnabled(category1 | category2) will return true if
|
||||
// category1 and/or category2 are set to logging.
|
||||
|
||||
const int kLoggingTraceOEMCryptoCalls = 0x01;
|
||||
const int kLoggingTraceOEMCryptoCalls = 0x01; // All except decrypt calls.
|
||||
const int kLoggingDumpContentKeys = 0x02;
|
||||
const int kLoggingDumpKeyControlBlocks = 0x04;
|
||||
const int kLoggingDumpDerivedKeys = 0x08;
|
||||
const int kLoggingTraceNonce = 0x10;
|
||||
const int kLoggingTraceDecryption = 0x20;
|
||||
const int kLoggingTraceUsageTable = 0x40;
|
||||
const int kLoggingTraceDecryptCalls = 0x80;
|
||||
const int kLoggingDumpTraceAll = 0xFF;
|
||||
|
||||
void SetLoggingSettings(int level, int categories);
|
||||
@@ -56,10 +57,9 @@ void dump_array_part_helper(std::string& buffer, std::string array,
|
||||
size_t index, std::string name,
|
||||
const uint8_t* vector, size_t length);
|
||||
|
||||
void dump_array_part(std::string array, size_t index,
|
||||
std::string name, const uint8_t* vector, size_t length);
|
||||
void dump_array_part(std::string array, size_t index, std::string name,
|
||||
const uint8_t* vector, size_t length);
|
||||
|
||||
} // namespace wvoec_mock
|
||||
|
||||
#endif
|
||||
|
||||
#endif // WVOEC_OEMCRYPTO_LOGGING_H_
|
||||
|
||||
146
oemcrypto/include/pst_report.h
Normal file
146
oemcrypto/include/pst_report.h
Normal file
@@ -0,0 +1,146 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
|
||||
/*********************************************************************
|
||||
* pst_report.h
|
||||
*
|
||||
* Reference APIs needed to support Widevine's crypto algorithms.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef PST_REPORT_H_
|
||||
#define PST_REPORT_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "string_conversions.h" // needed for htonll64.
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class Unpacked_PST_Report {
|
||||
public:
|
||||
// This object does not own the buffer, and does not check that buffer
|
||||
// is not null.
|
||||
Unpacked_PST_Report(uint8_t *buffer) : buffer_(buffer) {}
|
||||
|
||||
// Copy and move semantics of this class is like that of a pointer.
|
||||
Unpacked_PST_Report(const Unpacked_PST_Report& other) :
|
||||
buffer_(other.buffer_) {}
|
||||
|
||||
Unpacked_PST_Report& operator=(const Unpacked_PST_Report& other) {
|
||||
buffer_ = other.buffer_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
size_t report_size() const {
|
||||
return pst_length() + kraw_pst_report_size;
|
||||
}
|
||||
|
||||
static size_t report_size(size_t pst_length) {
|
||||
return pst_length + kraw_pst_report_size;
|
||||
}
|
||||
|
||||
uint8_t status() const {
|
||||
return static_cast<uint8_t>(* (buffer_ + kstatus_offset));
|
||||
}
|
||||
|
||||
void set_status(uint8_t value) {
|
||||
buffer_[kstatus_offset] = value;
|
||||
}
|
||||
|
||||
uint8_t* signature() {
|
||||
return buffer_ + ksignature_offset;
|
||||
}
|
||||
|
||||
uint8_t clock_security_level() const {
|
||||
return static_cast<uint8_t>(* (buffer_ + kclock_security_level_offset));
|
||||
}
|
||||
|
||||
void set_clock_security_level(uint8_t value) {
|
||||
buffer_[kclock_security_level_offset] = value;
|
||||
}
|
||||
|
||||
uint8_t pst_length() const {
|
||||
return static_cast<uint8_t>(* (buffer_ + kpst_length_offset));
|
||||
}
|
||||
|
||||
void set_pst_length(uint8_t value) {
|
||||
buffer_[kpst_length_offset] = value;
|
||||
}
|
||||
|
||||
uint8_t padding() const {
|
||||
return static_cast<uint8_t>(* (buffer_ + kpadding_offset));
|
||||
}
|
||||
|
||||
void set_padding(uint8_t value) {
|
||||
buffer_[kpadding_offset] = value;
|
||||
}
|
||||
|
||||
// In host byte order.
|
||||
int64_t seconds_since_license_received() const {
|
||||
int64_t time;
|
||||
memcpy(&time, buffer_ + kseconds_since_license_received_offset,
|
||||
sizeof(int64_t));
|
||||
return wvcdm::ntohll64(time);
|
||||
}
|
||||
|
||||
// Parameter time is in host byte order.
|
||||
void set_seconds_since_license_received(int64_t time) const {
|
||||
time = wvcdm::ntohll64(time);
|
||||
memcpy(buffer_ + kseconds_since_license_received_offset, &time,
|
||||
sizeof(int64_t));
|
||||
}
|
||||
|
||||
// In host byte order.
|
||||
int64_t seconds_since_first_decrypt() const {
|
||||
int64_t time;
|
||||
memcpy(&time, buffer_ + kseconds_since_first_decrypt_offset,
|
||||
sizeof(int64_t));
|
||||
return wvcdm::ntohll64(time);
|
||||
}
|
||||
|
||||
// Parameter time is in host byte order.
|
||||
void set_seconds_since_first_decrypt(int64_t time) const {
|
||||
time = wvcdm::ntohll64(time);
|
||||
memcpy(buffer_ + kseconds_since_first_decrypt_offset, &time,
|
||||
sizeof(int64_t));
|
||||
}
|
||||
|
||||
// In host byte order.
|
||||
int64_t seconds_since_last_decrypt() const {
|
||||
int64_t time;
|
||||
memcpy(&time, buffer_ + kseconds_since_last_decrypt_offset,
|
||||
sizeof(int64_t));
|
||||
return wvcdm::ntohll64(time);
|
||||
}
|
||||
|
||||
// Parameter time is in host byte order.
|
||||
void set_seconds_since_last_decrypt(int64_t time) const {
|
||||
time = wvcdm::ntohll64(time);
|
||||
memcpy(buffer_ + kseconds_since_last_decrypt_offset, &time,
|
||||
sizeof(int64_t));
|
||||
}
|
||||
|
||||
uint8_t* pst() {
|
||||
return (buffer_ + kpst_offset);
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t *buffer_;
|
||||
|
||||
// Size of the PST_Report without the pst string.
|
||||
static const size_t kraw_pst_report_size = 48;
|
||||
static const size_t ksignature_offset = 0;
|
||||
static const size_t kstatus_offset = 20;
|
||||
static const size_t kclock_security_level_offset = 21;
|
||||
static const size_t kpst_length_offset = 22;
|
||||
static const size_t kpadding_offset = 23;
|
||||
static const size_t kseconds_since_license_received_offset = 24;
|
||||
static const size_t kseconds_since_first_decrypt_offset = 32;
|
||||
static const size_t kseconds_since_last_decrypt_offset = 40;
|
||||
static const size_t kpst_offset = 48;
|
||||
};
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // PST_REPORT_H_
|
||||
Reference in New Issue
Block a user