Fork 0

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'.
This commit is contained in:
Harald Welte 2016-05-05 17:07:17 +02:00
parent 9239c1a615
commit 6294b3a19e
1 changed files with 6 additions and 4 deletions

View File

@ -125,7 +125,7 @@ int db_get_auth_data(struct db_context *dbc, const char *imsi,
goto end_2g;
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,
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,
aud3g->u.umts.opc_is_op = 1;
aud3g->u.umts.sqn = sqlite3_column_int64(stmt, 7);