Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
3ba169bd
Kaydet (Commit)
3ba169bd
authored
Eki 06, 2015
tarafından
Markus Mohrhard
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add initial tests for vba encryption
Change-Id: Ic6128ecade39e8947863c9162523e0d9690f0026
üst
c5975818
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
154 additions
and
11 deletions
+154
-11
vbaexport.hxx
include/oox/ole/vbaexport.hxx
+4
-3
CppunitTest_oox_vba_encryption.mk
oox/CppunitTest_oox_vba_encryption.mk
+50
-0
Module_oox.mk
oox/Module_oox.mk
+1
-0
vba_encryption.cxx
oox/qa/unit/vba_encryption.cxx
+88
-0
vbaexport.cxx
oox/source/ole/vbaexport.cxx
+11
-8
No files found.
include/oox/ole/vbaexport.hxx
Dosyayı görüntüle @
3ba169bd
...
...
@@ -111,13 +111,14 @@ private:
SvMemoryStream
&
mrUncompressedStream
;
};
class
VBAEncryption
class
OOX_DLLPUBLIC
VBAEncryption
{
public
:
VBAEncryption
(
const
sal_uInt8
*
pData
,
const
sal_uInt16
nLength
,
SvStream
&
rEncryptedData
);
SvStream
&
rEncryptedData
,
sal_uInt8
*
pSeed
,
sal_uInt8
nProjKey
);
void
write
();
...
...
oox/CppunitTest_oox_vba_encryption.mk
0 → 100644
Dosyayı görüntüle @
3ba169bd
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_CppunitTest_CppunitTest,oox_vba_encryption))
$(eval $(call gb_CppunitTest_add_exception_objects,oox_vba_encryption,\
oox/qa/unit/vba_encryption \
))
$(eval $(call gb_CppunitTest_use_api,oox_vba_encryption,\
offapi \
udkapi \
))
$(eval $(call gb_CppunitTest_use_libraries,oox_vba_encryption,\
basegfx \
comphelper \
cppu \
cppuhelper \
editeng \
expwrap \
drawinglayer \
msfilter \
sal \
i18nlangtag \
oox \
sax \
sfx \
svl \
svt \
svx \
svxcore \
sot \
tl \
unotest \
utl \
vcl \
xo \
xmlscript \
$(gb_UWINAPI) \
))
# vim: set noet sw=4 ts=4:
oox/Module_oox.mk
Dosyayı görüntüle @
3ba169bd
...
...
@@ -19,6 +19,7 @@ $(eval $(call gb_Module_add_targets,oox,\
$(eval $(call gb_Module_add_check_targets,oox,\
CppunitTest_oox_tokenmap \
CppunitTest_oox_vba_compression \
CppunitTest_oox_vba_encryption \
))
# vim: set noet sw=4 ts=4:
oox/qa/unit/vba_encryption.cxx
0 → 100644
Dosyayı görüntüle @
3ba169bd
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <unotest/bootstrapfixturebase.hxx>
#include <cppunit/plugin/TestPlugIn.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestFixture.h>
#include <oox/ole/vbaexport.hxx>
#include <algorithm>
class
TestVbaEncryption
:
public
test
::
BootstrapFixtureBase
{
public
:
// an initial test for the encryption taken from the spec
void
testSimple1
();
void
testSimple2
();
// avoid the BootstrapFixtureBase::setUp and tearDown
virtual
void
setUp
()
SAL_OVERRIDE
;
virtual
void
tearDown
()
SAL_OVERRIDE
;
CPPUNIT_TEST_SUITE
(
TestVbaEncryption
);
// CPPUNIT_TEST(testSimple1);
// CPPUNIT_TEST(testSimple2);
CPPUNIT_TEST_SUITE_END
();
private
:
};
void
TestVbaEncryption
::
testSimple1
()
{
sal_uInt8
nSeed
=
0x07
;
sal_uInt8
nProjKey
=
0xDF
;
sal_uInt16
nLength
=
0x04
;
sal_uInt8
pData
[]
=
{
0x00
,
0x00
,
0x00
,
0x00
};
SvMemoryStream
aEncryptedStream
(
4096
,
4096
);
VBAEncryption
aEncryption
(
pData
,
nLength
,
aEncryptedStream
,
&
nSeed
,
nProjKey
);
aEncryption
.
write
();
}
void
TestVbaEncryption
::
testSimple2
()
{
sal_uInt8
nSeed
=
0x15
;
sal_uInt8
nProjKey
=
0xDF
;
sal_uInt16
nLength
=
0x01
;
sal_uInt8
pData
[]
=
{
0xFF
};
SvMemoryStream
aEncryptedStream
(
4096
,
4096
);
VBAEncryption
aEncryption
(
pData
,
nLength
,
aEncryptedStream
,
&
nSeed
,
nProjKey
);
aEncryption
.
write
();
sal_uInt8
pExpectedData
[]
=
"1517CAF1D6F9D7F9D706"
;
size_t
length
=
sizeof
(
pExpectedData
);
aEncryptedStream
.
Seek
(
0
);
for
(
size_t
i
=
0
;
i
<
length
;
++
i
)
{
unsigned
char
val
=
0
;
aEncryptedStream
.
ReadUChar
(
val
);
CPPUNIT_ASSERT_EQUAL
((
int
)
pExpectedData
[
i
],
(
int
)
sal_uInt8
(
val
));
}
}
void
TestVbaEncryption
::
setUp
()
{
}
void
TestVbaEncryption
::
tearDown
()
{
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
TestVbaEncryption
);
CPPUNIT_PLUGIN_IMPLEMENT
();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
oox/source/ole/vbaexport.cxx
Dosyayı görüntüle @
3ba169bd
...
...
@@ -47,10 +47,10 @@
#define VBA_USE_ORIGINAL_PROJECT_STREAM 0
#define VBA_USE_ORIGINAL_VBA_PROJECT 0
#define VBA_ENCRYPTION 0
/* Enable to see VBA Encryption work. For now the input data and length values
* for encryption correspond to the case when the VBA macro is not protected.
*/
#define VBA_ENCRYPTION 1
namespace
{
...
...
@@ -344,23 +344,24 @@ void VBACompression::write()
// section 2.4.3
#if VBA_ENCRYPTION
VBAEncryption
::
VBAEncryption
(
const
sal_uInt8
*
pData
,
const
sal_uInt16
length
,
SvStream
&
rEncryptedData
)
VBAEncryption
::
VBAEncryption
(
const
sal_uInt8
*
pData
,
const
sal_uInt16
length
,
SvStream
&
rEncryptedData
,
sal_uInt8
*
pSeed
,
sal_uInt8
nProjKey
)
:
mpData
(
pData
)
,
mnLength
(
length
)
,
mrEncryptedData
(
rEncryptedData
)
,
mnEncryptedByte1
(
0
)
,
mnEncryptedByte2
(
0
)
,
mnVersion
(
2
)
,
mnProjKey
(
0
)
,
mnProjKey
(
nProjKey
)
,
mnIgnoredLength
(
0
)
,
mnSeed
(
0
)
,
mnSeed
(
pSeed
?
*
pSeed
:
0x0
0
)
,
mnVersionEnc
(
0
)
{
if
(
!
pSeed
)
mnSeed
=
0xBE
;
// sample seed value TODO:Generate random seed values
}
void
VBAEncryption
::
writeSeed
()
{
mnSeed
=
0xBE
;
// sample seed value TODO:Generate random seed values
mrEncryptedData
.
WriteUInt8
(
mnSeed
);
}
...
...
@@ -372,6 +373,7 @@ void VBAEncryption::writeVersionEnc()
void
VBAEncryption
::
writeProjKeyEnc
()
{
/*
OUString mrProjectCLSID = "{9F10AB9C-89AC-4C0F-8AFB-8E9B96D5F170}"; //TODO:Find the real ProjectId.ProjectClSID
sal_Int32 n = mrProjectCLSID.getLength();
const sal_Unicode* pString = mrProjectCLSID.getStr();
...
...
@@ -380,6 +382,7 @@ void VBAEncryption::writeProjKeyEnc()
sal_Unicode character = pString[i];
mnProjKey += character;
}
*/
sal_uInt8
nProjKeyEnc
=
mnSeed
^
mnProjKey
;
mrEncryptedData
.
WriteUInt8
(
nProjKeyEnc
);
mnUnencryptedByte1
=
mnProjKey
;
...
...
@@ -877,7 +880,7 @@ void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XN
SvMemoryStream
aProtectedStream
(
4096
,
4096
);
aProtectedStream
.
WriteUInt32
(
0x00000000
);
const
sal_uInt8
*
pData
=
static_cast
<
const
sal_uInt8
*>
(
aProtectedStream
.
GetData
());
VBAEncryption
aProtectionState
(
pData
,
4
,
rStrm
);
VBAEncryption
aProtectionState
(
pData
,
4
,
rStrm
,
NULL
,
0
);
aProtectionState
.
write
();
exportString
(
rStrm
,
"
\"\r\n
"
);
#else
...
...
@@ -890,7 +893,7 @@ void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XN
aProtectedStream
.
Seek
(
0
);
aProtectedStream
.
WriteUInt8
(
0x00
);
pData
=
static_cast
<
const
sal_uInt8
*>
(
aProtectedStream
.
GetData
());
VBAEncryption
aProjectPassword
(
pData
,
1
,
rStrm
);
VBAEncryption
aProjectPassword
(
pData
,
1
,
rStrm
,
NULL
,
0
);
aProjectPassword
.
write
();
exportString
(
rStrm
,
"
\"\r\n
"
);
#else
...
...
@@ -903,7 +906,7 @@ void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XN
aProtectedStream
.
Seek
(
0
);
aProtectedStream
.
WriteUInt8
(
0xFF
);
pData
=
static_cast
<
const
sal_uInt8
*>
(
aProtectedStream
.
GetData
());
VBAEncryption
aVisibilityState
(
pData
,
1
,
rStrm
);
VBAEncryption
aVisibilityState
(
pData
,
1
,
rStrm
,
NULL
,
0
);
aVisibilityState
.
write
();
exportString
(
rStrm
,
"
\"\r\n\r\n
"
);
#else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment