Skip to content
Snippets Groups Projects
Commit 7e12e96e authored by Niels Möller's avatar 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
No related branches found
No related tags found
No related merge requests found
...@@ -52,6 +52,15 @@ static char parity[] = { ...@@ -52,6 +52,15 @@ static char parity[] = {
#include "parity.h" #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 int
des_set_key(struct des_ctx *ctx, const uint8_t *key) des_set_key(struct des_ctx *ctx, const uint8_t *key)
{ {
......
/* des.h /* des.h
* *
* The des block cipher. * The des block cipher. And triple des.
*/ */
/* nettle, low-level cryptographics library /* nettle, low-level cryptographics library
...@@ -65,4 +65,32 @@ des_decrypt(struct des_ctx *ctx, ...@@ -65,4 +65,32 @@ des_decrypt(struct des_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); 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 */ #endif /* NETTLE_DES_H_INCLUDED */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment