Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
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
Container registry
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
fe9e31e7
Commit
fe9e31e7
authored
28 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
Bugfixes
Rev: src/modules/_Crypto/lib/rc4.c:1.3
parent
a42e99a0
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/_Crypto/lib/rc4.c
+16
-25
16 additions, 25 deletions
src/modules/_Crypto/lib/rc4.c
with
16 additions
and
25 deletions
src/modules/_Crypto/lib/rc4.c
+
16
−
25
View file @
fe9e31e7
...
...
@@ -5,48 +5,39 @@
#include
"crypto_types.h"
#include
<rc4.h>
#define SWAP(a,b) (a ^= b, b ^= a, a ^= b)
#if 0
void rc4_init(struct rc4_ctx *ctx)
{
int i;
for (i = 0; i < 256; i++)
ctx->S[i] = i;
ctx->i = ctx->j = 0;
}
#endif
#define SWAP(a,b) do { int _t = a; a = b; b = _t; } while(0)
void
rc4_set_key
(
struct
rc4_ctx
*
ctx
,
const
unsigned
INT8
*
key
,
INT32
len
)
{
register
unsigned
i
,
j
;
register
unsigned
INT8
i
,
j
;
/* Depends on the eight-bitness of these variables. */
INT32
k
;
/* Initialize context */
for
(
i
=
0
;
i
<
256
;
i
++
)
ctx
->
S
[
i
]
=
i
;
i
=
0
;
do
ctx
->
S
[
i
]
=
i
;
while
(
++
i
);
/* Expand key */
for
(
i
=
j
=
k
=
0
;
i
<
256
;
i
++
)
{
i
=
j
=
k
=
0
;
do
{
j
+=
ctx
->
S
[
i
]
+
key
[
k
];
SWAP
(
ctx
->
S
[
i
],
ctx
->
S
[
j
]);
k
=
(
k
+
1
)
%
len
;
/* Repeat key if needed */
}
ctx
->
j
=
j
;
ctx
->
i
=
0
;
}
while
(
++
i
);
ctx
->
i
=
ctx
->
j
=
0
;
}
void
rc4_crypt
(
struct
rc4_ctx
*
ctx
,
unsigned
INT8
*
dest
,
const
unsigned
INT8
*
src
,
INT32
len
)
{
register
unsigned
INT8
i
,
j
;
/* Depends on the
8
-bitness of these variables */
register
unsigned
INT8
i
,
j
;
/* Depends on the
eight
-bitness of these variables */
i
=
ctx
->
i
;
j
=
ctx
->
j
;
while
(
len
--
)
{
i
=
(
i
+
1
)
;
j
=
(
j
+
ctx
->
S
[
i
]
)
;
i
++
;
j
+
=
ctx
->
S
[
i
];
SWAP
(
ctx
->
S
[
i
],
ctx
->
S
[
j
]);
*
dest
++
=
*
src
++
^
ctx
->
S
[
(
ctx
->
S
[
i
]
+
ctx
->
S
[
j
])
];
*
dest
++
=
*
src
++
^
ctx
->
S
[
(
ctx
->
S
[
i
]
+
ctx
->
S
[
j
])
&
0xff
];
}
ctx
->
i
=
i
;
ctx
->
j
=
j
;
}
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