Call TA to get the max chunk size
[platform/core/security/key-manager.git] / src / manager / crypto / tz-backend / internals.h
index 77b8c36..98171a5 100644 (file)
@@ -62,7 +62,7 @@ void importData(const Data &key,
                                         RawBuffer &tag,
                                         const RawBuffer &hash);
 
-void importWrappedKey(const RawBuffer &wrappingKey,
+void importWrappedKey(const RawBuffer &wrappingKeyId,
                                          const Pwd &wrappingKeyPwd,
                                          const CryptoAlgorithm &alg,
                                          const Data &encryptedKey,
@@ -71,63 +71,83 @@ void importWrappedKey(const RawBuffer &wrappingKey,
                                          RawBuffer &encryptedKeyTag,
                                          const RawBuffer &encryptedKeyId);
 
+RawBuffer exportWrappedKey(const RawBuffer &wrappingKeyId,
+                                                  const Pwd &wrappingKeyPwd,
+                                                  const CryptoAlgorithm &alg,
+                                                  const RawBuffer &keyToWrapId,
+                                                  const Pwd &keyToWrapPwd);
+
 RawBuffer getData(const RawBuffer &dataId,
                                  const Pwd &pwd);
 
 void destroyData(const RawBuffer &dataId);
 
-void destroyKey(const RawBuffer &key);
+void destroyKey(const RawBuffer &keyId);
 
 RawBuffer symmetricEncrypt(
-       const RawBuffer &key,
+       const RawBuffer &keyId,
        const Pwd &pwd,
        const CryptoAlgorithm &alg,
        const RawBuffer &data);
 
 RawBuffer symmetricDecrypt(
-       const RawBuffer &key,
+       const RawBuffer &keyId,
        const Pwd &pwd,
        const CryptoAlgorithm &alg,
        const RawBuffer &cipher);
 
 RawBuffer asymmetricEncrypt(
-       const RawBuffer &key,
+       const RawBuffer &keyId,
        const Pwd &pwd,
        const CryptoAlgorithm &alg,
        const RawBuffer &data);
 
 RawBuffer asymmetricDecrypt(
-       const RawBuffer &key,
+       const RawBuffer &keyId,
        const Pwd &pwd,
        const CryptoAlgorithm &alg,
        const RawBuffer &cipher);
 
-BufferPair encryptDataAesGcm(const RawBuffer &key,
+BufferPair encryptDataAesGcm(const RawBuffer &keyId,
                                                        const Pwd &pwd,
                                                        const RawBuffer &iv,
                                                        int tagSize,
                                                        const RawBuffer &data,
                                                        const RawBuffer &aad = RawBuffer());
 
-RawBuffer decryptDataAesGcm(const RawBuffer &key,
+RawBuffer decryptDataAesGcm(const RawBuffer &keyId,
                                                        const Pwd &pwd,
                                                        const RawBuffer &iv,
                                                        const RawBuffer &tag,
                                                        const RawBuffer &data,
                                                        const RawBuffer &aad = RawBuffer());
 
-RawBuffer sign(const RawBuffer &pkey,
+uint32_t initCipher(const RawBuffer &keyId,
+                                       const Pwd &pwd,
+                                       const CryptoAlgorithm &alg,
+                                       bool encrypt);
+
+void addAAD(uint32_t opId,
+                       const RawBuffer &aad);
+
+RawBuffer updateCipher(uint32_t opId,
+                                          const RawBuffer &data);
+
+RawBuffer finalizeCipher(uint32_t opId,
+                                                const RawBuffer &data);
+
+RawBuffer sign(const RawBuffer &pkeyId,
                        const Pwd &pwd,
                        const CryptoAlgorithm &alg,
                        const RawBuffer &message);
 
-int verify(const RawBuffer &pkey,
+int verify(const RawBuffer &pkeyId,
                const Pwd &pwd,
                const CryptoAlgorithm &alg,
                const RawBuffer &message,
                const RawBuffer &signature);
 
-void deriveECDH(const RawBuffer &prvKey,
+void deriveECDH(const RawBuffer &prvKeyId,
                                const Pwd &prvKeyPwd,
                                const RawBuffer &pubKey,
                                const Password &secretPwd,
@@ -135,12 +155,15 @@ void deriveECDH(const RawBuffer &prvKey,
                                RawBuffer &secretTag,
                                const RawBuffer &secretHash);
 
-void deriveKBKDF(const RawBuffer &secret,
+void deriveKBKDF(const RawBuffer &secretId,
+                                const Pwd &secretPwd,
                                 const CryptoAlgorithm &alg,
                                 const Password &keyPwd,
                                 const RawBuffer &keyPwdIV,
                                 RawBuffer &keyTag,
                                 const RawBuffer &keyHash);
+
+size_t maxChunkSize();
 } // namespace Internals
 } // namespace TZ
 } // namespace Crypto