index.rst (2249B)
1 .. _mozilla_projects_nss_reference_nss_key_functions: 2 3 NSS Key Functions 4 ================= 5 6 .. container:: 7 8 This chapter describes two functions used to manipulate private keys and key databases such as 9 the key3.db database provided with NSS. This was converted from `"Chapter 6: Key 10 Functions" <https://developer.mozilla.org/en-US/docs/NSS/SSL_functions/sslkey.html>`__. 11 12 - :ref:`mozilla_projects_nss_reference` 13 - `SECKEY_GetDefaultKeyDB <#seckey_getdefaultkeydb>`__ 14 - `SECKEY_DestroyPrivateKey <#seckey_destroyprivatekey>`__ 15 16 .. rubric:: SECKEY_GetDefaultKeyDB 17 :name: seckey_getdefaultkeydb 18 19 Returns a handle to the default key database opened by NSS_Init. 20 21 Syntax 22 23 #. include <key.h> 24 #. include <keyt.h> 25 26 SECKEYKeyDBHandle \*SECKEY_GetDefaultKeyDB(void); 27 28 Returns The function returns a handle of type SECKEYKeyDBHandle. 29 30 Description NSS_Init opens the certificate, key, and security module databases that you specify 31 for use with NSS. SECKEYKeyDBHandle returns a handle to the key database opened by NSS_Init. 32 33 .. rubric:: SECKEY_DestroyPrivateKey 34 :name: seckey_destroyprivatekey 35 36 Destroys a private key structure. 37 38 Syntax 39 40 #. include <key.h> 41 #. include <keyt.h> 42 43 void SECKEY_DestroyPrivateKey(SECKEYPrivateKey \*key); 44 45 Parameter This function has the following parameter: 46 47 key 48 49 A pointer to the private key structure to destroy. 50 51 Description Certificate and key structures are shared objects. When an application makes a copy 52 of a particular certificate or key structure that already exists in memory, SSL makes a shallow 53 copy--that is, it increments the reference count for that object rather than making a whole new 54 copy. When you call CERT_DestroyCertificate or SECKEY_DestroyPrivateKey, the function decrements 55 the reference count and, if the reference count reaches zero as a result, both frees the memory 56 and sets all the bits to zero. The use of the word "destroy" in function names or in the 57 description of a function implies reference counting. 58 59 Never alter the contents of a certificate or key structure. If you attempt to do so, the change 60 affects all the shallow copies of that structure and can cause severe problems.