Add arc4 hashing

This commit is contained in:
Neale Pickett 2011-01-19 17:21:07 -07:00
parent f12ca038c6
commit 07fcf382b4
2 changed files with 17 additions and 1 deletions

View File

@ -51,3 +51,16 @@ arc4_crypt_buffer(uint8_t const *key, size_t keylen,
arc4_init(&ctx, key, keylen);
arc4_crypt(&ctx, buf, buf, buflen);
}
void
arc4_hash(uint8_t const *buf, size_t buflen,
uint8_t *hash)
{
struct arc4_ctx ctx;
int i;
arc4_init(&ctx, buf, buflen);
for (i = 0; i < ARC4_HASHLEN; i += 1) {
hash[i] = arc4_pad(&ctx);
}
}

View File

@ -4,6 +4,8 @@
#include <stdint.h>
#include <stdlib.h>
#define ARC4_HASHLEN 16
struct arc4_ctx {
uint8_t S[256];
uint8_t i;
@ -16,5 +18,6 @@ void arc4_crypt(struct arc4_ctx *ctx,
uint8_t *obuf, uint8_t const *ibuf, size_t buflen);
void arc4_crypt_buffer(uint8_t const *key, size_t keylen,
uint8_t *buf, size_t buflen);
void arc4_hash(uint8_t const *buf, size_t buflen,
uint8_t *hash);
#endif