RawBuffer tag;
unpack(token.data, pass, scheme, id, iv, tag);
- if (token.dataType.isKeyPrivate() || token.dataType.isKeyPublic())
+ if (token.dataType.isKeyPrivate())
return make<AKey>(scheme, std::move(id), Pwd(pass, iv, tag), token.dataType);
if (token.dataType.isSymmetricKey())
- return make<SKey>(scheme, std::move(id), Pwd(pass, iv, tag), token.dataType);
+ return make<SKey>(scheme, std::move(id), Pwd(pass, iv, tag));
if (token.dataType.isCertificate() || token.dataType.isChainCert())
return make<Cert>(scheme, std::move(id), Pwd(pass, iv, tag), token.dataType);
- if (token.dataType.isBinaryData()) {
- RawBuffer exported_data = Internals::getData(std::move(id), Pwd(pass, iv, tag));
- return make<BData>(std::move(exported_data));
- }
+ auto pwd = Pwd(pass, iv, tag);
+ RawBuffer raw = Internals::getData(id, pwd);
+
+ if (token.dataType.isKeyPublic())
+ return make<AKey>(scheme, std::move(id), std::move(pwd), token.dataType, std::move(raw));
+
+ if (token.dataType.isBinaryData())
+ return make<BData>(scheme, std::move(id), std::move(pwd), std::move(raw));
ThrowErr(Exc::Crypto::DataTypeNotSupported,
"This type of data is not supported by trustzone backend: ", token.dataType);
buffer.Deserialize(data);
}
- if (scheme & EncryptionScheme::PASSWORD && password.empty()) {
+ if ((scheme & EncryptionScheme::PASSWORD) && password.empty()) {
ThrowErr(Exc::Crypto::AuthenticationFailed,
"This token is protected with password and none passed");
} else if (!(scheme & EncryptionScheme::PASSWORD) && !password.empty()) {