Export and Import Key in Cpp
The following code sample illustrates how to export and import key.
TEKey::importKey(keyArray, numOfPairs, results) answers one result per key pair, in order:
RESULT_IMPORTED (the caller owns the imported key), RESULT_DUPLICATE (this key server already
holds a key under that t-Tag, expired or not, and it was not overwritten), or the key server's error
code for a pair it refused. Each pair is applied on its own; the overload without results throws
when any pair is refused, after every other pair was applied. A NATIVE import needs the Import
Key operation (the Exchanger role) and an established trust with the exporting key server.
A key removed from a key server (TEKey::removeKey) is gone from that key server only: a copy
exported earlier is not reached, and importing it again restores the key. A key expired there
(TEKey::expireKey) keeps its record, so importing a copy of it answers RESULT_DUPLICATE and the
key stays expired.
Code Sample
See the C++ environment settings for details on setting the project environment.
cpp_export_import_key.cpp
The complete source for this sample, together with its console output, is published in the SDK reference and is the maintained copy: