code: Use std::span where appropriate (#6658)

* code: Use std::span when possible

* code: Prefix memcpy and memcmp with std::
This commit is contained in:
GPUCode 2023-07-07 01:52:40 +03:00 committed by GitHub
parent 4ccd9f24fb
commit cf9bb90ae3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
106 changed files with 362 additions and 329 deletions

View file

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

@ -6,6 +6,7 @@
#include <array>
#include <cstddef>
#include <span>
#include <vector>
#include "common/common_types.h"
@ -23,7 +24,7 @@ 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,
std::vector<u8> EncryptSignCCM(std::span<const u8> pdata, const CCMNonce& nonce,
std::size_t slot_id);
/**
@ -33,7 +34,7 @@ std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& non
* @param slot_id The slot ID of the key to use for decryption
* @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,
std::vector<u8> DecryptVerifyCCM(std::span<const u8> cipher, const CCMNonce& nonce,
std::size_t slot_id);
} // namespace HW::AES