Start to use struct osmo_auth_vector from gsm_auth_tuple

Rather than having a 'private' structure for kc, sres and rand, we
now finally (with 4 years delay) use osmo_auth_vector from libosmogsm,
which encapsulates authentication vectors that can be either GSM
triplets or UMTS quintuples or a combination of both.

gsm_auth_tuple becomes a wrapper around osmo_auth_vector, adding
use_count and key_seq to it.

key_seq is no longer initialized inside gprs_gsup_messages.c, as there
is no CKSN / key_seq inside the message anyway.  If a usre of the code
needs key_seq, they need to manage it themselves.
diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c
index f30d56d..9191ae8 100644
--- a/openbsc/src/libmsc/auth.c
+++ b/openbsc/src/libmsc/auth.c
@@ -54,9 +54,9 @@
 	}
 
 	for (i=0; i<4; i++)
-		atuple->sres[i] = atuple->rand[i] ^ ainfo->a3a8_ki[i];
+		atuple->vec.sres[i] = atuple->vec.rand[i] ^ ainfo->a3a8_ki[i];
 	for (i=4; i<12; i++)
-		atuple->kc[i-4] = atuple->rand[i] ^ ainfo->a3a8_ki[i];
+		atuple->vec.kc[i-4] = atuple->vec.rand[i] ^ ainfo->a3a8_ki[i];
 
 	return 0;
 }
@@ -71,7 +71,7 @@
 		return -1;
 	}
 
-	comp128(ainfo->a3a8_ki, atuple->rand, atuple->sres, atuple->kc);
+	comp128(ainfo->a3a8_ki, atuple->vec.rand, atuple->vec.sres, atuple->vec.kc);
 
 	return 0;
 }
@@ -122,7 +122,7 @@
 	}
 	atuple->use_count = 1;
 
-	if (RAND_bytes(atuple->rand, sizeof(atuple->rand)) != 1) {
+	if (RAND_bytes(atuple->vec.rand, sizeof(atuple->vec.rand)) != 1) {
 		LOGP(DMM, LOGL_NOTICE, "RAND_bytes failed, can't generate new auth tuple\n");
 		return AUTH_ERROR;
 	}
diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c
index 267b5ef..a23ec89 100644
--- a/openbsc/src/libmsc/db.c
+++ b/openbsc/src/libmsc/db.c
@@ -700,25 +700,25 @@
 	atuple->key_seq = dbi_result_get_ulonglong(result, "key_seq");
 
 	len = dbi_result_get_field_length(result, "rand");
-	if (len != sizeof(atuple->rand))
+	if (len != sizeof(atuple->vec.rand))
 		goto err_size;
 
 	blob = dbi_result_get_binary(result, "rand");
-	memcpy(atuple->rand, blob, len);
+	memcpy(atuple->vec.rand, blob, len);
 
 	len = dbi_result_get_field_length(result, "sres");
-	if (len != sizeof(atuple->sres))
+	if (len != sizeof(atuple->vec.sres))
 		goto err_size;
 
 	blob = dbi_result_get_binary(result, "sres");
-	memcpy(atuple->sres, blob, len);
+	memcpy(atuple->vec.sres, blob, len);
 
 	len = dbi_result_get_field_length(result, "kc");
-	if (len != sizeof(atuple->kc))
+	if (len != sizeof(atuple->vec.kc))
 		goto err_size;
 
 	blob = dbi_result_get_binary(result, "kc");
-	memcpy(atuple->kc, blob, len);
+	memcpy(atuple->vec.kc, blob, len);
 
 	dbi_result_free(result);
 
@@ -759,11 +759,11 @@
 
 	/* Update / Insert */
 	dbi_conn_quote_binary_copy(conn,
-		atuple->rand, sizeof(atuple->rand), &rand_str);
+		atuple->vec.rand, sizeof(atuple->vec.rand), &rand_str);
 	dbi_conn_quote_binary_copy(conn,
-		atuple->sres, sizeof(atuple->sres), &sres_str);
+		atuple->vec.sres, sizeof(atuple->vec.sres), &sres_str);
 	dbi_conn_quote_binary_copy(conn,
-		atuple->kc, sizeof(atuple->kc), &kc_str);
+		atuple->vec.kc, sizeof(atuple->vec.kc), &kc_str);
 
 	if (!upd) {
 		result = dbi_conn_queryf(conn,
diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index 05cb886..f02f784 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -234,11 +234,11 @@
 	/* Then do whatever is needed ... */
 	if (rc == AUTH_DO_AUTH_THEN_CIPH) {
 		/* Start authentication */
-		return gsm48_tx_mm_auth_req(conn, op->atuple.rand, op->atuple.key_seq);
+		return gsm48_tx_mm_auth_req(conn, op->atuple.vec.rand, op->atuple.key_seq);
 	} else if (rc == AUTH_DO_CIPH) {
 		/* Start ciphering directly */
 		return gsm0808_cipher_mode(conn, net->a5_encryption,
-		                           op->atuple.kc, 8, 0);
+		                           op->atuple.vec.kc, 8, 0);
 	}
 
 	return -EINVAL; /* not reached */
@@ -1102,12 +1102,12 @@
 	}
 
 	/* Validate SRES */
-	if (memcmp(conn->sec_operation->atuple.sres, ar->sres,4)) {
+	if (memcmp(conn->sec_operation->atuple.vec.sres, ar->sres,4)) {
 		int rc;
 		gsm_cbfn *cb = conn->sec_operation->cb;
 
 		DEBUGPC(DMM, "Invalid (expected %s)\n",
-			osmo_hexdump(conn->sec_operation->atuple.sres, 4));
+			osmo_hexdump(conn->sec_operation->atuple.vec.sres, 4));
 
 		if (cb)
 			cb(GSM_HOOK_RR_SECURITY, GSM_SECURITY_AUTH_FAILED,
@@ -1122,7 +1122,7 @@
 
 	/* Start ciphering */
 	return gsm0808_cipher_mode(conn, net->a5_encryption,
-	                           conn->sec_operation->atuple.kc, 8, 0);
+	                           conn->sec_operation->atuple.vec.kc, 8, 0);
 }
 
 /* Receive a GSM 04.08 Mobility Management (MM) message */
diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c
index 790fedf..4c2088a 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -94,13 +94,13 @@
 		vty_out(vty, "     seq # : %d%s",
 			atuple.key_seq, VTY_NEWLINE);
 		vty_out(vty, "     RAND  : %s%s",
-			osmo_hexdump(atuple.rand, sizeof(atuple.rand)),
+			osmo_hexdump(atuple.vec.rand, sizeof(atuple.vec.rand)),
 			VTY_NEWLINE);
 		vty_out(vty, "     SRES  : %s%s",
-			osmo_hexdump(atuple.sres, sizeof(atuple.sres)),
+			osmo_hexdump(atuple.vec.sres, sizeof(atuple.vec.sres)),
 			VTY_NEWLINE);
 		vty_out(vty, "     Kc    : %s%s",
-			osmo_hexdump(atuple.kc, sizeof(atuple.kc)),
+			osmo_hexdump(atuple.vec.kc, sizeof(atuple.vec.kc)),
 			VTY_NEWLINE);
 	}