(mozilla-projects-nss-ssl-functions-ssltyp)= # ssltyp ::::{container} :::{note} - This page is part of the {ref}`mozilla_projects_nss_ssl_functions_old_ssl_reference` that we are migrating into the format described in the [MDN Style Guide](https://developer.mozilla.org/en-US/docs/Project:MDC_style_guide). If you are inclined to help with this migration, your help would be very much appreciated. - Upgraded documentation may be found in the {ref}`mozilla_projects_nss_reference` ::: ```{rubric} Selected SSL Types and Structures :name: Selected_SSL_Types_and_Structures ``` :::: [Chapter 3](#chapter_3_selected_ssl_types_and_structures) Selected SSL Types and Structures ______________________________________________________________________ :::{container} This chapter describes some of the most important types and structures used with the functions described in the rest of this document, and how to manage the memory used for them. Additional types are described with the functions that use them or in the header files. [Types and Structures](#1030559) [Managing SECItem Memory](#1029645) ::: (types-and-structures)= ## [Types and Structures](#types_and_structures) :::{container} These types and structures are described here: `` `CERTCertDBHandle `` \<#1028465>\`\_\_ `` `CERTCertificate `` \<#1027387>\`\_\_ `` `PK11SlotInfo `` \<#1028593>\`\_\_ `` `SECItem `` \<#1026076>\`\_\_ `` `SECKEYPrivateKey `` \<#1026727>\`\_\_ `` `SECStatus `` \<#1026722>\`\_\_ Additional types used by a single function only are described with the function's entry in each chapter. Some of these functions also use types defined by NSPR and described in the [NSPR Reference](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR/Reference). \ ``` `typedef struct PK11SlotInfo`Str `PK11SlotInfo`; ```{rubric} SECItem :name: secitem ``` A structure that points to other structures. ```{rubric} Syntax ``` ```{code} #include #include #include ``` ```{code} typedef enum { siBuffer, siClearDataBuffer, siCipherDataBuffer, siDERCertBuffer, siEncodedCertBuffer, siDERNameBuffer, siEncodedNameBuffer, siAsciiNameString, siAsciiString, siDEROID } SECItemType; ``` ```{code} typedef struct SECItemStr SECItem; ``` ```{code} struct SECItemStr { SECItemType type; unsigned char *data; unsigned int len; }; ``` ```{rubric} Description ``` A `SECItem` structure can be used to associate your own data with an SSL socket. To free a structure pointed to by a `SECItem`, and, if desired, the `SECItem` structure itself, use one the functions `` `SECItem_FreeItem `` \<#1030620>\`\_\_ or `` `SECItem_ZfreeItem `` \<#1030773>\`\_\_. ```{rubric} SECKEYPrivateKey :name: seckeyprivatekey ``` An opaque, generic key structure. ```{rubric} Syntax ``` ```{code} #include ``` ```{code} typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey; ``` ```{rubric} Description ``` Key structures are not shared objects. When an application makes a copy of a particular key structure that already exists in memory, SSL makes a *deep* copy--that is, it makes a whole new copy of that object. When you call `` `SECKEY_DestroyPrivateKey `` \\`\_\_, the function both frees the memory and sets all the bits to zero. Never alter the contents of a key structure. Treat the structure as read only. ```{rubric} SECStatus :name: secstatus ``` The return value for many SSL functions. ```{rubric} Syntax ``` ```{code} #include ``` ```{code} typedef enum { SECWouldBlock = -2, SECFailure = -1, SECSuccess = 0 } SECStatus; ``` ```{rubric} Enumerators :name: enumerators ``` The enum includes the following enumerators: ```{eval-rst} +-------------------------------------------------+-------------------------------------------------+ | .. code:: | Reserved for internal use. | | | | | SECWouldBlock | | +-------------------------------------------------+-------------------------------------------------+ | .. code:: | The operation failed. To find out why, call | | | ``PR_GetError``. | | SECFailure | | +-------------------------------------------------+-------------------------------------------------+ | .. code:: | The operation succeeded. In this case the value | | | returned by ``PR_GetError`` is meaningless. | | SECSuccess | | +-------------------------------------------------+-------------------------------------------------+ ``` ::: (managing-secitem-memory)= ## [Managing SECItem Memory](#managing_secitem_memory) :::{container} These functions are available for managing the memory associated with `SECItem` structures and the structures to which they point. `` `SECItem_FreeItem `` \<#1030620>\`\_\_ `` `SECItem_ZfreeItem `` \<#1030773>\`\_\_ ```{rubric} SECItem_FreeItem :name: secitem_freeitem ``` Frees the memory associated with a `SECItem` structure. ```{rubric} Syntax ``` ```{code} #include ``` ```{code} SECStatus SECItem_FreeItem ( SECItem *item, PRBool freeItem) ``` ```{rubric} Parameter ``` This function has the following parameter: ```{eval-rst} +----------+--------------------------------------------------------------------------------------+ | ``item`` | A pointer to a ``SECItem`` structure. | +----------+--------------------------------------------------------------------------------------+ | freeItem | When ``PR_FALSE``, free only the structure pointed to. Otherwise, free both the | | | structure pointed to and the ``SECItem`` structure itself. | +----------+--------------------------------------------------------------------------------------+ ``` ```{rubric} Returns ``` The function returns one of these value`s`: - If successful, `SECSuccess`. - If unsuccessful, `SECFailure`. Use [PR_GetError](../../../../../nspr/reference/html/prerr.html#26127) to retrieve the error code. ```{rubric} Description ``` This function frees the memory associated with the structure to which the specified item points, when that structure is no longer used. When `freeItem` is not `PR_FALSE`, also frees the item structure itself. ```{rubric} SECItem_ZfreeItem :name: secitem_zfreeitem ``` Zeroes and frees the memory associated with a `SECItem` structure. ```{rubric} Syntax ``` ```{code} #include ``` ```{code} SECStatus SECItem_ZfreeItem ( SECItem *item, PRBool freeItem) ``` ```{rubric} Parameter ``` This function has the following parameter: ```{eval-rst} +----------+--------------------------------------------------------------------------------------+ | ``item`` | A pointer to a ``SECItem`` structure. | +----------+--------------------------------------------------------------------------------------+ | freeItem | When ``PR_FALSE``, free only the structure pointed to. Otherwise, free both the | | | structure pointed to and the ``SECItem`` structure itself. | +----------+--------------------------------------------------------------------------------------+ ``` ```{rubric} Returns ``` The function returns one of these value`s`: - If successful, `SECSuccess`. - If unsuccessful, `SECFailure`. Use [PR_GetError](../../../../../nspr/reference/html/prerr.html#26127) to retrieve the error code. ```{rubric} Description ``` This function is similar to `` `SECItem_FreeItem `` \<#1030620>\`\_\_, except that it overwrites the structures to be freed with zeroes before it frees them. Zeros and frees the memory associated with the structure to which the specified item points, when that structure is no longer used. When `freeItem` is not `PR_FALSE`, also zeroes and frees the item structure itself. :::