blob: 0ba6a84585ad373bebcd355947525a87bafdf4b7 [file] [log] [blame]
Harald Welte867ca292019-07-12 18:21:39 +08001#ifndef __SNOW_3G__
2#define __SNOW_3G__
3
Harald Welte4a2bfcb2019-07-12 18:27:08 +08004#include <stdint.h>
Harald Welte867ca292019-07-12 18:21:39 +08005
6#ifdef __cplusplus
7extern "C" {
8#endif /* __cplusplus */
9
10typedef uint8_t u8;
11typedef uint32_t u32;
12typedef uint64_t u64;
13
14/* Initialization.
15* Input k[4]: Four 32-bit words making up 128-bit key.
16* Input IV[4]: Four 32-bit words making 128-bit initialization variable.
17* Output: All the LFSRs and FSM are initialized for key generation.
18* See Section 4.1.
19*/
20
21void snow_3g_initialize(u32 k[4], u32 IV[4]);
22
23/* Generation of Keystream.
24* input n: number of 32-bit words of keystream.
25* input z: space for the generated keystream, assumes
26* memory is allocated already.
27* output: generated keystream which is filled in z
28* See section 4.2.
29*/
30
31void snow_3g_generate_key_stream(u32 n, u32 *z);
32
33/* f8.
34* Input key: 128 bit Confidentiality Key.
35* Input count:32-bit Count, Frame dependent input.
36* Input bearer: 5-bit Bearer identity (in the LSB side).
37* Input dir:1 bit, direction of transmission.
38* Input data: length number of bits, input bit stream.
39* Input length: 32 bit Length, i.e., the number of bits to be encrypted or
40* decrypted.
41* Output data: Output bit stream. Assumes data is suitably memory
42* allocated.
43* Encrypts/decrypts blocks of data between 1 and 2^32 bits in length as
44* defined in Section 3.
45*/
46
47void snow_3g_f8( u8 *key, u32 count, u32 bearer, u32 dir,
48 u8 *data, u32 length );
49
50/* f9.
51* Input key: 128 bit Integrity Key.
52* Input count:32-bit Count, Frame dependent input.
53* Input fresh: 32-bit Random number.
54* Input dir:1 bit, direction of transmission (in the LSB).
55* Input data: length number of bits, input bit stream.
56* Input length: 64 bit Length, i.e., the number of bits to be MAC'd.
57* Output : 32 bit block used as MAC
58* Generates 32-bit MAC using UIA2 algorithm as defined in Section 4.
59*/
60
61void snow_3g_f9( u8* key, u32 count, u32 fresh, u32 dir,
62 u8 *data, u64 length, u8 *out);
63
64#ifdef __cplusplus
65}
66#endif /* __cplusplus */
67
68#endif /* __SNOW_3G__ */