]> git.cryptolib.org Git - avr-crypto-lib.git/blob - A5_1.h
a6f963a1c89b212988ad0028957cc6474ec1b214
[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         /* we are wasting one byte here but this allows a much faster implementation */
39         uint8_t r1[3], r2[3], r3[3]; /* the three regs, 19,22,23 bit in length  */
40 } a5_1_ctx_t;
41  
42
43 void            a5_1_init(a5_1_ctx_t *c, void* key, uint8_t keylength_b, void* iv, uint8_t ivlength_b);
44 uint8_t         a5_1_clock(a5_1_ctx_t *c);
45 uint8_t         a5_1_gen(a5_1_ctx_t *c);
46
47 #endif