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
e5f1bba2
Kaydet (Commit)
e5f1bba2
authored
Eki 07, 2015
tarafından
Markus Mohrhard
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add test for projkey generation
Change-Id: I42957abbdcf396830713d7ca4eb7539e6c110e11
üst
6970e2ba
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
15 deletions
+31
-15
vbaexport.hxx
include/oox/ole/vbaexport.hxx
+2
-0
vba_encryption.cxx
oox/qa/unit/vba_encryption.cxx
+10
-1
vbaexport.cxx
oox/source/ole/vbaexport.cxx
+19
-14
No files found.
include/oox/ole/vbaexport.hxx
Dosyayı görüntüle @
e5f1bba2
...
...
@@ -122,6 +122,8 @@ public:
void
write
();
static
sal_uInt8
calculateProjKey
(
const
OUString
&
rString
);
private
:
const
sal_uInt8
*
mpData
;
// an array of bytes to be obfuscated
const
sal_uInt16
mnLength
;
// the length of Data
...
...
oox/qa/unit/vba_encryption.cxx
Dosyayı görüntüle @
e5f1bba2
...
...
@@ -25,6 +25,8 @@ public:
void
testSimple2
();
void
testProjKey1
();
// avoid the BootstrapFixtureBase::setUp and tearDown
virtual
void
setUp
()
SAL_OVERRIDE
;
virtual
void
tearDown
()
SAL_OVERRIDE
;
...
...
@@ -32,6 +34,7 @@ public:
CPPUNIT_TEST_SUITE
(
TestVbaEncryption
);
// CPPUNIT_TEST(testSimple1);
// CPPUNIT_TEST(testSimple2);
CPPUNIT_TEST
(
testProjKey1
);
CPPUNIT_TEST_SUITE_END
();
private
:
...
...
@@ -48,7 +51,6 @@ void TestVbaEncryption::testSimple1()
VBAEncryption
aEncryption
(
pData
,
nLength
,
aEncryptedStream
,
&
nSeed
,
nProjKey
);
aEncryption
.
write
();
}
void
TestVbaEncryption
::
testSimple2
()
...
...
@@ -73,6 +75,13 @@ void TestVbaEncryption::testSimple2()
}
}
void
TestVbaEncryption
::
testProjKey1
()
{
OUString
aProjectID
(
"{917DED54-440B-4FD1-A5C1-74ACF261E600}"
);
sal_uInt8
nProjKey
=
VBAEncryption
::
calculateProjKey
(
aProjectID
);
CPPUNIT_ASSERT_EQUAL
((
int
)
0xdf
,
(
int
)
nProjKey
);
}
void
TestVbaEncryption
::
setUp
()
{
}
...
...
oox/source/ole/vbaexport.cxx
Dosyayı görüntüle @
e5f1bba2
...
...
@@ -384,19 +384,22 @@ void VBAEncryption::writeVersionEnc()
exportHexString
(
mrEncryptedData
,
mnVersionEnc
);
}
void
VBAEncryption
::
writeProjKeyEnc
(
)
sal_uInt8
VBAEncryption
::
calculateProjKey
(
const
OUString
&
rProjectKey
)
{
if
(
!
mnProjKey
)
sal_uInt8
nProjKey
=
0
;
sal_Int32
n
=
rProjectKey
.
getLength
();
const
sal_Unicode
*
pString
=
rProjectKey
.
getStr
();
for
(
sal_Int32
i
=
0
;
i
<
n
;
++
i
)
{
OUString
sProjectCLSID
=
"{9F10AB9C-89AC-4C0F-8AFB-8E9B96D5F170}"
;
//TODO:Find the real ProjectId.ProjectClSID
sal_Int32
n
=
sProjectCLSID
.
getLength
();
const
sal_Unicode
*
pString
=
sProjectCLSID
.
getStr
();
for
(
sal_Int32
i
=
0
;
i
<
n
;
++
i
)
{
sal_Unicode
character
=
pString
[
i
];
mnProjKey
+=
character
;
}
sal_Unicode
character
=
pString
[
i
];
nProjKey
+=
character
;
}
return
nProjKey
;
}
void
VBAEncryption
::
writeProjKeyEnc
()
{
sal_uInt8
nProjKeyEnc
=
mnSeed
^
mnProjKey
;
exportHexString
(
mrEncryptedData
,
nProjKeyEnc
);
mnUnencryptedByte1
=
mnProjKey
;
...
...
@@ -861,7 +864,8 @@ void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XN
// section 2.3.1.2 ProjectId
exportString
(
rStrm
,
"ID=
\"
"
);
exportString
(
rStrm
,
"{9F10AB9C-89AC-4C0F-8AFB-8E9B96D5F170}"
);
OUString
aProjectID
(
"{9F10AB9C-89AC-4C0F-8AFB-8E9B96D5F170}"
);
exportString
(
rStrm
,
aProjectID
);
exportString
(
rStrm
,
"
\"\r\n
"
);
// section 2.3.1.3 ProjectModule
...
...
@@ -894,7 +898,8 @@ 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
,
NULL
,
0
);
sal_uInt8
nProjKey
=
VBAEncryption
::
calculateProjKey
(
aProjectID
);
VBAEncryption
aProtectionState
(
pData
,
4
,
rStrm
,
NULL
,
nProjKey
);
aProtectionState
.
write
();
exportString
(
rStrm
,
"
\"\r\n
"
);
#else
...
...
@@ -907,7 +912,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
,
NULL
,
0
);
VBAEncryption
aProjectPassword
(
pData
,
1
,
rStrm
,
NULL
,
nProjKey
);
aProjectPassword
.
write
();
exportString
(
rStrm
,
"
\"\r\n
"
);
#else
...
...
@@ -920,7 +925,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
,
NULL
,
0
);
VBAEncryption
aVisibilityState
(
pData
,
1
,
rStrm
,
NULL
,
nProjKey
);
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