milenage: Add function to compute OPC from OP and K
diff --git a/src/gsm/milenage/milenage.c b/src/gsm/milenage/milenage.c
index cc4e95c..b43f986 100644
--- a/src/gsm/milenage/milenage.c
+++ b/src/gsm/milenage/milenage.c
@@ -327,3 +327,18 @@
 
 	return 0;
 }
+
+int milenage_opc_gen(u8 *opc, const u8 *k, const u8 *op)
+{
+	int i;
+
+	/* Encrypt OP using K */
+	if (aes_128_encrypt_block(k, op, opc))
+		return -1;
+
+	/* XOR the resulting Ek(OP) with OP */
+	for (i = 0; i < 16; i++)
+		opc[i] = opc[i] ^ op[i];
+
+	return 0;
+}
diff --git a/src/gsm/milenage/milenage.h b/src/gsm/milenage/milenage.h
index d5054d6..a91e946 100644
--- a/src/gsm/milenage/milenage.h
+++ b/src/gsm/milenage/milenage.h
@@ -30,4 +30,6 @@
 int milenage_f2345(const u8 *opc, const u8 *k, const u8 *_rand,
 		   u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar);
 
+int milenage_opc_gen(u8 *opc, const u8 *k, const u8 *op);
+
 #endif /* MILENAGE_H */