scute.texi 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. \input texinfo @c -*- Texinfo -*-
  2. @setfilename scute.info
  3. @settitle The Scute Manual
  4. @dircategory GNU Utilities
  5. @direntry
  6. * Scute: (scute). PKCS #11 module for the OpenPGP Card
  7. @end direntry
  8. @include version.texi
  9. @c Unify some of the indices.
  10. @syncodeindex tp fn
  11. @syncodeindex pg fn
  12. @ifinfo
  13. This file documents the Scute module.
  14. This is Edition @value{EDITION}, last updated @value{UPDATED}, of
  15. @cite{The Scute Manual}, for Version @value{VERSION}.
  16. @c NOTE: Don't forget to update the year for the TeX version, too.
  17. Copyright @copyright{} 2002, 2003, 2004, 2005, 2006, 2007 g10 Code GmbH.
  18. The Scute Manual is free software; you can redistribute it and/or modify
  19. it under the terms of the GNU General Public License as published by the
  20. Free Software Foundation; either version 2 of the License, or (at your
  21. option) any later version.
  22. The Scute Manual is distributed in the hope that it will be useful, but
  23. WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. General Public License for more details.
  26. You should have received a copy of the GNU Lesser General Public License
  27. along with this program; if not, write to the Free Software Foundation,
  28. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  29. @end ifinfo
  30. @iftex
  31. @shorttitlepage The Scute Manual
  32. @end iftex
  33. @titlepage
  34. @center @titlefont{The Scute Manual}
  35. @sp 6
  36. @center Edition @value{EDITION}
  37. @sp 1
  38. @center last updated @value{UPDATED}
  39. @sp 1
  40. @center for version @value{VERSION}
  41. @page
  42. @vskip 0pt plus 1filll
  43. Copyright @copyright{} 2002, 2003, 2004, 2005, 2006, 2007 g10 Code GmbH.
  44. The Scute Manual is free software; you can redistribute it and/or modify
  45. it under the terms of the GNU General Public License as published by the
  46. Free Software Foundation; either version 2 of the License, or (at your
  47. option) any later version.
  48. The Scute Manual is distributed in the hope that it will be useful, but
  49. WITHOUT ANY WARRANTY; without even the implied warranty of
  50. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  51. General Public License for more details.
  52. You should have received a copy of the GNU Lesser General Public License
  53. along with this program; if not, write to the Free Software Foundation,
  54. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  55. @end titlepage
  56. @page
  57. @ifnottex
  58. @node Top
  59. @top Main Menu
  60. This is Edition @value{EDITION}, last updated @value{UPDATED}, of
  61. @cite{The Scute Manual}, for Version @value{VERSION} of the Scute
  62. module.
  63. @end ifnottex
  64. @menu
  65. * Introduction:: How to use this manual.
  66. * Preparation:: What you should do before using Scute.
  67. * Client Authentication:: How to use Scute for client authentication.
  68. * Email Signing:: How to use Scute for S/MIME email signing.
  69. * Document Signing:: How to use Scute with LibreOffice.
  70. * Troubleshooting:: What to do when things go wrong.
  71. * Internals:: Technical details about Scute.
  72. Appendices
  73. * Copying:: The GNU General Public License says
  74. how you can copy and share Scute.
  75. Indices
  76. * Concept Index:: Index of concepts and programs.
  77. @detailmenu
  78. --- The Detailed Node Listing ---
  79. Introduction
  80. * Getting Started:: Purpose of the manual, and how to use it.
  81. * Features:: Reasons to install and use Scute.
  82. * Overview:: Basic architecture of the Scute module.
  83. Preparation
  84. * Prerequisites:: Dependencies of Scute.
  85. * Building the Source:: How to build Scute.
  86. * Certificate Preparation:: Preparing certificates for use with Scute.
  87. Client Authentication
  88. * Application Configuration:: Preparing the application for use with Scute.
  89. * Authentication With Service:: Using Scute for client authentication.
  90. Email Signing
  91. Document Signing
  92. Troubleshooting
  93. Internals
  94. * Features and Limitations:: Details about the interfaces implemented.
  95. * Developing Scute:: How to understand or improve Scute.
  96. * Mozilla Compatibility:: Interoperability notes for Mozilla NSS.
  97. @end detailmenu
  98. @end menu
  99. @node Introduction
  100. @chapter Introduction
  101. This is a PKCS #11 implementation for the GnuPG Agent using the GnuPG
  102. Smart Card Daemon. Currently, only the OpenPGP card is supported.
  103. Scute enables use of the OpenPGP smart card in applications supporting
  104. PKCS #11 compliant security tokens. The main application at this time
  105. is client authentication in Mozilla-based web browsers. In the future,
  106. other applications will be supported.
  107. @menu
  108. * Getting Started:: Purpose of the manual, and how to use it.
  109. * Features:: Reasons to install and use Scute.
  110. * Overview:: Basic architecture of the Scute module.
  111. @end menu
  112. @node Getting Started
  113. @section Getting Started
  114. This manual documents the Scute module, how it can be used for common
  115. applications supported by it, and how it can be extended and improved by
  116. programmers. It is thus a user manual as well as a developer manual.
  117. The reader is assumed to possess basic knowledge about cryptography in
  118. general, and public key cryptography in particular. The underlying
  119. cryptographic engines that are used by the library are not explained,
  120. but where necessary, special features or requirements are provided.
  121. This manual can be used in several ways. If read from the beginning to
  122. the end, it gives a good introduction into the module and how it can be
  123. used in an application. Forward references are included where
  124. necessary. Later on, the manual can be used as a reference manual to
  125. get just the information needed about any particular application of the
  126. module.
  127. @node Features
  128. @section Features
  129. Scute is currently the only implementation of PKCS #11 for the OpenPGP
  130. smart card. Apart from that, it offers a couple of other benefits:
  131. @table @asis
  132. @item it's free software
  133. Anybody can use, modify, and redistribute it under the terms of the GNU
  134. General Public License (@pxref{Copying}).
  135. @item it's built to grow
  136. Although Scute initially provided a single function, client
  137. authentication using OpenPGP smart cards in Mozilla-based web browsers,
  138. it was built with the intention of supporting other applications as well
  139. in the future.
  140. @item it's easy
  141. Building and installing Scute is easy, and preparing smart cards for use
  142. with Scute is a snatch using the GnuPG 2.0 framework. The integration
  143. of Scute into the application is seamless.
  144. @end table
  145. @node Overview
  146. @section Overview
  147. Scute is a security device that implements the PKCS #11 interface for
  148. security tokens. Applications which know how to use the PKCS #11
  149. interface to access security tokens for crytpographic operations can use
  150. Scute to access the OpenPGP smart card. An important example of such an
  151. application is the Firefox web browser by the Mozilla project, which
  152. uses the Mozilla Network Security Services library (NSS).
  153. Scute itself does not include a driver for the smart card itself.
  154. Instead, it uses the GnuPG 2.0 framework to access the smart cards and
  155. associated data like certificates. Scute acts as the glue between the
  156. application and GnuPG 2.0.
  157. Currently supported usages are client authentication over HTTPS with
  158. Firefox (allowing users to authenticate themselves to a remote web
  159. service without entering their log-in information), email signing
  160. with Thunderbird, and document signing with LibreOffice.
  161. @node Preparation
  162. @chapter Preparation
  163. To use Scute, you first have to install the software. You also have to
  164. prepare each card you want to use with Scute before it can be used.
  165. Furthermore, you need to configure the application to make use of Scute
  166. for cryptographic operations. This chapter explains each of these steps
  167. in detail.
  168. @menu
  169. * Prerequisites:: Dependencies of Scute.
  170. * Building the Source:: How to build Scute.
  171. * Certificate Preparation:: Preparing certificates for use with Scute.
  172. @end menu
  173. @node Prerequisites
  174. @section Prerequisites
  175. There are two types of dependencies for Scute: compile-time dependencies
  176. and run-time dependencies. The compile-time dependencies only need to
  177. be fulfilled when Scute is compiled and installed. The run-time
  178. dependencies need to be fulfilled when Scute is used in an application.
  179. Scute depends, in addition to the essential build utilities, on the
  180. following packages at build time:
  181. @table @code
  182. @item libgpg-error
  183. Scute uses the GnuPG 2.0 framework for error handling, so it depends on
  184. the GPG error library. The minimum version required is 1.14.
  185. @item libassuan
  186. Scute uses the GnuPG 2.0 framework for communication with the GPG Agent,
  187. so it depends on the Assuan library. The minimum version required is
  188. 2.0.0.
  189. @end table
  190. At run-time, in addition to the run-time versions of the above
  191. libraries, you also need the following packages installed and
  192. configured:
  193. @table @asis
  194. @item GnuPG
  195. Scute uses the GnuPG 2.0 framework to access the OpenPGP card and for
  196. certificate management. The minimum version required is 2.0.0.
  197. @item Pinentry
  198. Pinentry is a dependency of GnuPG 2.0, so it also needs to be installed
  199. with it.
  200. @item Firefox et al.
  201. Firefox is the first application supported by Scute. In the future,
  202. other applications may be supported. The applications are not
  203. dependencies of Scute, but Scute can not be used stand-alone, so you can
  204. not experience it without an application.
  205. @end table
  206. @node Building the Source
  207. @section Building the Source
  208. Scute does comply to the GNU coding standards and thus can be compiled
  209. and installed according to the generic installation instructions found
  210. in the source package in the file @code{INSTALL}. There are no Scute
  211. specific options to the configure script.
  212. After installation, the @code{scute.so} module file can be found in
  213. the library directory of the installation path.
  214. @node Certificate Preparation
  215. @section Certificate Preparation
  216. To use an OpenPGP card with Scute, it first has to be initialized by
  217. generating or loading a key on the card, see
  218. @uref{http://www.gnupg.org/(en)/howtos/card-howto/en/smartcard-howto.html,
  219. the OpenPGP Card How-To}. Then a certificate has to be created and
  220. imported into GPGSM. This task involves three steps: First, a
  221. certificate signing request (@acronym{CSR}) has to be created that
  222. matches the key on the card. This certificate signing request then has
  223. to be submitted to a certificate authority (@acronym{CA}), which will
  224. create the certificate and send it back to you. At last, the
  225. certificate has to be imported into GPGSM. This section will explain
  226. all of these steps in detail.
  227. Before you start, make sure that the GPG Agent is running, see
  228. @ref{Prerequisites}. There is no need to configure GPGSM, so you can
  229. create a CSR with the command:
  230. @example
  231. $ gpgsm --gen-key > floppy-head.csr
  232. Please select what kind of key you want:
  233. (1) RSA
  234. (2) Existing key
  235. (3) Existing key from card
  236. Your selection? 3
  237. @end example
  238. As we create a certificate for the OpenPGP Card, the option ``@code{[3]
  239. Direct from card}'' should be selected.
  240. @example
  241. Serial number of the card: 355F9746499F0D4B4ECEE4928B007D16
  242. Available keys:
  243. (1) D53137B94C38D9BF6A199706EA6D5253 OPENPGP.1
  244. (2) B0CD1A9DFC3539A1D6A8B851A11C8665 OPENPGP.2
  245. (3) 53DB41052CC590A40B403F3E6350E5DC OPENPGP.3
  246. Your selection? 3
  247. Possible actions for a RSA key:
  248. (1) sign, encrypt
  249. (2) sign
  250. (3) encrypt
  251. Your selection? 2
  252. @end example
  253. The only operation currently supported is client authentication. For
  254. this, the authentication key has to be selected. This is the third key
  255. on the card, so the options ``@code{[3] OPENPGP.3}'' and ``@code{[2]
  256. sign}'' should be chosen. Note that the key usage is only advisory, and
  257. the CA may assign different capabilities.
  258. @example
  259. Enter the X.509 subject name: CN=Floppy Head,OU="Webserver Team",O="Snake Oil, Ltd",L="Snake Town",ST="Snake Desert",C=XY
  260. Enter email addresses (end with an empty line):
  261. > floppy.head@@example.org
  262. >
  263. Enter DNS names (optional; end with an empty line):
  264. >
  265. Enter URIs (optional; end with an empty line):
  266. >
  267. Create self-signed certificate? (y/N) n
  268. @end example
  269. As a last step, the common name and e-mail address of the key owner need
  270. to be specified by you. The above are only an example for a fictious
  271. person working at a fictious company. DNS names are only meaningful for
  272. server certificates and thus should be left empty.
  273. We have now entered all required information and gpgsm will display what
  274. it has gathered and ask whether to create the certificate request:
  275. @example
  276. These parameters are used:
  277. Key-Type: card:OPENPGP.3
  278. Key-Length: 1024
  279. Key-Usage: sign
  280. Name-DN: CN=Floppy Head,OU="Webserver Team",O="Snake Oil, Ltd",L="Snake Town",ST="Snake Desert",C=XY
  281. Name-Email: floppy.head@@example.org
  282. Proceed with creation? (y/N) y
  283. Now creating certificate request. This may take a while ...
  284. gpgsm: about to sign the CSR for key: &53DB41052CC590A40B403F3E6350E5DC
  285. @end example
  286. GPGSM will now start working on creating the request. During this time
  287. you will be asked once for a passphrase to unprotect the authentication
  288. key on the card. A pop up window will appear to ask for it.
  289. When it is ready, you should see the final notice:
  290. @example
  291. gpgsm: certificate request created
  292. Ready. You should now send this request to your CA.
  293. @end example
  294. Now, you may look at the created request:
  295. @example
  296. $ cat floppy-head.csr
  297. -----BEGIN CERTIFICATE REQUEST-----
  298. MIICCDCCAXECAQAwgYExCzAJBgNVBAYTAlhZMRUwEwYDVQQIEwxTbmFrZSBEZXNl
  299. cnQxEzARBgNVBAcTClNuYWtlIFRvd24xFzAVBgNVBAoTDlNuYWtlIE9pbCwgTHRk
  300. MRcwFQYDVQQLEw5XZWJzZXJ2ZXIgVGVhbTEUMBIGA1UEAxMLRmxvcHB5IEhlYWQw
  301. gaAwDQYJKoZIhvcNAQEBBQADgY4AMIGKAoGBANWaM9YS89AOx3GX1Rua+4DUHwbL
  302. wt0rBYdBddlabMMteVjUcOOhbFMirLpLAi1S8fUXNiy84ysOmFStmvSIXDsAgXq5
  303. 1ESOU4SNg2zEkPDF1WYJ5BFIXdYq9i2k5W7+ctV8PkKv3e5IeYXTa5qppIPD31de
  304. gM8Qj7tK0hL/eNCfAgQAAQABoEUwQwYJKoZIhvcNAQkOMTYwNDAiBgNVHREEGzAZ
  305. gRdmbG9wcHkuaGVhZEBleGFtcGxlLmNvbTAOBgNVHQ8BAf8EBAMCBsAwDQYJKoZI
  306. hvcNAQEFBQADgYEAFC9q6+ib9YGCLB/2AlZR+/dvb+pEeXR1EbpV/dw/gjP1yPY6
  307. 29n8ZIDLUvQvNCtfCcXFxFimVSSB/KmFXXsJbM+NXQyT6Ocn34iHmkf9IVRMWQWg
  308. ZBYfQVeXAd7XlxI6d1wXDLwD/26lTU/rH2JU6H1+zSfZxqwVC4Iu+kiN4Y8=
  309. -----END CERTIFICATE REQUEST-----
  310. $
  311. @end example
  312. The next step is to submit this certificate request to the CA, which can
  313. then create a certificate and send it back to you.
  314. If, for example, you use the CA @uref{http://www.cacert.org, CAcert},
  315. then you can log into your account at the CAcert website, choose
  316. ``Client Certificates -> New'', check ``Show advanced options'', paste
  317. the above request block into the text field and click on ``Submit''.
  318. If everything works correctly, a certificate will be shown, which you
  319. can cut and paste into a new file @file{floppy-head.crt}.
  320. Alternatively if, for example, you set up your own CA with OpenSSL, then
  321. you can create your own certificate by issueing a command similar
  322. @code{openssl ca -in floppy-head.csr -cert snakeoil-ca-rsa.crt -keyfile
  323. snakeoil-ca-rsa.key -out floppy-head.crt}. Please see the OpenSSL
  324. documentation for more details on how to set up and administrate a
  325. certificate authority infrastructure.
  326. In any way you should end up with a certificate file
  327. @file{floppy-head.crt}, which you then have to import into GPGSM. It is
  328. also recommended that you import the root certificate of the CA first in
  329. the same fashion.
  330. @example
  331. $ gpgsm --import floppy-head.crt
  332. gpgsm: certificate imported
  333. gpgsm: total number processed: 1
  334. gpgsm: imported: 1
  335. @end example
  336. gpgsm tells you that it has imported the certificate. It is now
  337. associated with the key you used when creating the request. To see the
  338. content of your certificate, you may now enter:
  339. @example
  340. $ gpgsm -K Floppy
  341. /home/foo/.gnupg/pubring.kbx
  342. ---------------------------
  343. Serial number: 10
  344. Issuer: /CN=Snake Oil CA/OU=Certificate Authority/O=Snake Oil, Ltd/L=Snake Town/ST=Snake Desert/C=XY/EMail=ca@@snakeoil.dom
  345. Subject: /CN=Floppy Head/OU=Webserver Team/O=Snake Oil, Ltd/ST=Snake Desert/C=XY
  346. validity: 2006-11-11 14:09:12 through 2007-11-11 14:09:12
  347. key type: 1024 bit RSA
  348. fingerprint: EC:93:A2:55:C6:58:7F:C9:9E:96:DB:12:6E:64:99:54:BB:E1:94:68
  349. @end example
  350. The option ``@code{-K}'' is used above because this will only list
  351. certificates for which a private key is available. To see more details,
  352. you may use ``@code{--dump-secret-keys}'' instead of ``@code{-K}''.
  353. @node Client Authentication
  354. @chapter Client Authentication
  355. @menu
  356. * Application Configuration:: Preparing the application for use with Scute.
  357. * Authentication With Service:: Using Scute for client authentication.
  358. @end menu
  359. Scute allows you to authenticate yourself to a website securely without
  360. entering a username or password by simply using your OpenPGP card.
  361. Currently, only Mozilla-based browsers like Firefox are supported,
  362. although other applications using Mozilla NSS or supporting PKCS #11
  363. modules may work.
  364. @node Application Configuration
  365. @section Application Configuration
  366. To prepare your application for use with Scute, you have to load the
  367. Scute module as a PKCS #11 module into the application. With Firefox,
  368. this can be done by choosing @code{Edit->Preferences} in the menu. In
  369. the preferences configuration dialog, you should select the
  370. @code{Advanced} configuration section, then the @code{Security} tab, and
  371. then select @code{Security Devices} in the category @code{Certificates}.
  372. @center @image{firefox-pref,13cm}
  373. In the devices manager dialog, you can select @code{Load} to load a new
  374. PKCS #11 device.
  375. @center @image{firefox-dm-load-before,13cm}
  376. In the pop-up dialog that follows, you can give a module name
  377. (e.g. ``@code{Scute}'') and a module filename. The latter should
  378. correspond to the full file name of the installed Scute module file
  379. @file{scute.so}. The default installation path is
  380. @file{/usr/local/lib}, which would mean that you have to provide the
  381. file name @file{/usr/local/lib/scute.so}. If you or your system
  382. administrator installed Scute in a different location, you have to
  383. adjust the file name correspondingly.
  384. @center @image{firefox-dm-load,8cm}
  385. After confirming installation of the security device, a pop-up window
  386. should confirm that the module was successfully loaded, and an entry for
  387. the security device should appear in the device manager list of
  388. @code{Security Modules and Devices}.
  389. @center @image{firefox-dm-load-after,15cm}
  390. When you insert the OpenPGP card for which you generated and imported a
  391. certificate earlier (see @ref{Certificate Preparation}), the device
  392. manager should detect this security token and display some information
  393. about it in the @code{Details} list when you select it from the module
  394. list.
  395. @center @image{firefox-dm-token-present,15cm}
  396. The client certificate will show up in the @code{Certificate Manager}
  397. under @code{Your Certificates}:
  398. @center @image{firefox-cm,13cm}
  399. @node Authentication With Service
  400. @section Authentication With Service
  401. Before you access a web service which requires client authentication,
  402. for instance a fictious web service
  403. @ifnottex
  404. @indicateurl{https://example.com},
  405. @end ifnottex
  406. @iftex
  407. @code{https://example.com},
  408. @end iftex
  409. the OpenPGP card should be present. In this case, a pop-up window will
  410. appear that requests you to enter the PIN number protecting the
  411. authentication key on the OpenPGP card. After entering the PIN number,
  412. your browser will be authenticated to the server. If the server accepts
  413. your request and certificate, this is all which is required. You should
  414. leave the card in the reader as long as the connection persists.
  415. Depending on how aggressively GPG Agent caches your PIN number, you may
  416. have to enter the PIN number again later to keep up the connection to
  417. the server.
  418. If the card is not present, or you enter the wrong PIN, or the server
  419. does not admit your certificate, you will get an error message. This
  420. error message is generated by the application and Scute can not
  421. influence it. Unfortunately, in Firefox (at least up to version
  422. 38.5.0), this error message is not very user friendly. For example,
  423. entering a bad PIN results in the following generic error message, and
  424. the @code{Try Again} button does not work as expected:
  425. @center @image{firefox-bad-pin,11cm}
  426. @comment FIXME: Document possible error codes.
  427. @node Email Signing
  428. @chapter Email Signing
  429. Scute also allows you to use your card-based X.509 certificate to sign
  430. your emails with the S/MIME signature format. This has been tested
  431. with Mozilla Thunderbird only, but should work with any mail client
  432. with support for PKCS #11 (notably GNOME Evolution).
  433. You must first load the Scute module into your mail client. With
  434. Mozilla Thunderbird, the procedure is the same as the one described
  435. above for Mozilla Firefox.
  436. Then, open your accent configuration dialog (@code{Edit->Account
  437. Settings}), and in the @code{Security} tab, under the section
  438. @code{Digital Signing}, use the @code{Select...} button to associate
  439. your card-based certificate with your account.
  440. @center @image{thunderbird-account-settings,13cm}
  441. When writing a new message, you may then use the @code{S/MIME} button
  442. and select @code{Digitally sign this message} in the popup menu. You
  443. will be prompted for your User PIN before the message is sent.
  444. @center @image{thunderbird-smime-button,13cm}
  445. @node Document Signing
  446. @chapter Document Signing
  447. Scute can also be used with LibreOffice to sign OpenDocument files.
  448. First, you must load the Scute module into Mozilla Firefox according to
  449. the above procedure. Then, configure LibreOffice to use Firefox's
  450. certificate store by defining the @code{MOZILLA_CERTIFICATE_FOLDER}
  451. environment variable to your Firefox profile directory.
  452. Then, to sign the document you are editing, select the
  453. @code{File->Digital Signatures...} menu option to open the
  454. @code{Digital Signatures} dialog.
  455. @center @image{libreoffice-digital-signatures,13cm}
  456. Click the @code{Sign Document} button to open the certificate selection
  457. dialog. Select your card-based certificate, then validate. Enter your
  458. User PIN when prompted by GPG Agent.
  459. @center @image{libreoffice-certificate-selection,13cm}
  460. You may also sign a PDF export of your document. Select the
  461. @code{File->Export as PDF...} menu option to open the @code{PDF Options}
  462. dialog. In the @code{Digital Signatures} tab, use the @code{Select}
  463. button to open the certificate selection dialog as above. You will be
  464. prompted for your User PIN when you will click the @code{Export} button.
  465. @center @image{libreoffice-pdf-signature,13cm}
  466. @node Troubleshooting
  467. @chapter Troubleshooting
  468. @strong{Symptom:} Loading the Scute security device in the security
  469. device manager of Firefox fails with "Unable to load module".
  470. @strong{Solution:} Make sure that Scute is correctly installed, and that
  471. all libraries and executables are available. Make sure that the GPG
  472. Agent is running and can be found via the environment variable
  473. @code{GPG_AGENT_INFO}. @xref{Invoking GPG-AGENT, , , gnupg, Using the
  474. GNU Privacy Guard}, for details on how to run the GPG Agent.
  475. @strong{Symptom:} Client authentication fails with "<example.com> has
  476. received an incorrect or unexpected message. Error code: -12227".
  477. @strong{Solution:} Make sure that the correct OpenPGP card is inserted
  478. and the certificate available in GPGSM. Check that the OpenPGP card is
  479. detected correctly in the security device manager and the corresponding
  480. certificate is displayed in the certificate manager of Firefox.
  481. @xref{Authentication With Service}.
  482. @strong{Symptom:} The OpenPGP card is detected and displayed in the
  483. security device manager in Firefox, but no corresponding certificate is
  484. displayed in the certificate manager of Firefox.
  485. @strong{Solution:} Make sure that the corresponding certificate is
  486. imported in GPGSM.
  487. @comment FIXME: Can this really happen???
  488. @node Internals
  489. @chapter Internals
  490. The following notes are intended for people interested in more technical
  491. details about Scute and its implementation. They give an overview about
  492. its scope and potential compatibility issues with applications.
  493. @menu
  494. * Features and Limitations:: Details about the interfaces implemented.
  495. * Developing Scute:: How to understand or improve Scute.
  496. * Mozilla Compatibility:: Interoperability notes for Mozilla NSS.
  497. @end menu
  498. @node Features and Limitations
  499. @section Features and Limitations
  500. Scute implements version 2.20 of the
  501. @uref{http://www.rsasecurity.com/rsalabs/node.asp?id=2133, PKCS #11}
  502. specification.
  503. The @uref{http://www.g10code.com/p-card.html,OpenPGP smart card}
  504. application is supported in read-only mode.
  505. The following functions are not supported:
  506. @table @code
  507. @item C_Initialize
  508. No support for native thread package. Locking callbacks must be
  509. provided if multi-threaded operation is desired.
  510. @item C_WaitForSlotEvent
  511. Not implemented. The interface as specified by PKCS #11 is broken
  512. anyway, as the function can not safely be canceled. Thus, we require
  513. polling.
  514. @item C_GetOperationState
  515. @itemx C_SetOperationState
  516. Not supported.
  517. @item C_InitToken
  518. @itemx C_InitPIN
  519. @itemx C_SetPIN
  520. Not supported. No write operations are allowed. To configure the
  521. token, please use the tools accompanying the GnuPG software suite.
  522. @item C_Login
  523. @itemx C_Logout
  524. Not supported. No login into the token by the software is required.
  525. Passphrase queries are implemented by the use of GPG Agent and Pinentry.
  526. @item C_EncryptInit
  527. @itemx C_Encrypt
  528. @itemx C_EncryptUpdate
  529. @itemx C_EncryptFinal
  530. @itemx C_DigestInit
  531. @itemx C_Digest
  532. @itemx C_DigestUpdate
  533. @itemx C_DigestKey
  534. @itemx C_DigestFinal
  535. @itemx C_VerifyInit
  536. @itemx C_Verify
  537. @itemx C_VerifyUpdate
  538. @itemx C_VerifyFinal
  539. @itemx C_VerifyRecoverInit
  540. @itemx C_VerifyRec
  541. Not supported. Only secret key operations are supported.
  542. @item C_SignInit
  543. @itemx C_Sign
  544. Currently, only signing 36 bytes (MD5+SHA1) hashes is supported (used
  545. for client authentication).
  546. @item C_DecryptInit
  547. @itemx C_Decrypt
  548. Not yet supported, but will be in the future.
  549. @item C_SignUpdate
  550. @itemx C_SignFinal
  551. @itemx C_DecryptUpdate
  552. @itemx C_DecryptFinal
  553. No progressive crypto-operations are supported.
  554. @item C_SignRecoverInit
  555. @itemx C_SignRecover
  556. Not supported.
  557. @item C_DigestEncryptUpdate
  558. @itemx C_DecryptDigestUpdate
  559. @itemx C_SignEncryptUpdate
  560. @itemx C_DecryptVerifyUpdate
  561. Dual-purpose cryptographic functions are not supported.
  562. @item C_GenerateKey
  563. @itemx C_GenerateKeyPair
  564. @itemx C_WrapKey
  565. @itemx C_UnwrapKey
  566. @itemx C_DeriveKey
  567. Key management functions are not supported. Please use the tools
  568. accompanying the GnuPG software suite to generate and import keys for
  569. use with the token.
  570. @item C_SeedRandom
  571. @itemx C_GenerateRandom
  572. Not supported at this point. @code{C_GenerateRandom} may be supported
  573. in the future, though.
  574. @item C_CreateObject
  575. @itemx C_CopyObject
  576. @itemx C_DestroyObject
  577. @itemx C_SetAttributeValue:
  578. Only read-only operations are supported on objects.
  579. @item C_GetObjectSize
  580. Not supported.
  581. @item CKO_CERTIFICATE
  582. The label specifies the key on the card used (e.g. @code{OPENPGP.3}).
  583. The ID is the fingerprint.
  584. @item CKO_PRIVATE_KEY:
  585. The @code{CKA_LOCAL} attribute can not be supported by the OpenPGP card.
  586. It is always set to false (as the key on the card may be copied to the
  587. card from an external source).
  588. @end table
  589. @node Developing Scute
  590. @section Developing Scute
  591. Scute is single-threaded. There is a global lock that is taken in all
  592. entry points of Scute, except for @code{C_Initialize},
  593. @code{C_Finalize}, @code{C_GetFunctionList}, and stubs.
  594. Here are a couple of hints on how to develop PKCS #11 modules for
  595. Mozilla:
  596. @code{libopensc2} ships with a @code{pkcs11-spy} library that can be
  597. loaded as a wrapper around the PKCS #11 library you want to use to log
  598. all functions invoked by Mozilla. Here is how to use it:
  599. Set the @code{PKCS11SPY_OUTPUT} environment variable to a filename.
  600. @code{pkcs11-spy} appends its log messages at the end of this file. Set
  601. the @code{PKCS11SPY} environment variable to the filename of the PKCS
  602. #11 module you actually want to use. Start Mozilla within this
  603. environment.
  604. There is a different, probably more powerful way to debug Mozilla PKCS
  605. #11 libraries. However, to be able to use it, you need to configure and
  606. compile the Mozilla NSS sources with @code{--enable-debug}.
  607. Instructions can be found at:
  608. @uref{http://www.mozilla.org/projects/security/pki/nss/tech-notes/tn2.html}
  609. Here are a couple of links to more information about implementing a
  610. PKCS #11 module for Mozilla:
  611. @table @uref
  612. @item http://docs.sun.com/source/816-6150-10/index.htm
  613. @itemx http://docs.sun.com/source/816-6150-10/pkcs.htm
  614. Implementing PKCS #11 for the Netscape Security Library (Caution: The
  615. content may be out of date)
  616. @item http://www.mozilla.org/projects/security/pki/pkcs11/netscape/problems.html
  617. Common PKCS #11 Implementation Problems
  618. @item http://www.mozilla.org/projects/security/pki/pkcs11/
  619. PKCS #11 Conformance Testing
  620. @item http://www.mozilla.org/projects/security/pki/nss/
  621. The Mozilla NSS web page
  622. @end table
  623. @node Mozilla Compatibility
  624. @section Mozilla Compatibility
  625. Mozilla has a bug that causes the wrong security device to be unloaded
  626. when unloading a security device. Also, the displayed list becomes
  627. corrupt. When closing and reopening the security device manager, the
  628. list displayed is correct, but in anyway the wrong security module is
  629. unloaded.
  630. @include gpl.texi
  631. @node Concept Index
  632. @unnumbered Concept Index
  633. @printindex cp
  634. @summarycontents
  635. @contents
  636. @bye