PageRenderTime 80ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/libgcrypt/libgcrypt-1.2.2/doc/gcrypt.info

https://bitbucket.org/lkalif/emerald-snowglobe
Unknown | 4698 lines | 3737 code | 961 blank | 0 comment | 0 complexity | 20c855858e53f0cbed0617a6e61e1af9 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-2.0, BSD-3-Clause, GPL-2.0
  1. This is gcrypt.info, produced by makeinfo version 4.7 from gcrypt.texi.
  2. This manual is for Libgcrypt (version 1.2.2, 29 July 2005), which is
  3. GNU's library of cryptographic building blocks.
  4. Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this
  6. document under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the
  8. License, or (at your option) any later version. The text of the
  9. license can be found in the section entitled "Copying".
  10. INFO-DIR-SECTION GNU Libraries
  11. START-INFO-DIR-ENTRY
  12. * libgcrypt: (gcrypt). Cryptographic function library.
  13. END-INFO-DIR-ENTRY
  14. 
  15. File: gcrypt.info, Node: Top, Next: Introduction, Up: (dir)
  16. The Libgcrypt Library
  17. *********************
  18. This manual is for Libgcrypt (version 1.2.2, 29 July 2005), which is
  19. GNU's library of cryptographic building blocks.
  20. Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
  21. Permission is granted to copy, distribute and/or modify this
  22. document under the terms of the GNU General Public License as
  23. published by the Free Software Foundation; either version 2 of the
  24. License, or (at your option) any later version. The text of the
  25. license can be found in the section entitled "Copying".
  26. * Menu:
  27. * Introduction:: What is Libgcrypt.
  28. * Preparation:: What you should do before using the library.
  29. * Generalities:: General library functions and data types.
  30. * Handler Functions:: Working with handler functions.
  31. * Symmetric cryptography:: How to use symmetric cryptography.
  32. * Hashing:: How to use hashing.
  33. * Public Key cryptography (I):: How to use public key cryptography.
  34. * Public Key cryptography (II):: How to use public key cryptography, alternatively.
  35. * Random Numbers:: How to work with random numbers.
  36. * S-expressions:: How to manage S-expressions.
  37. * MPI library:: How to work with multi-precision-integers.
  38. * Utilities:: Utility functions.
  39. Appendices
  40. * Library Copying:: The GNU Lesser General Public License
  41. says how you can copy and share `Libgcrypt'.
  42. * Copying:: The GNU General Public License says how you
  43. can copy and share some parts of `Libgcrypt'.
  44. Indices
  45. * Concept Index:: Index of concepts and programs.
  46. * Function and Data Index:: Index of functions, variables and data types.
  47. --- The Detailed Node Listing ---
  48. Introduction
  49. * Getting Started:: How to use this manual.
  50. * Features:: A glance at Libgcrypt's features.
  51. * Overview:: Overview about the library.
  52. Preparation
  53. * Header:: What header file you need to include.
  54. * Building sources:: How to build sources using the library.
  55. * Building sources using Automake:: How to build sources with the help of Automake.
  56. * Initializing the library:: How to initialize the library.
  57. * Multi Threading:: How Libgcrypt can be used in a MT environment.
  58. Generalities
  59. * Controlling the library:: Controlling Libgcrypt's behavior.
  60. * Modules:: Description of extension modules.
  61. * Error Handling:: Error codes and such.
  62. Handler Functions
  63. * Progress handler:: Using a progress handler function.
  64. * Allocation handler:: Using special memory allocation functions.
  65. * Error handler:: Using error handler functions.
  66. * Logging handler:: Using a special logging function.
  67. Symmetric cryptography
  68. * Available ciphers:: List of ciphers supported by the library.
  69. * Cipher modules:: How to work with cipher modules.
  70. * Available cipher modes:: List of cipher modes supported by the library.
  71. * Working with cipher handles:: How to perform operations related to cipher handles.
  72. * General cipher functions:: General cipher functions independent of cipher handles.
  73. Hashing
  74. * Available hash algorithms:: List of hash algorithms supported by the library.
  75. * Hash algorithm modules:: How to work with hash algorithm modules.
  76. * Working with hash algorithms:: List of functions related to hashing.
  77. Public Key cryptography (I)
  78. * Used S-expressions:: Introduction into the used S-expression.
  79. * Available algorithms:: Algorithms supported by the library.
  80. * Public key modules:: How to work with public key modules.
  81. * Cryptographic Functions:: Functions for performing the cryptographic actions.
  82. * General public-key related Functions:: General functions, not implementing any cryptography.
  83. Public Key cryptography (II)
  84. * Available asymmetric algorithms:: List of algorithms supported by the library.
  85. * Working with sets of data:: How to work with sets of data.
  86. * Working with handles:: How to use handles.
  87. * Working with keys:: How to work with keys.
  88. * Using cryptographic functions:: How to perform cryptographic operations.
  89. * Handle-independent functions:: General functions independent of handles.
  90. Random Numbers
  91. * Quality of random numbers:: Libgcrypt uses different quality levels.
  92. * Retrieving random numbers:: How to retrieve random numbers.
  93. S-expressions
  94. * Data types for S-expressions:: Data types related with S-expressions.
  95. * Working with S-expressions:: How to work with S-expressions.
  96. MPI library
  97. * Data types:: MPI related data types.
  98. * Basic functions:: First steps with MPI numbers.
  99. * MPI formats:: External representation of MPIs.
  100. * Calculations:: Performing MPI calculations.
  101. * Comparisons:: How to compare MPI values.
  102. * Bit manipulations:: How to access single bits of MPI values.
  103. * Miscellaneous:: Miscellaneous MPI functions.
  104. Utilities
  105. * Memory allocation:: Functions related with memory allocation.
  106. 
  107. File: gcrypt.info, Node: Introduction, Next: Preparation, Prev: Top, Up: Top
  108. 1 Introduction
  109. **************
  110. `Libgcrypt' is a library providing cryptographic building blocks.
  111. * Menu:
  112. * Getting Started:: How to use this manual.
  113. * Features:: A glance at Libgcrypt's features.
  114. * Overview:: Overview about the library.
  115. 
  116. File: gcrypt.info, Node: Getting Started, Next: Features, Up: Introduction
  117. 1.1 Getting Started
  118. ===================
  119. This manual documents the `Libgcrypt' library application programming
  120. interface (API). All functions and data types provided by the library
  121. are explained.
  122. The reader is assumed to possess basic knowledge about applied
  123. cryptography.
  124. This manual can be used in several ways. If read from the beginning
  125. to the end, it gives a good introduction into the library and how it
  126. can be used in an application. Forward references are included where
  127. necessary. Later on, the manual can be used as a reference manual to
  128. get just the information needed about any particular interface of the
  129. library. Experienced programmers might want to start looking at the
  130. examples at the end of the manual, and then only read up those parts of
  131. the interface which are unclear.
  132. 
  133. File: gcrypt.info, Node: Features, Next: Overview, Prev: Getting Started, Up: Introduction
  134. 1.2 Features
  135. ============
  136. `Libgcrypt' might have a couple of advantages over other libraries doing
  137. a similar job.
  138. It's Free Software
  139. Anybody can use, modify, and redistribute it under the terms of
  140. the GNU Lesser General Public License (*note Library Copying::).
  141. Note, that some parts (which are not needed on a GNU or GNU/Linux
  142. system) are subject to the terms of the GNU General Public License
  143. (*note Copying::); please see the README file of the distribution
  144. for of list of these parts.
  145. It encapsulates the low level cryptography
  146. `Libgcrypt' provides a high level interface to cryptographic
  147. building blocks using an extendable and flexible API.
  148. 
  149. File: gcrypt.info, Node: Overview, Prev: Features, Up: Introduction
  150. 1.3 Overview
  151. ============
  152. The `Libgcrypt' library is fully thread-safe, where it makes sense to
  153. be thread-safe. An exception for thread-safety are some cryptographic
  154. functions that modify a certain context stored in handles. If the user
  155. really intents to use such functions from different threads on the same
  156. handle, he has to take care of the serialization of such functions
  157. himself. If not described otherwise, every function is thread-safe.
  158. Libgcrypt depends on the library `libgpg-error', which contains
  159. common error handling related code for GnuPG components.
  160. 
  161. File: gcrypt.info, Node: Preparation, Next: Generalities, Prev: Introduction, Up: Top
  162. 2 Preparation
  163. *************
  164. To use `Libgcrypt', you have to perform some changes to your sources
  165. and the build system. The necessary changes are small and explained in
  166. the following sections. At the end of this chapter, it is described
  167. how the library is initialized, and how the requirements of the library
  168. are verified.
  169. * Menu:
  170. * Header:: What header file you need to include.
  171. * Building sources:: How to build sources using the library.
  172. * Building sources using Automake:: How to build sources with the help of Automake.
  173. * Initializing the library:: How to initialize the library.
  174. * Multi Threading:: How Libgcrypt can be used in a MT environment.
  175. 
  176. File: gcrypt.info, Node: Header, Next: Building sources, Up: Preparation
  177. 2.1 Header
  178. ==========
  179. All interfaces (data types and functions) of the library are defined in
  180. the header file `gcrypt.h'. You must include this in all source files
  181. using the library, either directly or through some other header file,
  182. like this:
  183. #include <gcrypt.h>
  184. The name space of `Libgcrypt' is `gcry_*' for function and type
  185. names and `GCRY*' for other symbols. In addition the same name
  186. prefixes with one prepended underscore are reserved for internal use
  187. and should never be used by an application. Furthermore `libgpg-error'
  188. defines functions prefixed with `gpg_' and preprocessor symbols
  189. prefixed with `GPG_'. Note that Libgcrypt uses libgpg-error, which
  190. uses `gpg_err_*' as name space for function and type names and
  191. `GPG_ERR_*' for other symbols, including all the error codes.
  192. 
  193. File: gcrypt.info, Node: Building sources, Next: Building sources using Automake, Prev: Header, Up: Preparation
  194. 2.2 Building sources
  195. ====================
  196. If you want to compile a source file including the `gcrypt.h' header
  197. file, you must make sure that the compiler can find it in the directory
  198. hierarchy. This is accomplished by adding the path to the directory in
  199. which the header file is located to the compilers include file search
  200. path (via the `-I' option).
  201. However, the path to the include file is determined at the time the
  202. source is configured. To solve this problem, `Libgcrypt' ships with a
  203. small helper program `libgcrypt-config' that knows the path to the
  204. include file and other configuration options. The options that need to
  205. be added to the compiler invocation at compile time are output by the
  206. `--cflags' option to `libgcrypt-config'. The following example shows
  207. how it can be used at the command line:
  208. gcc -c foo.c `libgcrypt-config --cflags`
  209. Adding the output of `libgcrypt-config --cflags' to the compilers
  210. command line will ensure that the compiler can find the `Libgcrypt'
  211. header file.
  212. A similar problem occurs when linking the program with the library.
  213. Again, the compiler has to find the library files. For this to work,
  214. the path to the library files has to be added to the library search path
  215. (via the `-L' option). For this, the option `--libs' to
  216. `libgcrypt-config' can be used. For convenience, this option also
  217. outputs all other options that are required to link the program with
  218. the `Libgcrypt' libraries (in particular, the `-lgcrypt' option). The
  219. example shows how to link `foo.o' with the `Libgcrypt' library to a
  220. program `foo'.
  221. gcc -o foo foo.o `libgcrypt-config --libs`
  222. Of course you can also combine both examples to a single command by
  223. specifying both options to `libgcrypt-config':
  224. gcc -o foo foo.c `libgcrypt-config --cflags --libs`
  225. 
  226. File: gcrypt.info, Node: Building sources using Automake, Next: Initializing the library, Prev: Building sources, Up: Preparation
  227. 2.3 Building sources using Automake
  228. ===================================
  229. It is much easier if you use GNU Automake instead of writing your own
  230. Makefiles. If you do that you do not have to worry about finding and
  231. invoking the `libgcrypt-config' script at all. Libgcrypt provides an
  232. extension to Automake that does all the work for you.
  233. -- Macro: AM_PATH_LIBGCRYPT ([MINIMUM-VERSION], [ACTION-IF-FOUND],
  234. [ACTION-IF-NOT-FOUND])
  235. Check whether Libgcrypt (at least version MINIMUM-VERSION, if
  236. given) exists on the host system. If it is found, execute
  237. ACTION-IF-FOUND, otherwise do ACTION-IF-NOT-FOUND, if given.
  238. Additionally, the function defines `LIBGCRYPT_CFLAGS' to the flags
  239. needed for compilation of the program to find the `gcrypt.h'
  240. header file, and `LIBGCRYPT_LIBS' to the linker flags needed to
  241. link the program to the Libgcrypt library.
  242. You can use the defined Autoconf variables like this in your
  243. `Makefile.am':
  244. AM_CPPFLAGS = $(LIBGCRYPT_CFLAGS)
  245. LDADD = $(LIBGCRYPT_LIBS)
  246. 
  247. File: gcrypt.info, Node: Initializing the library, Next: Multi Threading, Prev: Building sources using Automake, Up: Preparation
  248. 2.4 Initializing the library
  249. ============================
  250. It is often desirable to check that the version of `Libgcrypt' used is
  251. indeed one which fits all requirements. Even with binary compatibility
  252. new features may have been introduced but due to problem with the
  253. dynamic linker an old version is actually used. So you may want to
  254. check that the version is okay right after program startup.
  255. -- Function: const char *gcry_check_version (const char *REQ_VERSION)
  256. The function `gcry_check_version' has three purposes. It can be
  257. used to retrieve the version number of the library. In addition it
  258. can verify that the version number is higher than a certain
  259. required version number.
  260. In either case, the function initializes some sub-systems, and for
  261. this reason alone it must be invoked early in your program, before
  262. you make use of the other functions of Libgcrypt.
  263. 
  264. File: gcrypt.info, Node: Multi Threading, Prev: Initializing the library, Up: Preparation
  265. 2.5 Multi Threading
  266. ===================
  267. As mentioned earlier, the `Libgcrypt' library is thread-safe if you
  268. adhere to the following requirements:
  269. * If your application is multi-threaded, you must set the thread
  270. support callbacks with the `GCRYCTL_SET_THREAD_CBS' command
  271. *before* any other function in the library.
  272. This is easy enough if you are indeed writing an application using
  273. Libgcrypt. It is rather problematic if you are writing a library
  274. instead. Here are some tips what to do if you are writing a
  275. library:
  276. If your library requires a certain thread package, just initialize
  277. Libgcrypt to use this thread package. If your library supports
  278. multiple thread packages, but needs to be configured, you will
  279. have to implement a way to determine which thread package the
  280. application wants to use with your library anyway. Then configure
  281. Libgcrypt to use this thread package.
  282. If your library is fully reentrant without any special support by a
  283. thread package, then you are lucky indeed. Unfortunately, this
  284. does not relieve you from doing either of the two above, or use a
  285. third option. The third option is to let the application
  286. initialize Libgcrypt for you. Then you are not using Libgcrypt
  287. transparently, though.
  288. As if this was not difficult enough, a conflict may arise if two
  289. libraries try to initialize Libgcrypt independently of each
  290. others, and both such libraries are then linked into the same
  291. application. To make it a bit simpler for you, this will probably
  292. work, but only if both libraries have the same requirement for the
  293. thread package. This is currently only supported for the
  294. non-threaded case, GNU Pth and pthread. Support for more thread
  295. packages is easy to add, so contact us if you require it.
  296. * The function `gcry_check_version' must be called before any other
  297. function in the library, except the `GCRYCTL_SET_THREAD_CBS'
  298. command (called via the `gcry_control' function), because it
  299. initializes the thread support subsystem in Libgcrypt. To achieve
  300. this in multi-threaded programs, you must synchronize the memory
  301. with respect to other threads that also want to use Libgcrypt.
  302. For this, it is sufficient to call `gcry_check_version' before
  303. creating the other threads using Libgcrypt(1).
  304. * As with the function `gpg_strerror', `gcry_strerror' is not
  305. thread safe. You have to use `gpg_strerror_r' instead.
  306. Libgcrypt contains convenient macros, which define the necessary
  307. thread callbacks for PThread and for GNU Pth:
  308. `GCRY_THREAD_OPTION_PTH_IMPL'
  309. This macro defines the following (static) symbols: gcry_pth_init,
  310. gcry_pth_mutex_init, gcry_pth_mutex_destroy, gcry_pth_mutex_lock,
  311. gcry_pth_mutex_unlock, gcry_pth_read, gcry_pth_write,
  312. gcry_pth_select, gcry_pth_waitpid, gcry_pth_accept,
  313. gcry_pth_connect, gcry_threads_pth.
  314. After including this macro, gcry_control() shall be used with a
  315. command of GCRYCTL_SET_THREAD_CBS in order to register the thread
  316. callback structure named "gcry_threads_pth".
  317. `GCRY_THREAD_OPTION_PTHREAD_IMPL'
  318. This macro defines the following (static) symbols:
  319. gcry_pthread_mutex_init, gcry_pthread_mutex_destroy,
  320. gcry_mutex_lock, gcry_mutex_unlock, gcry_threads_pthread.
  321. After including this macro, gcry_control() shall be used with a
  322. command of GCRYCTL_SET_THREAD_CBS in order to register the thread
  323. callback structure named "gcry_threads_pthread".
  324. Note that these macros need to be terminated with a semicolon. Keep
  325. in mind that these are convenient macros for C programmers; C++
  326. programmers might have to wrap these macros in an "extern C" body.
  327. ---------- Footnotes ----------
  328. (1) At least this is true for POSIX threads, as `pthread_create' is
  329. a function that synchronizes memory with respects to other threads.
  330. There are many functions which have this property, a complete list can
  331. be found in POSIX, IEEE Std 1003.1-2003, Base Definitions, Issue 6, in
  332. the definition of the term "Memory Synchronization". For other thread
  333. packages, more relaxed or more strict rules may apply.
  334. 
  335. File: gcrypt.info, Node: Generalities, Next: Handler Functions, Prev: Preparation, Up: Top
  336. 3 Generalities
  337. **************
  338. * Menu:
  339. * Controlling the library:: Controlling Libgcrypt's behavior.
  340. * Modules:: Description of extension modules.
  341. * Error Handling:: Error codes and such.
  342. 
  343. File: gcrypt.info, Node: Controlling the library, Next: Modules, Up: Generalities
  344. 3.1 Controlling the library
  345. ===========================
  346. -- Function: gcry_error_t gcry_control (enum gcry_ctl_cmds CMD, ...)
  347. This function can be used to influence the general behavior of
  348. Libgcrypt in several ways. Depending on CMD, more arguments can
  349. or have to be provided.
  350. 
  351. File: gcrypt.info, Node: Modules, Next: Error Handling, Prev: Controlling the library, Up: Generalities
  352. 3.2 Modules
  353. ===========
  354. Libgcrypt supports the use of `extension modules', which implement
  355. algorithms in addition to those already built into the library directly.
  356. -- Data type: gcry_module_t
  357. This data type represents a `module'.
  358. Functions registering modules provided by the user take a `module
  359. specification structure' as input and return a value of `gcry_module_t'
  360. and an ID that is unique in the modules' category. This ID can be used
  361. to reference the newly registered module. After registering a module
  362. successfully, the new functionality should be able to be used through
  363. the normal functions provided by Libgcrypt until it is unregistered
  364. again.
  365. 
  366. File: gcrypt.info, Node: Error Handling, Prev: Modules, Up: Generalities
  367. 3.3 Error Handling
  368. ==================
  369. Many functions in Libgcrypt can return an error if they fail. For this
  370. reason, the application should always catch the error condition and
  371. take appropriate measures, for example by releasing the resources and
  372. passing the error up to the caller, or by displaying a descriptive
  373. message to the user and cancelling the operation.
  374. Some error values do not indicate a system error or an error in the
  375. operation, but the result of an operation that failed properly. For
  376. example, if you try to decrypt a tempered message, the decryption will
  377. fail. Another error value actually means that the end of a data buffer
  378. or list has been reached. The following descriptions explain for many
  379. error codes what they mean usually. Some error values have specific
  380. meanings if returned by a certain functions. Such cases are described
  381. in the documentation of those functions.
  382. Libgcrypt uses the `libgpg-error' library. This allows to share the
  383. error codes with other components of the GnuPG system, and thus pass
  384. error values transparently from the crypto engine, or some helper
  385. application of the crypto engine, to the user. This way no information
  386. is lost. As a consequence, Libgcrypt does not use its own identifiers
  387. for error codes, but uses those provided by `libgpg-error'. They
  388. usually start with `GPG_ERR_'.
  389. However, Libgcrypt does provide aliases for the functions defined in
  390. libgpg-error, which might be preferred for name space consistency.
  391. Most functions in Libgcrypt return an error code in the case of
  392. failure. For this reason, the application should always catch the
  393. error condition and take appropriate measures, for example by releasing
  394. the resources and passing the error up to the caller, or by displaying
  395. a descriptive message to the user and canceling the operation.
  396. Some error values do not indicate a system error or an error in the
  397. operation, but the result of an operation that failed properly.
  398. GnuPG components, including Libgcrypt, use an extra library named
  399. libgpg-error to provide a common error handling scheme. For more
  400. information on libgpg-error, see the according manual.
  401. * Menu:
  402. * Error Values:: The error value and what it means.
  403. * Error Sources:: A list of important error sources.
  404. * Error Codes:: A list of important error codes.
  405. * Error Strings:: How to get a descriptive string from a value.
  406. 
  407. File: gcrypt.info, Node: Error Values, Next: Error Sources, Up: Error Handling
  408. 3.3.1 Error Values
  409. ------------------
  410. -- Data type: gcry_err_code_t
  411. The `gcry_err_code_t' type is an alias for the `libgpg-error' type
  412. `gpg_err_code_t'. The error code indicates the type of an error,
  413. or the reason why an operation failed.
  414. A list of important error codes can be found in the next section.
  415. -- Data type: gcry_err_source_t
  416. The `gcry_err_source_t' type is an alias for the `libgpg-error'
  417. type `gpg_err_source_t'. The error source has not a precisely
  418. defined meaning. Sometimes it is the place where the error
  419. happened, sometimes it is the place where an error was encoded
  420. into an error value. Usually the error source will give an
  421. indication to where to look for the problem. This is not always
  422. true, but it is attempted to achieve this goal.
  423. A list of important error sources can be found in the next section.
  424. -- Data type: gcry_error_t
  425. The `gcry_error_t' type is an alias for the `libgpg-error' type
  426. `gpg_error_t'. An error value like this has always two
  427. components, an error code and an error source. Both together form
  428. the error value.
  429. Thus, the error value can not be directly compared against an error
  430. code, but the accessor functions described below must be used.
  431. However, it is guaranteed that only 0 is used to indicate success
  432. (`GPG_ERR_NO_ERROR'), and that in this case all other parts of the
  433. error value are set to 0, too.
  434. Note that in Libgcrypt, the error source is used purely for
  435. diagnostic purposes. Only the error code should be checked to test
  436. for a certain outcome of a function. The manual only documents the
  437. error code part of an error value. The error source is left
  438. unspecified and might be anything.
  439. -- Function: gcry_err_code_t gcry_err_code (gcry_error_t ERR)
  440. The static inline function `gcry_err_code' returns the
  441. `gcry_err_code_t' component of the error value ERR. This function
  442. must be used to extract the error code from an error value in
  443. order to compare it with the `GPG_ERR_*' error code macros.
  444. -- Function: gcry_err_source_t gcry_err_source (gcry_error_t ERR)
  445. The static inline function `gcry_err_source' returns the
  446. `gcry_err_source_t' component of the error value ERR. This
  447. function must be used to extract the error source from an error
  448. value in order to compare it with the `GPG_ERR_SOURCE_*' error
  449. source macros.
  450. -- Function: gcry_error_t gcry_err_make (gcry_err_source_t SOURCE,
  451. gcry_err_code_t CODE)
  452. The static inline function `gcry_err_make' returns the error value
  453. consisting of the error source SOURCE and the error code CODE.
  454. This function can be used in callback functions to construct an
  455. error value to return it to the library.
  456. -- Function: gcry_error_t gcry_error (gcry_err_code_t CODE)
  457. The static inline function `gcry_error' returns the error value
  458. consisting of the default error source and the error code CODE.
  459. For GCRY applications, the default error source is
  460. `GPG_ERR_SOURCE_USER_1'. You can define `GCRY_ERR_SOURCE_DEFAULT'
  461. before including `gcrypt.h' to change this default.
  462. This function can be used in callback functions to construct an
  463. error value to return it to the library.
  464. The `libgpg-error' library provides error codes for all system error
  465. numbers it knows about. If ERR is an unknown error number, the error
  466. code `GPG_ERR_UNKNOWN_ERRNO' is used. The following functions can be
  467. used to construct error values from system errno numbers.
  468. -- Function: gcry_error_t gcry_err_make_from_errno
  469. (gcry_err_source_t SOURCE, int ERR)
  470. The function `gcry_err_make_from_errno' is like `gcry_err_make',
  471. but it takes a system error like `errno' instead of a
  472. `gcry_err_code_t' error code.
  473. -- Function: gcry_error_t gcry_error_from_errno (int ERR)
  474. The function `gcry_error_from_errno' is like `gcry_error', but it
  475. takes a system error like `errno' instead of a `gcry_err_code_t'
  476. error code.
  477. Sometimes you might want to map system error numbers to error codes
  478. directly, or map an error code representing a system error back to the
  479. system error number. The following functions can be used to do that.
  480. -- Function: gcry_err_code_t gcry_err_code_from_errno (int ERR)
  481. The function `gcry_err_code_from_errno' returns the error code for
  482. the system error ERR. If ERR is not a known system error, the
  483. function returns `GPG_ERR_UNKNOWN_ERRNO'.
  484. -- Function: int gcry_err_code_to_errno (gcry_err_code_t ERR)
  485. The function `gcry_err_code_to_errno' returns the system error for
  486. the error code ERR. If ERR is not an error code representing a
  487. system error, or if this system error is not defined on this
  488. system, the function returns `0'.
  489. 
  490. File: gcrypt.info, Node: Error Sources, Next: Error Codes, Prev: Error Values, Up: Error Handling
  491. 3.3.2 Error Sources
  492. -------------------
  493. The library `libgpg-error' defines an error source for every component
  494. of the GnuPG system. The error source part of an error value is not
  495. well defined. As such it is mainly useful to improve the diagnostic
  496. error message for the user.
  497. If the error code part of an error value is `0', the whole error
  498. value will be `0'. In this case the error source part is of course
  499. `GPG_ERR_SOURCE_UNKNOWN'.
  500. The list of error sources that might occur in applications using
  501. Libgctypt is:
  502. `GPG_ERR_SOURCE_UNKNOWN'
  503. The error source is not known. The value of this error source is
  504. `0'.
  505. `GPG_ERR_SOURCE_GPGME'
  506. The error source is GPGME itself.
  507. `GPG_ERR_SOURCE_GPG'
  508. The error source is GnuPG, which is the crypto engine used for the
  509. OpenPGP protocol.
  510. `GPG_ERR_SOURCE_GPGSM'
  511. The error source is GPGSM, which is the crypto engine used for the
  512. OpenPGP protocol.
  513. `GPG_ERR_SOURCE_GCRYPT'
  514. The error source is `libgcrypt', which is used by crypto engines
  515. to perform cryptographic operations.
  516. `GPG_ERR_SOURCE_GPGAGENT'
  517. The error source is `gpg-agent', which is used by crypto engines
  518. to perform operations with the secret key.
  519. `GPG_ERR_SOURCE_PINENTRY'
  520. The error source is `pinentry', which is used by `gpg-agent' to
  521. query the passphrase to unlock a secret key.
  522. `GPG_ERR_SOURCE_SCD'
  523. The error source is the SmartCard Daemon, which is used by
  524. `gpg-agent' to delegate operations with the secret key to a
  525. SmartCard.
  526. `GPG_ERR_SOURCE_KEYBOX'
  527. The error source is `libkbx', a library used by the crypto engines
  528. to manage local keyrings.
  529. `GPG_ERR_SOURCE_USER_1'
  530. `GPG_ERR_SOURCE_USER_2'
  531. `GPG_ERR_SOURCE_USER_3'
  532. `GPG_ERR_SOURCE_USER_4'
  533. These error sources are not used by any GnuPG component and can be
  534. used by other software. For example, applications using Libgcrypt
  535. can use them to mark error values coming from callback handlers.
  536. Thus `GPG_ERR_SOURCE_USER_1' is the default for errors created
  537. with `gcry_error' and `gcry_error_from_errno', unless you define
  538. `GCRY_ERR_SOURCE_DEFAULT' before including `gcrypt.h'.
  539. 
  540. File: gcrypt.info, Node: Error Codes, Next: Error Strings, Prev: Error Sources, Up: Error Handling
  541. 3.3.3 Error Codes
  542. -----------------
  543. The library `libgpg-error' defines many error values. The following
  544. list includes the most important error codes.
  545. `GPG_ERR_EOF'
  546. This value indicates the end of a list, buffer or file.
  547. `GPG_ERR_NO_ERROR'
  548. This value indicates success. The value of this error code is
  549. `0'. Also, it is guaranteed that an error value made from the
  550. error code `0' will be `0' itself (as a whole). This means that
  551. the error source information is lost for this error code, however,
  552. as this error code indicates that no error occured, this is
  553. generally not a problem.
  554. `GPG_ERR_GENERAL'
  555. This value means that something went wrong, but either there is not
  556. enough information about the problem to return a more useful error
  557. value, or there is no separate error value for this type of
  558. problem.
  559. `GPG_ERR_ENOMEM'
  560. This value means that an out-of-memory condition occurred.
  561. `GPG_ERR_E...'
  562. System errors are mapped to GPG_ERR_EFOO where FOO is the symbol
  563. for the system error.
  564. `GPG_ERR_INV_VALUE'
  565. This value means that some user provided data was out of range.
  566. `GPG_ERR_UNUSABLE_PUBKEY'
  567. This value means that some recipients for a message were invalid.
  568. `GPG_ERR_UNUSABLE_SECKEY'
  569. This value means that some signers were invalid.
  570. `GPG_ERR_NO_DATA'
  571. This value means that data was expected where no data was found.
  572. `GPG_ERR_CONFLICT'
  573. This value means that a conflict of some sort occurred.
  574. `GPG_ERR_NOT_IMPLEMENTED'
  575. This value indicates that the specific function (or operation) is
  576. not implemented. This error should never happen. It can only
  577. occur if you use certain values or configuration options which do
  578. not work, but for which we think that they should work at some
  579. later time.
  580. `GPG_ERR_DECRYPT_FAILED'
  581. This value indicates that a decryption operation was unsuccessful.
  582. `GPG_ERR_WRONG_KEY_USAGE'
  583. This value indicates that a key is not used appropriately.
  584. `GPG_ERR_NO_SECKEY'
  585. This value indicates that no secret key for the user ID is
  586. available.
  587. `GPG_ERR_UNSUPPORTED_ALGORITHM'
  588. This value means a verification failed because the cryptographic
  589. algorithm is not supported by the crypto backend.
  590. `GPG_ERR_BAD_SIGNATURE'
  591. This value means a verification failed because the signature is
  592. bad.
  593. `GPG_ERR_NO_PUBKEY'
  594. This value means a verification failed because the public key is
  595. not available.
  596. `GPG_ERR_USER_1'
  597. `GPG_ERR_USER_2'
  598. `...'
  599. `GPG_ERR_USER_16'
  600. These error codes are not used by any GnuPG component and can be
  601. freely used by other software. Applications using Libgcrypt might
  602. use them to mark specific errors returned by callback handlers if
  603. no suitable error codes (including the system errors) for these
  604. errors exist already.
  605. 
  606. File: gcrypt.info, Node: Error Strings, Prev: Error Codes, Up: Error Handling
  607. 3.3.4 Error Strings
  608. -------------------
  609. -- Function: const char * gcry_strerror (gcry_error_t ERR)
  610. The function `gcry_strerror' returns a pointer to a statically
  611. allocated string containing a description of the error code
  612. contained in the error value ERR. This string can be used to
  613. output a diagnostic message to the user.
  614. -- Function: const char * gcry_strsource (gcry_error_t ERR)
  615. The function `gcry_strerror' returns a pointer to a statically
  616. allocated string containing a description of the error source
  617. contained in the error value ERR. This string can be used to
  618. output a diagnostic message to the user.
  619. The following example illustrates the use of the functions described
  620. above:
  621. {
  622. gcry_cipher_hd_t handle;
  623. gcry_error_t err = 0;
  624. err = gcry_cipher_open (&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_CBC, 0);
  625. if (err)
  626. {
  627. fprintf (stderr, "Failure: %s/%s\n",
  628. gcry_strsource (err),
  629. gcry_strerror (err));
  630. }
  631. }
  632. 
  633. File: gcrypt.info, Node: Handler Functions, Next: Symmetric cryptography, Prev: Generalities, Up: Top
  634. 4 Handler Functions
  635. *******************
  636. Libgcrypt makes it possible to install so called `handler functions',
  637. which get called by Libgcrypt in case of certain events.
  638. * Menu:
  639. * Progress handler:: Using a progress handler function.
  640. * Allocation handler:: Using special memory allocation functions.
  641. * Error handler:: Using error handler functions.
  642. * Logging handler:: Using a special logging function.
  643. 
  644. File: gcrypt.info, Node: Progress handler, Next: Allocation handler, Up: Handler Functions
  645. 4.1 Progress handler
  646. ====================
  647. It is often useful to retrieve some feedback while long running
  648. operations are performed.
  649. -- Data type: gcry_handler_progress_t
  650. Progress handler functions have to be of the type
  651. `gcry_handler_progress_t', which is defined as:
  652. `void (*gcry_handler_progress_t) (void *, const char *, int, int,
  653. int)'
  654. The following function may be used to register a handler function for
  655. this purpose.
  656. -- Function: void gcry_set_progress_handler (gcry_handler_progress_t
  657. CB, void *CB_DATA)
  658. This function installs CB as the `Progress handler' function. CB
  659. must be defined as follows:
  660. void
  661. my_progress_handler (void *CB_DATA, const char *WHAT,
  662. int PRINTCHAR, int CURRENT, int TOTAL)
  663. {
  664. /* Do something. */
  665. }
  666. A description of the arguments of the progress handler function
  667. follows.
  668. CB_DATA
  669. The argument provided in the call to
  670. `gcry_set_progress_handler'.
  671. WHAT
  672. A string identifying the type of the progress output. The
  673. following values for WHAT are defined:
  674. `need_entropy'
  675. Not enough entropy is available. TOTAL holds the number
  676. of required bytes.
  677. `primegen'
  678. Values for PRINTCHAR:
  679. `\n'
  680. Prime generated.
  681. `!'
  682. Need to refresh the pool of prime numbers.
  683. `<, >'
  684. Number of bits adjusted.
  685. `^'
  686. Searching for a generator.
  687. `.'
  688. Fermat test on 10 candidates failed.
  689. `:'
  690. Restart with a new random value.
  691. `+'
  692. Rabin Miller test passed.
  693. 
  694. File: gcrypt.info, Node: Allocation handler, Next: Error handler, Prev: Progress handler, Up: Handler Functions
  695. 4.2 Allocation handler
  696. ======================
  697. It is possible to make Libgcrypt use special memory allocation
  698. functions instead of the built-in ones.
  699. Memory allocation functions are of the following types:
  700. -- Data type: gcry_handler_alloc_t
  701. This type is defined as: `void *(*gcry_handler_alloc_t) (size_t
  702. n)'.
  703. -- Data type: gcry_handler_secure_check_t
  704. This type is defined as: `int *(*gcry_handler_secure_check_t)
  705. (const void *)'.
  706. -- Data type: gcry_handler_realloc_t
  707. This type is defined as: `void *(*gcry_handler_realloc_t) (void
  708. *p, size_t n)'.
  709. -- Data type: gcry_handler_free_t
  710. This type is defined as: `void *(*gcry_handler_free_t) (void *)'.
  711. Special memory allocation functions can be installed with the
  712. following function:
  713. -- Function: void gcry_set_allocation_handler (gcry_handler_alloc_t
  714. FUNC_ALLOC, gcry_handler_alloc_t FUNC_ALLOC_SECURE,
  715. gcry_handler_secure_check_t FUNC_SECURE_CHECK,
  716. gcry_handler_realloc_t FUNC_REALLOC, gcry_handler_free_t
  717. FUNC_FREE)
  718. Install the provided functions and use them instead of the built-in
  719. functions for doing memory allocation.
  720. 
  721. File: gcrypt.info, Node: Error handler, Next: Logging handler, Prev: Allocation handler, Up: Handler Functions
  722. 4.3 Error handler
  723. =================
  724. The following functions may be used to register handler functions that
  725. are called by Libgcrypt in case certain error conditions occur.
  726. -- Data type: gcry_handler_no_mem_t
  727. This type is defined as: `void (*gcry_handler_no_mem_t) (void *,
  728. size_t, unsigned int)'
  729. -- Function: void gcry_set_outofcore_handler (gcry_handler_no_mem_t
  730. FUNC_NO_MEM, void *CB_DATA)
  731. This function registers FUNC_NO_MEM as `out-of-core handler',
  732. which means that it will be called in the case of not having enough
  733. memory available.
  734. -- Data type: gcry_handler_error_t
  735. This type is defined as: `void (*gcry_handler_error_t) (void *,
  736. int, const char *)'
  737. -- Function: void gcry_set_fatalerror_handler (gcry_handler_error_t
  738. FUNC_ERROR, void *CB_DATA)
  739. This function registers FUNC_ERROR as `error handler', which means
  740. that it will be called in error conditions.
  741. 
  742. File: gcrypt.info, Node: Logging handler, Prev: Error handler, Up: Handler Functions
  743. 4.4 Logging handler
  744. ===================
  745. -- Data type: gcry_handler_log_t
  746. This type is defined as: `void (*gcry_handler_log_t) (void *, int,
  747. const char *, va_list)'
  748. -- Function: void gcry_set_log_handler (gcry_handler_log_t FUNC_LOG,
  749. void *CB_DATA)
  750. This function registers FUNC_LOG as `logging handler', which means
  751. that it will be called in case Libgcrypt wants to log a message.
  752. 
  753. File: gcrypt.info, Node: Symmetric cryptography, Next: Hashing, Prev: Handler Functions, Up: Top
  754. 5 Symmetric cryptography
  755. ************************
  756. The cipher functions are used for symmetrical cryptography, i.e.
  757. cryptography using a shared key. The programming model follows an
  758. open/process/close paradigm and is in that similar to other building
  759. blocks provided by Libgcrypt.
  760. * Menu:
  761. * Available ciphers:: List of ciphers supported by the library.
  762. * Cipher modules:: How to work with cipher modules.
  763. * Available cipher modes:: List of cipher modes supported by the library.
  764. * Working with cipher handles:: How to perform operations related to cipher handles.
  765. * General cipher functions:: General cipher functions independent of cipher handles.
  766. 
  767. File: gcrypt.info, Node: Available ciphers, Next: Cipher modules, Up: Symmetric cryptography
  768. 5.1 Available ciphers
  769. =====================
  770. `GCRY_CIPHER_NONE'
  771. This is not a real algorithm but used by some functions as error
  772. return. The value always evaluates to false.
  773. `GCRY_CIPHER_IDEA'
  774. This is the IDEA algorithm. The constant is provided but there is
  775. currently no implementation for it because the algorithm is
  776. patented.
  777. `GCRY_CIPHER_3DES'
  778. Triple-DES with 3 Keys as EDE. The key size of this algorithm is
  779. 168 but you have to pass 192 bits because the most significant
  780. bits of each byte are ignored.
  781. `GCRY_CIPHER_CAST5'
  782. CAST128-5 block cipher algorithm. The key size is 128 bits.
  783. `GCRY_CIPHER_BLOWFISH'
  784. The blowfish algorithm. The current implementation allows only for
  785. a key size of 128 bits.
  786. `GCRY_CIPHER_SAFER_SK128'
  787. Reserved and not currently implemented.
  788. `GCRY_CIPHER_DES_SK'
  789. Reserved and not currently implemented.
  790. `GCRY_CIPHER_AES'
  791. `GCRY_CIPHER_AES128'
  792. `GCRY_CIPHER_RIJNDAEL'
  793. `GCRY_CIPHER_RIJNDAEL128'
  794. AES (Rijndael) with a 128 bit key.
  795. `GCRY_CIPHER_AES192'
  796. `GCRY_CIPHER_RIJNDAEL128'
  797. AES (Rijndael) with a 192 bit key.
  798. `GCRY_CIPHER_AES256'
  799. `GCRY_CIPHER_RIJNDAEL256'
  800. AES (Rijndael) with a 256 bit key.
  801. `GCRY_CIPHER_TWOFISH'
  802. The Twofish algorithm with a 256 bit key.
  803. `GCRY_CIPHER_TWOFISH128'
  804. The Twofish algorithm with a 128 bit key.
  805. `GCRY_CIPHER_ARCFOUR'
  806. An algorithm which is 100% compatible with RSA Inc.'s RC4
  807. algorithm. Note that this is a stream cipher and must be used
  808. very carefully to avoid a couple of weaknesses.
  809. `GCRY_CIPHER_DES'
  810. Standard DES with a 56 bit key. You need to pass 64 bit but the
  811. high bits of each byte are ignored. Note, that this is a weak
  812. algorithm which can be broken in reasonable time using a brute
  813. force approach.
  814. 
  815. File: gcrypt.info, Node: Cipher modules, Next: Available cipher modes, Prev: Available ciphers, Up: Symmetric cryptography
  816. 5.2 Cipher modules
  817. ==================
  818. Libgcrypt makes it possible to load additional `cipher modules'; these
  819. cipher can be used just like the cipher algorithms that are built into
  820. the library directly. For an introduction into extension modules, see
  821. *Note Modules::.
  822. -- Data type: gcry_cipher_spec_t
  823. This is the `module specification structure' needed for registering
  824. cipher modules, which has to be filled in by the user before it
  825. can be used to register a module. It contains the following
  826. members:
  827. `const char *name'
  828. The primary name of the algorithm.
  829. `const char **aliases'
  830. A list of strings that are `aliases' for the algorithm. The
  831. list must be terminated with a NULL element.
  832. `gcry_cipher_oid_spec_t *oids'
  833. A list of OIDs that are to be associated with the algorithm.
  834. The list's last element must have it's `oid' member set to
  835. NULL. See below for an explanation of this type.
  836. `size_t blocksize'
  837. The block size of the algorithm, in bytes.
  838. `size_t keylen'
  839. The length of the key, in bits.
  840. `size_t contextsize'
  841. The size of the algorithm-specific `context', that should be
  842. allocated for each handle.
  843. `gcry_cipher_setkey_t setkey'
  844. The function responsible for initializing a handle with a
  845. provided key. See below for a description of this type.
  846. `gcry_cipher_encrypt_t encrypt'
  847. The function responsible for encrypting a single block. See
  848. below for a description of this type.
  849. `gcry_cipher_decrypt_t decrypt'
  850. The function responsible for decrypting a single block. See
  851. below for a description of this type.
  852. `gcry_cipher_stencrypt_t stencrypt'
  853. Like `encrypt', for stream ciphers. See below for a
  854. description of this type.
  855. `gcry_cipher_stdecrypt_t stdecrypt'
  856. Like `decrypt', for stream ciphers. See below for a
  857. description of this type.
  858. -- Data type: gcry_cipher_oid_spec_t
  859. This type is used for associating a user-provided algorithm
  860. implementation with certain OIDs. It contains the following
  861. members:
  862. `const char *oid'
  863. Textual representation of the OID.
  864. `int mode'
  865. Cipher mode for which this OID is valid.
  866. -- Data type: gcry_cipher_setkey_t
  867. Type for the `setkey' function, defined as: gcry_err_code_t
  868. (*gcry_cipher_setkey_t) (void *c, const unsigned char *key,
  869. unsigned keylen)
  870. -- Data type: gcry_cipher_encrypt_t
  871. Type for the `encrypt' function, defined as: gcry_err_code_t
  872. (*gcry_cipher_encrypt_t) (void *c, const unsigned char *outbuf,
  873. const unsigned char *inbuf)
  874. -- Data type: gcry_cipher_decrypt_t
  875. Type for the `decrypt' function, defined as: gcry_err_code_t
  876. (*gcry_cipher_decrypt_t) (void *c, const unsigned char *outbuf,
  877. const unsigned char *inbuf)
  878. -- Data type: gcry_cipher_stencrypt_t
  879. Type for the `stencrypt' function, defined as: gcry_err_code_t
  880. (*gcry_cipher_stencrypt_t) (void *c, const unsigned char *outbuf,
  881. const unsigned char *, unsigned int n)
  882. -- Data type: gcry_cipher_stdecrypt_t
  883. Type for the `stdecrypt' function, defined as: gcry_err_code_t
  884. (*gcry_cipher_stdecrypt_t) (void *c, const unsigned char *outbuf,
  885. const unsigned char *, unsigned int n)
  886. -- Function: gcry_error_t gcry_cipher_register (gcry_cipher_spec_t
  887. *CIPHER, unsigned int *algorithm_id, gcry_module_t *MODULE)
  888. Register a new cipher module whose specification can be found in
  889. CIPHER. On success, a new algorithm ID is stored in ALGORITHM_ID
  890. and a pointer representing this module is stored in MODULE.
  891. -- Function: void gcry_cipher_unregister (gcry_module_t MODULE)
  892. Unregister the cipher identified by MODULE, which must have been
  893. registered with gcry_cipher_register.
  894. -- Function: gcry_error_t gcry_cipher_list (int *LIST, int
  895. *LIST_LENGTH)
  896. Get a list consisting of the IDs of the loaded cipher modules. If
  897. LIST is zero, write the number of loaded cipher modules to
  898. LIST_LENGTH and return. If LIST is non-zero, the first
  899. *LIST_LENGTH algorithm IDs are stored in LIST, which must be of
  900. according size. In case there are less cipher modules than
  901. *LIST_LENGTH, *LIST_LENGTH is updated to the correct number.
  902. 
  903. File: gcrypt.info, Node: Available cipher modes, Next: Working with cipher handles, Prev: Cipher modules, Up: Symmetric cryptography
  904. 5.3 Available cipher modes
  905. ==========================
  906. `GCRY_CIPHER_MODE_NONE'
  907. No mode specified, may be set later using other functions. The
  908. value of this constant is always 0.
  909. `GCRY_CIPHER_MODE_ECB'
  910. Electronic Codebook mode.
  911. `GCRY_CIPHER_MODE_CFB'
  912. Cipher Feedback mode.
  913. `GCRY_CIPHER_MODE_CBC'
  914. Cipher Block Chaining mode.
  915. `GCRY_CIPHER_MODE_STREAM'
  916. Stream mode, only to be used with stream cipher algorithms.
  917. `GCRY_CIPHER_MODE_OFB'
  918. Outer Feedback mode.
  919. `GCRY_CIPHER_MODE_CTR'
  920. Counter mode.
  921. 
  922. File: gcrypt.info, Node: Working with cipher handles, Next: General cipher functions, Prev: Available cipher modes, Up: Symmetric cryptography
  923. 5.4 Working with cipher handles
  924. ===============================
  925. To use a cipher algorithm, you must first allocate an according handle.
  926. This is to be done using the open function:
  927. -- Function: gcry_error_t gcry_cipher_open (gcry_cipher_hd_t *HD, int
  928. ALGO, int MODE, unsigned int FLAGS)
  929. This function creates the context handle required for most of the
  930. other cipher functions and returns a handle to it in `hd'. In
  931. case of an error, an according error code is returned.
  932. The ID of algorithm to use must be specified via ALGO. See *Note
  933. Available ciphers::, for a list of supported ciphers and the
  934. according constants.
  935. Besides using the constants directly, the function
  936. `gcry_cipher_map_name' may be used to convert the textual name of
  937. an algorithm into the according numeric ID.
  938. The cipher mode to use must be specified via MODE. See *Note
  939. Available cipher modes::, for a list of supported cipher modes and
  940. the according constants. Note, that some modes do not work
  941. together with all algorithms.
  942. The third argument FLAGS can either be passed as `0' or as the
  943. bit-wise OR of the following constants.
  944. `GCRY_CIPHER_SECURE'
  945. Make sure that all operations are allocated in secure memory.
  946. This is useful, when the key material is highly confidential.
  947. `GCRY_CIPHER_ENABLE_SYNC'
  948. This flag enables the CFB sync mode, which is a special
  949. feature of Libgcrypt's CFB mode implementation to allow for
  950. OpenPGP's CFB variant. See `gcry_cipher_sync'.
  951. `GCRY_CIPHER_CBC_CTS'
  952. Enable cipher text stealing (CTS) for the CBC mode. Cannot
  953. be used simultaneous as GCRY_CIPHER_CBC_MAC
  954. `GCRY_CIPHER_CBC_MAC'
  955. Compute CBC-MAC keyed checksums. This is the same as CBC
  956. mode, but only output the last block. Cannot be used
  957. simultaneous as GCRY_CIPHER_CBC_CTS.
  958. Use the following function to release an existing handle:
  959. -- Function: void gcry_cipher_close (gcry_cipher_hd_t H)
  960. This function releases the context created by `gcry_cipher_open'.
  961. In order to use a handle for performing cryptographic operations, a
  962. `key' has to be set first:
  963. -- Function: gcry_error_t gcry_cipher_setkey (gcry_cipher_hd_t H, void
  964. *K, size_t L)
  965. Set the key K used for encryption or decryption in the context
  966. denoted by the handle H. The length L of the key K must match the
  967. required length of the algorithm set for this context or be in the
  968. allowed range for algorithms with variable key size. The function
  969. checks this and returns an error if there is a problem. A caller
  970. should always check for an error.
  971. Note, this is currently implemented as a macro but may be changed
  972. to a function in the future.
  973. Most crypto modes requires an initialization vector (IV), which
  974. usually is a non-secret random string acting as a kind of salt value.
  975. The CTR mode requires a counter, which is also similar to a salt value.
  976. To set the IV or CTR, use these functions:
  977. -- Function: gcry_error_t gcry_cipher_setiv (gcry_cipher_hd_t H, void
  978. *K, size_t L)
  979. Set the initialization vector used for encryption or decryption.
  980. The vector is passed as the buffer K of length L and copied to
  981. internal data structures. The function checks that the IV matches
  982. the requirement of the selected algorithm and mode. Note, that
  983. this is implemented as a macro.
  984. -- Function: gcry_error_t gcry_cipher_setctr (gcry_cipher_hd_t H, void
  985. *C, size_t L)
  986. Set the counter vector used for encryption or decryption. The
  987. counter is passed as the buffer C of length L and copied to
  988. internal data structures. The function checks that the counter
  989. matches the requirement of the selected algorithm (i.e., it must be
  990. the same size as the block size). Note, that this is implemented
  991. as a macro.
  992. -- Function: gcry_error_t gcry_cipher_reset (gcry_cipher_hd_t H)
  993. Set the given handle's context back to the state it had after the
  994. last call to gcry_cipher_setkey and clear the initialization
  995. vector.
  996. Note, that gcry_cipher_reset is implemented as a macro.
  997. The actual encryption and decryption is done by using one of the
  998. following functions. They may be used as often as required to process
  999. all the data.
  1000. -- Function: gcry_error_t gcry_cipher_encrypt (gcry_cipher_hd_t H,
  1001. void *out, size_t OUTSIZE, const void *IN, size_t INLEN)
  1002. `gcry_cipher_encrypt' is used to encrypt the data. This function
  1003. can either work in place or with two buffers. It uses the cipher
  1004. context already setup and described by the handle H. There are 2
  1005. ways to use the function: If IN is passed as `NULL' and INLEN is
  1006. `0', in-place encryption of the data in OUT or length OUTSIZE
  1007. takes place. With IN being not `NULL', INLEN bytes are encrypted
  1008. to the buffer OUT which must have at least a size of INLEN.
  1009. OUTLEN must be set to the allocated size of OUT, so that the
  1010. function can check that there is sufficient space. Note, that
  1011. overlapping buffers are not allowed.
  1012. Depending on the selected algorithms and encryption mode, the
  1013. length of the buffers must be a multiple of the block size.
  1014. The function returns `0' on success or an error code.
  1015. -- Function: gcry_error_t gcry_cipher_decrypt (gcry_cipher_hd_t H,
  1016. void *out, size_t OUTSIZE, const void *IN, size_t INLEN)
  1017. `gcry_cipher_decrypt' is used to decrypt the data. This function
  1018. can either work in place or with two buffers. It uses the cipher
  1019. context already setup and described by the handle H. There are 2
  1020. ways to use the function: If IN is passed as `NULL' and INLEN is
  1021. `0', in-place decryption of the data in OUT or length OUTSIZE
  1022. takes place. With IN being not `NULL', INLEN bytes are decrypted
  1023. to the buffer OUT which must have at least a size of INLEN.
  1024. OUTLEN must be set to the allocated size of OUT, so that the
  1025. function can check that there is sufficient space. Note, that
  1026. overlapping buffers are not allowed.
  1027. Depending on the selected algorithms and encryption mode, the
  1028. length of the buffers must be a multiple of the block size.
  1029. The function returns `0' on success or an error code.
  1030. OpenPGP (as defined in RFC-2440) requires a special sync operation in
  1031. some places, the following function is used for this:
  1032. -- Function: gcry_error_t gcry_cipher_sync (gcry_cipher_hd_t H)
  1033. Perform the OpenPGP sync operation on context H. Note, that this
  1034. is a no-op unless the context was created with the flag
  1035. `GCRY_CIPHER_ENABLE_SYNC'
  1036. Some of the described functions are implemented as macros utilizing a
  1037. catch-all control function. This control function is rarely used
  1038. directly but there is nothing which would inhibit it:
  1039. -- Function: gcry_error_t gcry_cipher_ctl (gcry_cipher_hd_t H, int
  1040. CMD, void *BUFFER, size_t BUFLEN)
  1041. `gcry_cipher_ctl' controls various aspects of the cipher module and
  1042. specific cipher contexts. Usually some more specialized functions
  1043. or macros are used for this purpose. The semantics of the
  1044. function and its parameters depends on the the command CMD and the
  1045. passed context handle H. Please see the comments in the source
  1046. code (`src/global.c') for details.
  1047. -- Function: gcry_error_t gcry_cipher_info (gcry_cipher_hd_t H, int
  1048. WHAT, void *BUFFER, size_t *NBYTES)
  1049. `gcry_cipher_info' is used to retrieve various information about a
  1050. cipher context or the cipher module in general.
  1051. Currently no information is available.
  1052. 
  1053. File: gcrypt.info, Node: General cipher functions, Prev: Working with cipher handles, Up: Symmetric cryptography
  1054. 5.5 General cipher functions
  1055. ============================
  1056. To work with the algorithms, several functions are available to map
  1057. algorithm names to the internal identifiers, as well as ways to
  1058. retrieve information about an algorithm or the current cipher context.
  1059. -- Function: gcry_error_t gcry_cipher_algo_info (int ALGO, int WHAT,
  1060. void *BUFFER, size_t *NBYTES)
  1061. This function is used to retrieve information on a specific
  1062. algorithm. You pass the cipher algorithm ID as ALGO and the type
  1063. of information requested as WHAT. The result is either returned as
  1064. the return code of the function or copied to the provided BUFFER
  1065. whose allocated length must be available in an integer variable
  1066. with the address passed in NBYTES. This variable will also
  1067. receive the actual used length of the buffer.
  1068. Here is a list of supported codes for WHAT:
  1069. `GCRYCTL_GET_KEYLEN:'
  1070. Return the length of the key. If the algorithm supports
  1071. multiple key lengths, the maximum supported value is
  1072. returned. The length is returned as number of octets (bytes)
  1073. and not as number of bits in NBYTES; BUFFER must be zero.
  1074. `GCRYCTL_GET_BLKLEN:'
  1075. Return the block length of the algorithm. The length is
  1076. returned as a number of octets in NBYTES; BUFFER must be zero.
  1077. `GCRYCTL_TEST_ALGO:'
  1078. Returns `0' when the specified algorithm is available for use.
  1079. BUFFER and NBYTES must be zero.
  1080. -- Function: const char *gcry_cipher_algo_name (int ALGO)
  1081. `gcry_cipher_algo_name' returns a string with the name of the
  1082. cipher algorithm ALGO. If the algorithm is not known or another
  1083. error occurred, an empty string is returned. This function will
  1084. never return `NULL'.
  1085. -- Function: int gcry_cipher_map_name (const char *NAME)
  1086. `gcry_cipher_map_name' returns the algorithm identifier for the
  1087. cipher algorithm described by the string NAME. If this algorithm
  1088. is not available `0' is returned.
  1089. -- Function: int gcry_cipher_mode_from_oid (const char *STRING)
  1090. Return the cipher mode associated with an ASN.1 object identifier.
  1091. The object identifier is expected to be in the IETF-style dotted
  1092. decimal notation. The function returns `0' for an unknown object
  1093. identifier or when no mode is associated with it.
  1094. 
  1095. File: gcrypt.info, Node: Hashing, Next: Public Key cryptography (I), Prev: Symmetric cryptography, Up: Top
  1096. 6 Hashing
  1097. *********
  1098. Libgcrypt provides an easy and consistent to use interface for hashing.
  1099. Hashing is buffered and several hash algorithms can be updated at
  1100. once. It is possible to calculate a MAC using the same routines. The
  1101. programming model follows an open/process/close paradigm and is in that
  1102. similar to other building blocks provided by Libgcrypt.
  1103. For convenience reasons, a few cyclic redundancy check value
  1104. operations are also supported.
  1105. * Menu:
  1106. * Available hash algorithms:: List of hash algorithms supported by the library.
  1107. * Hash algorithm modules:: How to work with hash algorithm modules.
  1108. * Working with hash algorithms:: List of functions related to hashing.
  1109. 
  1110. File: gcrypt.info, Node: Available hash algorithms, Next: Hash algorithm modules, Up: Hashing
  1111. 6.1 Available hash algorithms
  1112. =============================
  1113. `GCRY_MD_NONE'
  1114. This is not a real algorithm but used by some functions as an error
  1115. return value. This constant is guaranteed to have the value `0'.
  1116. `GCRY_MD_SHA1'
  1117. This is the SHA-1 algorithm which yields a message digest of 20
  1118. bytes.
  1119. `GCRY_MD_RMD160'
  1120. This is the 160 bit version of the RIPE message digest
  1121. (RIPE-MD-160). Like SHA-1 it also yields a digest of 20 bytes.
  1122. `GCRY_MD_MD5'
  1123. This is the well known MD5 algorithm, which yields a message
  1124. digest of 16 bytes.
  1125. `GCRY_MD_MD4'
  1126. This is the MD4 algorithm, which yields a message digest of 16
  1127. bytes.
  1128. `GCRY_MD_MD2'
  1129. This is an reserved identifier for MD-2; there is no
  1130. implementation yet.
  1131. `GCRY_MD_TIGER'
  1132. This is the TIGER/192 algorithm which yields a message digest of
  1133. 24 bytes.
  1134. `GCRY_MD_HAVAL'
  1135. This is an reserved for the HAVAL algorithm with 5 passes and 160
  1136. bit. It yields a message digest of 20 bytes. Note that there is no
  1137. implementation yet available.
  1138. `GCRY_MD_SHA256'
  1139. This is the SHA-256 algorithm which yields a message digest of 32
  1140. bytes. See FIPS 180-2 for the specification.
  1141. `GCRY_MD_SHA384'
  1142. This is reserved for SHA-2 with 384 bits. It yields a message
  1143. digest of 48 bytes. Note that there is no implementation yet
  1144. available.
  1145. `GCRY_MD_SHA512'
  1146. This is reserved for SHA-2 with 512 bits. It yields a message
  1147. digest of 64 bytes. Note that there is no implementation yet
  1148. available.
  1149. `GCRY_MD_CRC32'
  1150. This is the ISO 3309 and ITU-T V.42 cyclic redundancy check. It
  1151. yields an output of 4 bytes.
  1152. `GCRY_MD_CRC32_RFC1510'
  1153. This is the above cyclic redundancy check function, as modified by
  1154. RFC 1510. It yields an output of 4 bytes.
  1155. `GCRY_MD_CRC24_RFC2440'
  1156. This is the OpenPGP cyclic redundancy check function. It yields an
  1157. output of 3 bytes.
  1158. 
  1159. File: gcrypt.info, Node: Hash algorithm modules, Next: Working with hash algorithms, Prev: Available hash algorithms, Up: Hashing
  1160. 6.2 Hash algorithm modules
  1161. ==========================
  1162. Libgcrypt makes it possible to load additional `message digest
  1163. modules'; these cipher can be used just like the message digest
  1164. algorithms that are built into the library directly. For an
  1165. introduction into extension modules, see *Note Modules::.
  1166. -- Data type: gcry_md_spec_t
  1167. This is the `module specification structure' needed for registering
  1168. message digest modules, which has to be filled in by the user
  1169. before it can be used to register a module. It contains the
  1170. following members:
  1171. `const char *name'
  1172. The primary name of this algorithm.
  1173. `unsigned char *asnoid'
  1174. Array of bytes that form the ASN OID.
  1175. `int asnlen'
  1176. Length of bytes in `asnoid'.
  1177. `gcry_md_oid_spec_t *oids'
  1178. A list of OIDs that are to be associated with the algorithm.
  1179. The list's last element must have it's `oid' member set to
  1180. NULL. See below for an explanation of this type. See below
  1181. for an explanation of this type.
  1182. `int mdlen'
  1183. Length of the message digest algorithm. See below for an
  1184. explanation of this type.
  1185. `gcry_md_init_t init'
  1186. The function responsible for initializing a handle. See
  1187. below for an explanation of this type.
  1188. `gcry_md_write_t write'
  1189. The function responsible for writing data into a message
  1190. digest context. See below for an explanation of this type.
  1191. `gcry_md_final_t final'
  1192. The function responsible for `finalizing' a message digest
  1193. context. See below for an explanation of this type.
  1194. `gcry_md_read_t read'
  1195. The function responsible for reading out a message digest
  1196. result. See below for an explanation of this type.
  1197. `size_t contextsize'
  1198. The size of the algorithm-specific `context', that should be
  1199. allocated for each handle.
  1200. -- Data type: gcry_md_oid_spec_t
  1201. This type is used for associating a user-provided algorithm
  1202. implementation with certain OIDs. It contains the following
  1203. members:
  1204. `const char *oidstring'
  1205. Textual representation of the OID.
  1206. -- Data type: gcry_md_init_t
  1207. Type for the `init' function, defined as: void (*gcry_md_init_t)
  1208. (void *c)
  1209. -- Data type: gcry_md_write_t
  1210. Type for the `write' function, defined as: void (*gcry_md_write_t)
  1211. (void *c, unsigned char *buf, size_t nbytes)
  1212. -- Data type: gcry_md_final_t
  1213. Type for the `final' function, defined as: void (*gcry_md_final_t)
  1214. (void *c)
  1215. -- Data type: gcry_md_read_t
  1216. Type for the `read' function, defined as: unsigned char
  1217. *(*gcry_md_read_t) (void *c)
  1218. -- Function: gcry_error_t gcry_md_register (gcry_md_spec_t *DIGEST,
  1219. unsigned int *algorithm_id, gcry_module_t *MODULE)
  1220. Register a new digest module whose specification can be found in
  1221. DIGEST. On success, a new algorithm ID is stored in ALGORITHM_ID
  1222. and a pointer representing this module is stored in MODULE.
  1223. -- Function: void gcry_md_unregister (gcry_module_t MODULE)
  1224. Unregister the digest identified by MODULE, which must have been
  1225. registered with gcry_md_register.
  1226. -- Function: gcry_error_t gcry_md_list (int *LIST, int *LIST_LENGTH)
  1227. Get a list consisting of the IDs of the loaded message digest
  1228. modules. If LIST is zero, write the number of loaded message
  1229. digest modules to LIST_LENGTH and return. If LIST is non-zero,
  1230. the first *LIST_LENGTH algorithm IDs are stored in LIST, which
  1231. must be of according size. In case there are less message digests
  1232. modules than *LIST_LENGTH, *LIST_LENGTH is updated to the correct
  1233. number.
  1234. 
  1235. File: gcrypt.info, Node: Working with hash algorithms, Prev: Hash algorithm modules, Up: Hashing
  1236. 6.3 Working with hash algorithms
  1237. ================================
  1238. To use most of these function it is necessary to create a context; this
  1239. is done using:
  1240. -- Function: gcry_error_t gcry_md_open (gcry_md_hd_t *HD, int ALGO,
  1241. unsigned int FLAGS)
  1242. Create a message digest object for algorithm ALGO. FLAGS may be
  1243. given as an bitwise OR of constants described below. ALGO may be
  1244. given as `0' if the algorithms to use are later set using
  1245. `gcry_md_enable'. HD is guaranteed to either receive a valid
  1246. handle or NULL.
  1247. For a list of supported algorithms, see *Note Available hash
  1248. algorithms::.
  1249. The flags allowed for MODE are:
  1250. `GCRY_MD_FLAG_SECURE'
  1251. Allocate all buffers and the resulting digest in "secure
  1252. memory". Use this is the hashed data is highly confidential.
  1253. `GCRY_MD_FLAG_HMAC'
  1254. Turn the algorithm into a HMAC message authentication
  1255. algorithm. This does only work if just one algorithm is
  1256. enabled for the handle and SHA-384 and SHA512 is not used.
  1257. Note that the function `gcry_md_setkey' must be used set the
  1258. MAC key. If you want CBC message authentication codes based
  1259. on a cipher, see *Note Working with cipher handles::.
  1260. You may use the function `gcry_md_is_enabled' to later check
  1261. whether an algorithm has been enabled.
  1262. If you want to calculate several hash algorithms at the same time,
  1263. you have to use the following function right after the `gcry_md_open':
  1264. -- Function: gcry_error_t gcry_md_enable (gcry_md_hd_t H, int ALGO)
  1265. Add the message digest algorithm ALGO to the digest object
  1266. described by handle H. Duplicated enabling of algorithms is
  1267. detected and ignored.
  1268. If the flag `GCRY_MD_FLAG_HMAC' was used, the key for the MAC must
  1269. be set using the function:
  1270. -- Function: gcry_error_t gcry_md_setkey (gcry_md_hd_t H, const void
  1271. *KEY, size_t KEYLEN)
  1272. For use with the HMAC feature, set the MAC key to the value of KEY
  1273. of length KEYLEN.
  1274. After you are done with the hash calculation, you should release the
  1275. resources by using:
  1276. -- Function: void gcry_md_close (gcry_md_hd_t H)
  1277. Release all resources of hash context H. H should not be used
  1278. after a call to this function. A `NULL' passed as H is ignored.
  1279. Often you have to do several hash operations using the same
  1280. algorithm. To avoid the overhead of creating and releasing context, a
  1281. reset function is provided:
  1282. -- Function: void gcry_md_reset (gcry_md_hd_t H)
  1283. Reset the current context to its initial state. This is
  1284. effectively identical to a close followed by an open and enabling
  1285. all currently active algorithms.
  1286. Often it is necessary to start hashing some data and than continue to
  1287. hash different data. To avoid hashing the same data several times
  1288. (which might not even be possible if the data is received from a pipe),
  1289. a snapshot of the current hash context can be taken and turned into a
  1290. new context:
  1291. -- Function: gcry_error_t gcry_md_copy (gcry_md_hd_t *HANDLE_DST,
  1292. gcry_md_hd_t HANDLE_SRC)
  1293. Create a new digest object as an exact copy of the object
  1294. described by handle HANDLE_SRC and store it in HANDLE_DST. The
  1295. context is not reset and you can continue to hash data using this
  1296. context and independently using the original context.
  1297. Now that we have prepared everything to calculate hashes, its time to
  1298. see how it is actually done. There are 2 ways for this, one to update
  1299. the hash with a block of memory and one macro to update the hash by
  1300. just one character. Both may be used intermixed.
  1301. -- Function: void gcry_md_write (gcry_md_hd_t H, const void *BUFFER,
  1302. size_t LENGTH)
  1303. Pass LENGTH bytes of the data in BUFFER to the digest object with
  1304. handle H to update the digest values. This function should be used
  1305. for large blocks of data.
  1306. -- Function: void gcry_md_putc (gcry_md_hd_t H, int C)
  1307. Pass the byte in C to the digest object with handle H to update
  1308. the digest value. This is an efficient function, implemented as a
  1309. macro to buffer the data before an actual update.
  1310. The semantics of the hash functions don't allow to read out
  1311. intermediate message digests because the calculation must be finalized
  1312. fist. This finalization may for example include the number of bytes
  1313. hashed in the message digest.
  1314. -- Function: void gcry_md_final (gcry_md_hd_t H)
  1315. Finalize the message digest calculation. This is not really needed
  1316. because `gcry_md_read' does this implicitly. After this has been
  1317. done no further updates (by means of `gcry_md_write' or
  1318. `gcry_md_putc' are allowed. Only the first call to this function
  1319. has an effect. It is implemented as a macro.
  1320. The way to read out the calculated message digest is by using the
  1321. function:
  1322. -- Function: unsigned char *gcry_md_read (gcry_md_hd_t H, int ALGO)
  1323. `gcry_md_read' returns the message digest after finalizing the
  1324. calculation. This function may be used as often as required but
  1325. it will always return the same value for one handle. The returned
  1326. message digest is allocated within the message context and
  1327. therefore valid until the handle is released or reseted (using
  1328. `gcry_md_close' or `gcry_md_reset'. ALGO may be given as 0 to
  1329. return the only enabled message digest or it may specify one of
  1330. the enabled algorithms. The function does return `NULL' if the
  1331. requested algorithm has not been enabled.
  1332. Because it is often necessary to get the message digest of one block
  1333. of memory, a fast convenience function is available for this task:
  1334. -- Function: void gcry_md_hash_buffer (int ALGO, void *DIGEST, const
  1335. cvoid *BUFFER, size_t LENGTH);
  1336. `gcry_md_hash_buffer' is a shortcut function to calculate a message
  1337. digest of a buffer. This function does not require a context and
  1338. immediately returns the message digest of the LENGTH bytes at
  1339. BUFFER. DIGEST must be allocated by the caller, large enough to
  1340. hold the message digest yielded by the the specified algorithm
  1341. ALGO. This required size may be obtained by using the function
  1342. `gcry_md_get_algo_dlen'.
  1343. Note, that this function will abort the process if an unavailable
  1344. algorithm is used.
  1345. Hash algorithms are identified by internal algorithm numbers (see
  1346. `gcry_md_open' for a list. However, in most applications they are used
  1347. by names, so 2 functions are available to map between string
  1348. representations and hash algorithm identifiers.
  1349. -- Function: const char *gcry_md_algo_name (int ALGO)
  1350. Map the digest algorithm id ALGO to a string representation of the
  1351. algorithm name. For unknown algorithms this functions returns an
  1352. empty string. This function should not be used to test for the
  1353. availability of an algorithm.
  1354. -- Function: int gcry_md_map_name (const char *NAME)
  1355. Map the algorithm with NAME to a digest algorithm identifier.
  1356. Returns 0 if the algorithm name is not known. Names representing
  1357. ASN.1 object identifiers are recognized if the IETF dotted format
  1358. is used and the OID is prefixed with either "`oid.'" or "`OID.'".
  1359. For a list of supported OIDs, see the source code at
  1360. `cipher/md.c'. This function should not be used to test for the
  1361. availability of an algorithm.
  1362. -- Function: gcry_error_t gcry_md_get_asnoid (int ALGO, void *BUFFER,
  1363. size_t *LENGTH)
  1364. Return an DER encoded ASN.1 OID for the algorithm ALGO in the user
  1365. allocated BUFFER. LENGTH must point to variable with the available
  1366. size of BUFFER and receives after return the actual size of the
  1367. returned OID. The returned error code may be `GPG_ERR_TOO_SHORT'
  1368. if the provided buffer is to short to receive the OID; it is
  1369. possible to call the function with `NULL' for BUFFER to have it
  1370. only return the required size. The function returns 0 on success.
  1371. To test whether an algorithm is actually available for use, the
  1372. following macro should be used:
  1373. -- Function: gcry_error_t gcry_md_test_algo (int ALGO)
  1374. The macro returns 0 if the algorithm ALGO is available for use.
  1375. If the length of a message digest is not known, it can be retrieved
  1376. using the following function:
  1377. -- Function: unsigned int gcry_md_get_algo_dlen (int ALGO)
  1378. Retrieve the length in bytes of the digest yielded by algorithm
  1379. ALGO. This is often used prior to `gcry_md_read' to allocate
  1380. sufficient memory for the digest.
  1381. In some situations it might be hard to remember the algorithm used
  1382. for the ongoing hashing. The following function might be used to get
  1383. that information:
  1384. -- Function: int gcry_md_get_algo (gcry_md_hd_t H)
  1385. Retrieve the algorithm used with the handle H. Note, that this
  1386. does not work reliable if more than one algorithm is enabled in H.
  1387. The following macro might also be useful:
  1388. -- Function: int gcry_md_is_secure (gcry_md_hd_t H)
  1389. This function returns true when the digest object H is allocated
  1390. in "secure memory"; i.e. H was created with the
  1391. `GCRY_MD_FLAG_SECURE'.
  1392. -- Function: int gcry_md_is_enabled (gcry_md_hd_t H, int ALGO)
  1393. This function returns true when the algorithm ALGO has been
  1394. enabled for the digest object H.
  1395. Tracking bugs related to hashing is often a cumbersome task which
  1396. requires to add a lot of printf statements into the code. Libgcrypt
  1397. provides an easy way to avoid this. The actual data hashed can be
  1398. written to files on request. The following 2 macros should be used to
  1399. implement such a debugging facility:
  1400. -- Function: void gcry_md_start_debug (gcry_md_hd_t H, const char
  1401. *SUFFIX)
  1402. Enable debugging for the digest object with handle H. This
  1403. creates create files named `dbgmd-<n>.<string>' while doing the
  1404. actual hashing. SUFFIX is the string part in the filename. The
  1405. number is a counter incremented for each new hashing. The data in
  1406. the file is the raw data as passed to `gcry_md_write' or
  1407. `gcry_md_putc'.
  1408. -- Function: void gcry_md_stop_debug (gcry_md_hd_t H, int RESERVED)
  1409. Stop debugging on handle H. RESERVED should be specified as 0.
  1410. This function is usually not required because `gcry_md_close' does
  1411. implicitly stop debugging.
  1412. 
  1413. File: gcrypt.info, Node: Public Key cryptography (I), Next: Public Key cryptography (II), Prev: Hashing, Up: Top
  1414. 7 Public Key cryptography (I)
  1415. *****************************
  1416. Public key cryptography, also known as asymmetric cryptography, is an
  1417. easy way for key management and to provide digital signatures.
  1418. Libgcrypt provides two completely different interfaces to public key
  1419. cryptography, this chapter explains the one based on S-expressions.
  1420. * Menu:
  1421. * Available algorithms:: Algorithms supported by the library.
  1422. * Used S-expressions:: Introduction into the used S-expression.
  1423. * Public key modules:: How to work with public key modules.
  1424. * Cryptographic Functions:: Functions for performing the cryptographic actions.
  1425. * General public-key related Functions:: General functions, not implementing any cryptography.
  1426. 
  1427. File: gcrypt.info, Node: Available algorithms, Next: Used S-expressions, Up: Public Key cryptography (I)
  1428. 7.1 Available algorithms
  1429. ========================
  1430. Libgcrypt supports the RSA (Rivest-Shamir-Adleman) algorithms as well
  1431. as DSA (Digital Signature Algorithm) and ElGamal. The versatile
  1432. interface allows to add more algorithms in the future.
  1433. 
  1434. File: gcrypt.info, Node: Used S-expressions, Next: Public key modules, Prev: Available algorithms, Up: Public Key cryptography (I)
  1435. 7.2 Used S-expressions
  1436. ======================
  1437. Libgcrypt's API for asymmetric cryptography is based on data structures
  1438. called S-expressions (see XXXX) and does not work with contexts as most
  1439. of the other building blocks of Libgcrypt do.
  1440. The following information are stored in S-expressions:
  1441. keys
  1442. plain text data
  1443. encrypted data
  1444. signatures
  1445. To describe how Libgcrypt expect keys, we use some examples. Note that
  1446. words in uppercase indicate parameters whereas lowercase words are
  1447. literals.
  1448. (private-key
  1449. (dsa
  1450. (p P-MPI)
  1451. (q Q-MPI)
  1452. (g G-MPI)
  1453. (y Y-MPI)
  1454. (x X-MPI)))
  1455. This specifies a DSA private key with the following parameters:
  1456. P-MPI
  1457. DSA prime p.
  1458. Q-MPI
  1459. DSA group order q (which is a prime divisor of p-1).
  1460. G-MPI
  1461. DSA group generator g.
  1462. Y-MPI
  1463. DSA public key value y = g^x \bmod p.
  1464. X-MPI
  1465. DSA secret exponent x.
  1466. All the MPI values are expected to be in `GCRYMPI_FMT_USG' format.
  1467. The public key is similar with "private-key" replaced by "public-key"
  1468. and no X-MPI.
  1469. An easy way to create such an S-expressions is by using
  1470. `gcry_sexp_build' which allows to pass a string with printf-like
  1471. escapes to insert MPI values.
  1472. Here is an example for an RSA key:
  1473. (private-key
  1474. (rsa
  1475. (n N-MPI)
  1476. (e E-MPI)
  1477. (d D-MPI)
  1478. (p P-MPI)
  1479. (q Q-MPI)
  1480. (u U-MPI)
  1481. with
  1482. N-MPI
  1483. RSA public modulus n.
  1484. E-MPI
  1485. RSA public exponent e.
  1486. D-MPI
  1487. RSA secret exponent d = e^-1 \bmod (p-1)(q-1).
  1488. P-MPI
  1489. RSA secret prime p.
  1490. Q-MPI
  1491. RSA secret prime q with q > p.
  1492. U-MPI
  1493. multiplicative inverse u = p^-1 \bmod q.
  1494. 
  1495. File: gcrypt.info, Node: Public key modules, Next: Cryptographic Functions, Prev: Used S-expressions, Up: Public Key cryptography (I)
  1496. 7.3 Public key modules
  1497. ======================
  1498. Libgcrypt makes it possible to load additional `public key modules';
  1499. these public key algorithms can be used just like the algorithms that
  1500. are built into the library directly. For an introduction into
  1501. extension modules, see *Note Modules::.
  1502. -- Data type: gcry_pk_spec_t
  1503. This is the `module specification structure' needed for registering
  1504. public key modules, which has to be filled in by the user before it
  1505. can be used to register a module. It contains the following
  1506. members:
  1507. `const char *name'
  1508. The primary name of this algorithm.
  1509. `char **aliases'
  1510. A list of strings that are `aliases' for the algorithm. The
  1511. list must be terminated with a NULL element.
  1512. `const char *elements_pkey'
  1513. String containing the one-letter names of the MPI values
  1514. contained in a public key.
  1515. `const char *element_skey'
  1516. String containing the one-letter names of the MPI values
  1517. contained in a secret key.
  1518. `const char *elements_enc'
  1519. String containing the one-letter names of the MPI values that
  1520. are the result of an encryption operation using this
  1521. algorithm.
  1522. `const char *elements_sig'
  1523. String containing the one-letter names of the MPI values that
  1524. are the result of a sign operation using this algorithm.
  1525. `const char *elements_grip'
  1526. String containing the one-letter names of the MPI values that
  1527. are to be included in the `key grip'.
  1528. `int use'
  1529. The bitwise-OR of the following flags, depending on the
  1530. abilities of the algorithm:
  1531. `GCRY_PK_USAGE_SIGN'
  1532. The algorithm supports signing and verifying of data.
  1533. `GCRY_PK_USAGE_ENCR'
  1534. The algorithm supports the encryption and decryption of
  1535. data.
  1536. `gcry_pk_generate_t generate'
  1537. The function responsible for generating a new key pair. See
  1538. below for a description of this type.
  1539. `gcry_pk_check_secret_key_t check_secret_key'
  1540. The function responsible for checking the sanity of a
  1541. provided secret key. See below for a description of this
  1542. type.
  1543. `gcry_pk_encrypt_t encrypt'
  1544. The function responsible for encrypting data. See below for a
  1545. description of this type.
  1546. `gcry_pk_decrypt_t decrypt'
  1547. The function responsible for decrypting data. See below for a
  1548. description of this type.
  1549. `gcry_pk_sign_t sign'
  1550. The function responsible for signing data. See below for a
  1551. description of this type.
  1552. `gcry_pk_verify_t verify'
  1553. The function responsible for verifying that the provided
  1554. signature matches the provided data. See below for a
  1555. description of this type.
  1556. `gcry_pk_get_nbits_t get_nbits'
  1557. The function responsible for returning the number of bits of
  1558. a provided key. See below for a description of this type.
  1559. -- Data type: gcry_pk_generate_t
  1560. Type for the `generate' function, defined as: gcry_err_code_t
  1561. (*gcry_pk_generate_t) (int algo, unsigned int nbits, unsigned long
  1562. use_e, gcry_mpi_t *skey, gcry_mpi_t **retfactors)
  1563. -- Data type: gcry_pk_check_secret_key_t
  1564. Type for the `check_secret_key' function, defined as:
  1565. gcry_err_code_t (*gcry_pk_check_secret_key_t) (int algo,
  1566. gcry_mpi_t *skey)
  1567. -- Data type: gcry_pk_encrypt_t
  1568. Type for the `encrypt' function, defined as: gcry_err_code_t
  1569. (*gcry_pk_encrypt_t) (int algo, gcry_mpi_t *resarr, gcry_mpi_t
  1570. data, gcry_mpi_t *pkey, int flags)
  1571. -- Data type: gcry_pk_decrypt_t
  1572. Type for the `decrypt' function, defined as: gcry_err_code_t
  1573. (*gcry_pk_decrypt_t) (int algo, gcry_mpi_t *result, gcry_mpi_t
  1574. *data, gcry_mpi_t *skey, int flags)
  1575. -- Data type: gcry_pk_sign_t
  1576. Type for the `sign' function, defined as: gcry_err_code_t
  1577. (*gcry_pk_sign_t) (int algo, gcry_mpi_t *resarr, gcry_mpi_t data,
  1578. gcry_mpi_t *skey)
  1579. -- Data type: gcry_pk_verify_t
  1580. Type for the `verify' function, defined as: gcry_err_code_t
  1581. (*gcry_pk_verify_t) (int algo, gcry_mpi_t hash, gcry_mpi_t *data,
  1582. gcry_mpi_t *pkey, int (*cmp) (void *, gcry_mpi_t), void *opaquev)
  1583. -- Data type: gcry_pk_get_nbits_t
  1584. Type for the `get_nbits' function, defined as: unsigned
  1585. (*gcry_pk_get_nbits_t) (int algo, gcry_mpi_t *pkey)
  1586. -- Function: gcry_error_t gcry_pk_register (gcry_pk_spec_t *PUBKEY,
  1587. unsigned int *algorithm_id, gcry_module_t *MODULE)
  1588. Register a new public key module whose specification can be found
  1589. in PUBKEY. On success, a new algorithm ID is stored in
  1590. ALGORITHM_ID and a pointer representing this module is stored in
  1591. MODULE.
  1592. -- Function: void gcry_pk_unregister (gcry_module_t MODULE)
  1593. Unregister the public key module identified by MODULE, which must
  1594. have been registered with gcry_pk_register.
  1595. -- Function: gcry_error_t gcry_pk_list (int *LIST, int *LIST_LENGTH)
  1596. Get a list consisting of the IDs of the loaded pubkey modules. If
  1597. LIST is zero, write the number of loaded pubkey modules to
  1598. LIST_LENGTH and return. If LIST is non-zero, the first
  1599. *LIST_LENGTH algorithm IDs are stored in LIST, which must be of
  1600. according size. In case there are less pubkey modules than
  1601. *LIST_LENGTH, *LIST_LENGTH is updated to the correct number.
  1602. 
  1603. File: gcrypt.info, Node: Cryptographic Functions, Next: General public-key related Functions, Prev: Public key modules, Up: Public Key cryptography (I)
  1604. 7.4 Cryptographic Functions
  1605. ===========================
  1606. Note, that we will in future allow to use keys without p,q and u
  1607. specified and may also support other parameters for performance reasons.
  1608. Some functions operating on S-expressions support `flags', that
  1609. influence the operation. These flags have to be listed in a
  1610. sub-S-expression named `flags'; the following flags are known:
  1611. PKCS1
  1612. Use PKCS#1 block type 2 padding.
  1613. NO-BLINDING
  1614. Do not use a technique called `blinding', which is used by default
  1615. in order to prevent leaking of secret information. Blinding is
  1616. only implemented by RSA, but it might be implemented by other
  1617. algorithms in the future as well, when necessary.
  1618. Now that we know the key basics, we can carry on and explain how to
  1619. encrypt and decrypt data. In almost all cases the data is a random
  1620. session key which is in turn used for the actual encryption of the real
  1621. data. There are 2 functions to do this:
  1622. -- Function: gcry_error_t gcry_pk_encrypt (gcry_sexp_t *R_CIPH,
  1623. gcry_sexp_t DATA, gcry_sexp_t PKEY)
  1624. Obviously a public key must be provided for encryption. It is
  1625. expected as an appropriate S-expression (see above) in PKEY. The
  1626. data to be encrypted can either be in the simple old format, which
  1627. is a very simple S-expression consisting only of one MPI, or it
  1628. may be a more complex S-expression which also allows to specify
  1629. flags for operation, like e.g. padding rules.
  1630. If you don't want to let Libgcrypt handle the padding, you must
  1631. pass an appropriate MPI using this expression for DATA:
  1632. (data
  1633. (flags raw)
  1634. (value MPI))
  1635. This has the same semantics as the old style MPI only way. MPI is
  1636. the actual data, already padded appropriate for your protocol.
  1637. Most systems however use PKCS#1 padding and so you can use this
  1638. S-expression for DATA:
  1639. (data
  1640. (flags pkcs1)
  1641. (value BLOCK))
  1642. Here, the "flags" list has the "pkcs1" flag which let the function
  1643. know that it should provide PKCS#1 block type 2 padding. The
  1644. actual data to be encrypted is passed as a string of octets in
  1645. BLOCK. The function checks that this data actually can be used
  1646. with the given key, does the padding and encrypts it.
  1647. If the function could successfully perform the encryption, the
  1648. return value will be 0 and a a new S-expression with the encrypted
  1649. result is allocated and assign to the variable at the address of
  1650. R_CIPH. The caller is responsible to release this value using
  1651. `gcry_sexp_release'. In case of an error, an error code is
  1652. returned and R_CIPH will be set to `NULL'.
  1653. The returned S-expression has this format when used with RSA:
  1654. (enc-val
  1655. (rsa
  1656. (a A-MPI)))
  1657. Where A-MPI is an MPI with the result of the RSA operation. When
  1658. using the ElGamal algorithm, the return value will have this
  1659. format:
  1660. (enc-val
  1661. (elg
  1662. (a A-MPI)
  1663. (b B-MPI)))
  1664. Where A-MPI and B-MPI are MPIs with the result of the ElGamal
  1665. encryption operation.
  1666. -- Function: gcry_error_t gcry_pk_decrypt (gcry_sexp_t *R_PLAIN,
  1667. gcry_sexp_t DATA, gcry_sexp_t SKEY)
  1668. Obviously a private key must be provided for decryption. It is
  1669. expected as an appropriate S-expression (see above) in SKEY. The
  1670. data to be decrypted must match the format of the result as
  1671. returned by `gcry_pk_encrypt', but should be enlarged with a
  1672. `flags' element:
  1673. (enc-val
  1674. (flags)
  1675. (elg
  1676. (a A-MPI)
  1677. (b B-MPI)))
  1678. Note, that this function currently does not know of any padding
  1679. methods and the caller must do any un-padding on his own.
  1680. The function returns 0 on success or an error code. The variable
  1681. at the address of R_PLAIN will be set to NULL on error or receive
  1682. the decrypted value on success. The format of R_PLAIN is a simple
  1683. S-expression part (i.e. not a valid one) with just one MPI if
  1684. there was no `flags' element in DATA; if at least an empty `flags'
  1685. is passed in DATA, the format is:
  1686. (value PLAINTEXT)
  1687. Another operation commonly performed using public key cryptography is
  1688. signing data. In some sense this is even more important than
  1689. encryption because digital signatures are an important instrument for
  1690. key management. Libgcrypt supports digital signatures using 2
  1691. functions, similar to the encryption functions:
  1692. -- Function: gcry_error_t gcry_pk_sign (gcry_sexp_t *R_SIG,
  1693. gcry_sexp_t DATA, gcry_sexp_t SKEY)
  1694. This function creates a digital signature for DATA using the
  1695. private key SKEY and place it into the variable at the address of
  1696. R_SIG. DATA may either be the simple old style S-expression with
  1697. just one MPI or a modern and more versatile S-expression which
  1698. allows to let Libgcrypt handle padding:
  1699. (data
  1700. (flags pkcs1)
  1701. (hash HASH-ALGO BLOCK))
  1702. This example requests to sign the data in BLOCK after applying
  1703. PKCS#1 block type 1 style padding. HASH-ALGO is a string with the
  1704. hash algorithm to be encoded into the signature, this may be any
  1705. hash algorithm name as supported by Libgcrypt. Most likely, this
  1706. will be "sha1", "rmd160" or "md5". It is obvious that the length
  1707. of BLOCK must match the size of that message digests; the function
  1708. checks that this and other constraints are valid.
  1709. If PKCS#1 padding is not required (because the caller does already
  1710. provide a padded value), either the old format or better the
  1711. following format should be used:
  1712. (data
  1713. (flags raw)
  1714. (value MPI))
  1715. Here, the data to be signed is directly given as an MPI.
  1716. The signature is returned as a newly allocated S-expression in
  1717. R_SIG using this format for RSA:
  1718. (sig-val
  1719. (rsa
  1720. (s S-MPI)))
  1721. Where S-MPI is the result of the RSA sign operation. For DSA the
  1722. S-expression returned is:
  1723. (sig-val
  1724. (dsa
  1725. (r R-MPI)
  1726. (s S-MPI)))
  1727. Where R-MPI and S-MPI are the result of the DSA sign operation.
  1728. For ElGamal signing (which is slow, yields large numbers and
  1729. probably is not as secure as the other algorithms), the same
  1730. format is used with "elg" replacing "dsa".
  1731. The operation most commonly used is definitely the verification of a
  1732. signature. Libgcrypt provides this function:
  1733. -- Function: gcry_error_t gcry_pk_verify (gcry_sexp_t SIG,
  1734. gcry_sexp_t DATA, gcry_sexp_t PKEY)
  1735. This is used to check whether the signature SIG matches the DATA.
  1736. The public key PKEY must be provided to perform this verification.
  1737. This function is similar in its parameters to `gcry_pk_sign' with
  1738. the exceptions that the public key is used instead of the private
  1739. key and that no signature is created but a signature, in a format
  1740. as created by `gcry_pk_sign', is passed to the function in SIG.
  1741. The result is 0 for success (i.e. the data matches the signature),
  1742. or an error code where the most relevant code is
  1743. `GCRYERR_BAD_SIGNATURE' to indicate that the signature does not
  1744. match the provided data.
  1745. 
  1746. File: gcrypt.info, Node: General public-key related Functions, Prev: Cryptographic Functions, Up: Public Key cryptography (I)
  1747. 7.5 General public-key related Functions
  1748. ========================================
  1749. A couple of utility functions are available to retrieve the length of
  1750. the key, map algorithm identifiers and perform sanity checks:
  1751. -- Function: const char * gcry_pk_algo_name (int ALGO)
  1752. Map the public key algorithm id ALGO to a string representation of
  1753. the algorithm name. For unknown algorithms this functions returns
  1754. an empty string.
  1755. -- Function: int gcry_pk_map_name (const char *NAME)
  1756. Map the algorithm NAME to a public key algorithm Id. Returns 0 if
  1757. the algorithm name is not known.
  1758. -- Function: int gcry_pk_test_algo (int ALGO)
  1759. Return 0 if the public key algorithm ALGO is available for use.
  1760. Note, that this is implemented as a macro.
  1761. -- Function: unsigned int gcry_pk_get_nbits (gcry_sexp_t KEY)
  1762. Return what is commonly referred as the key length for the given
  1763. public or private in KEY.
  1764. -- Function: unsigned char * gcry_pk_get_keygrip (gcry_sexp_t KEY,
  1765. unsigned char *ARRAY)
  1766. Return the so called "keygrip" which is the SHA-1 hash of the
  1767. public key parameters expressed in a way depended on the
  1768. algorithm. ARRAY must either provide space for 20 bytes or
  1769. `NULL;'. In the latter case a newly allocated array of that size
  1770. is returned. On success a pointer to the newly allocated space or
  1771. to ARRAY is returned. `NULL' is returned to indicate an error
  1772. which is most likely an unknown algorithm or one where a "keygrip"
  1773. has not yet been defined. The function accepts public or secret
  1774. keys in KEY.
  1775. -- Function: gcry_error_t gcry_pk_testkey (gcry_sexp_t KEY)
  1776. Return zero if the private key KEY is `sane', an error code
  1777. otherwise. Note, that it is not possible to chek the `saneness'
  1778. of a public key.
  1779. -- Function: int gcry_pk_algo_info (int ALGO, int WHAT, void *BUFFER,
  1780. size_t *NBYTES)
  1781. Depending on the value of WHAT return various information about
  1782. the public key algorithm with the id ALGO. Note, that the
  1783. function returns `-1' on error and the actual error code must be
  1784. retrieved using the function `gcry_errno'. The currently defined
  1785. values for WHAT are:
  1786. `GCRYCTL_TEST_ALGO:'
  1787. Return 0 when the specified algorithm is available for use.
  1788. BUFFER must be `NULL', NBYTES may be passed as `NULL' or
  1789. point to a variable with the required usage of the algorithm.
  1790. This may be 0 for "don't care" or the bit-wise OR of these
  1791. flags:
  1792. `GCRY_PK_USAGE_SIGN'
  1793. Algorithm is usable for signing.
  1794. `GCRY_PK_USAGE_ENCR'
  1795. Algorithm is usable for encryption.
  1796. `GCRYCTL_GET_ALGO_USAGE:'
  1797. Return the usage flags for the given algorithm. An invalid
  1798. algorithm return 0. Disabled algorithms are ignored here
  1799. because we want to know whether the algorithm is at all
  1800. capable of a certain usage.
  1801. `GCRYCTL_GET_ALGO_NPKEY'
  1802. Return the number of elements the public key for algorithm
  1803. ALGO consist of. Return 0 for an unknown algorithm.
  1804. `GCRYCTL_GET_ALGO_NSKEY'
  1805. Return the number of elements the private key for algorithm
  1806. ALGO consist of. Note that this value is always larger than
  1807. that of the public key. Return 0 for an unknown algorithm.
  1808. `GCRYCTL_GET_ALGO_NSIGN'
  1809. Return the number of elements a signature created with the
  1810. algorithm ALGO consists of. Return 0 for an unknown
  1811. algorithm or for an algorithm not capable of creating
  1812. signatures.
  1813. `GCRYCTL_GET_ALGO_NENC'
  1814. Return the number of elements a encrypted message created
  1815. with the algorithm ALGO consists of. Return 0 for an unknown
  1816. algorithm or for an algorithm not capable of encryption.
  1817. Please note that parameters not required should be passed as
  1818. `NULL'.
  1819. -- Function: gcry_error_t gcry_pk_ctl (int CMD, void *BUFFER,
  1820. size_t BUFLEN)
  1821. This is a general purpose function to perform certain control
  1822. operations. CMD controls what is to be done. The return value is
  1823. 0 for success or an error code. Currently supported values for
  1824. CMD are:
  1825. `GCRYCTL_DISABLE_ALGO'
  1826. Disable the algorithm given as an algorithm id in BUFFER.
  1827. BUFFER must point to an `int' variable with the algorithm id
  1828. and BUFLEN must have the value `sizeof (int)'.
  1829. Libgcrypt also provides a function for generating public key pairs:
  1830. -- Function: gcry_error_t gcry_pk_genkey (gcry_sexp_t *R_KEY,
  1831. gcry_sexp_t PARMS)
  1832. This function create a new public key pair using information given
  1833. in the S-expression PARMS and stores the private and the public key
  1834. in one new S-expression at the address given by R_KEY. In case of
  1835. an error, R_KEY is set to `NULL'. The return code is 0 for
  1836. success or an error code otherwise.
  1837. Here is an example for PARMS for creating a 1024 bit RSA key:
  1838. (genkey
  1839. (rsa
  1840. (nbits 4:1024)))
  1841. To create an ElGamal key, substitute "elg" for "rsa" and to create
  1842. a DSA key use "dsa". Valid ranges for the key length depend on the
  1843. algorithms; all commonly used key lengths are supported. Currently
  1844. supported parameters are:
  1845. `nbits'
  1846. This is always required to specify the length of the key.
  1847. The argument is a string with a number in C-notation.
  1848. `rsa-use-e'
  1849. This is only used with RSA to give a hint for the public
  1850. exponent. The value will be used as a base to test for a
  1851. usable exponent. Some values are special:
  1852. `0'
  1853. Use a secure and fast value. This is currently the
  1854. number 41.
  1855. `1'
  1856. Use a secure value as required by some specification.
  1857. This is currently the number 65537.
  1858. `2'
  1859. Reserved
  1860. If this parameter is not used, Libgcrypt uses for historic
  1861. reasons 65537.
  1862. The key pair is returned in a format depending on the algorithm.
  1863. Both private and public keys are returned in one container and may
  1864. be accompanied by some miscellaneous information.
  1865. As an example, here is what the ElGamal key generation returns:
  1866. (key-data
  1867. (public-key
  1868. (elg
  1869. (p P-MPI)
  1870. (g G-MPI)
  1871. (y Y-MPI)))
  1872. (private-key
  1873. (elg
  1874. (p P-MPI)
  1875. (g G-MPI)
  1876. (y Y-MPI)
  1877. (x X-MPI)))
  1878. (misc-key-info
  1879. (pm1-factors N1 N2 ... NN)))
  1880. As you can see, some of the information is duplicated, but this
  1881. provides an easy way to extract either the public or the private
  1882. key. Note that the order of the elements is not defined, e.g. the
  1883. private key may be stored before the public key. N1 N2 ... NN is a
  1884. list of prime numbers used to composite P-MPI; this is in general
  1885. not a very useful information.
  1886. 
  1887. File: gcrypt.info, Node: Public Key cryptography (II), Next: Random Numbers, Prev: Public Key cryptography (I), Up: Top
  1888. 8 Public Key cryptography (II)
  1889. ******************************
  1890. This chapter documents the alternative interface to asymmetric
  1891. cryptography (ac) that is not based on S-expressions, but on native C
  1892. data structures. As opposed to the pk interface described in the
  1893. former chapter, this one follows an open/use/close paradigm like other
  1894. building blocks of the library.
  1895. * Menu:
  1896. * Available asymmetric algorithms:: List of algorithms supported by the library.
  1897. * Working with sets of data:: How to work with sets of data.
  1898. * Working with handles:: How to use handles.
  1899. * Working with keys:: How to work with keys.
  1900. * Using cryptographic functions:: How to perform cryptographic operations.
  1901. * Handle-independent functions:: General functions independent of handles.
  1902. 
  1903. File: gcrypt.info, Node: Available asymmetric algorithms, Next: Working with sets of data, Up: Public Key cryptography (II)
  1904. 8.1 Available asymmetric algorithms
  1905. ===================================
  1906. Libgcrypt supports the RSA (Rivest-Shamir-Adleman) algorithms as well
  1907. as DSA (Digital Signature Algorithm) and ElGamal. The versatile
  1908. interface allows to add more algorithms in the future.
  1909. -- Data type: gcry_ac_id_t
  1910. The following constants are defined for this type:
  1911. `GCRY_AC_RSA'
  1912. Riven-Shamir-Adleman
  1913. `GCRY_AC_DSA'
  1914. Digital Signature Algorithm
  1915. `GCRY_AC_ELG'
  1916. ElGamal
  1917. `GCRY_AC_ELG_E'
  1918. ElGamal, encryption only.
  1919. 
  1920. File: gcrypt.info, Node: Working with sets of data, Next: Working with handles, Prev: Available asymmetric algorithms, Up: Public Key cryptography (II)
  1921. 8.2 Working with sets of data
  1922. =============================
  1923. In the context of this interface the term `data set' refers to a list
  1924. of `named MPI values' that is used by functions performing
  1925. cryptographic operations.
  1926. Such data sets are used for representing keys, since keys simply
  1927. consist of a variable amount of numbers. Furthermore some functions
  1928. return data sets to the caller that are to be provided to other
  1929. functions.
  1930. This section documents the data types, symbols and functions that are
  1931. relevant for working with such data sets.
  1932. -- Data type: gcry_ac_data_t
  1933. A data set, that is simply a list of named MPI values.
  1934. The following flags are supported:
  1935. `GCRY_AC_FLAG_DEALLOC'
  1936. Used for storing data in a data set. If given, the data will be
  1937. released by the library.
  1938. `GCRY_AC_FLAG_COPY'
  1939. Used for storing/retrieving data in/from a data set. If given, the
  1940. library will create copies of the provided/contained data, which
  1941. will then be given to the user/associated with the data set.
  1942. -- Function: gcry_error_t gcry_ac_data_new (gcry_ac_data_t *DATA)
  1943. Creates a new, empty data set and stores it in DATA.
  1944. -- Function: void gcry_ac_data_destroy (gcry_ac_data_t DATA)
  1945. Destroys the data set DATA.
  1946. -- Function: gcry_error_t gcry_ac_data_set (gcry_ac_data_t DATA,
  1947. unsigned int FLAGS, char *NAME, gcry_mpi_t MPI)
  1948. Add the value MPI to DATA with the label NAME. If FLAGS contains
  1949. GCRY_AC_FLAG_DATA_COPY, the data set will contain copies of NAME
  1950. and MPI. If FLAGS contains GCRY_AC_FLAG_DATA_DEALLOC or
  1951. GCRY_AC_FLAG_DATA_COPY, the values contained in the data set will
  1952. be deallocated when they are to be removed from the data set.
  1953. -- Function: gcry_error_t gcry_ac_data_copy (gcry_ac_data_t *DATA_CP,
  1954. gcry_ac_data_t DATA)
  1955. Create a copy of the data set DATA and store it in DATA_CP.
  1956. -- Function: unsigned int gcry_ac_data_length (gcry_ac_data_t DATA)
  1957. Returns the number of named MPI values inside of the data set DATA.
  1958. -- Function: gcry_error_t gcry_ac_data_get_name (gcry_ac_data_t DATA,
  1959. unsigned int FLAGS, char *NAME, gcry_mpi_t *MPI)
  1960. Store the value labelled with NAME found in DATA in MPI. If FLAGS
  1961. contains GCRY_AC_FLAG_COPY, store a copy of the MPI value
  1962. contained in the data set. MPI may be NULL.
  1963. -- Function: gcry_error_t gcry_ac_data_get_index (gcry_ac_data_t DATA,
  1964. unsigned int flags, unsigned int INDEX, const char **NAME,
  1965. gcry_mpi_t *MPI)
  1966. Stores in NAME and MPI the named MPI value contained in the data
  1967. set DATA with the index IDX. If FLAGS contains GCRY_AC_FLAG_COPY,
  1968. store copies of the values contained in the data set. NAME or MPI
  1969. may be NULL.
  1970. -- Function: void gcry_ac_data_clear (gcry_ac_data_t DATA)
  1971. Destroys any values contained in the data set DATA.
  1972. 
  1973. File: gcrypt.info, Node: Working with handles, Next: Working with keys, Prev: Working with sets of data, Up: Public Key cryptography (II)
  1974. 8.3 Working with handles
  1975. ========================
  1976. In order to use an algorithm, an according handle must be created.
  1977. This is done using the following function:
  1978. -- Function: gcry_error_t gcry_ac_open (gcry_ac_handle_t *HANDLE, int
  1979. ALGORITHM, int FLAGS)
  1980. Creates a new handle for the algorithm ALGORITHM and stores it in
  1981. HANDLE. FLAGS is not used yet.
  1982. ALGORITHM must be a valid algorithm ID, see *Note Available
  1983. algorithms::, for a list of supported algorithms and the according
  1984. constants. Besides using the listed constants directly, the
  1985. functions `gcry_ac_name_to_id' may be used to convert the textual
  1986. name of an algorithm into the according numeric ID.
  1987. -- Function: void gcry_ac_close (gcry_ac_handle_t HANDLE)
  1988. Destroys the handle HANDLE.
  1989. 
  1990. File: gcrypt.info, Node: Working with keys, Next: Using cryptographic functions, Prev: Working with handles, Up: Public Key cryptography (II)
  1991. 8.4 Working with keys
  1992. =====================
  1993. -- Data type: gcry_ac_key_type_t
  1994. Defined constants:
  1995. `GCRY_AC_KEY_TYPE_SECRET'
  1996. Specifies a secret key.
  1997. `GCRY_AC_KEY_TYPE_PUBLIC'
  1998. Specifies a public key.
  1999. -- Data type: gcry_ac_key_t
  2000. This type represents a single `key', either a secret one or a
  2001. public one.
  2002. -- Data type: gcry_ac_key_pair_t
  2003. This type represents a `key pair' containing a secret and a public
  2004. key.
  2005. Key data structures can be created in two different ways; a new key
  2006. pair can be generated, resulting in ready-to-use key. Alternatively a
  2007. key can be initialized from a given data set.
  2008. -- Function: gcry_error_t gcry_ac_key_init (gcry_ac_key_t *KEY,
  2009. gcry_ac_handle_t HANDLE, gcry_ac_key_type_t TYPE,
  2010. gcry_ac_data_t DATA)
  2011. Creates a new key of type TYPE, consisting of the MPI values
  2012. contained in the data set DATA and stores it in KEY.
  2013. -- Function: gcry_error_t gcry_ac_key_pair_generate (gcry_ac_handle_t
  2014. HANDLE, unsigned int NBITS, void *KEY_SPEC,
  2015. gcry_ac_key_pair_t *KEY_PAIR, gcry_mpi_t **MISC_DATA)
  2016. Generates a new key pair via the handle HANDLE of NBITS bits and
  2017. stores it in KEY_PAIR.
  2018. In case non-standard settings are wanted, a pointer to a structure
  2019. of type `gcry_ac_key_spec_<algorithm>_t', matching the selected
  2020. algorithm, can be given as KEY_SPEC. MISC_DATA is not used yet.
  2021. Such a structure does only exist for RSA. A descriptions of the
  2022. members of the supported structures follows.
  2023. `gcry_ac_key_spec_rsa_t'
  2024. `gcry_mpi_t e'
  2025. Generate the key pair using a special `e'. The value of
  2026. `e' has the following meanings:
  2027. `= 0'
  2028. Let Libgcrypt device what exponent should be used.
  2029. `= 1'
  2030. Request the use of a "secure" exponent; this is
  2031. required by some specification to be 65537.
  2032. `> 2'
  2033. Try starting at this value until a working exponent
  2034. is found. Note, that the current implementation
  2035. leaks some information about the private key
  2036. because the incrementation used is not randomized.
  2037. Thus, this function will be changed in the future
  2038. to return a random exponent of the given size.
  2039. Example code:
  2040. {
  2041. gcry_ac_key_pair_t key_pair;
  2042. gcry_ac_key_spec_rsa rsa_spec;
  2043. rsa_spec.e = gcry_mpi_new (0);
  2044. gcry_mpi_set_ui (rsa_spec.e, 1)
  2045. err = gcry_ac_open (&handle, GCRY_AC_RSA, 0);
  2046. assert (! err);
  2047. err = gcry_ac_key_pair_generate (handle, &key_pair, 1024, (void *) &rsa_spec);
  2048. assert (! err);
  2049. }
  2050. -- Function: gcry_ac_key_t gcry_ac_key_pair_extract
  2051. (gcry_ac_key_pair_t KEY_PAIR, gcry_ac_key_type_t WHICH)
  2052. Returns the key of type WHICH out of the key pair KEY_PAIR.
  2053. -- Function: void gcry_ac_key_destroy (gcry_ac_key_t KEY)
  2054. Destroys the key KEY.
  2055. -- Function: void gcry_ac_key_pair_destroy (gcry_ac_key_pair_t
  2056. KEY_PAIR)
  2057. Destroys the key pair KEY_PAIR.
  2058. -- Function: gcry_ac_data_t gcry_ac_key_data_get (gcry_ac_key_t KEY)
  2059. Returns the data set contained in the key KEY.
  2060. -- Function: gcry_error_t gcry_ac_key_test (gcry_ac_handle_t HANDLE,
  2061. gcry_ac_key_t KEY)
  2062. Verifies that the private key KEY is sane via HANDLE.
  2063. -- Function: gcry_error_t gcry_ac_key_get_nbits (gcry_ac_handle_t
  2064. HANDLE, gcry_ac_key_t KEY, unsigned int *NBITS)
  2065. Stores the number of bits of the key KEY in NBITS via HANDLE.
  2066. -- Function: gcry_error_t gcry_ac_key_get_grip (gcry_ac_handle_t
  2067. HANDLE, gcry_ac_key_t KEY, unsigned char *KEY_GRIP)
  2068. Writes the 20 byte long key grip of the key KEY to KEY_GRIP via
  2069. HANDLE.
  2070. 
  2071. File: gcrypt.info, Node: Using cryptographic functions, Next: Handle-independent functions, Prev: Working with keys, Up: Public Key cryptography (II)
  2072. 8.5 Using cryptographic functions
  2073. =================================
  2074. The following flags might be relevant:
  2075. `GCRY_AC_FLAG_NO_BLINDING'
  2076. Disable any blinding, which might be supported by the chosen
  2077. algorithm; blinding is the default.
  2078. -- Function: gcry_error_t gcry_ac_data_encrypt (gcry_ac_handle_t
  2079. HANDLE, unsigned int FLAGS, gcry_ac_key_t KEY, gcry_mpi_t
  2080. DATA_PLAIN, gcry_ac_data_t **DATA_ENCRYPTED)
  2081. Encrypts the plain text MPI value DATA_PLAIN with the key public
  2082. KEY under the control of the flags FLAGS and stores the resulting
  2083. data set into DATA_ENCRYPTED.
  2084. -- Function: gcry_error_t gcry_ac_data_decrypt (gcry_ac_handle_t
  2085. HANDLE, unsigned int FLAGS, gcry_ac_key_t KEY, gcry_mpi_t
  2086. *DATA_PLAIN, gcry_ac_data_t DATA_ENCRYPTED)
  2087. Decrypts the encrypted data contained in the data set
  2088. DATA_ENCRYPTED with the secret key KEY under the control of the
  2089. flags FLAGS and stores the resulting plain text MPI value in
  2090. DATA_PLAIN.
  2091. -- Function: gcry_error_t gcry_ac_data_sign (gcry_ac_handle_t HANDLE,
  2092. gcry_ac_key_t KEY, gcry_mpi_t DATA, gcry_ac_data_t
  2093. *DATA_SIGNATURE)
  2094. Signs the data contained in DATA with the secret key KEY and
  2095. stores the resulting signature in the data set DATA_SIGNATURE.
  2096. -- Function: gcry_error_t gcry_ac_data_verify (gcry_ac_handle_t
  2097. HANDLE, gcry_ac_key_t KEY, gcry_mpi_t DATA, gcry_ac_data_t
  2098. DATA_SIGNATURE)
  2099. Verifies that the signature contained in the data set
  2100. DATA_SIGNATURE is indeed the result of signing the data contained
  2101. in DATA with the secret key belonging to the public key KEY.
  2102. 
  2103. File: gcrypt.info, Node: Handle-independent functions, Prev: Using cryptographic functions, Up: Public Key cryptography (II)
  2104. 8.6 Handle-independent functions
  2105. ================================
  2106. -- Function: gcry_error_t gcry_ac_id_to_name (gcry_ac_id_t ALGORITHM,
  2107. const char **NAME)
  2108. Stores the textual representation of the algorithm whose id is
  2109. given in ALGORITHM in NAME.
  2110. -- Function: gcry_error_t gcry_ac_name_to_id (const char *NAME,
  2111. gcry_ac_id_t *ALGORITHM)
  2112. Stores the numeric ID of the algorithm whose textual
  2113. representation is contained in NAME in ALGORITHM.
  2114. 
  2115. File: gcrypt.info, Node: Random Numbers, Next: S-expressions, Prev: Public Key cryptography (II), Up: Top
  2116. 9 Random Numbers
  2117. ****************
  2118. * Menu:
  2119. * Quality of random numbers:: Libgcrypt uses different quality levels.
  2120. * Retrieving random numbers:: How to retrieve random numbers.
  2121. 
  2122. File: gcrypt.info, Node: Quality of random numbers, Next: Retrieving random numbers, Up: Random Numbers
  2123. 9.1 Quality of random numbers
  2124. =============================
  2125. Libgcypt offers random numbers of different quality levels:
  2126. -- Data type: enum gcry_random_level
  2127. The constants for the random quality levels are of this type.
  2128. `GCRY_WEAK_RANDOM'
  2129. This should not anymore be used. It has recently been changed to
  2130. an alias of GCRY_STRONG_RANDOM. Use `gcry_create_nonce' instead.
  2131. `GCRY_STRONG_RANDOM'
  2132. Use this level for e.g. session keys and similar purposes.
  2133. `GCRY_VERY_STRONG_RANDOM'
  2134. Use this level for e.g. key material.
  2135. 
  2136. File: gcrypt.info, Node: Retrieving random numbers, Prev: Quality of random numbers, Up: Random Numbers
  2137. 9.2 Retrieving random numbers
  2138. =============================
  2139. -- Function: void gcry_randomize (unsigned char *BUFFER, size_t
  2140. LENGTH, enum gcry_random_level LEVEL)
  2141. Fill BUFFER with LENGTH random bytes using a random quality as
  2142. defined by LEVEL.
  2143. -- Function: void * gcry_random_bytes (size_t NBYTES, enum
  2144. gcry_random_level LEVEL)
  2145. Allocate a memory block consisting of NBYTES fresh random bytes
  2146. using a random quality as defined by LEVEL.
  2147. -- Function: void * gcry_random_bytes_secure (size_t NBYTES, enum
  2148. gcry_random_level LEVEL)
  2149. Allocate a memory block consisting of NBYTES fresh random bytes
  2150. using a random quality as defined by LEVEL. This function differs
  2151. from `gcry_random_bytes' in that the returned buffer is allocated
  2152. in a "secure" area of the memory.
  2153. -- Function: void gcry_create_nonce (void *BUFFER, size_t LENGTH)
  2154. Fill BUFFER with LENGTH unpredictable bytes. This is commonly
  2155. called a nonce and may also be used for initialization vectors and
  2156. padding. This is an extra function nearly independent of the
  2157. other random function for 3 reasons: It better protects the
  2158. regular random generator's internal state, provides better
  2159. performance and does not drain the precious entropy pool.
  2160. 
  2161. File: gcrypt.info, Node: S-expressions, Next: MPI library, Prev: Random Numbers, Up: Top
  2162. 10 S-expressions
  2163. ****************
  2164. S-expressions are used by the public key functions to pass complex data
  2165. structures around. These LISP like objects are used by some
  2166. cryptographic protocols (cf. RFC-2692) and Libgcrypt provides functions
  2167. to parse and construct them. For detailed information, see `Ron
  2168. Rivest, code and description of S-expressions,
  2169. `http://theory.lcs.mit.edu/~rivest/sexp.html''.
  2170. * Menu:
  2171. * Data types for S-expressions:: Data types related with S-expressions.
  2172. * Working with S-expressions:: How to work with S-expressions.
  2173. 
  2174. File: gcrypt.info, Node: Data types for S-expressions, Next: Working with S-expressions, Up: S-expressions
  2175. 10.1 Data types for S-expressions
  2176. =================================
  2177. -- Data type: gcry_sexp_t
  2178. The `gcry_sexp_t' type describes an object with the Libgcrypt
  2179. internal representation of an S-expression.
  2180. 
  2181. File: gcrypt.info, Node: Working with S-expressions, Prev: Data types for S-expressions, Up: S-expressions
  2182. 10.2 Working with S-expressions
  2183. ===============================
  2184. There are several functions to create an Libgcrypt S-expression object
  2185. from its external representation or from a string template. There is
  2186. also a function to convert the internal representation back into one of
  2187. the external formats:
  2188. -- Function: gcry_error_t gcry_sexp_new (gcry_sexp_t *R_SEXP,
  2189. const void *BUFFER, size_t LENGTH, int AUTODETECT)
  2190. This is the generic function to create an new S-expression object
  2191. from its external representation in BUFFER of LENGTH bytes. On
  2192. success the result is stored at the address given by R_SEXP. With
  2193. AUTODETECT set to 0, the data in BUFFER is expected to be in
  2194. canonized format, with AUTODETECT set to 1 the parses any of the
  2195. defined external formats. If BUFFER does not hold a valid
  2196. S-expression an error code is returned and R_SEXP set to `NULL'.
  2197. Note, that the caller is responsible for releasing the newly
  2198. allocated S-expression using `gcry_sexp_release'.
  2199. -- Function: gcry_error_t gcry_sexp_create (gcry_sexp_t *R_SEXP,
  2200. void *BUFFER, size_t LENGTH, int AUTODETECT,
  2201. void (*FREEFNC)(void*))
  2202. This function is identical to `gcry_sexp_new' but has an extra
  2203. argument FREEFNC, which, when not set to `NULL', is expected to be
  2204. a function to release the BUFFER; most likely the standard `free'
  2205. function is used for this argument. This has the effect of
  2206. transferring the ownership of BUFFER to the created object in
  2207. R_SEXP. The advantage of using this function is that Libgcrypt
  2208. might decide to directly use the provided buffer and thus avoid
  2209. extra copying.
  2210. -- Function: gcry_error_t gcry_sexp_sscan (gcry_sexp_t *R_SEXP,
  2211. size_t *ERROFF, const char *BUFFER, size_t LENGTH)
  2212. This is another variant of the above functions. It behaves nearly
  2213. identical but provides an ERROFF argument which will receive the
  2214. offset into the buffer where the parsing stopped on error.
  2215. -- Function: gcry_error_t gcry_sexp_build (gcry_sexp_t *R_SEXP,
  2216. size_t *ERROFF, const char *FORMAT, ...)
  2217. This function creates an internal S-expression from the string
  2218. template FORMAT and stores it at the address of R_SEXP. If there
  2219. is a parsing error, the function returns an appropriate error code
  2220. and stores the offset into FORMAT where the parsing stopped in
  2221. ERROFF. The function supports a couple of printf-like formatting
  2222. characters and expects arguments for some of these escape
  2223. sequences right after FORMAT. The following format characters are
  2224. defined:
  2225. `%m'
  2226. The next argument is expected to be of type `gcry_mpi_t' and
  2227. a copy of its value is inserted into the resulting
  2228. S-expression.
  2229. `%s'
  2230. The next argument is expected to be of type `char *' and that
  2231. string is inserted into the resulting S-expression.
  2232. `%d'
  2233. The next argument is expected to be of type `int' and its
  2234. value ist inserted into the resulting S-expression.
  2235. `%b'
  2236. The next argument is expected to be of type `int' directly
  2237. followed by an argument of type `char *'. This represents a
  2238. buffer of given length to be inserted into the resulting
  2239. regular expression.
  2240. No other format characters are defined and would return an error.
  2241. Note, that the format character `%%' does not exists, because a
  2242. percent sign is not a valid character in an S-expression.
  2243. -- Function: void gcry_sexp_release (gcry_sexp_t SEXP)
  2244. Release the S-expression object SEXP.
  2245. The next 2 functions are used to convert the internal representation
  2246. back into a regular external S-expression format and to show the
  2247. structure for debugging.
  2248. -- Function: size_t gcry_sexp_sprint (gcry_sexp_t SEXP, int MODE,
  2249. void *BUFFER, size_t MAXLENGTH)
  2250. Copies the S-expression object SEXP into BUFFER using the format
  2251. specified in MODE. MAXLENGTH must be set to the allocated length
  2252. of BUFFER. The function returns the actual length of valid bytes
  2253. put into BUFFER or 0 if the provided buffer is too short. Passing
  2254. `NULL' for BUFFER returns the required length for BUFFER. For
  2255. convenience reasons an extra byte with value 0 is appended to the
  2256. buffer.
  2257. The following formats are supported:
  2258. `GCRYSEXP_FMT_DEFAULT'
  2259. Returns a convenient external S-expression representation.
  2260. `GCRYSEXP_FMT_CANON'
  2261. Return the S-expression in canonical format.
  2262. `GCRYSEXP_FMT_BASE64'
  2263. Not currently supported.
  2264. `GCRYSEXP_FMT_ADVANCED'
  2265. Returns the S-expression in advanced format.
  2266. -- Function: void gcry_sexp_dump (gcry_sexp_t SEXP)
  2267. Dumps SEXP in a format suitable for debugging to Libgcrypt's
  2268. logging stream.
  2269. Often canonical encoding is used in the external representation. The
  2270. following function can be used to check for valid encoding and to learn
  2271. the length of the S-expression"
  2272. -- Function: size_t gcry_sexp_canon_len (const unsigned char *BUFFER,
  2273. size_t LENGTH, size_t *ERROFF, int *ERRCODE)
  2274. Scan the canonical encoded BUFFER with implicit length values and
  2275. return the actual length this S-expression uses. For a valid
  2276. S-expression it should never return 0. If LENGTH is not 0, the
  2277. maximum length to scan is given; this can be used for syntax
  2278. checks of data passed from outside. ERRCODE and ERROFF may both be
  2279. passed as `NULL'.
  2280. There are a couple of functions to parse S-expressions and retrieve
  2281. elements:
  2282. -- Function: gcry_sexp_t gcry_sexp_find_token (const gcry_sexp_t LIST,
  2283. const char *TOKEN, size_t TOKLEN)
  2284. Scan the S-expression for a sublist with a type (the car of the
  2285. list) matching the string TOKEN. If TOKLEN is not 0, the token is
  2286. assumed to be raw memory of this length. The function returns a
  2287. newly allocated S-expression consisting of the found sublist or
  2288. `NULL' when not found.
  2289. -- Function: int gcry_sexp_length (const gcry_sexp_t LIST)
  2290. Return the length of the LIST. For a valid S-expression this
  2291. should be at least 1.
  2292. -- Function: gcry_sexp_t gcry_sexp_nth (const gcry_sexp_t LIST,
  2293. int NUMBER)
  2294. Create and return a new S-expression from the element with index
  2295. NUMBER in LIST. Note that the first element has the index 0. If
  2296. there is no such element, `NULL' is returned.
  2297. -- Function: gcry_sexp_t gcry_sexp_car (const gcry_sexp_t LIST)
  2298. Create and return a new S-expression from the first element in
  2299. LIST; this called the "type" and should always exist and be a
  2300. string. `NULL' is returned in case of a problem.
  2301. -- Function: gcry_sexp_t gcry_sexp_cdr (const gcry_sexp_t LIST)
  2302. Create and return a new list form all elements except for the
  2303. first one. Note, that this function may return an invalid
  2304. S-expression because it is not guaranteed, that the type exists
  2305. and is a string. However, for parsing a complex S-expression it
  2306. might be useful for intermediate lists. Returns `NULL' on error.
  2307. -- Function: const char * gcry_sexp_nth_data (const gcry_sexp_t LIST,
  2308. int NUMBER, size_t *DATALEN)
  2309. This function is used to get data from a LIST. A pointer to the
  2310. actual data with index NUMBER is returned and the length of this
  2311. data will be stored to DATALEN. If there is no data at the given
  2312. index or the index represents another list, `NULL' is returned.
  2313. *Take care:* The returned pointer is valid as long as LIST is not
  2314. modified or released.
  2315. Here is an example on how to extract and print the surname (Meier)
  2316. from the S-expression `(Name Otto Meier (address Burgplatz 3))':
  2317. size_t len;
  2318. const char *name;
  2319. name = gcry_sexp_nth_data (list, 2, &len);
  2320. printf ("my name is %.*s\n", (int)len, name);
  2321. -- Function: gcry_mpi_t gcry_sexp_nth_mpi (gcry_sexp_t LIST,
  2322. int NUMBER, int MPIFMT)
  2323. This function is used to get and convert data from a LIST. This
  2324. data is assumed to be an MPI stored in the format described by
  2325. MPIFMT and returned as a standard Libgcrypt MPI. The caller must
  2326. release this returned value using `gcry_mpi_release'. If there is
  2327. no data at the given index, the index represents a list or the
  2328. value can't be converted to an MPI, `NULL' is returned.
  2329. 
  2330. File: gcrypt.info, Node: MPI library, Next: Utilities, Prev: S-expressions, Up: Top
  2331. 11 MPI library
  2332. **************
  2333. * Menu:
  2334. * Data types:: MPI related data types.
  2335. * Basic functions:: First steps with MPI numbers.
  2336. * MPI formats:: External representation of MPIs.
  2337. * Calculations:: Performing MPI calculations.
  2338. * Comparisons:: How to compare MPI values.
  2339. * Bit manipulations:: How to access single bits of MPI values.
  2340. * Miscellaneous:: Miscellaneous MPI functions.
  2341. Public key cryptography is based on mathematics with large numbers.
  2342. To implement the public key functions, a library for handling these
  2343. large numbers is required. Because of the general usefulness of such a
  2344. library, its interface is exposed by Libgcrypt. The implementation is
  2345. based on an old release of GNU Multi-Precision Library (GMP) but in the
  2346. meantime heavily modified and stripped down to what is required for
  2347. cryptography. For a lot of CPUs, high performance assembler
  2348. implementations of some very low level functions are used to gain much
  2349. better performance than with the standard C implementation.
  2350. In the context of Libgcrypt and in most other applications, these large
  2351. numbers are called MPIs (multi-precision-integers).
  2352. 
  2353. File: gcrypt.info, Node: Data types, Next: Basic functions, Up: MPI library
  2354. 11.1 Data types
  2355. ===============
  2356. -- Data type: gcry_mpi_t
  2357. The `gcry_mpi_t' type represents an object to hold an MPI.
  2358. 
  2359. File: gcrypt.info, Node: Basic functions, Next: MPI formats, Prev: Data types, Up: MPI library
  2360. 11.2 Basic functions
  2361. ====================
  2362. To work with MPIs, storage must be allocated and released for the
  2363. numbers. This can be done with one of these functions:
  2364. -- Function: gcry_mpi_t gcry_mpi_new (unsigned int NBITS)
  2365. Allocate a new MPI object, initialize it to 0 and initially
  2366. allocate enough memory for a number of at least NBITS. This
  2367. pre-allocation is only a small performance issue and not actually
  2368. necessary because Libgcrypt automatically re-allocates the
  2369. required memory.
  2370. -- Function: gcry_mpi_t gcry_mpi_snew (unsigned int NBITS)
  2371. This is identical to `gcry_mpi_new' but allocates the MPI in the so
  2372. called "secure memory" which in turn will take care that all
  2373. derived values will also be stored in this "secure memory". Use
  2374. this for highly confidential data like private key parameters.
  2375. -- Function: gcry_mpi_t gcry_mpi_copy (const gcry_mpi_t A)
  2376. Create a new MPI as the exact copy of A.
  2377. -- Function: void gcry_mpi_release (gcry_mpi_t A)
  2378. Release the MPI A and free all associated resources. Passing
  2379. `NULL' is allowed and ignored. When a MPI stored in the "secure
  2380. memory" is released, that memory gets wiped out immediately.
  2381. The simplest operations are used to assign a new value to an MPI:
  2382. -- Function: gcry_mpi_t gcry_mpi_set (gcry_mpi_t W, const gcry_mpi_t U)
  2383. Assign the value of U to W and return W. If `NULL' is passed for
  2384. W, a new MPI is allocated, set to the value of U and returned.
  2385. -- Function: gcry_mpi_t gcry_mpi_set_ui (gcry_mpi_t W, unsigned long U)
  2386. Assign the value of U to W and return W. If `NULL' is passed for
  2387. W, a new MPI is allocated, set to the value of U and returned.
  2388. This function takes an `unsigned int' as type for U and thus it is
  2389. only possible to set W to small values (usually up to the word
  2390. size of the CPU).
  2391. -- Function: void gcry_mpi_swap (gcry_mpi_t A, gcry_mpi_t B)
  2392. Swap the values of A and B.
  2393. 
  2394. File: gcrypt.info, Node: MPI formats, Next: Calculations, Prev: Basic functions, Up: MPI library
  2395. 11.3 MPI formats
  2396. ================
  2397. The following functions are used to convert between an external
  2398. representation of an MPI and the internal one of Libgcrypt.
  2399. -- Function: int gcry_mpi_scan (gcry_mpi_t *R_MPI,
  2400. enum gcry_mpi_format FORMAT, const void *BUFFER,
  2401. size_t BUFLEN, size_t *NSCANNED)
  2402. Convert the external representation of an integer stored in BUFFER
  2403. with a length of BUFLEN into a newly created MPI returned which
  2404. will be stored at the address of R_MPI. For certain formats the
  2405. length argument is not required and may be passed as `0'. After a
  2406. successful operation the variable NSCANNED receives the number of
  2407. bytes actually scanned unless NSCANNED was given as `NULL'. FORMAT
  2408. describes the format of the MPI as stored in BUFFER:
  2409. `GCRYMPI_FMT_STD'
  2410. 2-complement stored without a length header.
  2411. `GCRYMPI_FMT_PGP'
  2412. As used by OpenPGP (only defined as unsigned). This is
  2413. basically `GCRYMPI_FMT_STD' with a 2 byte big endian length
  2414. header.
  2415. `GCRYMPI_FMT_SSH'
  2416. As used in the Secure Shell protocol. This is
  2417. `GCRYMPI_FMT_STD' with a 4 byte big endian header.
  2418. `GCRYMPI_FMT_HEX'
  2419. Stored as a C style string with each byte of the MPI encoded
  2420. as 2 hex digits.
  2421. `GCRYMPI_FMT_USG'
  2422. Simple unsigned integer.
  2423. Note, that all of the above formats store the integer in big-endian
  2424. format (MSB first).
  2425. -- Function: int gcry_mpi_print (enum gcry_mpi_format FORMAT,
  2426. unsigned char *BUFFER, size_t BUFLEN, size_t *NWRITTEN,
  2427. const gcry_mpi_t A)
  2428. Convert the MPI A into an external representation described by
  2429. FORMAT (see above) and store it in the provided BUFFER which has a
  2430. usable length of at least the BUFLEN bytes. If NWRITTEN is not
  2431. NULL, it will receive the number of bytes actually stored in
  2432. BUFFER after a successful operation.
  2433. -- Function: int gcry_mpi_aprint (enum gcry_mpi_format FORMAT,
  2434. unsigned char **BUFFER, size_t *NBYTES, const gcry_mpi_t A)
  2435. Convert the MPI A into an external representation described by
  2436. FORMAT (see above) and store it in a newly allocated buffer which
  2437. address will be stored in the variable BUFFER points to. The
  2438. number of bytes stored in this buffer will be stored in the
  2439. variable NBYTES points to, unless NBYTES is `NULL'.
  2440. -- Function: void gcry_mpi_dump (const gcry_mpi_t A)
  2441. Dump the value of A in a format suitable for debugging to
  2442. Libgcrypt's logging stream. Note that one leading space but no
  2443. trailing space or linefeed will be printed. It is okay to pass
  2444. `NULL' for A.
  2445. 
  2446. File: gcrypt.info, Node: Calculations, Next: Comparisons, Prev: MPI formats, Up: MPI library
  2447. 11.4 Calculations
  2448. =================
  2449. Basic arithmetic operations:
  2450. -- Function: void gcry_mpi_add (gcry_mpi_t W, gcry_mpi_t U,
  2451. gcry_mpi_t V)
  2452. W = U + V.
  2453. -- Function: void gcry_mpi_add_ui (gcry_mpi_t W, gcry_mpi_t U,
  2454. unsigned long V)
  2455. W = U + V. Note, that V is an unsigned integer.
  2456. -- Function: void gcry_mpi_addm (gcry_mpi_t W, gcry_mpi_t U,
  2457. gcry_mpi_t V, gcry_mpi_t M)
  2458. W = U + V \bmod M.
  2459. -- Function: void gcry_mpi_sub (gcry_mpi_t W, gcry_mpi_t U,
  2460. gcry_mpi_t V)
  2461. W = U - V.
  2462. -- Function: void gcry_mpi_sub_ui (gcry_mpi_t W, gcry_mpi_t U,
  2463. unsigned long V)
  2464. W = U - V. V is an unsigned integer.
  2465. -- Function: void gcry_mpi_subm (gcry_mpi_t W, gcry_mpi_t U,
  2466. gcry_mpi_t V, gcry_mpi_t M)
  2467. W = U - V \bmod M.
  2468. -- Function: void gcry_mpi_mul (gcry_mpi_t W, gcry_mpi_t U,
  2469. gcry_mpi_t V)
  2470. W = U * V.
  2471. -- Function: void gcry_mpi_mul_ui (gcry_mpi_t W, gcry_mpi_t U,
  2472. unsigned long V)
  2473. W = U * V. V is an unsigned integer.
  2474. -- Function: void gcry_mpi_mulm (gcry_mpi_t W, gcry_mpi_t U,
  2475. gcry_mpi_t V, gcry_mpi_t M)
  2476. W = U * V \bmod M.
  2477. -- Function: void gcry_mpi_mul_2exp (gcry_mpi_t W, gcry_mpi_t U,
  2478. unsigned long E)
  2479. W = U * 2^e.
  2480. -- Function: void gcry_mpi_div (gcry_mpi_t Q, gcry_mpi_t R,
  2481. gcry_mpi_t DIVIDEND, gcry_mpi_t DIVISOR, int ROUND)
  2482. Q = DIVIDEND / DIVISOR, R = DIVIDEND \bmod DIVISOR. Q and R may
  2483. be passed as `NULL'. ROUND should be negative or 0.
  2484. -- Function: void gcry_mpi_mod (gcry_mpi_t R, gcry_mpi_t DIVIDEND,
  2485. gcry_mpi_t DIVISOR)
  2486. R = DIVIDEND \bmod DIVISOR.
  2487. -- Function: void gcry_mpi_powm (gcry_mpi_t W, const gcry_mpi_t B,
  2488. const gcry_mpi_t E, const gcry_mpi_t M)
  2489. W = B^e \bmod M.
  2490. -- Function: int gcry_mpi_gcd (gcry_mpi_t G, gcry_mpi_t A,
  2491. gcry_mpi_t B)
  2492. Set G to the greatest common divisor of A and B. Return true if
  2493. the G is 1.
  2494. -- Function: int gcry_mpi_invm (gcry_mpi_t X, gcry_mpi_t A,
  2495. gcry_mpi_t M)
  2496. Set X to the multiplicative inverse of A \bmod M. Return true if
  2497. the inverse exists.
  2498. 
  2499. File: gcrypt.info, Node: Comparisons, Next: Bit manipulations, Prev: Calculations, Up: MPI library
  2500. 11.5 Comparisons
  2501. ================
  2502. The next 2 functions are used to compare MPIs:
  2503. -- Function: int gcry_mpi_cmp (const gcry_mpi_t U, const gcry_mpi_t V)
  2504. Compare the big integer number U and V returning 0 for equality, a
  2505. positive value for U > V and a negative for U < V.
  2506. -- Function: int gcry_mpi_cmp_ui (const gcry_mpi_t U, unsigned long V)
  2507. Compare the big integer number U with the unsigned integer V
  2508. returning 0 for equality, a positive value for U > V and a
  2509. negative for U < V.
  2510. 
  2511. File: gcrypt.info, Node: Bit manipulations, Next: Miscellaneous, Prev: Comparisons, Up: MPI library
  2512. 11.6 Bit manipulations
  2513. ======================
  2514. There are a couple of functions to get information on arbitrary bits in
  2515. an MPI and to set or clear them:
  2516. -- Function: unsigned int gcry_mpi_get_nbits (gcry_mpi_t A)
  2517. Return the number of bits required to represent A.
  2518. -- Function: int gcry_mpi_test_bit (gcry_mpi_t A, unsigned int N)
  2519. Return true if bit number N (counting from 0) is set in A.
  2520. -- Function: void gcry_mpi_set_bit (gcry_mpi_t A, unsigned int N)
  2521. Set bit number N in A.
  2522. -- Function: void gcry_mpi_clear_bit (gcry_mpi_t A, unsigned int N)
  2523. Clear bit number N in A.
  2524. -- Function: void gcry_mpi_set_highbit (gcry_mpi_t A, unsigned int N)
  2525. Set bit number N in A and clear all bits greater than N.
  2526. -- Function: void gcry_mpi_clear_highbit (gcry_mpi_t A, unsigned int N)
  2527. Clear bit number N in A and all bits greater than N.
  2528. -- Function: void gcry_mpi_rshift (gcry_mpi_t X, gcry_mpi_t A,
  2529. unsigned int N)
  2530. Shift the value of A by N bits to the right and store the result
  2531. in X.
  2532. 
  2533. File: gcrypt.info, Node: Miscellaneous, Prev: Bit manipulations, Up: MPI library
  2534. 11.7 Miscellanous
  2535. =================
  2536. -- Function: gcry_mpi_t gcry_mpi_set_opaque (gcry_mpi_t A, void *P,
  2537. unsigned int NBITS)
  2538. Store NBITS of the value P points to in A and mark A as an opaque
  2539. value (i.e. an value that can't be used for any math calculation
  2540. and is only used to store an arbitrary bit pattern in A).
  2541. WARNING: Never use an opaque MPI for actual math operations. The
  2542. only valid functions are gcry_mpi_get_opaque and gcry_mpi_release.
  2543. Use gcry_mpi_scan to convert a string of arbitrary bytes into an
  2544. MPI.
  2545. -- Function: void * gcry_mpi_get_opaque (gcry_mpi_t A,
  2546. unsigned int *NBITS)
  2547. Return a pointer to an opaque value stored in A and return its
  2548. size in NBITS. Note, that the returned pointer is still owned by
  2549. A and that the function should never be used for an non-opaque MPI.
  2550. -- Function: void gcry_mpi_set_flag (gcry_mpi_t A,
  2551. enum gcry_mpi_flag FLAG)
  2552. Set the FLAG for the MPI A. Currently only the flag
  2553. `GCRYMPI_FLAG_SECURE' is allowed to convert A into an MPI stored
  2554. in "secure memory".
  2555. -- Function: void gcry_mpi_clear_flag (gcry_mpi_t A,
  2556. enum gcry_mpi_flag FLAG)
  2557. Clear FLAG for the big integer A. Note, that this function is
  2558. currently useless as no flags are allowed.
  2559. -- Function: int gcry_mpi_get_flag (gcry_mpi_t A,
  2560. enum gcry_mpi_flag FLAG)
  2561. Return true when the FLAG is set for A.
  2562. -- Function: void gcry_mpi_randomize (gcry_mpi_t W,
  2563. unsigned int NBITS, enum gcry_random_level LEVEL)
  2564. Set the big integer W to a random value of NBITS, using random
  2565. data quality of level LEVEL. In case NBITS is not a multiple of a
  2566. byte, NBITS is rounded up to the next byte boundary.
  2567. 
  2568. File: gcrypt.info, Node: Utilities, Next: Library Copying, Prev: MPI library, Up: Top
  2569. 12 Utilities
  2570. ************
  2571. * Menu:
  2572. * Memory allocation:: Functions related with memory allocation.
  2573. 
  2574. File: gcrypt.info, Node: Memory allocation, Up: Utilities
  2575. 12.1 Memory allocation
  2576. ======================
  2577. -- Function: void *gcry_malloc (size_t N)
  2578. This function tries to allocate N bytes of memory. On success it
  2579. returns a pointer to the memory area, in an out-of-core condition,
  2580. it returns NULL.
  2581. -- Function: void *gcry_malloc_secure (size_t N)
  2582. Like `gcry_malloc', but uses secure memory.
  2583. -- Function: void *gcry_calloc (size_t N)
  2584. This function tries to allocate N bytes of cleared memory (i.e.
  2585. memory that is initialized with zero bytes). On success it
  2586. returns a pointer to the memory area, in an out-of-core condition,
  2587. it returns NULL.
  2588. -- Function: void *gcry_calloc_secure (size_t N)
  2589. Like `gcry_calloc', but uses secure memory.
  2590. -- Function: void *gcry_realloc (void *P, size_t N)
  2591. This function tries to resize the memory area pointed to by P to N
  2592. bytes. On success it returns a pointer to the new memory area, in
  2593. an out-of-core condition, it returns NULL. Depending on whether
  2594. the memory pointed to by P is secure memory or not, gcry_realloc
  2595. tries to use secure memory as well.
  2596. -- Function: void gcry_free (void *P)
  2597. Release the memory area pointed to by P.
  2598. 
  2599. File: gcrypt.info, Node: Library Copying, Next: Copying, Prev: Utilities, Up: Top
  2600. Appendix A GNU LESSER GENERAL PUBLIC LICENSE
  2601. ********************************************
  2602. Version 2.1, February 1999
  2603. Copyright (C) 1991, 1999 Free Software Foundation, Inc.
  2604. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  2605. Everyone is permitted to copy and distribute verbatim copies
  2606. of this license document, but changing it is not allowed.
  2607. [This is the first released version of the Lesser GPL. It also counts
  2608. as the successor of the GNU Library Public License, version 2, hence the
  2609. version number 2.1.]
  2610. A.0.1 Preamble
  2611. --------------
  2612. The licenses for most software are designed to take away your freedom
  2613. to share and change it. By contrast, the GNU General Public Licenses
  2614. are intended to guarantee your freedom to share and change free
  2615. software--to make sure the software is free for all its users.
  2616. This license, the Lesser General Public License, applies to some
  2617. specially designated software--typically libraries--of the Free
  2618. Software Foundation and other authors who decide to use it. You can use
  2619. it too, but we suggest you first think carefully about whether this
  2620. license or the ordinary General Public License is the better strategy to
  2621. use in any particular case, based on the explanations below.
  2622. When we speak of free software, we are referring to freedom of use,
  2623. not price. Our General Public Licenses are designed to make sure that
  2624. you have the freedom to distribute copies of free software (and charge
  2625. for this service if you wish); that you receive source code or can get
  2626. it if you want it; that you can change the software and use pieces of it
  2627. in new free programs; and that you are informed that you can do these
  2628. things.
  2629. To protect your rights, we need to make restrictions that forbid
  2630. distributors to deny you these rights or to ask you to surrender these
  2631. rights. These restrictions translate to certain responsibilities for
  2632. you if you distribute copies of the library or if you modify it.
  2633. For example, if you distribute copies of the library, whether gratis
  2634. or for a fee, you must give the recipients all the rights that we gave
  2635. you. You must make sure that they, too, receive or can get the source
  2636. code. If you link other code with the library, you must provide
  2637. complete object files to the recipients, so that they can relink them
  2638. with the library after making changes to the library and recompiling
  2639. it. And you must show them these terms so they know their rights.
  2640. We protect your rights with a two-step method: (1) we copyright the
  2641. library, and (2) we offer you this license, which gives you legal
  2642. permission to copy, distribute and/or modify the library.
  2643. To protect each distributor, we want to make it very clear that
  2644. there is no warranty for the free library. Also, if the library is
  2645. modified by someone else and passed on, the recipients should know that
  2646. what they have is not the original version, so that the original
  2647. author's reputation will not be affected by problems that might be
  2648. introduced by others.
  2649. Finally, software patents pose a constant threat to the existence of
  2650. any free program. We wish to make sure that a company cannot
  2651. effectively restrict the users of a free program by obtaining a
  2652. restrictive license from a patent holder. Therefore, we insist that
  2653. any patent license obtained for a version of the library must be
  2654. consistent with the full freedom of use specified in this license.
  2655. Most GNU software, including some libraries, is covered by the
  2656. ordinary GNU General Public License. This license, the GNU Lesser
  2657. General Public License, applies to certain designated libraries, and is
  2658. quite different from the ordinary General Public License. We use this
  2659. license for certain libraries in order to permit linking those
  2660. libraries into non-free programs.
  2661. When a program is linked with a library, whether statically or using
  2662. a shared library, the combination of the two is legally speaking a
  2663. combined work, a derivative of the original library. The ordinary
  2664. General Public License therefore permits such linking only if the
  2665. entire combination fits its criteria of freedom. The Lesser General
  2666. Public License permits more lax criteria for linking other code with
  2667. the library.
  2668. We call this license the "Lesser" General Public License because it
  2669. does _Less_ to protect the user's freedom than the ordinary General
  2670. Public License. It also provides other free software developers Less
  2671. of an advantage over competing non-free programs. These disadvantages
  2672. are the reason we use the ordinary General Public License for many
  2673. libraries. However, the Lesser license provides advantages in certain
  2674. special circumstances.
  2675. For example, on rare occasions, there may be a special need to
  2676. encourage the widest possible use of a certain library, so that it
  2677. becomes a de-facto standard. To achieve this, non-free programs must be
  2678. allowed to use the library. A more frequent case is that a free
  2679. library does the same job as widely used non-free libraries. In this
  2680. case, there is little to gain by limiting the free library to free
  2681. software only, so we use the Lesser General Public License.
  2682. In other cases, permission to use a particular library in non-free
  2683. programs enables a greater number of people to use a large body of free
  2684. software. For example, permission to use the GNU C Library in non-free
  2685. programs enables many more people to use the whole GNU operating
  2686. system, as well as its variant, the GNU/Linux operating system.
  2687. Although the Lesser General Public License is Less protective of the
  2688. users' freedom, it does ensure that the user of a program that is
  2689. linked with the Library has the freedom and the wherewithal to run that
  2690. program using a modified version of the Library.
  2691. The precise terms and conditions for copying, distribution and
  2692. modification follow. Pay close attention to the difference between a
  2693. "work based on the library" and a "work that uses the library". The
  2694. former contains code derived from the library, whereas the latter must
  2695. be combined with the library in order to run.
  2696. GNU LESSER GENERAL PUBLIC LICENSE
  2697. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  2698. 0. This License Agreement applies to any software library or other
  2699. program which contains a notice placed by the copyright holder or
  2700. other authorized party saying it may be distributed under the
  2701. terms of this Lesser General Public License (also called "this
  2702. License"). Each licensee is addressed as "you".
  2703. A "library" means a collection of software functions and/or data
  2704. prepared so as to be conveniently linked with application programs
  2705. (which use some of those functions and data) to form executables.
  2706. The "Library", below, refers to any such software library or work
  2707. which has been distributed under these terms. A "work based on the
  2708. Library" means either the Library or any derivative work under
  2709. copyright law: that is to say, a work containing the Library or a
  2710. portion of it, either verbatim or with modifications and/or
  2711. translated straightforwardly into another language. (Hereinafter,
  2712. translation is included without limitation in the term
  2713. "modification".)
  2714. "Source code" for a work means the preferred form of the work for
  2715. making modifications to it. For a library, complete source code
  2716. means all the source code for all modules it contains, plus any
  2717. associated interface definition files, plus the scripts used to
  2718. control compilation and installation of the library.
  2719. Activities other than copying, distribution and modification are
  2720. not covered by this License; they are outside its scope. The act
  2721. of running a program using the Library is not restricted, and
  2722. output from such a program is covered only if its contents
  2723. constitute a work based on the Library (independent of the use of
  2724. the Library in a tool for writing it). Whether that is true
  2725. depends on what the Library does and what the program that uses
  2726. the Library does.
  2727. 1. You may copy and distribute verbatim copies of the Library's
  2728. complete source code as you receive it, in any medium, provided
  2729. that you conspicuously and appropriately publish on each copy an
  2730. appropriate copyright notice and disclaimer of warranty; keep
  2731. intact all the notices that refer to this License and to the
  2732. absence of any warranty; and distribute a copy of this License
  2733. along with the Library.
  2734. You may charge a fee for the physical act of transferring a copy,
  2735. and you may at your option offer warranty protection in exchange
  2736. for a fee.
  2737. 2. You may modify your copy or copies of the Library or any portion
  2738. of it, thus forming a work based on the Library, and copy and
  2739. distribute such modifications or work under the terms of Section 1
  2740. above, provided that you also meet all of these conditions:
  2741. a. The modified work must itself be a software library.
  2742. b. You must cause the files modified to carry prominent notices
  2743. stating that you changed the files and the date of any change.
  2744. c. You must cause the whole of the work to be licensed at no
  2745. charge to all third parties under the terms of this License.
  2746. d. If a facility in the modified Library refers to a function or
  2747. a table of data to be supplied by an application program that
  2748. uses the facility, other than as an argument passed when the
  2749. facility is invoked, then you must make a good faith effort
  2750. to ensure that, in the event an application does not supply
  2751. such function or table, the facility still operates, and
  2752. performs whatever part of its purpose remains meaningful.
  2753. (For example, a function in a library to compute square roots
  2754. has a purpose that is entirely well-defined independent of the
  2755. application. Therefore, Subsection 2d requires that any
  2756. application-supplied function or table used by this function
  2757. must be optional: if the application does not supply it, the
  2758. square root function must still compute square roots.)
  2759. These requirements apply to the modified work as a whole. If
  2760. identifiable sections of that work are not derived from the
  2761. Library, and can be reasonably considered independent and separate
  2762. works in themselves, then this License, and its terms, do not
  2763. apply to those sections when you distribute them as separate
  2764. works. But when you distribute the same sections as part of a
  2765. whole which is a work based on the Library, the distribution of
  2766. the whole must be on the terms of this License, whose permissions
  2767. for other licensees extend to the entire whole, and thus to each
  2768. and every part regardless of who wrote it.
  2769. Thus, it is not the intent of this section to claim rights or
  2770. contest your rights to work written entirely by you; rather, the
  2771. intent is to exercise the right to control the distribution of
  2772. derivative or collective works based on the Library.
  2773. In addition, mere aggregation of another work not based on the
  2774. Library with the Library (or with a work based on the Library) on
  2775. a volume of a storage or distribution medium does not bring the
  2776. other work under the scope of this License.
  2777. 3. You may opt to apply the terms of the ordinary GNU General Public
  2778. License instead of this License to a given copy of the Library.
  2779. To do this, you must alter all the notices that refer to this
  2780. License, so that they refer to the ordinary GNU General Public
  2781. License, version 2, instead of to this License. (If a newer
  2782. version than version 2 of the ordinary GNU General Public License
  2783. has appeared, then you can specify that version instead if you
  2784. wish.) Do not make any other change in these notices.
  2785. Once this change is made in a given copy, it is irreversible for
  2786. that copy, so the ordinary GNU General Public License applies to
  2787. all subsequent copies and derivative works made from that copy.
  2788. This option is useful when you wish to copy part of the code of
  2789. the Library into a program that is not a library.
  2790. 4. You may copy and distribute the Library (or a portion or
  2791. derivative of it, under Section 2) in object code or executable
  2792. form under the terms of Sections 1 and 2 above provided that you
  2793. accompany it with the complete corresponding machine-readable
  2794. source code, which must be distributed under the terms of Sections
  2795. 1 and 2 above on a medium customarily used for software
  2796. interchange.
  2797. If distribution of object code is made by offering access to copy
  2798. from a designated place, then offering equivalent access to copy
  2799. the source code from the same place satisfies the requirement to
  2800. distribute the source code, even though third parties are not
  2801. compelled to copy the source along with the object code.
  2802. 5. A program that contains no derivative of any portion of the
  2803. Library, but is designed to work with the Library by being
  2804. compiled or linked with it, is called a "work that uses the
  2805. Library". Such a work, in isolation, is not a derivative work of
  2806. the Library, and therefore falls outside the scope of this License.
  2807. However, linking a "work that uses the Library" with the Library
  2808. creates an executable that is a derivative of the Library (because
  2809. it contains portions of the Library), rather than a "work that
  2810. uses the library". The executable is therefore covered by this
  2811. License. Section 6 states terms for distribution of such
  2812. executables.
  2813. When a "work that uses the Library" uses material from a header
  2814. file that is part of the Library, the object code for the work may
  2815. be a derivative work of the Library even though the source code is
  2816. not. Whether this is true is especially significant if the work
  2817. can be linked without the Library, or if the work is itself a
  2818. library. The threshold for this to be true is not precisely
  2819. defined by law.
  2820. If such an object file uses only numerical parameters, data
  2821. structure layouts and accessors, and small macros and small inline
  2822. functions (ten lines or less in length), then the use of the object
  2823. file is unrestricted, regardless of whether it is legally a
  2824. derivative work. (Executables containing this object code plus
  2825. portions of the Library will still fall under Section 6.)
  2826. Otherwise, if the work is a derivative of the Library, you may
  2827. distribute the object code for the work under the terms of Section
  2828. 6. Any executables containing that work also fall under Section 6,
  2829. whether or not they are linked directly with the Library itself.
  2830. 6. As an exception to the Sections above, you may also combine or
  2831. link a "work that uses the Library" with the Library to produce a
  2832. work containing portions of the Library, and distribute that work
  2833. under terms of your choice, provided that the terms permit
  2834. modification of the work for the customer's own use and reverse
  2835. engineering for debugging such modifications.
  2836. You must give prominent notice with each copy of the work that the
  2837. Library is used in it and that the Library and its use are covered
  2838. by this License. You must supply a copy of this License. If the
  2839. work during execution displays copyright notices, you must include
  2840. the copyright notice for the Library among them, as well as a
  2841. reference directing the user to the copy of this License. Also,
  2842. you must do one of these things:
  2843. a. Accompany the work with the complete corresponding
  2844. machine-readable source code for the Library including
  2845. whatever changes were used in the work (which must be
  2846. distributed under Sections 1 and 2 above); and, if the work
  2847. is an executable linked with the Library, with the complete
  2848. machine-readable "work that uses the Library", as object code
  2849. and/or source code, so that the user can modify the Library
  2850. and then relink to produce a modified executable containing
  2851. the modified Library. (It is understood that the user who
  2852. changes the contents of definitions files in the Library will
  2853. not necessarily be able to recompile the application to use
  2854. the modified definitions.)
  2855. b. Use a suitable shared library mechanism for linking with the
  2856. Library. A suitable mechanism is one that (1) uses at run
  2857. time a copy of the library already present on the user's
  2858. computer system, rather than copying library functions into
  2859. the executable, and (2) will operate properly with a modified
  2860. version of the library, if the user installs one, as long as
  2861. the modified version is interface-compatible with the version
  2862. that the work was made with.
  2863. c. Accompany the work with a written offer, valid for at least
  2864. three years, to give the same user the materials specified in
  2865. Subsection 6a, above, for a charge no more than the cost of
  2866. performing this distribution.
  2867. d. If distribution of the work is made by offering access to copy
  2868. from a designated place, offer equivalent access to copy the
  2869. above specified materials from the same place.
  2870. e. Verify that the user has already received a copy of these
  2871. materials or that you have already sent this user a copy.
  2872. For an executable, the required form of the "work that uses the
  2873. Library" must include any data and utility programs needed for
  2874. reproducing the executable from it. However, as a special
  2875. exception, the materials to be distributed need not include
  2876. anything that is normally distributed (in either source or binary
  2877. form) with the major components (compiler, kernel, and so on) of
  2878. the operating system on which the executable runs, unless that
  2879. component itself accompanies the executable.
  2880. It may happen that this requirement contradicts the license
  2881. restrictions of other proprietary libraries that do not normally
  2882. accompany the operating system. Such a contradiction means you
  2883. cannot use both them and the Library together in an executable
  2884. that you distribute.
  2885. 7. You may place library facilities that are a work based on the
  2886. Library side-by-side in a single library together with other
  2887. library facilities not covered by this License, and distribute
  2888. such a combined library, provided that the separate distribution
  2889. of the work based on the Library and of the other library
  2890. facilities is otherwise permitted, and provided that you do these
  2891. two things:
  2892. a. Accompany the combined library with a copy of the same work
  2893. based on the Library, uncombined with any other library
  2894. facilities. This must be distributed under the terms of the
  2895. Sections above.
  2896. b. Give prominent notice with the combined library of the fact
  2897. that part of it is a work based on the Library, and explaining
  2898. where to find the accompanying uncombined form of the same
  2899. work.
  2900. 8. You may not copy, modify, sublicense, link with, or distribute the
  2901. Library except as expressly provided under this License. Any
  2902. attempt otherwise to copy, modify, sublicense, link with, or
  2903. distribute the Library is void, and will automatically terminate
  2904. your rights under this License. However, parties who have
  2905. received copies, or rights, from you under this License will not
  2906. have their licenses terminated so long as such parties remain in
  2907. full compliance.
  2908. 9. You are not required to accept this License, since you have not
  2909. signed it. However, nothing else grants you permission to modify
  2910. or distribute the Library or its derivative works. These actions
  2911. are prohibited by law if you do not accept this License.
  2912. Therefore, by modifying or distributing the Library (or any work
  2913. based on the Library), you indicate your acceptance of this
  2914. License to do so, and all its terms and conditions for copying,
  2915. distributing or modifying the Library or works based on it.
  2916. 10. Each time you redistribute the Library (or any work based on the
  2917. Library), the recipient automatically receives a license from the
  2918. original licensor to copy, distribute, link with or modify the
  2919. Library subject to these terms and conditions. You may not impose
  2920. any further restrictions on the recipients' exercise of the rights
  2921. granted herein. You are not responsible for enforcing compliance
  2922. by third parties with this License.
  2923. 11. If, as a consequence of a court judgment or allegation of patent
  2924. infringement or for any other reason (not limited to patent
  2925. issues), conditions are imposed on you (whether by court order,
  2926. agreement or otherwise) that contradict the conditions of this
  2927. License, they do not excuse you from the conditions of this
  2928. License. If you cannot distribute so as to satisfy simultaneously
  2929. your obligations under this License and any other pertinent
  2930. obligations, then as a consequence you may not distribute the
  2931. Library at all. For example, if a patent license would not permit
  2932. royalty-free redistribution of the Library by all those who
  2933. receive copies directly or indirectly through you, then the only
  2934. way you could satisfy both it and this License would be to refrain
  2935. entirely from distribution of the Library.
  2936. If any portion of this section is held invalid or unenforceable
  2937. under any particular circumstance, the balance of the section is
  2938. intended to apply, and the section as a whole is intended to apply
  2939. in other circumstances.
  2940. It is not the purpose of this section to induce you to infringe any
  2941. patents or other property right claims or to contest validity of
  2942. any such claims; this section has the sole purpose of protecting
  2943. the integrity of the free software distribution system which is
  2944. implemented by public license practices. Many people have made
  2945. generous contributions to the wide range of software distributed
  2946. through that system in reliance on consistent application of that
  2947. system; it is up to the author/donor to decide if he or she is
  2948. willing to distribute software through any other system and a
  2949. licensee cannot impose that choice.
  2950. This section is intended to make thoroughly clear what is believed
  2951. to be a consequence of the rest of this License.
  2952. 12. If the distribution and/or use of the Library is restricted in
  2953. certain countries either by patents or by copyrighted interfaces,
  2954. the original copyright holder who places the Library under this
  2955. License may add an explicit geographical distribution limitation
  2956. excluding those countries, so that distribution is permitted only
  2957. in or among countries not thus excluded. In such case, this
  2958. License incorporates the limitation as if written in the body of
  2959. this License.
  2960. 13. The Free Software Foundation may publish revised and/or new
  2961. versions of the Lesser General Public License from time to time.
  2962. Such new versions will be similar in spirit to the present version,
  2963. but may differ in detail to address new problems or concerns.
  2964. Each version is given a distinguishing version number. If the
  2965. Library specifies a version number of this License which applies
  2966. to it and "any later version", you have the option of following
  2967. the terms and conditions either of that version or of any later
  2968. version published by the Free Software Foundation. If the Library
  2969. does not specify a license version number, you may choose any
  2970. version ever published by the Free Software Foundation.
  2971. 14. If you wish to incorporate parts of the Library into other free
  2972. programs whose distribution conditions are incompatible with these,
  2973. write to the author to ask for permission. For software which is
  2974. copyrighted by the Free Software Foundation, write to the Free
  2975. Software Foundation; we sometimes make exceptions for this. Our
  2976. decision will be guided by the two goals of preserving the free
  2977. status of all derivatives of our free software and of promoting
  2978. the sharing and reuse of software generally.
  2979. NO WARRANTY
  2980. 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
  2981. WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE
  2982. LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  2983. HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT
  2984. WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
  2985. NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  2986. FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
  2987. QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE
  2988. LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  2989. SERVICING, REPAIR OR CORRECTION.
  2990. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  2991. WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
  2992. MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE
  2993. LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
  2994. INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  2995. INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF
  2996. DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
  2997. OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY
  2998. OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
  2999. ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  3000. END OF TERMS AND CONDITIONS
  3001. A.0.2 How to Apply These Terms to Your New Libraries
  3002. ----------------------------------------------------
  3003. If you develop a new library, and you want it to be of the greatest
  3004. possible use to the public, we recommend making it free software that
  3005. everyone can redistribute and change. You can do so by permitting
  3006. redistribution under these terms (or, alternatively, under the terms of
  3007. the ordinary General Public License).
  3008. To apply these terms, attach the following notices to the library.
  3009. It is safest to attach them to the start of each source file to most
  3010. effectively convey the exclusion of warranty; and each file should have
  3011. at least the "copyright" line and a pointer to where the full notice is
  3012. found.
  3013. ONE LINE TO GIVE THE LIBRARY'S NAME AND AN IDEA OF WHAT IT DOES.
  3014. Copyright (C) YEAR NAME OF AUTHOR
  3015. This library is free software; you can redistribute it and/or modify it
  3016. under the terms of the GNU Lesser General Public License as published by
  3017. the Free Software Foundation; either version 2.1 of the License, or (at
  3018. your option) any later version.
  3019. This library is distributed in the hope that it will be useful, but
  3020. WITHOUT ANY WARRANTY; without even the implied warranty of
  3021. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3022. Lesser General Public License for more details.
  3023. You should have received a copy of the GNU Lesser General Public
  3024. License along with this library; if not, write to the Free Software
  3025. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
  3026. USA.
  3027. Also add information on how to contact you by electronic and paper
  3028. mail.
  3029. You should also get your employer (if you work as a programmer) or
  3030. your school, if any, to sign a "copyright disclaimer" for the library,
  3031. if necessary. Here is a sample; alter the names:
  3032. Yoyodyne, Inc., hereby disclaims all copyright interest in the library
  3033. `Frob' (a library for tweaking knobs) written by James Random Hacker.
  3034. SIGNATURE OF TY COON, 1 April 1990
  3035. Ty Coon, President of Vice
  3036. That's all there is to it!
  3037. 
  3038. File: gcrypt.info, Node: Copying, Next: Concept Index, Prev: Library Copying, Up: Top
  3039. Appendix B GNU GENERAL PUBLIC LICENSE
  3040. *************************************
  3041. Version 2, June 1991
  3042. Copyright (C) 1989, 1991 Free Software Foundation, Inc.
  3043. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  3044. Everyone is permitted to copy and distribute verbatim copies
  3045. of this license document, but changing it is not allowed.
  3046. B.0.1 Preamble
  3047. --------------
  3048. The licenses for most software are designed to take away your freedom
  3049. to share and change it. By contrast, the GNU General Public License is
  3050. intended to guarantee your freedom to share and change free
  3051. software--to make sure the software is free for all its users. This
  3052. General Public License applies to most of the Free Software
  3053. Foundation's software and to any other program whose authors commit to
  3054. using it. (Some other Free Software Foundation software is covered by
  3055. the GNU Library General Public License instead.) You can apply it to
  3056. your programs, too.
  3057. When we speak of free software, we are referring to freedom, not
  3058. price. Our General Public Licenses are designed to make sure that you
  3059. have the freedom to distribute copies of free software (and charge for
  3060. this service if you wish), that you receive source code or can get it
  3061. if you want it, that you can change the software or use pieces of it in
  3062. new free programs; and that you know you can do these things.
  3063. To protect your rights, we need to make restrictions that forbid
  3064. anyone to deny you these rights or to ask you to surrender the rights.
  3065. These restrictions translate to certain responsibilities for you if you
  3066. distribute copies of the software, or if you modify it.
  3067. For example, if you distribute copies of such a program, whether
  3068. gratis or for a fee, you must give the recipients all the rights that
  3069. you have. You must make sure that they, too, receive or can get the
  3070. source code. And you must show them these terms so they know their
  3071. rights.
  3072. We protect your rights with two steps: (1) copyright the software,
  3073. and (2) offer you this license which gives you legal permission to copy,
  3074. distribute and/or modify the software.
  3075. Also, for each author's protection and ours, we want to make certain
  3076. that everyone understands that there is no warranty for this free
  3077. software. If the software is modified by someone else and passed on, we
  3078. want its recipients to know that what they have is not the original, so
  3079. that any problems introduced by others will not reflect on the original
  3080. authors' reputations.
  3081. Finally, any free program is threatened constantly by software
  3082. patents. We wish to avoid the danger that redistributors of a free
  3083. program will individually obtain patent licenses, in effect making the
  3084. program proprietary. To prevent this, we have made it clear that any
  3085. patent must be licensed for everyone's free use or not licensed at all.
  3086. The precise terms and conditions for copying, distribution and
  3087. modification follow.
  3088. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  3089. 1. This License applies to any program or other work which contains a
  3090. notice placed by the copyright holder saying it may be distributed
  3091. under the terms of this General Public License. The "Program",
  3092. below, refers to any such program or work, and a "work based on
  3093. the Program" means either the Program or any derivative work under
  3094. copyright law: that is to say, a work containing the Program or a
  3095. portion of it, either verbatim or with modifications and/or
  3096. translated into another language. (Hereinafter, translation is
  3097. included without limitation in the term "modification".) Each
  3098. licensee is addressed as "you".
  3099. Activities other than copying, distribution and modification are
  3100. not covered by this License; they are outside its scope. The act
  3101. of running the Program is not restricted, and the output from the
  3102. Program is covered only if its contents constitute a work based on
  3103. the Program (independent of having been made by running the
  3104. Program). Whether that is true depends on what the Program does.
  3105. 2. You may copy and distribute verbatim copies of the Program's
  3106. source code as you receive it, in any medium, provided that you
  3107. conspicuously and appropriately publish on each copy an appropriate
  3108. copyright notice and disclaimer of warranty; keep intact all the
  3109. notices that refer to this License and to the absence of any
  3110. warranty; and give any other recipients of the Program a copy of
  3111. this License along with the Program.
  3112. You may charge a fee for the physical act of transferring a copy,
  3113. and you may at your option offer warranty protection in exchange
  3114. for a fee.
  3115. 3. You may modify your copy or copies of the Program or any portion
  3116. of it, thus forming a work based on the Program, and copy and
  3117. distribute such modifications or work under the terms of Section 1
  3118. above, provided that you also meet all of these conditions:
  3119. a. You must cause the modified files to carry prominent notices
  3120. stating that you changed the files and the date of any change.
  3121. b. You must cause any work that you distribute or publish, that
  3122. in whole or in part contains or is derived from the Program
  3123. or any part thereof, to be licensed as a whole at no charge
  3124. to all third parties under the terms of this License.
  3125. c. If the modified program normally reads commands interactively
  3126. when run, you must cause it, when started running for such
  3127. interactive use in the most ordinary way, to print or display
  3128. an announcement including an appropriate copyright notice and
  3129. a notice that there is no warranty (or else, saying that you
  3130. provide a warranty) and that users may redistribute the
  3131. program under these conditions, and telling the user how to
  3132. view a copy of this License. (Exception: if the Program
  3133. itself is interactive but does not normally print such an
  3134. announcement, your work based on the Program is not required
  3135. to print an announcement.)
  3136. These requirements apply to the modified work as a whole. If
  3137. identifiable sections of that work are not derived from the
  3138. Program, and can be reasonably considered independent and separate
  3139. works in themselves, then this License, and its terms, do not
  3140. apply to those sections when you distribute them as separate
  3141. works. But when you distribute the same sections as part of a
  3142. whole which is a work based on the Program, the distribution of
  3143. the whole must be on the terms of this License, whose permissions
  3144. for other licensees extend to the entire whole, and thus to each
  3145. and every part regardless of who wrote it.
  3146. Thus, it is not the intent of this section to claim rights or
  3147. contest your rights to work written entirely by you; rather, the
  3148. intent is to exercise the right to control the distribution of
  3149. derivative or collective works based on the Program.
  3150. In addition, mere aggregation of another work not based on the
  3151. Program with the Program (or with a work based on the Program) on
  3152. a volume of a storage or distribution medium does not bring the
  3153. other work under the scope of this License.
  3154. 4. You may copy and distribute the Program (or a work based on it,
  3155. under Section 2) in object code or executable form under the terms
  3156. of Sections 1 and 2 above provided that you also do one of the
  3157. following:
  3158. a. Accompany it with the complete corresponding machine-readable
  3159. source code, which must be distributed under the terms of
  3160. Sections 1 and 2 above on a medium customarily used for
  3161. software interchange; or,
  3162. b. Accompany it with a written offer, valid for at least three
  3163. years, to give any third party, for a charge no more than your
  3164. cost of physically performing source distribution, a complete
  3165. machine-readable copy of the corresponding source code, to be
  3166. distributed under the terms of Sections 1 and 2 above on a
  3167. medium customarily used for software interchange; or,
  3168. c. Accompany it with the information you received as to the offer
  3169. to distribute corresponding source code. (This alternative is
  3170. allowed only for noncommercial distribution and only if you
  3171. received the program in object code or executable form with
  3172. such an offer, in accord with Subsection b above.)
  3173. The source code for a work means the preferred form of the work for
  3174. making modifications to it. For an executable work, complete
  3175. source code means all the source code for all modules it contains,
  3176. plus any associated interface definition files, plus the scripts
  3177. used to control compilation and installation of the executable.
  3178. However, as a special exception, the source code distributed need
  3179. not include anything that is normally distributed (in either
  3180. source or binary form) with the major components (compiler,
  3181. kernel, and so on) of the operating system on which the executable
  3182. runs, unless that component itself accompanies the executable.
  3183. If distribution of executable or object code is made by offering
  3184. access to copy from a designated place, then offering equivalent
  3185. access to copy the source code from the same place counts as
  3186. distribution of the source code, even though third parties are not
  3187. compelled to copy the source along with the object code.
  3188. 5. You may not copy, modify, sublicense, or distribute the Program
  3189. except as expressly provided under this License. Any attempt
  3190. otherwise to copy, modify, sublicense or distribute the Program is
  3191. void, and will automatically terminate your rights under this
  3192. License. However, parties who have received copies, or rights,
  3193. from you under this License will not have their licenses
  3194. terminated so long as such parties remain in full compliance.
  3195. 6. You are not required to accept this License, since you have not
  3196. signed it. However, nothing else grants you permission to modify
  3197. or distribute the Program or its derivative works. These actions
  3198. are prohibited by law if you do not accept this License.
  3199. Therefore, by modifying or distributing the Program (or any work
  3200. based on the Program), you indicate your acceptance of this
  3201. License to do so, and all its terms and conditions for copying,
  3202. distributing or modifying the Program or works based on it.
  3203. 7. Each time you redistribute the Program (or any work based on the
  3204. Program), the recipient automatically receives a license from the
  3205. original licensor to copy, distribute or modify the Program
  3206. subject to these terms and conditions. You may not impose any
  3207. further restrictions on the recipients' exercise of the rights
  3208. granted herein. You are not responsible for enforcing compliance
  3209. by third parties to this License.
  3210. 8. If, as a consequence of a court judgment or allegation of patent
  3211. infringement or for any other reason (not limited to patent
  3212. issues), conditions are imposed on you (whether by court order,
  3213. agreement or otherwise) that contradict the conditions of this
  3214. License, they do not excuse you from the conditions of this
  3215. License. If you cannot distribute so as to satisfy simultaneously
  3216. your obligations under this License and any other pertinent
  3217. obligations, then as a consequence you may not distribute the
  3218. Program at all. For example, if a patent license would not permit
  3219. royalty-free redistribution of the Program by all those who
  3220. receive copies directly or indirectly through you, then the only
  3221. way you could satisfy both it and this License would be to refrain
  3222. entirely from distribution of the Program.
  3223. If any portion of this section is held invalid or unenforceable
  3224. under any particular circumstance, the balance of the section is
  3225. intended to apply and the section as a whole is intended to apply
  3226. in other circumstances.
  3227. It is not the purpose of this section to induce you to infringe any
  3228. patents or other property right claims or to contest validity of
  3229. any such claims; this section has the sole purpose of protecting
  3230. the integrity of the free software distribution system, which is
  3231. implemented by public license practices. Many people have made
  3232. generous contributions to the wide range of software distributed
  3233. through that system in reliance on consistent application of that
  3234. system; it is up to the author/donor to decide if he or she is
  3235. willing to distribute software through any other system and a
  3236. licensee cannot impose that choice.
  3237. This section is intended to make thoroughly clear what is believed
  3238. to be a consequence of the rest of this License.
  3239. 9. If the distribution and/or use of the Program is restricted in
  3240. certain countries either by patents or by copyrighted interfaces,
  3241. the original copyright holder who places the Program under this
  3242. License may add an explicit geographical distribution limitation
  3243. excluding those countries, so that distribution is permitted only
  3244. in or among countries not thus excluded. In such case, this
  3245. License incorporates the limitation as if written in the body of
  3246. this License.
  3247. 10. The Free Software Foundation may publish revised and/or new
  3248. versions of the General Public License from time to time. Such
  3249. new versions will be similar in spirit to the present version, but
  3250. may differ in detail to address new problems or concerns.
  3251. Each version is given a distinguishing version number. If the
  3252. Program specifies a version number of this License which applies
  3253. to it and "any later version", you have the option of following
  3254. the terms and conditions either of that version or of any later
  3255. version published by the Free Software Foundation. If the Program
  3256. does not specify a version number of this License, you may choose
  3257. any version ever published by the Free Software Foundation.
  3258. 11. If you wish to incorporate parts of the Program into other free
  3259. programs whose distribution conditions are different, write to the
  3260. author to ask for permission. For software which is copyrighted
  3261. by the Free Software Foundation, write to the Free Software
  3262. Foundation; we sometimes make exceptions for this. Our decision
  3263. will be guided by the two goals of preserving the free status of
  3264. all derivatives of our free software and of promoting the sharing
  3265. and reuse of software generally.
  3266. NO WARRANTY
  3267. 12. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
  3268. WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
  3269. LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  3270. HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
  3271. WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
  3272. NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  3273. FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
  3274. QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
  3275. PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  3276. SERVICING, REPAIR OR CORRECTION.
  3277. 13. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  3278. WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
  3279. MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
  3280. LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
  3281. INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  3282. INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
  3283. DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
  3284. OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
  3285. OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
  3286. ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  3287. END OF TERMS AND CONDITIONS
  3288. How to Apply These Terms to Your New Programs
  3289. =============================================
  3290. If you develop a new program, and you want it to be of the greatest
  3291. possible use to the public, the best way to achieve this is to make it
  3292. free software which everyone can redistribute and change under these
  3293. terms.
  3294. To do so, attach the following notices to the program. It is safest
  3295. to attach them to the start of each source file to most effectively
  3296. convey the exclusion of warranty; and each file should have at least
  3297. the "copyright" line and a pointer to where the full notice is found.
  3298. ONE LINE TO GIVE THE PROGRAM'S NAME AND AN IDEA OF WHAT IT DOES.
  3299. Copyright (C) 19YY NAME OF AUTHOR
  3300. This program is free software; you can redistribute it and/or
  3301. modify it under the terms of the GNU General Public License
  3302. as published by the Free Software Foundation; either version 2
  3303. of the License, or (at your option) any later version.
  3304. This program is distributed in the hope that it will be useful,
  3305. but WITHOUT ANY WARRANTY; without even the implied warranty of
  3306. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3307. GNU General Public License for more details.
  3308. You should have received a copy of the GNU General Public License along
  3309. with this program; if not, write to the Free Software Foundation, Inc.,
  3310. 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  3311. Also add information on how to contact you by electronic and paper
  3312. mail.
  3313. If the program is interactive, make it output a short notice like
  3314. this when it starts in an interactive mode:
  3315. Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR
  3316. Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
  3317. type `show w'. This is free software, and you are welcome
  3318. to redistribute it under certain conditions; type `show c'
  3319. for details.
  3320. The hypothetical commands `show w' and `show c' should show the
  3321. appropriate parts of the General Public License. Of course, the
  3322. commands you use may be called something other than `show w' and `show
  3323. c'; they could even be mouse-clicks or menu items--whatever suits your
  3324. program.
  3325. You should also get your employer (if you work as a programmer) or
  3326. your school, if any, to sign a "copyright disclaimer" for the program,
  3327. if necessary. Here is a sample; alter the names:
  3328. Yoyodyne, Inc., hereby disclaims all copyright
  3329. interest in the program `Gnomovision'
  3330. (which makes passes at compilers) written
  3331. by James Hacker.
  3332. SIGNATURE OF TY COON, 1 April 1989
  3333. Ty Coon, President of Vice
  3334. This General Public License does not permit incorporating your
  3335. program into proprietary programs. If your program is a subroutine
  3336. library, you may consider it more useful to permit linking proprietary
  3337. applications with the library. If this is what you want to do, use the
  3338. GNU Library General Public License instead of this License.
  3339. 
  3340. File: gcrypt.info, Node: Concept Index, Next: Function and Data Index, Prev: Copying, Up: Top
  3341. Concept Index
  3342. *************
  3343. �[index�]
  3344. * Menu:
  3345. * error codes: Error Values. (line 6)
  3346. * error codes, list of <1>: Error Codes. (line 6)
  3347. * error codes, list of: Error Sources. (line 6)
  3348. * error codes, printing of: Error Strings. (line 6)
  3349. * error sources: Error Values. (line 6)
  3350. * error sources, printing of: Error Strings. (line 6)
  3351. * error strings: Error Strings. (line 6)
  3352. * error values: Error Values. (line 6)
  3353. * error values, printing of: Error Strings. (line 6)
  3354. * GPL, GNU General Public License: Copying. (line 6)
  3355. * LGPL, Lesser General Public License: Library Copying. (line 6)
  3356. 
  3357. File: gcrypt.info, Node: Function and Data Index, Prev: Concept Index, Up: Top
  3358. Function and Data Index
  3359. ***********************
  3360. �[index�]
  3361. * Menu:
  3362. * *: Retrieving random numbers.
  3363. (line 13)
  3364. * *gcry_calloc: Memory allocation. (line 15)
  3365. * *gcry_calloc_secure: Memory allocation. (line 21)
  3366. * *gcry_malloc: Memory allocation. (line 7)
  3367. * *gcry_malloc_secure: Memory allocation. (line 12)
  3368. * *gcry_realloc: Memory allocation. (line 24)
  3369. * AM_PATH_LIBGCRYPT: Building sources using Automake.
  3370. (line 13)
  3371. * char <1>: Working with hash algorithms.
  3372. (line 117)
  3373. * char <2>: General cipher functions.
  3374. (line 39)
  3375. * char: Initializing the library.
  3376. (line 13)
  3377. * enum: Quality of random numbers.
  3378. (line 9)
  3379. * gcry_ac_close: Working with handles.
  3380. (line 21)
  3381. * gcry_ac_data_clear: Working with sets of data.
  3382. (line 68)
  3383. * gcry_ac_data_copy: Working with sets of data.
  3384. (line 48)
  3385. * gcry_ac_data_decrypt: Using cryptographic functions.
  3386. (line 22)
  3387. * gcry_ac_data_destroy: Working with sets of data.
  3388. (line 36)
  3389. * gcry_ac_data_encrypt: Using cryptographic functions.
  3390. (line 15)
  3391. * gcry_ac_data_get_index: Working with sets of data.
  3392. (line 62)
  3393. * gcry_ac_data_get_name: Working with sets of data.
  3394. (line 55)
  3395. * gcry_ac_data_new: Working with sets of data.
  3396. (line 33)
  3397. * gcry_ac_data_set: Working with sets of data.
  3398. (line 40)
  3399. * gcry_ac_data_sign: Using cryptographic functions.
  3400. (line 30)
  3401. * gcry_ac_data_t: Working with sets of data.
  3402. (line 19)
  3403. * gcry_ac_data_verify: Using cryptographic functions.
  3404. (line 36)
  3405. * gcry_ac_id_t: Available asymmetric algorithms.
  3406. (line 11)
  3407. * gcry_ac_id_to_name: Handle-independent functions.
  3408. (line 8)
  3409. * gcry_ac_key_data_get: Working with keys. (line 92)
  3410. * gcry_ac_key_destroy: Working with keys. (line 85)
  3411. * gcry_ac_key_get_grip: Working with keys. (line 104)
  3412. * gcry_ac_key_get_nbits: Working with keys. (line 100)
  3413. * gcry_ac_key_init: Working with keys. (line 30)
  3414. * gcry_ac_key_pair_destroy: Working with keys. (line 89)
  3415. * gcry_ac_key_pair_extract: Working with keys. (line 82)
  3416. * gcry_ac_key_pair_generate: Working with keys. (line 36)
  3417. * gcry_ac_key_pair_t: Working with keys. (line 20)
  3418. * gcry_ac_key_t: Working with keys. (line 16)
  3419. * gcry_ac_key_test: Working with keys. (line 96)
  3420. * gcry_ac_key_type_t: Working with keys. (line 7)
  3421. * gcry_ac_name_to_id: Handle-independent functions.
  3422. (line 13)
  3423. * gcry_ac_open: Working with handles.
  3424. (line 11)
  3425. * gcry_cipher_algo_info: General cipher functions.
  3426. (line 12)
  3427. * gcry_cipher_close: Working with cipher handles.
  3428. (line 52)
  3429. * gcry_cipher_ctl: Working with cipher handles.
  3430. (line 152)
  3431. * gcry_cipher_decrypt: Working with cipher handles.
  3432. (line 122)
  3433. * gcry_cipher_decrypt_t: Cipher modules. (line 80)
  3434. * gcry_cipher_encrypt: Working with cipher handles.
  3435. (line 104)
  3436. * gcry_cipher_encrypt_t: Cipher modules. (line 75)
  3437. * gcry_cipher_info: Working with cipher handles.
  3438. (line 161)
  3439. * gcry_cipher_list: Cipher modules. (line 106)
  3440. * gcry_cipher_map_name: General cipher functions.
  3441. (line 45)
  3442. * gcry_cipher_mode_from_oid: General cipher functions.
  3443. (line 50)
  3444. * gcry_cipher_oid_spec_t: Cipher modules. (line 60)
  3445. * gcry_cipher_open: Working with cipher handles.
  3446. (line 11)
  3447. * gcry_cipher_register: Cipher modules. (line 96)
  3448. * gcry_cipher_reset: Working with cipher handles.
  3449. (line 92)
  3450. * gcry_cipher_setctr: Working with cipher handles.
  3451. (line 84)
  3452. * gcry_cipher_setiv: Working with cipher handles.
  3453. (line 76)
  3454. * gcry_cipher_setkey: Working with cipher handles.
  3455. (line 59)
  3456. * gcry_cipher_setkey_t: Cipher modules. (line 70)
  3457. * gcry_cipher_spec_t: Cipher modules. (line 12)
  3458. * gcry_cipher_stdecrypt_t: Cipher modules. (line 90)
  3459. * gcry_cipher_stencrypt_t: Cipher modules. (line 85)
  3460. * gcry_cipher_sync: Working with cipher handles.
  3461. (line 142)
  3462. * gcry_cipher_unregister: Cipher modules. (line 101)
  3463. * gcry_control: Controlling the library.
  3464. (line 7)
  3465. * gcry_create_nonce: Retrieving random numbers.
  3466. (line 24)
  3467. * gcry_err_code: Error Values. (line 43)
  3468. * gcry_err_code_from_errno: Error Values. (line 95)
  3469. * gcry_err_code_t: Error Values. (line 7)
  3470. * gcry_err_code_to_errno: Error Values. (line 100)
  3471. * gcry_err_make: Error Values. (line 57)
  3472. * gcry_err_make_from_errno: Error Values. (line 81)
  3473. * gcry_err_source: Error Values. (line 49)
  3474. * gcry_err_source_t: Error Values. (line 14)
  3475. * gcry_error: Error Values. (line 64)
  3476. * gcry_error_from_errno: Error Values. (line 86)
  3477. * gcry_error_t: Error Values. (line 25)
  3478. * gcry_free: Memory allocation. (line 31)
  3479. * gcry_handler_alloc_t: Allocation handler. (line 12)
  3480. * gcry_handler_error_t: Error handler. (line 20)
  3481. * gcry_handler_free_t: Allocation handler. (line 24)
  3482. * gcry_handler_log_t: Logging handler. (line 7)
  3483. * gcry_handler_no_mem_t: Error handler. (line 10)
  3484. * gcry_handler_progress_t: Progress handler. (line 10)
  3485. * gcry_handler_realloc_t: Allocation handler. (line 20)
  3486. * gcry_handler_secure_check_t: Allocation handler. (line 16)
  3487. * gcry_md_close: Working with hash algorithms.
  3488. (line 59)
  3489. * gcry_md_copy: Working with hash algorithms.
  3490. (line 80)
  3491. * gcry_md_enable: Working with hash algorithms.
  3492. (line 43)
  3493. * gcry_md_final: Working with hash algorithms.
  3494. (line 107)
  3495. * gcry_md_final_t: Hash algorithm modules.
  3496. (line 73)
  3497. * gcry_md_get_algo: Working with hash algorithms.
  3498. (line 193)
  3499. * gcry_md_get_asnoid: Working with hash algorithms.
  3500. (line 165)
  3501. * gcry_md_hash_buffer: Working with hash algorithms.
  3502. (line 132)
  3503. * gcry_md_init_t: Hash algorithm modules.
  3504. (line 65)
  3505. * gcry_md_is_enabled: Working with hash algorithms.
  3506. (line 204)
  3507. * gcry_md_is_secure: Working with hash algorithms.
  3508. (line 199)
  3509. * gcry_md_list: Hash algorithm modules.
  3510. (line 91)
  3511. * gcry_md_map_name: Working with hash algorithms.
  3512. (line 155)
  3513. * gcry_md_oid_spec_t: Hash algorithm modules.
  3514. (line 57)
  3515. * gcry_md_open: Working with hash algorithms.
  3516. (line 11)
  3517. * gcry_md_putc: Working with hash algorithms.
  3518. (line 97)
  3519. * gcry_md_read_t: Hash algorithm modules.
  3520. (line 77)
  3521. * gcry_md_register: Hash algorithm modules.
  3522. (line 82)
  3523. * gcry_md_reset: Working with hash algorithms.
  3524. (line 68)
  3525. * gcry_md_setkey: Working with hash algorithms.
  3526. (line 52)
  3527. * gcry_md_spec_t: Hash algorithm modules.
  3528. (line 12)
  3529. * gcry_md_start_debug: Working with hash algorithms.
  3530. (line 215)
  3531. * gcry_md_stop_debug: Working with hash algorithms.
  3532. (line 223)
  3533. * gcry_md_test_algo: Working with hash algorithms.
  3534. (line 178)
  3535. * gcry_md_unregister: Hash algorithm modules.
  3536. (line 87)
  3537. * gcry_md_write: Working with hash algorithms.
  3538. (line 92)
  3539. * gcry_md_write_t: Hash algorithm modules.
  3540. (line 69)
  3541. * gcry_module_t: Modules. (line 10)
  3542. * gcry_mpi_add: Calculations. (line 10)
  3543. * gcry_mpi_add_ui: Calculations. (line 14)
  3544. * gcry_mpi_addm: Calculations. (line 18)
  3545. * gcry_mpi_aprint: MPI formats. (line 53)
  3546. * gcry_mpi_clear_bit: Bit manipulations. (line 19)
  3547. * gcry_mpi_clear_flag: Miscellaneous. (line 32)
  3548. * gcry_mpi_clear_highbit: Bit manipulations. (line 25)
  3549. * gcry_mpi_cmp: Comparisons. (line 9)
  3550. * gcry_mpi_cmp_ui: Comparisons. (line 13)
  3551. * gcry_mpi_copy: Basic functions. (line 23)
  3552. * gcry_mpi_div: Calculations. (line 50)
  3553. * gcry_mpi_dump: MPI formats. (line 60)
  3554. * gcry_mpi_gcd: Calculations. (line 63)
  3555. * gcry_mpi_get_flag: Miscellaneous. (line 37)
  3556. * gcry_mpi_get_nbits: Bit manipulations. (line 10)
  3557. * gcry_mpi_get_opaque: Miscellaneous. (line 20)
  3558. * gcry_mpi_invm: Calculations. (line 68)
  3559. * gcry_mpi_mod: Calculations. (line 55)
  3560. * gcry_mpi_mul: Calculations. (line 34)
  3561. * gcry_mpi_mul_2exp: Calculations. (line 46)
  3562. * gcry_mpi_mul_ui: Calculations. (line 38)
  3563. * gcry_mpi_mulm: Calculations. (line 42)
  3564. * gcry_mpi_new: Basic functions. (line 10)
  3565. * gcry_mpi_powm: Calculations. (line 59)
  3566. * gcry_mpi_print: MPI formats. (line 45)
  3567. * gcry_mpi_randomize: Miscellaneous. (line 41)
  3568. * gcry_mpi_release: Basic functions. (line 26)
  3569. * gcry_mpi_rshift: Bit manipulations. (line 29)
  3570. * gcry_mpi_scan: MPI formats. (line 12)
  3571. * gcry_mpi_set: Basic functions. (line 33)
  3572. * gcry_mpi_set_bit: Bit manipulations. (line 16)
  3573. * gcry_mpi_set_flag: Miscellaneous. (line 26)
  3574. * gcry_mpi_set_highbit: Bit manipulations. (line 22)
  3575. * gcry_mpi_set_opaque: Miscellaneous. (line 8)
  3576. * gcry_mpi_set_ui: Basic functions. (line 37)
  3577. * gcry_mpi_snew: Basic functions. (line 17)
  3578. * gcry_mpi_sub: Calculations. (line 22)
  3579. * gcry_mpi_sub_ui: Calculations. (line 26)
  3580. * gcry_mpi_subm: Calculations. (line 30)
  3581. * gcry_mpi_swap: Basic functions. (line 44)
  3582. * gcry_mpi_t: Data types. (line 7)
  3583. * gcry_mpi_test_bit: Bit manipulations. (line 13)
  3584. * gcry_pk_algo_info: General public-key related Functions.
  3585. (line 46)
  3586. * gcry_pk_algo_name: General public-key related Functions.
  3587. (line 10)
  3588. * gcry_pk_check_secret_key_t: Public key modules. (line 91)
  3589. * gcry_pk_ctl: General public-key related Functions.
  3590. (line 96)
  3591. * gcry_pk_decrypt: Cryptographic Functions.
  3592. (line 85)
  3593. * gcry_pk_decrypt_t: Public key modules. (line 101)
  3594. * gcry_pk_encrypt: Cryptographic Functions.
  3595. (line 29)
  3596. * gcry_pk_encrypt_t: Public key modules. (line 96)
  3597. * gcry_pk_generate_t: Public key modules. (line 86)
  3598. * gcry_pk_genkey: General public-key related Functions.
  3599. (line 111)
  3600. * gcry_pk_get_keygrip: General public-key related Functions.
  3601. (line 28)
  3602. * gcry_pk_get_nbits: General public-key related Functions.
  3603. (line 23)
  3604. * gcry_pk_get_nbits_t: Public key modules. (line 116)
  3605. * gcry_pk_list: Public key modules. (line 131)
  3606. * gcry_pk_map_name: General public-key related Functions.
  3607. (line 15)
  3608. * gcry_pk_register: Public key modules. (line 121)
  3609. * gcry_pk_sign: Cryptographic Functions.
  3610. (line 117)
  3611. * gcry_pk_sign_t: Public key modules. (line 106)
  3612. * gcry_pk_spec_t: Public key modules. (line 12)
  3613. * gcry_pk_test_algo: General public-key related Functions.
  3614. (line 19)
  3615. * gcry_pk_testkey: General public-key related Functions.
  3616. (line 39)
  3617. * gcry_pk_unregister: Public key modules. (line 127)
  3618. * gcry_pk_verify: Cryptographic Functions.
  3619. (line 170)
  3620. * gcry_pk_verify_t: Public key modules. (line 111)
  3621. * gcry_randomize: Retrieving random numbers.
  3622. (line 8)
  3623. * gcry_set_allocation_handler: Allocation handler. (line 34)
  3624. * gcry_set_fatalerror_handler: Error handler. (line 25)
  3625. * gcry_set_log_handler: Logging handler. (line 12)
  3626. * gcry_set_outofcore_handler: Error handler. (line 15)
  3627. * gcry_set_progress_handler: Progress handler. (line 21)
  3628. * gcry_sexp_build: Working with S-expressions.
  3629. (line 43)
  3630. * gcry_sexp_canon_len: Working with S-expressions.
  3631. (line 116)
  3632. * gcry_sexp_car: Working with S-expressions.
  3633. (line 146)
  3634. * gcry_sexp_cdr: Working with S-expressions.
  3635. (line 151)
  3636. * gcry_sexp_create: Working with S-expressions.
  3637. (line 26)
  3638. * gcry_sexp_dump: Working with S-expressions.
  3639. (line 107)
  3640. * gcry_sexp_find_token: Working with S-expressions.
  3641. (line 129)
  3642. * gcry_sexp_length: Working with S-expressions.
  3643. (line 136)
  3644. * gcry_sexp_new: Working with S-expressions.
  3645. (line 13)
  3646. * gcry_sexp_nth: Working with S-expressions.
  3647. (line 141)
  3648. * gcry_sexp_nth_data: Working with S-expressions.
  3649. (line 159)
  3650. * gcry_sexp_nth_mpi: Working with S-expressions.
  3651. (line 177)
  3652. * gcry_sexp_release: Working with S-expressions.
  3653. (line 76)
  3654. * gcry_sexp_sprint: Working with S-expressions.
  3655. (line 84)
  3656. * gcry_sexp_sscan: Working with S-expressions.
  3657. (line 37)
  3658. * gcry_sexp_t: Data types for S-expressions.
  3659. (line 7)
  3660. * gcry_strerror: Error Strings. (line 7)
  3661. * gcry_strsource: Error Strings. (line 13)
  3662. * int <1>: Working with sets of data.
  3663. (line 51)
  3664. * int: Working with hash algorithms.
  3665. (line 184)
  3666. 
  3667. Tag Table:
  3668. Node: Top730
  3669. Node: Introduction6207
  3670. Node: Getting Started6581
  3671. Node: Features7464
  3672. Node: Overview8254
  3673. Node: Preparation8902
  3674. Node: Header9700
  3675. Node: Building sources10583
  3676. Node: Building sources using Automake12505
  3677. Node: Initializing the library13686
  3678. Node: Multi Threading14729
  3679. Ref: Multi Threading-Footnote-118634
  3680. Node: Generalities19042
  3681. Node: Controlling the library19367
  3682. Node: Modules19751
  3683. Node: Error Handling20530
  3684. Node: Error Values23055
  3685. Node: Error Sources27995
  3686. Node: Error Codes30266
  3687. Node: Error Strings33227
  3688. Node: Handler Functions34379
  3689. Node: Progress handler34938
  3690. Node: Allocation handler36885
  3691. Node: Error handler38180
  3692. Node: Logging handler39237
  3693. Node: Symmetric cryptography39743
  3694. Node: Available ciphers40532
  3695. Node: Cipher modules42436
  3696. Node: Available cipher modes46959
  3697. Node: Working with cipher handles47638
  3698. Node: General cipher functions55498
  3699. Node: Hashing57975
  3700. Node: Available hash algorithms58781
  3701. Node: Hash algorithm modules60808
  3702. Node: Working with hash algorithms64655
  3703. Node: Public Key cryptography (I)75048
  3704. Node: Available algorithms75901
  3705. Node: Used S-expressions76254
  3706. Node: Public key modules78046
  3707. Node: Cryptographic Functions83634
  3708. Node: General public-key related Functions91123
  3709. Node: Public Key cryptography (II)98345
  3710. Node: Available asymmetric algorithms99252
  3711. Node: Working with sets of data99932
  3712. Node: Working with handles102954
  3713. Node: Working with keys103898
  3714. Node: Using cryptographic functions107960
  3715. Node: Handle-independent functions109778
  3716. Node: Random Numbers110392
  3717. Node: Quality of random numbers110687
  3718. Node: Retrieving random numbers111343
  3719. Node: S-expressions112755
  3720. Node: Data types for S-expressions113399
  3721. Node: Working with S-expressions113725
  3722. Node: MPI library122259
  3723. Node: Data types123567
  3724. Node: Basic functions123773
  3725. Node: MPI formats125841
  3726. Node: Calculations128631
  3727. Node: Comparisons130886
  3728. Node: Bit manipulations131504
  3729. Node: Miscellaneous132648
  3730. Node: Utilities134492
  3731. Node: Memory allocation134696
  3732. Node: Library Copying135952
  3733. Node: Copying164116
  3734. Node: Concept Index183319
  3735. Node: Function and Data Index184274
  3736. 
  3737. End Tag Table