Ejemplo n.º 1
0
int hci_send_cmd(const hci_cmd_t *cmd, ...) {
    va_list argptr;
    va_start(argptr, cmd);
    uint16_t len = hci_create_cmd_internal(packet_buffer, cmd, argptr);
    va_end(argptr);
    hci_dump_packet(HCI_COMMAND_DATA_PACKET, 0, packet_buffer, len);
    dump_packet(HCI_COMMAND_DATA_PACKET, packet_buffer, len);
    packet_buffer_len = len;

    // track le encrypt and le rand
    if (cmd->opcode ==  hci_le_encrypt.opcode) {
        uint8_t * key_flipped = &packet_buffer[3];
        uint8_t key[16];
        swap128(key_flipped, key);
        // printf("le_encrypt key ");
        // hexdump(key, 16);
        uint8_t * plaintext_flipped = &packet_buffer[19];
        uint8_t plaintext[16];
        swap128(plaintext_flipped, plaintext);
        // printf("le_encrypt txt ");
        // hexdump(plaintext, 16);
        aes128_calc_cyphertext(key, plaintext, aes128_cyphertext);
        // printf("le_encrypt res ");
        // hexdump(aes128_cyphertext, 16);
    }
    return 0;
}
Ejemplo n.º 2
0
int main(){
	uint8_t key[16];
	uint8_t plaintext[16];
	bzero(key, 16);
	bzero(plaintext, 16);
	uint8_t cyphertext[16];
	aes128_calc_cyphertext(key, plaintext, cyphertext);
	hexdump2(cyphertext, 16);
}