[PATCH] Add A5/3-4 cipher support

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Sylvain Munaut 246tnt at gmail.com
Tue Jun 17 19:35:59 UTC 2014


#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