142763c280
- Change BuildTool to Meson - Many BUGS Fixed
73 lines
2 KiB
C
73 lines
2 KiB
C
#if !defined(OGS_CRYPT_INSIDE) && !defined(OGS_CRYPT_COMPILATION)
|
|
#error "This header cannot be included directly."
|
|
#endif
|
|
|
|
#ifndef SNOW_3G_H
|
|
#define SNOW_3G_H
|
|
|
|
#include "ogs-core.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef uint8_t u8;
|
|
typedef uint32_t u32;
|
|
typedef uint64_t u64;
|
|
|
|
/* Initialization.
|
|
* Input k[4]: Four 32-bit words making up 128-bit key.
|
|
* Input IV[4]: Four 32-bit words making 128-bit initialization variable.
|
|
* Output: All the LFSRs and FSM are initialized for key generation.
|
|
* See Section 4.1.
|
|
*/
|
|
|
|
void snow_3g_initialize(u32 k[4], u32 IV[4]);
|
|
|
|
/* Generation of Keystream.
|
|
* input n: number of 32-bit words of keystream.
|
|
* input z: space for the generated keystream, assumes
|
|
* memory is allocated already.
|
|
* output: generated keystream which is filled in z
|
|
* See section 4.2.
|
|
*/
|
|
|
|
void snow_3g_generate_key_stream(u32 n, u32 *z);
|
|
|
|
/* f8.
|
|
* Input key: 128 bit Confidentiality Key.
|
|
* Input count:32-bit Count, Frame dependent input.
|
|
* Input bearer: 5-bit Bearer identity (in the LSB side).
|
|
* Input dir:1 bit, direction of transmission.
|
|
* Input data: length number of bits, input bit stream.
|
|
* Input length: 32 bit Length, i.e., the number of bits to be encrypted or
|
|
* decrypted.
|
|
* Output data: Output bit stream. Assumes data is suitably memory
|
|
* allocated.
|
|
* Encrypts/decrypts blocks of data between 1 and 2^32 bits in length as
|
|
* defined in Section 3.
|
|
*/
|
|
|
|
void snow_3g_f8( u8 *key, u32 count, u32 bearer, u32 dir,
|
|
u8 *data, u32 length );
|
|
|
|
/* f9.
|
|
* Input key: 128 bit Integrity Key.
|
|
* Input count:32-bit Count, Frame dependent input.
|
|
* Input fresh: 32-bit Random number.
|
|
* Input dir:1 bit, direction of transmission (in the LSB).
|
|
* Input data: length number of bits, input bit stream.
|
|
* Input length: 64 bit Length, i.e., the number of bits to be MAC'd.
|
|
* Output : 32 bit block used as MAC
|
|
* Generates 32-bit MAC using UIA2 algorithm as defined in Section 4.
|
|
*/
|
|
|
|
void snow_3g_f9( u8* key, u32 count, u32 fresh, u32 dir,
|
|
u8 *data, u64 length, u8 *out);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* SNOW_3G_H */
|