SPP packet AES-128-GCM cipher context implementation. More...
#include "external/encryption/cipher.h"#include "external/encryption/encryption.h"#include <string.h>Go to the source code of this file.
Functions | |
| static void | s_buildNonce (const SPP_Packet_t *p_packet, spp_uint8_t p_nonce[K_SPP_CIPHER_NONCE_LEN]) |
| Derive the 12-byte GCM nonce from an SPP packet header. | |
| SPP_RetVal_t | SPP_EXTERNAL_ENCRYPTION_CYPHER_encryptPacket (spp_uint8_t *p_buffer, spp_uint16_t *p_outSize) |
| Encrypt an SPP packet buffer in-place with AES-128-GCM. | |
Variables | |
| static const spp_uint8_t | s_key [K_SPP_CIPHER_KEY_LEN] = K_SPP_CIPHER_KEY |
SPP packet AES-128-GCM cipher context implementation.
Encrypts a raw SPP packet buffer in-place, producing the output frame: [ nonce (12 B) | ciphertext (sizeof SPP_Packet_t) | tag (16 B) ]
Definition in file cipher.c.
|
static |
Derive the 12-byte GCM nonce from an SPP packet header.
| [in] | p_packet | Packet to derive nonce from. |
| [out] | p_nonce | 12-byte output buffer. |
Definition at line 34 of file cipher.c.
References K_SPP_CIPHER_NONCE_LEN, s_buildNonce(), and SPP_Packet_t.
Referenced by s_buildNonce(), and SPP_EXTERNAL_ENCRYPTION_CYPHER_encryptPacket().
| SPP_RetVal_t SPP_EXTERNAL_ENCRYPTION_CYPHER_encryptPacket | ( | spp_uint8_t * | p_buffer, |
| spp_uint16_t * | p_outSize ) |
Encrypt an SPP packet buffer in-place with AES-128-GCM.
Reads sizeof(SPP_Packet_t) bytes from p_buffer, encrypts them, and overwrites p_buffer with the output frame:
[ nonce (12 B) | ciphertext (sizeof SPP_Packet_t) | tag (16 B) ]
The nonce is derived from the packet header:
p_buffer must point to a buffer of at least K_SPP_CIPHER_FRAME_LEN bytes so the output frame fits.
| [in,out] | p_buffer | On entry: raw SPP packet bytes. On exit: encrypted frame (nonce | ciphertext | tag). |
| [out] | p_outSize | Set to K_SPP_CIPHER_FRAME_LEN on success. |
Definition at line 56 of file cipher.c.
References K_SPP_CIPHER_FRAME_LEN, K_SPP_CIPHER_NONCE_LEN, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, s_buildNonce(), s_key, SPP_EXTERNAL_ENCRYPTION_CYPHER_encryptPacket(), SPP_EXTERNAL_ENCRYPTION_gcmEncrypt(), and SPP_Packet_t.
Referenced by SPP_EXTERNAL_ENCRYPTION_CYPHER_encryptPacket(), and SPP_HAL_UART_transmit().
|
static |
Definition at line 22 of file cipher.c.
Referenced by SPP_EXTERNAL_ENCRYPTION_CYPHER_encryptPacket().