ooxml_crypt 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/ext/ooxml_crypt/extconf.rb +18 -0
- data/ext/ooxml_crypt/ooxml_crypt.c +27 -0
- data/ext/ooxml_crypt/ooxml_crypt.h +7 -0
- data/lib/ooxml_crypt/version.rb +5 -0
- data/lib/ooxml_crypt.rb +75 -0
- data/vendor/cybozulib/.github/workflows/main.yml +12 -0
- data/vendor/cybozulib/.gitignore +5 -0
- data/vendor/cybozulib/CMakeLists.txt +6 -0
- data/vendor/cybozulib/COPYRIGHT +27 -0
- data/vendor/cybozulib/Makefile +26 -0
- data/vendor/cybozulib/bin/libeay32.dll +0 -0
- data/vendor/cybozulib/bin/libmecab.dll +0 -0
- data/vendor/cybozulib/bin/ssleay32.dll +0 -0
- data/vendor/cybozulib/common.mk +116 -0
- data/vendor/cybozulib/common.props +25 -0
- data/vendor/cybozulib/cybozulib.sln +286 -0
- data/vendor/cybozulib/debug.props +14 -0
- data/vendor/cybozulib/include/cybozu/array.hpp +197 -0
- data/vendor/cybozulib/include/cybozu/atoi.hpp +238 -0
- data/vendor/cybozulib/include/cybozu/atomic.hpp +146 -0
- data/vendor/cybozulib/include/cybozu/base64.hpp +210 -0
- data/vendor/cybozulib/include/cybozu/benchmark.hpp +212 -0
- data/vendor/cybozulib/include/cybozu/bfd.hpp +105 -0
- data/vendor/cybozulib/include/cybozu/bit_operation.hpp +139 -0
- data/vendor/cybozulib/include/cybozu/bitvector.hpp +358 -0
- data/vendor/cybozulib/include/cybozu/condition_variable.hpp +113 -0
- data/vendor/cybozulib/include/cybozu/condition_variable_cs.hpp +74 -0
- data/vendor/cybozulib/include/cybozu/config.hpp +392 -0
- data/vendor/cybozulib/include/cybozu/critical_section.hpp +60 -0
- data/vendor/cybozulib/include/cybozu/crypto.hpp +321 -0
- data/vendor/cybozulib/include/cybozu/csucvector.hpp +624 -0
- data/vendor/cybozulib/include/cybozu/csv.hpp +294 -0
- data/vendor/cybozulib/include/cybozu/data_type.hpp +27 -0
- data/vendor/cybozulib/include/cybozu/endian.hpp +224 -0
- data/vendor/cybozulib/include/cybozu/env.hpp +63 -0
- data/vendor/cybozulib/include/cybozu/event.hpp +122 -0
- data/vendor/cybozulib/include/cybozu/exception.hpp +253 -0
- data/vendor/cybozulib/include/cybozu/file.hpp +626 -0
- data/vendor/cybozulib/include/cybozu/fmindex.hpp +291 -0
- data/vendor/cybozulib/include/cybozu/format.hpp +93 -0
- data/vendor/cybozulib/include/cybozu/frequency.hpp +264 -0
- data/vendor/cybozulib/include/cybozu/hash.hpp +67 -0
- data/vendor/cybozulib/include/cybozu/inttype.hpp +174 -0
- data/vendor/cybozulib/include/cybozu/itoa.hpp +336 -0
- data/vendor/cybozulib/include/cybozu/json.hpp +120 -0
- data/vendor/cybozulib/include/cybozu/line_stream.hpp +149 -0
- data/vendor/cybozulib/include/cybozu/link_libeay32.hpp +21 -0
- data/vendor/cybozulib/include/cybozu/link_mpir.hpp +18 -0
- data/vendor/cybozulib/include/cybozu/link_ssleay32.hpp +19 -0
- data/vendor/cybozulib/include/cybozu/log.hpp +237 -0
- data/vendor/cybozulib/include/cybozu/minixml.hpp +452 -0
- data/vendor/cybozulib/include/cybozu/mmap.hpp +143 -0
- data/vendor/cybozulib/include/cybozu/mutex.hpp +144 -0
- data/vendor/cybozulib/include/cybozu/nlp/mecab.hpp +96 -0
- data/vendor/cybozulib/include/cybozu/nlp/plsi.hpp +315 -0
- data/vendor/cybozulib/include/cybozu/nlp/random.hpp +74 -0
- data/vendor/cybozulib/include/cybozu/nlp/sparse.hpp +529 -0
- data/vendor/cybozulib/include/cybozu/nlp/svd.hpp +486 -0
- data/vendor/cybozulib/include/cybozu/nlp/tfidf.hpp +226 -0
- data/vendor/cybozulib/include/cybozu/nlp/top_score.hpp +75 -0
- data/vendor/cybozulib/include/cybozu/option.hpp +743 -0
- data/vendor/cybozulib/include/cybozu/parallel.hpp +88 -0
- data/vendor/cybozulib/include/cybozu/pcg.hpp +72 -0
- data/vendor/cybozulib/include/cybozu/process.hpp +324 -0
- data/vendor/cybozulib/include/cybozu/quit_signal_handler.hpp +66 -0
- data/vendor/cybozulib/include/cybozu/random_generator.hpp +144 -0
- data/vendor/cybozulib/include/cybozu/regex.hpp +463 -0
- data/vendor/cybozulib/include/cybozu/select8.hpp +279 -0
- data/vendor/cybozulib/include/cybozu/serializer.hpp +363 -0
- data/vendor/cybozulib/include/cybozu/sha1.hpp +209 -0
- data/vendor/cybozulib/include/cybozu/sha2.hpp +506 -0
- data/vendor/cybozulib/include/cybozu/siphash.hpp +105 -0
- data/vendor/cybozulib/include/cybozu/socket.hpp +785 -0
- data/vendor/cybozulib/include/cybozu/ssl.hpp +203 -0
- data/vendor/cybozulib/include/cybozu/stacktrace.hpp +291 -0
- data/vendor/cybozulib/include/cybozu/stream.hpp +269 -0
- data/vendor/cybozulib/include/cybozu/string.hpp +1746 -0
- data/vendor/cybozulib/include/cybozu/string_operation.hpp +365 -0
- data/vendor/cybozulib/include/cybozu/sucvector.hpp +378 -0
- data/vendor/cybozulib/include/cybozu/test.hpp +373 -0
- data/vendor/cybozulib/include/cybozu/thread.hpp +229 -0
- data/vendor/cybozulib/include/cybozu/time.hpp +281 -0
- data/vendor/cybozulib/include/cybozu/tls.hpp +115 -0
- data/vendor/cybozulib/include/cybozu/unordered_map.hpp +13 -0
- data/vendor/cybozulib/include/cybozu/unordered_set.hpp +13 -0
- data/vendor/cybozulib/include/cybozu/v128.hpp +376 -0
- data/vendor/cybozulib/include/cybozu/wavelet_matrix.hpp +345 -0
- data/vendor/cybozulib/include/cybozu/xorshift.hpp +189 -0
- data/vendor/cybozulib/include/cybozu/zlib.hpp +325 -0
- data/vendor/cybozulib/include/sais.hxx +364 -0
- data/vendor/cybozulib/misc/make_select8tbl.cpp +26 -0
- data/vendor/cybozulib/mk.bat +37 -0
- data/vendor/cybozulib/readme.md +29 -0
- data/vendor/cybozulib/release.props +12 -0
- data/vendor/cybozulib/sample/Makefile +30 -0
- data/vendor/cybozulib/sample/csucvector_smpl.cpp +42 -0
- data/vendor/cybozulib/sample/data/svd/org/test1.S +4 -0
- data/vendor/cybozulib/sample/data/svd/org/test1.U +4 -0
- data/vendor/cybozulib/sample/data/svd/org/test1.V +6 -0
- data/vendor/cybozulib/sample/data/svd/test1 +4 -0
- data/vendor/cybozulib/sample/data/svd/test2 +4 -0
- data/vendor/cybozulib/sample/desymbol.cpp +127 -0
- data/vendor/cybozulib/sample/exception_smpl.cpp +46 -0
- data/vendor/cybozulib/sample/fmindex_smpl.cpp +231 -0
- data/vendor/cybozulib/sample/log_smpl.cpp +19 -0
- data/vendor/cybozulib/sample/mecab_smpl.cpp +37 -0
- data/vendor/cybozulib/sample/option2_smpl.cpp +68 -0
- data/vendor/cybozulib/sample/option_smpl.cpp +42 -0
- data/vendor/cybozulib/sample/plsi_smpl.cpp +207 -0
- data/vendor/cybozulib/sample/proj/exception_smpl.vcproj +184 -0
- data/vendor/cybozulib/sample/proj/mecab_smpl.vcproj +184 -0
- data/vendor/cybozulib/sample/proj/ssl_smpl/ssl_smpl.vcxproj +85 -0
- data/vendor/cybozulib/sample/proj/ssl_smpl.vcproj +347 -0
- data/vendor/cybozulib/sample/proj/stacktrace_smpl/stacktrace_smpl.vcxproj +85 -0
- data/vendor/cybozulib/sample/proj/svd_smpl.vcproj +184 -0
- data/vendor/cybozulib/sample/quit_signal_handler.cpp +30 -0
- data/vendor/cybozulib/sample/serializer_smpl.cpp +196 -0
- data/vendor/cybozulib/sample/socket_smpl.cpp +82 -0
- data/vendor/cybozulib/sample/ssl_smpl.cpp +39 -0
- data/vendor/cybozulib/sample/stacktrace_smpl.cpp +52 -0
- data/vendor/cybozulib/sample/svd_bench_smpl.cpp +143 -0
- data/vendor/cybozulib/sample/svd_smpl.cpp +94 -0
- data/vendor/cybozulib/sample/wm_bench_smpl.cpp +182 -0
- data/vendor/cybozulib/sample/zlib_smpl.cpp +41 -0
- data/vendor/cybozulib/src/Makefile +8 -0
- data/vendor/cybozulib/src/base/Makefile +19 -0
- data/vendor/cybozulib/test/Makefile +12 -0
- data/vendor/cybozulib/test/base/Makefile +37 -0
- data/vendor/cybozulib/test/base/array_test.cpp +173 -0
- data/vendor/cybozulib/test/base/atoi_test.cpp +774 -0
- data/vendor/cybozulib/test/base/atomic_test.cpp +49 -0
- data/vendor/cybozulib/test/base/base64_test.cpp +113 -0
- data/vendor/cybozulib/test/base/bit_operation_test.cpp +134 -0
- data/vendor/cybozulib/test/base/bitvector_test.cpp +204 -0
- data/vendor/cybozulib/test/base/condition_variable_cs_test.cpp +92 -0
- data/vendor/cybozulib/test/base/condition_variable_test.cpp +88 -0
- data/vendor/cybozulib/test/base/config_test.cpp +236 -0
- data/vendor/cybozulib/test/base/crypto_test.cpp +122 -0
- data/vendor/cybozulib/test/base/csucvector_test.cpp +63 -0
- data/vendor/cybozulib/test/base/csv_test.cpp +182 -0
- data/vendor/cybozulib/test/base/data/a.xml +26 -0
- data/vendor/cybozulib/test/base/endian_test.cpp +56 -0
- data/vendor/cybozulib/test/base/env_test.cpp +22 -0
- data/vendor/cybozulib/test/base/event_test.cpp +41 -0
- data/vendor/cybozulib/test/base/file_test.cpp +233 -0
- data/vendor/cybozulib/test/base/fmindex_test.cpp +118 -0
- data/vendor/cybozulib/test/base/format_test.cpp +12 -0
- data/vendor/cybozulib/test/base/frequency_test.cpp +104 -0
- data/vendor/cybozulib/test/base/itoa_test.cpp +522 -0
- data/vendor/cybozulib/test/base/line_stream_test.cpp +208 -0
- data/vendor/cybozulib/test/base/mecab_test.cpp +41 -0
- data/vendor/cybozulib/test/base/minixml_test.cpp +103 -0
- data/vendor/cybozulib/test/base/mmap_test.cpp +15 -0
- data/vendor/cybozulib/test/base/option_test.cpp +487 -0
- data/vendor/cybozulib/test/base/parallel_test.cpp +48 -0
- data/vendor/cybozulib/test/base/proj/array_test/array_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/atoi_test/atoi_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/atomic_test/atomic_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/base64_test/base64_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/condition_variable_cs_test/condition_variable_cs_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/condition_variable_test/condition_variable_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/config_test/config_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/csv_test/csv_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/endian_test/endian_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/env_test/env_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/event_test/event_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/file_test/file_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/itoa_test/itoa_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/mecab_test/mecab_test.vcxproj +88 -0
- data/vendor/cybozulib/test/base/proj/minixml_test/minixml_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/mmap_test/mmap_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/serializer_test/serializer_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/sha1_test/sha1_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/stream_test/stream_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/string_operation_test/string_operation_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/string_test/string_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/thread_test/thread_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/time_test/time_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/tls_test/tls_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/proj/zlib_test/zlib_test.vcxproj +86 -0
- data/vendor/cybozulib/test/base/random_generator_test.cpp +28 -0
- data/vendor/cybozulib/test/base/regex_test.cpp +74 -0
- data/vendor/cybozulib/test/base/serializer_test.cpp +483 -0
- data/vendor/cybozulib/test/base/sha1_test.cpp +61 -0
- data/vendor/cybozulib/test/base/sha2_test.cpp +191 -0
- data/vendor/cybozulib/test/base/siphash_test.cpp +33 -0
- data/vendor/cybozulib/test/base/socket_test.cpp +76 -0
- data/vendor/cybozulib/test/base/stream_test.cpp +101 -0
- data/vendor/cybozulib/test/base/string_operation_test.cpp +340 -0
- data/vendor/cybozulib/test/base/string_test.cpp +1705 -0
- data/vendor/cybozulib/test/base/sucvector_test.cpp +312 -0
- data/vendor/cybozulib/test/base/thread_test.cpp +62 -0
- data/vendor/cybozulib/test/base/time_test.cpp +164 -0
- data/vendor/cybozulib/test/base/tls_test.cpp +50 -0
- data/vendor/cybozulib/test/base/wavelet_matrix_test.cpp +145 -0
- data/vendor/cybozulib/test/base/zlib_test.cpp +371 -0
- data/vendor/cybozulib/test/nlp/Makefile +27 -0
- data/vendor/cybozulib/test/nlp/proj/random_test.vcproj +184 -0
- data/vendor/cybozulib/test/nlp/proj/sparse_test.vcproj +184 -0
- data/vendor/cybozulib/test/nlp/proj/svd_test.vcproj +184 -0
- data/vendor/cybozulib/test/nlp/random_test.cpp +62 -0
- data/vendor/cybozulib/test/nlp/sparse_test.cpp +347 -0
- data/vendor/cybozulib/test/nlp/svd_test.cpp +234 -0
- data/vendor/cybozulib/test/nlp/top_score_test.cpp +40 -0
- data/vendor/cybozulib/tool/create_vcproj.py +186 -0
- data/vendor/cybozulib/tool/vcproj_tmpl.py +185 -0
- data/vendor/msoffice/COPYRIGHT +27 -0
- data/vendor/msoffice/Makefile +29 -0
- data/vendor/msoffice/bin/64/msoc.dll +0 -0
- data/vendor/msoffice/bin/64/msocsample.exe +0 -0
- data/vendor/msoffice/bin/64/msoffice-crypt.exe +0 -0
- data/vendor/msoffice/bin/msoc.dll +0 -0
- data/vendor/msoffice/bin/msocsample.exe +0 -0
- data/vendor/msoffice/bin/msoffice-crypt.exe +0 -0
- data/vendor/msoffice/common.mk +71 -0
- data/vendor/msoffice/common.props +26 -0
- data/vendor/msoffice/debug.props +14 -0
- data/vendor/msoffice/include/attack.hpp +211 -0
- data/vendor/msoffice/include/cfb.hpp +777 -0
- data/vendor/msoffice/include/crypto_util.hpp +450 -0
- data/vendor/msoffice/include/custom_sha1.hpp +342 -0
- data/vendor/msoffice/include/decode.hpp +240 -0
- data/vendor/msoffice/include/encode.hpp +221 -0
- data/vendor/msoffice/include/make_dataspace.hpp +316 -0
- data/vendor/msoffice/include/msoc.h +129 -0
- data/vendor/msoffice/include/resource.hpp +7 -0
- data/vendor/msoffice/include/standard_encryption.hpp +145 -0
- data/vendor/msoffice/include/uint32vec.hpp +179 -0
- data/vendor/msoffice/include/util.hpp +212 -0
- data/vendor/msoffice/lib/.emptydir +0 -0
- data/vendor/msoffice/misc/decrypt-xls.vbs +46 -0
- data/vendor/msoffice/mk.bat +1 -0
- data/vendor/msoffice/mkdll.bat +3 -0
- data/vendor/msoffice/msoc.def +13 -0
- data/vendor/msoffice/msocsample.py +178 -0
- data/vendor/msoffice/msoffice12.sln +31 -0
- data/vendor/msoffice/readme.md +110 -0
- data/vendor/msoffice/release.props +28 -0
- data/vendor/msoffice/src/Makefile +19 -0
- data/vendor/msoffice/src/attack.cpp +124 -0
- data/vendor/msoffice/src/cfb_test.cpp +77 -0
- data/vendor/msoffice/src/minisample.c +54 -0
- data/vendor/msoffice/src/msocdll.cpp +276 -0
- data/vendor/msoffice/src/msocsample.c +136 -0
- data/vendor/msoffice/src/msoffice-crypt.cpp +219 -0
- data/vendor/msoffice/src/proj/attack/attack.vcxproj +88 -0
- data/vendor/msoffice/src/proj/main/msoffice-crypt.vcxproj +88 -0
- data/vendor/msoffice/src/sha1.cpp +234 -0
- data/vendor/msoffice/test/Makefile +20 -0
- data/vendor/msoffice/test/cfb_test.cpp +74 -0
- data/vendor/msoffice/test/hash_test.cpp +59 -0
- data/vendor/msoffice/test/proj/cfb/cfb_test.vcxproj +90 -0
- data/vendor/msoffice/test/proj/hash/hash_test.vcxproj +90 -0
- data/vendor/msoffice/test/sampl.bat +8 -0
- data/vendor/msoffice/test_all.py +46 -0
- data/vendor/update +4 -0
- metadata +351 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
3
|
+
<ItemGroup Label="ProjectConfigurations">
|
4
|
+
<ProjectConfiguration Include="Debug|x64">
|
5
|
+
<Configuration>Debug</Configuration>
|
6
|
+
<Platform>x64</Platform>
|
7
|
+
</ProjectConfiguration>
|
8
|
+
<ProjectConfiguration Include="Release|x64">
|
9
|
+
<Configuration>Release</Configuration>
|
10
|
+
<Platform>x64</Platform>
|
11
|
+
</ProjectConfiguration>
|
12
|
+
</ItemGroup>
|
13
|
+
<PropertyGroup Label="Globals">
|
14
|
+
<ProjectGuid>{40B5AD5D-5F35-4FFD-945D-022E7F1AAB31}</ProjectGuid>
|
15
|
+
<Keyword>Win32Proj</Keyword>
|
16
|
+
<RootNamespace>attack</RootNamespace>
|
17
|
+
</PropertyGroup>
|
18
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
19
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
20
|
+
<ConfigurationType>Application</ConfigurationType>
|
21
|
+
<UseDebugLibraries>true</UseDebugLibraries>
|
22
|
+
<PlatformToolset>v110</PlatformToolset>
|
23
|
+
<CharacterSet>MultiByte</CharacterSet>
|
24
|
+
</PropertyGroup>
|
25
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
26
|
+
<ConfigurationType>Application</ConfigurationType>
|
27
|
+
<UseDebugLibraries>false</UseDebugLibraries>
|
28
|
+
<PlatformToolset>v110</PlatformToolset>
|
29
|
+
<WholeProgramOptimization>true</WholeProgramOptimization>
|
30
|
+
<CharacterSet>MultiByte</CharacterSet>
|
31
|
+
</PropertyGroup>
|
32
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
33
|
+
<ImportGroup Label="ExtensionSettings">
|
34
|
+
</ImportGroup>
|
35
|
+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
36
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
37
|
+
<Import Project="..\..\..\common.props" />
|
38
|
+
<Import Project="..\..\..\debug.props" />
|
39
|
+
</ImportGroup>
|
40
|
+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
41
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
42
|
+
<Import Project="..\..\..\common.props" />
|
43
|
+
<Import Project="..\..\..\release.props" />
|
44
|
+
</ImportGroup>
|
45
|
+
<PropertyGroup Label="UserMacros" />
|
46
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
47
|
+
<LinkIncremental>true</LinkIncremental>
|
48
|
+
</PropertyGroup>
|
49
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
50
|
+
<LinkIncremental>false</LinkIncremental>
|
51
|
+
</PropertyGroup>
|
52
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
53
|
+
<ClCompile>
|
54
|
+
<PrecompiledHeader>
|
55
|
+
</PrecompiledHeader>
|
56
|
+
<WarningLevel>Level4</WarningLevel>
|
57
|
+
<Optimization>Disabled</Optimization>
|
58
|
+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NOMINMAX</PreprocessorDefinitions>
|
59
|
+
</ClCompile>
|
60
|
+
<Link>
|
61
|
+
<SubSystem>Console</SubSystem>
|
62
|
+
<GenerateDebugInformation>true</GenerateDebugInformation>
|
63
|
+
</Link>
|
64
|
+
</ItemDefinitionGroup>
|
65
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
66
|
+
<ClCompile>
|
67
|
+
<WarningLevel>Level4</WarningLevel>
|
68
|
+
<PrecompiledHeader>
|
69
|
+
</PrecompiledHeader>
|
70
|
+
<Optimization>MaxSpeed</Optimization>
|
71
|
+
<FunctionLevelLinking>true</FunctionLevelLinking>
|
72
|
+
<IntrinsicFunctions>true</IntrinsicFunctions>
|
73
|
+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NOMINMAX</PreprocessorDefinitions>
|
74
|
+
</ClCompile>
|
75
|
+
<Link>
|
76
|
+
<SubSystem>Console</SubSystem>
|
77
|
+
<GenerateDebugInformation>true</GenerateDebugInformation>
|
78
|
+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
79
|
+
<OptimizeReferences>true</OptimizeReferences>
|
80
|
+
</Link>
|
81
|
+
</ItemDefinitionGroup>
|
82
|
+
<ItemGroup>
|
83
|
+
<ClCompile Include="..\..\attack.cpp" />
|
84
|
+
</ItemGroup>
|
85
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
86
|
+
<ImportGroup Label="ExtensionTargets">
|
87
|
+
</ImportGroup>
|
88
|
+
</Project>
|
@@ -0,0 +1,88 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
3
|
+
<ItemGroup Label="ProjectConfigurations">
|
4
|
+
<ProjectConfiguration Include="Debug|x64">
|
5
|
+
<Configuration>Debug</Configuration>
|
6
|
+
<Platform>x64</Platform>
|
7
|
+
</ProjectConfiguration>
|
8
|
+
<ProjectConfiguration Include="Release|x64">
|
9
|
+
<Configuration>Release</Configuration>
|
10
|
+
<Platform>x64</Platform>
|
11
|
+
</ProjectConfiguration>
|
12
|
+
</ItemGroup>
|
13
|
+
<PropertyGroup Label="Globals">
|
14
|
+
<ProjectGuid>{9E396E79-C168-4C40-BDE0-C9413B33C8CE}</ProjectGuid>
|
15
|
+
<Keyword>Win32Proj</Keyword>
|
16
|
+
<RootNamespace>msoffice-crypt</RootNamespace>
|
17
|
+
</PropertyGroup>
|
18
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
19
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
20
|
+
<ConfigurationType>Application</ConfigurationType>
|
21
|
+
<UseDebugLibraries>true</UseDebugLibraries>
|
22
|
+
<PlatformToolset>v110</PlatformToolset>
|
23
|
+
<CharacterSet>MultiByte</CharacterSet>
|
24
|
+
</PropertyGroup>
|
25
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
26
|
+
<ConfigurationType>Application</ConfigurationType>
|
27
|
+
<UseDebugLibraries>false</UseDebugLibraries>
|
28
|
+
<PlatformToolset>v110</PlatformToolset>
|
29
|
+
<WholeProgramOptimization>true</WholeProgramOptimization>
|
30
|
+
<CharacterSet>MultiByte</CharacterSet>
|
31
|
+
</PropertyGroup>
|
32
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
33
|
+
<ImportGroup Label="ExtensionSettings">
|
34
|
+
</ImportGroup>
|
35
|
+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
36
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
37
|
+
<Import Project="..\..\..\common.props" />
|
38
|
+
<Import Project="..\..\..\debug.props" />
|
39
|
+
</ImportGroup>
|
40
|
+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
41
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
42
|
+
<Import Project="..\..\..\common.props" />
|
43
|
+
<Import Project="..\..\..\release.props" />
|
44
|
+
</ImportGroup>
|
45
|
+
<PropertyGroup Label="UserMacros" />
|
46
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
47
|
+
<LinkIncremental>true</LinkIncremental>
|
48
|
+
</PropertyGroup>
|
49
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
50
|
+
<LinkIncremental>false</LinkIncremental>
|
51
|
+
</PropertyGroup>
|
52
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
53
|
+
<ClCompile>
|
54
|
+
<PrecompiledHeader>
|
55
|
+
</PrecompiledHeader>
|
56
|
+
<WarningLevel>Level4</WarningLevel>
|
57
|
+
<Optimization>Disabled</Optimization>
|
58
|
+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NOMINMAX</PreprocessorDefinitions>
|
59
|
+
</ClCompile>
|
60
|
+
<Link>
|
61
|
+
<SubSystem>Console</SubSystem>
|
62
|
+
<GenerateDebugInformation>true</GenerateDebugInformation>
|
63
|
+
</Link>
|
64
|
+
</ItemDefinitionGroup>
|
65
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
66
|
+
<ClCompile>
|
67
|
+
<WarningLevel>Level4</WarningLevel>
|
68
|
+
<PrecompiledHeader>
|
69
|
+
</PrecompiledHeader>
|
70
|
+
<Optimization>MaxSpeed</Optimization>
|
71
|
+
<FunctionLevelLinking>true</FunctionLevelLinking>
|
72
|
+
<IntrinsicFunctions>true</IntrinsicFunctions>
|
73
|
+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NOMINMAX</PreprocessorDefinitions>
|
74
|
+
</ClCompile>
|
75
|
+
<Link>
|
76
|
+
<SubSystem>Console</SubSystem>
|
77
|
+
<GenerateDebugInformation>true</GenerateDebugInformation>
|
78
|
+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
79
|
+
<OptimizeReferences>true</OptimizeReferences>
|
80
|
+
</Link>
|
81
|
+
</ItemDefinitionGroup>
|
82
|
+
<ItemGroup>
|
83
|
+
<ClCompile Include="..\..\msoffice-crypt.cpp" />
|
84
|
+
</ItemGroup>
|
85
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
86
|
+
<ImportGroup Label="ExtensionTargets">
|
87
|
+
</ImportGroup>
|
88
|
+
</Project>
|
@@ -0,0 +1,234 @@
|
|
1
|
+
/**
|
2
|
+
@file
|
3
|
+
@brief sha1 sample
|
4
|
+
Copyright (C) 2012 Cybozu Labs, Inc., all rights reserved.
|
5
|
+
*/
|
6
|
+
#include <stdio.h>
|
7
|
+
#include <stdlib.h>
|
8
|
+
#include <cybozu/sha1.hpp>
|
9
|
+
#include "aes.hpp"
|
10
|
+
#include <cybozu/base64.hpp>
|
11
|
+
#include <sstream>
|
12
|
+
#include <fstream>
|
13
|
+
#include <cybozu/mmap.hpp>
|
14
|
+
#include <cybozu/minixml.hpp>
|
15
|
+
#include <cybozu/atoi.hpp>
|
16
|
+
|
17
|
+
/*
|
18
|
+
<keyData
|
19
|
+
saltSize="16"
|
20
|
+
blockSize="16"
|
21
|
+
keyBits="128"
|
22
|
+
hashSize="20"
|
23
|
+
cipherAlgorithm="AES"
|
24
|
+
cipherChaining="ChainingModeCBC"
|
25
|
+
hashAlgorithm="SHA1"
|
26
|
+
saltValue="xJqq7pkATGsBfuXNEbhnKQ=="
|
27
|
+
/>
|
28
|
+
<dataIntegrity
|
29
|
+
encryptedHmacKey="rxCSo+nqBf18m0mctP82tZbBRRaC5h7DM1q7q/bKPrU="
|
30
|
+
encryptedHmacValue="yuBiZXxrtgU3WNRWahDolVZJ8PbwsI9w7Hksnu2UkvM="
|
31
|
+
/>
|
32
|
+
<keyEncryptors>
|
33
|
+
<p:encryptedKey
|
34
|
+
spinCount="100000"
|
35
|
+
saltSize="16"
|
36
|
+
blockSize="16"
|
37
|
+
keyBits="128"
|
38
|
+
hashSize="20"
|
39
|
+
cipherAlgorithm="AES"
|
40
|
+
cipherChaining="ChainingModeCBC"
|
41
|
+
hashAlgorithm="SHA1"
|
42
|
+
saltValue="9JlPmy3NXg6EvGOG1FI9LA=="
|
43
|
+
encryptedVerifierHashInput="xpwBRhK5VWSrmM9kspOnwg=="
|
44
|
+
encryptedVerifierHashValue="jpuVmPpsYgBZR1fvJ21E9BhRTtuIlbJsknEjEPz1wmI="
|
45
|
+
encryptedKeyValue="cnNcvlFXRSEykrLjpWgYlw=="
|
46
|
+
/>
|
47
|
+
</keyEncryptor>
|
48
|
+
*/
|
49
|
+
|
50
|
+
void dump(const std::string& str)
|
51
|
+
{
|
52
|
+
for (size_t i = 0; i < str.size(); i++) {
|
53
|
+
printf("%02X:", (unsigned char)str[i]);
|
54
|
+
}
|
55
|
+
printf("\n");
|
56
|
+
}
|
57
|
+
|
58
|
+
std::string hex(const std::string& str)
|
59
|
+
{
|
60
|
+
std::string ret;
|
61
|
+
for (size_t i = 0; i < str.size(); i++) {
|
62
|
+
char buf[64];
|
63
|
+
CYBOZU_SNPRINTF(buf, sizeof(buf), "%02X", (unsigned char)str[i]);
|
64
|
+
ret.append(buf, 2);
|
65
|
+
}
|
66
|
+
return ret;
|
67
|
+
}
|
68
|
+
|
69
|
+
inline std::string dec64(const std::string& str)
|
70
|
+
{
|
71
|
+
cybozu::MemoryInputStream is(str);
|
72
|
+
cybozu::StringOutputStream os;
|
73
|
+
cybozu::DecodeFromBase64(os, is);
|
74
|
+
return os.str_;
|
75
|
+
}
|
76
|
+
|
77
|
+
std::string hashPassword(const std::string& salt, const std::string& pass, int spinCount)
|
78
|
+
{
|
79
|
+
cybozu::Sha1 s;
|
80
|
+
s.update(salt);
|
81
|
+
std::string h = s.digest(pass);
|
82
|
+
for (int i = 0; i < spinCount; i++) {
|
83
|
+
char iter[4];
|
84
|
+
cybozu::Set32bitAsLE(iter, i);
|
85
|
+
cybozu::Sha1 s;
|
86
|
+
s.update(iter, sizeof(iter));
|
87
|
+
h = s.digest(h);
|
88
|
+
}
|
89
|
+
return h;
|
90
|
+
}
|
91
|
+
|
92
|
+
std::string hash(const std::string& msg)
|
93
|
+
{
|
94
|
+
cybozu::Sha1 s;
|
95
|
+
return s.digest(msg);
|
96
|
+
}
|
97
|
+
|
98
|
+
std::string generateKey(const std::string& hash, const std::string& blockKey)
|
99
|
+
{
|
100
|
+
cybozu::Sha1 s;
|
101
|
+
s.update(hash);
|
102
|
+
return s.digest(blockKey).substr(0, 16);
|
103
|
+
}
|
104
|
+
|
105
|
+
std::string generateIv(const std::string& salt, const std::string& blockKey)
|
106
|
+
{
|
107
|
+
if (blockKey.empty()) {
|
108
|
+
return salt.substr(0, 16);
|
109
|
+
}
|
110
|
+
return generateKey(salt, blockKey);
|
111
|
+
}
|
112
|
+
|
113
|
+
std::string cipher(const char *msg, size_t msgLen, const std::string& key, const std::string& iv)
|
114
|
+
{
|
115
|
+
printf("msg len=%d\n", (int)msgLen);
|
116
|
+
if ((msgLen % 16) != 0) {
|
117
|
+
puts("only size= 16x");
|
118
|
+
exit(1);
|
119
|
+
}
|
120
|
+
cybozu::Aes cipher;
|
121
|
+
if (!cipher.setup(hex(key).c_str(), cybozu::Aes::DECODING, 128, hex(iv).c_str())) {
|
122
|
+
fprintf(stderr, "can't setup\n");
|
123
|
+
exit(1);
|
124
|
+
}
|
125
|
+
std::string ret;
|
126
|
+
for (size_t i = 0; i < msgLen; i += 16) {
|
127
|
+
char outBuf[256];
|
128
|
+
int writeSize = cipher.update(&msg[i], 16, outBuf);
|
129
|
+
if (writeSize < 0) {
|
130
|
+
exit(1);
|
131
|
+
}
|
132
|
+
ret.append(outBuf, writeSize);
|
133
|
+
}
|
134
|
+
return ret;
|
135
|
+
}
|
136
|
+
|
137
|
+
std::string cipher(const std::string& msg, const std::string& key, const std::string& iv)
|
138
|
+
{
|
139
|
+
return cipher(msg.c_str(), msg.size(), key, iv);
|
140
|
+
}
|
141
|
+
|
142
|
+
std::string decContent(const std::string& data, const std::string& key, const std::string& salt)
|
143
|
+
{
|
144
|
+
std::string dec;
|
145
|
+
dec.reserve(data.size());
|
146
|
+
const size_t n = (data.size() + 4095) / 4096;
|
147
|
+
for (size_t i = 0; i < n; i++) {
|
148
|
+
const size_t len = (i < n - 1) ? 4096 : (data.size() % 4096);
|
149
|
+
std::string blockKey(4, 0);
|
150
|
+
cybozu::Set32bitAsLE(&blockKey[0], i);
|
151
|
+
const std::string iv = generateKey(salt, blockKey);
|
152
|
+
dec.append(cipher(data.c_str() + i * 4096, len, key, iv));
|
153
|
+
}
|
154
|
+
return dec;
|
155
|
+
}
|
156
|
+
|
157
|
+
int main()
|
158
|
+
try
|
159
|
+
{
|
160
|
+
cybozu::Mmap xmlFile("EncryptionInfo");
|
161
|
+
cybozu::MiniXml xml(xmlFile.get() + 8, xmlFile.get() + xmlFile.size());
|
162
|
+
|
163
|
+
const cybozu::minixml::Node *keyData = xml.get().getFirstTagByName("keyData");
|
164
|
+
const std::string keyData_saltValue(dec64(keyData->attr["saltValue"]));
|
165
|
+
|
166
|
+
const cybozu::minixml::Node *dataIntegrity = xml.get().getFirstTagByName("dataIntegrity");
|
167
|
+
|
168
|
+
const std::string encryptedHmacKey(dec64(dataIntegrity->attr["encryptedHmacKey"]));
|
169
|
+
const std::string encryptedHmacValue(dec64(dataIntegrity->attr["encryptedHmacValue"]));
|
170
|
+
|
171
|
+
// keyEncryptors
|
172
|
+
const cybozu::minixml::Node *p_encryptedKey = xml.get().getFirstTagByName("p:encryptedKey");
|
173
|
+
const int spinCount = cybozu::atoi(p_encryptedKey->attr["spinCount"]);
|
174
|
+
const std::string encryptedKey_saltValue(dec64(p_encryptedKey->attr["saltValue"]));
|
175
|
+
const std::string encryptedVerifierHashInput(dec64(p_encryptedKey->attr["encryptedVerifierHashInput"]));
|
176
|
+
const std::string encryptedVerifierHashValue(dec64(p_encryptedKey->attr["encryptedVerifierHashValue"]));
|
177
|
+
const std::string encryptedKeyValue(dec64(p_encryptedKey->attr["encryptedKeyValue"]));
|
178
|
+
|
179
|
+
std::string pass("t\x00""e\x00""s\x00""t\x00", 8);
|
180
|
+
const std::string kV("\xfe" "\xa7" "\xd2" "\x76" "\x3b" "\x4b" "\x9e" "\x79", 8);
|
181
|
+
const std::string kH("\xd7" "\xaa" "\x0f" "\x6d" "\x30" "\x61" "\x34" "\x4e", 8);
|
182
|
+
const std::string kC("\x14" "\x6e" "\x0b" "\xe7" "\xab" "\xac" "\xd0" "\xd6", 8);
|
183
|
+
|
184
|
+
puts("pass"); dump(pass);
|
185
|
+
const std::string pwHash = hashPassword(encryptedKey_saltValue, pass, spinCount);
|
186
|
+
|
187
|
+
const std::string iv = encryptedKey_saltValue;
|
188
|
+
const std::string skey1 = generateKey(pwHash, kV);
|
189
|
+
const std::string verifierHashInput = cipher(encryptedVerifierHashInput, skey1, iv);
|
190
|
+
puts("verifierHashInput");
|
191
|
+
dump(verifierHashInput);
|
192
|
+
const std::string hashedVerifier = hash(verifierHashInput);
|
193
|
+
puts("hashedVerifier"); dump(hashedVerifier);
|
194
|
+
|
195
|
+
const std::string skey2 = generateKey(pwHash, kH);
|
196
|
+
const std::string verifierHash = cipher(encryptedVerifierHashValue, skey2, iv).substr(0, hashedVerifier.size());
|
197
|
+
puts("verifierHash"); dump(verifierHash);
|
198
|
+
|
199
|
+
if (hashedVerifier != verifierHash) {
|
200
|
+
puts("miss");
|
201
|
+
return 1;
|
202
|
+
}
|
203
|
+
const std::string skey3 = generateKey(pwHash, kC);
|
204
|
+
std::string secretKey = cipher(encryptedKeyValue, skey3, iv);
|
205
|
+
puts("secretKey"); dump(secretKey);
|
206
|
+
|
207
|
+
cybozu::Mmap m("EncryptedPackage");
|
208
|
+
uint64_t fileSize = cybozu::Get64bitAsLE(m.get());
|
209
|
+
printf("fileSize=%d\n", (int)fileSize);
|
210
|
+
std::string encData(m.get() + 8, (int)m.size() - 8);
|
211
|
+
printf("encData.size=%d\n", (int)encData.size());
|
212
|
+
|
213
|
+
// decode
|
214
|
+
std::string decData = decContent(encData, secretKey, keyData_saltValue);
|
215
|
+
{
|
216
|
+
std::ofstream ofs("dec.pptx", std::ios::binary);
|
217
|
+
ofs.write(decData.c_str(), (int)fileSize);
|
218
|
+
}
|
219
|
+
// integrity
|
220
|
+
{
|
221
|
+
const std::string b1("\x5f" "\xb2" "\xad" "\x01" "\x0c" "\xb9" "\xe1" "\xf6", 8);
|
222
|
+
const std::string iv1 = generateIv(keyData_saltValue, b1);
|
223
|
+
const std::string salt = cipher(encryptedHmacKey, secretKey, iv1).substr(0, 20);
|
224
|
+
printf("salt=%s\n", hex(salt).c_str());
|
225
|
+
}
|
226
|
+
{
|
227
|
+
const std::string b2("\xa0" "\x67" "\x7f" "\x02" "\xb2" "\x2c" "\x84" "\x33", 8);
|
228
|
+
const std::string iv2 = generateIv(keyData_saltValue, b2);
|
229
|
+
const std::string r2 = cipher(encryptedHmacValue, secretKey, iv2).substr(0, 20);
|
230
|
+
printf(" r2=%s\n", hex(r2).c_str());
|
231
|
+
}
|
232
|
+
} catch (cybozu::Exception& e) {
|
233
|
+
printf("ERR %s\n", e.what());
|
234
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <stdlib.h>
|
3
|
+
#include <string>
|
4
|
+
#include <locale>
|
5
|
+
#include <fstream>
|
6
|
+
#include <cybozu/mmap.hpp>
|
7
|
+
#include "cfb.hpp"
|
8
|
+
|
9
|
+
void usage()
|
10
|
+
{
|
11
|
+
fprintf(stderr, "cfb_test -f <inFile>\n");
|
12
|
+
exit(0);
|
13
|
+
}
|
14
|
+
|
15
|
+
std::string toAscii(const cybozu::String16& str)
|
16
|
+
{
|
17
|
+
std::string ret;
|
18
|
+
if (cybozu::ConvertUtf16ToUtf8(&ret, str)) {
|
19
|
+
return ret;
|
20
|
+
}
|
21
|
+
return "";
|
22
|
+
}
|
23
|
+
|
24
|
+
void run(const std::string& inFile)
|
25
|
+
{
|
26
|
+
cybozu::Mmap m(inFile);
|
27
|
+
if (m.size() > 0xffffffff) {
|
28
|
+
fprintf(stderr, "too large file size %lld\n", (long long)m.size());
|
29
|
+
exit(1);
|
30
|
+
}
|
31
|
+
const uint32_t mSize = static_cast<uint32_t>(m.size());
|
32
|
+
ms::cfb::CompoundFile cfb(m.get(), mSize);
|
33
|
+
cfb.put();
|
34
|
+
const char nameTbl[][128] = {
|
35
|
+
"EncryptedPackage",
|
36
|
+
"EncryptionInfo",
|
37
|
+
};
|
38
|
+
const ms::cfb::DirectoryEntryVec& dirs = cfb.dirs;
|
39
|
+
for (size_t i = 0; i < dirs.size(); i++) {
|
40
|
+
const ms::cfb::DirectoryEntry& dir = dirs[i];
|
41
|
+
for (size_t j = 0; j < CYBOZU_NUM_OF_ARRAY(nameTbl); j++) {
|
42
|
+
std::string asc = toAscii(dir.directoryEntryName);
|
43
|
+
if (asc == nameTbl[j]) {
|
44
|
+
printf("save %s\n", nameTbl[j]);
|
45
|
+
std::ofstream ofs(nameTbl[j], std::ios::binary);
|
46
|
+
ofs.write((const char*)&dir.content[0], (size_t)dir.streamSize);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
int main(int argc, char *argv[])
|
53
|
+
try
|
54
|
+
{
|
55
|
+
argc--, argv++;
|
56
|
+
std::string inFile;
|
57
|
+
while (argc > 0) {
|
58
|
+
if (argc > 1 && strcmp(*argv, "-f") == 0) {
|
59
|
+
argc--, argv++;
|
60
|
+
inFile = *argv;
|
61
|
+
} else
|
62
|
+
{
|
63
|
+
usage();
|
64
|
+
}
|
65
|
+
argc--, argv++;
|
66
|
+
}
|
67
|
+
if (inFile.empty()) {
|
68
|
+
usage();
|
69
|
+
}
|
70
|
+
run(inFile);
|
71
|
+
} catch (std::exception& e) {
|
72
|
+
fprintf(stderr, "exception:%s\n", e.what());
|
73
|
+
return 1;
|
74
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#include <cybozu/test.hpp>
|
2
|
+
#include <crypto_util.hpp>
|
3
|
+
#include <cybozu/benchmark.hpp>
|
4
|
+
#include "custom_sha1.hpp"
|
5
|
+
|
6
|
+
namespace ms {
|
7
|
+
|
8
|
+
inline std::string hashPasswordOrg(cybozu::crypto::Hash::Name name, const std::string& salt, const std::string& pass, int spinCount)
|
9
|
+
{
|
10
|
+
cybozu::crypto::Hash s(name);
|
11
|
+
std::string h = s.digest(salt + pass);
|
12
|
+
assert(h.size() == 20);
|
13
|
+
for (int i = 0; i < spinCount; i++) {
|
14
|
+
char iter[4];
|
15
|
+
cybozu::Set32bitAsLE(iter, i);
|
16
|
+
s.update(iter, sizeof(iter));
|
17
|
+
s.digest(&h[0], &h[0], h.size());
|
18
|
+
}
|
19
|
+
return h;
|
20
|
+
}
|
21
|
+
|
22
|
+
inline std::string sha1PasswordNew(const std::string& salt, const std::string& pass, int spinCount)
|
23
|
+
{
|
24
|
+
std::string h = cybozu::crypto::Hash::digest(cybozu::crypto::Hash::N_SHA1, salt + pass);
|
25
|
+
assert(h.size() == 20);
|
26
|
+
CustomSha1::digest(&h[0], spinCount);
|
27
|
+
return h;
|
28
|
+
}
|
29
|
+
|
30
|
+
} // ms
|
31
|
+
|
32
|
+
CYBOZU_TEST_AUTO(hashPassword)
|
33
|
+
{
|
34
|
+
cybozu::crypto::Hash::Name hash = cybozu::crypto::Hash::N_SHA1;
|
35
|
+
const std::string pass[8] = { "adsfasdf", "xxx", "12345234", "999", "abcD", "XXX", "---", "---------sfas" };
|
36
|
+
const std::string salt = "sdfa3rvawvfafas";
|
37
|
+
std::string out[8];
|
38
|
+
const int spinCount = 10000;
|
39
|
+
const std::string x = ms::hashPasswordOrg(hash, salt, pass[0], spinCount);
|
40
|
+
const std::string y = ms::sha1PasswordNew(salt, pass[0], spinCount);
|
41
|
+
CYBOZU_TEST_EQUAL(x, y);
|
42
|
+
#ifdef SHA1_USE_SIMD
|
43
|
+
const int N = Uint32Vec::size;
|
44
|
+
printf("SIMD=%d\n", N);
|
45
|
+
ms::sha1PasswordX<N>(out, salt, pass, spinCount);
|
46
|
+
for (int i = 0; i < N; i++) {
|
47
|
+
CYBOZU_TEST_EQUAL(ms::hex(out[i]), ms::hex(ms::hashPasswordOrg(hash, salt, pass[i], spinCount)));
|
48
|
+
}
|
49
|
+
#endif
|
50
|
+
#ifdef NDEBUG
|
51
|
+
if (x == y) {
|
52
|
+
CYBOZU_BENCH("org", ms::hashPasswordOrg, hash, salt, pass[0], spinCount);
|
53
|
+
CYBOZU_BENCH("new", ms::sha1PasswordNew, salt, pass[0], spinCount);
|
54
|
+
#ifdef SHA1_USE_SIMD
|
55
|
+
CYBOZU_BENCH("xN ", ms::sha1PasswordX<Uint32Vec::size>, out, salt, pass, spinCount);
|
56
|
+
#endif
|
57
|
+
}
|
58
|
+
#endif
|
59
|
+
}
|
@@ -0,0 +1,90 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
3
|
+
<ItemGroup Label="ProjectConfigurations">
|
4
|
+
<ProjectConfiguration Include="Debug|x64">
|
5
|
+
<Configuration>Debug</Configuration>
|
6
|
+
<Platform>x64</Platform>
|
7
|
+
</ProjectConfiguration>
|
8
|
+
<ProjectConfiguration Include="Release|x64">
|
9
|
+
<Configuration>Release</Configuration>
|
10
|
+
<Platform>x64</Platform>
|
11
|
+
</ProjectConfiguration>
|
12
|
+
</ItemGroup>
|
13
|
+
<PropertyGroup Label="Globals">
|
14
|
+
<ProjectGuid>{9E396E79-C168-4C40-BDE0-C9413B33C8CE}</ProjectGuid>
|
15
|
+
<Keyword>Win32Proj</Keyword>
|
16
|
+
<RootNamespace>cfb_test</RootNamespace>
|
17
|
+
</PropertyGroup>
|
18
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
19
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
20
|
+
<ConfigurationType>Application</ConfigurationType>
|
21
|
+
<UseDebugLibraries>true</UseDebugLibraries>
|
22
|
+
<PlatformToolset>v110</PlatformToolset>
|
23
|
+
<CharacterSet>MultiByte</CharacterSet>
|
24
|
+
</PropertyGroup>
|
25
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
26
|
+
<ConfigurationType>Application</ConfigurationType>
|
27
|
+
<UseDebugLibraries>false</UseDebugLibraries>
|
28
|
+
<PlatformToolset>v110</PlatformToolset>
|
29
|
+
<WholeProgramOptimization>true</WholeProgramOptimization>
|
30
|
+
<CharacterSet>MultiByte</CharacterSet>
|
31
|
+
</PropertyGroup>
|
32
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
33
|
+
<ImportGroup Label="ExtensionSettings">
|
34
|
+
</ImportGroup>
|
35
|
+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
36
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
37
|
+
<Import Project="..\..\..\common.props" />
|
38
|
+
<Import Project="..\..\..\debug.props" />
|
39
|
+
</ImportGroup>
|
40
|
+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
41
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
42
|
+
<Import Project="..\..\..\common.props" />
|
43
|
+
<Import Project="..\..\..\release.props" />
|
44
|
+
</ImportGroup>
|
45
|
+
<PropertyGroup Label="UserMacros" />
|
46
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
47
|
+
<LinkIncremental>true</LinkIncremental>
|
48
|
+
</PropertyGroup>
|
49
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
50
|
+
<LinkIncremental>false</LinkIncremental>
|
51
|
+
</PropertyGroup>
|
52
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
53
|
+
<ClCompile>
|
54
|
+
<PrecompiledHeader>
|
55
|
+
</PrecompiledHeader>
|
56
|
+
<WarningLevel>Level4</WarningLevel>
|
57
|
+
<Optimization>Disabled</Optimization>
|
58
|
+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NOMINMAX</PreprocessorDefinitions>
|
59
|
+
<AdditionalIncludeDirectories>$(SolutionDir)include;$(SolutionDir)..\cybozulib\include;$(SolutionDir)..\cybozulib_ext\openssl\include</AdditionalIncludeDirectories>
|
60
|
+
</ClCompile>
|
61
|
+
<Link>
|
62
|
+
<SubSystem>Console</SubSystem>
|
63
|
+
<GenerateDebugInformation>true</GenerateDebugInformation>
|
64
|
+
</Link>
|
65
|
+
</ItemDefinitionGroup>
|
66
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
67
|
+
<ClCompile>
|
68
|
+
<WarningLevel>Level4</WarningLevel>
|
69
|
+
<PrecompiledHeader>
|
70
|
+
</PrecompiledHeader>
|
71
|
+
<Optimization>MaxSpeed</Optimization>
|
72
|
+
<FunctionLevelLinking>true</FunctionLevelLinking>
|
73
|
+
<IntrinsicFunctions>true</IntrinsicFunctions>
|
74
|
+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NOMINMAX</PreprocessorDefinitions>
|
75
|
+
<AdditionalIncludeDirectories>$(SolutionDir)include;$(SolutionDir)..\cybozulib\include;$(SolutionDir)..\cybozulib_ext\openssl\include</AdditionalIncludeDirectories>
|
76
|
+
</ClCompile>
|
77
|
+
<Link>
|
78
|
+
<SubSystem>Console</SubSystem>
|
79
|
+
<GenerateDebugInformation>true</GenerateDebugInformation>
|
80
|
+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
81
|
+
<OptimizeReferences>true</OptimizeReferences>
|
82
|
+
</Link>
|
83
|
+
</ItemDefinitionGroup>
|
84
|
+
<ItemGroup>
|
85
|
+
<ClCompile Include="..\..\cfb_test.cpp" />
|
86
|
+
</ItemGroup>
|
87
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
88
|
+
<ImportGroup Label="ExtensionTargets">
|
89
|
+
</ImportGroup>
|
90
|
+
</Project>
|