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