-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMED40.h
61 lines (51 loc) · 1.88 KB
/
MED40.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <memory>
#include "ISeedKeyInterface.h"
#include "ISecurityAlgorithmInterface.h"
#include "DaimlerStandardSecurityAlgo.h"
#include "ParameterProvider_MED40.h"
class MED40 : public ISeedKey {
public:
std::vector<int> GetConfiguredAccessTypes() override {
return {1, 5, 9};
}
int GetSeedLength(int paramInteger) override {
switch (paramInteger) {
case 1:
case 5:
case 9:
return 8;
default:
return -1;
}
}
int GetKeyLength(int paramInteger) override {
switch (paramInteger) {
case 1:
case 5:
case 9:
return 4;
default:
return -1;
}
}
std::string GetECUName() override {
return "MED40";
}
VKeyGenResultEx GenerateKey(const std::vector<uint8_t>& paramArrayOfByte1, int paramInt, const std::string& paramString1,
const std::string& paramString2, std::vector<uint8_t>& paramArrayOfByte2, Parameter<int>& paramParameter) override {
VKeyGenResultEx vKeyGenResultEx = VKeyGenResultEx::KGRE_UnspecifiedError;
std::unique_ptr<IParameterProvider> paramIParameterProvider;
switch (paramInt) {
case 1:
case 5:
case 9:
paramIParameterProvider = std::make_unique<ParameterProvider_MED40>();
break;
default:
return VKeyGenResultEx::KGRE_SecurityLevelInvalid;
}
DaimlerStandardSecurityAlgo daimlerStandardSecurityAlgo(paramIParameterProvider.get());
vKeyGenResultEx = daimlerStandardSecurityAlgo.GenerateKey(paramArrayOfByte1, paramInt, paramString1, paramString2, paramArrayOfByte2, paramParameter);
return vKeyGenResultEx;
}
};