[FR_CODE_DISCONNECT_REQUEST] = true,
};
-/*
- * For request packets which have the Request Authenticator being
- * all zeros. We need to decode attributes using a Request
- * Authenticator of all zeroes, but the actual Request
- * Authenticator contains the signature of the packet, so we
- * can't use that.
- */
-static uint8_t nullvector[RADIUS_AUTH_VECTOR_LENGTH] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/** Return the on-the-wire length of an attribute value
*
uint8_t *out_p, *out_end;
packet_ctx.secret = secret;
- packet_ctx.vector = packet + 4;
packet_ctx.rand_ctx.a = fr_rand();
packet_ctx.rand_ctx.b = fr_rand();
switch (code) {
case FR_CODE_ACCESS_REQUEST:
case FR_CODE_STATUS_SERVER:
+ memcpy(packet_ctx.vector, packet + 4, sizeof(packet_ctx.vector));
break;
case FR_CODE_ACCESS_ACCEPT:
fr_strerror_printf("Cannot encode response without request");
return -1;
}
- packet_ctx.vector = original + 4;
+ memcpy(packet_ctx.vector, original + 4, sizeof(packet_ctx.vector));
memcpy(packet + 4, packet_ctx.vector, RADIUS_AUTH_VECTOR_LENGTH);
break;
case FR_CODE_ACCOUNTING_REQUEST:
- packet_ctx.vector = nullvector;
- memcpy(packet + 4, packet_ctx.vector, RADIUS_AUTH_VECTOR_LENGTH);
- break;
-
case FR_CODE_COA_REQUEST:
case FR_CODE_DISCONNECT_REQUEST:
- packet_ctx.vector = nullvector;
- memcpy(packet + 4, packet_ctx.vector, RADIUS_AUTH_VECTOR_LENGTH);
+ memset(packet_ctx.vector, 0, sizeof(packet_ctx.vector));
+ memset(packet + 4, 0, RADIUS_AUTH_VECTOR_LENGTH);
break;
default:
packet_ctx.tmp_ctx = talloc_init_const("tmp");
packet_ctx.secret = secret;
- packet_ctx.vector = original ? original + 4 : packet + 4;
+ memcpy(packet_ctx.vector, original ? original + 4 : packet + 4, sizeof(packet_ctx.vector));
attr = packet + 20;
end = packet + packet_len;
static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
{
- static uint8_t vector[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
+ static uint8_t vector[RADIUS_AUTH_VECTOR_LENGTH] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
fr_radius_ctx_t *test_ctx;
test_ctx = talloc_zero(ctx, fr_radius_ctx_t);
test_ctx->secret = talloc_strdup(test_ctx, "testing123");
- test_ctx->vector = vector;
+ memcpy(test_ctx->vector, vector, sizeof(test_ctx->vector));
test_ctx->tmp_ctx = talloc_zero(ctx, uint8_t);
talloc_set_destructor(test_ctx, _test_ctx_free);
static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
{
- static uint8_t vector[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
+ static uint8_t vector[RADIUS_AUTH_VECTOR_LENGTH] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
fr_radius_ctx_t *test_ctx;
if (!test_ctx) return -1;
test_ctx->secret = talloc_strdup(test_ctx, "testing123");
- test_ctx->vector = vector;
+ memcpy(test_ctx->vector, vector, sizeof(test_ctx->vector));
test_ctx->rand_ctx.a = 6809;
test_ctx->rand_ctx.b = 2112;
talloc_set_destructor(test_ctx, _test_ctx_free);
fr_cursor_t cursor, out;
fr_radius_ctx_t packet_ctx = {
.secret = secret,
- .vector = packet->vector,
.tunnel_password_zeros = tunnel_password_zeros
};
switch (packet->code) {
case FR_CODE_ACCESS_REQUEST:
case FR_CODE_STATUS_SERVER:
+ memcpy(packet_ctx.vector, packet->vector, sizeof(packet_ctx.vector));
break;
case FR_CODE_ACCESS_ACCEPT:
* radsniff doesn't always have a response
*/
if (original) {
- packet_ctx.vector = original->vector;
+ memcpy(packet_ctx.vector, original->vector, sizeof(packet_ctx.vector));
} else {
memset(packet->vector, 0, sizeof(packet->vector));
+ memset(packet_ctx.vector, 0, sizeof(packet_ctx.vector));
}
break;
case FR_CODE_ACCOUNTING_REQUEST:
- memset(packet->vector, 0, sizeof(packet->vector));
- break;
-
case FR_CODE_COA_REQUEST:
case FR_CODE_DISCONNECT_REQUEST:
memset(packet->vector, 0, sizeof(packet->vector));
+ memset(packet_ctx.vector, 0, sizeof(packet_ctx.vector));
break;
default:
typedef struct {
TALLOC_CTX *tmp_ctx; //!< for temporary things cleaned up during decoding
- uint8_t const *vector; //!< vector for encryption / decryption of data
+ uint8_t vector[RADIUS_AUTH_VECTOR_LENGTH]; //!< vector for encryption / decryption of data
char const *secret; //!< shared secret. MUST be talloc'd
fr_fast_rand_t rand_ctx; //!< for tunnel passwords
int salt_offset; //!< for tunnel passwords