summaryrefslogtreecommitdiff
path: root/doc/rst/legacy/reference/fc_getinfo/index.rst
blob: 1b73f250825cef93bc0bb117d3dbb93c61b9dca0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
.. _mozilla_projects_nss_reference_fc_getinfo:

FC_GetInfo
==========

`Name <#name>`__
~~~~~~~~~~~~~~~~

.. container::

   FC_GetInfo - return general information about the PKCS #11 library.

`Syntax <#syntax>`__
~~~~~~~~~~~~~~~~~~~~

.. container::

   .. code::

      CK_RV  FC_GetInfo(CK_INFO_PTR pInfo);

`Parameters <#parameters>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. container::

   ``FC_GetInfo`` has one parameter:

   ``pInfo``
      points to a `CK_INFO </en-US/CK_INFO>`__ structure

`Description <#description>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. container::

   ``FC_GetInfo`` returns general information about the PKCS #11 library. On return, the ``CK_INFO``
   structure that ``pInfo`` points to has the following information:

   -  ``cryptokiVersion``: PKCS #11 interface version number implemented by the PKCS #11 library.
      The version is 2.20 (``major=0x02, minor=0x14``).
   -  ``manufacturerID``: the PKCS #11 library manufacturer, "Mozilla Foundation", padded with
      spaces to 32 characters and not null-terminated.
   -  ``flags``: should be 0.
   -  ``libraryDescription``: description of the library, "NSS Internal Crypto Services", padded
      with spaces to 32 characters and not null-terminated.
   -  ``libraryVersion``: PKCS #11 library version number, for example, 3.11
      (``major=0x03, minor=0x0b``).

   A user may call ``FC_GetInfo`` without logging into the token (to assume the NSS User role).

.. _return_value:

`Return value <#return_value>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. container::

   ``FC_GetInfo`` always returns ``CKR_OK``.

   .. note::

      ``FC_GetInfo`` should return ``CKR_ARGUMENTS_BAD`` if ``pInfo`` is ``NULL``.

      ``FC_GetInfo`` should return ``CKR_CRYPTOKI_NOT_INITIALIZED`` if the library is not
      initialized.

`Examples <#examples>`__
~~~~~~~~~~~~~~~~~~~~~~~~

.. container::

   Note the use of the ``%.32s`` format string to print the ``manufacturerID`` and
   ``libraryDescription`` members of the ``CK_INFO`` structure.

   .. code::

      #include <assert.h>
      #include <stdio.h>

      CK_FUNCTION_LIST_PTR pFunctionList;
      CK_RV crv;
      CK_INFO info;

      crv = FC_GetFunctionList(&pFunctionList);
      assert(crv == CKR_OK);

      ...

      /* invoke FC_GetInfo as pFunctionList->C_GetInfo */
      crv = pFunctionList->C_GetInfo(&info);
      assert(crv == CKR_OK);
      printf("General information about the PKCS #11 library:\n");
      printf("    PKCS #11 version: %d.%d\n",
          (int)info.cryptokiVersion.major, (int)info.cryptokiVersion.minor);
      printf("    manufacturer ID: %.32s\n", info.manufacturerID);
      printf("    flags: 0x%08lx\n", info.flags);
      printf("    library description: %.32s\n", info.libraryDescription);
      printf("    library version: %d.%d\n",
          (int)info.libraryVersion.major, (int)info.libraryVersion.minor);
      printf("\n");

.. _see_also:

`See also <#see_also>`__
~~~~~~~~~~~~~~~~~~~~~~~~

.. container::

   -  `NSC_GetInfo </en-US/NSC_GetInfo>`__