mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-20 18:40:31 +00:00
debug pairing test case
This commit is contained in:
parent
fdcd1130d4
commit
e2bc2c157b
@ -26,11 +26,14 @@ COMMON = \
|
||||
|
||||
COMMON_OBJ = $(COMMON:.c=.o)
|
||||
|
||||
all: security_manager
|
||||
all: security_manager aestest
|
||||
|
||||
security_manager: ${CORE_OBJ} ${COMMON_OBJ} security_manager.c
|
||||
${CC} ${CORE_OBJ} ${COMMON_OBJ} security_manager.c ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
aestest: aestest.c rijndael.c
|
||||
${CC} ${CFLAGS} -m32 rijndael.c aestest.c -o $@
|
||||
|
||||
clean:
|
||||
rm -f security_manager
|
||||
rm -f *.o ${BTSTACK_ROOT}/src/*.o
|
||||
|
30
test/security_manager/aestest.c
Normal file
30
test/security_manager/aestest.c
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
#include "rijndael.h"
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
|
||||
void aes128_calc_cyphertext(uint8_t key[16], uint8_t plaintext[16], uint8_t cyphertext[16]){
|
||||
uint32_t rk[RKLENGTH(KEYBITS)];
|
||||
int nrounds = rijndaelSetupEncrypt(rk, &key[0], KEYBITS);
|
||||
rijndaelEncrypt(rk, nrounds, plaintext, cyphertext);
|
||||
}
|
||||
|
||||
|
||||
static void hexdump2(void *data, int size){
|
||||
if (size <= 0) return;
|
||||
int i;
|
||||
for (i=0; i<size;i++){
|
||||
printf("%02X ", ((uint8_t *)data)[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
@ -114,9 +114,9 @@ int hci_send_cmd(const hci_cmd_t *cmd, ...){
|
||||
swap128(key_flipped, key);
|
||||
swap128(plaintext_flipped, plaintext);
|
||||
printf("le_encrypt key ");
|
||||
hexdump(key_flipped, 16);
|
||||
hexdump(key, 16);
|
||||
printf("le_encrypt txt ");
|
||||
hexdump(plaintext_flipped, 16);
|
||||
hexdump(plaintext, 16);
|
||||
aes128_calc_cyphertext(key, plaintext, aes128_cyphertext);
|
||||
printf("le_encrypt res ");
|
||||
hexdump(aes128_cyphertext, 16);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,16 +6,12 @@
|
||||
#ifndef H__RIJNDAEL
|
||||
#define H__RIJNDAEL
|
||||
|
||||
#if defined __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int rijndaelSetupEncrypt(uint32_t *rk, const unsigned char *key, int keybits);
|
||||
int rijndaelSetupDecrypt(uint32_t *rk, const unsigned char *key, int keybits);
|
||||
void rijndaelEncrypt(const uint32_t *rk, int nrounds, const unsigned char plaintext[16], unsigned char ciphertext[16]);
|
||||
void rijndaelDecrypt(const uint32_t *rk, int nrounds, const unsigned char ciphertext[16], unsigned char plaintext[16]);
|
||||
int rijndaelSetupEncrypt(uint32_t *rk, const uint8_t *key, int keybits);
|
||||
int rijndaelSetupDecrypt(uint32_t *rk, const uint8_t *key, int keybits);
|
||||
void rijndaelEncrypt(const uint32_t *rk, int nrounds, const uint8_t plaintext[16], uint8_t ciphertext[16]);
|
||||
void rijndaelDecrypt(const uint32_t *rk, int nrounds, const uint8_t ciphertext[16], uint8_t plaintext[16]);
|
||||
|
||||
#define KEYBITS 128
|
||||
|
||||
@ -23,9 +19,5 @@ void rijndaelDecrypt(const uint32_t *rk, int nrounds, const unsigned char cipher
|
||||
#define RKLENGTH(keybits) ((keybits)/8+28)
|
||||
#define NROUNDS(keybits) ((keybits)/32+6)
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -78,7 +78,7 @@ TEST_GROUP(GATTClient){
|
||||
run_loop_init(RUN_LOOP_POSIX);
|
||||
sm_init();
|
||||
sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
|
||||
sm_set_authentication_requirements( SM_AUTHREQ_BONDING | SM_AUTHREQ_MITM_PROTECTION);
|
||||
sm_set_authentication_requirements( SM_AUTHREQ_BONDING );
|
||||
|
||||
mock_simulate_hci_state_working();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user