16#include <com/sun/star/io/SequenceInputStream.hpp>
17#include <com/sun/star/io/XSequenceOutputStream.hpp>
23using namespace css::beans;
24using namespace css::io;
25using namespace css::lang;
26using namespace css::uno;
53 Reference<XOutputStream>& rxOutputStream)
63 rxOutputStream->flush();
68 std::u16string_view sStreamName)
70 for (
const auto& aStream : rStreams)
72 if (aStream.Name == sStreamName)
74 Sequence<sal_Int8>
aSeq;
75 aStream.Value >>=
aSeq;
76 Reference<XInputStream> aStream2(
77 io::SequenceInputStream::createStreamFromSequence(
mxContext,
aSeq),
87 Reference<XInputStream> xEncryptionInfo =
getStream(aStreams,
u"EncryptionInfo");
88 if (!xEncryptionInfo.is())
92 sal_uInt32 aVersion = aBinaryInputStream.
readuInt32();
119 for (
const auto& aParam : rMediaEncData)
121 if (aParam.Name ==
"OOXPassword")
123 aParam.Value >>= sPassword;
133 aEncryptionData[
"OOXPassword"] <<= rPassword;
134 aEncryptionData[
"CryptoType"] <<= OUString(
"StrongEncryptionDataSpace");
143 return Sequence<NamedValue>();
145 Reference<XSeekable> xSeekable(rxInputStream, UNO_QUERY);
147 return Sequence<NamedValue>();
149 sal_uInt32 aLength = xSeekable->getLength();
151 Reference<XOutputStream> xOutputStream(
152 mxContext->getServiceManager()->createInstanceWithContext(
153 "com.sun.star.io.SequenceOutputStream",
mxContext),
156 mCryptoEngine->encrypt(rxInputStream, xOutputStream, aLength);
160 Reference<XSequenceOutputStream> xEncodedFileSequenceStream(xOutputStream, UNO_QUERY);
161 aStreams[
"EncryptedPackage"] <<= xEncodedFileSequenceStream->getWrittenBytes();
163 Reference<XOutputStream> aEncryptionInfoStream(
164 mxContext->getServiceManager()->createInstanceWithContext(
165 "com.sun.star.io.SequenceOutputStream",
mxContext),
169 aEncryptionInfoStream->flush();
170 Reference<XSequenceOutputStream> aEncryptionInfoSequenceStream(aEncryptionInfoStream,
173 aStreams[
"EncryptionInfo"] <<= aEncryptionInfoSequenceStream->getWrittenBytes();
180 return "com.sun.star.comp.oox.crypto.StrongEncryptionDataSpace";
190 Sequence<OUString> aServices{
"com.sun.star.packages.PackageEncryption" };
196extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
198 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_oox_crypto_StrongEncryptionDataSpace_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
css::uno::Sequence< css::beans::NamedValue > getAsConstNamedValueList() const
Wraps a UNO output stream and provides convenient access functions.
virtual css::uno::Sequence< css::beans::NamedValue > SAL_CALL encrypt(const css::uno::Reference< css::io::XInputStream > &rxInputStream) override
virtual sal_Bool SAL_CALL readEncryptionInfo(const css::uno::Sequence< css::beans::NamedValue > &aStreams) override
virtual sal_Bool SAL_CALL setupEncryption(const css::uno::Sequence< css::beans::NamedValue > &rMediaEncData) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL decrypt(const css::uno::Reference< css::io::XInputStream > &rxInputStream, css::uno::Reference< css::io::XOutputStream > &rxOutputStream) override
std::unique_ptr< CryptoEngine > mCryptoEngine
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual css::uno::Sequence< css::beans::NamedValue > SAL_CALL createEncryptionData(const OUString &rPassword) override
virtual sal_Bool SAL_CALL generateEncryptionKey(const OUString &rPassword) override
css::uno::Reference< css::io::XInputStream > getStream(const css::uno::Sequence< css::beans::NamedValue > &rStreams, std::u16string_view sStreamName)
virtual OUString SAL_CALL getImplementationName() override
StrongEncryptionDataSpace(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
virtual sal_Bool SAL_CALL checkDataIntegrity() override
Sequence< sal_Int8 > aSeq
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
const sal_uInt32 VERSION_INFO_2007_FORMAT
const sal_uInt32 VERSION_INFO_2007_FORMAT_SP2
const sal_uInt32 VERSION_INFO_AGILE