The bt_crypto_gatt_hash uses AES-CCM to create a hash with the contents
stored in the iovec.
Note: The spec disregards the byte order so both the key, msg and res
are not swapped.
Change-Id: Ifaa2b5ce256c17344b6a78b5f056ad5b1d63e1d7
Signed-off-by: himanshu <h.himanshu@samsung.com>
return true;
}
+
+bool bt_crypto_gatt_hash(struct bt_crypto *crypto, struct iovec *iov,
+ size_t iov_len, uint8_t res[16])
+{
+ const uint8_t key[16] = {};
+ ssize_t len;
+ int fd;
+
+ if (!crypto)
+ return false;
+
+ fd = alg_new(crypto->cmac_aes, key, 16);
+ if (fd < 0)
+ return false;
+
+ len = writev(fd, iov, iov_len);
+ if (len < 0) {
+ close(fd);
+ return false;
+ }
+
+ len = read(fd, res, 16);
+ if (len < 0) {
+ close(fd);
+ return false;
+ }
+
+ close(fd);
+
+ return true;
+}
#include <stdbool.h>
#include <stdint.h>
+#include <sys/uio.h>
struct bt_crypto;
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]);
+bool bt_crypto_gatt_hash(struct bt_crypto *crypto, struct iovec *iov,
+ size_t iov_len, uint8_t res[16]);