summaryrefslogtreecommitdiffstats
path: root/src/core/hw/aes/ccm.h
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2017-01-01 13:58:02 +0100
committerwwylele <wwylele@gmail.com>2017-02-21 22:57:31 +0100
commitea1ea0224c04753402e0b6472080f0c5d90a7a46 (patch)
treed6823e52d913418d63ec3f0b7ed12eb763a98899 /src/core/hw/aes/ccm.h
parentMerge pull request #2562 from yuriks/pica-refactor3 (diff)
downloadyuzu-ea1ea0224c04753402e0b6472080f0c5d90a7a46.tar
yuzu-ea1ea0224c04753402e0b6472080f0c5d90a7a46.tar.gz
yuzu-ea1ea0224c04753402e0b6472080f0c5d90a7a46.tar.bz2
yuzu-ea1ea0224c04753402e0b6472080f0c5d90a7a46.tar.lz
yuzu-ea1ea0224c04753402e0b6472080f0c5d90a7a46.tar.xz
yuzu-ea1ea0224c04753402e0b6472080f0c5d90a7a46.tar.zst
yuzu-ea1ea0224c04753402e0b6472080f0c5d90a7a46.zip
Diffstat (limited to 'src/core/hw/aes/ccm.h')
-rw-r--r--src/core/hw/aes/ccm.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/core/hw/aes/ccm.h b/src/core/hw/aes/ccm.h
new file mode 100644
index 000000000..bf4146e80
--- /dev/null
+++ b/src/core/hw/aes/ccm.h
@@ -0,0 +1,40 @@
+// Copyright 2017 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <array>
+#include <cstddef>
+#include <vector>
+#include "common/common_types.h"
+
+namespace HW {
+namespace AES {
+
+constexpr size_t CCM_NONCE_SIZE = 12;
+constexpr size_t CCM_MAC_SIZE = 16;
+
+using CCMNonce = std::array<u8, CCM_NONCE_SIZE>;
+
+/**
+ * Encrypts and adds a MAC to the given data using AES-CCM algorithm.
+ * @param pdata The plain text data to encrypt
+ * @param nonce The nonce data to use for encryption
+ * @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);
+
+/**
+ * Decrypts and verify the MAC of the given data using AES-CCM algorithm.
+ * @param cipher The cipher text data to decrypt, with MAC at the end to verify
+ * @param nonce The nonce data to use for decryption
+ * @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,
+ size_t slot_id);
+
+} // namespace AES
+} // namespace HW