Prefix all size_t with std::

done automatically by executing regex replace `([^:0-9a-zA-Z_])size_t([^0-9a-zA-Z_])` -> `$1std::size_t$2`
This commit is contained in:
Weiyi Wang 2018-09-06 16:03:28 -04:00
parent eca98eeb3e
commit 7d8f115185
158 changed files with 669 additions and 634 deletions

View file

@ -44,7 +44,7 @@ public:
} // namespace
std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& nonce,
size_t slot_id) {
std::size_t slot_id) {
if (!IsNormalKeyAvailable(slot_id)) {
LOG_ERROR(HW_AES, "Key slot {} not available. Will use zero key.", slot_id);
}
@ -65,7 +65,7 @@ std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& non
}
std::vector<u8> DecryptVerifyCCM(const std::vector<u8>& cipher, const CCMNonce& nonce,
size_t slot_id) {
std::size_t slot_id) {
if (!IsNormalKeyAvailable(slot_id)) {
LOG_ERROR(HW_AES, "Key slot {} not available. Will use zero key.", slot_id);
}

View file

@ -12,8 +12,8 @@
namespace HW {
namespace AES {
constexpr size_t CCM_NONCE_SIZE = 12;
constexpr size_t CCM_MAC_SIZE = 16;
constexpr std::size_t CCM_NONCE_SIZE = 12;
constexpr std::size_t CCM_MAC_SIZE = 16;
using CCMNonce = std::array<u8, CCM_NONCE_SIZE>;
@ -24,7 +24,8 @@ using CCMNonce = std::array<u8, CCM_NONCE_SIZE>;
* @param slot_id The slot ID of the key to use for encryption
* @returns a vector of u8 containing the encrypted data with MAC at the end
*/
std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& nonce, size_t slot_id);
std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& nonce,
std::size_t slot_id);
/**
* Decrypts and verify the MAC of the given data using AES-CCM algorithm.
@ -34,7 +35,7 @@ std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& non
* @returns a vector of u8 containing the decrypted data; an empty vector if the verification fails
*/
std::vector<u8> DecryptVerifyCCM(const std::vector<u8>& cipher, const CCMNonce& nonce,
size_t slot_id);
std::size_t slot_id);
} // namespace AES
} // namespace HW

View file

@ -62,7 +62,7 @@ AESKey HexToKey(const std::string& hex) {
}
AESKey key;
for (size_t i = 0; i < key.size(); ++i) {
for (std::size_t i = 0; i < key.size(); ++i) {
key[i] = static_cast<u8>(std::stoi(hex.substr(i * 2, 2), 0, 16));
}
@ -102,7 +102,7 @@ void LoadPresetKeys() {
continue;
}
size_t slot_id;
std::size_t slot_id;
char key_type;
if (std::sscanf(name.c_str(), "slot0x%zXKey%c", &slot_id, &key_type) != 2) {
LOG_ERROR(HW_AES, "Invalid key name {}", name);
@ -145,23 +145,23 @@ void SetGeneratorConstant(const AESKey& key) {
generator_constant = key;
}
void SetKeyX(size_t slot_id, const AESKey& key) {
void SetKeyX(std::size_t slot_id, const AESKey& key) {
key_slots.at(slot_id).SetKeyX(key);
}
void SetKeyY(size_t slot_id, const AESKey& key) {
void SetKeyY(std::size_t slot_id, const AESKey& key) {
key_slots.at(slot_id).SetKeyY(key);
}
void SetNormalKey(size_t slot_id, const AESKey& key) {
void SetNormalKey(std::size_t slot_id, const AESKey& key) {
key_slots.at(slot_id).SetNormalKey(key);
}
bool IsNormalKeyAvailable(size_t slot_id) {
bool IsNormalKeyAvailable(std::size_t slot_id) {
return key_slots.at(slot_id).normal.is_initialized();
}
AESKey GetNormalKey(size_t slot_id) {
AESKey GetNormalKey(std::size_t slot_id) {
return key_slots.at(slot_id).normal.value_or(AESKey{});
}

View file

@ -11,7 +11,7 @@
namespace HW {
namespace AES {
enum KeySlotID : size_t {
enum KeySlotID : std::size_t {
// Used to decrypt the SSL client cert/private-key stored in ClCertA.
SSLKey = 0x0D,
@ -31,19 +31,19 @@ enum KeySlotID : size_t {
MaxKeySlotID = 0x40,
};
constexpr size_t AES_BLOCK_SIZE = 16;
constexpr std::size_t AES_BLOCK_SIZE = 16;
using AESKey = std::array<u8, AES_BLOCK_SIZE>;
void InitKeys();
void SetGeneratorConstant(const AESKey& key);
void SetKeyX(size_t slot_id, const AESKey& key);
void SetKeyY(size_t slot_id, const AESKey& key);
void SetNormalKey(size_t slot_id, const AESKey& key);
void SetKeyX(std::size_t slot_id, const AESKey& key);
void SetKeyY(std::size_t slot_id, const AESKey& key);
void SetNormalKey(std::size_t slot_id, const AESKey& key);
bool IsNormalKeyAvailable(size_t slot_id);
AESKey GetNormalKey(size_t slot_id);
bool IsNormalKeyAvailable(std::size_t slot_id);
AESKey GetNormalKey(std::size_t slot_id);
} // namespace AES
} // namespace HW