[PATCH] Add A5/3-4 cipher support

Sylvain Munaut 246tnt at gmail.com
Tue Jun 17 19:46:38 UTC 2014


Bunch of fucking idiots who chose as test data completely invalid FN
count values that can't possibly happen in a GSM system ...

- Either just use different test vector you generate
- Or use a marker bit like (1<<31) to indicate to _a5_{3,4} not to
convert the values for testing



On Tue, Jun 17, 2014 at 9:35 PM, Sylvain Munaut <246tnt at gmail.com> wrote:
> #include <stdio.h>
> #include <stdint.h>
>
>
> static inline uint32_t
> osmo_a5_fn_count(uint32_t fn)
> {
>         int t1 = fn / (26 * 51);
>         int t2 = fn % 26;
>         int t3 = fn % 51;
>         return (t1 << 11) | (t3 << 5) | t2;
> }
>
> static inline uint32_t
> osmo_a5_fn(uint32_t fn_count)
> {
>         int t1 = fn_count >> 11;
>         int t2 = fn_count & 0x1f;
>         int t3 = (fn_count >> 5) & 0x3f;
>         return (t1 * 26 * 51) + ((t3 - t2 + 26) % 26) * 51 + t3;
> }
>
> #define FN_MAX 26*51*2048
>
> int main(int argc, char *argv[])
> {
>         int i;
>         for (i=0; i<FN_MAX; i++)
>                 if (i != osmo_a5_fn(osmo_a5_fn_count(i)))
>                         printf("%d\n", i);
>
> }




More information about the baseband-devel mailing list