Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Putty
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
m-team
tools
packaging
upstream
Putty
Commits
609502b0
Commit
609502b0
authored
4 years ago
by
Simon Tatham
Browse files
Options
Downloads
Patches
Plain Diff
Add utility function 'memxor'.
parent
09fa3f0e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
misc.h
+9
-0
9 additions, 0 deletions
misc.h
utils.c
+26
-0
26 additions, 0 deletions
utils.c
with
35 additions
and
0 deletions
misc.h
+
9
−
0
View file @
609502b0
...
@@ -430,4 +430,13 @@ LoadFileStatus lf_load(LoadedFile *lf, const Filename *filename);
...
@@ -430,4 +430,13 @@ LoadFileStatus lf_load(LoadedFile *lf, const Filename *filename);
static
inline
ptrlen
ptrlen_from_lf
(
LoadedFile
*
lf
)
static
inline
ptrlen
ptrlen_from_lf
(
LoadedFile
*
lf
)
{
return
make_ptrlen
(
lf
->
data
,
lf
->
len
);
}
{
return
make_ptrlen
(
lf
->
data
,
lf
->
len
);
}
/* Set the memory block of 'size' bytes at 'out' to the bitwise XOR of
* the two blocks of the same size at 'in1' and 'in2'.
*
* 'out' may point to exactly the same address as one of the inputs,
* but if the input and output blocks overlap in any other way, the
* result of this function is not guaranteed. No memmove-style effort
* is made to handle difficult overlap cases. */
void
memxor
(
uint8_t
*
out
,
const
uint8_t
*
in1
,
const
uint8_t
*
in2
,
size_t
size
);
#endif
#endif
This diff is collapsed.
Click to expand it.
utils.c
+
26
−
0
View file @
609502b0
...
@@ -1073,3 +1073,29 @@ void write_c_string_literal(FILE *fp, ptrlen str)
...
@@ -1073,3 +1073,29 @@ void write_c_string_literal(FILE *fp, ptrlen str)
fprintf
(
fp
,
"
\\
%03o"
,
(
unsigned
char
)
c
);
fprintf
(
fp
,
"
\\
%03o"
,
(
unsigned
char
)
c
);
}
}
}
}
void
memxor
(
uint8_t
*
out
,
const
uint8_t
*
in1
,
const
uint8_t
*
in2
,
size_t
size
)
{
switch
(
size
&
15
)
{
case
0
:
while
(
size
>=
16
)
{
*
out
++
=
*
in1
++
^
*
in2
++
;
case
15
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
14
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
13
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
12
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
11
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
10
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
9
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
8
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
7
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
6
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
5
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
4
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
3
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
2
:
*
out
++
=
*
in1
++
^
*
in2
++
;
case
1
:
*
out
++
=
*
in1
++
^
*
in2
++
;
size
-=
16
;
}
}
}
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