-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMAC.cpp
54 lines (48 loc) · 837 Bytes
/
MAC.cpp
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
//
// mac.cpp
// browser-cc
//
// Created by Nissassin Seventeen on 10/6/15.
// Copyright (c) 2015 Nissassin Seventeen. All rights reserved.
//
#include "MAC.hpp"
int MAC::getMacLength() const {
return macLength;
}
int MAC::getMacKeyLength() const {
return macKeyLength;
}
;
MAC::Algorithm MAC::getAlgorithm() const {
return algorithm;
}
MAC::MAC(MACType type) {
setType(type);
}
void MAC::setType(MACType type) {
this->type = type;
switch (type) {
case MAC_NULL:
algorithm = ALGORITHM_NONE;
macLength = 0;
macKeyLength = 0;
break;
case MD5:
algorithm = HMAC_MD5;
macLength = 16;
macKeyLength = 16;
break;
case SHA:
algorithm = HMAC_SHA1;
macKeyLength = 20;
macLength = 20;
break;
case SHA256:
algorithm = HMAC_SHA256;
macLength = 32;
macKeyLength = 32;
break;
default:
break;
}
}