Commit 7e12e96e authored by Niels Möller's avatar Niels Möller

* des.c (des_fix_parity): New function.

Rev: src/nettle/des.c:1.4
Rev: src/nettle/des.h:1.6
parent 3a75965e
......@@ -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
*
* 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 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment