### 3.5 Retrieving SPA Data ¶

This section describes the functions used for retrieving the various SPA data fields and parameters settings. They all return an FKO error code. The value of the respective field or parmeter that is being retrieved will placed into the variables whose addresses are passed to the function.

Function: `int` fko_get_spa_data `(fko_ctx_t ctx, char **spa_data);` ¶

  Assigns the pointer to the string holding the final encrypted SPA data to the address spa_data is pointing to. This is the data that would be packaged into a packet and sent to an fwknop server. The return value is an FKO error status.

Function: `int` fko_get_rand_value `(fko_ctx_t ctx, char **rand_val);` ¶

  Assigns the pointer to the string holding the random 16-character decimal number (`rand_val`) associated with the current context to the address rand_val is pointing to. The return value is an FKO error status.

Function: `int` fko_get_username `(fko_ctx_t ctx, char **username);` ¶

  Assigns the pointer to the string holding the username associated with the current context to the address rand_val is pointing to. The return value is an FKO error status.

Function: `int` fko_get_timestamp `(fko_ctx_t ctx, time_t *timestamp);` ¶

  Sets the value of the timestamp variable to the timestamp value associated with the current context. The return value is an FKO error status.

Function: `int` fko_get_spa_message_type `(fko_ctx_t ctx, short *msg_type);` ¶

  Sets the value of the msg_type variable to the SPA message type value associated with the current context. This value can be checked against the list of valid message_types listed in SPA Messages of this manual. For example:

          short msg_type;

          rc = fko_get_spa_message_type(ctx, &msg_type);

          switch(msg_type)
          {
              case FKO_ACCESS_MSG:
                  process_access_msg(...);
                  break;
              case FKO_NAT_ACCESS_MSG:
                  process_nat_access_msg(...);
                  break;
          /*...and so on...*/
          }

  The return value is an FKO error status.

Function: `int` fko_get_spa_message `(fko_ctx_t ctx, char **spa_msg);` ¶

  Assigns the pointer to the string holding the the fko SPA request message associated with the current context to the address spa_msg is pointing to. The return value is an FKO error status.

Function: `int` fko_get_spa_nat_access `(fko_ctx_t ctx, char **nat_access);` ¶

  Assigns the pointer to the string holding the the fko SPA nat access message associated with the current context to the address nat_access is pointing to. The return value is an FKO error status.

Function: `int` fko_get_spa_server_auth `(fko_ctx_t ctx, char **server_auth);` ¶

  Assigns the pointer to the string holding the the fko SPA server auth message associated with the current context to the address server_auth is pointing to. The return value is an FKO error status.

Function: `int` fko_get_spa_client_timeout `(fko_ctx_t ctx, int *client_timeout);` ¶

  Sets the value of the client_timeout variable to the client_timeout value associated with the current context. The return value is an FKO error status.

Function: `int` fko_get_spa_digest_type `(fko_ctx_t ctx, short *digest_type);` ¶

  Sets the value of the digest_type variable to the digest type value associated with the current context. This value can be checked against the list of valid digest_types listed in Digests of this manual. The return value is an FKO error status.

Function: `int` fko_get_spa_hmac_type `(fko_ctx_t ctx, short *hmac_type);` ¶

  Sets the value of the hmac_type variable to the HMAC type value associated with the current context. This value can be checked against the list of valid hmac_types listed in HMAC Digests of this manual. The return value is an FKO error status.

Function: `int` fko_get_spa_digest `(fko_ctx_t ctx, char **spa_digest);` ¶

  Assigns the pointer to the string holding the the fko SPA digest value associated with the current context to the address spa_digest is pointing to. The return value is an FKO error status.

Function: `int` fko_get_spa_hmac `(fko_ctx_t ctx, char **spa_hmac);` ¶

  Assigns the pointer to the string holding the the fko SPA HMAC value associated with the current context to the address spa_hmac is pointing to. The return value is an FKO error status.

Function: `int` fko_get_spa_encryption_type `(fko_ctx_t ctx, short *enc_type);` ¶

  Sets the value of the enc_type variable to the encryption type value associated with the current context. This value can be checked against the list of valid digest_types listed in Encryption Algorithms of this manual. The return value is an FKO error status.

Function: `int` fko_get_encoded_data `(fko_ctx_t ctx, char **enc_msg);` ¶

  Assigns the pointer to the string holding the the encoded SPA data (before encryption) associated with the current context to the address enc_msg is pointing to. This is intermediate data that would not normally be of use unless debugging the library. The return value is an FKO error status.

Function: `int` fko_get_version `(fko_ctx_t ctx, char **fko_version);` ¶

  Assigns the pointer to the string holding the the SPA version value associated with the current context to the address fko_version is pointing to. This is a static value for SPA data that is being created in a new context. For data parsed from an external source, the version string will be whatever version the sending client used. The return value is an FKO error status.

GPG-specific functions:

Function: `int` fko_get_gpg_recipient `(fko_ctx_t ctx, char **recipient);` ¶

  Assigns the pointer to the string holding the the GPG recipient ID associated with the current context to the address recipient is pointing to. The return value is an FKO error status.

Function: `int` fko_get_gpg_signer `(fko_ctx_t ctx, char **signer);` ¶

  Assigns the pointer to the string holding the the GPG signer ID associated with the current context to the address signer is pointing to. The return value is an FKO error status.

Function: `int` fko_get_gpg_home_dir `(fko_ctx_t ctx, char **gpg_dir);` ¶

  Assigns the pointer to the string holding the the GPG home directory associated with the current context to the address gpg_dir is pointing to. The return value is an FKO error status.

Function: `int` fko_get_gpg_signature_verify `(fko_ctx_t ctx, unsigned char *val);` ¶

  Sets the value of the val variable to the current gpg_signature_verify flag value associated with the current context. The return value is an FKO error status.

Function: `int` fko_get_gpg_ignore_verify_error `(fko_ctx_t ctx, unsigned char *val);` ¶

  Sets the value of the val variable to the current ignore_verify_error flag value associated with the current context. The return value is an FKO error status.

Function: `int` fko_get_gpg_signature_id `(fko_ctx_t ctx, char **sig_id);` ¶

  Assigns the pointer to the string holding the the GPG signature ID associated with the current context to the address sig_id is pointing to. The return value is an FKO error status.

Function: `int` fko_get_gpg_signature_fpr `(fko_ctx_t ctx, char **sig_fpr);` ¶

  Assigns the pointer to the string holding the the GPG signature fingerprint associated with the current context to the address sig_fpr is pointing to. The return value is an FKO error status.

Function: `int` fko_get_gpg_signature_summary `(fko_ctx_t ctx, int *sig_sum);` ¶

  Sets the value of the sig_sum variable to the GPG signature summary value associated with the current context. The return value is an FKO error status.

Function: `int` fko_get_gpg_signature_status `(fko_ctx_t ctx, int *sig_stat);` ¶

  Sets the value of the sig_stat variable to the GPG signature error status value associated with the current context. The return value is an FKO error status.

Function: `int` fko_get_gpg_exe `(fko_ctx_t ctx, char **gpg_exe);` ¶

  Assigns the pointer to the string holding the the GPG executable path associated with the current context to the address gpg_exe is pointing to. The return value is an FKO error status.

Note: The char* values retrieved by the GPG-related functions above will be NULL if the context value was not previously set.