Diff between 55192ae2c449e7a254aa3073437ee76491e7a319 and ea940e67394ad58aac139d44c5586a9db98bbff7

Changed Files

File Additions Deletions Status
src/shared/crypto.c +11 -2 modified
src/shared/crypto.h +2 -0 modified

Full Patch

diff --git a/src/shared/crypto.c b/src/shared/crypto.c
index aa66dac..6de5514 100644
--- a/src/shared/crypto.c
+++ b/src/shared/crypto.c
@@ -568,8 +568,8 @@ bool bt_crypto_s1(struct bt_crypto *crypto, const uint8_t k[16],
 	return bt_crypto_e(crypto, k, res, res);
 }
 
-static bool aes_cmac(struct bt_crypto *crypto, uint8_t key[16], uint8_t *msg,
-					size_t msg_len, uint8_t res[16])
+static bool aes_cmac(struct bt_crypto *crypto, const uint8_t key[16],
+			const uint8_t *msg, size_t msg_len, uint8_t res[16])
 {
 	uint8_t key_msb[16], out[16], msg_msb[CMAC_MSG_MAX];
 	ssize_t len;
@@ -679,3 +679,12 @@ bool bt_crypto_g2(struct bt_crypto *crypto, uint8_t u[32], uint8_t v[32],
 
 	return true;
 }
+
+bool bt_crypto_h6(struct bt_crypto *crypto, const uint8_t w[16],
+				const uint8_t keyid[4], uint8_t res[16])
+{
+	if (!aes_cmac(crypto, w, keyid, 4, res))
+		return false;
+
+	return true;
+}
diff --git a/src/shared/crypto.h b/src/shared/crypto.h
index 9ba5803..84d4992 100644
--- a/src/shared/crypto.h
+++ b/src/shared/crypto.h
@@ -56,6 +56,8 @@ bool bt_crypto_f6(struct bt_crypto *crypto, uint8_t w[16], uint8_t n1[16],
 			uint8_t a1[7], uint8_t a2[7], uint8_t res[16]);
 bool bt_crypto_g2(struct bt_crypto *crypto, uint8_t u[32], uint8_t v[32],
 				uint8_t x[16], uint8_t y[16], uint32_t *val);
+bool bt_crypto_h6(struct bt_crypto *crypto, const uint8_t w[16],
+				const uint8_t keyid[4], uint8_t res[16]);
 bool bt_crypto_sign_att(struct bt_crypto *crypto, const uint8_t key[16],
 				const uint8_t *m, uint16_t m_len,
 				uint32_t sign_cnt, uint8_t signature[12]);