TrustCore SDK NanoSSH API reference  version 7.0
Protocol-Specific Callbacks

Variables

sbyte4(* sshClientSettings::funcPtrReleaseNakedAuthKeys )(sbyte4 connectionInstance, ubyte **ppFreeKeyBlob)
 Release (free) memory allocated for authentication keys. More...
 
sbyte4(* sshClientSettings::funcPtrRetrieveNakedAuthKeys )(sbyte4 connectionInstance, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLength)
 Get a public/private key pair (naked key blob). More...
 
sbyte4(* sshClientSettings::funcPtrServerPubKeyAuth )(sbyte4 connectionInstance, const ubyte *pPubKey, ubyte4 pubKeyLength)
 Validate a public key. More...
 

Detailed Description

See also
General Purpose Callbacks

Variable Documentation

◆ funcPtrReleaseNakedAuthKeys

sbyte4(* sshClientSettings::funcPtrReleaseNakedAuthKeys) (sbyte4 connectionInstance, ubyte **ppFreeKeyBlob)

This callback function is invoked after a call to sshClientSettings::funcPtrRetrieveNakedKeys. It should release (free) the memory allocated for the public and private keys that were retrieved by the sshClientSettings::funcPtrRetrieveNakedKeys call.

Callback registration happens at session creation and initialization by assigning your custom callback function (which can have any name) to this callback pointer.

Since
2.02
Version
2.02 and later

There are no flag dependencies to enable this callback.

Parameters
connectionInstanceConnection instance returned from SSHC_connect().
ppFreeKeyBlobPointer to key blob (containing public/private key pair) to release (free).
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

sshc.h

◆ funcPtrRetrieveNakedAuthKeys

sbyte4(* sshClientSettings::funcPtrRetrieveNakedAuthKeys) (sbyte4 connectionInstance, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLength)

This callback function is invoked when NanoSSH client needs to authenticate itself to the SSH server using public key authentication; it should return the key blob containing the public and private keys from the public and private authorization key files, respectively. (Therefore, NanoSSH client must have access to the client's unique key.)

Callback registration happens at session creation and initialization by assigning your custom callback function (which can have any name) to this callback pointer.

Since
2.02
Version
2.02 and later

There are no flag dependencies to enable this callback.

Parameters
connectionInstanceConnection instance returned from SSHC_connect().
ppRetKeyBlobOn return, pointer to address of key blob (containing public/private key pair).
pRetKeyBlobLengthOn return, pointer to number of bytes in returned key blob (ppRetKeyBlob).
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

sshc.h

◆ funcPtrServerPubKeyAuth

sbyte4(* sshClientSettings::funcPtrServerPubKeyAuth) (sbyte4 connectionInstance, const ubyte *pPubKey, ubyte4 pubKeyLength)

This callback function is invoked during connection establishment; it should verify that the provided public key is on record, compare the provided and on-file keys, and return TRUE or FALSE to indicate whether the keys match. (If they match, the key is valid.)

Callback registration happens at session creation and initialization by assigning your custom callback function (which can have any name) to this callback pointer.

Since
1.41
Version
1.41 and later

There are no flag dependencies to enable this callback.

Parameters
connectionInstanceConnection instance returned from SSHC_connect().
pPubKeyPointer to public key to validate.

The public key (pubKeyLength) is a byte string representation of the keyblob, both version 1 and version 2 are supported:
  • Version 1, begins with a 12-byte header, with all bytes set to zero except the following:
  • header[7] contains the Mocana SoT Platform keyblob version (1)
  • header[11] contains the key type (any of the akt_* enumerated values defined in ca_mgmt.h)

    For DSA keys, the data following the header is:
  • 4 bytes length of p string
  • n bytes length of p byte string
  • 4 bytes length of q string
  • n bytes length of q byte string
  • 4 bytes length of g string
  • n bytes length of g byte string
  • 4 bytes length of y string
  • n bytes length of y byte string
  • 4 bytes length of x string
  • n bytes length of x byte string

    For RSA keys, the data following the header is:
  • 4 bytes length of e string
  • n bytes length of e byte string
  • 4 bytes length of n string
  • n bytes length of n byte string
  • 4 bytes length of p string
  • n bytes length of p byte string
  • 4 bytes length of q string
  • n bytes length of q byte string
  • 4 bytes length of private string #1
  • n bytes length of private byte string #1
  • 4 bytes length of private string #2
  • n bytes length of private byte string #2
  • 4 bytes length of private string #3
  • n bytes length of private byte string #3
  • 4 bytes length of private string #4
  • n bytes length of private byte string #4
  • 4 bytes length of private string #5
  • n bytes length of private byte string #5

    For ECC keys, the data following the header is:
  • 1 byte OID suffix identifying the curve
  • 4 bytes length of Point string
  • n bytes length of Point byte string (uncompressed X9-62 format)
  • 4 bytes length of Scalar string
  • n bytes length of Scalar byte string
    Version 2:
  • 4 bytes: all zeroes
  • 4 bytes: version number which must be 0x00000002
  • 4 bytes: key type which must be one of the KEYBLOB_TYPE enums
  • 4 bytes: OID type which must be one of the MAlgoOid enums
  • n bytes: ASN.1 encoded algorithm identifier
  • 4 bytes: reserved
  • n bytes: reserved
  • 4 bytes: key data length (keylen)
  • keylen bytes: key data (key data formats are mentioned above)
pubKeyLengthNumber of bytes in the public key (pPubKey).
Returns
TRUE (1) if the provided key matches the key on file; otherwise FALSE (0).

sshc.h