mirror of https://github.com/dirtbags/moth.git
Add arc4 hashing
This commit is contained in:
parent
6062e3fd09
commit
f2e4bb8757
|
@ -51,3 +51,16 @@ arc4_crypt_buffer(uint8_t const *key, size_t keylen,
|
||||||
arc4_init(&ctx, key, keylen);
|
arc4_init(&ctx, key, keylen);
|
||||||
arc4_crypt(&ctx, buf, buf, buflen);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define ARC4_HASHLEN 16
|
||||||
|
|
||||||
struct arc4_ctx {
|
struct arc4_ctx {
|
||||||
uint8_t S[256];
|
uint8_t S[256];
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
@ -16,5 +18,6 @@ void arc4_crypt(struct arc4_ctx *ctx,
|
||||||
uint8_t *obuf, uint8_t const *ibuf, size_t buflen);
|
uint8_t *obuf, uint8_t const *ibuf, size_t buflen);
|
||||||
void arc4_crypt_buffer(uint8_t const *key, size_t keylen,
|
void arc4_crypt_buffer(uint8_t const *key, size_t keylen,
|
||||||
uint8_t *buf, size_t buflen);
|
uint8_t *buf, size_t buflen);
|
||||||
|
void arc4_hash(uint8_t const *buf, size_t buflen,
|
||||||
|
uint8_t *hash);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue