Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
basic_robot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
basic_robot
Commits
00847188
Commit
00847188
authored
7 years ago
by
rnd1
Browse files
Options
Downloads
Patches
Plain Diff
encrypt: fix of vulnerabilities and a bit of spice up with nonlinear nesting
parent
6b955f9d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
commands.lua
+8
-6
8 additions, 6 deletions
commands.lua
with
8 additions
and
6 deletions
commands.lua
+
8
−
6
View file @
00847188
...
...
@@ -1020,18 +1020,20 @@ basic_robot.commands.machine = {
local
n
=
16
;
-- range 0-255 (for just chat can use 32 - 132)
local
m
=
65
;
local
ret
=
""
;
input
=
input
or
""
;
local
block_offset
=
0
;
local
rndseed
=
get_hash
(
password
,
10
^
30
);
_G
.
math
.
randomseed
(
rndseed
);
local
block_offset
=
1
+
math.random
(
n
);
local
offset
=
1
+
math.random
(
n
);
for
i
=
1
,
string.len
(
input
)
do
local
offset
=
math.random
(
n
)
^
2
+
(
i
%
n
)
^
3
;
-- yay, nonlinearity is fun
offset
=
(
offset
^
2
)
%
n
offset
=
math.random
(
n
+
math.random
(
2
+
(
i
+
offset
+
block_offset
)
^
2
));
-- yay, nested nonlinearity is fun and makes cryptanalysis 'trivial' hehe
if
i
%
8
==
1
then
-- every 8 characters new offset using strong hash function incorporation recent offset in nonlinear way
block_offset
=
get_hash
(
_G
.
minetest
.
get_password_hash
(
""
,
i
*
(
offset
+
1
)
..
password
..
(
block_offset
^
2
)),
n
);
if
math.random
(
100
)
>
50
then
block_offset
=
block_offset
*
math.random
(
n
)
^
2
end
-- extra fun, why not
block_offset
=
get_hash
(
_G
.
minetest
.
get_password_hash
(
""
,
i
*
(
offset
+
1
)
..
password
..
(
block_offset
^
2
)),
n
);
-- composite fun with more serious hash function
math.randomseed
(
rndseed
+
block_offset
)
-- time for change of tune, can you keep up ? :)
if
math.random
(
100
)
>
50
then
block_offset
=
block_offset
*
math.random
(
n
*
(
1
+
block_offset
))
end
-- extra fun, why not
end
offset
=
offset
+
block_offset
;
offset
=
(
offset
+
block_offset
)
%
n
;
local
c
=
string.byte
(
input
,
i
)
-
m
;
c
=
m
+
((
c
+
offset
*
sgn
)
%
n
);
ret
=
ret
..
string.char
(
c
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment