Thanks for developing this awesome crypto library.In C++ / Obj C, key generation for hybrid encryption and digital signature is not implemented.
Will it be supported before 1.2.0 final release?
On Saturday, July 14, 2018 at 1:28:28 PM UTC+5:30, Charles Lee II wrote:Tink 1.2.0-rc2 was released 2018-07-13.
--
You received this message because you are subscribed to the Google Groups "tink-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tink-users+...@googlegroups.com.
To post to this group, send email to tink-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tink-users/614a6e5d-dd13-4b25-be90-2f10f392593a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#include "tink/config/tink_config.h"
#include "tink/hybrid_key_templates.h"
#include "tink/keyset_handle.h"
using namespace crypto::tink;int main() {
auto status = TinkConfig::Register();
if (!status.ok()) {
std::cout << status.ToString() << std::endl;
exit(1);
}
auto new_keyset_handle_result = KeysetHandle::GenerateNew(HybridKeyTemplates::EciesP256HkdfHmacSha256Aes128Gcm());
if (!new_keyset_handle_result.ok()) {
std::cout << new_keyset_handle_result.status().ToString() << std::endl;
exit(1);
}
auto keyset_handle = std::move(new_keyset_handle_result.ValueOrDie());
}
To view this discussion on the web visit https://groups.google.com/d/msgid/tink-users/18f4330a-d8dc-4c17-9587-ef66b3ab64a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/tink-users/b5a2a715-937d-4d16-90e5-7b9f15c58dc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
auto private_keyset_handle = std::move(crypto::tink::KeysetHandle::GenerateNew(
crypto::tink::HybridKeyTemplates::EciesP256HkdfHmacSha256Aes128Gcm()).ValueOrDie());
auto private_keyset = crypto::tink::CleartextKeysetHandle::GetKeyset(*private_keyset_handle);
auto public_keyset = google::crypto::tink::Keyset();
public_keyset.set_primary_key_id(private_keyset.primary_key_id());
for (int i=0; i<private_keyset.key_size(); i++) {
auto private_key = google::crypto::tink::EciesAeadHkdfPrivateKey();
private_key.ParseFromString(private_keyset.key(i).key_data().value());
public_keyset.add_key();
auto public_key = public_keyset.mutable_key(i);
public_key->MergeFrom(private_keyset.key(i));
public_key->mutable_key_data()->set_value(private_key.public_key().SerializeAsString());
public_key->mutable_key_data()->set_key_material_type(
google::crypto::tink::KeyData_KeyMaterialType::KeyData_KeyMaterialType_ASYMMETRIC_PUBLIC);
public_key->mutable_key_data()->set_type_url(crypto::tink::EciesAeadHkdfPublicKeyManager::kKeyType);
}
auto public_keyset_handle = crypto::tink::KeysetUtil::GetKeysetHandle(public_keyset);
KeysetHandle privateKeysetHandle = KeysetHandle.generateNew(HybridKeyTemplates.ECIES_P256_HKDF_HMAC_SHA256_AES128_GCM);
KeysetHandle publicKeysetHandle = privateKeysetHandle.getPublicKeysetHandle();
Apart from this key generation for hybrid encryption and digital signature is now working.
Hi Thai,Thanks for update. Key generation works now.Just one suggestion. It is little bit complicated to get the public keyset from private keyset. See sample code below for generating public and private keyset for hybrid encryption in c++.auto private_keyset_handle = std::move(crypto::tink::KeysetHandle::GenerateNew(
crypto::tink::HybridKeyTemplates::EciesP256HkdfHmacSha256Aes128Gcm()).ValueOrDie());
auto private_keyset = crypto::tink::CleartextKeysetHandle::GetKeyset(*private_keyset_handle);
auto public_keyset = google::crypto::tink::Keyset();
public_keyset.set_primary_key_id(private_keyset.primary_key_id());
for (int i=0; i<private_keyset.key_size(); i++) {
auto private_key = google::crypto::tink::EciesAeadHkdfPrivateKey();
private_key.ParseFromString(private_keyset.key(i).key_data().value());
public_keyset.add_key();
auto public_key = public_keyset.mutable_key(i);
public_key->MergeFrom(private_keyset.key(i));
public_key->mutable_key_data()->set_value(private_key.public_key().SerializeAsString());
public_key->mutable_key_data()->set_key_material_type(
google::crypto::tink::KeyData_KeyMaterialType::KeyData_KeyMaterialType_ASYMMETRIC_PUBLIC);
public_key->mutable_key_data()->set_type_url(crypto::tink::EciesAeadHkdfPublicKeyManager::kKeyType);
}
auto public_keyset_handle = crypto::tink::KeysetUtil::GetKeysetHandle(public_keyset);It would be useful to have an API similar to Java.KeysetHandle privateKeysetHandle = KeysetHandle.generateNew(HybridKeyTemplates.ECIES_P256_HKDF_HMAC_SHA256_AES128_GCM);
KeysetHandle publicKeysetHandle = privateKeysetHandle.getPublicKeysetHandle();
To view this discussion on the web visit https://groups.google.com/d/msgid/tink-users/4b146915-95ee-4944-ab5c-666e992f390a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/tink-users/fb6fdefc-b614-4c9e-98c0-b4a7a033ecad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.