Line | Count | Source (jump to first uncovered line) |
1 | | // hex.cpp - originally written and placed in the public domain by Wei Dai |
2 | | |
3 | | #include "pch.h" |
4 | | |
5 | | #ifndef CRYPTOPP_IMPORTS |
6 | | |
7 | | #include "hex.h" |
8 | | |
9 | | NAMESPACE_BEGIN(CryptoPP) |
10 | | ANONYMOUS_NAMESPACE_BEGIN |
11 | | |
12 | | const byte s_vecUpper[] = "0123456789ABCDEF"; |
13 | | const byte s_vecLower[] = "0123456789abcdef"; |
14 | | const int s_array[256] = { |
15 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
16 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
17 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
18 | | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, |
19 | | -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
20 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
21 | | -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
22 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
23 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
24 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
25 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
26 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
27 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
28 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
29 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
30 | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 |
31 | | }; |
32 | | |
33 | | ANONYMOUS_NAMESPACE_END |
34 | | |
35 | | void HexEncoder::IsolatedInitialize(const NameValuePairs ¶meters) |
36 | 0 | { |
37 | 0 | bool uppercase = parameters.GetValueWithDefault(Name::Uppercase(), true); |
38 | 0 | m_filter->Initialize(CombinedNameValuePairs( |
39 | 0 | parameters, |
40 | 0 | MakeParameters(Name::EncodingLookupArray(), uppercase ? &s_vecUpper[0] : &s_vecLower[0], false)(Name::Log2Base(), 4, true))); |
41 | 0 | } |
42 | | |
43 | | void HexDecoder::IsolatedInitialize(const NameValuePairs ¶meters) |
44 | 0 | { |
45 | 0 | BaseN_Decoder::IsolatedInitialize(CombinedNameValuePairs( |
46 | 0 | parameters, |
47 | 0 | MakeParameters(Name::DecodingLookupArray(), GetDefaultDecodingLookupArray(), false)(Name::Log2Base(), 4, true))); |
48 | 0 | } |
49 | | |
50 | | // Unrolled initialization, http://github.com/weidai11/cryptopp/issues/376 |
51 | | const int *HexDecoder::GetDefaultDecodingLookupArray() |
52 | 135k | { |
53 | 135k | return s_array; |
54 | 135k | } |
55 | | |
56 | | NAMESPACE_END |
57 | | |
58 | | #endif // CRYPTOPP_IMPORTS |