Skip to main content

tech.pisoft.teagent.TEKey

The TEKey class provides operations for creating, exporting and importing keys.

Since: 6.2.0

© Pi Soft, 2018-2026 · Tricryption Engine 8.1

Inheritance​

Static Public Attributes​

TypeNameDescription
intKEY_FORMAT_NATIVEAn integer representing Native format.
intKEY_FORMAT_RAWAn integer representing RAW format.
intKEY_FORMAT_WRAPPEDAn integer representing WRAPPED format: a key wrapped to the key server's RSA trust certificate, by rsa-oaep-sha256 or rsa-aes-kwp-sha256.
final intRESULT_EXPIREDPer-key result of expireKey: the key is now expired.
final intRESULT_ALREADY_EXPIREDPer-key result of expireKey: the key was already expired; nothing changed.
final intRESULT_REMOVEDPer-key result of removeKey: the key, its access control list and every cached copy are deleted.
final intRESULT_IMPORTEDPer-key result of importKey: the key is imported and the caller is its owner.
final intRESULT_DUPLICATEPer-key result of importKey: a key with that hidden link exists (expired or not); it was not overwritten.
final intCODE_BAD_HIDDEN_LINKThe key server's refusal of a malformed (empty or too short) hidden link.
final intCODE_NO_SUCH_KEYThe key server's refusal of a hidden link that names no key (never created, or removed).
final intCODE_KEY_EXPIREDThe key server's refusal of any use of an expired key, on every key server of the deployment.

Static Public Member Functions​

MemberDescription
byte[] rawKeyBlob(String cipher, byte[] key, byte[] iv)The RAW (3) key blob: the key server's export form – the cipher's NID (4 bytes, big-endian), the key, then the IV or none (the key server mints it).
byte[] wrappedKeyBlob(String method, String cipher, byte[] wrapped, byte[] iv)The WRAPPED (4) key blob: version 1, the method, the cipher's NID (big-endian), the IV length and IV, then the wrapped key material, passed through unread.

Public Member Functions​

MemberDescription
TEKey()The TEKey constructor is the default constructor.
void exportKey(String trustedServerName, Vector< TEKey.KeyPair > keys)The exportKey Method is for exporting encryption keys in a vector of KeyPair objects for given trusted key server.
int[] importKey(Vector< TEKey.KeyPair > keys, int type)The importKey Method is for importing encryption keys.
String createKey(String aclTemplateName)The createKey method creates a new key with given ACL template name.
int[] expireKey(Collection< String > hls)Expire keys.
int[] removeKey(Collection< String > hls)Remove keys: each key's access control list, its stored key and every cached copy are deleted, on every key server of the deployment.

Member Function Documentation​

byte[] rawKeyBlob(String cipher, byte[] key, byte[] iv)​

The RAW (3) key blob: the key server's export form – the cipher's NID (4 bytes, big-endian), the key, then the IV or none (the key server mints it).

Parameters

ParameterDescription
cipherAES-128-CBC, AES-192-CBC or AES-256-CBC
keythe key bytes, the cipher's key length. KEY MATERIAL: the blob IS the key.
ivthe cipher's IV length, or null

Returns: the blob for importKey(keys, KEY_FORMAT_RAW)

byte[] wrappedKeyBlob(String method, String cipher, byte[] wrapped, byte[] iv)​

The WRAPPED (4) key blob: version 1, the method, the cipher's NID (big-endian), the IV length and IV, then the wrapped key material, passed through unread.

Parameters

ParameterDescription
method"rsa-oaep-sha256" (RSA-OAEP, SHA-256, MGF1-SHA-256, of the key bytes) or "rsa-aes-kwp-sha256" (RSA-OAEP-SHA256 of a one-time AES-256 key, then that key's RFC 5649 wrap of the key bytes), both to the key server's trust certificate
cipherAES-128-CBC, AES-192-CBC or AES-256-CBC
wrappedthe wrapped key material
ivthe cipher's IV length, or null for the key server to mint

Returns: the blob for importKey(keys, KEY_FORMAT_WRAPPED)

TEKey()​

The TEKey constructor is the default constructor.

void exportKey(String trustedServerName, Vector< TEKey.KeyPair > keys)​

The exportKey Method is for exporting encryption keys in a vector of KeyPair objects for given trusted key server.

Parameters

ParameterDescription
trustedServerNameA string representing the trusted server's friendly name.
keysVector of KeyPair objects. Input with TTag and output with encrypted key blobs. Try: Vector<TEKey.KeyPair> keys = new Vector<TEKey.KeyPair>()

Exceptions

ExceptionDescription
TEAgentExceptionif the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException).

int[] importKey(Vector< TEKey.KeyPair > keys, int type)​

The importKey Method is for importing encryption keys.

Parameters

ParameterDescription
keysVector of KeyPair objects. Input with TTag and encrypted key blobs. Try: Vector<TEKey.KeyPair> keys = new Vector<TEKey.KeyPair>()
typeKEY_FORMAT_NATIVE (0) – key blobs exported by a key server this one has an established trust with, needing the "Import Key" operation (the Exchanger role) – or KEY_FORMAT_RAW (3), raw keys (rawKeyBlob) under hidden links this key server mints and writes back into each KeyPair whose link is empty – or KEY_FORMAT_WRAPPED (4), keys wrapped to this key server's RSA trust certificate (wrappedKeyBlob), the same links. A non-empty link is the caller's identifier, kept as given; a refused key's link comes back empty. Any other type is refused with IllegalArgumentException.

Exceptions

ExceptionDescription
TEAgentExceptionif the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException) – a request naming ONE pair that is refused is answered as an error.

Returns: one result per pair, in order: RESULT_IMPORTED (the caller owns the key), RESULT_DUPLICATE (a key with that hidden link exists, expired or not, and was not overwritten), or the key server's error code for that pair's refusal. Each pair is applied independently. An empty array for a null vector.

String createKey(String aclTemplateName)​

The createKey method creates a new key with given ACL template name.

Parameters

ParameterDescription
aclTemplateNameA string representing the ACL template name.

Exceptions

ExceptionDescription
TEAgentExceptionif the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException).

Returns: Base64 encoded string of TTag

int[] expireKey(Collection< String > hls)​

Expire keys.

An expired key keeps its record and its access control list (readable, its expiration flag set), and every later use of it – decrypt, encrypt under its hidden link, export, an access-control update – is refused with CODE_KEY_EXPIRED (0x0406), on every key server of the deployment. An expiry is never undone; to delete a key use removeKey. Needs the "Expire Key" operation (the Encryptor role) and the OWNER right on each key.

Parameters

ParameterDescription
hlscollection of Hidden Links, canonical base64

Exceptions

ExceptionDescription
TEAgentExceptionif the request cannot be completed on the connection, or the Key Service refuses it – a request naming ONE key that is refused is answered as an error.

Returns: one result per hidden link, in iteration order: RESULT_EXPIRED, RESULT_ALREADY_EXPIRED, or the key server's error code for that key's refusal. Each key is applied independently; one refused key neither stops nor undoes the others.

int[] removeKey(Collection< String > hls)​

Remove keys: each key's access control list, its stored key and every cached copy are deleted, on every key server of the deployment.

Irreversible on this key server, and local to it: a copy exported earlier (exportKey) can be imported again (importKey). An expired key may still be removed by its owner. Same rights as expireKey.

Parameters

ParameterDescription
hlscollection of Hidden Links, canonical base64

Exceptions

ExceptionDescription
TEAgentExceptionas expireKey

Returns: one result per hidden link, in iteration order: RESULT_REMOVED or the key server's error code for that key's refusal.