remove ogslib dependency from snow
* don't use ogslib specific header files * don't use ogs_{malloc,free} but simply use the stack Change-Id: I5604c594934b03d2fd83e1e465fc150fc542a475
This commit is contained in:
parent
135af53c48
commit
4a2bfcb77f
|
@ -381,7 +381,7 @@ void snow_3g_f8(u8 *key, u32 count, u32 bearer, u32 dir, u8 *data, u32 length)
|
||||||
int n = ( length + 31 ) / 32;
|
int n = ( length + 31 ) / 32;
|
||||||
int i=0;
|
int i=0;
|
||||||
int lastbits = (8-(length%8)) % 8;
|
int lastbits = (8-(length%8)) % 8;
|
||||||
u32 *KS;
|
u32 KS[n];
|
||||||
|
|
||||||
/*Initialisation*/
|
/*Initialisation*/
|
||||||
/* Load the confidentiality key for SNOW 3G initialization as in section
|
/* Load the confidentiality key for SNOW 3G initialization as in section
|
||||||
|
@ -399,7 +399,6 @@ void snow_3g_f8(u8 *key, u32 count, u32 bearer, u32 dir, u8 *data, u32 length)
|
||||||
|
|
||||||
/* Run SNOW 3G algorithm to generate sequence of key stream bits KS*/
|
/* Run SNOW 3G algorithm to generate sequence of key stream bits KS*/
|
||||||
snow_3g_initialize(K,IV);
|
snow_3g_initialize(K,IV);
|
||||||
KS = (u32 *)ogs_malloc(4*n);
|
|
||||||
snow_3g_generate_key_stream(n,(u32*)KS);
|
snow_3g_generate_key_stream(n,(u32*)KS);
|
||||||
|
|
||||||
/* Exclusive-OR the input data with keystream to generate the output bit
|
/* Exclusive-OR the input data with keystream to generate the output bit
|
||||||
|
@ -412,8 +411,6 @@ void snow_3g_f8(u8 *key, u32 count, u32 bearer, u32 dir, u8 *data, u32 length)
|
||||||
data[4*i+3] ^= (u8) (KS[i] ) & 0xff;
|
data[4*i+3] ^= (u8) (KS[i] ) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
ogs_free(KS);
|
|
||||||
|
|
||||||
/* zero last bits of data in case its length is not byte-aligned
|
/* zero last bits of data in case its length is not byte-aligned
|
||||||
this is an addition to the C reference code, which did not handle it */
|
this is an addition to the C reference code, which did not handle it */
|
||||||
if (lastbits)
|
if (lastbits)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __SNOW_3G__
|
#ifndef __SNOW_3G__
|
||||||
#define __SNOW_3G__
|
#define __SNOW_3G__
|
||||||
|
|
||||||
#include "ogs-core.h"
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
Loading…
Reference in New Issue