Skip to content

Commit

Permalink
use some placeholder data for agile key
Browse files Browse the repository at this point in the history
  • Loading branch information
tfussell committed Apr 20, 2017
1 parent b26d764 commit 4dedcd2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
6 changes: 3 additions & 3 deletions source/detail/cryptography/pole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,9 @@ void DirTree::debug()

// =========== StorageIO ==========

StorageIO::StorageIO(Storage *st, char *bytes, std::size_t length)
StorageIO::StorageIO(Storage *st, std::uint8_t *bytes, std::size_t length)
: storage(st),
filedata(reinterpret_cast<std::uint8_t *>(bytes)),
filedata(bytes),
dataLength(length),
result(Storage::Ok),
opened(false),
Expand Down Expand Up @@ -1064,7 +1064,7 @@ void StreamIO::updateCache()

// =========== Storage ==========

Storage::Storage(char *bytes, std::size_t length)
Storage::Storage(std::uint8_t *bytes, std::size_t length)
: io(new StorageIO(this, bytes, length))
{
}
Expand Down
4 changes: 2 additions & 2 deletions source/detail/cryptography/pole.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace POLE
/**
* Constructs a storage with name filename.
**/
Storage( char* bytes, std::size_t length );
Storage(std::uint8_t *bytes, std::size_t length);

/**
* Destroys the storage.
Expand Down Expand Up @@ -279,7 +279,7 @@ namespace POLE

std::list<Stream*> streams;

StorageIO( Storage* storage, char* bytes, std::size_t length );
StorageIO( Storage* storage, std::uint8_t *bytes, std::size_t length );
~StorageIO();

bool open();
Expand Down
3 changes: 1 addition & 2 deletions source/detail/cryptography/xlsx_crypto_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,7 @@ std::vector<std::uint8_t> decrypt_xlsx(
throw xlnt::exception("empty file");
}

std::vector<char> as_chars(bytes.begin(), bytes.end());
POLE::Storage storage(as_chars.data(), static_cast<unsigned long>(bytes.size()));
POLE::Storage storage(const_cast<std::uint8_t *>(bytes.data()), bytes.size());

if (!storage.open())
{
Expand Down
29 changes: 29 additions & 0 deletions source/detail/cryptography/xlsx_crypto_producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,35 @@ encryption_info generate_encryption_info(const std::u16string &password)
{
encryption_info result;

result.is_agile = true;

result.agile = encryption_info::agile_encryption_info{};

result.agile.key_data.block_size = 16;
result.agile.key_data.cipher_algorithm = "AES";
result.agile.key_data.cipher_chaining = "CBC";
result.agile.key_data.hash_algorithm = "SHA512";
result.agile.key_data.hash_size = 64;
result.agile.key_data.key_bits = 128;
result.agile.key_data.salt_size = 10;
result.agile.key_data.salt_value = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

result.agile.data_integrity.hmac_key = { 1, 2, 3 };
result.agile.data_integrity.hmac_value = { 3, 4, 5 };

result.agile.key_encryptor.spin_count = 100000;
result.agile.key_encryptor.block_size = 16;
result.agile.key_encryptor.cipher_algorithm = "AES";
result.agile.key_encryptor.cipher_chaining = "CBC";
result.agile.key_encryptor.hash = xlnt::detail::hash_algorithm::sha512;
result.agile.key_encryptor.hash_size = 64;
result.agile.key_encryptor.key_bits = 128;
result.agile.key_encryptor.salt_size = 10;
result.agile.key_encryptor.salt_value = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
result.agile.key_encryptor.verifier_hash_input = { 1, 2, 3 };
result.agile.key_encryptor.verifier_hash_value = { 1, 2, 3 };
result.agile.key_encryptor.encrypted_key_value = { 3, 4, 5 };

result.agile.key_data.salt_value.assign(
reinterpret_cast<const std::uint8_t *>(password.data()),
reinterpret_cast<const std::uint8_t *>(password.data() + password.size()));
Expand Down

0 comments on commit 4dedcd2

Please sign in to comment.