mirror of
https://github.com/Neo-Desktop/WindowsXPKg
synced 2025-06-12 16:44:17 +03:00
Compare commits
256 Commits
Server-200
...
a827844cbd
Author | SHA1 | Date | |
---|---|---|---|
a827844cbd | |||
3e51fe1c8b | |||
783a5afb3a | |||
cb557c1ed8 | |||
d378c6499e | |||
5e68e1c8e1 | |||
bf6365916d | |||
3ea8731271 | |||
018f9f533c | |||
f1f1e0e6ea | |||
c4b63c15b2 | |||
1548e14169 | |||
c0a4c76b54 | |||
8cc691b72f | |||
72d48dd38b | |||
00d4906b28 | |||
88f60630c1 | |||
2ac6920e2c | |||
8f843ad4c3 | |||
2753bf2a40 | |||
d17ada2e64 | |||
6685b38aac | |||
884d8c9703 | |||
5ba2dbddd4 | |||
bf40bb6402 | |||
12a041c380 | |||
ecd9cd8dd2 | |||
6989ae6c94 | |||
ac510f8253 | |||
72c42f66c9 | |||
759c4009ef | |||
78c358c933 | |||
1d5e233c19 | |||
6c06732331 | |||
f347231362 | |||
a7e97e45ee | |||
bf57c32eae | |||
25db955b61 | |||
1aeceb28f1 | |||
b451a04f3c | |||
3e5e03df4d | |||
e3bdc93249 | |||
36b2eb3e7d | |||
49fefca596 | |||
178c9e0689 | |||
214d2d38a5 | |||
3ae078e3c5 | |||
12e511b3a5 | |||
21bac3b66c | |||
09842ace12 | |||
0d016b8872 | |||
b1743f4bff | |||
cc765edb4f | |||
4d1b5d6681 | |||
f59d77bdd1 | |||
71cbd19017 | |||
974f400cfc | |||
a2d521c230 | |||
d53409f5bd | |||
2703e17f69 | |||
680239bdb7 | |||
104bdb19e3 | |||
f2f859faeb | |||
a2d9c46a4b | |||
f65533bbb3 | |||
90e31b667a | |||
492d245f86 | |||
361a39e204 | |||
31993afb62 | |||
b3f64e6330 | |||
ccf93a0089 | |||
ae391a5e50 | |||
3620cf5af6 | |||
33774f7ad2 | |||
06ed5ef240 | |||
161aa2de4c | |||
a50688657d | |||
1679583e64 | |||
02c85b50b1 | |||
93732e152b | |||
95803054ba | |||
8619fccb11 | |||
06b9d937b1 | |||
453151f20f | |||
1bb00cf53d | |||
a787fc8e85 | |||
582ddf1bb8 | |||
13bf69c7e1 | |||
b7965f19e8 | |||
52c9a57ea2 | |||
283df1c1fe | |||
c1eb81490b | |||
2ee6a99acd | |||
1370a6ecff | |||
e3a6b78407 | |||
9fec269ad0 | |||
6ae5c9e435 | |||
a6bfaed6e8 | |||
f7b41a9810 | |||
e76eb7ac33 | |||
c91bbad69a | |||
75e81e7049 | |||
e9131e45c8 | |||
c664ea7f9c | |||
f95501b789 | |||
444f8c45c7 | |||
de09feb18f | |||
bde4371cbe | |||
f43a2d5c37 | |||
46c39df15d | |||
c078247bea | |||
232be6aba2 | |||
c0c3149be7 | |||
8e15a4f5b8 | |||
d411d56d81 | |||
11253c5e2c | |||
9f7920ca2d | |||
9063e32a89 | |||
958169ccb5 | |||
63fbbd83ef | |||
de659846d4 | |||
7c4bcdc847 | |||
859a21656c | |||
4b2ef7ac72 | |||
216c9cdf9d | |||
8f685a022c | |||
e4058ddf19 | |||
45004623be | |||
a4cb524fed | |||
03ae90163a | |||
c1e9a0f021 | |||
152c03456c | |||
ea51438766 | |||
8ee1acc2be | |||
3134a6f7a3 | |||
b75d08b3be | |||
20c84661b2 | |||
fefc8552b6 | |||
503fa3e1d8 | |||
15cbe19006 | |||
de04746c5e | |||
9817a83e74 | |||
bcd51e0e4e | |||
4b60737bb4 | |||
bc23fc5233 | |||
dc64133adf | |||
477f5c9af2 | |||
32a14cb8d9 | |||
db5ff7cd74 | |||
ca9ccc43ee | |||
57b2477e44 | |||
73a9cb3b2a | |||
40c60e656f | |||
62ab8caf87 | |||
7ea57ed136 | |||
529543ceef | |||
b1c80d3fa9 | |||
149f525a51 | |||
3e100d79a6 | |||
4bc029e645 | |||
fa0f832919 | |||
c306573fe8 | |||
88640191e8 | |||
e3b4485aa2 | |||
34619a2202 | |||
d4d50d9885 | |||
f11552509a | |||
eed869981b | |||
947fd48f38 | |||
0b94791ee1 | |||
f6755b0c22 | |||
3a7a37d814 | |||
4973d71d64 | |||
aa8e5ff8e7 | |||
4f7fb772a5 | |||
cc3900d4d0 | |||
726be7da20 | |||
98c8db7e02 | |||
8c295cf973 | |||
fcaa449ead | |||
42c24b57a1 | |||
0204d8486b | |||
6d3fd0031d | |||
cd3cc31cd6 | |||
29465ffb37 | |||
11dedcbd5f | |||
b69dbd541c | |||
530e5cdc21 | |||
da7e88b970 | |||
04e6362d7e | |||
1603dbd6e2 | |||
150f7433dc | |||
79d62a3b1b | |||
35c18d473b | |||
632c84249c | |||
d20cb1fa49 | |||
983acba760 | |||
974695b178 | |||
9b3abe7fb9 | |||
9812529903 | |||
21e31fd1b6 | |||
799fee5a68 | |||
1c5f93b687 | |||
3922223b9f | |||
9302ebd751 | |||
08ec7cb9bb | |||
8e4285c960 | |||
63bc103384 | |||
06920ede2a | |||
3f95974e61 | |||
166a0b5df7 | |||
e9a10e2882 | |||
728bf2a781 | |||
7c62596aa5 | |||
574b7b3b32 | |||
7944a9b15f | |||
6b85db12c9 | |||
19cce11bc2 | |||
475241e608 | |||
a14d44cdca | |||
d930648230 | |||
72d441b539 | |||
e437cc548a | |||
cc009d0ad4 | |||
96639bbaf7 | |||
1f30ff762d | |||
62e2e37373 | |||
814b8e48fb | |||
8088c455ff | |||
88619134bc | |||
bd11fb5eed | |||
5bf1da663a | |||
f5423a8eb0 | |||
3999ed0996 | |||
46adbee701 | |||
44dbb1e722 | |||
05ee5eb933 | |||
ac47a88f7e | |||
f5a76d8df5 | |||
388464da68 | |||
b6ade7c890 | |||
3764743558 | |||
ad91633ae1 | |||
aadeb8fe46 | |||
b7c6621809 | |||
1564056d68 | |||
fa12ad2c48 | |||
78194d7ab9 | |||
04601b7260 | |||
2af9f6db64 | |||
8c506fe798 | |||
a7a670be02 | |||
92938eb908 | |||
a40632a7fe | |||
9b040f9613 | |||
3d300e0c84 |
220
.clang-format
Normal file
220
.clang-format
Normal file
@ -0,0 +1,220 @@
|
||||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: Microsoft
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterObjCDeclaration: true
|
||||
AfterStruct: true
|
||||
AfterUnion: false
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 120
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
QualifierAlignment: Leave
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
PackConstructorInitializers: BinPack
|
||||
BasedOnStyle: ''
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentRequiresClause: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertBraces: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
LambdaBodyIndentation: Signature
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 1000
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Right
|
||||
PPIndentWidth: -1
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: true
|
||||
RemoveBracesLLVM: false
|
||||
RequiresClausePosition: OwnLine
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: CaseSensitive
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterOverloadedOperator: false
|
||||
AfterRequiresInClause: false
|
||||
AfterRequiresInExpression: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: Latest
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 4
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
...
|
||||
---
|
||||
Language: Json
|
||||
BasedOnStyle: LLVM
|
||||
...
|
||||
|
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
||||
build*/
|
||||
cmake-*/
|
12
.gitattributes
vendored
Normal file
12
.gitattributes
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||
* text=auto eol=lf
|
||||
|
||||
*.c text
|
||||
*.h text
|
||||
*.cpp text
|
||||
*.hpp text
|
||||
*.json text
|
||||
*.txt text
|
||||
LICENSE text
|
||||
*.md text
|
||||
fully-licensed-wpa.txt -text
|
87
.github/workflows/dos-djgpp.yml
vendored
Normal file
87
.github/workflows/dos-djgpp.yml
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Neo on 06/19/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
name: C/C++ CI (DOS DJGPP)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CC: ${{ github.workspace }}/djgpp/bin/i586-pc-msdosdjgpp-gcc
|
||||
CXX: ${{ github.workspace }}/djgpp/bin/i586-pc-msdosdjgpp-g++
|
||||
CMAKE_FIND_ROOT_PATH: ${{ github.workspace }}/djgpp
|
||||
WATT_ROOT: ${{ github.workspace }}/djgpp/watt32
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Source Tree
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup build environment
|
||||
run: |
|
||||
sudo apt -y update
|
||||
sudo apt -y install build-essential cmake wget 7zip git flex libfl-dev nasm libslang2-dev pkg-config libslang2-modules gcc-multilib
|
||||
|
||||
- name: Download and Setup DJGPP Toolchain
|
||||
run: |
|
||||
pushd ${{ github.workspace }}
|
||||
wget https://github.com/andrewwutw/build-djgpp/releases/download/v3.4/djgpp-linux64-gcc1220.tar.bz2
|
||||
tar xjf djgpp-linux64-gcc1220.tar.bz2
|
||||
cd ${{ github.workspace }}/djgpp
|
||||
git clone https://github.com/UMSKT/Watt-32.git watt32
|
||||
cd watt32/util
|
||||
make clean && make linux
|
||||
cd ../src
|
||||
source ${{ github.workspace }}/djgpp/setenv
|
||||
./configur.sh djgpp
|
||||
make -f djgpp.mak
|
||||
ln -s ${WATT_ROOT}/lib/libwatt.a ${{ github.workspace }}/djgpp/lib
|
||||
|
||||
- name: Checkout and Cross Compile OpenSSL 3.1.2
|
||||
run: |
|
||||
git clone https://github.com/UMSKT/openssl.git openssl
|
||||
pushd openssl
|
||||
source ${{ github.workspace }}/djgpp/setenv
|
||||
./Configure no-threads -DOPENSSL_DEV_NO_ATOMICS --prefix=${{ github.workspace }}/djgpp DJGPP
|
||||
make && make install
|
||||
popd
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
source ${{ github.workspace }}/djgpp/setenv
|
||||
pushd build
|
||||
cmake ../ -D DJGPP_WATT32=${WATT_ROOT}/lib/libwatt.a -D CMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
|
||||
make
|
||||
|
||||
- name: Move executable to upload directory
|
||||
run: |
|
||||
mkdir build/actions_upload
|
||||
mv build/umskt.exe build/actions_upload/
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: UMSKT-DOS
|
||||
path: build/actions_upload
|
65
.github/workflows/freebsd.yml
vendored
Normal file
65
.github/workflows/freebsd.yml
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by techguy16 on 07/23/2023
|
||||
# @Maintainer techguy16
|
||||
|
||||
name: C/C++ CI (FreeBSD)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip
|
||||
pull_request:
|
||||
branches: [ "*" ]
|
||||
paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: build-x86_64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build & Test in FreeBSD
|
||||
id: test
|
||||
uses: vmactions/freebsd-vm@v1
|
||||
with:
|
||||
envs: 'MYTOKEN MYTOKEN2'
|
||||
usesh: true
|
||||
prepare: |
|
||||
pkg install -y cmake openssl git bash
|
||||
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
./umskt # Execute the test here
|
||||
|
||||
- name: Move files to correct directory
|
||||
run: |
|
||||
mkdir -p build/actions_upload
|
||||
mv build/umskt build/actions_upload/umskt
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: UMSKT-FreeBSD
|
||||
path: build/actions_upload
|
87
.github/workflows/linux.yml
vendored
Normal file
87
.github/workflows/linux.yml
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by TheTank20 on 06/13/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
name: C/C++ CI (Linux)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- arch: x86
|
||||
- arch: x86_64
|
||||
- arch: aarch64
|
||||
steps:
|
||||
- name: Checkout Source Tree
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup latest Alpine Linux for ${{ matrix.arch }}
|
||||
uses: jirutka/setup-alpine@v1
|
||||
with:
|
||||
packages: >
|
||||
bash
|
||||
build-base
|
||||
cmake
|
||||
git
|
||||
musl-dev
|
||||
openssl-dev
|
||||
openssl-libs-static
|
||||
zlib-dev
|
||||
arch: ${{ matrix.arch }}
|
||||
shell-name: alpine-target.sh
|
||||
|
||||
- name: Configure and build UMSKT
|
||||
uses: threeal/cmake-action@7ef2eb8da6e5ec0a6de6b1ddc96987080bed06e8
|
||||
with:
|
||||
options: MUSL_STATIC=ON
|
||||
run-build: true
|
||||
shell: alpine-target.sh {0}
|
||||
|
||||
- name: Move files to correct directory
|
||||
run: |
|
||||
mkdir -p build/actions_upload
|
||||
mv build/umskt build/actions_upload/umskt
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: UMSKT-linux-${{ matrix.arch }}-static
|
||||
path: build/actions_upload
|
||||
|
||||
- name: Configure and build static internal deps UMSKT
|
||||
uses: threeal/cmake-action@7ef2eb8da6e5ec0a6de6b1ddc96987080bed06e8
|
||||
with:
|
||||
options: MUSL_STATIC=OFF BUILD_SHARED_LIBS=OFF
|
||||
run-build: true
|
||||
shell: alpine-target.sh {0}
|
||||
|
||||
- name: Configure and build shared deps UMSKT
|
||||
uses: threeal/cmake-action@7ef2eb8da6e5ec0a6de6b1ddc96987080bed06e8
|
||||
with:
|
||||
options: MUSL_STATIC=OFF BUILD_SHARED_LIBS=ON
|
||||
run-build: true
|
||||
shell: alpine-target.sh {0}
|
60
.github/workflows/macos.yml
vendored
Normal file
60
.github/workflows/macos.yml
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by techguy16 on 07/23/2023
|
||||
# @Maintainer techguy16
|
||||
|
||||
name: C/C++ CI (macOS)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-x86:
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- arch: x86_64
|
||||
steps:
|
||||
- name: Checkout Source Tree
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Configure and build UMSKT
|
||||
run: |
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make
|
||||
|
||||
- name: Move files to correct directory
|
||||
run: |
|
||||
mkdir -p build/actions_upload
|
||||
mv build/umskt build/actions_upload/umskt
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd build/actions_upload
|
||||
./umskt
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: UMSKT-macOS-${{ matrix.arch }}
|
||||
path: build/actions_upload
|
148
.github/workflows/windows.yml
vendored
Normal file
148
.github/workflows/windows.yml
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by TheTank20 on 06/13/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
name: C/C++ CI (Windows)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
paths-ignore: [ '**.md', 'doc/**', '.idea/**'] # If only these files are edited, skip
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-32bit:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
# https://github.com/actions/runner-images/issues/6067#issuecomment-1213069040
|
||||
- name: Install Windows XP Support for Visual Studio
|
||||
run: |
|
||||
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
|
||||
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
|
||||
$componentsToAdd = @(
|
||||
"Microsoft.VisualStudio.Component.WinXP"
|
||||
)
|
||||
[string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_}
|
||||
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
|
||||
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
|
||||
if ($process.ExitCode -eq 0)
|
||||
{
|
||||
Write-Host "components have been successfully added"
|
||||
Get-ChildItem C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.Windows.XPSupport.*
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "components were not installed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
- name: Download And Install 32-bit OpenSSL 3.1.4
|
||||
run: |
|
||||
$installDir = "$Env:ProgramFiles\OpenSSL"
|
||||
$installerURL = "https://slproweb.com/download/Win32OpenSSL-3_1_4.exe"
|
||||
$installerName = "Win32OpenSSL-3_1_4.exe"
|
||||
$installerPath = Join-Path -Path "${env:Temp}" -ChildPath "$installerName"
|
||||
|
||||
(New-Object System.Net.WebClient).DownloadFile($installerURL, $installerPath)
|
||||
|
||||
Remove-Item "$installDir" -Force -Recurse
|
||||
$installerArgs = '/silent', '/sp-', '/suppressmsgboxes', "/DIR=`"$installDir`""
|
||||
Start-Process -FilePath $installerPath -ArgumentList $installerArgs -Wait -PassThru
|
||||
|
||||
- name: Checkout Source Tree
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v1
|
||||
|
||||
- name: Configure UMSKT
|
||||
uses: threeal/cmake-action@v1.2.0
|
||||
with:
|
||||
generator: "Visual Studio 17 2022"
|
||||
options: CMAKE_SYSTEM_VERSION="5.1.2600"
|
||||
args: -A "Win32" -T v141_xp
|
||||
|
||||
- name: Build UMSKT
|
||||
working-directory: build
|
||||
run: msbuild ALL_BUILD.vcxproj /P:Configuration=Release
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: UMSKT-Win32
|
||||
path: build/Release
|
||||
|
||||
build-64bit:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Install Windows XP Support for Visual Studio
|
||||
run: |
|
||||
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
|
||||
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
|
||||
$componentsToAdd = @(
|
||||
"Microsoft.VisualStudio.Component.WinXP"
|
||||
)
|
||||
[string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_}
|
||||
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
|
||||
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
|
||||
if ($process.ExitCode -eq 0)
|
||||
{
|
||||
Write-Host "components have been successfully added"
|
||||
Get-ChildItem C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.Windows.XPSupport.*
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "components were not installed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
- name: Download And Install 64-bit OpenSSL 3.1.4
|
||||
run: |
|
||||
$installDir = "$Env:ProgramFiles\OpenSSL"
|
||||
$installerURL = "https://slproweb.com/download/Win64OpenSSL-3_1_4.exe"
|
||||
$installerName = "Win64OpenSSL-3_1_4.exe"
|
||||
$installerPath = Join-Path -Path "${env:Temp}" -ChildPath "$installerName"
|
||||
|
||||
(New-Object System.Net.WebClient).DownloadFile($installerURL, $installerPath)
|
||||
|
||||
Remove-Item "$installDir" -Force -Recurse
|
||||
$installerArgs = '/silent', '/sp-', '/suppressmsgboxes', "/DIR=`"$installDir`""
|
||||
Start-Process -FilePath $installerPath -ArgumentList $installerArgs -Wait -PassThru
|
||||
|
||||
- name: Checkout Source Tree
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v1
|
||||
|
||||
- name: Configure UMSKT
|
||||
uses: threeal/cmake-action@v1.2.0
|
||||
with:
|
||||
generator: "Visual Studio 17 2022"
|
||||
args: -A "x64" -T "v141_xp"
|
||||
|
||||
- name: Build UMSKT
|
||||
working-directory: build
|
||||
run: msbuild ALL_BUILD.vcxproj /P:Configuration=Release
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: UMSKT-Win64
|
||||
path: build/Release
|
255
.gitignore
vendored
Normal file
255
.gitignore
vendored
Normal file
@ -0,0 +1,255 @@
|
||||
build/*
|
||||
*.tar
|
||||
*.exe
|
||||
*.wasm
|
||||
umskt
|
||||
|
||||
### NotepadPP template
|
||||
# Notepad++ backups #
|
||||
*.bak
|
||||
|
||||
### VisualStudioCode template
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
### JetBrains+all template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### Linux template
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
### Windows template
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
### Vim template
|
||||
# Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
!*.svg # comment out if you don't need vector files
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
# Session
|
||||
Session.vim
|
||||
Sessionx.vim
|
||||
|
||||
# Temporary
|
||||
.netrwhist
|
||||
|
||||
# Auto-generated tag files
|
||||
tags
|
||||
# Persistent undo
|
||||
[._]*.un~
|
||||
|
||||
### macOS template
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### SublimeText template
|
||||
# Cache files for Sublime Text
|
||||
*.tmlanguage.cache
|
||||
*.tmPreferences.cache
|
||||
*.stTheme.cache
|
||||
|
||||
# Workspace files are user-specific
|
||||
*.sublime-workspace
|
||||
|
||||
# Project files should be checked into the repository, unless a significant
|
||||
# proportion of contributors will probably not be using Sublime Text
|
||||
# *.sublime-project
|
||||
|
||||
# SFTP configuration file
|
||||
sftp-config.json
|
||||
sftp-config-alt*.json
|
||||
|
||||
# Package control specific files
|
||||
Package Control.last-run
|
||||
Package Control.ca-list
|
||||
Package Control.ca-bundle
|
||||
Package Control.system-ca-bundle
|
||||
Package Control.cache/
|
||||
Package Control.ca-certs/
|
||||
Package Control.merged-ca-bundle
|
||||
Package Control.user-ca-bundle
|
||||
oscrypto-ca-bundle.crt
|
||||
bh_unicode_properties.cache
|
||||
|
||||
# Sublime-github package stores a github token in this file
|
||||
# https://packagecontrol.io/packages/sublime-github
|
||||
GitHub.sublime-settings
|
||||
|
||||
### CMake template
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
CMakeSettings.json
|
||||
|
||||
# Visual Studio
|
||||
.vs/
|
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
||||
UMSKT
|
2
.idea/UMSKT.iml
generated
Normal file
2
.idea/UMSKT.iml
generated
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
2
.idea/WindowsXPKg.iml
generated
Normal file
2
.idea/WindowsXPKg.iml
generated
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
90
.idea/editor.xml
generated
Normal file
90
.idea/editor.xml
generated
Normal file
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="BackendCodeEditorSettings">
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="ALIGN_ALL" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="2" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_DECLARATION_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/FREE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="END_OF_LINE_NO_SPACE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Space" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" />
|
||||
</component>
|
||||
</project>
|
15
.idea/misc.xml
generated
Normal file
15
.idea/misc.xml
generated
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
<component name="CidrRootsConfiguration">
|
||||
<sourceRoots>
|
||||
<file path="$PROJECT_DIR$/src" />
|
||||
</sourceRoots>
|
||||
<libraryRoots>
|
||||
<file path="$PROJECT_DIR$/lib" />
|
||||
</libraryRoots>
|
||||
<excludeRoots>
|
||||
<file path="$PROJECT_DIR$/build" />
|
||||
</excludeRoots>
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/UMSKT.iml" filepath="$PROJECT_DIR$/.idea/UMSKT.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
14
.idea/remote-targets.xml
generated
Normal file
14
.idea/remote-targets.xml
generated
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteTargetsManager">
|
||||
<option name="projectDefaultTargetUuid" value="36c80fd0-a122-4ef6-8ee6-1bd41007a378" />
|
||||
<targets>
|
||||
<target name="WSL - Ubuntu" type="wsl" uuid="36c80fd0-a122-4ef6-8ee6-1bd41007a378">
|
||||
<config>
|
||||
<option name="distributionMsId" value="Ubuntu" />
|
||||
<option name="projectRootOnTarget" value="{exitCode=0, timeout=false, cancelled=false, stdout=/mnt/c/Users/neo/AppData/Local/Programs/CLion/jbr/bin , stderr=}/UMSKT" />
|
||||
</config>
|
||||
</target>
|
||||
</targets>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
25
.pre-commit-config.yaml
Normal file
25
.pre-commit-config.yaml
Normal file
@ -0,0 +1,25 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Neo on 01/03/2024
|
||||
# @Maintainer Neo
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: 'v17.0.6' # Use the sha / tag you want to point at
|
||||
hooks:
|
||||
- id: clang-format
|
255
CMakeLists.txt
Normal file
255
CMakeLists.txt
Normal file
@ -0,0 +1,255 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Andrew on 05/30/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
|
||||
PROJECT(UMSKT)
|
||||
|
||||
SET(CMAKE_CXX_STANDARD 17)
|
||||
SET(CMAKE_OSX_SYSROOT "macosx" CACHE PATH "macOS SDK path")
|
||||
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
OPTION(BUILD_SHARED_LIBS "Build all libraries as shared" OFF)
|
||||
OPTION(UMSKT_USE_SHARED_OPENSSL "Force linking against the system-wide OpenSSL library" OFF)
|
||||
OPTION(MUSL_STATIC "Enable fully static builds in a muslc environment (i.e. Alpine Linux)" OFF)
|
||||
OPTION(DJGPP_WATT32 "Enable compilation and linking with DJGPP/WATT32/OpenSSL" OFF)
|
||||
OPTION(MSVC_MSDOS_STUB "Specify a custom MS-DOS stub for a 32-bit MSVC compilation" OFF)
|
||||
|
||||
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS})
|
||||
SET(UMSKT_LINK_DIRS ${UMSKT_LINK_DIRS})
|
||||
|
||||
# macOS does not support static build
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
SET(UMSKT_USE_SHARED_OPENSSL ON)
|
||||
ENDIF ()
|
||||
|
||||
# neither does dos idk i'm trying random stuff
|
||||
IF (DJGPP_WATT32)
|
||||
SET(UMSKT_USE_SHARED_OPENSSL ON)
|
||||
ENDIF ()
|
||||
|
||||
IF (UMSKT_USE_SHARED_OPENSSL)
|
||||
SET(OPENSSL_USE_STATIC_LIBS FALSE)
|
||||
SET(OPENSSL_MSVC_STATIC_RT FALSE)
|
||||
MESSAGE(STATUS "[UMSKT] Requesting dynamic version of OpenSSL")
|
||||
ELSE ()
|
||||
SET(OPENSSL_USE_STATIC_LIBS TRUE)
|
||||
SET(OPENSSL_MSVC_STATIC_RT TRUE)
|
||||
MESSAGE(STATUS "[UMSKT] Requesting static version of OpenSSL")
|
||||
ENDIF ()
|
||||
|
||||
IF (DJGPP_WATT32)
|
||||
SET(CMAKE_SYSTEM_NAME MSDOS)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS} ${DJGPP_WATT32})
|
||||
SET(UMSKT_LINK_DIRS ${UMSKT_LINK_DIRS} ${WATT_ROOT}/lib)
|
||||
ENDIF ()
|
||||
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
SET(BUILD_SHARED_LIBS ON)
|
||||
MESSAGE(STATUS "[UMSKT] macOS has no static library - Shared library forced on")
|
||||
ENDIF ()
|
||||
|
||||
# if we're compiling with MSVC, respect the DEBUG compile option
|
||||
IF (MSVC)
|
||||
SET(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "/MT")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "/MTd")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "/INCREMENTAL:NO /NODEFAULTLIB:MSVCRT")
|
||||
SET(CMAKE_ENABLE_EXPORTS ON)
|
||||
SET(UMSKT_EXE_WINDOWS_EXTRA src/windows/umskt.rc)
|
||||
SET(UMSKT_EXE_WINDOWS_DLL src/windows/dllmain.cpp)
|
||||
ENDIF ()
|
||||
|
||||
IF (MUSL_STATIC)
|
||||
MESSAGE(STATUS "[UMSKT] Performing a fully static build using muslc")
|
||||
SET(BUILD_SHARED_LIBS OFF)
|
||||
SET(OPENSSL_USE_STATIC_LIBS TRUE)
|
||||
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
|
||||
ENDIF ()
|
||||
|
||||
# find the system installed OpenSSL development library
|
||||
FIND_PACKAGE(OpenSSL REQUIRED)
|
||||
IF (NOT OPENSSL_FOUND)
|
||||
MESSAGE(SEND_ERROR "OpenSSL Development Libraries Not Found")
|
||||
MESSAGE(SEND_ERROR "Please consult your package manager of choice to install the prerequisite")
|
||||
MESSAGE(SEND_ERROR "The package name is commonly called libssl-dev or openssl-dev depending on distribution")
|
||||
MESSAGE(FATAL_ERROR "Can not continue without OpenSSL")
|
||||
ENDIF ()
|
||||
|
||||
IF (NOT MUSL_STATIC)
|
||||
# if we found shared libraries - do the following:
|
||||
IF (OPENSSL_USE_STATIC_LIBS)
|
||||
MESSAGE(STATUS "[UMSKT] requested static version of OpenSSL")
|
||||
IF (NOT UMSKT_USE_SHARED_OPENSSL)
|
||||
MESSAGE(STATUS "[UMSKT] not asked for shared version of OpenSSL")
|
||||
ENDIF ()
|
||||
|
||||
IF (MSVC)
|
||||
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS} "ws2_32.lib")
|
||||
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS} "crypt32.lib")
|
||||
MESSAGE(STATUS "[UMSKT] msvc adding ws2_32.lib crypt32.lib")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
STRING(REGEX MATCH "(\\.so|\\.dll|\\.dylib)$" OPENSSL_CRYPTO_SHARED "${OPENSSL_CRYPTO_LIBRARY}")
|
||||
IF (OPENSSL_CRYPTO_SHARED)
|
||||
MESSAGE(STATUS "[UMSKT] Detected Shared library version of OpenSSL")
|
||||
ELSE ()
|
||||
MESSAGE(STATUS "[UMSKT] Detected Static Library version of OpenSSL")
|
||||
|
||||
# static libcrypto on Fedora needs -lz at link time
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
FIND_PACKAGE(ZLIB REQUIRED)
|
||||
IF (NOT ZLIB_FOUND)
|
||||
MESSAGE(FATAL_ERROR "[UMSKT] linux static OpenSSL requires zlib")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
# initialize cpm.CMake
|
||||
FILE(
|
||||
DOWNLOAD
|
||||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.38.3/CPM.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
|
||||
EXPECTED_HASH SHA256=cc155ce02e7945e7b8967ddfaff0b050e958a723ef7aad3766d368940cb15494
|
||||
)
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)
|
||||
|
||||
# fetch cpm.CMake dependencies
|
||||
# Include JSON development library
|
||||
CPMAddPackage(
|
||||
NAME nlohmann_json
|
||||
GITHUB_REPOSITORY nlohmann/json
|
||||
VERSION 3.11.3
|
||||
)
|
||||
|
||||
# Include fmt development library
|
||||
CPMAddPackage(
|
||||
NAME fmt
|
||||
GITHUB_REPOSITORY fmtlib/fmt
|
||||
GIT_TAG 10.2.0
|
||||
VERSION 10.2.0
|
||||
)
|
||||
|
||||
# Include cmrc resource compiler
|
||||
CPMAddPackage(
|
||||
NAME cmrc
|
||||
GITHUB_REPOSITORY vector-of-bool/cmrc
|
||||
GIT_TAG 2.0.1
|
||||
VERSION 2.0.1
|
||||
)
|
||||
|
||||
# Include Crypto++ development library
|
||||
#CPMAddPackage(
|
||||
# NAME cryptopp-cmake
|
||||
# GITHUB_REPOSITORY abdes/cryptopp-cmake
|
||||
# GIT_TAG CRYPTOPP_8_8_0
|
||||
# VERSION 8.8.0
|
||||
# OPTIONS "CRYPTOPP_BUILD_TESTING OFF"
|
||||
#)
|
||||
|
||||
#include googletest unit testing library
|
||||
#CPMAddPackage(
|
||||
# NAME googletest
|
||||
# GITHUB_REPOSITORY google/googletest
|
||||
# VERSION 1.13.0
|
||||
# OPTIONS "INSTALL_GTEST OFF" "gtest_force_shared_crt"
|
||||
#)
|
||||
|
||||
### Resource compilation
|
||||
CMRC_ADD_RESOURCE_LIBRARY(umskt-rc ALIAS umskt::rc NAMESPACE umskt keys.json)
|
||||
|
||||
SET(LIBUMSKT_PIDGEN2 src/libumskt/pidgen2/PIDGEN2.cpp)
|
||||
SET(LIBUMSKT_PIDGEN3 src/libumskt/pidgen3/PIDGEN3.cpp src/libumskt/pidgen3/BINK1998.cpp src/libumskt/pidgen3/BINK2002.cpp)
|
||||
SET(LIBUMSKT_CONFID src/libumskt/confid/confid.cpp src/libumskt/confid/polynomial.cpp src/libumskt/confid/residue.cpp src/libumskt/confid/divisor.cpp)
|
||||
SET(LIBUMSKT_SRC src/libumskt/libumskt.cpp src/libumskt/debugoutput.cpp ${LIBUMSKT_PIDGEN2} ${LIBUMSKT_PIDGEN3} ${LIBUMSKT_CONFID})
|
||||
SET(UMSKT_CLI_SRC src/main.cpp src/help.cpp src/cli.cpp src/generate.cpp)
|
||||
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS} ${OPENSSL_CRYPTO_LIBRARIES} ${ZLIB_LIBRARIES} fmt)
|
||||
|
||||
IF (NOT MSVC)
|
||||
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS} umskt::rc)
|
||||
SET(UMSKT_CLI_SRC ${UMSKT_CLI_SRC} src/rc.cpp)
|
||||
ELSE()
|
||||
SET(UMSKT_CLI_SRC ${UMSKT_CLI_SRC} src/windows/platform.cpp)
|
||||
ENDIF()
|
||||
|
||||
#### Separate Build Path for emscripten
|
||||
IF (EMSCRIPTEN)
|
||||
ADD_EXECUTABLE(umskt ${UMSKT_CLI_SRC} ${LIBUMSKT_SRC})
|
||||
TARGET_INCLUDE_DIRECTORIES(umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||
TARGET_LINK_LIBRARIES(umskt PUBLIC ${UMSKT_LINK_LIBS})
|
||||
SET(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
|
||||
SET_TARGET_PROPERTIES(umskt PROPERTIES COMPILE_FLAGS "-Os -sEXPORTED_RUNTIME_METHODS=ccall,cwrap")
|
||||
SET_TARGET_PROPERTIES(umskt PROPERTIES LINK_FLAGS "-Os -sWASM=1 -sEXPORT_ALL=1 -sEXPORTED_RUNTIME_METHODS=ccall,cwrap --no-entry")
|
||||
ELSE ()
|
||||
## umskt.so/.dll creation
|
||||
ADD_LIBRARY(_umskt SHARED ${LIBUMSKT_SRC} ${UMSKT_EXE_WINDOWS_EXTRA} ${UMSKT_EXE_WINDOWS_DLL})
|
||||
TARGET_INCLUDE_DIRECTORIES(_umskt PUBLIC ${OPENSSL_INCLUDE_DIR} ${CMAKE_BINARY_DIR})
|
||||
TARGET_LINK_DIRECTORIES(_umskt PUBLIC ${UMSKT_LINK_DIRS})
|
||||
TARGET_LINK_LIBRARIES(_umskt PUBLIC ${UMSKT_LINK_LIBS})
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(_umskt PROPERTIES OUTPUT_NAME libumskt)
|
||||
ELSE()
|
||||
SET_TARGET_PROPERTIES(_umskt PROPERTIES OUTPUT_NAME umskt)
|
||||
ENDIF()
|
||||
|
||||
## umskt_static.a/.lib creation
|
||||
ADD_LIBRARY(umskt_static ${LIBUMSKT_SRC} ${UMSKT_EXE_WINDOWS_EXTRA} ${UMSKT_EXE_WINDOWS_DLL})
|
||||
TARGET_INCLUDE_DIRECTORIES(umskt_static PUBLIC ${OPENSSL_INCLUDE_DIR} ${CMAKE_BINARY_DIR})
|
||||
TARGET_LINK_DIRECTORIES(umskt_static PUBLIC ${UMSKT_LINK_DIRS})
|
||||
TARGET_LINK_LIBRARIES(umskt_static PUBLIC ${UMSKT_LINK_LIBS})
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(umskt_static PROPERTIES OUTPUT_NAME libumskt_static)
|
||||
ELSE()
|
||||
SET_TARGET_PROPERTIES(umskt_static PROPERTIES OUTPUT_NAME umskt_static)
|
||||
ENDIF()
|
||||
|
||||
### UMSKT executable compilation
|
||||
ADD_EXECUTABLE(umskt ${UMSKT_CLI_SRC} ${UMSKT_EXE_WINDOWS_EXTRA})
|
||||
TARGET_INCLUDE_DIRECTORIES(umskt PUBLIC ${OPENSSL_INCLUDE_DIR} ${CMAKE_BINARY_DIR})
|
||||
TARGET_LINK_LIBRARIES(umskt PUBLIC umskt_static ${UMSKT_LINK_LIBS} nlohmann_json::nlohmann_json)
|
||||
TARGET_LINK_DIRECTORIES(umskt PUBLIC ${UMSKT_LINK_DIRS})
|
||||
IF (MSVC)
|
||||
SET_PROPERTY(TARGET umskt APPEND PROPERTY COMPILE_FLAGS /DUMSKT_CLI_WINRC_EMBED_JSON)
|
||||
IF (MSVC_MSDOS_STUB)
|
||||
SET_PROPERTY(TARGET umskt APPEND PROPERTY LINK_FLAGS /STUB:${MSVC_MSDOS_STUB})
|
||||
ENDIF()
|
||||
ENDIF ()
|
||||
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
INSTALL(TARGETS umskt DESTINATION bin)
|
||||
ENDIF ()
|
||||
|
||||
### Copy Shared Libraries and dependency files
|
||||
IF (OPENSSL_CRYPTO_SHARED)
|
||||
GET_FILENAME_COMPONENT(OPENSSL_CRYPTO_LIBRARY_FILENAME ${OPENSSL_CRYPTO_LIBRARY} NAME)
|
||||
CONFIGURE_FILE(${OPENSSL_CRYPTO_LIBRARY} "${CMAKE_CURRENT_BINARY_DIR}/${OPENSSL_CRYPTO_LIBRARY_FILENAME}" COPYONLY)
|
||||
ENDIF ()
|
||||
ENDIF ()
|
53
Dockerfile
Normal file
53
Dockerfile
Normal file
@ -0,0 +1,53 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Neo on 06/19/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
# Stage 1: Install Prereqisites
|
||||
FROM alpine:latest as prereqisites
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
build-base \
|
||||
cmake \
|
||||
git \
|
||||
musl-dev \
|
||||
openssl-dev \
|
||||
openssl-libs-static
|
||||
|
||||
|
||||
# Stage 2: Build
|
||||
FROM prereqisites as builder
|
||||
|
||||
WORKDIR /src
|
||||
COPY . /src
|
||||
|
||||
# Build UMSKT from the local directory
|
||||
RUN mkdir /src/build \
|
||||
&& cd /src/build \
|
||||
&& cmake -DMUSL_STATIC=ON .. \
|
||||
&& make
|
||||
|
||||
# Stage 3: Output
|
||||
FROM scratch as output
|
||||
|
||||
COPY --from=builder /src/build/umskt /umskt
|
||||
|
||||
# invoke via
|
||||
# docker build -o type=tar,dest=umskt.tar .
|
123
Dockerfile.djgpp
Normal file
123
Dockerfile.djgpp
Normal file
@ -0,0 +1,123 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Neo on 06/19/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
# Stage 1: Install Prerequisites
|
||||
FROM alpine:latest as prerequisites
|
||||
|
||||
# Stage 1: Install build dependencies
|
||||
RUN apk add --no-cache \
|
||||
autoconf \
|
||||
automake \
|
||||
bash \
|
||||
bison \
|
||||
build-base \
|
||||
clang \
|
||||
cmake \
|
||||
coreutils \
|
||||
curl \
|
||||
elfutils-dev \
|
||||
findutils \
|
||||
git \
|
||||
gawk \
|
||||
flex \
|
||||
libelf \
|
||||
libslirp-dev \
|
||||
linux-headers \
|
||||
nasm \
|
||||
sed \
|
||||
slang-dev \
|
||||
texinfo \
|
||||
unzip \
|
||||
zlib-dev
|
||||
|
||||
|
||||
FROM prerequisites as djgpp
|
||||
|
||||
WORKDIR /tmp
|
||||
|
||||
# Stage 2: compile djgpp for muslc
|
||||
ENV DJGPP_PREFIX=/djgpp BUILD_VER=12.2.0-i386
|
||||
RUN git clone https://github.com/andrewwutw/build-djgpp.git djgpp \
|
||||
&& cd djgpp \
|
||||
&& cd script \
|
||||
&& wget https://gist.github.com/Neo-Desktop/4cfd708f61f5847a7bf457d38db3b59f/raw/25d24cf509b0fc486d5d18ecb6656f120c3d0e51/12.2.0-i386 -O 12.2.0-i386 \
|
||||
&& chmod +x 12.2.0-i386 \
|
||||
&& cd ../patch \
|
||||
&& wget https://gist.github.com/Neo-Desktop/4cfd708f61f5847a7bf457d38db3b59f/raw/25d24cf509b0fc486d5d18ecb6656f120c3d0e51/patch-alpine-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch -O patch-alpine-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch \
|
||||
&& cd .. \
|
||||
&& sed -i 's/i586/i386/g' setenv/setenv \
|
||||
&& sed -i 's/i586/i386/g' setenv/setenv.bat \
|
||||
&& ./build-djgpp.sh $BUILD_VER \
|
||||
&& rm -rf /tmp/djgpp
|
||||
|
||||
# Stage 3: compile watt32 for djgpp-i386
|
||||
FROM djgpp as watt32
|
||||
WORKDIR /djgpp
|
||||
ENV WATT_ROOT=/djgpp/watt32 DJGPP_PREFIX=i386-pc-msdosdjgpp
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
RUN git clone https://github.com/gvanem/Watt-32.git watt32 \
|
||||
&& cd watt32/util \
|
||||
&& make clean && make linux \
|
||||
&& cd ../src \
|
||||
&& source /djgpp/setenv \
|
||||
&& ./configur.sh djgpp \
|
||||
&& sed -i 's/i586/i386/g' djgpp.mak \
|
||||
&& wget https://gist.github.com/Neo-Desktop/ad26e888d64b22a59c743ab4e21ac186/raw/c9a73e1eb75ba8857883ac5c08691d2fe5b82594/djgpp.err -O ../inc/sys/djgpp.err \
|
||||
&& wget https://gist.github.com/Neo-Desktop/ad26e888d64b22a59c743ab4e21ac186/raw/c9a73e1eb75ba8857883ac5c08691d2fe5b82594/syserr.c -O build/djgpp/syserr.c \
|
||||
&& make -f djgpp.mak \
|
||||
&& ln -s /djgpp/watt32/lib/libwatt.a /djgpp/lib
|
||||
|
||||
# Stage 4: compile OpenSSL for djgpp-i386/watt32
|
||||
FROM watt32 as openssl
|
||||
WORKDIR /tmp
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
RUN git clone https://github.com/openssl/openssl.git openssl \
|
||||
&& cd openssl \
|
||||
&& git checkout openssl-3.1.1 \
|
||||
&& source /djgpp/setenv \
|
||||
&& wget https://gist.github.com/Neo-Desktop/ad26e888d64b22a59c743ab4e21ac186/raw/c9a73e1eb75ba8857883ac5c08691d2fe5b82594/50-djgpp.conf.patch -O Configurations/50-djgpp.conf.patch \
|
||||
&& git apply Configurations/50-djgpp.conf.patch \
|
||||
&& ./Configure no-threads -DOPENSSL_DEV_NO_ATOMICS --prefix=/djgpp DJGPP \
|
||||
&& make && make install
|
||||
|
||||
# Stage 5: compile UMSKT
|
||||
FROM openssl as build
|
||||
|
||||
WORKDIR /src
|
||||
COPY . /src
|
||||
|
||||
ENV CC=/djgpp/bin/i386-pc-msdosdjgpp-gcc CXX=/djgpp/bin/i386-pc-msdosdjgpp-g++ PKG_CONFIG_PATH=/djgpp/lib/pkgconfig VERBOSE=1
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
# Build UMSKT from the local directory
|
||||
RUN mkdir /src/build \
|
||||
&& cd /src/build \
|
||||
&& source /djgpp/setenv \
|
||||
&& cmake -DDJGPP_WATT32=${WATT_ROOT}/lib/libwatt.a .. \
|
||||
&& make
|
||||
|
||||
CMD ["bash"]
|
||||
|
||||
# Stage 6: Output
|
||||
FROM scratch as output
|
||||
|
||||
COPY --from=build /src/build/umskt.exe /umskt.exe
|
||||
|
||||
# invoke via
|
||||
# docker build -f Dockerfile.djgpp -o type=tar,dest=umskt-dos.tar .
|
64
Dockerfile.emscripten
Normal file
64
Dockerfile.emscripten
Normal file
@ -0,0 +1,64 @@
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Neo on 06/25/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
# Stage 1: Install Prerequisites
|
||||
FROM emscripten/emsdk:latest as prerequisites
|
||||
RUN apt update \
|
||||
&& apt -y install pkg-config \
|
||||
&& apt -y clean autoclean autoremove
|
||||
|
||||
# Stage 2: compile OpenSSL for emscripten
|
||||
FROM prerequisites as openssl
|
||||
WORKDIR /tmp
|
||||
ENV EMSCRIPTEN=/emsdk/upstream/emscripten VERBOSE=1
|
||||
RUN git clone https://github.com/openssl/openssl.git openssl \
|
||||
&& cd openssl \
|
||||
&& git checkout openssl-3.1.1 \
|
||||
&& emconfigure ./Configure gcc -no-tests -no-asm -static -fPIC -no-sock -no-afalgeng -DOPENSSL_SYS_NETWARE -DSIG_DFL=0 -DSIG_IGN=0 -DHAVE_FORK=0 -DOPENSSL_NO_AFALGENG=1 --with-rand-seed=getrandom --prefix=$EMSCRIPTEN/cache/sysroot|| exit $? \
|
||||
&& sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile \
|
||||
&& emmake make -j 12 build_generated libssl.a libcrypto.a build_libs_nodep \
|
||||
&& rm -rf $EMSCRIPTEN/cache/sysroot/include/openssl \
|
||||
&& cp -R include/openssl $EMSCRIPTEN/cache/sysroot/include \
|
||||
&& cp libcrypto.a libssl.a $EMSCRIPTEN/cache/sysroot/lib \
|
||||
&& cp libcrypto.pc libssl.pc openssl.pc $EMSCRIPTEN/cache/sysroot/lib/pkgconfig/ \
|
||||
&& cd .. \
|
||||
&& rm -rf openssl
|
||||
|
||||
# Stage 3: compile UMSKT
|
||||
FROM openssl as build
|
||||
|
||||
WORKDIR /src
|
||||
COPY . /src
|
||||
|
||||
# Build UMSKT from the local directory
|
||||
RUN mkdir /src/build \
|
||||
&& cd /src/build \
|
||||
&& emcmake cmake .. \
|
||||
&& emmake make
|
||||
|
||||
CMD ["bash"]
|
||||
|
||||
# Stage 4: Output
|
||||
FROM scratch as output
|
||||
|
||||
COPY --from=build /src/build/umskt.html /src/build/umskt.wasm /src/build/umskt.js /
|
||||
|
||||
# invoke via
|
||||
# docker build -f Dockerfile.emscripten -o type=tar,dest=umskt-wasm.tar .
|
86
Dockerfile.windows
Normal file
86
Dockerfile.windows
Normal file
@ -0,0 +1,86 @@
|
||||
# escape=`
|
||||
|
||||
# This file is a part of the UMSKT Project
|
||||
#
|
||||
# Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# @FileCreated by Neo on 06/19/2023
|
||||
# @Maintainer Neo
|
||||
|
||||
# Stage 1: Install Visual Studio
|
||||
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8.1 as visualstudio
|
||||
# Download and install Build Tools for Visual Studio 2022 for native desktop workload.
|
||||
#ADD https://aka.ms/vs/17/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
|
||||
ADD vs_buildtools.exe C:\TEMP\vs_buildtools.exe
|
||||
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
|
||||
--add Microsoft.VisualStudio.Workload.VCTools `
|
||||
--add Microsoft.VisualStudio.Workload.MSBuildTools `
|
||||
--add Microsoft.VisualStudio.Component.WinXP `
|
||||
--includeRecommended `
|
||||
--installPath C:\BuildTools \
|
||||
|
||||
# Stage 2: Install Chocolatey and Prereqisites
|
||||
FROM visualstudio as prereqisites
|
||||
WORKDIR C:\TEMP\
|
||||
|
||||
RUN ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass", "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))"]
|
||||
RUN ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass", "choco feature enable -n allowGlobalConfirmation"]
|
||||
RUN ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass", "choco install git --params \"'/GitAndUnixToolsOnPath /WindowsTerminal /NoShellIntegration /NoGuiHereIntegration /NoShellHereIntegration /NoCredentialManager /SChannel'\""]
|
||||
|
||||
#Install OpenSSL 32bit 3.1.1
|
||||
#ADD https://slproweb.com/download/Win32OpenSSL-3_1_1.msi C:\TEMP\Win32OpenSSL-3_1_1.msi
|
||||
ADD Win32OpenSSL-3_1_1.msi C:\TEMP\Win32OpenSSL-3_1_1.msi
|
||||
RUN msiexec /i C:\TEMP\Win32OpenSSL-3_1_1.msi /quiet /qn /norestart
|
||||
|
||||
#Install OpenSSL 64bit 3.1.1
|
||||
#ADD https://slproweb.com/download/Win64OpenSSL-3_1_1.msi C:\TEMP\Win64OpenSSL-3_1_1.msi
|
||||
ADD Win64OpenSSL-3_1_1.msi C:\TEMP\Win64OpenSSL-3_1_1.msi
|
||||
RUN msiexec /i C:\TEMP\Win64OpenSSL-3_1_1.msi /quiet /qn /norestart
|
||||
|
||||
# Stage 3: Build the 32-bit version of UMSKT
|
||||
FROM prereqisites as Build32
|
||||
WORKDIR C:\umskt\
|
||||
COPY . C:\umskt\
|
||||
|
||||
RUN C:\BuildTools\Common7\Tools\VsDevCmd.bat && `
|
||||
mkdir C:\umskt\build && `
|
||||
cd C:\umskt\build && `
|
||||
cmake -DMSVC_MSDOS_STUB:string=..\umskt.exe .. -G "Visual Studio 17 2022" -A "Win32" -T v141_xp && `
|
||||
msbuild ALL_BUILD.vcxproj /P:Configuration=Release
|
||||
|
||||
# Stage 4: Build the 64-bit version of UMSKT
|
||||
FROM prereqisites as Build64
|
||||
|
||||
WORKDIR C:\umskt\
|
||||
COPY . C:\umskt\
|
||||
|
||||
ENV OPENSSL_ROOT_DIR="C:\Program Files\OpenSSL-Win64"
|
||||
RUN C:\BuildTools\Common7\Tools\VsDevCmd.bat && `
|
||||
mkdir C:\umskt\build && `
|
||||
cd C:\umskt\build && `
|
||||
cmake .. && `
|
||||
msbuild ALL_BUILD.vcxproj /P:Configuration=Release
|
||||
|
||||
# Stage 5: Copy binaries to an output/runtime image
|
||||
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8.1 as output
|
||||
|
||||
COPY --from=Build32 C:\umskt\build\Release\umskt.exe C:\umskt\umskt.exe
|
||||
COPY --from=Build64 C:\umskt\build\Release\umskt.exe C:\umskt\umskt64.exe
|
||||
|
||||
#invoke via
|
||||
# docker build -f Dockerfile.windows .
|
||||
# docker run <hash>
|
||||
# docker cp <plug>:C:\umskt umskt-win
|
674
LICENSE
674
LICENSE
@ -1,21 +1,661 @@
|
||||
MIT License
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (c) 2019 TheMCHK
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Preamble
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
134
README.md
134
README.md
@ -1,33 +1,123 @@
|
||||
## **Windows XP Keygen!**
|
||||
# Universal MS Key Toolkit (UMSKT)
|
||||
|
||||
# **FAQ**
|
||||
**Connect with us**
|
||||
|
||||
* **What does it do?**
|
||||
[](https://umskt.zulipchat.com)
|
||||
[](https://web.libera.chat/gamja/?nick=Guest?#mspid)
|
||||
[](https://discord.gg/PpBSpuphWM)
|
||||
|
||||
This program allows you to generate endless Windows XP keys.
|
||||
You also can use it to check your already existing keys.
|
||||
**Build status**
|
||||
|
||||
* **How does it work?**
|
||||
[](../../actions/workflows/windows.yml)
|
||||
|
||||
This program is based on [this paper](https://www.licenturion.com/xp/fully-licensed-wpa.txt) Basically,
|
||||
it uses a cracked private key from Microsoft to sign some stuff encoded in the 25-digit product key. It also does this process in reverse to check for the validation of the keys.
|
||||
[](../../actions/workflows/macos.yml)
|
||||
|
||||
* **How do I use it?**
|
||||
[](../../actions/workflows/linux.yml)
|
||||
|
||||
It all comes down to four simple steps:
|
||||
|
||||
|
||||
**1.** Use this program to generate a key, and use such key during installation.
|
||||
|
||||
**2.** After installation, you will be prompted to activate Windows. Select the
|
||||
*telephone activation* method, then, fire up [this website](https://msdev.gointeract.io/interact/index?interaction=1461173234028-3884f8602eccbe259104553afa8415434b4581-05d1&accountId=microsoft&appkey=196de13c-e946-4531-98f6-2719ec8405ce) and enter the installation ID that the activation wizard gave you.
|
||||
|
||||
**3.** Click "**Next**"
|
||||
|
||||
**4.** Profit!
|
||||
[](../../actions/workflows/freebsd.yml)
|
||||
|
||||
[](../../actions/workflows/dos-djgpp.yml)
|
||||
|
||||
------
|
||||
|
||||
### Plan of Action / ToDo List
|
||||
|
||||
In light of the recent exponential interest in this project I've decided to put updates of this project here:
|
||||
|
||||
[Please see ticket #8 for more information](https://github.com/UMSKT/UMSKT/issues/8)
|
||||
|
||||
------
|
||||
|
||||
### **FAQ**
|
||||
|
||||
#### **What does it do?**
|
||||
|
||||
* This program is a tool for researching and experimenting with retro Microsoft product licensing, for products released before 2012.
|
||||
|
||||
#### **How does it work?**
|
||||
|
||||
* [Enderman's XPKeygen Readme explains everything in detail.](https://github.com/Endermanch/XPKeygen)
|
||||
|
||||
#### **How do I use it?**
|
||||
|
||||
* It all comes down to four simple steps:
|
||||
|
||||
------
|
||||
|
||||
### **Usage**
|
||||
#### 1. Download the latest version of UMSKT
|
||||
|
||||
* *(GitHub account required)*
|
||||
* Download the latest experimental version using the Actions tab ([Windows](../../actions/workflows/windows.yml?query=branch%3Amaster+is%3Asuccess), [Linux](../../actions/workflows/linux.yml?query=branch%3Amaster+is%3Asuccess), [macOS](../../actions/workflows/macos.yml?query=branch%3Amaster+is%3Asuccess), [FreeBSD](../../actions/workflows/freebsd.yml?query=branch%3Amaster+is%3Asuccess), [DOS DJGPP](../../actions/workflows/dos-djgpp.yml?query=branch%3Amaster+is%3Asuccess))
|
||||
|
||||
|
||||
* ~~*(GitHub account \*not\* required)*~~
|
||||
* ~~Download the latest release for your operating system and architecture from [the releases page](../../releases)~~
|
||||
* No official releases right now, use the other method to get the latest version.
|
||||
|
||||
**REQUIREMENTS:**
|
||||
* **Note:** Before continuing, please ensure you have the `umskt` executable extracted and on UNIX-like systems, have execution permissions (`chmod +x umskt`).
|
||||
|
||||
* `OpenSSL >0.9.8b`
|
||||
#### 2. Install OpenSSL 3.1.2.
|
||||
For Windows, click [here](https://slproweb.com/products/Win32OpenSSL.html) and choose the right version. For other operating systems, consult your package manager.
|
||||
*Note: This only applies if the build you download has OpenSSL embedded (static library) or not. You can usually tell if the download size is measured in KB or MB. If it's MB, you don't need this.*
|
||||
|
||||
#### 3. Run `umskt` to generate a key, or add `--help` or `-h` to see more options.
|
||||
|
||||
#### 4. *(Activation step for `Retail` and `OEM` only)*
|
||||
* After installation, you will be prompted to activate Windows.
|
||||
|
||||
|
||||
* Select the **telephone activation** method, then, run `umskt -i <Installation ID>` using the `Installation ID` the activation Wizard provides for you
|
||||
* If you're activating a non-Windows product, use `umskt -i <Installation ID> -m <Product>`, where `<Product>` is one of `OFFICEXP`, `OFFICE2K3`, `OFFICE2K7`, or `PLUSDME`
|
||||
* If activating Office 2003/2007, use `umskt -i <Installation ID> -m <Product> -p <Product ID>`
|
||||
|
||||
#### 4. Profit!
|
||||
|
||||
|
||||
------
|
||||
|
||||
|
||||
### Authors
|
||||
The list of people who have helped to bring the XP generation to where it is now:
|
||||
* z22
|
||||
* MSKey
|
||||
* diamondggg
|
||||
* pottzman
|
||||
* david4599
|
||||
* Endermanch
|
||||
* Neo-Desktop
|
||||
* WitherOrNot
|
||||
* TheTank20
|
||||
* InvoxiPlayGames
|
||||
* brakmic
|
||||
* techguy16
|
||||
|
||||
(the list will be updated to add more collaborators)
|
||||
|
||||
------
|
||||
|
||||
### **Development Requirements:**
|
||||
|
||||
* `build-essential`
|
||||
* `cmake`
|
||||
* `make`
|
||||
* `gcc`
|
||||
* `g++`
|
||||
* `git`
|
||||
|
||||
#### Build Steps:
|
||||
|
||||
1. `git clone https://github.com/UMSKT/UMSKT`
|
||||
2. `cd UMSKT/build`
|
||||
3. `cmake ..`
|
||||
4. `make`
|
||||
|
||||
|
||||
-----
|
||||
|
||||
### **Known Ports**
|
||||
|
||||
| Language | Author | Repo URL |
|
||||
|----------|-----------|-----------------------------------------------------------|
|
||||
| Rust | Alex Page | [anpage/umskt-rs](https://github.com/anpage/umskt-rs) |
|
||||
| Python | techguy16 | [techguy16/umsktpy](https://github.com/techguy16/umsktpy) |
|
||||
|
0
build/.gitkeep
Normal file
0
build/.gitkeep
Normal file
99
doc/Vista+.md
Normal file
99
doc/Vista+.md
Normal file
@ -0,0 +1,99 @@
|
||||
## 6. Product ID
|
||||
|
||||
Product ID is 5 groups of decimals, e.g.:
|
||||
|
||||
```
|
||||
AAAAA BBB CCCCCCC DD EEE
|
||||
52273 005 6861993 09 146
|
||||
```
|
||||
|
||||
If you search `ProductID` in registry, you will find a product ID associated with your currently installed one.
|
||||
|
||||
The meaning of each group of numbers:
|
||||
|
||||
| Number | Meaning |
|
||||
| --------- | ----------------------------------------------------------------------------------------------- |
|
||||
| `AAAAA` | Product code. e.g.: `55661` for Windows Pro; `55660` for Windows Home. |
|
||||
| `BBB` | First 3 effective number digits of Primary Product Serial. |
|
||||
| `CCCCCCC` | Last 6 effective number digits of Primary Product Serial, and a digit of checksum. |
|
||||
| `DD` | Public key index number for product validation. e.g.: Pro is 22, VLK is 23. |
|
||||
| `EEE` | Nonce (random number), for generating different install ID when doing activation via telephone. |
|
||||
|
||||
For `CCCCCCC` mentioned above, it had two parts including 1 digit and 6 digits. The checksum is calculated as follows: **Add all digits together (including the checksum digit), it is divisible by 7.**
|
||||
For example: the last 6 digits of Primary Product Serial is `728439`, then `7 + 2 + 8 + 4 + 3 + 9 = 33` , then the checksum digit should be `2`, because `7 + 2 + 8 + 4 + 3 + 9 + 2 = 33 + 2 = 35`, and 35 is divisible by 7. So the `CCCCCCC` in Product ID should be `7284392`.
|
||||
|
||||
## 7. OEM related mechanism
|
||||
<!-- Oh boy this section is a total mess... The original content itself is confusing as hell.. -->
|
||||
|
||||
For licensed product to OEMs, starting from Windows XP, Microsoft is using SLP (System-Locked Preinstallation) technology, aka.: before installing the OS, lock in the motherboard with the OS. Windows XP used SLP 1.0, it works by detecting specific string set by OEM in BIOS. This method is easy to be spoofed, but the VLK crack is more easy to use so this method is not wide-spread.
|
||||
From the Windows Vista, SLP upgraded to 2.0 . Primarily the change is using cryptographic key pairs to sign the data to prevent spoofing. This requires a special SLIC (Software Licensing Internal Code) table in BIOS to support this.
|
||||
In Windows 7 series of product, SLP 2.1 is used, but there is no major changes in SLP for this revision, only updated the marker in SLIC to 2.1 .
|
||||
|
||||
SLIC is the important part of SLP, usually directly backed in BIOS ROM, as the most underlying information of OS activation. SLIC contains the digital signature of OEM, when OS is activating, the upper level certificate must can be verified with the OEM information inside SLIC. SLIC usually contained inside SLDT(Software Licensing Description Table), which 374 bytes long, and SLDT itself is contained inside ACPI(Advanced Configuration and Power Management Interface).
|
||||
|
||||
OEM certificate is a certification file provided by Microsoft, including to some mandatory information provided by OEM, the extension for the file is `xrm-ms`. The OEM certificate including the OEM identification information and digitally signed by Microsoft. When OS is activating, the OEM certificate must can be validated against SLIC.
|
||||
|
||||
OEM product key seems no difference with retail product key, but OEM key is only valid for OEM activation, and it identifies the Windows product variation. Windows Vista cancelled the VLK model, only OEM activation is provided, and used SLP 2.0, used public key instead plain text for validation, caused difficulties for cracking.
|
||||
|
||||
### Windows Vista (SLP 2.0)
|
||||
<!-- Following procedure is for SLP 2.0, which is for Windows Vista. -->
|
||||
The procedure for SLP 2.0 verification is as follows:
|
||||
|
||||
1. When installing Windows Vista, retail version user need to input the serial (CD-KEY) presented on the box. For users who got the OEM version of Windows Vista with the computer, they can find a sticker that corresponding the version they got with the computer, as a voucher for purchasing the Windows Vista OEM version. The system identifies different versions of Windows Vista based on their serial numbers, such as Home Basic, Home Advanced, Business, Ultimate, and so on. After installation, the serial number is converted into 4 sets of letters or numbers, which is the "Product ID" shown in the "System Properties". The second group is the "OEM" one, which is the serial number (CD-KEY) of the OEM version. From now on, the product ID replaces the CD-KEY <!-- as user inputted their retail CD-KEY on the box, this OEM product ID became the CD-KEY in this case -->, and the installer generates an OEM certificate for the OEM version of the installation <!-- "product certificate" maybe? And, installed to where? usually the installation is done by OEM. The information is conflicting with the "OEM certificate is a certification file provided by Microsoft" mentioned above. -->.
|
||||
|
||||
2. The information in the BIOS got loaded into RAM every time system boots.
|
||||
|
||||
3. After logging into the Windows Vista, OS calls SLP service to check the licensed rights of running product, especially the activation status. It starts to identify the licensing status of the system based on the product ID. If no product ID is detected or no valid retail version product ID is detected, it is considered as inactivated. If a valid retail version product ID is detected, it is considered successfully activated. If an OEM version of the product ID is detected, continue with the OEM verification.
|
||||
|
||||
4. If the OEM product ID is detected, the OEM verification process starts, and it will check the installed OEM certificate <!-- "product certificate" ? --> is valid. It mainly uses the SLIC public key from BIOS which is loaded into the RAM, to verify the digital signature of product certificate <!-- Yes, this "product certificate" came from nowhere, so I guess this the OEM certificate that installed while installing the Windows Vista by OEM. -->. If validation failed, it is considered as inactivated.
|
||||
|
||||
5. Validate the OEM ID field between SLIC and RSDT (Root System Description Table), and compare the OEM ID field and OEM Table ID fields between SLIC and XSDT (Extended System Description Table). If they didn't match, it is considered as inactivated.
|
||||
|
||||
6. After the above hurdles, the OEM license will be considered as activated. If not then fallback to inactivated and continue with normal procedure, like require user to activate the Windows.
|
||||
|
||||
### Windows 7 (SLP 2.1)
|
||||
<!-- Following procedure is for SLP 2.1, which is for Windows 7. -->
|
||||
Windows 7 still retains the OEM activation policy, but using SLP 2.1 instead.
|
||||
|
||||
Here is more detailed verification process:
|
||||
|
||||
1. After the activation process starts, if the correct SLP Key is detected, the OEM activation process starts, otherwise the WPA activation (online or telephone activation) is performed.
|
||||
|
||||
2. Detect the OEM certificate <!-- "product certificate" ? -->, and use the digital signature inside the OEM certificate to validate the it (Microsoft used their private key to sign the OEM certificate, and verified against the public key), if verified then continue on OEM activation process, otherwise continue on WPA activation process.
|
||||
|
||||
3. Compare the OEM public key, OEM ID and various fields with the information presented in the OEM certificate <!-- "product certificate" ? -->. If they match (this means OEM public key and etc. are correct), then continue on OEM activation process, otherwise continue on WPA activation process.
|
||||
|
||||
4. Use OEM public key verify against the digital signature of the Marker inside SLIC. if verified (this means the Message in the Marker is correct. <!-- There is no where talked about what is that Message and Marker. -->) then continue on OEM activation process, otherwise continue on WPA activation process.
|
||||
|
||||
5. Validate the Windows Logo <!-- I guess? "Windows Logo" part can be directly translate to "Windows Flag Mark", and this "Flag" means that actual waving thing, not a digital bit. I guess this approach is similar as the Nintendo logo bitmap inside Game Boy game cartridge ROM thing. --> inside the Marker. If the Windows Logo is present, then continue on OEM activation process, otherwise continue on WPA activation process.
|
||||
|
||||
6. Validate the version of Marker. If it's at least `0x20001` then continue on OEM activation process, otherwise OEM activation failed, and continue on WPA activation process.
|
||||
|
||||
7. Compare the OEM ID and OEM Table ID against all corresponding ACPI table headers. If they match, then OEM activation completed successfully, otherwise continue on WPA activation process.
|
||||
|
||||
Key points (Not containing all details, this info is only there to emphasize the key points of Microsoft encryption):
|
||||
|
||||
1. OEM certificate <!-- "product certificate" ? --> contains
|
||||
- Data (OEM ID and other information, Microsoft public key, etc.)
|
||||
- Hash (Hash of data)
|
||||
- Signature (Hash were signed with Microsoft private key)
|
||||
|
||||
2. SLIC contains:
|
||||
- Data (OEM ID, Marker version, etc., Microsoft public key, etc.)
|
||||
- Hash (Hash the data)
|
||||
- Signature (Hash were signed with Microsoft private key)
|
||||
|
||||
3. First, use the public key to verify whether the signatures of OEM and SLIC, then, compare the OEM ID, public key and other information in OEM and SLIC to see whether they are the same; verify the Marker version is matching the type of system currently installed.
|
||||
|
||||
* * *
|
||||
Oh boy what a mess...
|
||||
|
||||
This source is from CSDN.net, and this is a known "copy paste and profit" site that infamous in China.
|
||||
|
||||
This article is old enough that the author is actually had integrity and cited all the actual juicy sources. However, all the actual juicy sources were long gone, because the BBS that the author cited is down,only unusable archives were left (reported by discord member @itsmefeng ).
|
||||
|
||||
This article isn't providing enough information on how to crack the Windows Vista/7 activation process. We may need more actual good sources for this.
|
||||
|
||||
For better understanding I provided some comment (as HTML comments for Markdown compatibility). Hopefully it will be useful.
|
||||
|
||||
-- Some Anonymous Person
|
607
doc/fully-licensed-wpa.txt
Normal file
607
doc/fully-licensed-wpa.txt
Normal file
@ -0,0 +1,607 @@
|
||||
|
||||
Inside Windows Product Activation
|
||||
|
||||
A Fully Licensed Paper
|
||||
|
||||
July 2001
|
||||
|
||||
Fully Licensed GmbH, Rudower Chaussee 29, 12489 Berlin, Germany
|
||||
|
||||
http://www.licenturion.com
|
||||
|
||||
|
||||
>> INTRODUCTION
|
||||
|
||||
The current public discussion of Windows Product Activation (WPA) is
|
||||
characterized by uncertainty and speculation. In this paper we supply
|
||||
the technical details of WPA - as implemented in Windows XP - that
|
||||
Microsoft should have published long ago.
|
||||
|
||||
While we strongly believe that every software vendor has the right to
|
||||
enforce the licensing terms governing the use of a piece of licensed
|
||||
software by technical means, we also do believe that each individual
|
||||
has the right to detailed knowledge about the full implications of the
|
||||
employed means and possible limitations imposed by it on software
|
||||
usage.
|
||||
|
||||
In this paper we answer what we think are currently the two most
|
||||
important open questions related to Windows Product Activation.
|
||||
|
||||
* Exactly what information is transmitted during activation?
|
||||
|
||||
* How do hardware modifications affect an already activated
|
||||
installation of Windows XP?
|
||||
|
||||
Our answers to these questions are based on Windows XP Release
|
||||
Candidate 1 (build 2505). Later builds as well as the final version of
|
||||
Windows XP might differ from build 2505, e.g. in the employed
|
||||
cryptographic keys or the layout of some of the data
|
||||
structures.
|
||||
|
||||
However, beyond such minor modifications we expect Microsoft to cling
|
||||
to the general architecture of their activation mechanism. Thus, we
|
||||
are convinced that the answers provided by this paper will still be
|
||||
useful when the final version of Windows XP ships.
|
||||
|
||||
This paper supplies in-depth technical information about the inner
|
||||
workings of WPA. Still, the discussion is a little vague at some
|
||||
points in order not to facilitate the task of an attacker attempting
|
||||
to circumvent the license enforcement supplied by the activation
|
||||
mechanism.
|
||||
|
||||
XPDec, a command line utility suitable for verifying the presented
|
||||
information, can be obtained from http://www.licenturion.com/xp/. It
|
||||
implements the algorithms presented in this paper. Reading its source
|
||||
code, which is available from the same location, is highly
|
||||
recommended.
|
||||
|
||||
We have removed an important cryptographic key from the XPDec source
|
||||
code. Recompiling the source code will thus fail to produce a working
|
||||
executable. The XPDec executable on our website, however, contains
|
||||
this key and is fully functional.
|
||||
|
||||
So, download the source code to learn about the inner workings of WPA,
|
||||
but obtain the executable to experiment with your installation of
|
||||
Windows XP.
|
||||
|
||||
We expect the reader to be familiar with the general procedure of
|
||||
Windows Product Activation.
|
||||
|
||||
>> INSIDE THE INSTALLATION ID
|
||||
|
||||
We focused our research on product activation via telephone. We did
|
||||
so, because we expected this variant of activation to be the most
|
||||
straight-forward to analyze.
|
||||
|
||||
The first step in activating Windows XP via telephone is supplying the
|
||||
call-center agent with the Installation ID displayed by msoobe.exe,
|
||||
the application that guides a user through the activation process. The
|
||||
Installation ID is a number consisting of 50 decimal digits that are
|
||||
divided into groups of six digits each, as in
|
||||
|
||||
002666-077894-484890-114573-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XX
|
||||
|
||||
In this authentic Installation ID we have substituted digits that we
|
||||
prefer not to disclose by 'X' characters.
|
||||
|
||||
If msoobe.exe is invoked more than once, it provides a different
|
||||
Installation ID each time.
|
||||
|
||||
In return, the call-center agent provides a Confirmation ID matching
|
||||
the given Installation ID. Entering the Confirmation ID completes the
|
||||
activation process.
|
||||
|
||||
Since the Installation ID is the only piece of information revealed
|
||||
during activation, the above question concerning the information
|
||||
transmitted during the activation process is equivalent to the
|
||||
question
|
||||
|
||||
'How is the Installation ID generated?'
|
||||
|
||||
To find an answer to this question, we trace back each digit of the
|
||||
Installation ID to its origins.
|
||||
|
||||
>>> Check digits
|
||||
|
||||
The rightmost digit in each of the groups is a check digit to guard
|
||||
against simple errors such as the call center agent's mistyping of one
|
||||
of the digits read to him or her. The value of the check digit is
|
||||
calculated by adding the other five digits in the group, adding the
|
||||
digits at even positions a second time, and dividing the sum by
|
||||
seven. The remainder of the division is the value of the check
|
||||
digit. In the above example the check digit for the first group (6) is
|
||||
calculated as follows.
|
||||
|
||||
1 | 2 | 3 | 4 | 5 <- position
|
||||
---+---+---+---+---
|
||||
0 | 0 | 2 | 6 | 6 <- digits
|
||||
|
||||
0 + 0 + 2 + 6 + 6 = 14 (step 1: add all digits)
|
||||
0 + 6 + 14 = 20 (step 2: add even digits again)
|
||||
|
||||
step 3: division
|
||||
20 / 7 = 2, remainder is 20 - (2 * 7) = 6
|
||||
|
||||
=> check digit is 6
|
||||
|
||||
Adding the even digits twice is probably intended to guard against the
|
||||
relatively frequent error of accidentally swapping two digits while
|
||||
typing, as in 00626 vs. 00266, which yield different check digits.
|
||||
|
||||
>>> Decoding
|
||||
|
||||
Removing the check digits results in a 41-digit decimal number. A
|
||||
decimal number of this length roughly corresponds to a 136-bit binary
|
||||
number. In fact, the 41-digit number is just the decimal encoding of
|
||||
such a 136-bit multi-precision integer, which is stored in little
|
||||
endian byte order as a byte array. Hence, the above Installation ID
|
||||
can also be represented as a sequence of 17 bytes as in
|
||||
|
||||
0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX
|
||||
0x94 0xAA 0x46 0xD6 0x0F 0xBD 0x2C 0xC8
|
||||
0x00
|
||||
|
||||
In this representation of the above Installation ID 'X' characters
|
||||
again substitute the digits that we prefer not to disclose. The '0x'
|
||||
prefix denotes hex notation throughout this paper.
|
||||
|
||||
>>> Decryption
|
||||
|
||||
When decoding arbitrary Installation IDs it can be noticed that the
|
||||
most significant byte always seems to be 0x00 or 0x01, whereas the
|
||||
other bytes look random. The reason for this is that the lower 16
|
||||
bytes of the Installation ID are encrypted, whereas the most
|
||||
significant byte is kept in plaintext.
|
||||
|
||||
The cryptographic algorithm employed to encrypt the Installation ID is
|
||||
a proprietary four-round Feistel cipher. Since the block of input
|
||||
bytes passed to a Feistel cipher is divided into two blocks of equal
|
||||
size, this class of ciphers is typically applied to input blocks
|
||||
consisting of an even number of bytes - in this case the lower 16 of
|
||||
the 17 input bytes. The round function of the cipher is the SHA-1
|
||||
message digest algorithm keyed with a four-byte sequence.
|
||||
|
||||
Let + denote the concatenation of two byte sequences, ^ the XOR
|
||||
operation, L and R the left and right eight-byte input half for one
|
||||
round, L' and R' the output halves of said round, and First-8() a
|
||||
function that returns the first eight bytes of an SHA-1 message
|
||||
digest. Then one round of decryption looks as follows.
|
||||
|
||||
L' = R ^ First-8(SHA-1(L + Key))
|
||||
R' = L
|
||||
|
||||
The result of the decryption is 16 bytes of plaintext, which are -
|
||||
together with the 17th unencrypted byte - from now on interpreted as
|
||||
four double words in little endian byte order followed by a single
|
||||
byte as in
|
||||
|
||||
name | size | offset
|
||||
-----+-------------+-------
|
||||
H1 | double word | 0
|
||||
H2 | double word | 4
|
||||
P1 | double word | 8
|
||||
P2 | double word | 12
|
||||
P3 | byte | 16
|
||||
|
||||
H1 and H2 specify the hardware configuration that the Installation ID
|
||||
is linked to. P1 and P2 as well as the remaining byte P3 contain the
|
||||
Product ID associated with the Installation ID.
|
||||
|
||||
>>> Product ID
|
||||
|
||||
The Product ID consists of five groups of decimal digits, as in
|
||||
|
||||
AAAAA-BBB-CCCCCCC-DDEEE
|
||||
|
||||
If you search your registry for a value named 'ProductID', you will
|
||||
discover the ID that applies to your installation. The 'About' window
|
||||
of Internet Explorer should also yield your Product ID.
|
||||
|
||||
>>>> Decoding
|
||||
|
||||
The mapping between the Product ID in decimal representation and its
|
||||
binary encoding in the double words P1 and P2 and the byte P3 is
|
||||
summarized in the following table.
|
||||
|
||||
digits | length | encoding
|
||||
--------+---------+---------------------------------------
|
||||
AAAAA | 17 bits | bit 0 to bit 16 of P1
|
||||
BBB | 10 bits | bit 17 to bit 26 of P1
|
||||
CCCCCCC | 28 bits | bit 27 to bit 31 of P1 (lower 5 bits)
|
||||
| | bit 0 to bit 22 of P2 (upper 23 bits)
|
||||
DDEEE | 17 bits | bit 23 to bit 31 of P2 (lower 9 bits)
|
||||
| | bit 0 to bit 7 of P3 (upper 8 bits)
|
||||
|
||||
The meaning of each of the five groups of digits is documented in the
|
||||
next table.
|
||||
|
||||
digits | meaning
|
||||
--------+-------------------------------------------------
|
||||
AAAAA | apparently always 55034 (in Windows XP RC1)
|
||||
BBB | most significant three digits of Raw Product Key
|
||||
| (see below)
|
||||
CCCCCCC | least significant six digits of Raw Product Key
|
||||
| plus check digit (see below)
|
||||
DD | index of the public key used to verify the
|
||||
| Product Key (see below)
|
||||
EEE | random value
|
||||
|
||||
As can be seen, the (Raw) Product Key plays an important role in
|
||||
generating the Product ID.
|
||||
|
||||
>>>> Product Key
|
||||
|
||||
The Raw Product Key is buried inside the Product Key that is printed
|
||||
on the sticker distributed with each Windows XP CD. It consists of
|
||||
five alphanumeric strings separated by '-' characters, where each
|
||||
string is composed of five characters, as in
|
||||
|
||||
FFFFF-GGGGG-HHHHH-JJJJJ-KKKKK
|
||||
|
||||
Each character is one of the following 24 letters and digits:
|
||||
|
||||
B C D F G H J K M P Q R T V W X Y 2 3 4 6 7 8 9
|
||||
|
||||
Very similar to the decimal encoding of the Installation ID the 25
|
||||
characters of the Product Key form a base-24 encoding of the binary
|
||||
representation of the Product Key. Decoding the Product Key yields a
|
||||
multi-precision integer of roughly 115 bits, which is stored - again
|
||||
in little endian byte order - in an array of 15 bytes. Decoding the
|
||||
above Product Key results in the following byte sequence.
|
||||
|
||||
0x6F 0xFA 0x95 0x45 0xFC 0x75 0xB5 0x52
|
||||
0xBB 0xEF 0xB1 0x17 0xDA 0xCD 0x00
|
||||
|
||||
Of these 15 bytes the least significant four bytes contain the Raw
|
||||
Product Key in little endian byte order. The least significant bit is
|
||||
removed by shifting this 32-bit value (0x4595FA6F - remember the
|
||||
little endian byte order) to the left by one bit position, resulting
|
||||
in a Raw Product Key of 0x22CAFD37, or
|
||||
|
||||
583728439
|
||||
|
||||
in decimal notation.
|
||||
|
||||
The eleven remaining bytes form a digital signature, allowing
|
||||
verification of the authenticity of the Product Key by means of a
|
||||
hard-coded public key.
|
||||
|
||||
>>>> Product Key -> Product ID
|
||||
|
||||
The three most significant digits, i.e. 583, of the Raw Product Key's
|
||||
nine-digit decimal representation directly map to the BBB component of
|
||||
the Product ID described above.
|
||||
|
||||
To obtain the CCCCCCC component, a check digit is appended to the
|
||||
remaining six digits 728439. The check digit is chosen such that the
|
||||
sum of all digits - including the check digit - is divisible by
|
||||
seven. In the given case, the sum of the six digits is
|
||||
|
||||
7 + 2 + 8 + 4 + 3 + 9 = 33
|
||||
|
||||
which results in a check digit of 2, since
|
||||
|
||||
7 + 2 + 8 + 4 + 3 + 9 + 2 = 33 + 2 = 35
|
||||
|
||||
which is divisible by seven. The CCCCCCC component of the Product ID
|
||||
is therefore 7284392.
|
||||
|
||||
For verifying a Product Key, more than one public key is available. If
|
||||
verification with the first public key fails, the second is tried,
|
||||
etc. The DD component of the Product ID specifies which of the public
|
||||
keys in this sequence was successfully used to verify the Product Key.
|
||||
|
||||
This mechanism might be intended to support several different parties
|
||||
generating valid Product Keys with different individual private keys.
|
||||
|
||||
However, the different private keys might also represent different
|
||||
versions of a product. A Product Key for the 'professional' release
|
||||
could then be signed with a different key than a Product Key for the
|
||||
'server' release. The DD component would then represent the product
|
||||
version.
|
||||
|
||||
Finally, a valid Product ID derived from our example Product Key might
|
||||
be
|
||||
|
||||
55034-583-7284392-00123
|
||||
|
||||
which indicates that the first public key (DD = index = 0) matched and
|
||||
123 was chosen as the random number EEE.
|
||||
|
||||
The randomly selected EEE component is the reason for msoobe.exe
|
||||
presenting a different Installation ID at each invocation. Because of
|
||||
the applied encryption this small change results in a completely
|
||||
different Installation ID.
|
||||
|
||||
So, the Product ID transmitted during activation will most probably
|
||||
differ in the last three digits from your Product ID as displayed by
|
||||
Internet Explorer or as stored in the registry.
|
||||
|
||||
>>> Hardware Information
|
||||
|
||||
As discussed above, the hardware configuration linked to the
|
||||
Installation ID is represented by the two double words H1 and H2.
|
||||
|
||||
>>>> Bit-fields
|
||||
|
||||
For this purpose, the double words are divided into twelve
|
||||
bit-fields. The relationship between the computer hardware and the
|
||||
bit-fields is given in the following table.
|
||||
|
||||
double word | offset | length | bit-field value based on
|
||||
------------+--------+--------+----------------------------
|
||||
H1 | 0 | 10 | volume serial number string
|
||||
| | | of system volume
|
||||
H1 | 10 | 10 | network adapter MAC address
|
||||
| | | string
|
||||
H1 | 20 | 7 | CD-ROM drive hardware
|
||||
| | | identification string
|
||||
H1 | 27 | 5 | graphics adapter hardware
|
||||
| | | identification string
|
||||
H2 | 0 | 3 | unused, set to 001
|
||||
H2 | 3 | 6 | CPU serial number string
|
||||
H2 | 9 | 7 | harddrive hardware
|
||||
| | | identification string
|
||||
H2 | 16 | 5 | SCSI host adapter hardware
|
||||
| | | identification string
|
||||
H2 | 21 | 4 | IDE controller hardware
|
||||
| | | identification string
|
||||
H2 | 25 | 3 | processor model string
|
||||
H2 | 28 | 3 | RAM size
|
||||
H2 | 31 | 1 | 1 = dockable
|
||||
| | | 0 = not dockable
|
||||
|
||||
Bit 31 of H2 specifies, whether the bit-fields represent a notebook
|
||||
computer that supports a docking station. If docking is possible, the
|
||||
activation mechanism will be more tolerant with respect to future
|
||||
hardware modifications. Here, the idea is that plugging a notebook
|
||||
into its docking station possibly results in changes to its hardware
|
||||
configuration, e.g. a SCSI host adapter built into the docking station
|
||||
may become available.
|
||||
|
||||
Bits 2 through 0 of H2 are unused and always set to 001.
|
||||
|
||||
If the hardware component corresponding to one of the remaining ten
|
||||
bit-fields is present, the respective bit-field contains a non-zero
|
||||
value describing the component. A value of zero marks the hardware
|
||||
component as not present.
|
||||
|
||||
All hardware components are identified by a hardware identification
|
||||
string obtained from the registry. Hashing this string provides the
|
||||
value for the corresponding bit-field.
|
||||
|
||||
>>>> Hashing
|
||||
|
||||
The hash result is obtained by feeding the hardware identification
|
||||
string into the MD5 message digest algorithm and picking the number of
|
||||
bits required for a bit-field from predetermined locations in the
|
||||
resulting message digest. Different predetermined locations are used
|
||||
for different bit-fields. In addition, a hash result of zero is
|
||||
avoided by calculating
|
||||
|
||||
Hash = (Hash % BitFieldMax) + 1
|
||||
|
||||
where BitFieldMax is the maximal value that may be stored in the
|
||||
bit-field in question, e.g. 1023 for a 10-bit bit-field, and 'x % y'
|
||||
denotes the remainder of the division of x by y. This results in
|
||||
values between 1 and BitFieldMax. The obtained value is then stored in
|
||||
the respective bit-field.
|
||||
|
||||
>>>> RAM bit-field
|
||||
|
||||
The bit-field related to the amount of RAM available to the operating
|
||||
system is calculated differently. The seven valid values specify the
|
||||
approximate amount of available RAM as documented in the following
|
||||
table.
|
||||
|
||||
value | amount of RAM available
|
||||
------+---------------------------
|
||||
0 | (bit-field unused)
|
||||
1 | below 32 MB
|
||||
2 | between 32 MB and 63 MB
|
||||
3 | between 64 MB and 127 MB
|
||||
4 | between 128 MB and 255 MB
|
||||
5 | between 256 MB and 511 MB
|
||||
6 | between 512 MB and 1023 MB
|
||||
7 | above 1023 MB
|
||||
|
||||
It is important to note that the amount of RAM is retrieved by calling
|
||||
the GlobalMemoryStatus() function, which reports a few hundred
|
||||
kilobytes less than the amount of RAM physically installed. So, 128 MB
|
||||
of RAM would typically be classified as "between 64 MB and 127 MB".
|
||||
|
||||
>>>> Real-world example
|
||||
|
||||
Let us have a look at a real-world example. On one of our test systems
|
||||
the hardware information consists of the following eight bytes.
|
||||
|
||||
0xC5 0x95 0x12 0xAC 0x01 0x6E 0x2C 0x32
|
||||
|
||||
Converting the bytes into H1 and H2, we obtain
|
||||
|
||||
H1 = 0xAC1295C5 and H2 = 0x322C6E01
|
||||
|
||||
Splitting H1 and H2 yields the next table in which we give the value
|
||||
of each of the bit-fields and the information from which each value is
|
||||
derived.
|
||||
|
||||
dw & | |
|
||||
offset | value | derived from
|
||||
-------+-------+-----------------------------------------------
|
||||
H1 0 | 0x1C5 | '1234-ABCD'
|
||||
H1 10 | 0x0A5 | '00C0DF089E44'
|
||||
H1 20 | 0x37 | 'SCSI\CDROMPLEXTOR_CD-ROM_PX-32TS__1.01'
|
||||
H1 27 | 0x15 | 'PCI\VEN_102B&DEV_0519&SUBSYS_00000000&REV_01'
|
||||
H2 0 | 0x1 | (unused, always 0x1)
|
||||
H2 3 | 0x00 | (CPU serial number not present)
|
||||
H2 9 | 0x37 | 'SCSI\DISKIBM_____DCAS-34330______S65A'
|
||||
H2 16 | 0x0C | 'PCI\VEN_9004&DEV_7178&SUBSYS_00000000&REV_03'
|
||||
H2 21 | 0x1 | 'PCI\VEN_8086&DEV_7111&SUBSYS_00000000&REV_01'
|
||||
H2 25 | 0x1 | 'GenuineIntel Family 6 Model 3'
|
||||
H2 28 | 0x3 | (system has 128 MB of RAM)
|
||||
H2 31 | 0x0 | (system is not dockable)
|
||||
|
||||
>>> Using XPDec
|
||||
|
||||
XPDec is a utility to be run from the command prompt. It may be
|
||||
invoked with one of four command line options to carry out one of four
|
||||
tasks.
|
||||
|
||||
>>>> XPDec -i
|
||||
|
||||
This option enables you to access the information hidden in an
|
||||
Installation ID. It decodes the Installation ID, decrypts it, and
|
||||
displays the values of the hardware bit-fields as well as the Product
|
||||
ID of your product. Keep in mind that the last three digits of the
|
||||
Product ID contained in the Installation ID are randomly selected and
|
||||
differ from the Product ID displayed by Internet Explorer.
|
||||
|
||||
The only argument needed for the '-i' option is the Installation ID,
|
||||
as in
|
||||
|
||||
XPDec -i 002666-077894-484890-114573-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XX
|
||||
|
||||
>>>> XPDec -p
|
||||
|
||||
To help you trace the origin of your Product ID, this option decodes a
|
||||
Product Key and displays the Raw Product Key as it would be used in a
|
||||
Product ID.
|
||||
|
||||
The only argument needed for the '-p' option is the Product Key, as in
|
||||
|
||||
XPDec -p FFFFF-GGGGG-HHHHH-JJJJJ-KKKKK
|
||||
|
||||
Note that this option does not verify the digital signature of the
|
||||
Product Key.
|
||||
|
||||
>>>> XPDec -v
|
||||
|
||||
This option calculates the hash of a given volume serial number. It
|
||||
was implemented to illustrate our description of string hashing. First
|
||||
use '-i' to display the hardware bit-fields. Then use this option to
|
||||
verify our claims concerning the volume serial number hash.
|
||||
|
||||
The only argument needed for the '-v' option is the volume serial
|
||||
number of your system volume, as in
|
||||
|
||||
XPDec -v 1234-ABCD
|
||||
|
||||
(The volume serial number is part of the 'dir' command's output.)
|
||||
|
||||
>>>> XPDec -m
|
||||
|
||||
This option calculates the network adapter bit-field value
|
||||
corresponding to the given MAC address. Similar to '-v' this option
|
||||
was implemented as a proof of concept.
|
||||
|
||||
The only argument needed for the '-m' option is the MAC address of
|
||||
your network adapter, as in
|
||||
|
||||
XPDec -m 00-C0-DF-08-9E-44
|
||||
|
||||
(Use the 'route print' command to obtain the MAC address of your
|
||||
network adapter.)
|
||||
|
||||
>> HARDWARE MODIFICATIONS
|
||||
|
||||
When looking at the effects of hardware modifications on an already
|
||||
activated installation of Windows XP, the file 'wpa.dbl' in the
|
||||
'system32' directory plays a central role. It is a simple
|
||||
RC4-encrypted database that stores, among other things like expiration
|
||||
information and the Confirmation ID of an activated installation,
|
||||
|
||||
a) the bit-field values representing the current hardware
|
||||
configuration,
|
||||
|
||||
and
|
||||
|
||||
b) the bit-field values representing the hardware configuration
|
||||
at the time of product activation.
|
||||
|
||||
While a) is automatically updated each time the hardware configuration
|
||||
is modified in order to reflect the changes, b) remains fixed. Hence,
|
||||
b) can be thought of as a snapshot of the hardware configuration at
|
||||
the time of product activation.
|
||||
|
||||
This snapshot does not exist in the database before product activation
|
||||
and if we compare the size of 'wpa.dbl' before and after activation,
|
||||
we will notice an increased file size. This is because the snapshot is
|
||||
added to the database.
|
||||
|
||||
When judging whether re-activation is necessary, the bit-field values
|
||||
of a) are compared to the bit-field values of b), i.e. the current
|
||||
hardware configuration is compared to the hardware configuration at
|
||||
the time of activation.
|
||||
|
||||
>>> Non-dockable computer
|
||||
|
||||
Typically all bit-fields with the exception of the unused field and
|
||||
the 'dockable' field are compared. If more than three of these ten
|
||||
bit-fields have changed in a) since product activation, re-activation
|
||||
is required.
|
||||
|
||||
This means, for example, that in our above real-world example, we
|
||||
could replace the harddrive and the CD-ROM drive and substantially
|
||||
upgrade our RAM without having to re-activate our Windows XP
|
||||
installation.
|
||||
|
||||
However, if we completely re-installed Windows XP, the information in
|
||||
b) would be lost and we would have to re-activate our installation,
|
||||
even if we had not changed our hardware.
|
||||
|
||||
>>> Dockable computer
|
||||
|
||||
If bit 31 of H2 indicates that our computer supports a docking
|
||||
station, however, only seven of the ten bit-fields mentioned above are
|
||||
compared. The bit-fields corresponding to the SCSI host adapter, the
|
||||
IDE controller, and the graphics board are omitted. But again, of
|
||||
these remaining seven bit-fields, only up to three may change without
|
||||
requiring re-activation.
|
||||
|
||||
>> CONCLUSIONS
|
||||
|
||||
In this paper we have given a technical overview of Windows Product
|
||||
Activation as implemented in Windows XP. We have shown what
|
||||
information the data transmitted during product activation is derived
|
||||
from and how hardware upgrades affect an already activated
|
||||
installation.
|
||||
|
||||
Looking at the technical details of WPA, we do not think that it is as
|
||||
problematic as many people have expected. We think so, because WPA is
|
||||
tolerant with respect to hardware modifications. In addition, it is
|
||||
likely that more than one hardware component map to a certain value
|
||||
for a given bit-field. From the above real-world example we know that
|
||||
the PX-32TS maps to the value 0x37 = 55. But there are probably many
|
||||
other CD-ROM drives that map to the same value. Hence, it is
|
||||
impossible to tell from the bit-field value whether it is a PX-32TS
|
||||
that we are using or one of the other drives that map to the same
|
||||
value.
|
||||
|
||||
In contrast to many critics of Windows Product Activation, we think
|
||||
that WPA does not prevent typical hardware modifications and,
|
||||
moreover, respects the user's right to privacy.
|
||||
|
||||
>> ABOUT THE AUTHORS
|
||||
|
||||
Fully Licensed GmbH is a start-up company focusing on novel approaches
|
||||
to online software licensing and distribution. Have a look at their
|
||||
website at
|
||||
|
||||
http://www.licenturion.com
|
||||
|
||||
for more information.
|
||||
|
||||
Their research branch every now and then analyzes licensing solutions
|
||||
implemented by other companies.
|
||||
|
||||
>> COPYRIGHT
|
||||
|
||||
Copyright (C) 2001 Fully Licensed GmbH (www.licenturion.com)
|
||||
All rights reserved.
|
||||
|
||||
You are free to do whatever you want with this paper. However, you
|
||||
have to supply the URL of its online version
|
||||
|
||||
http://www.licenturion.com/xp/
|
||||
|
||||
with any work derived from this paper to give credit to its authors.
|
557
main.cpp
557
main.cpp
@ -1,557 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/bn.h>
|
||||
|
||||
#include <openssl/ec.h>
|
||||
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#define FIELD_BITS 384
|
||||
|
||||
#define FIELD_BYTES 48
|
||||
|
||||
unsigned char cset[] = "BCDFGHJKMPQRTVWXY2346789";
|
||||
|
||||
static void unpack(unsigned long *pid, unsigned long *hash, unsigned long *sig, unsigned long *raw)
|
||||
|
||||
{
|
||||
|
||||
// pid = Bit 0..30
|
||||
|
||||
pid[0] = raw[0] & 0x7fffffff;
|
||||
|
||||
// hash(s) = Bit 31..58
|
||||
|
||||
hash[0] = ((raw[0] >> 31) | (raw[1] << 1)) & 0xfffffff;
|
||||
|
||||
// sig(e) = bit 58..113
|
||||
|
||||
sig[0] = (raw[1] >> 27) | (raw[2] << 5);
|
||||
|
||||
sig[1] = (raw[2] >> 27) | (raw[3] << 5);
|
||||
|
||||
}
|
||||
|
||||
static void pack(unsigned long *raw, unsigned long *pid, unsigned long *hash, unsigned long *sig)
|
||||
|
||||
{
|
||||
|
||||
raw[0] = pid[0] | ((hash[0] & 1) << 31);
|
||||
|
||||
raw[1] = (hash[0] >> 1) | ((sig[0] & 0x1f) << 27);
|
||||
|
||||
raw[2] = (sig[0] >> 5) | (sig[1] << 27);
|
||||
|
||||
raw[3] = sig[1] >> 5;
|
||||
|
||||
}
|
||||
|
||||
// Reverse data
|
||||
|
||||
static void endian(unsigned char *data, int len)
|
||||
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len/2; i++) {
|
||||
|
||||
unsigned char temp;
|
||||
|
||||
temp = data;
|
||||
|
||||
data = data[len-i-1];
|
||||
|
||||
data[len-i-1] = temp;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void unbase24(unsigned long *x, unsigned char *c)
|
||||
|
||||
{
|
||||
|
||||
memset(x, 0, 16);
|
||||
|
||||
int i, n;
|
||||
|
||||
BIGNUM *y = BN_new();
|
||||
|
||||
BN_zero(y);
|
||||
|
||||
for (i = 0; i < 25; i++)
|
||||
|
||||
{
|
||||
|
||||
BN_mul_word(y, 24);
|
||||
|
||||
BN_add_word(y, c);
|
||||
|
||||
}
|
||||
|
||||
n = BN_num_bytes(y);
|
||||
|
||||
BN_bn2bin(y, (unsigned char *)x);
|
||||
|
||||
BN_free(y);
|
||||
|
||||
endian((unsigned char *)x, n);
|
||||
|
||||
}
|
||||
|
||||
void base24(unsigned char *c, unsigned long *x)
|
||||
|
||||
{
|
||||
|
||||
unsigned char y[16];
|
||||
|
||||
int i;
|
||||
|
||||
BIGNUM *z;
|
||||
|
||||
// Convert x to BigNum z
|
||||
|
||||
memcpy(y, x, sizeof(y)); // Copy X to Y; Y=X
|
||||
|
||||
for (i = 15; y == 0; i--) {} i++; // skip following nulls
|
||||
|
||||
endian(y, i); // Reverse y
|
||||
|
||||
z = BN_bin2bn(y, i, NULL); // Convert y to BigNum z
|
||||
|
||||
// Divide z by 24 and convert remainder with cset to Base24-CDKEY Char
|
||||
|
||||
c[25] = 0;
|
||||
|
||||
for (i = 24; i >= 0; i--) {
|
||||
|
||||
unsigned char t = BN_div_word(z, 24);
|
||||
|
||||
c = cset[t];
|
||||
|
||||
}
|
||||
|
||||
BN_free(z);
|
||||
|
||||
}
|
||||
|
||||
void print_product_id(unsigned long *pid)
|
||||
|
||||
{
|
||||
|
||||
char raw[12];
|
||||
|
||||
char b[6], c[8];
|
||||
|
||||
int i, digit = 0;
|
||||
|
||||
// Cut a away last bit of pid and convert it to an accii-number (=raw)
|
||||
|
||||
sprintf(raw, "%d", pid[0] >> 1);
|
||||
|
||||
// Make b-part {640-....}
|
||||
|
||||
strncpy(b, raw, 3);
|
||||
|
||||
b[3] = 0;
|
||||
|
||||
// Make c-part {...-123456X...}
|
||||
|
||||
strcpy(c, raw + 3);
|
||||
|
||||
// Make checksum digit-part {...56X-}
|
||||
|
||||
assert(strlen© == 6);
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
|
||||
digit -= c - '0'; // Sum digits
|
||||
|
||||
while (digit < 0)
|
||||
|
||||
digit += 7;
|
||||
|
||||
c[6] = digit + '0';
|
||||
|
||||
c[7] = 0;
|
||||
|
||||
printf("Product ID: 55274-%s-%s-23xxx\n", b, c);
|
||||
|
||||
}
|
||||
|
||||
void print_product_key(unsigned char *pk)
|
||||
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
assert(strlen((const char *)pk) == 25);
|
||||
|
||||
for (i = 0; i < 25; i++) {
|
||||
|
||||
putchar(pk);
|
||||
|
||||
if (i != 24 && i % 5 == 4) putchar('-');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void verify(EC_GROUP *ec, EC_POINT *generator, EC_POINT *public_key, char *cdkey)
|
||||
|
||||
{
|
||||
|
||||
unsigned char key[25];
|
||||
|
||||
int i, j, k;
|
||||
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
|
||||
// remove Dashs from CDKEY
|
||||
|
||||
for (i = 0, k = 0; i < strlen(cdkey); i++) {
|
||||
|
||||
for (j = 0; j < 24; j++) {
|
||||
|
||||
if (cdkey != '-' && cdkey == cset[j]) {
|
||||
|
||||
key[k++] = j;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
assert(j < 24);
|
||||
|
||||
}
|
||||
|
||||
if (k >= 25) break;
|
||||
|
||||
}
|
||||
|
||||
// Base24_CDKEY -> Bin_CDKEY
|
||||
|
||||
unsigned long bkey[4] = {0};
|
||||
|
||||
unsigned long pid[1], hash[1], sig[2];
|
||||
|
||||
unbase24(bkey, key);
|
||||
|
||||
// Output Bin_CDKEY
|
||||
|
||||
printf("%.8x %.8x %.8x %.8x\n", bkey[3], bkey[2], bkey[1], bkey[0]);
|
||||
|
||||
// Divide/Extract pid_data, hash, sig from Bin_CDKEY
|
||||
|
||||
unpack(pid, hash, sig, bkey);
|
||||
|
||||
print_product_id(pid);
|
||||
|
||||
printf("PID: %.8x\nHash: %.8x\nSig: %.8x %.8x\n", pid[0], hash[0], sig[1], sig[0]);
|
||||
|
||||
BIGNUM *e, *s;
|
||||
|
||||
/* e = hash, s = sig */
|
||||
|
||||
e = BN_new();
|
||||
|
||||
BN_set_word(e, hash[0]);
|
||||
|
||||
endian((unsigned char *)sig, sizeof(sig));
|
||||
|
||||
s = BN_bin2bn((unsigned char *)sig, sizeof(sig), NULL);
|
||||
|
||||
BIGNUM *x = BN_new();
|
||||
|
||||
BIGNUM *y = BN_new();
|
||||
|
||||
EC_POINT *u = EC_POINT_new(ec);
|
||||
|
||||
EC_POINT *v = EC_POINT_new(ec);
|
||||
|
||||
/* v = s*generator + e*(-public_key) */
|
||||
|
||||
EC_POINT_mul(ec, u, NULL, generator, s, ctx);
|
||||
|
||||
EC_POINT_mul(ec, v, NULL, public_key, e, ctx);
|
||||
|
||||
EC_POINT_add(ec, v, u, v, ctx);
|
||||
|
||||
EC_POINT_get_affine_coordinates_GFp(ec, v, x, y, ctx);
|
||||
|
||||
unsigned char buf[FIELD_BYTES], md[20];
|
||||
|
||||
unsigned long h;
|
||||
|
||||
unsigned char t[4];
|
||||
|
||||
SHA_CTX h_ctx;
|
||||
|
||||
/* h = (fist 32 bits of SHA1(pid || v.x, v.y)) >> 4 */
|
||||
|
||||
SHA1_Init(&h_ctx);
|
||||
|
||||
t[0] = pid[0] & 0xff;
|
||||
|
||||
t[1] = (pid[0] & 0xff00) >> 8;
|
||||
|
||||
t[2] = (pid[0] & 0xff0000) >> 16;
|
||||
|
||||
t[3] = (pid[0] & 0xff000000) >> 24;
|
||||
|
||||
SHA1_Update(&h_ctx, t, sizeof(t));
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
BN_bn2bin(x, buf);
|
||||
|
||||
endian((unsigned char *)buf, sizeof(buf));
|
||||
|
||||
SHA1_Update(&h_ctx, buf, sizeof(buf));
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
BN_bn2bin(y, buf);
|
||||
|
||||
endian((unsigned char *)buf, sizeof(buf));
|
||||
|
||||
SHA1_Update(&h_ctx, buf, sizeof(buf));
|
||||
|
||||
SHA1_Final(md, &h_ctx);
|
||||
|
||||
h = (md[0] | (md[1] << 8) | (md[2] << 16) | (md[3] << 24)) >> 4;
|
||||
|
||||
h &= 0xfffffff;
|
||||
|
||||
printf("Calculated hash: %.8x\n", h);
|
||||
|
||||
if (h == hash[0]) printf("Key valid\n");
|
||||
|
||||
else printf("Key invalid\n");
|
||||
|
||||
putchar('\n');
|
||||
|
||||
BN_free(e);
|
||||
|
||||
BN_free(s);
|
||||
|
||||
BN_free(x);
|
||||
|
||||
BN_free(y);
|
||||
|
||||
EC_POINT_free(u);
|
||||
|
||||
EC_POINT_free(v);
|
||||
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
}
|
||||
|
||||
void generate(unsigned char *pkey, EC_GROUP *ec, EC_POINT *generator, BIGNUM *order, BIGNUM *priv, unsigned long *pid)
|
||||
|
||||
{
|
||||
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
|
||||
BIGNUM *k = BN_new();
|
||||
|
||||
BIGNUM *s = BN_new();
|
||||
|
||||
BIGNUM *x = BN_new();
|
||||
|
||||
BIGNUM *y = BN_new();
|
||||
|
||||
EC_POINT *r = EC_POINT_new(ec);
|
||||
|
||||
unsigned long bkey[4];
|
||||
|
||||
// Loop in case signaturepart will make cdkey(base-24 "digits") longer than 25
|
||||
|
||||
do {
|
||||
|
||||
BN_pseudo_rand(k, FIELD_BITS, -1, 0);
|
||||
|
||||
EC_POINT_mul(ec, r, NULL, generator, k, ctx);
|
||||
|
||||
EC_POINT_get_affine_coordinates_GFp(ec, r, x, y, ctx);
|
||||
|
||||
SHA_CTX h_ctx;
|
||||
|
||||
unsigned char t[4], md[20], buf[FIELD_BYTES];
|
||||
|
||||
unsigned long hash[1];
|
||||
|
||||
/* h = (fist 32 bits of SHA1(pid || r.x, r.y)) >> 4 */
|
||||
|
||||
SHA1_Init(&h_ctx);
|
||||
|
||||
t[0] = pid[0] & 0xff;
|
||||
|
||||
t[1] = (pid[0] & 0xff00) >> 8;
|
||||
|
||||
t[2] = (pid[0] & 0xff0000) >> 16;
|
||||
|
||||
t[3] = (pid[0] & 0xff000000) >> 24;
|
||||
|
||||
SHA1_Update(&h_ctx, t, sizeof(t));
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
BN_bn2bin(x, buf);
|
||||
|
||||
endian((unsigned char *)buf, sizeof(buf));
|
||||
|
||||
SHA1_Update(&h_ctx, buf, sizeof(buf));
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
BN_bn2bin(y, buf);
|
||||
|
||||
endian((unsigned char *)buf, sizeof(buf));
|
||||
|
||||
SHA1_Update(&h_ctx, buf, sizeof(buf));
|
||||
|
||||
SHA1_Final(md, &h_ctx);
|
||||
|
||||
hash[0] = (md[0] | (md[1] << 8) | (md[2] << 16) | (md[3] << 24)) >> 4;
|
||||
|
||||
hash[0] &= 0xfffffff;
|
||||
|
||||
/* s = priv*h + k */
|
||||
|
||||
BN_copy(s, priv);
|
||||
|
||||
BN_mul_word(s, hash[0]);
|
||||
|
||||
BN_mod_add(s, s, k, order, ctx);
|
||||
|
||||
unsigned long sig[2] = {0};
|
||||
|
||||
BN_bn2bin(s, (unsigned char *)sig);
|
||||
|
||||
endian((unsigned char *)sig, BN_num_bytes(s));
|
||||
|
||||
pack(bkey, pid, hash, sig);
|
||||
|
||||
printf("PID: %.8x\nHash: %.8x\nSig: %.8x %.8x\n", pid[0], hash[0], sig[1], sig[0]);
|
||||
|
||||
} while (bkey[3] >= 0x62a32);
|
||||
|
||||
base24(pkey, bkey);
|
||||
|
||||
BN_free(k);
|
||||
|
||||
BN_free(s);
|
||||
|
||||
BN_free(x);
|
||||
|
||||
BN_free(y);
|
||||
|
||||
EC_POINT_free®;
|
||||
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
|
||||
// Init
|
||||
|
||||
BIGNUM *a, *b, *p, *gx, *gy, *pubx, *puby, *n, *priv;
|
||||
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
|
||||
// make BigNumbers
|
||||
|
||||
a = BN_new();
|
||||
|
||||
b = BN_new();
|
||||
|
||||
p = BN_new();
|
||||
|
||||
gx = BN_new();
|
||||
|
||||
gy = BN_new();
|
||||
|
||||
pubx = BN_new();
|
||||
|
||||
puby = BN_new();
|
||||
|
||||
n = BN_new();
|
||||
|
||||
priv = BN_new();
|
||||
|
||||
// Data from pidgen-Bink-resources
|
||||
|
||||
/* Elliptic curve parameters: y^2 = x^3 + ax + b mod p */
|
||||
|
||||
BN_hex2bn(&p, "92ddcf14cb9e71f4489a2e9ba350ae29454d98cb93bdbcc07d62b502ea12238ee904a8b20d017197aae0c103b32713a9");
|
||||
|
||||
BN_set_word(a, 1);
|
||||
|
||||
BN_set_word(b, 0);
|
||||
|
||||
/* base point (generator) G */
|
||||
|
||||
BN_hex2bn(&gx, "46E3775ECE21B0898D39BEA57050D422A0AF989E497962BAEE2CB17E0A28D5360D5476B8DC966443E37A14F1AEF37742");
|
||||
|
||||
BN_hex2bn(&gy, "7C8E741D2C34F4478E325469CD491603D807222C9C4AC09DDB2B31B3CE3F7CC191B3580079932BC6BEF70BE27604F65E");
|
||||
|
||||
/* inverse of public key */
|
||||
|
||||
BN_hex2bn(&pubx, "5D8DBE75198015EC41C45AAB6143542EB098F6A5CC9CE4178A1B8A1E7ABBB5BC64DF64FAF6177DC1B0988AB00BA94BF8");
|
||||
|
||||
BN_hex2bn(&puby, "23A2909A0B4803C89F910C7191758B48746CEA4D5FF07667444ACDB9512080DBCA55E6EBF30433672B894F44ACE92BFA");
|
||||
|
||||
// Computed data
|
||||
|
||||
/* order of G - computed in 18 hours using a P3-450 */
|
||||
|
||||
BN_hex2bn(&n, "DB6B4C58EFBAFD");
|
||||
|
||||
/* THE private key - computed in 10 hours using a P3-450 */
|
||||
|
||||
BN_hex2bn(&priv, "565B0DFF8496C8");
|
||||
|
||||
// Calculation
|
||||
|
||||
EC_GROUP *ec = EC_GROUP_new_curve_GFp(p, a, b, ctx);
|
||||
|
||||
EC_POINT *g = EC_POINT_new(ec);
|
||||
|
||||
EC_POINT_set_affine_coordinates_GFp(ec, g, gx, gy, ctx);
|
||||
|
||||
EC_POINT *pub = EC_POINT_new(ec);
|
||||
|
||||
EC_POINT_set_affine_coordinates_GFp(ec, pub, pubx, puby, ctx);
|
||||
|
||||
unsigned char pkey[26];
|
||||
|
||||
unsigned long pid[1];
|
||||
|
||||
pid[0] = 640000000 << 1; /* <- change */
|
||||
|
||||
// generate a key
|
||||
|
||||
generate(pkey, ec, g, n, priv, pid);
|
||||
|
||||
print_product_key(pkey); printf("\n\n");
|
||||
|
||||
// verify the key
|
||||
|
||||
verify(ec, g, pub, (char*)pkey);
|
||||
|
||||
// Cleanup
|
||||
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
432
src/cli.cpp
Normal file
432
src/cli.cpp
Normal file
@ -0,0 +1,432 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Andrew on 01/06/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "cli.h"
|
||||
|
||||
// define static storage
|
||||
Options CLI::options;
|
||||
json CLI::keys;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param argcIn
|
||||
* @param argvIn
|
||||
* @return exit status (where success is 0)
|
||||
*/
|
||||
BYTE CLI::Init(int argcIn, char **argvIn)
|
||||
{
|
||||
// set default options
|
||||
options = {argcIn, argvIn, "2E", "", "", "", "", "", "WINXP", "PROVLK", 0,
|
||||
0, 1, false, false, false, false, false, false, false, PIDGEN_3, STATE_PIDGEN_GENERATE};
|
||||
|
||||
SetHelpText();
|
||||
|
||||
BOOL success = parseCommandLine();
|
||||
if (!success)
|
||||
{
|
||||
return options.error;
|
||||
}
|
||||
|
||||
// if we displayed help, without an error
|
||||
// return success
|
||||
if (options.help)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
success = processOptions();
|
||||
if (!success)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param filename
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::loadJSON(const fs::path &filename)
|
||||
{
|
||||
if (filename.empty())
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Loading internal keys file\n");
|
||||
}
|
||||
|
||||
auto retval = loadEmbeddedJSON();
|
||||
|
||||
if (retval && options.verbose)
|
||||
{
|
||||
fmt::print("Loaded internal keys file successfully\n\n");
|
||||
}
|
||||
else if (!retval)
|
||||
{
|
||||
fmt::print("Error loading internal keys file...\n\n");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (!fs::exists(filename))
|
||||
{
|
||||
fmt::print("ERROR: File {} does not exist\n", filename.string());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Loading keys file {}\n", options.keysFilename);
|
||||
}
|
||||
|
||||
std::ifstream f(filename);
|
||||
try
|
||||
{
|
||||
keys = json::parse(f, nullptr, false, false);
|
||||
}
|
||||
catch (const json::exception &e)
|
||||
{
|
||||
fmt::print("ERROR: Exception thrown while parsing {}: {}\n", filename.string(), e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (keys.is_discarded())
|
||||
{
|
||||
fmt::print("ERROR: Unable to parse keys from {}\n", filename.string());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Loaded keys from {} successfully\n", options.keysFilename);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pid
|
||||
*/
|
||||
void CLI::printID(DWORD *pid)
|
||||
{
|
||||
char raw[12], b[6], c[8];
|
||||
char i, digit = 0;
|
||||
|
||||
// Convert PID to ascii-number (=raw)
|
||||
snprintf(raw, sizeof(raw), "%09lu", pid[0]);
|
||||
|
||||
// Make b-part {640-....}
|
||||
_strncpy(b, 6, &raw[0], 3);
|
||||
b[3] = 0;
|
||||
|
||||
// Make c-part {...-123456X...}
|
||||
_strcpy(c, &raw[3]);
|
||||
|
||||
// Make checksum digit-part {...56X-}
|
||||
assert(strlen(c) == 6);
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
digit += c[i] - '0'; // Sum digits
|
||||
}
|
||||
|
||||
digit %= 7;
|
||||
if (digit > 0)
|
||||
{
|
||||
digit = 7 - digit;
|
||||
}
|
||||
|
||||
c[6] = digit + '0';
|
||||
c[7] = 0;
|
||||
|
||||
DWORD binkid;
|
||||
_sscanf(options.binkID.c_str(), "%lx", &binkid);
|
||||
binkid /= 2;
|
||||
|
||||
fmt::print("> Product ID: PPPPP-{}-{}-{}xxx\n", b, c, binkid);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pidgen3
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::InitPIDGEN3(PIDGEN3 &pidgen3)
|
||||
{
|
||||
const char *BINKID = &options.binkID[0];
|
||||
auto bink = keys["BINK"][BINKID];
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("{:->80}\n", "");
|
||||
fmt::print("Loaded the following elliptic curve parameters: BINK[{}]\n", BINKID);
|
||||
fmt::print("{:->80}\n", "");
|
||||
fmt::print("{:>6}: {}\n", "P", bink["p"]);
|
||||
fmt::print("{:>6}: {}\n", "a", bink["a"]);
|
||||
fmt::print("{:>6}: {}\n", "b", bink["b"]);
|
||||
fmt::print("{:>6}: [{},\n{:>9}{}]\n", "G[x,y]", bink["g"]["x"], "", bink["g"]["y"]);
|
||||
fmt::print("{:>6}: [{},\n{:>9}{}]\n", "K[x,y]", bink["pub"]["x"], "", bink["pub"]["y"]);
|
||||
fmt::print("{:>6}: {}\n", "n", bink["n"]);
|
||||
fmt::print("{:>6}: {}\n", "k", bink["priv"]);
|
||||
fmt::print("\n");
|
||||
}
|
||||
|
||||
pidgen3.LoadEllipticCurve(bink["p"], bink["a"], bink["b"], bink["g"]["x"], bink["g"]["y"], bink["pub"]["x"],
|
||||
bink["pub"]["y"], bink["n"], bink["priv"]);
|
||||
|
||||
if (options.state != STATE_PIDGEN_GENERATE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
pidgen3.info.setChannelID(options.channelID);
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("> Channel ID: {:03d}\n", options.channelID);
|
||||
}
|
||||
|
||||
if (options.serialSet)
|
||||
{
|
||||
pidgen3.info.setSerial(options.serial);
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("> Serial {:#09d}\n", options.serial);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param confid
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::InitConfirmationID(ConfirmationID &confid)
|
||||
{
|
||||
auto ctx = BN_CTX_new();
|
||||
BIGNUM *pkey = BN_CTX_get(ctx), *nonresidue = BN_CTX_get(ctx), *modulous = BN_CTX_get(ctx);
|
||||
BIGNUM *fvals[6];
|
||||
QWORD fvalsq[6];
|
||||
|
||||
if (!keys["products"][options.productCode].contains("meta") ||
|
||||
!keys["products"][options.productCode]["meta"].contains("activation"))
|
||||
{
|
||||
fmt::print("ERROR: product flavour {} does not have known activation values", options.productCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto meta = keys["products"][options.productCode]["meta"]["activation"];
|
||||
|
||||
if (!keys["activation"].contains(meta["flavour"]))
|
||||
{
|
||||
fmt::print("ERROR: {} is an unknown activation flavour", meta["flavour"]);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto flavour = keys["activation"][meta["flavour"]];
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("{:->80}\n", "");
|
||||
fmt::print("Loaded the following hyperelliptic curve parameters: activation[{}]\n", meta["flavour"]);
|
||||
fmt::print("{:->80}\n", "");
|
||||
fmt::print("{:>7}: {}\n", "name", flavour["name"]);
|
||||
fmt::print("{:>7}: {}\n", "version", meta["version"]);
|
||||
fmt::print("{:>7}: {}\n", "Fp", flavour["p"]);
|
||||
fmt::print("{:>7}: [{}, {}, {},\n{:>10}{}, {}, {}]\n", "F[]", flavour["x"]["0"], flavour["x"]["1"],
|
||||
flavour["x"]["2"], "", flavour["x"]["3"], flavour["x"]["4"], flavour["x"]["5"]);
|
||||
fmt::print("{:>7}: {}\n", "INV", flavour["quotient"]);
|
||||
fmt::print("{:>7}: {}\n", "mqnr", flavour["non_residue"]);
|
||||
fmt::print("{:>7}: {}\n", "k", flavour["priv"]);
|
||||
fmt::print("{:>7}: {}\n", "IID", flavour["iid_key"]);
|
||||
fmt::print("\n");
|
||||
}
|
||||
|
||||
for (BYTE i = 0; i < 6; i++)
|
||||
{
|
||||
fvals[i] = BN_CTX_get(ctx);
|
||||
auto xval = flavour["x"][fmt::format("{}", i)].get<std::string>();
|
||||
BN_dec2bn(&fvals[i], xval.c_str());
|
||||
UMSKT::BN_bn2lebin(fvals[i], (unsigned char *)&fvalsq[i], sizeof(*fvalsq));
|
||||
}
|
||||
|
||||
// confid.LoadHyperellipticCurve(fvals, );
|
||||
|
||||
BN_CTX_free(ctx);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::PIDGENGenerate()
|
||||
{
|
||||
// TODO:
|
||||
// if options.pidgen2generate
|
||||
// return pidgen2generate
|
||||
// otherwise...
|
||||
|
||||
const char *BINKID = &options.binkID[0];
|
||||
auto bink = keys["BINK"][BINKID];
|
||||
|
||||
std::string key;
|
||||
bink["p"].get_to(key);
|
||||
|
||||
if (PIDGEN3::checkFieldStrIsBink1998(key))
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Detected a BINK1998 key\n");
|
||||
}
|
||||
|
||||
auto bink1998 = BINK1998();
|
||||
InitPIDGEN3(bink1998);
|
||||
return BINK1998Generate(bink1998);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Detected a BINK2002 key\n");
|
||||
}
|
||||
auto bink2002 = BINK2002();
|
||||
InitPIDGEN3(bink2002);
|
||||
return BINK2002Generate(bink2002);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return isValid
|
||||
*/
|
||||
BOOL CLI::PIDGENValidate()
|
||||
{
|
||||
// TODO:
|
||||
// if options.pidgen2validate
|
||||
// return pidgen2validate
|
||||
// otherwise...
|
||||
|
||||
const char *BINKID = &options.binkID[0];
|
||||
auto bink = keys["BINK"][BINKID];
|
||||
|
||||
std::string key;
|
||||
bink["p"].get_to(key);
|
||||
|
||||
if (PIDGEN3::checkFieldStrIsBink1998(key))
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Detected a BINK1998 key\n");
|
||||
}
|
||||
auto bink1998 = BINK1998();
|
||||
InitPIDGEN3(bink1998);
|
||||
return BINK1998Validate(bink1998);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Detected a BINK2002 key\n");
|
||||
}
|
||||
auto bink2002 = BINK2002();
|
||||
InitPIDGEN3(bink2002);
|
||||
return BINK2002Validate(bink2002);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process application state
|
||||
*
|
||||
* @return application status code
|
||||
*/
|
||||
int CLI::Run()
|
||||
{
|
||||
/**
|
||||
* TODO: we should be checking if the system's pseudorandom facilities work
|
||||
* before attempting generation, validation does not require entropy
|
||||
*/
|
||||
switch (options.state)
|
||||
{
|
||||
case STATE_PIDGEN_GENERATE:
|
||||
return PIDGENGenerate();
|
||||
|
||||
case STATE_PIDGEN_VALIDATE:
|
||||
return PIDGENValidate();
|
||||
|
||||
case STATE_CONFIRMATION_ID:
|
||||
return ConfirmationIDGenerate();
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a product key to stdout
|
||||
*
|
||||
* @param pk std::string to print
|
||||
*/
|
||||
void CLI::printKey(std::string &pk)
|
||||
{
|
||||
assert(pk.length() >= PK_LENGTH);
|
||||
|
||||
fmt::print("{}-{}-{}-{}-{}", pk.substr(0, 5), pk.substr(5, 5), pk.substr(10, 5), pk.substr(15, 5),
|
||||
pk.substr(20, 5));
|
||||
}
|
||||
|
||||
/**
|
||||
* std::BinaryOperation compatible accumulator for validating/stripping an input string against the PIDGEN3 charset
|
||||
* this can be moved to the PIDGEN3 at a later date
|
||||
*
|
||||
* @param accumulator
|
||||
* @param currentChar
|
||||
* @return
|
||||
*/
|
||||
std::string CLI::validateInputKeyCharset(std::string &accumulator, char currentChar)
|
||||
{
|
||||
char cchar = ::toupper(currentChar);
|
||||
if (std::find(std::begin(PIDGEN3::pKeyCharset), std::end(PIDGEN3::pKeyCharset), cchar) !=
|
||||
std::end(PIDGEN3::pKeyCharset))
|
||||
{
|
||||
accumulator.push_back(cchar);
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param in_key
|
||||
* @param out_key
|
||||
* @return
|
||||
*/
|
||||
BOOL CLI::stripKey(const std::string &in_key, std::string &out_key)
|
||||
{
|
||||
// copy out the product key stripping out extraneous characters
|
||||
out_key = std::accumulate(in_key.begin(), in_key.end(), std::string(), validateInputKeyCharset);
|
||||
|
||||
// only return true if we've handled exactly PK_LENGTH chars
|
||||
return (out_key.length() == PK_LENGTH);
|
||||
}
|
207
src/cli.h
Normal file
207
src/cli.h
Normal file
@ -0,0 +1,207 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/06/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_CLI_H
|
||||
#define UMSKT_CLI_H
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/color.h>
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/ostream.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
// fmt <-> json linkage
|
||||
template <> struct fmt::formatter<json> : ostream_formatter
|
||||
{
|
||||
auto format(const json &j, format_context &ctx) const
|
||||
{
|
||||
if (j.is_string())
|
||||
{
|
||||
return formatter<string_view>::format(j.get<std::string>(), ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
return basic_ostream_formatter<char>::format(j, ctx);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#include "help.h"
|
||||
#include "libumskt/confid/confid.h"
|
||||
#include "libumskt/libumskt.h"
|
||||
#include "libumskt/pidgen2/PIDGEN2.h"
|
||||
#include "libumskt/pidgen3/BINK1998.h"
|
||||
#include "libumskt/pidgen3/BINK2002.h"
|
||||
#include "libumskt/pidgen3/PIDGEN3.h"
|
||||
|
||||
#ifndef UMSKTCLI_VERSION_STRING
|
||||
#define UMSKTCLI_VERSION_STRING "unknown version-dirty"
|
||||
#endif
|
||||
|
||||
enum APPLICATION_STATE
|
||||
{
|
||||
STATE_PIDGEN_GENERATE,
|
||||
STATE_PIDGEN_VALIDATE,
|
||||
STATE_CONFIRMATION_ID
|
||||
};
|
||||
|
||||
enum PIDGEN_VERSION
|
||||
{
|
||||
PIDGEN_2 = 2,
|
||||
PIDGEN_3 = 3,
|
||||
};
|
||||
|
||||
struct Options
|
||||
{
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
std::string binkID;
|
||||
std::string keysFilename;
|
||||
std::string installationID;
|
||||
std::string keyToCheck;
|
||||
std::string productID;
|
||||
std::string authInfo;
|
||||
std::string productCode;
|
||||
std::string productFlavour;
|
||||
|
||||
DWORD channelID;
|
||||
DWORD serial;
|
||||
DWORD numKeys;
|
||||
|
||||
BOOL oem;
|
||||
BOOL upgrade;
|
||||
BOOL serialSet;
|
||||
BOOL verbose;
|
||||
BOOL help;
|
||||
BOOL error;
|
||||
BOOL list;
|
||||
|
||||
struct Meta
|
||||
{
|
||||
std::string type;
|
||||
std::vector<std::string> tags;
|
||||
struct Activation
|
||||
{
|
||||
std::string flavour;
|
||||
int version;
|
||||
};
|
||||
};
|
||||
|
||||
PIDGEN3::KeyInfo info;
|
||||
|
||||
PIDGEN_VERSION pidgenversion;
|
||||
APPLICATION_STATE state;
|
||||
};
|
||||
|
||||
class CLI
|
||||
{
|
||||
std::string pKey;
|
||||
DWORD count, total, iBinkID;
|
||||
|
||||
static Options options;
|
||||
|
||||
public:
|
||||
CLI()
|
||||
{
|
||||
count = 0;
|
||||
total = options.numKeys;
|
||||
}
|
||||
|
||||
static std::array<CLIHelpOptions, CLIHelpOptionID_END> helpOptions;
|
||||
static json keys;
|
||||
|
||||
static BYTE Init(int argv, char *argc[]);
|
||||
static void SetHelpText();
|
||||
|
||||
static BOOL loadJSON(const fs::path &filename);
|
||||
static BOOL loadEmbeddedJSON();
|
||||
|
||||
static CLIHandlerFunc DisplayHelp;
|
||||
static CLIHandlerFunc DisplayErrorMessage;
|
||||
static CLIHandlerFunc SetVerboseOption;
|
||||
static CLIHandlerFunc SetDebugOption;
|
||||
static CLIHandlerFunc SetListOption;
|
||||
static CLIHandlerFunc SetOEMOption;
|
||||
static CLIHandlerFunc SetUpgradeOption;
|
||||
static CLIHandlerFunc SetFileOption;
|
||||
static CLIHandlerFunc SetNumberOption;
|
||||
static CLIHandlerFunc SetChannelIDOption;
|
||||
static CLIHandlerFunc SetBINKOption;
|
||||
static CLIHandlerFunc SetSerialOption;
|
||||
static CLIHandlerFunc SetActivationIDOption;
|
||||
static CLIHandlerFunc SetProductIDOption;
|
||||
static CLIHandlerFunc SetValidateOption;
|
||||
static CLIHandlerFunc SetProductCodeOption;
|
||||
static CLIHandlerFunc SetFlavourOption;
|
||||
|
||||
static BOOL parseCommandLine();
|
||||
static BOOL processOptions();
|
||||
static void printID(DWORD *pid);
|
||||
static void printKey(std::string &pk);
|
||||
static BOOL stripKey(const std::string &in_key, std::string &out_key);
|
||||
static std::string validateInputKeyCharset(std::string &accumulator, char currentChar);
|
||||
|
||||
BOOL InitPIDGEN3(PIDGEN3 &pidgen3);
|
||||
BOOL InitConfirmationID(ConfirmationID &confid);
|
||||
|
||||
BOOL PIDGENGenerate();
|
||||
BOOL PIDGENValidate();
|
||||
|
||||
BOOL PIDGEN2Generate(PIDGEN2 &pidgen2);
|
||||
BOOL PIDGEN2Validate(PIDGEN2 &pidgen2);
|
||||
BOOL BINK1998Generate(PIDGEN3 &pidgen3);
|
||||
BOOL BINK1998Validate(PIDGEN3 &pidgen3);
|
||||
BOOL BINK2002Generate(PIDGEN3 &pidgen3);
|
||||
BOOL BINK2002Validate(PIDGEN3 &pidgen3);
|
||||
BOOL ConfirmationIDGenerate();
|
||||
|
||||
INLINE static std::string strtolower(std::string &in)
|
||||
{
|
||||
auto retval = std::string(in);
|
||||
std::transform(retval.begin(), retval.end(), retval.begin(), ::tolower);
|
||||
return retval;
|
||||
}
|
||||
|
||||
INLINE static std::string strtoupper(std::string &in)
|
||||
{
|
||||
auto retval = std::string(in);
|
||||
std::transform(retval.begin(), retval.end(), retval.begin(), ::toupper);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int Run();
|
||||
};
|
||||
|
||||
#endif // UMSKT_CLI_H
|
271
src/generate.cpp
Normal file
271
src/generate.cpp
Normal file
@ -0,0 +1,271 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 01/05/2024
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "cli.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pidgen2
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::PIDGEN2Generate(PIDGEN2 &pidgen2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pidgen2
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::PIDGEN2Validate(PIDGEN2 &pidgen2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::BINK1998Generate(PIDGEN3 &pidgen3)
|
||||
{
|
||||
// raw PID/serial value
|
||||
DWORD nRaw = options.channelID * 1'000'000;
|
||||
DWORD serialRnd;
|
||||
|
||||
if (options.serialSet)
|
||||
{
|
||||
// using user-provided serial
|
||||
serialRnd = options.serial;
|
||||
}
|
||||
else
|
||||
{
|
||||
// generate a random number to use as a serial
|
||||
serialRnd = UMSKT::getRandom<DWORD>();
|
||||
}
|
||||
|
||||
// make sure it's less than 999999
|
||||
nRaw += (serialRnd % 999999);
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
// print the resulting Product ID
|
||||
// PID value is printed in BINK1998::Generate
|
||||
printID(&nRaw);
|
||||
}
|
||||
|
||||
for (int i = 0; i < total; i++)
|
||||
{
|
||||
pidgen3.info.setSerial(nRaw);
|
||||
pidgen3.Generate(pKey);
|
||||
|
||||
bool isValid = pidgen3.Validate(pKey);
|
||||
if (isValid)
|
||||
{
|
||||
printKey(pKey);
|
||||
if (i <= total - 1 || options.verbose)
|
||||
{
|
||||
fmt::print("\n");
|
||||
}
|
||||
count += isValid;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
printKey(pKey);
|
||||
fmt::print(" [Invalid]");
|
||||
if (i <= total - 1)
|
||||
{
|
||||
fmt::print("\n");
|
||||
}
|
||||
}
|
||||
total++; // queue a redo, basically
|
||||
}
|
||||
}
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("\nSuccess count: {}/{}\n", count, total);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::BINK1998Validate(PIDGEN3 &bink1998)
|
||||
{
|
||||
std::string product_key;
|
||||
|
||||
if (!CLI::stripKey(options.keyToCheck, product_key))
|
||||
{
|
||||
fmt::print("ERROR: Product key is in an incorrect format!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
CLI::printKey(product_key);
|
||||
fmt::print("\n");
|
||||
if (!bink1998.Validate(product_key))
|
||||
{
|
||||
fmt::print("ERROR: Product key is invalid! Wrong BINK ID?\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
fmt::print("Key validated successfully!\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::BINK2002Generate(PIDGEN3 &pidgen3)
|
||||
{
|
||||
// generate a key
|
||||
for (int i = 0; i < total; i++)
|
||||
{
|
||||
pidgen3.info.AuthInfo = UMSKT::getRandom<DWORD>() & BITMASK(10);
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("> AuthInfo: {:#08x}\n", pidgen3.info.AuthInfo);
|
||||
}
|
||||
|
||||
pidgen3.Generate(pKey);
|
||||
|
||||
bool isValid = pidgen3.Validate(pKey);
|
||||
if (isValid)
|
||||
{
|
||||
CLI::printKey(pKey);
|
||||
if (i <= total - 1 || options.verbose)
|
||||
{ // check if end of list or verbose
|
||||
fmt::print("\n");
|
||||
}
|
||||
count += isValid; // add to count
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
CLI::printKey(pKey); // print the key
|
||||
fmt::print(" [Invalid]"); // and add " [Invalid]" to the key
|
||||
if (i <= total - 1)
|
||||
{ // check if end of list
|
||||
fmt::print("\n");
|
||||
}
|
||||
}
|
||||
total++; // queue a redo, basically
|
||||
}
|
||||
}
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("\nSuccess count: {}/{}\n", count, total);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::BINK2002Validate(PIDGEN3 &pidgen3)
|
||||
{
|
||||
std::string product_key;
|
||||
|
||||
if (!CLI::stripKey(options.keyToCheck, product_key))
|
||||
{
|
||||
fmt::print("ERROR: Product key is in an incorrect format!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
CLI::printKey(product_key);
|
||||
fmt::print("\n");
|
||||
if (!pidgen3.Validate(product_key))
|
||||
{
|
||||
fmt::print("ERROR: Product key is invalid! Wrong BINK ID?\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
fmt::print("Key validated successfully!\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::ConfirmationIDGenerate()
|
||||
{
|
||||
auto confid = ConfirmationID();
|
||||
std::string confirmation_id;
|
||||
|
||||
if (!InitConfirmationID(confid))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD err = confid.Generate(options.installationID, confirmation_id, options.productID);
|
||||
|
||||
if (err == SUCCESS)
|
||||
{
|
||||
fmt::print("{}\n", confirmation_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (err)
|
||||
{
|
||||
case ERR_TOO_SHORT:
|
||||
fmt::print("ERROR: Installation ID is too short.\n");
|
||||
break;
|
||||
|
||||
case ERR_TOO_LARGE:
|
||||
fmt::print("ERROR: Installation ID is too long.\n");
|
||||
break;
|
||||
|
||||
case ERR_INVALID_CHARACTER:
|
||||
fmt::print("ERROR: Invalid character in installation ID.\n");
|
||||
break;
|
||||
|
||||
case ERR_INVALID_CHECK_DIGIT:
|
||||
fmt::print("ERROR: Installation ID checksum failed. Please check that it is typed correctly.\n");
|
||||
break;
|
||||
|
||||
case ERR_UNKNOWN_VERSION:
|
||||
fmt::print("ERROR: Unknown installation ID version.\n");
|
||||
break;
|
||||
|
||||
case ERR_UNLUCKY:
|
||||
fmt::print("ERROR: Unable to generate valid confirmation ID.\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
fmt::print("Unknown error occurred during Confirmation ID generation: {}\n", err);
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
595
src/help.cpp
Normal file
595
src/help.cpp
Normal file
@ -0,0 +1,595 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 01/02/2024
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "cli.h"
|
||||
|
||||
// define static storage
|
||||
std::array<CLIHelpOptions, CLIHelpOptionID_END> CLI::helpOptions;
|
||||
|
||||
void CLI::SetHelpText()
|
||||
{
|
||||
helpOptions[OPTION_HELP] = {"h", "help", "show this help text", false, "", &DisplayHelp};
|
||||
helpOptions[OPTION_HELP2] = {"?", "", "show this help text", false, "", &DisplayHelp};
|
||||
|
||||
helpOptions[OPTION_VERSION] = {"", "version", "show UMSKT CLI / libumskt versions", false, "", nullptr};
|
||||
|
||||
helpOptions[OPTION_VERBOSE] = {"v", "verbose", "enable verbose output", false, "", &SetVerboseOption};
|
||||
|
||||
helpOptions[OPTION_DEBUG] = {"d", "debug", "enable debug output", false, "", &SetDebugOption};
|
||||
|
||||
helpOptions[OPTION_FILE] = {
|
||||
"F", "file", "(advanced) specify which keys JSON file to load", true, "[embedded file]", &SetFileOption};
|
||||
|
||||
helpOptions[OPTION_LIST] = {"l", "list", "list supported products", false, "", &SetListOption};
|
||||
|
||||
helpOptions[OPTION_PRODUCT] = {"p", "product", "[REQUIRED] which product to generate keys for",
|
||||
true, options.productCode, &SetProductCodeOption};
|
||||
|
||||
helpOptions[OPTION_FLAVOUR] = {
|
||||
"f", "flavour", "which product flavour to generate keys for (required in some instances)",
|
||||
true, "", &SetFlavourOption};
|
||||
|
||||
helpOptions[OPTION_NUMBER] = {"n", "number", "(PIDGEN only) number of keys to generate",
|
||||
true, "1", &SetNumberOption};
|
||||
|
||||
helpOptions[OPTION_ACTIVATIONID] = {
|
||||
"i", "installationID", "(activation only) installation ID used to generate confirmation ID", true,
|
||||
"", &SetActivationIDOption};
|
||||
|
||||
helpOptions[OPTION_ACTIVATIONPID] = {
|
||||
"P", "productID", "(Office activation only) product ID to generate confirmation ID for",
|
||||
true, "", &SetProductIDOption};
|
||||
|
||||
helpOptions[OPTION_OEM] = {"O", "oem", "(PIDGEN) generate an OEM key", false, "", &SetOEMOption};
|
||||
|
||||
helpOptions[OPTION_UPGRADE] = {"U", "upgrade", "(PIDGEN 3 only) generate an upgrade key",
|
||||
false, "", &SetUpgradeOption};
|
||||
|
||||
helpOptions[OPTION_BINK] = {"b", "binkID", "(advanced) override which BINK identifier to load",
|
||||
true, "", &SetBINKOption};
|
||||
|
||||
helpOptions[OPTION_CHANNELID] = {"c", "channelid", "(advanced) override which product channel to use",
|
||||
true, "", &SetChannelIDOption};
|
||||
|
||||
helpOptions[OPTION_SERIAL] = {
|
||||
"s", "serial", "(advanced, PIDGEN 2/3 [BINK 1998] only) specify a serial to generate",
|
||||
true, "", &SetSerialOption};
|
||||
|
||||
helpOptions[OPTION_AUTHDATA] = {
|
||||
"a", "authdata", "(advanced, PIDGEN 3 [BINK 2002] only) specify a value for the authentication data field",
|
||||
true, "", nullptr};
|
||||
|
||||
helpOptions[OPTION_VALIDATE] = {
|
||||
"V", "validate", "validate a specified product ID against known BINKs and algorithms",
|
||||
true, "", &SetValidateOption};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::parseCommandLine()
|
||||
{
|
||||
for (DWORD i = 1; i < options.argc; i++)
|
||||
{
|
||||
std::string arg = options.argv[i];
|
||||
|
||||
if (arg[0] == '-' || arg[0] == '/')
|
||||
{
|
||||
arg.erase(0, 1 + (arg[1] == '-' ? 1 : 0));
|
||||
}
|
||||
|
||||
if (arg.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (BYTE j = 0; j < CLIHelpOptionID_END; j++)
|
||||
{
|
||||
auto thisOption = helpOptions[j];
|
||||
if (arg != thisOption.Short && arg != thisOption.Long)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string nextarg;
|
||||
if (thisOption.hasArguments)
|
||||
{
|
||||
if (i == options.argc - 1)
|
||||
{
|
||||
options.error = true;
|
||||
goto CommandLineParseEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
nextarg = std::string(options.argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (thisOption.handler == nullptr)
|
||||
{
|
||||
// prevent accidental segmentation faults
|
||||
continue;
|
||||
}
|
||||
|
||||
auto success = thisOption.handler(1, &nextarg[0]);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
options.error = true;
|
||||
goto CommandLineParseEnd;
|
||||
}
|
||||
if (options.help)
|
||||
{
|
||||
goto CommandLineParseEnd;
|
||||
}
|
||||
goto ParseNextCommandLineOption;
|
||||
}
|
||||
|
||||
fmt::print("unknown option: {}\n", arg);
|
||||
options.error = true;
|
||||
goto CommandLineParseEnd;
|
||||
|
||||
ParseNextCommandLineOption:
|
||||
continue;
|
||||
}
|
||||
|
||||
CommandLineParseEnd:
|
||||
if (options.error)
|
||||
{
|
||||
DisplayErrorMessage(0, nullptr);
|
||||
}
|
||||
return !options.error;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::processOptions()
|
||||
{
|
||||
if (!loadJSON(options.keysFilename))
|
||||
{
|
||||
options.error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.list)
|
||||
{
|
||||
// the following code is absolutely unhinged
|
||||
// I'm so sorry
|
||||
|
||||
#if defined(__UNICODE__) || defined(__GNUC__)
|
||||
auto *leaf = "\u251C", *last = "\u2514", *line = "\u2500";
|
||||
#else
|
||||
auto *leaf = "\xC3", *last = "\xC0", *line = "\xC4";
|
||||
#endif
|
||||
|
||||
fmt::print("Listing known products and flavours: \n\n");
|
||||
|
||||
fmt::print("* The following product list uses this style of formatting:\n");
|
||||
fmt::print("{}: {} \n", fmt::styled("PRODUCT", fmt::emphasis::bold), "Product name");
|
||||
fmt::print("{}{}{} {}: {} \n", last, line, line, "FLAVOUR", "Flavour name");
|
||||
fmt::print("* Products that require a flavour are noted with {}\n\n",
|
||||
fmt::styled("(no default)", fmt::emphasis::bold));
|
||||
|
||||
for (auto const &i : keys["products"].items())
|
||||
{
|
||||
auto el = i.value();
|
||||
auto containsFlavours = el.contains("flavours");
|
||||
|
||||
fmt::print("{:<9} {} ", fmt::styled(fmt::format("{}:", i.key()), fmt::emphasis::bold), el["name"]);
|
||||
if (el.contains("BINK"))
|
||||
{
|
||||
fmt::print("{}\n", el["BINK"]);
|
||||
}
|
||||
else if (el["meta"].contains("default"))
|
||||
{
|
||||
fmt::print("(default: {} {})\n", fmt::styled(el["meta"]["default"], fmt::emphasis::bold),
|
||||
el["flavours"][el["meta"]["default"]]["BINK"]);
|
||||
}
|
||||
else if (el["meta"]["type"].get<std::string>() == "PIDGEN3")
|
||||
{
|
||||
fmt::print("[{}]\n", el["meta"]["type"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt::print("{}\n", fmt::styled("(no default)", fmt::emphasis::bold));
|
||||
}
|
||||
if (containsFlavours)
|
||||
{
|
||||
auto flavours = el["flavours"];
|
||||
for (auto j = flavours.begin(); j != flavours.end(); j++)
|
||||
{
|
||||
auto el2 = j.value();
|
||||
BOOL isLast = j == --flavours.end();
|
||||
fmt::print("{}{}{} {:<9} {} ", !isLast ? leaf : last, line, line, fmt::format("{}:", j.key()),
|
||||
fmt::format("{} {}", el["name"], el2["name"]));
|
||||
if (el2.contains("meta") && el2["meta"].contains("type"))
|
||||
{
|
||||
fmt::print("[{}]\n", el2["meta"]["type"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt::print("{}\n", el2["BINK"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt::print("\n");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.productCode.empty())
|
||||
{
|
||||
fmt::print("ERROR: product code is required. Exiting...");
|
||||
DisplayHelp(0, nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *productCode = &options.productCode[0];
|
||||
if (!keys["products"].contains(productCode))
|
||||
{
|
||||
fmt::print("ERROR: Product {} is unknown", productCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto product = keys["products"][productCode];
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Selecting product: {}\n", productCode);
|
||||
}
|
||||
|
||||
json flavour;
|
||||
if (product.contains("flavours"))
|
||||
{
|
||||
flavour = product["flavours"][options.productFlavour];
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Selecting flavour: {}\n", options.productFlavour);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flavour = product;
|
||||
}
|
||||
|
||||
if (options.state != STATE_PIDGEN_GENERATE && options.state != STATE_PIDGEN_VALIDATE)
|
||||
{
|
||||
// exit early if we're not doing PIDGEN
|
||||
goto processOptionsExitEarly;
|
||||
}
|
||||
|
||||
if (options.oem)
|
||||
{
|
||||
flavour["BINK"][1].get_to(options.binkID);
|
||||
}
|
||||
else
|
||||
{
|
||||
flavour["BINK"][0].get_to(options.binkID);
|
||||
}
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Selected BINK: {}\n", options.binkID);
|
||||
}
|
||||
|
||||
if (options.state != STATE_PIDGEN_GENERATE)
|
||||
{
|
||||
// exit early if we're only validating
|
||||
goto processOptionsExitEarly;
|
||||
}
|
||||
|
||||
if (flavour.contains("DPC") && flavour["DPC"].contains(options.binkID) && options.channelID == 0)
|
||||
{
|
||||
std::vector<json> filtered;
|
||||
for (auto const &i : flavour["DPC"][options.binkID].items())
|
||||
{
|
||||
auto el = i.value();
|
||||
if (!el["isEvaluation"].get<bool>())
|
||||
{
|
||||
filtered.emplace_back(el);
|
||||
}
|
||||
}
|
||||
|
||||
// roll a die to choose which DPC entry to pick
|
||||
auto rand = UMSKT::getRandom<BYTE>();
|
||||
auto dpc = filtered[rand % filtered.size()];
|
||||
auto min = dpc["min"].get<WORD>(), max = dpc["max"].get<WORD>();
|
||||
|
||||
if (min == max)
|
||||
{
|
||||
options.channelID = min;
|
||||
}
|
||||
else
|
||||
{
|
||||
options.channelID = min + (rand % (max - min));
|
||||
}
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Selected channel ID: {} (DPC entry {}/{})\n", options.channelID, rand % filtered.size(),
|
||||
filtered.size());
|
||||
}
|
||||
}
|
||||
|
||||
if (options.channelID == 0)
|
||||
{
|
||||
options.channelID = UMSKT::getRandom<WORD>() % 999;
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Generated channel ID: {}\n", options.channelID);
|
||||
}
|
||||
}
|
||||
|
||||
// FE and FF are BINK 1998, but use a different, currently unhandled encoding scheme, we return an error here
|
||||
if (options.binkID == "FE" || options.binkID == "FF")
|
||||
{
|
||||
fmt::print("ERROR: Terminal Services BINKs (FE and FF) are unsupported at this time\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
processOptionsExitEarly:
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::DisplayHelp(int, char *)
|
||||
{
|
||||
options.help = true;
|
||||
fmt::print("usage: {} \n", options.argv[0]);
|
||||
|
||||
for (BYTE i = 0; i < CLIHelpOptionID_END; i++)
|
||||
{
|
||||
CLIHelpOptions o = helpOptions[i];
|
||||
if (o.Short.empty())
|
||||
{
|
||||
fmt::print("\t{:>2} --{:<15} {}", "", o.Long, o.HelpText);
|
||||
}
|
||||
else if (o.Long.empty())
|
||||
{
|
||||
fmt::print("\t-{} {:<15} {}", o.Short, "", o.HelpText);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt::print("\t-{} --{:<15} {}", o.Short, o.Long, o.HelpText);
|
||||
}
|
||||
|
||||
if (!o.Default.empty())
|
||||
{
|
||||
fmt::print(" (defaults to {})", o.Default);
|
||||
}
|
||||
fmt::print("\n");
|
||||
}
|
||||
|
||||
fmt::print("\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::DisplayErrorMessage(int, char *)
|
||||
{
|
||||
fmt::print("Error parsing command line options\n");
|
||||
DisplayHelp(0, nullptr);
|
||||
options.error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOL CLI::SetVerboseOption(int, char *)
|
||||
{
|
||||
fmt::print("Enabling verbose option\n\n");
|
||||
options.verbose = true;
|
||||
UMSKT::VERBOSE = true;
|
||||
UMSKT::setDebugOutput(stderr);
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::SetDebugOption(int, char *)
|
||||
{
|
||||
fmt::print("Enabling debug option\n");
|
||||
options.verbose = true;
|
||||
UMSKT::DEBUG = true;
|
||||
UMSKT::setDebugOutput(stderr);
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::SetListOption(int, char *)
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Setting list option\n");
|
||||
}
|
||||
options.list = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::SetOEMOption(int, char *)
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Setting oem option\n");
|
||||
}
|
||||
options.oem = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::SetUpgradeOption(int, char *)
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Setting upgrade option\n");
|
||||
}
|
||||
options.upgrade = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::SetFileOption(int count, char *file)
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Setting file option to: {}\n", file);
|
||||
}
|
||||
options.keysFilename = file;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::SetNumberOption(int count, char *num)
|
||||
{
|
||||
int nKeys;
|
||||
if (!_sscanf(num, "%d", &nKeys))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Setting generation number option to: {}\n", num);
|
||||
}
|
||||
|
||||
options.numKeys = nKeys;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param count
|
||||
* @param channum
|
||||
* @return
|
||||
*/
|
||||
BOOL CLI::SetChannelIDOption(int count, char *channum)
|
||||
{
|
||||
int siteID;
|
||||
if (!_sscanf(channum, "%d", &siteID))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// channel ids must be between 000 and 999
|
||||
if (siteID > 999)
|
||||
{
|
||||
fmt::print("ERROR: refusing to create a key with a Channel ID greater than 999\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Setting channel number option to: {}\n", siteID);
|
||||
}
|
||||
|
||||
options.channelID = siteID;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::SetBINKOption(int count, char *bink)
|
||||
{
|
||||
auto strbinkid = std::string(bink);
|
||||
options.binkID = strtoupper(strbinkid);
|
||||
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Setting BINK option to {}\n", strbinkid);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::SetFlavourOption(int count, char *flavour)
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Setting flavour option to {}\n", flavour);
|
||||
}
|
||||
|
||||
options.productFlavour = flavour;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param count
|
||||
* @param arg
|
||||
* @return
|
||||
*/
|
||||
BOOL CLI::SetSerialOption(int count, char *arg)
|
||||
{
|
||||
int serial_val;
|
||||
if (!_sscanf(arg, "%d", &serial_val))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// serials must be between 000000 and 999999
|
||||
if (serial_val > 999999)
|
||||
{
|
||||
fmt::print("ERROR: refusing to create a key with a Serial not between 000000 and 999999\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
options.serialSet = true;
|
||||
options.serial = serial_val;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::SetActivationIDOption(int count, char *aid)
|
||||
{
|
||||
options.installationID = aid;
|
||||
options.state = STATE_CONFIRMATION_ID;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::SetProductIDOption(int count, char *product)
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Setting product ID to {}", product);
|
||||
}
|
||||
options.productID = product;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::SetValidateOption(int count, char *productID)
|
||||
{
|
||||
options.keyToCheck = productID;
|
||||
options.state = STATE_PIDGEN_VALIDATE;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLI::SetProductCodeOption(int, char *product)
|
||||
{
|
||||
if (options.verbose)
|
||||
{
|
||||
fmt::print("Setting product code to {}\n", product);
|
||||
}
|
||||
|
||||
auto strProduct = std::string(product);
|
||||
options.productCode = strtoupper(strProduct);
|
||||
return true;
|
||||
}
|
63
src/help.h
Normal file
63
src/help.h
Normal file
@ -0,0 +1,63 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 01/02/2024
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_HELP_H
|
||||
#define UMSKT_HELP_H
|
||||
|
||||
typedef BOOL CLIHandlerFunc(int, char *);
|
||||
|
||||
enum CLIHelpOptionIDs
|
||||
{
|
||||
OPTION_HELP,
|
||||
OPTION_HELP2,
|
||||
OPTION_VERSION,
|
||||
OPTION_VERBOSE,
|
||||
OPTION_DEBUG,
|
||||
OPTION_FILE,
|
||||
OPTION_LIST,
|
||||
OPTION_PRODUCT,
|
||||
OPTION_FLAVOUR,
|
||||
OPTION_NUMBER,
|
||||
OPTION_OEM,
|
||||
OPTION_UPGRADE,
|
||||
OPTION_ACTIVATIONID,
|
||||
OPTION_ACTIVATIONPID,
|
||||
OPTION_BINK,
|
||||
OPTION_CHANNELID,
|
||||
OPTION_SERIAL,
|
||||
OPTION_AUTHDATA,
|
||||
OPTION_VALIDATE,
|
||||
|
||||
CLIHelpOptionID_END
|
||||
};
|
||||
|
||||
struct CLIHelpOptions
|
||||
{
|
||||
std::string Short;
|
||||
std::string Long;
|
||||
std::string HelpText;
|
||||
BOOL hasArguments;
|
||||
std::string Default;
|
||||
CLIHandlerFunc *handler;
|
||||
};
|
||||
|
||||
#endif // UMSKT_HELP_H
|
559
src/libumskt/confid/confid.cpp
Normal file
559
src/libumskt/confid/confid.cpp
Normal file
@ -0,0 +1,559 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by WitherOrNot on 06/02/2023
|
||||
* @Maintainer WitherOrNot
|
||||
*
|
||||
* @History {
|
||||
* This algorithm was provided to the UMSKT project by diamondggg
|
||||
* the history provided by diamondggg is that they are the originator of the code
|
||||
* and was created in tandem with an acquaintance who knows number theory.
|
||||
* The file dates suggest this code was written sometime in 2017/2018
|
||||
* }
|
||||
*/
|
||||
|
||||
#include "confid.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x0
|
||||
* @param x1
|
||||
* @param x2
|
||||
* @param x3
|
||||
* @param x4
|
||||
* @param x5
|
||||
* @param priv
|
||||
* @param modulous
|
||||
* @param nonresidue
|
||||
* @param isOffice
|
||||
* @param isXPBrand
|
||||
* @param flagVersion
|
||||
* @return
|
||||
*/
|
||||
BOOL ConfirmationID::LoadHyperellipticCurve(QWORD x0, QWORD x1, QWORD x2, QWORD x3, QWORD x4, QWORD x5, Q_OWORD priv,
|
||||
QWORD modulous, QWORD nonresidue, BOOL isOffice, BOOL isXPBrand,
|
||||
BYTE flagVersion)
|
||||
{
|
||||
curve[0] = x0;
|
||||
curve[1] = x1;
|
||||
curve[2] = x2;
|
||||
curve[3] = x3;
|
||||
curve[4] = x4;
|
||||
curve[5] = x5;
|
||||
|
||||
memcpy(&privateKey, &priv, sizeof(Q_OWORD));
|
||||
|
||||
MOD = modulous;
|
||||
NON_RESIDUE = nonresidue;
|
||||
this->isOffice = isOffice;
|
||||
this->isXPBrand = isXPBrand;
|
||||
this->flagVersion = flagVersion;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param f
|
||||
* @param priv
|
||||
* @param modulous
|
||||
* @param nonresidue
|
||||
* @param isOffice
|
||||
* @param isXPBrand
|
||||
* @param flagVersion
|
||||
* @return
|
||||
*/
|
||||
BOOL ConfirmationID::LoadHyperellipticCurve(QWORD *f, Q_OWORD priv, QWORD modulous, QWORD nonresidue, BOOL isOffice,
|
||||
BOOL isXPBrand, BYTE flagVersion)
|
||||
{
|
||||
memcpy(&curve, f, sizeof(curve));
|
||||
memcpy(&privateKey, &priv, sizeof(Q_OWORD));
|
||||
|
||||
MOD = modulous;
|
||||
NON_RESIDUE = nonresidue;
|
||||
this->isOffice = isOffice;
|
||||
this->isXPBrand = isXPBrand;
|
||||
this->flagVersion = flagVersion;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL LoadHyperellipticCurve(const std::string &x0, const std::string &x1, const std::string &x2, const std::string &x3,
|
||||
const std::string &x4, const std::string &x5, const std::string &priv,
|
||||
const std::string &modulous, const std::string &nonresidue, BOOL isOffice, BOOL isXPBrand,
|
||||
BYTE flagVersion)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
DWORD ConfirmationID::calculateCheckDigit(DWORD pid)
|
||||
{
|
||||
DWORD i = 0, j = 0, k = 0;
|
||||
for (j = pid; j; i += k)
|
||||
{
|
||||
k = j % 10;
|
||||
j /= 10;
|
||||
}
|
||||
|
||||
return ((10 * pid) - (i % 7)) + 7;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iid
|
||||
* @param hwid
|
||||
* @param version
|
||||
*/
|
||||
void ConfirmationID::decode_iid_new_version(BYTE *iid, BYTE *hwid, DWORD *version)
|
||||
{
|
||||
QWORD buffer[5];
|
||||
for (BYTE i = 0; i < 5; i++)
|
||||
{
|
||||
memcpy(&buffer[i], (iid + (4 * i)), 4);
|
||||
}
|
||||
|
||||
DWORD v1 = (buffer[3] & 0xFFFFFFF8) | 2;
|
||||
DWORD v2 = ((buffer[3] & 7) << 29) | (buffer[2] >> 3);
|
||||
QWORD hardwareIDVal = ((QWORD)v1 << 32) | v2;
|
||||
for (BYTE i = 0; i < 8; ++i)
|
||||
{
|
||||
hwid[i] = (hardwareIDVal >> (8 * i)) & 0xFF;
|
||||
}
|
||||
|
||||
*version = buffer[0] & 7;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param buffer
|
||||
* @param bufSize
|
||||
* @param key
|
||||
* @param keySize
|
||||
*/
|
||||
void ConfirmationID::Mix(BYTE *buffer, BYTE bufSize, const BYTE *key, BYTE keySize)
|
||||
{
|
||||
BYTE sha1_input[64], sha1_result[20];
|
||||
BYTE half = bufSize / 2;
|
||||
|
||||
// assert(half <= sizeof(sha1_result) && half + keySize <= sizeof(sha1_input) - 9);
|
||||
for (BYTE external_counter = 0; external_counter < 4; external_counter++)
|
||||
{
|
||||
memset(sha1_input, 0, sizeof(sha1_input));
|
||||
|
||||
if (isXPBrand)
|
||||
{
|
||||
memcpy(sha1_input, buffer + half, half);
|
||||
memcpy(sha1_input + half, key, keySize);
|
||||
|
||||
sha1_input[half + keySize] = 0x80;
|
||||
sha1_input[sizeof(sha1_input) - 1] = (half + keySize) * 8;
|
||||
sha1_input[sizeof(sha1_input) - 2] = (half + keySize) * 8 / 0x100;
|
||||
}
|
||||
else if (isOffice)
|
||||
{
|
||||
sha1_input[0] = 0x79;
|
||||
memcpy(sha1_input + 1, buffer + half, half);
|
||||
memcpy(sha1_input + 1 + half, key, keySize);
|
||||
|
||||
sha1_input[1 + half + keySize] = 0x80;
|
||||
sha1_input[sizeof(sha1_input) - 1] = (1 + half + keySize) * 8;
|
||||
sha1_input[sizeof(sha1_input) - 2] = (1 + half + keySize) * 8 / 0x100;
|
||||
}
|
||||
|
||||
SHA1(sha1_input, sizeof(sha1_input), sha1_result);
|
||||
|
||||
for (BYTE i = half & ~3; i < half; i++)
|
||||
{
|
||||
sha1_result[i] = sha1_result[i + 4 - (half & 3)];
|
||||
}
|
||||
|
||||
for (BYTE i = 0; i < half; i++)
|
||||
{
|
||||
unsigned char tmp = buffer[i + half];
|
||||
buffer[i + half] = buffer[i] ^ sha1_result[i];
|
||||
buffer[i] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param buffer
|
||||
* @param bufSize
|
||||
* @param key
|
||||
* @param keySize
|
||||
*/
|
||||
void ConfirmationID::Unmix(BYTE *buffer, BYTE bufSize, const BYTE key[4], BYTE keySize)
|
||||
{
|
||||
BYTE sha1_input[64], sha1_result[20];
|
||||
BYTE half = bufSize / 2;
|
||||
// assert(half <= sizeof(sha1_result) && half + keySize <= sizeof(sha1_input) - 9);
|
||||
|
||||
for (BYTE external_counter = 0; external_counter < 4; external_counter++)
|
||||
{
|
||||
memset(sha1_input, 0, sizeof(sha1_input));
|
||||
|
||||
if (isXPBrand)
|
||||
{
|
||||
memcpy(sha1_input, buffer, half);
|
||||
memcpy(sha1_input + half, key, keySize);
|
||||
sha1_input[half + keySize] = 0x80;
|
||||
sha1_input[sizeof(sha1_input) - 1] = (half + keySize) * 8;
|
||||
sha1_input[sizeof(sha1_input) - 2] = (half + keySize) * 8 / 0x100;
|
||||
}
|
||||
else if (isOffice)
|
||||
{
|
||||
sha1_input[0] = 0x79;
|
||||
memcpy(sha1_input + 1, buffer, half);
|
||||
memcpy(sha1_input + 1 + half, key, keySize);
|
||||
sha1_input[1 + half + keySize] = 0x80;
|
||||
sha1_input[sizeof(sha1_input) - 1] = (1 + half + keySize) * 8;
|
||||
sha1_input[sizeof(sha1_input) - 2] = (1 + half + keySize) * 8 / 0x100;
|
||||
}
|
||||
|
||||
SHA1(sha1_input, sizeof(sha1_input), sha1_result);
|
||||
|
||||
for (BYTE i = half & ~3; i < half; i++)
|
||||
{
|
||||
sha1_result[i] = sha1_result[i + 4 - (half & 3)];
|
||||
}
|
||||
|
||||
for (BYTE i = 0; i < half; i++)
|
||||
{
|
||||
unsigned char tmp = buffer[i];
|
||||
buffer[i] = buffer[i + half] ^ sha1_result[i];
|
||||
buffer[i + half] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param installationIDIn
|
||||
* @param confirmationIDOut
|
||||
* @param productIDIn
|
||||
* @return
|
||||
*/
|
||||
CONFIRMATION_ID_STATUS ConfirmationID::Generate(const std::string &installationIDIn, std::string &confirmationIDOut,
|
||||
std::string &productIDIn)
|
||||
{
|
||||
DWORD version;
|
||||
BYTE hardwareID[8];
|
||||
BYTE installation_id[19]; // 10**45 < 256**19
|
||||
BYTE productID[4];
|
||||
|
||||
BYTE installation_id_len = 0;
|
||||
auto pid = installationIDIn.c_str();
|
||||
|
||||
BYTE count = 0, totalCount = 0;
|
||||
unsigned check = 0;
|
||||
|
||||
BYTE i;
|
||||
|
||||
Q_OWORD mod_inv;
|
||||
memcpy(&mod_inv, &privateKey, sizeof(mod_inv));
|
||||
|
||||
for (; *pid; pid++)
|
||||
{
|
||||
if (*pid == ' ' || *pid == '-')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int d = *pid - '0';
|
||||
|
||||
if (d < 0 || d > 9)
|
||||
{
|
||||
return ERR_INVALID_CHARACTER;
|
||||
}
|
||||
|
||||
if (count == 5 || mod_inv.qword[0] == 0)
|
||||
{
|
||||
if (!count)
|
||||
{
|
||||
return (totalCount == 45) ? ERR_TOO_LARGE : ERR_TOO_SHORT;
|
||||
}
|
||||
|
||||
if (d != check % 7)
|
||||
{
|
||||
return (count < 5) ? ERR_TOO_SHORT : ERR_INVALID_CHECK_DIGIT;
|
||||
}
|
||||
|
||||
check = 0;
|
||||
count = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
check += (count % 2 ? d * 2 : d);
|
||||
count++;
|
||||
|
||||
totalCount++;
|
||||
if (totalCount > 45)
|
||||
{
|
||||
return ERR_TOO_LARGE;
|
||||
}
|
||||
|
||||
unsigned char carry = d;
|
||||
for (i = 0; i < installation_id_len; i++)
|
||||
{
|
||||
unsigned x = installation_id[i] * 10 + carry;
|
||||
installation_id[i] = x & 0xFF;
|
||||
carry = x >> 8;
|
||||
}
|
||||
|
||||
if (carry)
|
||||
{
|
||||
assert(installation_id_len < sizeof(installation_id));
|
||||
installation_id[installation_id_len++] = carry;
|
||||
}
|
||||
}
|
||||
|
||||
if (totalCount != 41 && totalCount < 45)
|
||||
{
|
||||
return ERR_TOO_SHORT;
|
||||
}
|
||||
|
||||
for (; installation_id_len < sizeof(installation_id); installation_id_len++)
|
||||
{
|
||||
installation_id[installation_id_len] = 0;
|
||||
}
|
||||
|
||||
Unmix(installation_id, totalCount == 41 ? 17 : 19, iid_key, 4);
|
||||
|
||||
if (installation_id[18] >= 0x10)
|
||||
{
|
||||
return ERR_UNKNOWN_VERSION;
|
||||
}
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct
|
||||
{
|
||||
QWORD HardwareID;
|
||||
QWORD ProductIDLow;
|
||||
BYTE ProductIDHigh;
|
||||
WORD KeySHA1;
|
||||
} parsed;
|
||||
#pragma pack(pop)
|
||||
|
||||
if (isXPBrand)
|
||||
{
|
||||
memcpy(&parsed, installation_id, sizeof(parsed));
|
||||
productID[0] = parsed.ProductIDLow & ((1 << 17) - 1);
|
||||
productID[1] = (parsed.ProductIDLow >> 17) & ((1 << 10) - 1);
|
||||
productID[2] = (parsed.ProductIDLow >> 27) & ((1 << 24) - 1);
|
||||
version = (parsed.ProductIDLow >> 51) & 15;
|
||||
productID[3] = (parsed.ProductIDLow >> 55) | (parsed.ProductIDHigh << 9);
|
||||
|
||||
if (flagVersion == 0)
|
||||
{
|
||||
if (version != (totalCount == 41 ? 9 : 10))
|
||||
{
|
||||
return ERR_UNKNOWN_VERSION;
|
||||
}
|
||||
}
|
||||
else if (flagVersion != version)
|
||||
{
|
||||
return ERR_UNKNOWN_VERSION;
|
||||
}
|
||||
}
|
||||
else if (isOffice)
|
||||
{
|
||||
decode_iid_new_version(installation_id, hardwareID, &version);
|
||||
|
||||
if (flagVersion != version)
|
||||
{
|
||||
return ERR_UNKNOWN_VERSION;
|
||||
}
|
||||
|
||||
memcpy(&parsed, hardwareID, 8);
|
||||
productID[0] = stoi(productIDIn.substr(0, 5));
|
||||
|
||||
auto channelid = productIDIn.substr(6, 3);
|
||||
char *p = &channelid[0];
|
||||
for (; *p; p++)
|
||||
{
|
||||
*p = toupper((unsigned char)*p);
|
||||
}
|
||||
|
||||
if (strcmp(&channelid[0], "OEM") == 0)
|
||||
{
|
||||
productID[1] = stoi(productIDIn.substr(12, 3));
|
||||
productID[2] = (stoi(productIDIn.substr(15, 1)) * 100000) + stoi(productIDIn.substr(18, 5));
|
||||
productID[2] = calculateCheckDigit(productID[2]);
|
||||
productID[3] = ((stoi(productIDIn.substr(10, 2))) * 1000) + productID[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
productID[1] = stoi(productIDIn.substr(6, 3));
|
||||
productID[2] = stoi(productIDIn.substr(10, 7));
|
||||
productID[3] = stoi(productIDIn.substr(18, 5));
|
||||
}
|
||||
// fmt::print("ProductID: {}-{}-{}-{} \n", productID[0], productID[1], productID[2], productID[3]);
|
||||
}
|
||||
|
||||
BYTE keybuf[16];
|
||||
memcpy(keybuf, &parsed.HardwareID, 8);
|
||||
|
||||
QWORD productIdMixed =
|
||||
(QWORD)productID[0] << 41 | (QWORD)productID[1] << 58 | (QWORD)productID[2] << 17 | productID[3];
|
||||
memcpy(keybuf + 8, &productIdMixed, 8);
|
||||
|
||||
TDivisor d;
|
||||
BYTE attempt;
|
||||
|
||||
Q_OWORD ulowhi;
|
||||
memset(&ulowhi, 0, sizeof(ulowhi));
|
||||
|
||||
for (attempt = 0; attempt <= 0x80; attempt++)
|
||||
{
|
||||
if (isXPBrand)
|
||||
{
|
||||
ulowhi.byte[7] = attempt;
|
||||
}
|
||||
else if (isOffice)
|
||||
{
|
||||
ulowhi.byte[6] = attempt;
|
||||
}
|
||||
|
||||
Mix(ulowhi.byte, 14, keybuf, 16);
|
||||
QWORD x2 = residue->ui128_quotient_mod(ulowhi.qword[0], ulowhi.qword[1]);
|
||||
QWORD x1 = ulowhi.qword[0] - x2 * MOD;
|
||||
x2++;
|
||||
|
||||
d.u[0] = residue->sub(residue->mul(x1, x1), residue->mul(NON_RESIDUE, residue->mul(x2, x2)));
|
||||
d.u[1] = residue->add(x1, x1);
|
||||
if (divisor->find_divisor_v(&d))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (attempt > 0x80)
|
||||
{
|
||||
return ERR_UNLUCKY;
|
||||
}
|
||||
|
||||
Q_OWORD priv;
|
||||
memcpy(&priv, &privateKey, sizeof(priv));
|
||||
|
||||
divisor->mul128(&d, priv.qword[0], priv.qword[1], &d);
|
||||
|
||||
Q_OWORD e;
|
||||
memset(&e, 0, sizeof(e));
|
||||
|
||||
if (d.u[0] == BAD)
|
||||
{
|
||||
// we can not get the zero divisor, actually...
|
||||
e.qword[0] = residue->__umul128(MOD + 2, MOD, &e.qword[1]);
|
||||
}
|
||||
else if (d.u[1] == BAD)
|
||||
{
|
||||
// O(1/MOD) chance
|
||||
// encoded = (unsigned __int128)(MOD + 1) * d.u[0] + MOD; // * MOD + d.u[0] is fine too
|
||||
e.qword[0] = residue->__umul128(MOD + 1, d.u[0], &e.qword[1]);
|
||||
e.qword[0] += MOD;
|
||||
e.qword[1] += (e.qword[0] < MOD);
|
||||
}
|
||||
else
|
||||
{
|
||||
QWORD x1 = (d.u[1] % 2 ? d.u[1] + MOD : d.u[1]) / 2;
|
||||
QWORD x2sqr = residue->sub(residue->mul(x1, x1), d.u[0]);
|
||||
QWORD x2 = residue->sqrt(x2sqr);
|
||||
|
||||
if (x2 == BAD)
|
||||
{
|
||||
x2 = residue->sqrt(residue->mul(x2sqr, residue->inv(NON_RESIDUE)));
|
||||
assert(x2 != BAD);
|
||||
e.qword[0] = residue->__umul128(MOD + 1, MOD + x2, &e.qword[1]);
|
||||
e.qword[0] += x1;
|
||||
e.qword[1] += (e.qword[0] < x1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// points (-x1+x2, v(-x1+x2)) and (-x1-x2, v(-x1-x2))
|
||||
QWORD x1a = residue->sub(x1, x2);
|
||||
QWORD y1 = residue->sub(d.v[0], residue->mul(d.v[1], x1a));
|
||||
QWORD x2a = residue->add(x1, x2);
|
||||
QWORD y2 = residue->sub(d.v[0], residue->mul(d.v[1], x2a));
|
||||
if (x1a > x2a)
|
||||
{
|
||||
QWORD tmp = x1a;
|
||||
x1a = x2a;
|
||||
x2a = tmp;
|
||||
}
|
||||
|
||||
if ((y1 ^ y2) & 1)
|
||||
{
|
||||
QWORD tmp = x1a;
|
||||
x1a = x2a;
|
||||
x2a = tmp;
|
||||
}
|
||||
|
||||
e.qword[0] = residue->__umul128(MOD + 1, x1a, &e.qword[1]);
|
||||
e.qword[0] += x2a;
|
||||
e.qword[1] += (e.qword[0] < x2a);
|
||||
}
|
||||
}
|
||||
|
||||
BYTE decimal[35];
|
||||
for (i = 0; i < 35; i++)
|
||||
{
|
||||
unsigned c = e.byte[3] % 10;
|
||||
e.byte[3] /= 10;
|
||||
|
||||
unsigned c2 = ((QWORD)c << 32 | e.byte[2]) % 10;
|
||||
e.byte[2] = ((QWORD)c << 32 | e.byte[2]) / 10;
|
||||
|
||||
unsigned c3 = ((QWORD)c2 << 32 | e.byte[1]) % 10;
|
||||
e.byte[1] = ((QWORD)c2 << 32 | e.byte[1]) / 10;
|
||||
|
||||
unsigned c4 = ((QWORD)c3 << 32 | e.byte[0]) % 10;
|
||||
e.byte[0] = ((QWORD)c3 << 32 | e.byte[0]) / 10;
|
||||
|
||||
decimal[34 - i] = c4;
|
||||
}
|
||||
|
||||
assert(e.encoded[0] == 0 && e.encoded[1] == 0 && e.encoded[2] == 0 && e.encoded[3] == 0);
|
||||
|
||||
char *q = &confirmationIDOut[0];
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
if (i)
|
||||
{
|
||||
*q++ = '-';
|
||||
}
|
||||
|
||||
unsigned char *p = decimal + i * 5;
|
||||
q[0] = p[0] + '0';
|
||||
q[1] = p[1] + '0';
|
||||
q[2] = p[2] + '0';
|
||||
q[3] = p[3] + '0';
|
||||
q[4] = p[4] + '0';
|
||||
q[5] = ((p[0] + p[1] * 2 + p[2] + p[3] * 2 + p[4]) % 7) + '0';
|
||||
q += 6;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
153
src/libumskt/confid/confid.h
Normal file
153
src/libumskt/confid/confid.h
Normal file
@ -0,0 +1,153 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/06/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_CONFID_H
|
||||
#define UMSKT_CONFID_H
|
||||
|
||||
#include "../libumskt.h"
|
||||
|
||||
// Confirmation ID generator constants
|
||||
enum CONFIRMATION_ID_STATUS
|
||||
{
|
||||
SUCCESS = 0,
|
||||
ERR_TOO_SHORT = 1,
|
||||
ERR_TOO_LARGE = 2,
|
||||
ERR_INVALID_CHARACTER = 3,
|
||||
ERR_INVALID_CHECK_DIGIT = 4,
|
||||
ERR_UNKNOWN_VERSION = 5,
|
||||
ERR_UNLUCKY = 6
|
||||
};
|
||||
|
||||
#define BAD 0xFFFFFFFFFFFFFFFFull
|
||||
|
||||
typedef struct
|
||||
{
|
||||
QWORD u[2];
|
||||
QWORD v[2];
|
||||
} TDivisor;
|
||||
|
||||
class EXPORT ConfirmationID
|
||||
{
|
||||
QWORD MOD = 0, NON_RESIDUE = 0;
|
||||
QWORD curve[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
|
||||
Q_OWORD privateKey;
|
||||
|
||||
BYTE iid_key[4] = {0x0, 0x0, 0x0, 0x0};
|
||||
BOOL isOffice = false, isXPBrand = false;
|
||||
unsigned flagVersion = 0;
|
||||
|
||||
DWORD calculateCheckDigit(DWORD pid);
|
||||
void decode_iid_new_version(BYTE *iid, BYTE *hwid, DWORD *version);
|
||||
void Mix(BYTE *buffer, BYTE bufSize, const BYTE *key, BYTE keySize);
|
||||
void Unmix(BYTE *buffer, BYTE bufSize, const BYTE *key, BYTE keySize);
|
||||
|
||||
class Divisor
|
||||
{
|
||||
ConfirmationID *parent;
|
||||
|
||||
public:
|
||||
explicit Divisor(ConfirmationID *p)
|
||||
{
|
||||
parent = p;
|
||||
}
|
||||
|
||||
int find_divisor_v(TDivisor *d);
|
||||
void add(const TDivisor *src1, const TDivisor *src2, TDivisor *dst);
|
||||
void mul(const TDivisor *src, QWORD mult, TDivisor *dst);
|
||||
void mul128(const TDivisor *src, QWORD mult_lo, QWORD mult_hi, TDivisor *dst);
|
||||
int u2poly(const TDivisor *src, QWORD polyu[3], QWORD polyv[2]);
|
||||
};
|
||||
friend class Divisor;
|
||||
|
||||
class Residue
|
||||
{
|
||||
ConfirmationID *parent;
|
||||
|
||||
public:
|
||||
explicit Residue(ConfirmationID *p)
|
||||
{
|
||||
parent = p;
|
||||
}
|
||||
|
||||
QWORD add(QWORD x, QWORD y);
|
||||
QWORD sub(QWORD x, QWORD y);
|
||||
QWORD __umul128(QWORD a, QWORD b, QWORD *hi);
|
||||
QWORD ui128_quotient_mod(QWORD lo, QWORD hi);
|
||||
QWORD mul(QWORD x, QWORD y);
|
||||
QWORD pow(QWORD x, QWORD y);
|
||||
QWORD inverse(QWORD u, QWORD v);
|
||||
QWORD inv(QWORD x);
|
||||
QWORD sqrt(QWORD what);
|
||||
};
|
||||
friend class Residue;
|
||||
|
||||
class Polynomial
|
||||
{
|
||||
ConfirmationID *parent;
|
||||
|
||||
public:
|
||||
explicit Polynomial(ConfirmationID *p)
|
||||
{
|
||||
parent = p;
|
||||
}
|
||||
|
||||
int mul(int adeg, const QWORD a[], int bdeg, const QWORD b[], int resultprevdeg, QWORD result[]);
|
||||
int div_monic(int adeg, QWORD a[], int bdeg, const QWORD b[], QWORD *quotient);
|
||||
void xgcd(int adeg, const QWORD a[3], int bdeg, const QWORD b[3], int *pgcddeg, QWORD gcd[3], int *pmult1deg,
|
||||
QWORD mult1[3], int *pmult2deg, QWORD mult2[3]);
|
||||
};
|
||||
friend class Polynomial;
|
||||
|
||||
Residue *residue;
|
||||
Polynomial *polynomial;
|
||||
Divisor *divisor;
|
||||
|
||||
public:
|
||||
ConfirmationID()
|
||||
{
|
||||
residue = new Residue(this);
|
||||
polynomial = new Polynomial(this);
|
||||
divisor = new Divisor(this);
|
||||
privateKey.qword[0] = privateKey.qword[1] = 0x00;
|
||||
}
|
||||
|
||||
BOOL LoadHyperellipticCurve(const std::string &x0, const std::string &x1, const std::string &x2,
|
||||
const std::string &x3, const std::string &x4, const std::string &x5,
|
||||
const std::string &priv, const std::string &modulous, const std::string &nonresidue,
|
||||
BOOL isOffice, BOOL isXPBrand, BYTE flagVersion);
|
||||
|
||||
BOOL LoadHyperellipticCurve(QWORD x0, QWORD x1, QWORD x2, QWORD x3, QWORD x4, QWORD x5, Q_OWORD priv,
|
||||
QWORD modulous, QWORD nonresidue, BOOL isOffice, BOOL isXPBrand, BYTE flagVersion);
|
||||
|
||||
BOOL LoadHyperellipticCurve(QWORD *f, Q_OWORD priv, QWORD modulous, QWORD nonresidue, BOOL isOffice, BOOL isXPBrand,
|
||||
BYTE flagVersion);
|
||||
|
||||
CONFIRMATION_ID_STATUS Generate(const std::string &installation_id_str, std::string &confirmation_id,
|
||||
std::string &productid);
|
||||
|
||||
~ConfirmationID()
|
||||
{
|
||||
delete residue, polynomial, divisor;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // UMSKT_CONFID_H
|
397
src/libumskt/confid/divisor.cpp
Normal file
397
src/libumskt/confid/divisor.cpp
Normal file
@ -0,0 +1,397 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 12/05/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "confid.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* @param d
|
||||
* @return
|
||||
*/
|
||||
int ConfirmationID::ConfirmationID::Divisor::find_divisor_v(TDivisor *d)
|
||||
{
|
||||
// u | v^2 - curve
|
||||
// u = u0 + u1*x + x^2
|
||||
// curve%u = f0 + f1*x
|
||||
QWORD v1, f2[6];
|
||||
|
||||
for (BYTE i = 0; i < 6; i++)
|
||||
{
|
||||
f2[i] = parent->curve[i];
|
||||
}
|
||||
|
||||
const QWORD u0 = d->u[0], u1 = d->u[1];
|
||||
for (BYTE j = 4; j--;)
|
||||
{
|
||||
f2[j] = parent->residue->sub(f2[j], parent->residue->mul(u0, f2[j + 2]));
|
||||
f2[j + 1] = parent->residue->sub(f2[j + 1], parent->residue->mul(u1, f2[j + 2]));
|
||||
f2[j + 2] = 0;
|
||||
}
|
||||
|
||||
// v = v0 + v1*x
|
||||
// u | (v0^2 - f0) + (2*v0*v1 - f1)*x + v1^2*x^2 = u0*v1^2 + u1*v1^2*x + v1^2*x^2
|
||||
// v0^2 - f0 = u0*v1^2
|
||||
// 2*v0*v1 - f1 = u1*v1^2
|
||||
// v0^2 = f0 + u0*v1^2 = (f1 + u1*v1^2)^2 / (2*v1)^2
|
||||
// (f1^2) + 2*(f1*u1-2*f0) * v1^2 + (u1^2-4*u0) * v1^4 = 0
|
||||
// v1^2 = ((2*f0-f1*u1) +- 2*sqrt(-f0*f1*u1 + f0^2 + f1^2*u0))) / (u1^2-4*u0)
|
||||
const QWORD f0 = f2[0], f1 = f2[1];
|
||||
const QWORD u0double = parent->residue->add(u0, u0);
|
||||
const QWORD coeff2 = parent->residue->sub(parent->residue->mul(u1, u1), parent->residue->add(u0double, u0double));
|
||||
const QWORD coeff1 = parent->residue->sub(parent->residue->add(f0, f0), parent->residue->mul(f1, u1));
|
||||
|
||||
if (coeff2 == 0)
|
||||
{
|
||||
if (coeff1 == 0)
|
||||
{
|
||||
if (f1 == 0)
|
||||
{
|
||||
// impossible
|
||||
// printf("bad curve(), double root detected\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
QWORD sqr = parent->residue->mul(parent->residue->mul(f1, f1),
|
||||
parent->residue->inv(parent->residue->add(coeff1, coeff1)));
|
||||
v1 = parent->residue->sqrt(sqr);
|
||||
if (v1 == BAD)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QWORD d = parent->residue->add(
|
||||
parent->residue->mul(f0, f0),
|
||||
parent->residue->mul(f1, parent->residue->sub(parent->residue->mul(f1, u0), parent->residue->mul(f0, u1))));
|
||||
d = parent->residue->sqrt(d);
|
||||
if (d == BAD)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
d = parent->residue->add(d, d);
|
||||
QWORD inv = parent->residue->inv(coeff2);
|
||||
QWORD root = parent->residue->mul(parent->residue->add(coeff1, d), inv);
|
||||
v1 = parent->residue->sqrt(root);
|
||||
if (v1 == BAD)
|
||||
{
|
||||
root = parent->residue->mul(parent->residue->sub(coeff1, d), inv);
|
||||
v1 = parent->residue->sqrt(root);
|
||||
if (v1 == BAD)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWORD v0 = parent->residue->mul(parent->residue->add(f1, parent->residue->mul(u1, parent->residue->mul(v1, v1))),
|
||||
parent->residue->inv(parent->residue->add(v1, v1)));
|
||||
d->v[0] = v0;
|
||||
d->v[1] = v1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param src
|
||||
* @param polyu
|
||||
* @param polyv
|
||||
* @return
|
||||
*/
|
||||
int ConfirmationID::ConfirmationID::Divisor::u2poly(const TDivisor *src, QWORD polyu[3], QWORD polyv[2])
|
||||
{
|
||||
if (src->u[1] != BAD)
|
||||
{
|
||||
polyu[0] = src->u[0];
|
||||
polyu[1] = src->u[1];
|
||||
polyu[2] = 1;
|
||||
|
||||
polyv[0] = src->v[0];
|
||||
polyv[1] = src->v[1];
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (src->u[0] != BAD)
|
||||
{
|
||||
polyu[0] = src->u[0];
|
||||
polyu[1] = 1;
|
||||
|
||||
polyv[0] = src->v[0];
|
||||
polyv[1] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
polyu[0] = 1;
|
||||
polyv[0] = 0;
|
||||
polyv[1] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param src1
|
||||
* @param src2
|
||||
* @param dst
|
||||
*/
|
||||
void ConfirmationID::Divisor::add(const TDivisor *src1, const TDivisor *src2, TDivisor *dst)
|
||||
{
|
||||
QWORD u1[3], u2[3], v1[2], v2[2];
|
||||
int u1deg = u2poly(src1, u1, v1);
|
||||
int u2deg = u2poly(src2, u2, v2);
|
||||
|
||||
// extended gcd: d1 = gcd(u1, u2) = e1*u1 + e2*u2
|
||||
int d1deg, e1deg, e2deg;
|
||||
QWORD d1[3], e1[3], e2[3];
|
||||
parent->polynomial->xgcd(u1deg, u1, u2deg, u2, &d1deg, d1, &e1deg, e1, &e2deg, e2);
|
||||
assert(e1deg <= 1);
|
||||
assert(e2deg <= 1);
|
||||
|
||||
// extended gcd again: d = gcd(d1, v1+v2) = c1*d1 + c2*(v1+v2)
|
||||
QWORD b[3] = {parent->residue->add(v1[0], v2[0]), parent->residue->add(v1[1], v2[1]), 0};
|
||||
int bdeg = (b[1] == 0 ? (b[0] == 0 ? -1 : 0) : 1);
|
||||
int ddeg, c1deg, c2deg;
|
||||
QWORD d[3], c1[3], c2[3];
|
||||
parent->polynomial->xgcd(d1deg, d1, bdeg, b, &ddeg, d, &c1deg, c1, &c2deg, c2);
|
||||
assert(c1deg <= 0);
|
||||
assert(c2deg <= 1);
|
||||
assert(ddeg >= 0);
|
||||
QWORD dmult = parent->residue->inv(d[ddeg]);
|
||||
int i;
|
||||
for (i = 0; i < ddeg; i++)
|
||||
{
|
||||
d[i] = parent->residue->mul(d[i], dmult);
|
||||
}
|
||||
|
||||
d[i] = 1;
|
||||
for (i = 0; i <= c1deg; i++)
|
||||
{
|
||||
c1[i] = parent->residue->mul(c1[i], dmult);
|
||||
}
|
||||
|
||||
for (i = 0; i <= c2deg; i++)
|
||||
{
|
||||
c2[i] = parent->residue->mul(c2[i], dmult);
|
||||
}
|
||||
|
||||
QWORD u[5];
|
||||
int udeg = parent->polynomial->mul(u1deg, u1, u2deg, u2, -1, u);
|
||||
// u is monic
|
||||
|
||||
QWORD v[7], tmp[7];
|
||||
int vdeg, tmpdeg;
|
||||
// c1*(e1*u1*v2 + e2*u2*v1) + c2*(v1*v2 + curve)
|
||||
// c1*(e1*u1*(v2-v1) + d1*v1) + c2*(v1*v2 + curve)
|
||||
v[0] = parent->residue->sub(v2[0], v1[0]);
|
||||
v[1] = parent->residue->sub(v2[1], v1[1]);
|
||||
tmpdeg = parent->polynomial->mul(e1deg, e1, 1, v, -1, tmp);
|
||||
vdeg = parent->polynomial->mul(u1deg, u1, tmpdeg, tmp, -1, v);
|
||||
vdeg = parent->polynomial->mul(d1deg, d1, 1, v1, vdeg, v);
|
||||
|
||||
for (i = 0; i <= vdeg; i++)
|
||||
{
|
||||
v[i] = parent->residue->mul(v[i], c1[0]);
|
||||
}
|
||||
|
||||
memcpy(tmp, parent->curve, 6 * sizeof(parent->curve[0]));
|
||||
tmpdeg = 5;
|
||||
tmpdeg = parent->polynomial->mul(1, v1, 1, v2, tmpdeg, tmp);
|
||||
vdeg = parent->polynomial->mul(c2deg, c2, tmpdeg, tmp, vdeg, v);
|
||||
|
||||
if (ddeg > 0)
|
||||
{
|
||||
assert(udeg >= 2 * ddeg);
|
||||
QWORD udiv[5];
|
||||
parent->polynomial->div_monic(udeg, u, ddeg, d, udiv);
|
||||
udeg -= ddeg;
|
||||
parent->polynomial->div_monic(udeg, udiv, ddeg, d, u);
|
||||
udeg -= ddeg;
|
||||
if (vdeg >= 0)
|
||||
{
|
||||
assert(vdeg >= ddeg);
|
||||
parent->polynomial->div_monic(vdeg, v, ddeg, d, udiv);
|
||||
vdeg -= ddeg;
|
||||
memcpy(v, udiv, (vdeg + 1) * sizeof(v[0]));
|
||||
}
|
||||
}
|
||||
|
||||
vdeg = parent->polynomial->div_monic(vdeg, v, udeg, u, NULL);
|
||||
|
||||
while (udeg > 2)
|
||||
{
|
||||
assert(udeg <= 4);
|
||||
assert(vdeg <= 3);
|
||||
// u' = monic((curve-v^2)/u), v'=-v mod u'
|
||||
tmpdeg = parent->polynomial->mul(vdeg, v, vdeg, v, -1, tmp);
|
||||
for (i = 0; i <= tmpdeg && i <= 5; i++)
|
||||
{
|
||||
tmp[i] = parent->residue->sub(parent->curve[i], tmp[i]);
|
||||
}
|
||||
|
||||
for (; i <= tmpdeg; i++)
|
||||
{
|
||||
tmp[i] = parent->residue->sub(0, tmp[i]);
|
||||
}
|
||||
|
||||
for (; i <= 5; i++)
|
||||
{
|
||||
tmp[i] = parent->curve[i];
|
||||
}
|
||||
|
||||
tmpdeg = i - 1;
|
||||
QWORD udiv[5];
|
||||
parent->polynomial->div_monic(tmpdeg, tmp, udeg, u, udiv);
|
||||
|
||||
udeg = tmpdeg - udeg;
|
||||
QWORD mult = parent->residue->inv(udiv[udeg]);
|
||||
|
||||
for (i = 0; i < udeg; i++)
|
||||
{
|
||||
u[i] = parent->residue->mul(udiv[i], mult);
|
||||
}
|
||||
|
||||
u[i] = 1;
|
||||
|
||||
for (i = 0; i <= vdeg; i++)
|
||||
{
|
||||
v[i] = parent->residue->sub(0, v[i]);
|
||||
}
|
||||
|
||||
vdeg = parent->polynomial->div_monic(vdeg, v, udeg, u, NULL);
|
||||
}
|
||||
|
||||
if (udeg == 2)
|
||||
{
|
||||
dst->u[0] = u[0];
|
||||
dst->u[1] = u[1];
|
||||
dst->v[0] = (vdeg >= 0 ? v[0] : 0);
|
||||
dst->v[1] = (vdeg >= 1 ? v[1] : 0);
|
||||
}
|
||||
else if (udeg == 1)
|
||||
{
|
||||
dst->u[0] = u[0];
|
||||
dst->u[1] = BAD;
|
||||
dst->v[0] = (vdeg >= 0 ? v[0] : 0);
|
||||
dst->v[1] = BAD;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(udeg == 0);
|
||||
dst->u[0] = BAD;
|
||||
dst->u[1] = BAD;
|
||||
dst->v[0] = BAD;
|
||||
dst->v[1] = BAD;
|
||||
}
|
||||
}
|
||||
|
||||
#define divisor_double(src, dst) add(src, src, dst)
|
||||
|
||||
/**
|
||||
*
|
||||
* @param src
|
||||
* @param mult
|
||||
* @param dst
|
||||
*/
|
||||
void ConfirmationID::Divisor::mul(const TDivisor *src, QWORD mult, TDivisor *dst)
|
||||
{
|
||||
if (mult == 0)
|
||||
{
|
||||
dst->u[0] = BAD;
|
||||
dst->u[1] = BAD;
|
||||
dst->v[0] = BAD;
|
||||
dst->v[1] = BAD;
|
||||
return;
|
||||
}
|
||||
|
||||
TDivisor cur = *src;
|
||||
while (!(mult & 1))
|
||||
{
|
||||
divisor_double(&cur, &cur);
|
||||
mult >>= 1;
|
||||
}
|
||||
|
||||
*dst = cur;
|
||||
while ((mult >>= 1) != 0)
|
||||
{
|
||||
divisor_double(&cur, &cur);
|
||||
if (mult & 1)
|
||||
{
|
||||
add(dst, &cur, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param src
|
||||
* @param mult_lo
|
||||
* @param mult_hi
|
||||
* @param dst
|
||||
*/
|
||||
void ConfirmationID::Divisor::mul128(const TDivisor *src, QWORD mult_lo, QWORD mult_hi, TDivisor *dst)
|
||||
{
|
||||
if (mult_lo == 0 && mult_hi == 0)
|
||||
{
|
||||
dst->u[0] = BAD;
|
||||
dst->u[1] = BAD;
|
||||
dst->v[0] = BAD;
|
||||
dst->v[1] = BAD;
|
||||
return;
|
||||
}
|
||||
|
||||
TDivisor cur = *src;
|
||||
while (!(mult_lo & 1))
|
||||
{
|
||||
divisor_double(&cur, &cur);
|
||||
mult_lo >>= 1;
|
||||
if (mult_hi & 1)
|
||||
{
|
||||
mult_lo |= (1ULL << 63);
|
||||
}
|
||||
mult_hi >>= 1;
|
||||
}
|
||||
|
||||
*dst = cur;
|
||||
for (;;)
|
||||
{
|
||||
mult_lo >>= 1;
|
||||
if (mult_hi & 1)
|
||||
{
|
||||
mult_lo |= (1ULL << 63);
|
||||
}
|
||||
|
||||
mult_hi >>= 1;
|
||||
if (mult_lo == 0 && mult_hi == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
divisor_double(&cur, &cur);
|
||||
if (mult_lo & 1)
|
||||
{
|
||||
add(dst, &cur, dst);
|
||||
}
|
||||
}
|
||||
}
|
261
src/libumskt/confid/polynomial.cpp
Normal file
261
src/libumskt/confid/polynomial.cpp
Normal file
@ -0,0 +1,261 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 12/05/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "confid.h"
|
||||
|
||||
/**
|
||||
* generic short slow code
|
||||
*
|
||||
* @param adeg
|
||||
* @param a
|
||||
* @param bdeg
|
||||
* @param b
|
||||
* @param resultprevdeg
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
int ConfirmationID::Polynomial::mul(int adeg, const QWORD a[], int bdeg, const QWORD b[], int resultprevdeg,
|
||||
QWORD result[])
|
||||
{
|
||||
if (adeg < 0 || bdeg < 0)
|
||||
{
|
||||
return resultprevdeg;
|
||||
}
|
||||
|
||||
int i, j;
|
||||
|
||||
for (i = resultprevdeg + 1; i <= adeg + bdeg; i++)
|
||||
{
|
||||
result[i] = 0;
|
||||
}
|
||||
|
||||
resultprevdeg = i - 1;
|
||||
|
||||
for (i = 0; i <= adeg; i++)
|
||||
{
|
||||
for (j = 0; j <= bdeg; j++)
|
||||
{
|
||||
result[i + j] = parent->residue->add(result[i + j], parent->residue->mul(a[i], b[j]));
|
||||
}
|
||||
}
|
||||
|
||||
while (resultprevdeg >= 0 && result[resultprevdeg] == 0)
|
||||
{
|
||||
--resultprevdeg;
|
||||
}
|
||||
|
||||
return resultprevdeg;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param adeg
|
||||
* @param a
|
||||
* @param bdeg
|
||||
* @param b
|
||||
* @param quotient
|
||||
* @return
|
||||
*/
|
||||
int ConfirmationID::Polynomial::div_monic(int adeg, QWORD a[], int bdeg, const QWORD b[], QWORD *quotient)
|
||||
{
|
||||
assert(bdeg >= 0);
|
||||
assert(b[bdeg] == 1);
|
||||
int i, j;
|
||||
|
||||
for (i = adeg - bdeg; i >= 0; i--)
|
||||
{
|
||||
QWORD q = a[i + bdeg];
|
||||
if (quotient)
|
||||
{
|
||||
quotient[i] = q;
|
||||
}
|
||||
for (j = 0; j < bdeg; j++)
|
||||
{
|
||||
a[i + j] = parent->residue->sub(a[i + j], parent->residue->mul(q, b[j]));
|
||||
}
|
||||
a[i + j] = 0;
|
||||
}
|
||||
|
||||
i += bdeg;
|
||||
while (i >= 0 && a[i] == 0)
|
||||
{
|
||||
i--;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param adeg
|
||||
* @param a
|
||||
* @param bdeg
|
||||
* @param b
|
||||
* @param pgcddeg
|
||||
* @param gcd
|
||||
* @param pmult1deg
|
||||
* @param mult1
|
||||
* @param pmult2deg
|
||||
* @param mult2
|
||||
*/
|
||||
void ConfirmationID::Polynomial::xgcd(int adeg, const QWORD a[3], int bdeg, const QWORD b[3], int *pgcddeg,
|
||||
QWORD gcd[3], int *pmult1deg, QWORD mult1[3], int *pmult2deg, QWORD mult2[3])
|
||||
{
|
||||
int sdeg = -1;
|
||||
QWORD s[3] = {0, 0, 0};
|
||||
|
||||
int mult1deg = 0;
|
||||
mult1[0] = 1;
|
||||
mult1[1] = 0;
|
||||
mult1[2] = 0;
|
||||
|
||||
int tdeg = 0;
|
||||
QWORD t[3] = {1, 0, 0};
|
||||
|
||||
int mult2deg = -1;
|
||||
mult2[0] = 0;
|
||||
mult2[1] = 0;
|
||||
mult2[2] = 0;
|
||||
|
||||
int rdeg = bdeg;
|
||||
QWORD r[3] = {b[0], b[1], b[2]};
|
||||
|
||||
int gcddeg = adeg;
|
||||
gcd[0] = a[0];
|
||||
gcd[1] = a[1];
|
||||
gcd[2] = a[2];
|
||||
// s*u1 + t*u2 = r
|
||||
// mult1*u1 + mult2*u2 = gcd
|
||||
|
||||
while (rdeg >= 0)
|
||||
{
|
||||
if (rdeg > gcddeg)
|
||||
{
|
||||
unsigned tmp;
|
||||
int tmpi;
|
||||
|
||||
tmp = rdeg;
|
||||
rdeg = gcddeg;
|
||||
gcddeg = tmp;
|
||||
|
||||
tmpi = sdeg;
|
||||
sdeg = mult1deg;
|
||||
mult1deg = tmpi;
|
||||
|
||||
tmpi = tdeg;
|
||||
tdeg = mult2deg;
|
||||
mult2deg = tmpi;
|
||||
|
||||
QWORD tmp2;
|
||||
tmp2 = r[0];
|
||||
r[0] = gcd[0];
|
||||
gcd[0] = tmp2;
|
||||
|
||||
tmp2 = r[1];
|
||||
r[1] = gcd[1];
|
||||
gcd[1] = tmp2;
|
||||
|
||||
tmp2 = r[2];
|
||||
r[2] = gcd[2];
|
||||
gcd[2] = tmp2;
|
||||
|
||||
tmp2 = s[0];
|
||||
s[0] = mult1[0];
|
||||
mult1[0] = tmp2;
|
||||
|
||||
tmp2 = s[1];
|
||||
s[1] = mult1[1];
|
||||
mult1[1] = tmp2;
|
||||
|
||||
tmp2 = s[2];
|
||||
s[2] = mult1[2];
|
||||
mult1[2] = tmp2;
|
||||
|
||||
tmp2 = t[0];
|
||||
t[0] = mult2[0];
|
||||
mult2[0] = tmp2;
|
||||
|
||||
tmp2 = t[1];
|
||||
t[1] = mult2[1];
|
||||
mult2[1] = tmp2;
|
||||
|
||||
tmp2 = t[2];
|
||||
t[2] = mult2[2];
|
||||
mult2[2] = tmp2;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
int delta = gcddeg - rdeg;
|
||||
QWORD mult = parent->residue->mul(gcd[gcddeg], parent->residue->inv(r[rdeg]));
|
||||
// quotient = mult * x**delta
|
||||
|
||||
assert(rdeg + delta < 3);
|
||||
for (int i = 0; i <= rdeg; i++)
|
||||
{
|
||||
gcd[i + delta] = parent->residue->sub(gcd[i + delta], parent->residue->mul(mult, r[i]));
|
||||
}
|
||||
|
||||
while (gcddeg >= 0 && gcd[gcddeg] == 0)
|
||||
{
|
||||
gcddeg--;
|
||||
}
|
||||
assert(sdeg + delta < 3);
|
||||
|
||||
for (int i = 0; i <= sdeg; i++)
|
||||
{
|
||||
mult1[i + delta] = parent->residue->sub(mult1[i + delta], parent->residue->mul(mult, s[i]));
|
||||
}
|
||||
|
||||
if (mult1deg < sdeg + delta)
|
||||
{
|
||||
mult1deg = sdeg + delta;
|
||||
}
|
||||
|
||||
while (mult1deg >= 0 && mult1[mult1deg] == 0)
|
||||
{
|
||||
mult1deg--;
|
||||
}
|
||||
|
||||
assert(tdeg + delta < 3);
|
||||
|
||||
for (int i = 0; i <= tdeg; i++)
|
||||
{
|
||||
mult2[i + delta] = parent->residue->sub(mult2[i + delta], parent->residue->mul(mult, t[i]));
|
||||
}
|
||||
|
||||
if (mult2deg < tdeg + delta)
|
||||
{
|
||||
mult2deg = tdeg + delta;
|
||||
}
|
||||
|
||||
while (mult2deg >= 0 && mult2[mult2deg] == 0)
|
||||
{
|
||||
mult2deg--;
|
||||
}
|
||||
}
|
||||
|
||||
// d1 = gcd, e1 = mult1, e2 = mult2
|
||||
*pgcddeg = gcddeg;
|
||||
*pmult1deg = mult1deg;
|
||||
*pmult2deg = mult2deg;
|
||||
}
|
279
src/libumskt/confid/residue.cpp
Normal file
279
src/libumskt/confid/residue.cpp
Normal file
@ -0,0 +1,279 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 12/05/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "confid.h"
|
||||
|
||||
#if defined(__x86_64__) || defined(_M_AMD64) || defined(__aarch64__) || (defined(__arm64__) && defined(__APPLE__))
|
||||
#ifdef __GNUC__
|
||||
QWORD ConfirmationID::Residue::__umul128(QWORD multiplier, QWORD multiplicand, QWORD *product_hi)
|
||||
{
|
||||
OWORD r = (OWORD)multiplier * (OWORD)multiplicand;
|
||||
*product_hi = r >> 64;
|
||||
return (QWORD)r;
|
||||
}
|
||||
#else // basically msvc
|
||||
/**
|
||||
*
|
||||
* @param multiplier
|
||||
* @param multiplicand
|
||||
* @param product_hi
|
||||
* @return
|
||||
*/
|
||||
QWORD ConfirmationID::Residue::__umul128(QWORD multiplier, QWORD multiplicand, QWORD *product_hi)
|
||||
{
|
||||
return _umul128(multiplier, multiplicand, product_hi);
|
||||
}
|
||||
#endif
|
||||
#elif defined(__i386__) || defined(_M_IX86) || defined(__arm__) || defined(__EMSCRIPTEN__)
|
||||
QWORD ConfirmationID::Residue::__umul128(QWORD multiplier, QWORD multiplicand, QWORD *product_hi)
|
||||
{
|
||||
// multiplier = ab = a * 2^32 + b
|
||||
// multiplicand = cd = c * 2^32 + d
|
||||
// ab * cd = a * c * 2^64 + (a * d + b * c) * 2^32 + b * d
|
||||
QWORD a = multiplier >> 32;
|
||||
QWORD b = multiplier & 0xFFFFFFFF;
|
||||
QWORD c = multiplicand >> 32;
|
||||
QWORD d = multiplicand & 0xFFFFFFFF;
|
||||
|
||||
// QWORD ac = a * c;
|
||||
QWORD ad = a * d;
|
||||
// QWORD bc = b * c;
|
||||
QWORD bd = b * d;
|
||||
|
||||
QWORD adbc = ad + (b * c);
|
||||
QWORD adbc_carry = adbc < ad ? 1 : 0;
|
||||
|
||||
// multiplier * multiplicand = product_hi * 2^64 + product_lo
|
||||
QWORD product_lo = bd + (adbc << 32);
|
||||
QWORD product_lo_carry = product_lo < bd ? 1 : 0;
|
||||
*product_hi = (a * c) + (adbc >> 32) + (adbc_carry << 32) + product_lo_carry;
|
||||
|
||||
return product_lo;
|
||||
}
|
||||
#else
|
||||
#error Unknown architecture detected - please edit confid.cpp to tailor __umul128() your architecture
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* @param lo
|
||||
* @param hi
|
||||
* @return
|
||||
*/
|
||||
QWORD ConfirmationID::Residue::ui128_quotient_mod(QWORD lo, QWORD hi)
|
||||
{
|
||||
// hi:lo * ceil(2**170/MOD) >> (64 + 64 + 42)
|
||||
QWORD prod1;
|
||||
__umul128(lo, parent->privateKey.qword[0], &prod1);
|
||||
|
||||
QWORD part1hi, part1lo = __umul128(lo, parent->privateKey.qword[1], &part1hi);
|
||||
QWORD part2hi, part2lo = __umul128(hi, parent->privateKey.qword[0], &part2hi);
|
||||
|
||||
QWORD sum1 = part1lo + part2lo;
|
||||
unsigned sum1carry = (sum1 < part1lo);
|
||||
sum1 += prod1;
|
||||
sum1carry += (sum1 < prod1);
|
||||
QWORD prod2 = part1hi + part2hi + sum1carry;
|
||||
|
||||
QWORD prod3hi, prod3lo = __umul128(hi, parent->privateKey.qword[1], &prod3hi);
|
||||
|
||||
prod3lo += prod2;
|
||||
prod3hi += (prod3lo < prod2);
|
||||
return (prod3lo >> 42) | (prod3hi << 22);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
*/
|
||||
QWORD ConfirmationID::Residue::mul(QWORD x, QWORD y)
|
||||
{
|
||||
// * ceil(2**170/MOD) = 0x2d351 c6d04f8b|604fa6a1 c6346a87 for (p-1)*(p-1) max
|
||||
QWORD hi, lo = __umul128(x, y, &hi);
|
||||
QWORD quotient = ui128_quotient_mod(lo, hi);
|
||||
return lo - quotient * parent->MOD;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
*/
|
||||
QWORD ConfirmationID::Residue::pow(QWORD x, QWORD y)
|
||||
{
|
||||
if (y == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
QWORD cur = x;
|
||||
while (!(y & 1))
|
||||
{
|
||||
cur = mul(cur, cur);
|
||||
y >>= 1;
|
||||
}
|
||||
|
||||
QWORD res = cur;
|
||||
while ((y >>= 1) != 0)
|
||||
{
|
||||
cur = mul(cur, cur);
|
||||
if (y & 1)
|
||||
{
|
||||
res = mul(res, cur);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
*/
|
||||
QWORD ConfirmationID::Residue::add(QWORD x, QWORD y)
|
||||
{
|
||||
QWORD z = x + y;
|
||||
// z = z - (z >= MOD ? MOD : 0);
|
||||
if (z >= parent->MOD)
|
||||
{
|
||||
z -= parent->MOD;
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
*/
|
||||
QWORD ConfirmationID::Residue::sub(QWORD x, QWORD y)
|
||||
{
|
||||
QWORD z = x - y;
|
||||
// z += (x < y ? MOD : 0);
|
||||
if (x < y)
|
||||
{
|
||||
z += parent->MOD;
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param u
|
||||
* @param v
|
||||
* @return
|
||||
*/
|
||||
QWORD ConfirmationID::Residue::inverse(QWORD u, QWORD v)
|
||||
{
|
||||
// assert(u);
|
||||
int64_t tmp;
|
||||
int64_t xu = 1, xv = 0;
|
||||
QWORD v0 = v;
|
||||
while (u > 1)
|
||||
{
|
||||
QWORD d = v / u;
|
||||
QWORD remainder = v % u;
|
||||
tmp = u;
|
||||
u = remainder;
|
||||
v = tmp;
|
||||
tmp = xu;
|
||||
xu = xv - d * xu;
|
||||
xv = tmp;
|
||||
}
|
||||
xu += (xu < 0 ? v0 : 0);
|
||||
return xu;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
* @return
|
||||
*/
|
||||
QWORD ConfirmationID::Residue::inv(QWORD x)
|
||||
{
|
||||
return inverse(x, parent->MOD);
|
||||
// return residue_pow(x, MOD - 2);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param what
|
||||
* @return
|
||||
*/
|
||||
QWORD ConfirmationID::Residue::sqrt(QWORD what)
|
||||
{
|
||||
if (!what)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
QWORD g = parent->NON_RESIDUE, z, y, r, x, b, t;
|
||||
QWORD e = 0, q = parent->MOD - 1;
|
||||
|
||||
while (!(q & 1))
|
||||
{
|
||||
e++, q >>= 1;
|
||||
}
|
||||
|
||||
z = pow(g, q);
|
||||
y = z;
|
||||
r = e;
|
||||
x = pow(what, (q - 1) / 2);
|
||||
b = mul(mul(what, x), x);
|
||||
x = mul(what, x);
|
||||
|
||||
while (b != 1)
|
||||
{
|
||||
QWORD m = 0, b2 = b;
|
||||
|
||||
do
|
||||
{
|
||||
m++;
|
||||
b2 = mul(b2, b2);
|
||||
} while (b2 != 1);
|
||||
|
||||
if (m == r)
|
||||
{
|
||||
return BAD;
|
||||
}
|
||||
|
||||
t = pow(y, 1 << (r - m - 1));
|
||||
y = mul(t, t);
|
||||
r = m;
|
||||
x = mul(x, t);
|
||||
b = mul(b, y);
|
||||
}
|
||||
|
||||
if (mul(x, x) != what)
|
||||
{
|
||||
// printf("internal error in sqrt\n");
|
||||
return BAD;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
48
src/libumskt/debugoutput.cpp
Normal file
48
src/libumskt/debugoutput.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/25/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "libumskt.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
// this seems janky but it works, and doesn't use storage that would otherwise get clobbered
|
||||
std::FILE *getFileStreamToNul()
|
||||
{
|
||||
fopen_s(&UMSKT::debug, "nul", "w");
|
||||
return UMSKT::debug;
|
||||
}
|
||||
std::FILE *UMSKT::debug = getFileStreamToNul();
|
||||
#else
|
||||
std::FILE *UMSKT::debug = std::fopen("/dev/null", "w");
|
||||
#endif
|
||||
|
||||
BOOL UMSKT::VERBOSE = false;
|
||||
BOOL UMSKT::DEBUG = false;
|
||||
|
||||
/**
|
||||
* sets the filestream used for debugging
|
||||
*
|
||||
* @param input std::FILE
|
||||
*/
|
||||
void UMSKT::setDebugOutput(std::FILE *input)
|
||||
{
|
||||
debug = input;
|
||||
}
|
292
src/libumskt/libumskt.cpp
Normal file
292
src/libumskt/libumskt.cpp
Normal file
@ -0,0 +1,292 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/25/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "libumskt.h"
|
||||
#include "confid/confid.h"
|
||||
#include "pidgen2/PIDGEN2.h"
|
||||
#include "pidgen3/BINK1998.h"
|
||||
#include "pidgen3/BINK2002.h"
|
||||
#include "pidgen3/PIDGEN3.h"
|
||||
|
||||
std::map<UMSKT_TAG, UMSKT_Value> UMSKT::tags;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
/**
|
||||
* Sets debug output to a given C++ File stream
|
||||
* if the memory allocated at filestream is "STDOUT" or "STDERR"
|
||||
* simply use the global vars allocated by *this* C++ runtime.
|
||||
* otherwise, assume that the input pointer is an ABI equivalent std::FILE
|
||||
*
|
||||
* @param char* or std::FILE "filestream"
|
||||
*/
|
||||
EXPORT BOOL UMSKT_SET_DEBUG_OUTPUT(void *filestream)
|
||||
{
|
||||
char buffer[7];
|
||||
memcpy(buffer, filestream, 6);
|
||||
buffer[6] = 0;
|
||||
auto buffstring = std::string(buffer);
|
||||
std::transform(buffstring.begin(), buffstring.end(), buffstring.begin(), ::tolower);
|
||||
|
||||
if (buffstring == "stdout")
|
||||
{
|
||||
UMSKT::debug = stdout;
|
||||
return true;
|
||||
}
|
||||
else if (buffstring == "stderr")
|
||||
{
|
||||
UMSKT::debug = stderr;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
UMSKT::debug = (std::FILE *)filestream;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @param tag
|
||||
* @param value
|
||||
* @param valueSize
|
||||
* @return success
|
||||
*/
|
||||
EXPORT BOOL UMSKT_SET_TAG(UMSKT_TAG tag, char *value, size_t valueSize)
|
||||
{
|
||||
if (valueSize > sizeof(UMSKT_Value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// wipe/set the tag
|
||||
memset(&UMSKT::tags[tag], 0, sizeof(UMSKT_Value));
|
||||
memcpy(&UMSKT::tags[tag], value, valueSize);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
EXPORT void UMSKT_RESET_TAGS()
|
||||
{
|
||||
UMSKT::tags.clear();
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
|
||||
EXPORT void *CONFID_INIT()
|
||||
{
|
||||
auto cid = new ConfirmationID();
|
||||
|
||||
// cid->LoadHyperellipticCurve(0, 0, 0, 0, 0, 0, 0, 0, 0, false, false, 0);
|
||||
|
||||
return cid;
|
||||
}
|
||||
|
||||
EXPORT BYTE CONFID_GENERATE(void *cidIn, const char *installation_id_str, char *&confirmation_id, char *productid)
|
||||
{
|
||||
ConfirmationID *cid;
|
||||
try
|
||||
{
|
||||
cid = static_cast<ConfirmationID *>(cidIn);
|
||||
}
|
||||
catch (const std::bad_cast &e)
|
||||
{
|
||||
fmt::print(UMSKT::debug, "{}: input is not a {} - {}", __FUNCTION__, e.what());
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (auto const i : UMSKT::tags)
|
||||
{
|
||||
switch (i.first)
|
||||
{
|
||||
case UMSKT_tag_InstallationID:
|
||||
break;
|
||||
case UMSKT_tag_ProductID:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string str, confid(confirmation_id), productids(productid);
|
||||
auto retval = cid->Generate(str, confid, productids);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
EXPORT void CONFID_END(void *cidIn)
|
||||
{
|
||||
auto *cid((ConfirmationID *)cidIn);
|
||||
delete cid;
|
||||
cid = nullptr;
|
||||
cidIn = nullptr;
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
|
||||
EXPORT void *PIDGEN3_INIT(const char *p, const char *a, const char *b, const char *generatorX,
|
||||
const char *generatorY, const char *publicKeyX, const char *publicKeyY,
|
||||
const char *genOrder, const char *privateKey)
|
||||
{
|
||||
PIDGEN3 *p3;
|
||||
|
||||
if (PIDGEN3::checkFieldStrIsBink1998(p))
|
||||
{
|
||||
p3 = new BINK1998();
|
||||
}
|
||||
else
|
||||
{
|
||||
p3 = new BINK2002();
|
||||
}
|
||||
|
||||
p3->LoadEllipticCurve(p, a, b, generatorX, generatorY, publicKeyX, publicKeyY, genOrder, privateKey);
|
||||
|
||||
return p3;
|
||||
}
|
||||
|
||||
EXPORT BOOL PIDGEN3_Generate(void *&ptrIn, char *&pKeyOut, int pKeySizeIn)
|
||||
{
|
||||
auto *p3((PIDGEN3 *)ptrIn);
|
||||
|
||||
for (auto const i : UMSKT::tags)
|
||||
{
|
||||
switch (i.first)
|
||||
{
|
||||
case UMSKT_tag_isUpgrade:
|
||||
p3->info.isUpgrade = i.second.boolean;
|
||||
break;
|
||||
case UMSKT_tag_ChannelID:
|
||||
p3->info.setChannelID(i.second.dword);
|
||||
break;
|
||||
case UMSKT_tag_Serial:
|
||||
p3->info.setSerial(i.second.dword);
|
||||
break;
|
||||
case UMSKT_tag_AuthData:
|
||||
p3->info.setAuthInfo(i.second.dword);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string str;
|
||||
BOOL retval = p3->Generate(str);
|
||||
|
||||
assert(pKeySizeIn >= str.length() + 1);
|
||||
|
||||
memcpy(pKeyOut, &str[0], str.length());
|
||||
pKeyOut[str.length()] = 0;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
EXPORT BOOL PIDGEN3_Validate(void *&ptrIn, char *pKeyIn)
|
||||
{
|
||||
auto *p3((PIDGEN3 *)ptrIn);
|
||||
std::string str(pKeyIn);
|
||||
|
||||
BOOL retval = p3->Validate(str);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
EXPORT void PIDGEN3_END(void *ptrIn)
|
||||
{
|
||||
auto *p3((PIDGEN3 *)ptrIn);
|
||||
delete p3;
|
||||
ptrIn = nullptr;
|
||||
p3 = nullptr;
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
|
||||
EXPORT void *PIDGEN2_INIT()
|
||||
{
|
||||
auto p2 = new PIDGEN2();
|
||||
return p2;
|
||||
}
|
||||
|
||||
EXPORT BOOL PIDGEN2_GENERATE(void *ptrIn, char *&keyout)
|
||||
{
|
||||
auto p2 = (PIDGEN2 *)ptrIn;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
EXPORT void PIDGEN2_END(void *ptrIn)
|
||||
{
|
||||
auto p2 = (PIDGEN2 *)ptrIn;
|
||||
delete p2;
|
||||
p2 = nullptr;
|
||||
ptrIn = nullptr;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
/**
|
||||
* Convert data between endianness types.
|
||||
*
|
||||
* @param data [in]
|
||||
* @param length [in]
|
||||
**/
|
||||
void UMSKT::endian(BYTE *data, int length)
|
||||
{
|
||||
for (int i = 0; i < length / 2; i++)
|
||||
{
|
||||
BYTE temp = data[i];
|
||||
data[i] = data[length - i - 1];
|
||||
data[length - i - 1] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an OpenSSL BigNumber to it's Little Endian binary equivalent
|
||||
*
|
||||
* @param a [in] BigNumber to convert
|
||||
* @param to [out] char* binary representation
|
||||
* @param tolen [in] length of the char* array
|
||||
*
|
||||
* @return length of number in to
|
||||
**/
|
||||
int UMSKT::BN_bn2lebin(const BIGNUM *a, unsigned char *to, int tolen)
|
||||
{
|
||||
if (a == nullptr || to == nullptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int len = BN_bn2bin(a, to);
|
||||
|
||||
if (len > tolen)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Choke point inside BN_bn2lebinpad: OpenSSL uses len instead of tolen.
|
||||
endian(to, tolen);
|
||||
|
||||
return len;
|
||||
}
|
139
src/libumskt/libumskt.h
Normal file
139
src/libumskt/libumskt.h
Normal file
@ -0,0 +1,139 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/24/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_LIBUMSKT_H
|
||||
#define UMSKT_LIBUMSKT_H
|
||||
|
||||
#include "../typedefs.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/format.h>
|
||||
|
||||
// Algorithm macros
|
||||
#define PK_LENGTH 25
|
||||
#define NULL_TERMINATOR 1
|
||||
|
||||
#define FIELD_BITS 384
|
||||
#define FIELD_BYTES 48
|
||||
#define FIELD_BITS_2003 512
|
||||
#define FIELD_BYTES_2003 64
|
||||
|
||||
#define SHA_MSG_LENGTH_XP (4 + 2 * FIELD_BYTES)
|
||||
#define SHA_MSG_LENGTH_2003 (3 + 2 * FIELD_BYTES_2003)
|
||||
|
||||
#define NEXTSNBITS(field, n, offset) (((QWORD)(field) >> (offset)) & ((1ULL << (n)) - 1))
|
||||
#define FIRSTNBITS(field, n) NEXTSNBITS((field), (n), 0)
|
||||
|
||||
#define HIBYTES(field, bytes) NEXTSNBITS((QWORD)(field), ((bytes) * 8), ((bytes) * 8))
|
||||
#define LOBYTES(field, bytes) FIRSTNBITS((QWORD)(field), ((bytes) * 8))
|
||||
|
||||
#define BYDWORD(n) (DWORD)(*((n) + 0) | *((n) + 1) << 8 | *((n) + 2) << 16 | *((n) + 3) << 24)
|
||||
#define BITMASK(n) ((1ULL << (n)) - 1)
|
||||
|
||||
#ifndef LIBUMSKT_VERSION_STRING
|
||||
#define LIBUMSKT_VERSION_STRING "unknown version-dirty"
|
||||
#endif
|
||||
|
||||
enum ValueType
|
||||
{
|
||||
VALUE_BOOL,
|
||||
VALUE_WORD,
|
||||
VALUE_DWORD,
|
||||
VALUE_QWORD,
|
||||
VALUE_OWORD,
|
||||
VALUE_CHARPTR
|
||||
};
|
||||
|
||||
struct UMSKT_Value
|
||||
{
|
||||
ValueType type;
|
||||
union {
|
||||
BOOL boolean;
|
||||
WORD word;
|
||||
DWORD dword;
|
||||
QWORD qword;
|
||||
OWORD oword;
|
||||
char *chars;
|
||||
};
|
||||
};
|
||||
|
||||
enum UMSKT_TAG
|
||||
{
|
||||
UMSKT_tag_isOEM,
|
||||
UMSKT_tag_isUpgrade,
|
||||
UMSKT_tag_Year,
|
||||
UMSKT_tag_Day,
|
||||
UMSKT_tag_OEMID,
|
||||
UMSKT_tag_AuthData,
|
||||
UMSKT_tag_Serial,
|
||||
UMSKT_tag_ChannelID,
|
||||
UMSKT_tag_InstallationID,
|
||||
UMSKT_tag_ProductID
|
||||
};
|
||||
|
||||
class EXPORT UMSKT
|
||||
{
|
||||
public:
|
||||
static std::FILE *debug;
|
||||
static BOOL VERBOSE;
|
||||
static BOOL DEBUG;
|
||||
static std::map<UMSKT_TAG, UMSKT_Value> tags;
|
||||
|
||||
// Hello OpenSSL developers, please tell me, where is this function at?
|
||||
static int BN_bn2lebin(const BIGNUM *a, unsigned char *to, int tolen);
|
||||
static void endian(BYTE *data, int length);
|
||||
|
||||
static void DESTRUCT()
|
||||
{
|
||||
if (debug != nullptr)
|
||||
{
|
||||
std::fclose(debug);
|
||||
}
|
||||
debug = nullptr;
|
||||
}
|
||||
|
||||
static void setDebugOutput(std::FILE *input);
|
||||
|
||||
template <typename T> static T getRandom()
|
||||
{
|
||||
T retval;
|
||||
RAND_bytes((BYTE *)&retval, sizeof(retval));
|
||||
return retval;
|
||||
}
|
||||
|
||||
static const char *VERSION()
|
||||
{
|
||||
return fmt::format("LIBUMSKT {} compiled on {} {}", LIBUMSKT_VERSION_STRING, __DATE__, __TIME__).c_str();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // UMSKT_LIBUMSKT_H
|
208
src/libumskt/pidgen2/PIDGEN2.cpp
Normal file
208
src/libumskt/pidgen2/PIDGEN2.cpp
Normal file
@ -0,0 +1,208 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/17/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "PIDGEN2.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
BOOL PIDGEN2::isNumericString(char *input)
|
||||
{
|
||||
for (int i = 0; i < strlen(input); i++)
|
||||
{
|
||||
if (input[i] < '0' || input[i] > '9')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
int PIDGEN2::addDigits(char *input)
|
||||
{
|
||||
int output = 0;
|
||||
|
||||
if (!isNumericString(input))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < strlen(input); i++)
|
||||
{
|
||||
output += input[i] - '0';
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channelID
|
||||
* @return
|
||||
*/
|
||||
BOOL PIDGEN2::isValidChannelID(char *channelID)
|
||||
{
|
||||
if (strlen(channelID) > 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i <= 6; i++)
|
||||
{
|
||||
if (strcmp(channelID, channelIDBlacklist[i]) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param OEMID
|
||||
* @return
|
||||
*/
|
||||
BOOL PIDGEN2::isValidOEMID(char *OEMID)
|
||||
{
|
||||
if (!isNumericString(OEMID))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strlen(OEMID) > 5)
|
||||
{
|
||||
if (OEMID[0] != '0' || OEMID[1] != '0')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int mod = addDigits(OEMID);
|
||||
|
||||
return (mod % 21 == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param year
|
||||
* @return
|
||||
*/
|
||||
BOOL PIDGEN2::isValidYear(char *year)
|
||||
{
|
||||
for (int i = 0; i <= 7; i++)
|
||||
{
|
||||
if (year == validYears[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param day
|
||||
* @return
|
||||
*/
|
||||
BOOL PIDGEN2::isValidDay(char *day)
|
||||
{
|
||||
if (!isNumericString(day))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int iDay = std::stoi(day);
|
||||
if (iDay == 0 || iDay >= 365)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param productID
|
||||
* @return
|
||||
*/
|
||||
BOOL PIDGEN2::isValidRetailProductID(char *productID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channelID
|
||||
* @param keyout
|
||||
* @return
|
||||
*/
|
||||
int PIDGEN2::GenerateRetail(char *channelID, char *&keyout)
|
||||
{
|
||||
if (!isValidChannelID(channelID))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param year
|
||||
* @param day
|
||||
* @param oem
|
||||
* @param keyout
|
||||
* @return
|
||||
*/
|
||||
int PIDGEN2::GenerateOEM(char *year, char *day, char *oem, char *&keyout)
|
||||
{
|
||||
if (!isValidOEMID(oem))
|
||||
{
|
||||
int mod = addDigits(oem);
|
||||
mod += mod % 21;
|
||||
|
||||
snprintf(oem, 8, "%07u", mod);
|
||||
}
|
||||
|
||||
if (!isValidYear(year))
|
||||
{
|
||||
_strncpy(year, 4, validYears[0], 4);
|
||||
}
|
||||
|
||||
if (!isValidDay(day))
|
||||
{
|
||||
auto iday = UMSKT::getRandom<int>();
|
||||
iday = (iday + 1) % 365;
|
||||
}
|
||||
|
||||
_strncpy(keyout, 32, &fmt::format("{}{}-OEM-{}-{}", year, day, oem, oem).c_str()[0], 32);
|
||||
|
||||
return 0;
|
||||
}
|
50
src/libumskt/pidgen2/PIDGEN2.h
Normal file
50
src/libumskt/pidgen2/PIDGEN2.h
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/17/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_PIDGEN2_H
|
||||
#define UMSKT_PIDGEN2_H
|
||||
|
||||
#include "../libumskt.h"
|
||||
|
||||
class EXPORT PIDGEN2
|
||||
{
|
||||
DWORD year;
|
||||
DWORD day;
|
||||
BOOL isOEM;
|
||||
BOOL isOffice;
|
||||
|
||||
static constexpr char channelIDBlacklist[7][4] = {"333", "444", "555", "666", "777", "888", "999"};
|
||||
static constexpr char validYears[8][3] = {"95", "96", "97", "98", "99", "00", "01", "02"};
|
||||
|
||||
public:
|
||||
BOOL isNumericString(char *input);
|
||||
BOOL isValidChannelID(char *channelID);
|
||||
BOOL isValidOEMID(char *OEMID);
|
||||
BOOL isValidYear(char *year);
|
||||
BOOL isValidDay(char *day);
|
||||
BOOL isValidRetailProductID(char *productID);
|
||||
int addDigits(char *input);
|
||||
int GenerateRetail(char *channelID, char *&keyout);
|
||||
int GenerateOEM(char *year, char *day, char *oem, char *&keyout);
|
||||
};
|
||||
|
||||
#endif // UMSKT_PIDGEN2_H
|
284
src/libumskt/pidgen3/BINK1998.cpp
Normal file
284
src/libumskt/pidgen3/BINK1998.cpp
Normal file
@ -0,0 +1,284 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Andrew on 01/06/2023
|
||||
* @Maintainer Andrew
|
||||
*
|
||||
* @History {
|
||||
* Algorithm was initially written and open sourced by z22
|
||||
* and uploaded to GitHub by TheMCHK in August of 2019
|
||||
*
|
||||
* Endermanch (Andrew) rewrote the algorithm in May of 2023
|
||||
* }
|
||||
*/
|
||||
|
||||
#include "BINK1998.h"
|
||||
|
||||
/**
|
||||
* Packs a Windows XP-like Product Key.
|
||||
*
|
||||
* @param pRaw [in] *QWORD[2] raw product key input
|
||||
**/
|
||||
BOOL BINK1998::Pack(QWORD *pRaw)
|
||||
{
|
||||
// The quantity of information the key provides is 114 bits.
|
||||
// We're storing it in 2 64-bit quad-words with 14 trailing bits.
|
||||
// 64 * 2 = 128
|
||||
|
||||
// Signature [114..59] <- Hash [58..31] <- Serial [30..1] <- Upgrade [0]
|
||||
pRaw[0] = FIRSTNBITS(info.Signature, 5) << 59 | FIRSTNBITS(info.Hash, 28) << 31 | info.Serial << 1 | info.isUpgrade;
|
||||
pRaw[1] = NEXTSNBITS(info.Signature, 51, 5);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpacks a Windows XP-like Product Key.
|
||||
*
|
||||
* @param pRaw [out] *QWORD[2] raw product key output
|
||||
**/
|
||||
BOOL BINK1998::Unpack(QWORD *pRaw)
|
||||
{
|
||||
// We're assuming that the quantity of information within the product key is at most 114 bits.
|
||||
// log2(24^25) = 114.
|
||||
|
||||
// Upgrade = Bit 0
|
||||
info.isUpgrade = FIRSTNBITS(pRaw[0], 1);
|
||||
|
||||
// Serial = Bits [1..30] -> 30 bits
|
||||
info.Serial = NEXTSNBITS(pRaw[0], 30, 1);
|
||||
|
||||
// Hash = Bits [31..58] -> 28 bits
|
||||
info.Hash = NEXTSNBITS(pRaw[0], 28, 31);
|
||||
|
||||
// Signature = Bits [59..113] -> 56 bits
|
||||
info.Signature = FIRSTNBITS(pRaw[1], 51) << 5 | NEXTSNBITS(pRaw[0], 5, 59);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a Windows XP-like Product Key.
|
||||
*
|
||||
* @param pKey [out]
|
||||
*
|
||||
* @return true on success, false on fail
|
||||
*/
|
||||
BOOL BINK1998::Generate(std::string &pKey)
|
||||
{
|
||||
BN_CTX *numContext = BN_CTX_new();
|
||||
|
||||
BIGNUM *c = BN_CTX_get(numContext), *s = BN_CTX_get(numContext), *x = BN_CTX_get(numContext),
|
||||
*y = BN_CTX_get(numContext);
|
||||
|
||||
QWORD pRaw[2];
|
||||
|
||||
// Data segment of the RPK.
|
||||
DWORD pData = info.Serial << 1 | info.isUpgrade;
|
||||
|
||||
// prepare the private key for generation
|
||||
BN_sub(privateKey, genOrder, privateKey);
|
||||
|
||||
do
|
||||
{
|
||||
EC_POINT *r = EC_POINT_new(eCurve);
|
||||
|
||||
// Generate a random number c consisting of 384 bits without any constraints.
|
||||
BN_rand(c, FIELD_BITS, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY);
|
||||
|
||||
// Pick a random derivative of the base point on the elliptic curve.
|
||||
// R = cG;
|
||||
EC_POINT_mul(eCurve, r, nullptr, genPoint, c, numContext);
|
||||
|
||||
// Acquire its coordinates.
|
||||
// x = R.x; y = R.y;
|
||||
EC_POINT_get_affine_coordinates(eCurve, r, x, y, numContext);
|
||||
|
||||
BYTE msgDigest[SHA_DIGEST_LENGTH], msgBuffer[SHA_MSG_LENGTH_XP];
|
||||
BYTE xBin[FIELD_BYTES], yBin[FIELD_BYTES];
|
||||
|
||||
// Convert coordinates to bytes.
|
||||
UMSKT::BN_bn2lebin(x, xBin, FIELD_BYTES);
|
||||
UMSKT::BN_bn2lebin(y, yBin, FIELD_BYTES);
|
||||
|
||||
// Assemble the SHA message.
|
||||
memcpy(&msgBuffer[0], &pData, 4);
|
||||
memcpy(&msgBuffer[4], xBin, FIELD_BYTES);
|
||||
memcpy(&msgBuffer[4 + FIELD_BYTES], yBin, FIELD_BYTES);
|
||||
|
||||
// pHash = SHA1(pSerial || R.x || R.y)
|
||||
SHA1(msgBuffer, SHA_MSG_LENGTH_XP, msgDigest);
|
||||
|
||||
// Translate the byte digest into a 32-bit integer - this is our computed pHash.
|
||||
// Truncate the pHash to 28 bits.
|
||||
info.Hash = BYDWORD(msgDigest) >> 4 & BITMASK(28);
|
||||
|
||||
/*
|
||||
*
|
||||
* Scalars:
|
||||
* c = Random multiplier
|
||||
* e = Hash
|
||||
* s = Signature
|
||||
* n = Order of G
|
||||
* k = Private Key
|
||||
*
|
||||
* Points:
|
||||
* G(x, y) = Generator (Base Point)
|
||||
* R(x, y) = Random derivative of the generator
|
||||
* K(x, y) = Public Key
|
||||
*
|
||||
* We need to find the signature s that satisfies the equation with a given hash:
|
||||
* P = sG + eK
|
||||
* s = ek + c (mod n) <- computation optimization
|
||||
*/
|
||||
|
||||
// s = ek;
|
||||
BN_copy(s, privateKey);
|
||||
BN_mul_word(s, info.Hash);
|
||||
|
||||
// s += c (mod n)
|
||||
BN_mod_add(s, s, c, genOrder, numContext);
|
||||
|
||||
// Translate resulting scalar into a 64-bit integer (the byte order is little-endian).
|
||||
BN_bn2lebinpad(s, (BYTE *)&info.Signature, BN_num_bytes(s));
|
||||
|
||||
// Pack product key.
|
||||
Pack(pRaw);
|
||||
|
||||
auto serial = fmt::format("{:d}", info.Serial);
|
||||
fmt::print(UMSKT::debug, "Generation results:\n");
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:b}\n", "Upgrade", (bool)info.isUpgrade);
|
||||
fmt::print(UMSKT::debug, "{:>10}: {}\n", "Channel ID", serial.substr(0, 3));
|
||||
fmt::print(UMSKT::debug, "{:>10}: {}\n", "Sequence", serial.substr(3));
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:d}\n", "Hash", info.Hash);
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:d}\n", "Signature", info.Signature);
|
||||
fmt::print(UMSKT::debug, "\n");
|
||||
|
||||
EC_POINT_free(r);
|
||||
} while (info.Signature > BITMASK(55));
|
||||
// ↑ ↑ ↑
|
||||
// The signature can't be longer than 55 bits, else it will
|
||||
// make the CD-key longer than 25 characters.
|
||||
|
||||
// Convert bytecode to Base24 CD-key.
|
||||
base24(pKey, (BYTE *)pRaw);
|
||||
|
||||
BN_CTX_free(numContext);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a Windows XP-like Product Key.
|
||||
*
|
||||
* @param pKey [in]
|
||||
*
|
||||
* @return true if provided key validates against loaded curve
|
||||
*/
|
||||
BOOL BINK1998::Validate(std::string &pKey)
|
||||
{
|
||||
if (pKey.length() != 25)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
BN_CTX *numContext = BN_CTX_new();
|
||||
|
||||
QWORD pRaw[2];
|
||||
|
||||
// Convert Base24 CD-key to bytecode.
|
||||
unbase24((BYTE *)pRaw, pKey);
|
||||
|
||||
// Extract RPK, hash and signature from bytecode.
|
||||
Unpack(pRaw);
|
||||
|
||||
auto serial = fmt::format("{:d}", info.Serial);
|
||||
fmt::print(UMSKT::debug, "Validation results:\n");
|
||||
fmt::print(UMSKT::debug, "{:>10}: {}\n", "Upgrade", (bool)info.isUpgrade);
|
||||
fmt::print(UMSKT::debug, "{:>10}: {}\n", "Channel ID", serial.substr(0, 3));
|
||||
fmt::print(UMSKT::debug, "{:>10}: {}\n", "Sequence", serial.substr(3));
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:d}\n", "Hash", info.Hash);
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:d}\n", "Signature", info.Signature);
|
||||
fmt::print(UMSKT::debug, "\n");
|
||||
|
||||
DWORD pData = info.Serial << 1 | info.isUpgrade;
|
||||
|
||||
/*
|
||||
*
|
||||
* Scalars:
|
||||
* e = Hash
|
||||
* s = Schnorr Signature
|
||||
*
|
||||
* Points:
|
||||
* G(x, y) = Generator (Base Point)
|
||||
* K(x, y) = Public Key
|
||||
*
|
||||
* Equation:
|
||||
* P = sG + eK
|
||||
*
|
||||
*/
|
||||
|
||||
BIGNUM *e = BN_lebin2bn((BYTE *)&info.Hash, sizeof(info.Hash), nullptr),
|
||||
*s = BN_lebin2bn((BYTE *)&info.Signature, sizeof(info.Signature), nullptr);
|
||||
|
||||
BIGNUM *x = BN_CTX_get(numContext), *y = BN_CTX_get(numContext);
|
||||
|
||||
// Create 2 points on the elliptic curve.
|
||||
EC_POINT *t = EC_POINT_new(eCurve), *p = EC_POINT_new(eCurve);
|
||||
|
||||
// t = sG
|
||||
EC_POINT_mul(eCurve, t, nullptr, genPoint, s, numContext);
|
||||
|
||||
// P = eK
|
||||
EC_POINT_mul(eCurve, p, nullptr, pubPoint, e, numContext);
|
||||
|
||||
// P += t
|
||||
EC_POINT_add(eCurve, p, t, p, numContext);
|
||||
|
||||
// x = P.x; y = P.y;
|
||||
EC_POINT_get_affine_coordinates(eCurve, p, x, y, numContext);
|
||||
|
||||
BYTE msgDigest[SHA_DIGEST_LENGTH], msgBuffer[SHA_MSG_LENGTH_XP], xBin[FIELD_BYTES], yBin[FIELD_BYTES];
|
||||
|
||||
// Convert resulting point coordinates to bytes.
|
||||
UMSKT::BN_bn2lebin(x, xBin, FIELD_BYTES);
|
||||
UMSKT::BN_bn2lebin(y, yBin, FIELD_BYTES);
|
||||
|
||||
// Assemble the SHA message.
|
||||
memcpy(&msgBuffer[0], &pData, 4);
|
||||
memcpy(&msgBuffer[4], xBin, FIELD_BYTES);
|
||||
memcpy(&msgBuffer[4 + FIELD_BYTES], yBin, FIELD_BYTES);
|
||||
|
||||
// compHash = SHA1(pSerial || P.x || P.y)
|
||||
SHA1(msgBuffer, SHA_MSG_LENGTH_XP, msgDigest);
|
||||
|
||||
// Translate the byte digest into a 32-bit integer - this is our computed hash.
|
||||
// Truncate the hash to 28 bits.
|
||||
DWORD compHash = BYDWORD(msgDigest) >> 4 & BITMASK(28);
|
||||
|
||||
BN_free(e);
|
||||
BN_free(s);
|
||||
|
||||
BN_CTX_free(numContext);
|
||||
|
||||
EC_POINT_free(t);
|
||||
EC_POINT_free(p);
|
||||
|
||||
// If the computed hash checks out, the key is valid.
|
||||
return compHash == info.Hash;
|
||||
}
|
54
src/libumskt/pidgen3/BINK1998.h
Normal file
54
src/libumskt/pidgen3/BINK1998.h
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/06/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_BINK1998_H
|
||||
#define UMSKT_BINK1998_H
|
||||
|
||||
#include "PIDGEN3.h"
|
||||
|
||||
class EXPORT BINK1998 : public PIDGEN3
|
||||
{
|
||||
public:
|
||||
using PIDGEN3::PIDGEN3;
|
||||
explicit BINK1998(PIDGEN3 *p3)
|
||||
{
|
||||
privateKey = p3->privateKey;
|
||||
genOrder = p3->genOrder;
|
||||
genPoint = p3->genPoint;
|
||||
pubPoint = p3->pubPoint;
|
||||
eCurve = p3->eCurve;
|
||||
}
|
||||
|
||||
using PIDGEN3::Pack;
|
||||
BOOL Pack(QWORD *pRaw) override;
|
||||
|
||||
using PIDGEN3::Unpack;
|
||||
BOOL Unpack(QWORD *pRaw) override;
|
||||
|
||||
using PIDGEN3::Generate;
|
||||
BOOL Generate(std::string &pKey) override;
|
||||
|
||||
using PIDGEN3::Validate;
|
||||
BOOL Validate(std::string &pKey) override;
|
||||
};
|
||||
|
||||
#endif // UMSKT_BINK1998_H
|
363
src/libumskt/pidgen3/BINK2002.cpp
Normal file
363
src/libumskt/pidgen3/BINK2002.cpp
Normal file
@ -0,0 +1,363 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Andrew on 01/06/2023
|
||||
* @Maintainer Andrew
|
||||
*
|
||||
* @History {
|
||||
* Algorithm was initially written and open sourced by z22
|
||||
* and uploaded to GitHub by TheMCHK in August of 2019
|
||||
*
|
||||
* Endermanch (Andrew) rewrote the algorithm in May of 2023
|
||||
* }
|
||||
*/
|
||||
|
||||
#include "BINK2002.h"
|
||||
|
||||
/**
|
||||
* Packs a Windows Server 2003-like Product Key.
|
||||
*
|
||||
* @param pRaw *QWORD[2] raw product key output
|
||||
**/
|
||||
BOOL BINK2002::Pack(QWORD *pRaw)
|
||||
{
|
||||
// AuthInfo [113..104] <- Signature [103..42] <- Hash [41..11] <- Channel ID [10..1] <- Upgrade [0]
|
||||
pRaw[0] = FIRSTNBITS(info.Signature, 22) << 42 | (QWORD)info.Hash << 11 | info.ChannelID << 1 | info.isUpgrade;
|
||||
pRaw[1] = FIRSTNBITS(info.AuthInfo, 10) << 40 | NEXTSNBITS(info.Signature, 40, 22);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpacks a Windows Server 2003-like Product Key.
|
||||
*
|
||||
* @param pRaw *QWORD[2] raw product key input
|
||||
**/
|
||||
BOOL BINK2002::Unpack(QWORD *pRaw)
|
||||
{
|
||||
// We're assuming that the quantity of information within the product key is at most 114 bits.
|
||||
// log2(24^25) = 114.
|
||||
|
||||
// Upgrade = Bit 0
|
||||
info.isUpgrade = FIRSTNBITS(pRaw[0], 1);
|
||||
|
||||
// Channel ID = Bits [1..10] -> 10 bits
|
||||
info.ChannelID = NEXTSNBITS(pRaw[0], 10, 1);
|
||||
|
||||
// Hash = Bits [11..41] -> 31 bits
|
||||
info.Hash = NEXTSNBITS(pRaw[0], 31, 11);
|
||||
|
||||
// Signature = Bits [42..103] -> 62 bits
|
||||
// The quad-word signature overlaps AuthInfo in bits 104 and 105,
|
||||
// hence Microsoft employs a secret technique called: Signature = HIDWORD(Signature) >> 2 | LODWORD(Signature)
|
||||
info.Signature = NEXTSNBITS(pRaw[1], 30, 10) << 32 | FIRSTNBITS(pRaw[1], 10) << 22 | NEXTSNBITS(pRaw[0], 22, 42);
|
||||
|
||||
// AuthInfo = Bits [104..113] -> 10 bits
|
||||
info.AuthInfo = NEXTSNBITS(pRaw[1], 10, 40);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a Windows Server 2003-like Product Key.
|
||||
*
|
||||
* @param info
|
||||
* @param pKey
|
||||
* @return
|
||||
*/
|
||||
BOOL BINK2002::Generate(std::string &pKey)
|
||||
{
|
||||
BN_CTX *numContext = BN_CTX_new();
|
||||
|
||||
BIGNUM *c = BN_CTX_get(numContext), *e = BN_CTX_get(numContext), *s = BN_CTX_get(numContext),
|
||||
*x = BN_CTX_get(numContext), *y = BN_CTX_get(numContext);
|
||||
|
||||
QWORD pRaw[2];
|
||||
|
||||
// Data segment of the RPK.
|
||||
DWORD pData = info.ChannelID << 1 | info.isUpgrade;
|
||||
|
||||
BOOL noSquare;
|
||||
|
||||
do
|
||||
{
|
||||
EC_POINT *r = EC_POINT_new(eCurve);
|
||||
|
||||
// Generate a random number c consisting of 512 bits without any constraints.
|
||||
BN_rand(c, FIELD_BITS_2003, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY);
|
||||
|
||||
// R = cG
|
||||
EC_POINT_mul(eCurve, r, nullptr, genPoint, c, numContext);
|
||||
|
||||
// Acquire its coordinates.
|
||||
// x = R.x; y = R.y;
|
||||
EC_POINT_get_affine_coordinates(eCurve, r, x, y, numContext);
|
||||
|
||||
BYTE msgDigest[SHA_DIGEST_LENGTH], msgBuffer[SHA_MSG_LENGTH_2003], xBin[FIELD_BYTES_2003],
|
||||
yBin[FIELD_BYTES_2003];
|
||||
|
||||
// Convert resulting point coordinates to bytes.
|
||||
UMSKT::BN_bn2lebin(x, xBin, FIELD_BYTES_2003);
|
||||
UMSKT::BN_bn2lebin(y, yBin, FIELD_BYTES_2003);
|
||||
|
||||
// Assemble the first SHA message.
|
||||
msgBuffer[0x00] = 0x79;
|
||||
msgBuffer[0x01] = (pData & 0x00FF);
|
||||
msgBuffer[0x02] = (pData & 0xFF00) >> 8;
|
||||
|
||||
memcpy(&msgBuffer[3], xBin, FIELD_BYTES_2003);
|
||||
memcpy(&msgBuffer[3 + FIELD_BYTES_2003], yBin, FIELD_BYTES_2003);
|
||||
|
||||
// pHash = SHA1(79 || Channel ID || R.x || R.y)
|
||||
SHA1(msgBuffer, SHA_MSG_LENGTH_2003, msgDigest);
|
||||
|
||||
// Translate the byte digest into a 32-bit integer - this is our computed hash.
|
||||
// Truncate the hash to 31 bits.
|
||||
info.Hash = BYDWORD(msgDigest) & BITMASK(31);
|
||||
|
||||
// Assemble the second SHA message.
|
||||
msgBuffer[0x00] = 0x5D;
|
||||
msgBuffer[0x01] = (pData & 0x00FF);
|
||||
msgBuffer[0x02] = (pData & 0xFF00) >> 8;
|
||||
msgBuffer[0x03] = (info.Hash & 0x000000FF);
|
||||
msgBuffer[0x04] = (info.Hash & 0x0000FF00) >> 8;
|
||||
msgBuffer[0x05] = (info.Hash & 0x00FF0000) >> 16;
|
||||
msgBuffer[0x06] = (info.Hash & 0xFF000000) >> 24;
|
||||
msgBuffer[0x07] = (info.AuthInfo & 0x00FF);
|
||||
msgBuffer[0x08] = (info.AuthInfo & 0xFF00) >> 8;
|
||||
msgBuffer[0x09] = 0x00;
|
||||
msgBuffer[0x0A] = 0x00;
|
||||
|
||||
// newSignature = SHA1(5D || Channel ID || Hash || AuthInfo || 00 00)
|
||||
SHA1(msgBuffer, 11, msgDigest);
|
||||
|
||||
// Translate the byte digest into a 64-bit integer - this is our computed intermediate signature.
|
||||
// As the signature is only 62 bits long at most, we have to truncate it by shifting the high DWORD right 2
|
||||
// bits (per spec).
|
||||
QWORD iSignature = NEXTSNBITS(BYDWORD(&msgDigest[4]), 30, 2) << 32 | BYDWORD(msgDigest);
|
||||
|
||||
BN_lebin2bn((BYTE *)&iSignature, sizeof(iSignature), e);
|
||||
|
||||
/*
|
||||
*
|
||||
* Scalars:
|
||||
* c = Random multiplier
|
||||
* e = Intermediate Signature
|
||||
* s = Signature
|
||||
* n = Order of G
|
||||
* k = Private Key
|
||||
*
|
||||
* Points:
|
||||
* G(x, y) = Generator (Base Point)
|
||||
* R(x, y) = Random derivative of the generator
|
||||
* K(x, y) = Public Key
|
||||
*
|
||||
* Equation:
|
||||
* s(sG + eK) = R (mod p)
|
||||
* ↓ K = kG; R = cG ↓
|
||||
*
|
||||
* s(sG + ekG) = cG (mod p)
|
||||
* s(s + ek)G = cG (mod p)
|
||||
* ↓ G cancels out, the scalar arithmetic shrinks to order n ↓
|
||||
*
|
||||
* s(s + ek) = c (mod n)
|
||||
* s² + (ek)s - c = 0 (mod n)
|
||||
* ↓ This is a quadratic equation in respect to the signature ↓
|
||||
*
|
||||
* s = (-ek ± √((ek)² + 4c)) / 2 (mod n)
|
||||
*/
|
||||
|
||||
// e = ek (mod n)
|
||||
BN_mod_mul(e, e, privateKey, genOrder, numContext);
|
||||
|
||||
// s = e
|
||||
BN_copy(s, e);
|
||||
|
||||
// s = (ek (mod n))²
|
||||
BN_mod_sqr(s, s, genOrder, numContext);
|
||||
|
||||
// c *= 4 (c <<= 2)
|
||||
BN_lshift(c, c, 2);
|
||||
|
||||
// s += c
|
||||
BN_add(s, s, c);
|
||||
|
||||
// Around half of numbers modulo a prime are not squares -> BN_sqrt_mod fails about half of the times,
|
||||
// hence if BN_sqrt_mod returns NULL, we need to restart with a different seed.
|
||||
// s = √((ek)² + 4c (mod n))
|
||||
noSquare = BN_mod_sqrt(s, s, genOrder, numContext) == nullptr;
|
||||
|
||||
// s = -ek + √((ek)² + 4c) (mod n)
|
||||
BN_mod_sub(s, s, e, genOrder, numContext);
|
||||
|
||||
// If s is odd, add order to it.
|
||||
// The order is a prime, so it can't be even.
|
||||
if (BN_is_odd(s))
|
||||
{
|
||||
// s = -ek + √((ek)² + 4c) + n
|
||||
BN_add(s, s, genOrder);
|
||||
}
|
||||
|
||||
// s /= 2 (s >>= 1)
|
||||
BN_rshift1(s, s);
|
||||
|
||||
// Translate resulting scalar into a 64-bit integer (the byte order is little-endian).
|
||||
BN_bn2lebinpad(s, (BYTE *)&info.Signature, BN_num_bytes(s));
|
||||
|
||||
// Pack product key.
|
||||
Pack(pRaw);
|
||||
|
||||
fmt::print(UMSKT::debug, "Generation results:\n");
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:b}\n", "Upgrade", (bool)info.isUpgrade);
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:d}\n", "Channel ID", info.ChannelID);
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:d}\n", "Hash", info.Hash);
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:d}\n", "Signature", info.Signature);
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:d}\n", "AuthInfo", info.AuthInfo);
|
||||
fmt::print(UMSKT::debug, "\n");
|
||||
|
||||
EC_POINT_free(r);
|
||||
} while (info.Signature > BITMASK(62) || noSquare);
|
||||
// ↑ ↑ ↑
|
||||
// The signature can't be longer than 62 bits, else it will
|
||||
// overlap with the AuthInfo segment next to it.
|
||||
|
||||
// Convert bytecode to Base24 CD-key.
|
||||
base24(pKey, (BYTE *)pRaw);
|
||||
|
||||
BN_CTX_free(numContext);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a Windows Server 2003-like Product Key.
|
||||
*
|
||||
* @param pKey
|
||||
**/
|
||||
BOOL BINK2002::Validate(std::string &pKey)
|
||||
{
|
||||
BN_CTX *context = BN_CTX_new();
|
||||
|
||||
QWORD bKey[2];
|
||||
|
||||
// Convert Base24 CD-key to bytecode.
|
||||
unbase24((BYTE *)bKey, &pKey[0]);
|
||||
|
||||
// Extract product key segments from bytecode.
|
||||
Unpack(bKey);
|
||||
|
||||
DWORD pData = info.ChannelID << 1 | info.isUpgrade;
|
||||
|
||||
fmt::print(UMSKT::debug, "Validation results:\n");
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:b}\n", "Upgrade", (bool)info.isUpgrade);
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:d}\n", "Channel ID", info.ChannelID);
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:d}\n", "Hash", info.Hash);
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:d}\n", "Signature", info.Signature);
|
||||
fmt::print(UMSKT::debug, "{:>10}: {:d}\n", "AuthInfo", info.AuthInfo);
|
||||
fmt::print(UMSKT::debug, "\n");
|
||||
|
||||
BYTE msgDigest[SHA_DIGEST_LENGTH], msgBuffer[SHA_MSG_LENGTH_2003], xBin[FIELD_BYTES_2003], yBin[FIELD_BYTES_2003];
|
||||
|
||||
// Assemble the first SHA message.
|
||||
msgBuffer[0x00] = 0x5D;
|
||||
msgBuffer[0x01] = (pData & 0x00FF);
|
||||
msgBuffer[0x02] = (pData & 0xFF00) >> 8;
|
||||
msgBuffer[0x03] = (info.Hash & 0x000000FF);
|
||||
msgBuffer[0x04] = (info.Hash & 0x0000FF00) >> 8;
|
||||
msgBuffer[0x05] = (info.Hash & 0x00FF0000) >> 16;
|
||||
msgBuffer[0x06] = (info.Hash & 0xFF000000) >> 24;
|
||||
msgBuffer[0x07] = (info.AuthInfo & 0x00FF);
|
||||
msgBuffer[0x08] = (info.AuthInfo & 0xFF00) >> 8;
|
||||
msgBuffer[0x09] = 0x00;
|
||||
msgBuffer[0x0A] = 0x00;
|
||||
|
||||
// newSignature = SHA1(5D || Channel ID || Hash || AuthInfo || 00 00)
|
||||
SHA1(msgBuffer, 11, msgDigest);
|
||||
|
||||
// Translate the byte digest into a 64-bit integer - this is our computed intermediate signature.
|
||||
// As the signature is only 62 bits long at most, we have to truncate it by shifting the high DWORD right 2 bits
|
||||
// (per spec).
|
||||
QWORD iSignature = NEXTSNBITS(BYDWORD(&msgDigest[4]), 30, 2) << 32 | BYDWORD(msgDigest);
|
||||
|
||||
/*
|
||||
*
|
||||
* Scalars:
|
||||
* e = Hash
|
||||
* s = Schnorr Signature
|
||||
*
|
||||
* Points:
|
||||
* G(x, y) = Generator (Base Point)
|
||||
* K(x, y) = Public Key
|
||||
*
|
||||
* Equation:
|
||||
* P = s(sG + eK)
|
||||
*
|
||||
*/
|
||||
|
||||
BIGNUM *e = BN_lebin2bn((BYTE *)&iSignature, sizeof(iSignature), nullptr),
|
||||
*s = BN_lebin2bn((BYTE *)&info.Signature, sizeof(info.Signature), nullptr);
|
||||
BIGNUM *x = BN_CTX_get(context), *y = BN_CTX_get(context);
|
||||
|
||||
// Create 2 points on the elliptic curve.
|
||||
EC_POINT *p = EC_POINT_new(eCurve), *t = EC_POINT_new(eCurve);
|
||||
|
||||
// t = sG
|
||||
EC_POINT_mul(eCurve, t, nullptr, genPoint, s, context);
|
||||
|
||||
// p = eK
|
||||
EC_POINT_mul(eCurve, p, nullptr, pubPoint, e, context);
|
||||
|
||||
// p += t
|
||||
EC_POINT_add(eCurve, p, t, p, context);
|
||||
|
||||
// p *= s
|
||||
EC_POINT_mul(eCurve, p, nullptr, p, s, context);
|
||||
|
||||
// x = p.x; y = p.y;
|
||||
EC_POINT_get_affine_coordinates(eCurve, p, x, y, context);
|
||||
|
||||
// Convert resulting point coordinates to bytes.
|
||||
UMSKT::BN_bn2lebin(x, xBin, FIELD_BYTES_2003);
|
||||
UMSKT::BN_bn2lebin(y, yBin, FIELD_BYTES_2003);
|
||||
|
||||
// Assemble the second SHA message.
|
||||
msgBuffer[0x00] = 0x79;
|
||||
msgBuffer[0x01] = (pData & 0x00FF);
|
||||
msgBuffer[0x02] = (pData & 0xFF00) >> 8;
|
||||
|
||||
memcpy((void *)&msgBuffer[3], (void *)xBin, FIELD_BYTES_2003);
|
||||
memcpy((void *)&msgBuffer[3 + FIELD_BYTES_2003], (void *)yBin, FIELD_BYTES_2003);
|
||||
|
||||
// compHash = SHA1(79 || Channel ID || p.x || p.y)
|
||||
SHA1(msgBuffer, SHA_MSG_LENGTH_2003, msgDigest);
|
||||
|
||||
// Translate the byte digest into a 32-bit integer - this is our computed hash.
|
||||
// Truncate the hash to 31 bits.
|
||||
DWORD compHash = BYDWORD(msgDigest) & BITMASK(31);
|
||||
|
||||
BN_free(s);
|
||||
BN_free(e);
|
||||
|
||||
EC_POINT_free(p);
|
||||
EC_POINT_free(t);
|
||||
|
||||
BN_CTX_free(context);
|
||||
|
||||
// If the computed hash checks out, the key is valid.
|
||||
return compHash == info.Hash;
|
||||
}
|
54
src/libumskt/pidgen3/BINK2002.h
Normal file
54
src/libumskt/pidgen3/BINK2002.h
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/06/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_BINK2002_H
|
||||
#define UMSKT_BINK2002_H
|
||||
|
||||
#include "PIDGEN3.h"
|
||||
|
||||
class EXPORT BINK2002 : public PIDGEN3
|
||||
{
|
||||
public:
|
||||
using PIDGEN3::PIDGEN3;
|
||||
explicit BINK2002(PIDGEN3 *p3)
|
||||
{
|
||||
privateKey = p3->privateKey;
|
||||
genOrder = p3->genOrder;
|
||||
genPoint = p3->genPoint;
|
||||
pubPoint = p3->pubPoint;
|
||||
eCurve = p3->eCurve;
|
||||
}
|
||||
|
||||
using PIDGEN3::Pack;
|
||||
BOOL Pack(QWORD *pRaw) override;
|
||||
|
||||
using PIDGEN3::Unpack;
|
||||
BOOL Unpack(QWORD *pRaw) override;
|
||||
|
||||
using PIDGEN3::Generate;
|
||||
BOOL Generate(std::string &pKey) override;
|
||||
|
||||
using PIDGEN3::Validate;
|
||||
BOOL Validate(std::string &pKey) override;
|
||||
};
|
||||
|
||||
#endif // UMSKT_BINK2002_H
|
277
src/libumskt/pidgen3/PIDGEN3.cpp
Normal file
277
src/libumskt/pidgen3/PIDGEN3.cpp
Normal file
@ -0,0 +1,277 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Andrew on 01/06/2023
|
||||
* @Maintainer Andrew
|
||||
*/
|
||||
|
||||
#include "PIDGEN3.h"
|
||||
#include "BINK1998.h"
|
||||
#include "BINK2002.h"
|
||||
|
||||
/**
|
||||
* https://xkcd.com/221/
|
||||
*
|
||||
* @return 4
|
||||
*/
|
||||
int getRandomNumber()
|
||||
{
|
||||
return 4; // chosen by fair dice roll
|
||||
// guaranteed to be random
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the elliptic curve
|
||||
*
|
||||
* @param pSel [in] prime
|
||||
* @param aSel [in] a
|
||||
* @param bSel [in] b
|
||||
* @param generatorXSel [in] G[x]
|
||||
* @param generatorYSel [in] G[y]
|
||||
* @param publicKeyXSel [in] pub[x]
|
||||
* @param publicKeyYSel [in] pub[y]
|
||||
* @param genOrderSel [in] computed order of G
|
||||
* @param privateKeySel [in] computed private key
|
||||
*
|
||||
* @return true on success, false on fail
|
||||
*/
|
||||
BOOL PIDGEN3::LoadEllipticCurve(const std::string pSel, const std::string aSel, const std::string bSel,
|
||||
const std::string generatorXSel, const std::string generatorYSel,
|
||||
const std::string publicKeyXSel, const std::string publicKeyYSel,
|
||||
const std::string genOrderSel, const std::string privateKeySel)
|
||||
{
|
||||
// We cannot produce a valid key without knowing the private key k. The reason for this is that
|
||||
// we need the result of the function K(x; y) = kG(x; y).
|
||||
|
||||
// We can, however, validate any given key using the available public key: {p, a, b, G, K}.
|
||||
// genOrder the order of the generator G, a value we have to reverse -> Schoof's Algorithm.
|
||||
|
||||
// Initialize BIGNUM and BIGNUMCTX structures.
|
||||
// BIGNUM - Large numbers
|
||||
// BIGNUMCTX - Context large numbers (temporary)
|
||||
|
||||
// Context variable
|
||||
BN_CTX *context = BN_CTX_new();
|
||||
|
||||
// We're presented with an elliptic curve, a multivariable function y(x; p; a; b), where
|
||||
// y^2 % p = x^3 + ax + b % p.
|
||||
BIGNUM *a = BN_CTX_get(context), *b = BN_CTX_get(context), *p = BN_CTX_get(context);
|
||||
|
||||
// Public key will consist of the resulting (x; y) values.
|
||||
BIGNUM *publicKeyX = BN_CTX_get(context), *publicKeyY = BN_CTX_get(context);
|
||||
|
||||
// G(x; y) is a generator function, its return value represents a point on the elliptic curve.
|
||||
BIGNUM *generatorX = BN_CTX_get(context), *generatorY = BN_CTX_get(context);
|
||||
|
||||
genOrder = BN_new();
|
||||
privateKey = BN_new();
|
||||
|
||||
/* Public data */
|
||||
BN_dec2bn(&p, &pSel[0]);
|
||||
BN_dec2bn(&a, &aSel[0]);
|
||||
BN_dec2bn(&b, &bSel[0]);
|
||||
BN_dec2bn(&generatorX, &generatorXSel[0]);
|
||||
BN_dec2bn(&generatorY, &generatorYSel[0]);
|
||||
|
||||
BN_dec2bn(&publicKeyX, &publicKeyXSel[0]);
|
||||
BN_dec2bn(&publicKeyY, &publicKeyYSel[0]);
|
||||
|
||||
/* Computed Data */
|
||||
BN_dec2bn(&genOrder, &genOrderSel[0]);
|
||||
BN_dec2bn(&privateKey, &privateKeySel[0]);
|
||||
|
||||
/* Elliptic Curve calculations. */
|
||||
// The group is defined via Fp = all integers [0; p - 1], where p is prime.
|
||||
// The function EC_POINT_set_affine_coordinates() sets the x and y coordinates for the point p defined over the
|
||||
// curve given in group.
|
||||
eCurve = EC_GROUP_new_curve_GFp(p, a, b, context);
|
||||
|
||||
// Create new point for the generator on the elliptic curve and set its coordinates to (genX; genY).
|
||||
genPoint = EC_POINT_new(eCurve);
|
||||
EC_POINT_set_affine_coordinates(eCurve, genPoint, generatorX, generatorY, context);
|
||||
|
||||
// Create new point for the public key on the elliptic curve and set its coordinates to (pubX; pubY).
|
||||
pubPoint = EC_POINT_new(eCurve);
|
||||
EC_POINT_set_affine_coordinates(eCurve, pubPoint, publicKeyX, publicKeyY, context);
|
||||
|
||||
// If generator and public key points are not on the elliptic curve, either the generator or the public key values
|
||||
// are incorrect.
|
||||
assert(EC_POINT_is_on_curve(eCurve, genPoint, context) == true);
|
||||
assert(EC_POINT_is_on_curve(eCurve, pubPoint, context) == true);
|
||||
|
||||
// Cleanup
|
||||
BN_CTX_free(context);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL PIDGEN3::Generate(std::string &pKey)
|
||||
{
|
||||
BOOL retval;
|
||||
|
||||
if (checkFieldIsBink1998())
|
||||
{
|
||||
auto p3 = BINK1998();
|
||||
retval = p3.Generate(pKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto p3 = BINK2002();
|
||||
retval = p3.Generate(pKey);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
BOOL PIDGEN3::Validate(std::string &pKey)
|
||||
{
|
||||
BOOL retval;
|
||||
|
||||
if (checkFieldIsBink1998())
|
||||
{
|
||||
auto p3 = BINK1998(this);
|
||||
retval = p3.Validate(pKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto p3 = BINK2002(this);
|
||||
retval = p3.Validate(pKey);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts from byte sequence to the CD-key.
|
||||
*
|
||||
* @param cdKey [out] std::string CDKey input
|
||||
* @param byteSeq [in] BYTE*
|
||||
**/
|
||||
void PIDGEN3::base24(std::string &cdKey, BYTE *byteSeq)
|
||||
{
|
||||
BYTE rbyteSeq[16], output[26];
|
||||
BIGNUM *z;
|
||||
|
||||
// Copy byte sequence to the reversed byte sequence.
|
||||
memcpy(rbyteSeq, byteSeq, sizeof(rbyteSeq));
|
||||
|
||||
// Skip trailing zeroes and reverse y.
|
||||
int length;
|
||||
|
||||
for (length = 15; rbyteSeq[length] <= 0; length--)
|
||||
{
|
||||
; // do nothing, just counting
|
||||
}
|
||||
|
||||
UMSKT::endian(rbyteSeq, ++length);
|
||||
|
||||
// Convert reversed byte sequence to BigNum z.
|
||||
z = BN_bin2bn(rbyteSeq, length, nullptr);
|
||||
|
||||
// Divide z by 24 and convert the remainder to a CD-key char.
|
||||
for (int i = 24; i >= 0; i--)
|
||||
{
|
||||
output[i] = pKeyCharset[BN_div_word(z, 24)];
|
||||
}
|
||||
|
||||
output[25] = 0;
|
||||
|
||||
cdKey = (char *)output;
|
||||
|
||||
BN_free(z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts from CD-key to a byte sequence.
|
||||
*
|
||||
* @param byteSeq [out] *BYTE representation of the CDKey
|
||||
* @param cdKey [in] std::string CDKey to convert
|
||||
**/
|
||||
void PIDGEN3::unbase24(BYTE *byteSeq, std::string cdKey)
|
||||
{
|
||||
BYTE pDecodedKey[PK_LENGTH + NULL_TERMINATOR]{};
|
||||
BIGNUM *y = BN_new();
|
||||
|
||||
// Remove dashes from the CD-key and put it into a Base24 byte array.
|
||||
for (int i = 0, k = 0; i < cdKey.length() && k < PK_LENGTH; i++)
|
||||
{
|
||||
for (int j = 0; j < 24; j++)
|
||||
{
|
||||
if (cdKey[i] != '-' && cdKey[i] == pKeyCharset[j])
|
||||
{
|
||||
pDecodedKey[k++] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Empty byte sequence.
|
||||
memset(byteSeq, 0, 16);
|
||||
|
||||
// Calculate the weighed sum of byte array elements.
|
||||
for (int i = 0; i < PK_LENGTH; i++)
|
||||
{
|
||||
BN_mul_word(y, PK_LENGTH - 1);
|
||||
BN_add_word(y, pDecodedKey[i]);
|
||||
}
|
||||
|
||||
// Acquire length.
|
||||
int n = BN_num_bytes(y);
|
||||
|
||||
// Place the generated code into the byte sequence.
|
||||
BN_bn2bin(y, byteSeq);
|
||||
BN_free(y);
|
||||
|
||||
// Reverse the byte sequence.
|
||||
UMSKT::endian(byteSeq, n);
|
||||
}
|
||||
|
||||
BOOL PIDGEN3::checkFieldIsBink1998()
|
||||
{
|
||||
auto *max = BN_new();
|
||||
|
||||
// 1 << 385 (or max size of BINK1998 field in bits + 1)
|
||||
BN_set_bit(max, (12 * 4 * 8) + 1);
|
||||
|
||||
// retval is -1 when (max < privateKey)
|
||||
int retval = BN_cmp(max, privateKey);
|
||||
|
||||
BN_free(max);
|
||||
|
||||
// is max > privateKey?
|
||||
return retval == 1;
|
||||
}
|
||||
|
||||
BOOL PIDGEN3::checkFieldStrIsBink1998(std::string keyin)
|
||||
{
|
||||
auto *context = BN_CTX_new();
|
||||
auto max = BN_CTX_get(context), input = BN_CTX_get(context);
|
||||
|
||||
BN_dec2bn(&input, &keyin[0]);
|
||||
|
||||
// 1 << 385 (or max size of BINK1998 field in bits + 1)
|
||||
BN_set_bit(max, (12 * 4 * 8) + 1);
|
||||
|
||||
// retval is -1 when (max < privateKey)
|
||||
int retval = BN_cmp(max, input);
|
||||
|
||||
BN_CTX_free(context);
|
||||
|
||||
// is max > privateKey?
|
||||
return retval == 1;
|
||||
}
|
104
src/libumskt/pidgen3/PIDGEN3.h
Normal file
104
src/libumskt/pidgen3/PIDGEN3.h
Normal file
@ -0,0 +1,104 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/24/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_PIDGEN3_H
|
||||
#define UMSKT_PIDGEN3_H
|
||||
|
||||
#include "../libumskt.h"
|
||||
|
||||
class BINK1998;
|
||||
class BINK2002;
|
||||
|
||||
class EXPORT PIDGEN3
|
||||
{
|
||||
friend class BINK1998;
|
||||
friend class BINK2002;
|
||||
|
||||
protected:
|
||||
BIGNUM *privateKey, *genOrder;
|
||||
EC_POINT *genPoint, *pubPoint;
|
||||
EC_GROUP *eCurve;
|
||||
|
||||
public:
|
||||
PIDGEN3()
|
||||
{
|
||||
}
|
||||
|
||||
PIDGEN3(PIDGEN3 &p3)
|
||||
{
|
||||
privateKey = p3.privateKey;
|
||||
genOrder = p3.genOrder;
|
||||
genPoint = p3.genPoint;
|
||||
pubPoint = p3.pubPoint;
|
||||
eCurve = p3.eCurve;
|
||||
}
|
||||
|
||||
virtual ~PIDGEN3()
|
||||
{
|
||||
EC_GROUP_free(eCurve);
|
||||
EC_POINT_free(genPoint);
|
||||
EC_POINT_free(pubPoint);
|
||||
BN_free(genOrder);
|
||||
BN_free(privateKey);
|
||||
}
|
||||
|
||||
struct KeyInfo
|
||||
{
|
||||
DWORD Serial = 0, AuthInfo = 0, ChannelID = 0, Hash = 0;
|
||||
QWORD Signature = 0;
|
||||
BOOL isUpgrade = false;
|
||||
|
||||
void setSerial(DWORD serialIn)
|
||||
{
|
||||
Serial = serialIn;
|
||||
}
|
||||
|
||||
void setAuthInfo(DWORD AuthInfoIn)
|
||||
{
|
||||
AuthInfo = AuthInfoIn;
|
||||
}
|
||||
|
||||
void setChannelID(DWORD ChannelIDIn)
|
||||
{
|
||||
ChannelID = ChannelIDIn;
|
||||
}
|
||||
} info;
|
||||
|
||||
static constexpr char pKeyCharset[] = "BCDFGHJKMPQRTVWXY2346789";
|
||||
|
||||
BOOL LoadEllipticCurve(std::string pSel, std::string aSel, std::string bSel, std::string generatorXSel,
|
||||
std::string generatorYSel, std::string publicKeyXSel, std::string publicKeyYSel,
|
||||
std::string genOrderSel, std::string privateKeySel);
|
||||
|
||||
virtual BOOL Pack(QWORD *pRaw) = 0;
|
||||
virtual BOOL Unpack(QWORD *pRaw) = 0;
|
||||
virtual BOOL Generate(std::string &pKey);
|
||||
virtual BOOL Validate(std::string &pKey);
|
||||
|
||||
// PIDGEN3.cpp
|
||||
void base24(std::string &cdKey, BYTE *byteSeq);
|
||||
void unbase24(BYTE *byteSeq, std::string cdKey);
|
||||
BOOL checkFieldIsBink1998();
|
||||
static BOOL checkFieldStrIsBink1998(std::string keyin);
|
||||
};
|
||||
|
||||
#endif // UMSKT_PIDGEN3_H
|
38
src/main.cpp
Normal file
38
src/main.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Andrew on 01/06/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "cli.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int status;
|
||||
if (status = CLI::Init(argc, argv); status != 0)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
auto cli = CLI();
|
||||
status = cli.Run();
|
||||
|
||||
UMSKT::DESTRUCT();
|
||||
return status;
|
||||
}
|
40
src/rc.cpp
Normal file
40
src/rc.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 01/07/2024
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "cli.h"
|
||||
|
||||
#include <cmrc/cmrc.hpp>
|
||||
CMRC_DECLARE(umskt);
|
||||
|
||||
/**
|
||||
* load a cmrc embedded JSON file
|
||||
*
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::loadEmbeddedJSON()
|
||||
{
|
||||
auto fs = cmrc::umskt::get_filesystem();
|
||||
auto jsonFile = fs.open("keys.json");
|
||||
keys = json::parse(jsonFile, nullptr, false, false);
|
||||
|
||||
return true;
|
||||
}
|
122
src/typedefs.h
Normal file
122
src/typedefs.h
Normal file
@ -0,0 +1,122 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/24/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#ifndef UMSKT_TYPEDEFS_H
|
||||
#define UMSKT_TYPEDEFS_H
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <intrin.h>
|
||||
#include <windows.h>
|
||||
|
||||
#endif // defined(WIN32)
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdbool>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <cassert>
|
||||
#else
|
||||
#define assert(x) /* do nothing */
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define FNEXPORT __declspec(dllexport)
|
||||
#define FNIMPORT __declspec(dllimport)
|
||||
#define FNINLINE __forceinline
|
||||
#elif defined(__GNUC__)
|
||||
#define FNEXPORT __attribute__((visibility("default")))
|
||||
#define FNIMPORT __attribute__((visibility("default")))
|
||||
#define FNINLINE inline __attribute__((__always_inline__))
|
||||
#elif defined(__CLANG__)
|
||||
#if __has_attribute(__always_inline__)
|
||||
#define forceinline inline __attribute__((__always_inline__))
|
||||
#else
|
||||
#define forceinline inline
|
||||
#endif // __has_attribute(__always_inline__)
|
||||
#else
|
||||
#define FNEXPORT
|
||||
#define FNINLINE
|
||||
#warning "function inlining not handled"
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#define EXPORT EMSCRIPTEN_KEEPALIVE FNEXPORT
|
||||
#define INLINE FNINLINE
|
||||
#else
|
||||
#ifdef UMSKT_IMPORT_LIB
|
||||
#define EXPORT FNIMPORT
|
||||
#else
|
||||
#define EXPORT FNEXPORT
|
||||
#endif // ifdef UMSKT_IMPORT_LIB
|
||||
#define INLINE FNINLINE
|
||||
#endif // ifdef __EMSCRIPTEN__
|
||||
|
||||
// POSIX <-> Windows compatability layer, because MS just *had* to be different
|
||||
#ifdef _MSC_VER
|
||||
#ifndef _sscanf
|
||||
#define _sscanf sscanf_s
|
||||
#endif
|
||||
#ifndef _strncpy
|
||||
#define _strncpy strncpy_s
|
||||
#endif
|
||||
#ifndef _strcpy
|
||||
#define _strcpy strcpy_s
|
||||
#endif
|
||||
#else
|
||||
#define _sscanf sscanf
|
||||
#define _strncpy(x, y, z, w) strncpy(x, z, w)
|
||||
#define _strcpy strcpy
|
||||
#endif // ifdef _MSC_VER
|
||||
|
||||
// Type definitions now with more windows compatability (unfortunately)
|
||||
using BOOL = int32_t;
|
||||
using BYTE = uint8_t;
|
||||
using WORD = uint16_t;
|
||||
using DWORD = unsigned long;
|
||||
using QWORD = uint64_t;
|
||||
|
||||
#if defined(_M_ARM) // for Windows on ARM ??
|
||||
using __m128 = __n128;
|
||||
#endif
|
||||
|
||||
#if defined(__SIZEOF_INT128__) || defined(__int128)
|
||||
using uint128_t = unsigned __int128;
|
||||
#else // use the intel-supplied __m128 intrisic
|
||||
using uint128_t = __m128;
|
||||
#endif
|
||||
using OWORD = uint128_t;
|
||||
|
||||
typedef union {
|
||||
OWORD oword;
|
||||
QWORD qword[2];
|
||||
DWORD dword[4];
|
||||
WORD word[8];
|
||||
BYTE byte[16];
|
||||
} Q_OWORD;
|
||||
|
||||
#endif // UMSKT_TYPEDEFS_H
|
45
src/windows/dllmain.cpp
Normal file
45
src/windows/dllmain.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/17/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "../typedefs.h"
|
||||
#include "resource.h"
|
||||
|
||||
BOOLEAN WINAPI DllMain(IN HINSTANCE hDllHandle, IN DWORD nReason, IN LPVOID Reserved)
|
||||
{
|
||||
|
||||
BOOLEAN bSuccess = TRUE;
|
||||
// Perform global initialization.
|
||||
switch (nReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
// For optimization.
|
||||
DisableThreadLibraryCalls(hDllHandle);
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
// end DllMain
|
BIN
src/windows/icon.ico
Normal file
BIN
src/windows/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
70
src/windows/platform.cpp
Normal file
70
src/windows/platform.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 01/07/2024
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
#include "../cli.h"
|
||||
#include "resource.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* @return success
|
||||
*/
|
||||
BOOL CLI::loadEmbeddedJSON()
|
||||
{
|
||||
HMODULE hModule = GetModuleHandle(nullptr);
|
||||
|
||||
// Find
|
||||
HRSRC hResource = FindResource(hModule, MAKEINTRESOURCE(IDR_JSON1), "JSON");
|
||||
if (hResource == nullptr)
|
||||
{
|
||||
fmt::print("ERROR: Could not find internal JSON resource?");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load
|
||||
HGLOBAL hResourceData = LoadResource(hModule, hResource);
|
||||
if (hResourceData == nullptr)
|
||||
{
|
||||
fmt::print("ERROR: Could not load internal JSON resource?");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Lock
|
||||
LPVOID pData = LockResource(hResourceData);
|
||||
if (pData == nullptr)
|
||||
{
|
||||
fmt::print("ERROR: Could not lock internal JSON resource?");
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
keys = json::parse((char *)pData, nullptr, false, false);
|
||||
}
|
||||
catch (const json::exception &e)
|
||||
{
|
||||
fmt::print("ERROR: Exception occurred while parsing internal JSON file: {}\n", e.what());
|
||||
}
|
||||
|
||||
FreeResource(hResourceData);
|
||||
|
||||
return true;
|
||||
}
|
40
src/windows/resource.h
Normal file
40
src/windows/resource.h
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* This file is a part of the UMSKT Project
|
||||
*
|
||||
* Copyleft (C) 2019-2024 UMSKT Contributors (et.al.)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @FileCreated by Neo on 06/17/2023
|
||||
* @Maintainer Neo
|
||||
*/
|
||||
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by umskt.rc
|
||||
//
|
||||
#define IDI_ICON1 101
|
||||
#define IDR_JSON1 102
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
BIN
src/windows/umskt.rc
Normal file
BIN
src/windows/umskt.rc
Normal file
Binary file not shown.
Reference in New Issue
Block a user