-/* Copyright (c) 2014 Samsung Electronics Co.
+/* Copyright (c) 2014-2019 Samsung Electronics Co., Ltd. All rights reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// used to pass password and raw key data
typedef SafeBuffer<unsigned char>::Type RawBuffer;
+template <class T, bool Uppercase = false>
+T hexDump(const RawBuffer &raw) {
+ T dump;
+ dump.reserve(2 * raw.size());
+ constexpr char digit[2][16] = {{
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ 'a', 'b', 'c', 'd', 'e', 'f'
+ }, {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ 'A', 'B', 'C', 'D', 'E', 'F'
+ }};
+ for (auto &e : raw) {
+ dump.push_back(digit[Uppercase][e / 16]);
+ dump.push_back(digit[Uppercase][e % 16]);
+ }
+ return dump;
+}
+
} // namespace CKM
#endif //_SAFE_BUFFER_H_