Обновление
This commit is contained in:
parent
7aa6118a8b
commit
8b9d584815
21
CanUds.c
21
CanUds.c
|
|
@ -15,9 +15,6 @@
|
||||||
#define LOG_SIGN "CAN_UDS"
|
#define LOG_SIGN "CAN_UDS"
|
||||||
#define LOGGER env->logger
|
#define LOGGER env->logger
|
||||||
|
|
||||||
uint32_t randomSecuritySeed = 0x853A08FB;
|
|
||||||
|
|
||||||
|
|
||||||
extern uint32_t generate_key(uint32_t seed);
|
extern uint32_t generate_key(uint32_t seed);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -975,14 +972,16 @@ static uint16_t SecurityAccess_27(tCanUds *env) {
|
||||||
env->dataResponse[5] = 0;
|
env->dataResponse[5] = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (randomSecuritySeed == 0) {
|
env->randomSecuritySeed = getRandom32(env->adcTask0);
|
||||||
randomSecuritySeed = 0x11223344;
|
|
||||||
|
if (env->randomSecuritySeed == 0) {
|
||||||
|
env->randomSecuritySeed = 0x11223344;
|
||||||
}
|
}
|
||||||
|
|
||||||
env->dataResponse[2] = randomSecuritySeed >> 24;
|
env->dataResponse[2] = env->randomSecuritySeed >> 24;
|
||||||
env->dataResponse[3] = randomSecuritySeed >> 16;
|
env->dataResponse[3] = env->randomSecuritySeed >> 16;
|
||||||
env->dataResponse[4] = randomSecuritySeed >> 8;
|
env->dataResponse[4] = env->randomSecuritySeed >> 8;
|
||||||
env->dataResponse[5] = randomSecuritySeed;
|
env->dataResponse[5] = env->randomSecuritySeed;
|
||||||
}
|
}
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
@ -1013,7 +1012,7 @@ static uint16_t SecurityAccess_27(tCanUds *env) {
|
||||||
uint32_t securitySeedFromServer =
|
uint32_t securitySeedFromServer =
|
||||||
(env->data.data[2] << 24) | (env->data.data[3] << 16) | (env->data.data[4] << 8) | env->data.data[5];
|
(env->data.data[2] << 24) | (env->data.data[3] << 16) | (env->data.data[4] << 8) | env->data.data[5];
|
||||||
|
|
||||||
uint32_t securitySeedMy = generate_key(randomSecuritySeed);
|
uint32_t securitySeedMy = generate_key(env->randomSecuritySeed);
|
||||||
|
|
||||||
if (securitySeedMy != securitySeedFromServer) {
|
if (securitySeedMy != securitySeedFromServer) {
|
||||||
++env->SA.counter_max_attempts_default;
|
++env->SA.counter_max_attempts_default;
|
||||||
|
|
@ -1360,12 +1359,14 @@ void CanUds_Init(
|
||||||
tSerialPortFrameIO *CanIO,
|
tSerialPortFrameIO *CanIO,
|
||||||
tDeviceStorage *deviceStorage,
|
tDeviceStorage *deviceStorage,
|
||||||
tCanSpamTransmitter *canSpamTransmitter,
|
tCanSpamTransmitter *canSpamTransmitter,
|
||||||
|
tAdcTask *adcTask0,
|
||||||
tLoggerInterface *logger) {
|
tLoggerInterface *logger) {
|
||||||
|
|
||||||
env->logger = logger;
|
env->logger = logger;
|
||||||
env->CanIO = CanIO;
|
env->CanIO = CanIO;
|
||||||
env->deviceStorage = deviceStorage;
|
env->deviceStorage = deviceStorage;
|
||||||
env->Diagnostic = Diagnostic;
|
env->Diagnostic = Diagnostic;
|
||||||
|
env->adcTask0 = adcTask0;
|
||||||
env->filterIdCount = 2;
|
env->filterIdCount = 2;
|
||||||
env->canSpamTransmitter = canSpamTransmitter;
|
env->canSpamTransmitter = canSpamTransmitter;
|
||||||
env->queue = osMessageQueueNew(CAN_US_QUEUE_SIZE, sizeof(tCanTP_data), NULL);
|
env->queue = osMessageQueueNew(CAN_US_QUEUE_SIZE, sizeof(tCanTP_data), NULL);
|
||||||
|
|
|
||||||
6
CanUds.h
6
CanUds.h
|
|
@ -9,6 +9,7 @@
|
||||||
#include "DeviceStorage.h"
|
#include "DeviceStorage.h"
|
||||||
#include "DiagnosticTask.h"
|
#include "DiagnosticTask.h"
|
||||||
#include "CanSpamTransmitter.h"
|
#include "CanSpamTransmitter.h"
|
||||||
|
#include "AdcTasks.h"
|
||||||
|
|
||||||
#define LOG_UDS 1
|
#define LOG_UDS 1
|
||||||
|
|
||||||
|
|
@ -143,6 +144,8 @@ typedef struct {
|
||||||
|
|
||||||
osMessageQueueId_t queue;
|
osMessageQueueId_t queue;
|
||||||
|
|
||||||
|
tAdcTask *adcTask0;
|
||||||
|
|
||||||
tCanTP_data data;
|
tCanTP_data data;
|
||||||
uint8_t dataResponse[1024];
|
uint8_t dataResponse[1024];
|
||||||
|
|
||||||
|
|
@ -158,6 +161,8 @@ typedef struct {
|
||||||
|
|
||||||
tCanSpamTransmitter *canSpamTransmitter;
|
tCanSpamTransmitter *canSpamTransmitter;
|
||||||
|
|
||||||
|
uint32_t randomSecuritySeed;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool requestSequenceRequestSeed;
|
bool requestSequenceRequestSeed;
|
||||||
bool stateSecurityAccess;
|
bool stateSecurityAccess;
|
||||||
|
|
@ -181,6 +186,7 @@ void CanUds_Init(
|
||||||
tSerialPortFrameIO *CanIO,
|
tSerialPortFrameIO *CanIO,
|
||||||
tDeviceStorage *deviceStorage,
|
tDeviceStorage *deviceStorage,
|
||||||
tCanSpamTransmitter *canSpamTransmitter,
|
tCanSpamTransmitter *canSpamTransmitter,
|
||||||
|
tAdcTask *adcTask0,
|
||||||
tLoggerInterface *logger);
|
tLoggerInterface *logger);
|
||||||
|
|
||||||
void CanSerialPortCanUds_Start(tCanUds *env);
|
void CanSerialPortCanUds_Start(tCanUds *env);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue