summaryrefslogtreecommitdiffstats
path: root/osmo-gsup-hlr
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-05-05 17:07:17 +0200
committerHarald Welte <laforge@gnumonks.org>2016-05-05 17:08:48 +0200
commit6294b3a19eaa04ac0a7a5793ecf90d3654f36768 (patch)
tree23f4821bda078ea2c8287ed45e98275897b644c9 /osmo-gsup-hlr
parent9239c1a61584e40a58f869a5c97dc3ab3465a339 (diff)
AUC: use osmo_hexparse() when reading key material from db
The database stores the key material as hex-ascii, we thus need to go through osmo_hexparse() when reading. We could also store the material as BLOB in the database. That would however complicate matters, as it would basically mean using the sqlite3 command to manually inspect/modify data from the console would no longer be easily possible. Using this commit I have 2G authentication working against osmo-sgsn with GSUP and 'auth policy remote'.
Diffstat (limited to 'osmo-gsup-hlr')
-rw-r--r--osmo-gsup-hlr/src/db_auc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/osmo-gsup-hlr/src/db_auc.c b/osmo-gsup-hlr/src/db_auc.c
index 439018e..9196922 100644
--- a/osmo-gsup-hlr/src/db_auc.c
+++ b/osmo-gsup-hlr/src/db_auc.c
@@ -125,7 +125,7 @@ int db_get_auth_data(struct db_context *dbc, const char *imsi,
goto end_2g;
}
#endif
- memcpy(&aud2g->u.gsm.ki, ki, sizeof(aud2g->u.gsm.ki));
+ osmo_hexparse(ki, &aud2g->u.gsm.ki, sizeof(aud2g->u.gsm.ki));
aud2g->type = OSMO_AUTH_TYPE_GSM;
} else
LOGAUC(imsi, LOGL_DEBUG, "No 2G Auth Data\n");
@@ -140,7 +140,7 @@ int db_get_auth_data(struct db_context *dbc, const char *imsi,
LOGAUC(imsi, LOGL_ERROR, "Error reading K: %d\n", rc);
goto out;
}
- memcpy(&aud3g->u.umts.k, k, sizeof(aud3g->u.umts.k));
+ osmo_hexparse(k, &aud3g->u.umts.k, sizeof(aud3g->u.umts.k));
/* UMTS Subscribers can have either OP or OPC */
op = sqlite3_column_text(stmt, 5);
if (!op) {
@@ -149,10 +149,12 @@ int db_get_auth_data(struct db_context *dbc, const char *imsi,
LOGAUC(imsi, LOGL_ERROR, "Error reading OPC: %d\n", rc);
goto out;
}
- memcpy(&aud3g->u.umts.opc, opc, sizeof(aud3g->u.umts.opc));
+ osmo_hexparse(opc, &aud3g->u.umts.opc,
+ sizeof(aud3g->u.umts.opc));
aud3g->u.umts.opc_is_op = 0;
} else {
- memcpy(&aud3g->u.umts.opc, op, sizeof(aud3g->u.umts.opc));
+ osmo_hexparse(op, &aud3g->u.umts.opc,
+ sizeof(aud3g->u.umts.opc));
aud3g->u.umts.opc_is_op = 1;
}
aud3g->u.umts.sqn = sqlite3_column_int64(stmt, 7);