Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Dmitry Baryshkov
nettle
Commits
b5fbae36
Commit
b5fbae36
authored
23 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
(des_cbc_cksum): Implemented.
(des_key_sched): Fixed return values. Rev: src/nettle/des-compat.c:1.3
parent
0ae0ae6b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
des-compat.c
+40
-8
40 additions, 8 deletions
des-compat.c
with
40 additions
and
8 deletions
des-compat.c
+
40
−
8
View file @
b5fbae36
...
...
@@ -28,6 +28,10 @@
#undef des_set_key
#include
"cbc.h"
#include
"memxor.h"
#include
<string.h>
#include
<assert.h>
struct
des_compat_des3
{
struct
des_ctx
*
keys
[
3
];
};
...
...
@@ -62,10 +66,27 @@ des_ecb3_encrypt(const uint8_t *src, uint8_t *dst,
(
&
keys
,
DES_BLOCK_SIZE
,
dst
,
src
);
}
uint32_t
des_cbc_cksum
(
const
uint8_t
*
src
,
uint8_t
dst
,
void
des_cbc_cksum
(
const
uint8_t
*
src
,
uint8_t
*
dst
,
long
length
,
struct
des_ctx
*
ctx
,
uint8_t
*
iv
);
uint8_t
*
iv
)
{
/* FIXME: I'm not entirely sure how this function is supposed to
* work, in particular what it should return, and if iv can be
* modified. */
uint8_t
block
[
DES_BLOCK_SIZE
];
memcpy
(
block
,
iv
,
DES_BLOCK_SIZE
);
assert
(
!
(
length
%
DES_BLOCK_SIZE
));
for
(
;
length
;
length
-=
DES_BLOCK_SIZE
,
src
+=
DES_BLOCK_SIZE
)
{
memxor
(
iv
,
src
,
DES_BLOCK_SIZE
);
des_encrypt
(
ctx
,
DES_BLOCK_SIZE
,
block
,
block
);
}
memcpy
(
dst
,
block
,
DES_BLOCK_SIZE
);
}
void
des_cbc_encrypt
(
const
uint8_t
*
src
,
uint8_t
*
dst
,
long
length
,
...
...
@@ -115,17 +136,28 @@ int
des_set_odd_parity
(
uint8_t
*
key
)
{
des_fix_parity
(
DES_KEY_SIZE
,
key
,
key
);
/* FIXME: What to return? */
return
0
;
}
/* Returns 0 for ok, -1 for bad parity, and -2 for weak keys. */
int
des_
compat_set_key
(
const
uint8_t
*
key
,
struct
des_ctx
*
ctx
)
des_
key_sched
(
const
uint8_t
*
key
,
struct
des_ctx
*
ctx
)
{
des_set_key
(
ctx
,
key
);
if
(
des_set_key
(
ctx
,
key
))
return
0
;
else
switch
(
ctx
->
status
)
{
case
DES_BAD_PARITY
:
return
-
1
;
case
DES_WEAK_KEY
:
return
-
2
;
default:
abort
();
}
}
int
des_key_sched
(
const
uint8_t
*
key
,
struct
des_ctx
*
ctx
);
int
des_is_weak_key
(
const
uint8_t
*
key
)
{
...
...
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