Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Wim Lewis
nettle
Commits
7e12e96e
Commit
7e12e96e
authored
Sep 09, 2001
by
Niels Möller
Browse files
* des.c (des_fix_parity): New function.
Rev: src/nettle/des.c:1.4 Rev: src/nettle/des.h:1.6
parent
3a75965e
Changes
2
Hide whitespace changes
Inline
Side-by-side
des.c
View file @
7e12e96e
...
...
@@ -52,6 +52,15 @@ static char parity[] = {
#include
"parity.h"
};
void
des_fix_parity
(
unsigned
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
)
{
unsigned
i
;
for
(
i
=
0
;
i
<
length
;
i
++
)
dst
[
i
]
=
src
[
i
]
^
(
parity
[
src
[
i
]]
==
8
);
}
int
des_set_key
(
struct
des_ctx
*
ctx
,
const
uint8_t
*
key
)
{
...
...
des.h
View file @
7e12e96e
/* des.h
*
* The des block cipher.
* The des block cipher.
And triple des.
*/
/* nettle, low-level cryptographics library
...
...
@@ -65,4 +65,32 @@ des_decrypt(struct des_ctx *ctx,
unsigned
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
);
void
des_fix_parity
(
unsigned
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
);
#define DES3_KEY_SIZE 24
#define DES3_BLOCK_SIZE DES_BLOCK_SIZE
struct
des3_ctx
{
struct
des_ctx
des
[
3
];
enum
des_error
status
;
};
/* On success, returns 1 and sets ctx->status to DES_OK (zero). On
* error, returns 0 and sets ctx->status accordingly. */
int
des3_set_key
(
struct
des3_ctx
*
ctx
,
const
uint8_t
*
key
);
void
des3_encrypt
(
struct
des3_ctx
*
ctx
,
unsigned
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
);
void
des3_decrypt
(
struct
des3_ctx
*
ctx
,
unsigned
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
);
#endif
/* NETTLE_DES_H_INCLUDED */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment