tech.pisoft.teagent.TEAgent
The TEAgent class is an abstract class containing the common cryptographic functions and the Key Service Agent settings.
Since: 1.0
© Pi Soft, 2018-2026 · Tricryption Engine 8.1
Inheritance
- Inherits tech.pisoft.teagent.IConnection
- Inherited by tech.pisoft.teagent.TEAgentFile
- Inherited by tech.pisoft.teagent.TEAgentMatrix
- Inherited by tech.pisoft.teagent.TEAgentResultSet
Static Public Attributes
| Type | Name | Description |
|---|---|---|
| final short | ENCRYPTION | The ENCRYPTION field is a constant value for the operation type. |
| final short | DECRYPTION | The DECRYPTION field is a constant value for the operation type. |
| final int | HMAC_SHA384_LEN | The length in bytes of an HMAC-SHA384 MAC. |
Public Member Functions
| Member | Description |
|---|---|
TEAgent() | The TEAgent constructor is the default constructor for the TEAgent class. |
TEAgent(TEAgentConnection conn) | The TEAgent constructor constructs a connection object with a connection. |
abstract void encrypt() | The encrypt method encrypts data. |
abstract void decrypt() | The decrypt method decrypts data. |
synchronized byte[] performHMacSha384(byte[] data, byte[] hiddenLink) | The performHMacSha384 method computes the keyed data hash: HMAC-SHA384 (RFC 2104 over SHA-384) of the data, computed by the Key Service under the raw bytes of the key the hidden link names; the key never leaves the Key Service. |
synchronized byte[] encryptBuffer(byte[] szData, byte[][] szHL) | The encryptBuffer method encrypts a buffer. |
synchronized byte[] decryptBuffer(byte[] szData, byte[] szHL) | The decryptBuffer method decrypts a buffer. |
synchronized void reset() | The reset method resets the status of a TEAgent object. |
Static Public Member Functions
| Member | Description |
|---|---|
String performHash(String strData, String strSalt) | The performHash method hashes data with SHA-256 (performHash v2). |
byte[] performHash(byte[] byteData, byte[] byteSalt) | The performHash method hashes data with SHA-256 (performHash v2). |
byte[] performHMacSha384(TEAgentConnection conn, byte[] data, byte[] hiddenLink) | The performHMacSha384 method computes the keyed data hash: HMAC-SHA384 (RFC 2104 over SHA-384) of the data, computed by the Key Service under the raw bytes of the key the hidden link names; the key never leaves the Key Service. |
synchronized byte[] encryptBuffer(TEAgentConnection conn, byte[] szData, byte[][] szHL) | The encryptBuffer method encrypts a buffer. |
synchronized byte[] encryptBuffer(TEAgentConnection conn, byte[] szData, byte[][] szHL, byte[] szIV, boolean bHLEncoded) | The encryptBuffer method encrypts a buffer. |
synchronized byte[] decryptBuffer(TEAgentConnection conn, byte[] szData, byte[] szHL) | The decryptBuffer method decrypts a buffer. |
synchronized byte[] decryptBuffer(TEAgentConnection conn, byte[] szData, byte[] szHL, byte[] szIV, boolean bHLEncoded) | The decryptBuffer method decrypts a buffer. |
byte[] encryptBuffer(TECipher algorithm, byte[] data) | The encryptBuffer method encrypts a buffer. |
byte[] decryptBuffer(TECipher algorithm, byte[] data) | The decryptBuffer method decrypts a buffer. |
Member Function Documentation
TEAgent()
The TEAgent constructor is the default constructor for the TEAgent class.
TEAgent(TEAgentConnection conn)
The TEAgent constructor constructs a connection object with a connection.
Parameters
| Parameter | Description |
|---|---|
conn | A TEAgentConnection object. |
abstract void encrypt()
The encrypt method encrypts data.
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException). |
abstract void decrypt()
The decrypt method decrypts data.
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException). |
synchronized byte[] performHMacSha384(byte[] data, byte[] hiddenLink)
The performHMacSha384 method computes the keyed data hash: HMAC-SHA384 (RFC 2104 over SHA-384) of the data, computed by the Key Service under the raw bytes of the key the hidden link names; the key never leaves the Key Service.
Parameters
| Parameter | Description |
|---|---|
data | A byte array representing the data to be MACed (may be empty). |
hiddenLink | A byte array representing the TTag of the key (raw, not Base64 encoded). |
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the hidden link is empty (refused locally, before any request), the request cannot be completed on the connection, or the Key Service refuses it (a TEServerException: no such key, the key's ACL, or no role granting HMAC Data). |
Returns: A byte array holding the 48-byte MAC.
synchronized byte[] encryptBuffer(byte[] szData, byte[][] szHL)
The encryptBuffer method encrypts a buffer.
Parameters
| Parameter | Description |
|---|---|
szData | A byte array representing data to be encrypted. |
szHL | A byte array representing a TTag. |
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException). |
Returns: A byte array representing the encrypted data.
synchronized byte[] decryptBuffer(byte[] szData, byte[] szHL)
The decryptBuffer method decrypts a buffer.
Parameters
| Parameter | Description |
|---|---|
szData | A byte array representing data to be encrypted. |
szHL | A byte array representing a TTag. |
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException). |
Returns: A byte array representing the decrypted buffer.
synchronized void reset()
The reset method resets the status of a TEAgent object.
String performHash(String strData, String strSalt)
The performHash method hashes data with SHA-256 (performHash v2).
v1 (SHA-1/MD5) outputs do not match v2 outputs; there is no compatibility mode. Note: performHash provides integrity/searchability, not strong pseudonymization of low-entropy data; for that, use a keyed construction (see the keyed-API roadmap note).
Parameters
| Parameter | Description |
|---|---|
strData | A string representing the data to be hashed. |
strSalt | A string representing the salt to be used for hashing. |
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException). |
Returns: A string representing the hashed data (Based 64 encoded).
byte[] performHash(byte[] byteData, byte[] byteSalt)
The performHash method hashes data with SHA-256 (performHash v2).
v1 (SHA-1/MD5) outputs do not match v2 outputs; there is no compatibility mode. Note: performHash provides integrity/searchability, not strong pseudonymization of low-entropy data; for that, use a keyed construction (see the keyed-API roadmap note).
Parameters
| Parameter | Description |
|---|---|
byteData | A byte array representing the data to be hashed. |
byteSalt | A byte array representing the salt to be used for hashing. |
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException). |
Returns: A byte array representing the hashed data (unencoded).
byte[] performHMacSha384(TEAgentConnection conn, byte[] data, byte[] hiddenLink)
The performHMacSha384 method computes the keyed data hash: HMAC-SHA384 (RFC 2104 over SHA-384) of the data, computed by the Key Service under the raw bytes of the key the hidden link names; the key never leaves the Key Service.
Parameters
| Parameter | Description |
|---|---|
conn | An authenticated TEAgentConnection object. |
data | A byte array representing the data to be MACed (may be empty). |
hiddenLink | A byte array representing the TTag of the key (raw, not Base64 encoded). |
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the hidden link is empty (refused locally, before any request), the request cannot be completed on the connection, or the Key Service refuses it (a TEServerException: no such key, the key's ACL, or no role granting HMAC Data). |
Returns: A byte array holding the 48-byte MAC.
synchronized byte[] encryptBuffer(TEAgentConnection conn, byte[] szData, byte[][] szHL)
The encryptBuffer method encrypts a buffer.
Parameters
| Parameter | Description |
|---|---|
conn | An TEAgentConnection object. |
szData | A byte array representing data to be encrypted. |
szHL | A byte array representing a TTag. |
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException). |
Returns: A byte array representing the encrypted data.
synchronized byte[] encryptBuffer(TEAgentConnection conn, byte[] szData, byte[][] szHL, byte[] szIV, boolean bHLEncoded)
The encryptBuffer method encrypts a buffer.
Parameters
| Parameter | Description |
|---|---|
conn | An TEAgentConnection object. |
szData | A byte array representing data to be encrypted. |
szHL | A byte array representing a TTag. |
szIV | A byte array representing the IV. |
bHLEncoded | A boolean representing whether or not the data is Base64 encoded. |
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException). |
Returns: A byte array representing the encrypted data.
synchronized byte[] decryptBuffer(TEAgentConnection conn, byte[] szData, byte[] szHL)
The decryptBuffer method decrypts a buffer.
Parameters
| Parameter | Description |
|---|---|
conn | An TEAgentConnection object. |
szData | A byte array representing data to be encrypted. |
szHL | A byte array representing a TTag. |
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException). |
Returns: A byte array representing the decrypted buffer.
synchronized byte[] decryptBuffer(TEAgentConnection conn, byte[] szData, byte[] szHL, byte[] szIV, boolean bHLEncoded)
The decryptBuffer method decrypts a buffer.
Parameters
| Parameter | Description |
|---|---|
conn | An TEAgentConnection object. |
szData | A byte array representing data to be encrypted. |
szHL | A byte array representing a TTag. |
szIV | A byte array representing the IV. |
bHLEncoded | A boolean representing whether or not the data is Base64 encoded. |
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException). |
Returns: A byte array representing the decrypted buffer.
byte[] encryptBuffer(TECipher algorithm, byte[] data)
The encryptBuffer method encrypts a buffer.
Parameters
| Parameter | Description |
|---|---|
algorithm | The encryption algorithm to use. AES_CBC_128, AES_CBC_192, AES_CBC_256 |
data | A byte array representing data to be encrypted. |
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException). |
Returns: Returns a string representing the encrypted data.
See also: TECipher, AES_CBC_128, AES_CBC_192, AES_CBC_256
byte[] decryptBuffer(TECipher algorithm, byte[] data)
The decryptBuffer method decrypts a buffer.
Parameters
| Parameter | Description |
|---|---|
algorithm | The encryption algorithm to use. AES_CBC_128, AES_CBC_192, AES_CBC_256 |
data | A byte array representing data to be decrypted. |
Exceptions
| Exception | Description |
|---|---|
TEAgentException | if the request cannot be completed on the connection, or the Key Service returns an error for it (delivered as a TEServerException). |
Returns: A byte array representing the decrypted buffer.
See also: TECipher, AES_CBC_128, AES_CBC_192, AES_CBC_256