I want to connect to a bluetooth device. Communication is via Hex-Strings only. I need to encode a 16 byte value. As a result I also expect a 16 byte value. In my implementation CryptoJS always returns a longer result. According to the documentation the IV is not needed. ("All the 16-byte data must be encrypted with the Customer Master Key currently stored in the device, using AES128 CBC cipher mode") Therefore I set the IV to 00000000000000000000000000000000 because CryptoJS seems to require it. What am I doing wrong?
const CryptoJS = require('crypto-js');
const value = CryptoJS.enc.Hex.parse('5ff58680541c5a5903f4833dfaa4281f');
const key = CryptoJS.enc.Hex.parse('41435231323535552d4a312041757458'); // known master key
const ivvar = CryptoJS.enc.Hex.parse('00000000000000000000000000000000');
const encryptedString = CryptoJS.AES.encrypt(value, key, {iv: ivvar, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.NoPadding}).toString();
// current result is edijc9R7sl3zwZVrBBBrFQ==
Sure, the result is only a string, but it is too long anyway.