Implement public key extraction in TZ backend
[platform/core/security/key-manager.git] / src / manager / crypto / tz-backend / obj.cpp
index d743753..fa464f1 100644 (file)
@@ -66,7 +66,7 @@ Token BData::derive(const CryptoAlgorithm &alg, const Password &pass, const RawB
                iv = Internals::generateIV();
        }
 
-       Internals::deriveKBKDF(getBinary(), alg, pass, iv, tag, hash);
+       Internals::deriveKBKDF(getId(), alg, pass, iv, tag, hash);
 
        return Token(backendId(), DataType(KeyType::KEY_AES), Store::pack(hash, pass, iv, tag));
 }
@@ -88,7 +88,7 @@ Token Key::unwrap(const CryptoAlgorithm &params,
                passIV = Internals::generateIV();
        }
 
-       Internals::importWrappedKey(getBinary(),
+       Internals::importWrappedKey(getId(),
                                                                getPassword(),
                                                                params,
                                                                encryptedKey,
@@ -115,7 +115,7 @@ RawBuffer Key::wrap(const CryptoAlgorithm &alg,
                                  keyToWrapIV,
                                  keyToWrapTag);
 
-       return Internals::exportWrappedKey(getBinary(),
+       return Internals::exportWrappedKey(getId(),
                                                                           getPassword(),
                                                                           alg,
                                                                           keyToWrapId,
@@ -124,29 +124,29 @@ RawBuffer Key::wrap(const CryptoAlgorithm &alg,
 
 RawBuffer SKey::encrypt(const CryptoAlgorithm &alg, const RawBuffer &data)
 {
-    return Internals::symmetricEncrypt(getBinary(), getPassword(), alg, data);
+    return Internals::symmetricEncrypt(getId(), getPassword(), alg, data);
 }
 
 RawBuffer SKey::decrypt(const CryptoAlgorithm &alg, const RawBuffer &cipher)
 {
-    return Internals::symmetricDecrypt(getBinary(), getPassword(), alg, cipher);
+    return Internals::symmetricDecrypt(getId(), getPassword(), alg, cipher);
 }
 
 GCtxShPtr SKey::initContext(const CryptoAlgorithm &alg, bool onward)
 {
-       auto opId = Internals::initCipher(getBinary(), getPassword(), alg, onward);
+       auto opId = Internals::initCipher(getId(), getPassword(), alg, onward);
 
        return std::make_shared<CipherCtx>(opId);
 }
 
 RawBuffer AKey::encrypt(const CryptoAlgorithm &alg, const RawBuffer &data)
 {
-       return Internals::asymmetricEncrypt(getBinary(), getPassword(), alg, data);
+       return Internals::asymmetricEncrypt(getId(), getPassword(), alg, data);
 }
 
 RawBuffer AKey::decrypt(const CryptoAlgorithm &alg, const RawBuffer &cipher)
 {
-       return Internals::asymmetricDecrypt(getBinary(), getPassword(), alg, cipher);
+       return Internals::asymmetricDecrypt(getId(), getPassword(), alg, cipher);
 }
 
 Token AKey::derive(const CryptoAlgorithm &alg, const Password &pass, const RawBuffer &hash)
@@ -167,7 +167,7 @@ Token AKey::derive(const CryptoAlgorithm &alg, const Password &pass, const RawBu
                iv = Internals::generateIV();
        }
 
-       Internals::deriveECDH(getBinary(), getPassword(), pubKey, pass, iv, tag, hash);
+       Internals::deriveECDH(getId(), getPassword(), pubKey, pass, iv, tag, hash);
 
        return Token(backendId(), DataType::BINARY_DATA, Store::pack(hash, pass, iv, tag));
 }
@@ -183,7 +183,7 @@ RawBuffer AKey::sign(
 {
        CryptoAlgorithm algWithType(alg);
        algWithType.setParam(ParamName::ALGO_TYPE, key2algo(m_type));
-       return Internals::sign(getBinary(), getPassword(), algWithType, message);
+       return Internals::sign(getId(), getPassword(), algWithType, message);
 }
 
 int AKey::verify(const CryptoAlgorithm &alg, const RawBuffer &message,
@@ -197,7 +197,7 @@ int AKey::verify(const CryptoAlgorithm &alg, const RawBuffer &message,
                algWithType.setParam(ParamName::ALGO_TYPE, key2algo(m_type));
        }
 
-       return Internals::verify(getBinary(), getPassword(), algWithType, message, sign);
+       return Internals::verify(getId(), getPassword(), algWithType, message, sign);
 }
 
 Token Cert::unwrap(const CryptoAlgorithm &,