btstack_crypto.c (2fca4dad957cd7b88f4657ed51e89c12615dda72) | btstack_crypto.c (f2a94e3bf69dd83e88a5463a30173a12a1e5b2f6) |
---|---|
1/* 2 * Copyright (C) 2017 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 742 unchanged lines hidden (view full) --- 751 uint8_t btstack_crypto_ccm_buffer[16]; 752 btstack_crypto_ccm->state = CCM_W4_XN; 753 754#ifdef DEBUG_CCM 755 printf("%16s: ", "bn"); 756 printf_hexdump(plaintext, 16); 757#endif 758 uint8_t i; | 1/* 2 * Copyright (C) 2017 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 742 unchanged lines hidden (view full) --- 751 uint8_t btstack_crypto_ccm_buffer[16]; 752 btstack_crypto_ccm->state = CCM_W4_XN; 753 754#ifdef DEBUG_CCM 755 printf("%16s: ", "bn"); 756 printf_hexdump(plaintext, 16); 757#endif 758 uint8_t i; |
759 uint8_t bytes_to_decrypt = btstack_crypto_ccm->block_len; | 759 uint16_t bytes_to_decrypt = btstack_crypto_ccm->block_len; |
760 // use explicit min implementation as c-stat worried about out-of-bounds-reads 761 if (bytes_to_decrypt > 16u) { 762 bytes_to_decrypt = 16; 763 } 764 for (i = 0; i < bytes_to_decrypt ; i++){ 765 btstack_crypto_ccm_buffer[i] = btstack_crypto_ccm->x_i[i] ^ plaintext[i]; 766 } 767 (void)memcpy(&btstack_crypto_ccm_buffer[i], &btstack_crypto_ccm->x_i[i], --- 615 unchanged lines hidden --- | 760 // use explicit min implementation as c-stat worried about out-of-bounds-reads 761 if (bytes_to_decrypt > 16u) { 762 bytes_to_decrypt = 16; 763 } 764 for (i = 0; i < bytes_to_decrypt ; i++){ 765 btstack_crypto_ccm_buffer[i] = btstack_crypto_ccm->x_i[i] ^ plaintext[i]; 766 } 767 (void)memcpy(&btstack_crypto_ccm_buffer[i], &btstack_crypto_ccm->x_i[i], --- 615 unchanged lines hidden --- |