OpenXLSX 1.9.1
Loading...
Searching...
No Matches
XLCrypto.hpp
Go to the documentation of this file.
1#ifndef OPENXLSX_XLCRYPTO_HPP
2#define OPENXLSX_XLCRYPTO_HPP
3
4#pragma once
5
6#include <vector>
7#include <string>
8#include <cstdint>
9#include "OpenXLSX-Exports.hpp"
10#include "XLException.hpp"
11#include <gsl/span>
12
13namespace OpenXLSX {
14
20 OPENXLSX_EXPORT bool isEncryptedDocument(gsl::span<const uint8_t> data);
21
28 OPENXLSX_EXPORT std::vector<uint8_t> decryptDocument(gsl::span<const uint8_t> data, const std::string& password);
29
36 OPENXLSX_EXPORT std::vector<uint8_t> encryptDocument(gsl::span<const uint8_t> zipData, const std::string& password);
37
38 // Advanced Crypto routines for internal use
39 namespace Crypto {
40 std::vector<uint8_t> readCfbStream(gsl::span<const uint8_t> data, const std::string& streamName);
41 std::vector<uint8_t> decryptAgilePackage(gsl::span<const uint8_t> encryptionInfo,
42 gsl::span<const uint8_t> encryptedPackage,
43 const std::string& password);
44 std::vector<uint8_t> encryptStandardPackage(gsl::span<const uint8_t> zipData, const std::string& password);
45 std::vector<uint8_t> encryptAgilePackage(gsl::span<const uint8_t> zipData, const std::string& password);
46 std::vector<uint8_t> decryptStandardPackage(gsl::span<const uint8_t> encryptionInfo,
47 gsl::span<const uint8_t> encryptedPackage,
48 const std::string& password);
49
50 std::vector<uint8_t> aes256CbcDecrypt(gsl::span<const uint8_t> data, gsl::span<const uint8_t> key, gsl::span<const uint8_t> iv);
51 std::vector<uint8_t> sha512Hash(gsl::span<const uint8_t> data);
52 std::vector<uint8_t> generateAgileHash(const std::string& password, gsl::span<const uint8_t> salt, int spinCount);
53 }
54} // namespace OpenXLSX
55
56#endif // OPENXLSX_XLCRYPTO_HPP
std::vector< uint8_t > encryptStandardPackage(gsl::span< const uint8_t > zipData, const std::string &password)
Definition XLCrypto.cpp:267
std::vector< uint8_t > encryptAgilePackage(gsl::span< const uint8_t > zipData, const std::string &password)
Definition XLCrypto.cpp:551
std::vector< uint8_t > decryptStandardPackage(gsl::span< const uint8_t > encryptionInfo, gsl::span< const uint8_t > encryptedPackage, const std::string &password)
Definition XLCrypto.cpp:703
std::vector< uint8_t > generateAgileHash(const std::string &password, gsl::span< const uint8_t > salt, int spinCount)
Definition XLCrypto.cpp:389
std::vector< uint8_t > readCfbStream(gsl::span< const uint8_t > data, const std::string &streamName)
Definition XLCrypto.cpp:52
std::vector< uint8_t > sha512Hash(gsl::span< const uint8_t > data)
Definition XLCrypto.cpp:387
std::vector< uint8_t > decryptAgilePackage(gsl::span< const uint8_t > encryptionInfo, gsl::span< const uint8_t > encryptedPackage, const std::string &password)
Definition XLCrypto.cpp:417
std::vector< uint8_t > aes256CbcDecrypt(gsl::span< const uint8_t > data, gsl::span< const uint8_t > key, gsl::span< const uint8_t > iv)
Definition XLCrypto.cpp:386
Definition IZipArchive.hpp:18
OPENXLSX_EXPORT std::vector< uint8_t > decryptDocument(gsl::span< const uint8_t > data, const std::string &password)
High-level API to decrypt an entire document from a buffer.
Definition XLCrypto.cpp:34
OPENXLSX_EXPORT bool isEncryptedDocument(gsl::span< const uint8_t > data)
Checks if a given byte stream represents an OLE CFB document.
Definition XLCrypto.cpp:22
OPENXLSX_EXPORT std::vector< uint8_t > encryptDocument(gsl::span< const uint8_t > zipData, const std::string &password)
High-level API to encrypt a ZIP package into a CFB container.
Definition XLCrypto.cpp:28