]> git.cryptolib.org Git - avr-crypto-lib.git/blob - A5_1.h
new, derived from old avr/crypto + cast5
[avr-crypto-lib.git] / A5_1.h
1 /* 
2  * File:                A5_1.h
3  * Author:      Daniel Otte
4  * Date:        24.06.2006
5  * License: GPL
6  * Description: Implementation of the A5/1 stream cipher algorithm, as used in GSM.
7  * ! Warning, this is weak crypto !
8  * 
9  */
10 #ifndef A5_1_H_
11 #define A5_1_H_
12
13 #include <stdint.h>
14
15 #define R1_LENGTH 19
16 #define R2_LENGTH 22
17 #define R3_LENGTH 23
18 #define R1_CLK 11
19 #define R2_CLK 12
20 #define R3_CLK 13
21
22 /* 3-Bit word parity lookup table (Byte) 
23  * 0: 0
24  * 1: 1
25  * 2: 1
26  * 3: 0
27  * 4: 1
28  * 5: 0
29  * 6: 0
30  * 7: 1
31  * => 1001.0110 = 0x96
32  * 
33  */
34
35 #define PARITY_LOOKUP 0x96
36
37 typedef struct {
38         uint32_t r1,r2,r3; /* the three regs, 19,22,23 bit in length  */
39 } a5_1_ctx_t;
40  
41
42 void            a5_1_init(a5_1_ctx_t *c, uint8_t *key, uint8_t length);
43 bool            a5_1_clock(a5_1_ctx_t *c);
44 uint8_t a5_1_gen(a5_    1_ctx_t *c);
45
46 #endif