aboutsummaryrefslogtreecommitdiffstats
path: root/src/gsm/auth_xor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gsm/auth_xor.c')
-rw-r--r--src/gsm/auth_xor.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/gsm/auth_xor.c b/src/gsm/auth_xor.c
index 36e006e6..a506a03d 100644
--- a/src/gsm/auth_xor.c
+++ b/src/gsm/auth_xor.c
@@ -20,10 +20,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
*/
#include <string.h>
@@ -47,19 +43,23 @@ static void xor(uint8_t *out, const uint8_t *a, const uint8_t *b, size_t len)
/* 3GPP TS 34.108, section 8.1.2.1 */
static int xor_gen_vec(struct osmo_auth_vector *vec,
- struct osmo_sub_auth_data *aud,
+ struct osmo_sub_auth_data2 *aud,
const uint8_t *_rand)
{
uint8_t xdout[16], cdout[8];
uint8_t ak[6], xmac[8];
int i;
+ OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_XOR_3G);
+
/* Step 1: xdout = (ki or k) ^ rand */
if (aud->type == OSMO_AUTH_TYPE_GSM)
xor(xdout, aud->u.gsm.ki, _rand, sizeof(xdout));
- else if (aud->type == OSMO_AUTH_TYPE_UMTS)
+ else if (aud->type == OSMO_AUTH_TYPE_UMTS) {
+ if (aud->u.umts.k_len != 16)
+ return -EINVAL;
xor(xdout, aud->u.umts.k, _rand, sizeof(xdout));
- else
+ } else
return -ENOTSUP;
/**
@@ -129,7 +129,7 @@ static int xor_gen_vec(struct osmo_auth_vector *vec,
/* 3GPP TS 34.108, section 8.1.2.2 */
static int xor_gen_vec_auts(struct osmo_auth_vector *vec,
- struct osmo_sub_auth_data *aud,
+ struct osmo_sub_auth_data2 *aud,
const uint8_t *auts,
const uint8_t *rand_auts,
const uint8_t *_rand)
@@ -138,12 +138,16 @@ static int xor_gen_vec_auts(struct osmo_auth_vector *vec,
uint8_t ak[6], xmac[8];
uint8_t sqnms[6];
+ OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_XOR_3G);
+
/* Step 1: xdout = (ki or k) ^ rand */
if (aud->type == OSMO_AUTH_TYPE_GSM)
xor(xdout, aud->u.gsm.ki, _rand, sizeof(xdout));
- else if (aud->type == OSMO_AUTH_TYPE_UMTS)
+ else if (aud->type == OSMO_AUTH_TYPE_UMTS) {
+ if (aud->u.umts.k_len != 16)
+ return -EINVAL;
xor(xdout, aud->u.umts.k, _rand, sizeof(xdout));
- else
+ } else
return -ENOTSUP;
/* Step 2: ak = xdout[2-8] */
@@ -172,8 +176,8 @@ static int xor_gen_vec_auts(struct osmo_auth_vector *vec,
}
static struct osmo_auth_impl xor_alg = {
- .algo = OSMO_AUTH_ALG_XOR,
- .name = "XOR (libosmogsm built-in)",
+ .algo = OSMO_AUTH_ALG_XOR_3G,
+ .name = "XOR-3G (libosmogsm built-in)",
.priority = 1000,
.gen_vec = &xor_gen_vec,
.gen_vec_auts = &xor_gen_vec_auts,