X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=A5_1.h;fp=A5_1.h;h=8803198b644698283761b4c5e1105054670af0b1;hb=3c995d0a8faeb9d37927d48e20fc45d839e066ea;hp=0000000000000000000000000000000000000000;hpb=a7f70b30f9c841e9d2287f8428b6263642eb0493;p=avr-crypto-lib.git diff --git a/A5_1.h b/A5_1.h new file mode 100644 index 0000000..8803198 --- /dev/null +++ b/A5_1.h @@ -0,0 +1,46 @@ +/* + * File: A5_1.h + * Author: Daniel Otte + * Date: 24.06.2006 + * License: GPL + * Description: Implementation of the A5/1 stream cipher algorithm, as used in GSM. + * ! Warning, this is weak crypto ! + * + */ +#ifndef A5_1_H_ +#define A5_1_H_ + +#include + +#define R1_LENGTH 19 +#define R2_LENGTH 22 +#define R3_LENGTH 23 +#define R1_CLK 11 +#define R2_CLK 12 +#define R3_CLK 13 + +/* 3-Bit word parity lookup table (Byte) + * 0: 0 + * 1: 1 + * 2: 1 + * 3: 0 + * 4: 1 + * 5: 0 + * 6: 0 + * 7: 1 + * => 1001.0110 = 0x96 + * + */ + +#define PARITY_LOOKUP 0x96 + +typedef struct { + uint32_t r1,r2,r3; /* the three regs, 19,22,23 bit in length */ +} a5_1_ctx_t; + + +void a5_1_init(a5_1_ctx_t *c, uint8_t *key, uint8_t length); +bool a5_1_clock(a5_1_ctx_t *c); +uint8_t a5_1_gen(a5_ 1_ctx_t *c); + +#endif