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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
4b85c94c
Commit
4b85c94c
authored
Feb 27, 1997
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
Changed padding method. Now pads the same way SSL does.
Rev: src/modules/_Crypto/crypto.c:1.14
parent
7d8d9196
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/crypto.c
+20
-21
20 additions, 21 deletions
src/modules/_Crypto/crypto.c
with
20 additions
and
21 deletions
src/modules/_Crypto/crypto.c
+
20
−
21
View file @
4b85c94c
/*
/*
* $Id: crypto.c,v 1.1
3
1997/02/
15 22:03:03
nisse Exp $
* $Id: crypto.c,v 1.1
4
1997/02/
27 13:51:54
nisse Exp $
*
*
* A pike module for getting access to some common cryptos.
* A pike module for getting access to some common cryptos.
*
*
...
@@ -367,15 +367,17 @@ static void f_crypt(INT32 args)
...
@@ -367,15 +367,17 @@ static void f_crypt(INT32 args)
static
void
f_pad
(
INT32
args
)
static
void
f_pad
(
INT32
args
)
{
{
int
i
;
int
i
;
int
len
;
if
(
args
)
{
if
(
args
)
{
error
(
"Too many arguments to crypto->pad()
\n
"
);
error
(
"Too many arguments to crypto->pad()
\n
"
);
}
}
for
(
i
=
THIS
->
backlog_len
;
i
<
(
THIS
->
block_size
-
1
);
i
++
)
{
len
=
THIS
->
block_size
-
1
-
THIS
->
backlog_len
;
THIS
->
backlog
[
i
]
=
my_rand
()
&
0xff
;
for
(
i
=
0
;
i
<
len
;
i
++
)
}
THIS
->
backlog
[
THIS
->
backlog_len
+
i
]
=
my_rand
()
&
0xff
;
THIS
->
backlog
[
i
]
=
THIS
->
backlog_len
;
THIS
->
backlog
[
i
]
=
len
;
push_string
(
make_shared_binary_string
((
const
char
*
)
THIS
->
backlog
,
push_string
(
make_shared_binary_string
((
const
char
*
)
THIS
->
backlog
,
THIS
->
block_size
));
THIS
->
block_size
));
...
@@ -392,29 +394,26 @@ static void f_unpad(INT32 args)
...
@@ -392,29 +394,26 @@ static void f_unpad(INT32 args)
int
len
;
int
len
;
struct
pike_string
*
str
;
struct
pike_string
*
str
;
if
(
args
!=
1
)
{
if
(
args
!=
1
)
error
(
"Wrong number of arguments to crypto->unpad()
\n
"
);
error
(
"Wrong number of arguments to crypto->unpad()
\n
"
);
}
if
(
sp
[
-
1
].
type
!=
T_STRING
)
{
if
(
sp
[
-
1
].
type
!=
T_STRING
)
error
(
"Bad argument 1 to crypto->unpad()
\n
"
);
error
(
"Bad argument 1 to crypto->unpad()
\n
"
);
}
str
=
sp
[
-
1
].
u
.
string
;
str
=
sp
[
-
1
].
u
.
string
;
len
=
str
->
len
;
len
=
str
->
len
;
len
+=
str
->
str
[
len
-
1
]
-
THIS
->
block_size
;
if
(
str
->
str
[
len
-
1
]
>
(
THIS
->
block_size
-
1
))
error
(
"crypto->unpad(): Invalid padding
\n
"
);
if
(
len
<
0
)
{
len
-=
(
str
->
str
[
len
-
1
]
+
1
);
if
(
len
<
0
)
error
(
"crypto->unpad(): String to short to unpad
\n
"
);
error
(
"crypto->unpad(): String to short to unpad
\n
"
);
}
str
->
refs
++
;
str
->
refs
++
;
pop_stack
();
pop_stack
();
push_string
(
make_shared_binary_string
(
str
->
str
,
len
));
push_string
(
make_shared_binary_string
(
str
->
str
,
len
));
free_string
(
str
);
free_string
(
str
);
}
}
...
@@ -491,9 +490,9 @@ void pike_module_init(void)
...
@@ -491,9 +490,9 @@ void pike_module_init(void)
add_function
(
"hex_to_string"
,
f_hex_to_string
,
"function(string:string)"
,
OPT_TRY_OPTIMIZE
);
add_function
(
"hex_to_string"
,
f_hex_to_string
,
"function(string:string)"
,
OPT_TRY_OPTIMIZE
);
#if 0
#if 0
MOD_INIT(md2)();
MOD_INIT(md2)();
MOD_INIT(md5)();
#endif
#endif
#if 1
#if 1
MOD_INIT
(
md5
)();
MOD_INIT
(
crypto
)();
MOD_INIT
(
crypto
)();
MOD_INIT
(
idea
)();
MOD_INIT
(
idea
)();
MOD_INIT
(
des
)();
MOD_INIT
(
des
)();
...
@@ -510,9 +509,9 @@ void pike_module_exit(void)
...
@@ -510,9 +509,9 @@ void pike_module_exit(void)
/* free_program()s */
/* free_program()s */
#if 0
#if 0
MOD_EXIT(md2)();
MOD_EXIT(md2)();
MOD_EXIT(md5)();
#endif
#endif
#if 1
#if 1
MOD_EXIT
(
md5
)();
MOD_EXIT
(
crypto
)();
MOD_EXIT
(
crypto
)();
MOD_EXIT
(
idea
)();
MOD_EXIT
(
idea
)();
MOD_EXIT
(
des
)();
MOD_EXIT
(
des
)();
...
...
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