libosmogsm
0.9.3
Osmocom GSM library
|
00001 /* 00002 * a5.h 00003 * 00004 * Copyright (C) 2011 Sylvain Munaut <tnt@246tNt.com> 00005 * 00006 * All Rights Reserved 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License along 00019 * with this program; if not, write to the Free Software Foundation, Inc., 00020 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00021 */ 00022 00023 #pragma once 00024 00025 #include <stdint.h> 00026 00027 #include <osmocom/core/bits.h> 00028 00041 static inline uint32_t 00042 osmo_a5_fn_count(uint32_t fn) 00043 { 00044 int t1 = fn / (26 * 51); 00045 int t2 = fn % 26; 00046 int t3 = fn % 51; 00047 return (t1 << 11) | (t3 << 5) | t2; 00048 } 00049 00050 /* Notes: 00051 * - key must be 8 or 16 (for a5/4) bytes long (or NULL for A5/0) 00052 * - the dl and ul pointer must be either NULL or 114 bits long 00053 * - fn is the _real_ GSM frame number. 00054 * (converted internally to fn_count) 00055 */ 00056 int osmo_a5(int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul); 00057 void osmo_a5_1(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul); 00058 void osmo_a5_2(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul); 00059