1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
19278: gnrc_dhcpv6_client_simple_pd: select upstream based on type/index r=benpicco a=benpicco



19290: sys/crypto: make AES_KEY struct private & rename it r=benpicco a=benpicco



Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
Co-authored-by: Benjamin Valentin <benjamin.valentin@bht-berlin.de>
This commit is contained in:
bors[bot] 2023-02-20 19:09:03 +00:00 committed by GitHub
commit be29a00d74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 23 deletions

View File

@ -32,8 +32,6 @@
* @}
*/
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
@ -62,6 +60,16 @@
# define AES_KEY_SIZE(ctx) ctx->key_size
#endif
/**
* @brief AES key
* @see cipher_context_t
*/
typedef struct {
/** @cond INTERNAL */
uint32_t rd_key[4 * (AES_MAXNR + 1)];
int rounds;
/** @endcond */
} aes_key_t;
/**
* Interface to the aes cipher
*/
@ -860,7 +868,7 @@ int aes_init(cipher_context_t *context, const uint8_t *key, uint8_t keySize)
* Expand the cipher key into the encryption key schedule.
*/
static int aes_set_encrypt_key(const unsigned char *userKey, const int bits,
AES_KEY *key)
aes_key_t *key)
{
u32 *rk;
int i = 0;
@ -979,7 +987,7 @@ static int aes_set_encrypt_key(const unsigned char *userKey, const int bits,
* Expand the cipher key into the decryption key schedule.
*/
static int aes_set_decrypt_key(const unsigned char *userKey, const int bits,
AES_KEY *key)
aes_key_t *key)
{
u32 *rk;
int i, j;
@ -1062,8 +1070,8 @@ int aes_encrypt(const cipher_context_t *context, const uint8_t *plainBlock,
{
/* setup AES_KEY */
int res;
AES_KEY aeskey;
const AES_KEY *key = &aeskey;
aes_key_t aeskey;
const aes_key_t *key = &aeskey;
res = aes_set_encrypt_key((unsigned char *)context->context,
AES_KEY_SIZE(context) * 8, &aeskey);
@ -1331,8 +1339,8 @@ int aes_decrypt(const cipher_context_t *context, const uint8_t *cipherBlock,
{
/* setup AES_KEY */
int res;
AES_KEY aeskey;
const AES_KEY *key = &aeskey;
aes_key_t aeskey;
const aes_key_t *key = &aeskey;
res = aes_set_decrypt_key((unsigned char *)context->context,
AES_KEY_SIZE(context) * 8, &aeskey);

View File

@ -30,10 +30,6 @@
#ifndef CRYPTO_AES_H
#define CRYPTO_AES_H
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include "crypto/ciphers.h"
@ -64,17 +60,6 @@ typedef uint8_t u8;
#define AES_KEY_SIZE_256 32
/** @} */
/**
* @brief AES key
* @see cipher_context_t
*/
typedef struct aes_key_st {
/** @cond INTERNAL */
uint32_t rd_key[4 * (AES_MAXNR + 1)];
int rounds;
/** @endcond */
} AES_KEY;
/**
* @brief the cipher_context_t-struct adapted for AES
*/

View File

@ -36,6 +36,25 @@ extern "C" {
#define CONFIG_GNRC_DHCPV6_CLIENT_6LBR_UPSTREAM (0)
#endif
/**
* @brief Interface type of the upstream interface
*
* See @ref netdev_type_t for possible values
*/
#ifndef CONFIG_GNRC_DHCPV6_CLIENT_6LBR_UPSTREAM_TYPE
#define CONFIG_GNRC_DHCPV6_CLIENT_6LBR_UPSTREAM_TYPE NETDEV_ANY
#endif
/**
* @brief Interface index of the upstream interface
*
* If there are multiple interfaces of the same type, set this to select
* which one to use for the upstream.
*/
#ifndef CONFIG_GNRC_DHCPV6_CLIENT_6LBR_UPSTREAM_IDX
#define CONFIG_GNRC_DHCPV6_CLIENT_6LBR_UPSTREAM_IDX (0)
#endif
/**
* @brief 6LoWPAN compression context lifetime for configured prefixes in
* minutes

View File

@ -48,6 +48,12 @@ static gnrc_netif_t *_find_upstream_netif(void)
if (CONFIG_GNRC_DHCPV6_CLIENT_6LBR_UPSTREAM) {
return gnrc_netif_get_by_pid(CONFIG_GNRC_DHCPV6_CLIENT_6LBR_UPSTREAM);
}
if (CONFIG_GNRC_DHCPV6_CLIENT_6LBR_UPSTREAM_TYPE != NETDEV_ANY) {
return gnrc_netif_get_by_type(CONFIG_GNRC_DHCPV6_CLIENT_6LBR_UPSTREAM_TYPE,
CONFIG_GNRC_DHCPV6_CLIENT_6LBR_UPSTREAM_IDX);
}
while ((netif = gnrc_netif_iter(netif))) {
if (!gnrc_netif_is_6lo(netif)) {
LOG_WARNING("DHCPv6: Selecting interface %d as upstream\n",
@ -93,9 +99,16 @@ static void _configure_dhcpv6_client(void)
{
gnrc_netif_t *netif = NULL;
gnrc_netif_t *upstream = _find_upstream_netif();
if (upstream == NULL) {
LOG_ERROR("DHCPv6: No upstream interface found!\n");
return;
}
if (IS_ACTIVE(MODULE_DHCPV6_CLIENT_IA_NA)) {
upstream->ipv6.aac_mode |= GNRC_NETIF_AAC_DHCP;
}
while ((netif = gnrc_netif_iter(netif))) {
if (IS_USED(MODULE_GNRC_DHCPV6_CLIENT_6LBR)
&& !gnrc_netif_is_6lo(netif)) {

View File

@ -6,6 +6,7 @@
* directory for more details.
*/
#include <string.h>
#include <limits.h>
#include "embUnit.h"