A52HackTool 1.3.0
Turnkey & easy to use tool for cracking the GSM A5/2 cipher
Functions
keygen.c File Reference

Implementation of A5/2 keystream generation. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "utils.h"
#include "keygen.h"

Functions

void keygen_clockReg (const int index)
 Clock the specified register.
void keygen_clockingUnit (int clockAll)
 Performs register clocking according to the rules of the Clocking Unit.
byte keygen_getOutBit ()
 Returns the current out keystream bit.
void keysetup (const byte Kc[SECRETKEY_BITS], const byte frameId[FRAMEID_BITS])
 Initializes the whole system according to the keysetup procedure.
void getKeystream (byte keystream[], const int len)
 Generates the desired amount of keystream.
int keygen_test ()
 Autotests the key generation on a verified set.

Variables

byte R1 [R1_BITS]
 LFSRs Storage (as global variables for easier exploitation)
byte R2 [R2_BITS]
 LFSRs Storage (as global variables for easier exploitation)
byte R3 [R3_BITS]
 LFSRs Storage (as global variables for easier exploitation)
byte R4 [R4_BITS]
 LFSRs Storage (as global variables for easier exploitation)

Detailed Description

Implementation of A5/2 keystream generation.

Author:
Nicolas Paglieri & Olivier Benjamin
Version:
File Revision #10
Date:
24/06/2011

Here are located the methods used for simulating the behavior of the A5/2 keystream generator. Four LFSRs are used... TODO: Write some more documentation


Function Documentation

void getKeystream ( byte  keystream[],
const int  len 
)

Generates the desired amount of keystream.

Parameters:
[out]keystreamKeystream to be generated
[in]lendesired amount of keystream bits

References keygen_clockingUnit(), and keygen_getOutBit().

Referenced by attack_test(), keygen_test(), main(), and matrices_generation_test().

void keygen_clockingUnit ( int  clockAll)

Performs register clocking according to the rules of the Clocking Unit.

Parameters:
[in]clockAllWhen non-zero, bypass Clocking Unit decision: always clock (initialization phase)

References keygen_clockReg(), MAJORITY, R4, R4_CLOCKTAP_R1, R4_CLOCKTAP_R2, and R4_CLOCKTAP_R3.

Referenced by getKeystream(), and keysetup().

void keygen_clockReg ( const int  index)

Clock the specified register.

Parameters:
[in]indexRegister to be clocked

References DEBUG, R1, R1_BITS, R1_SHIFTTAP_1, R1_SHIFTTAP_2, R1_SHIFTTAP_3, R1_SHIFTTAP_4, R2, R2_BITS, R2_SHIFTTAP_1, R2_SHIFTTAP_2, R3, R3_BITS, R3_SHIFTTAP_1, R3_SHIFTTAP_2, R3_SHIFTTAP_3, R3_SHIFTTAP_4, R4, R4_BITS, R4_SHIFTTAP_1, and R4_SHIFTTAP_2.

Referenced by keygen_clockingUnit().

int keygen_test ( )

Autotests the key generation on a verified set.

Returns:
0 if the test is successfull, non-zero otherwise

References DEBUG, FRAMEID_BITS, getKeystream(), keysetup(), and SECRETKEY_BITS.

Referenced by main().

void keysetup ( const byte  Kc[SECRETKEY_BITS],
const byte  frameId[FRAMEID_BITS] 
)

Initializes the whole system according to the keysetup procedure.

Parameters:
[in]KcSecret Key
[in]frameIdFrame Id

References FRAMEID_BITS, keygen_clockingUnit(), R1, R1_BITS, R1_INITIAL_CONST_POS, R2, R2_BITS, R2_INITIAL_CONST_POS, R3, R3_BITS, R3_INITIAL_CONST_POS, R4, R4_BITS, R4_INITIAL_CONST_POS, and SECRETKEY_BITS.

Referenced by attack_test(), keygen_test(), main(), and matrices_generation_test().