Copyright (C) 2000-2012 |
Whole document tree The Libgcrypt Reference ManualVersion 1.1.2aCopyright © 2000 by Free Software Foundation, Inc. Please direct questions, bug reports, or suggestions concerning this manual to the mailing list <gnupg-doc@gnupg.org>. This manual may be redistributed under the terms of the GNU General Public License.
I. Libgcrypt Reference Pages
gcry_cipher_openSynopsis#include <gcrypt.h>
gcry_cipher_ctlNamegcry_cipher_ctl, gcry_cipher_setkey, gcry_cipher_setiv, gcry_cipher_setiv -- control cipher functionsSynopsis#include <gcrypt.h>
Descriptiongcry_cipher_ctl controls various aspects of the cipher module and specific cipher contexts. A couple of macros may be used for convenience: gcry_cipher_setkey(h,k,l) gcry_cipher_setiv(h,k,l) gcry_cipher_sync(h) gcry_cipher_infoDescriptiongcry_cipher_info is used to retrieve various information about a cipher context or the cipher module in general. Currently no information is available. gcry_cipher_algo_nameDescriptiongcry_cipher_algo_name returns a string with the name of the cipher algorithm algo. If the algorithm is not known or an other error occured, an empty string is return. This function will never return NULL. gcry_cipher_map_nameDescriptiongcry_cipher_map_name returns the algorithm identifier for the cipher algorithm described by the string name. If this algorith is not available 0 is returned. gcry_cipher_encryptSynopsis#include <gcrypt.h>
Descriptiongcry_cipher_encrypt is used to encrypt the data. the complemetary function gcry_cipher_decrypt is be used to decrypt the data. The calling convention for both functions is the same. These functions can either work in place or with two buffers. Overlapping buffers are not allowed. gcry_md_openSynopsis#include <gcrypt.h>
Descriptiongcry_md_open creates the context required for the message digest functions. The hash algorithm may optionally be specified. It is possible to use these functions as MAC functons; therefore the flag GCRY_MD_FLAG_HMAC must be given along with the hash functions. Other MAC algorithms than HMAC are currently not supported. The key for the MAC must be set using the gcry_md_setkey function. gcry_md_close releases all resources associated with the context. gcry_md_enable may be used to enable hash algorithms. This function may be used multiple times to create a hash context for multiple algorithms. Adding an already enabled algorithm has no effect. A algorithm must be enabled prios to calculate hash algorithms. gcry_md_copyDescriptiongcry_md_copy creates an excat copy of the given context. This is useful to calculate hashes with a common initial part of the plaintext. gcry_md_resetDescriptiongcry_md_reset is used to reuse a message context without the overhead of an open and close operation. gcry_md_ctlSynopsis#include <gcrypt.h>
Descriptiongcry_md_ctl is a multi-purpose function to control the behaviour of all gcry_md functions or one instance of it. Currently defined values for cmd are: GCRYCTL_FINALIZE and the convenience macro gcry_md_final(a) GCRYCTL_SET_KEY and the convenience macro gcry_md_setkey(a). This is used to turn these hash functions into MAC functions. The key may be any string of the speicified length. The type of the MAC is determined by special flags set with the open function. NEW: There is now a function to do this gcry_md_writeSynopsis#include <gcrypt.h>
Descriptiongcry_md_write is used to actually calulate the message digest of a buffer. This function updates the internal state of the message digest. gcry_md_putc is a macro which is used to update the message digest by one byte. this is the preferred way to calculate a digest if only a few bytes at a time are available. gcry_md_readDescriptiongcry_md_read returns the message digest after finalizing the calculation. This function may be used as often as required but it will alwas return the same value for one handle. The returned message digest is allocated within the message context and therefore valid until the conext is released. algo may be given as 0 to return the only enbaled message digest or it may specify one of the enabled algorithms. The function will return NULL if the algorithm has not been enabled. gcry_md_infoSynopsis#include <gcrypt.h>
Descriptiongcry_md_info returns some information about the handle or an global parameter. The only defined value for what is GCRYCTL_IS_SECURE to return whether the handle has been allocated in secure memory. Buffer and buflen are not needed in this cases. The convenience macro gcry_md_is_secure(a) may be also used for this purpose. gcry_md_algo_infoNamegcry_md_algo_info, gcry_md_test_algo, gcry_md_get_algo_dlen -- get information about an algorithmSynopsis#include <gcrypt.h>
Descriptiongcry_md_algo_info returns some information about an algorithm. On error the value -1 is return and a more detailed error description is available with gcry_errno. The defined values for what are GCRYCTL_TEST_ALGO to return whether the algorithm is supported. Buffer and buflen are not needed in this cases. The convenience macro gcry_md_test_algo(a) may be used for this purpose. GCRYCTL_GET_ASNOID to return whether the ASN.1 object identifier. IF buffer is specified as NULL, only the required length for the buffer is returned. gcry_md_get_algo_dlen returns the length of the digest for a given algorithm in bytes. gcry_md_algo_nameSynopsis#include <gcrypt.h>
DescriptionThese both functions are used to map a string with the algorithm name to the internal algorithm identifier value and vice versa. gcry_md_algo_name never returns NULL even in cases where the algorithm string is not available. Instead a string consisting of a single question mark is returned. Do not use this function to test for the existence of an algorithm. gcry_md_map_name returns 0 if the algorithm is not known to Libgcrypt. gcry_md_hash_bufferSynopsis#include <gcrypt.h>
Descriptiongcry_md_hash_buffer is a shortcut function to calculate a message digest of a buffer. This function does not require a context and immediatley returns the message digest. digest must be string large enough to hold the digest given by algo. This length may be obtained by using the function gcry_md_get_algo_dlen but in most cases it will be a statically allocated buffer. gcry_pk_encryptSynopsis#include <gcrypt.h>
Descriptiongcry_pk_encrypt performs public key encryption operations. The caller has to provide a public key as the S-Exp pkey and data as a S-Exp with just one MPI in it. The function returns a S-Exp which may be passed tp to pk_decrypt. Later versions of this functions may take more complex input data. Returns: 0 or an errorcode. s_data = (mpi) gcry_check_versionDescriptiongcry_check_version checks that the version of the library is at minimum the requested one and return the version string; NULL is returned if the condition is not met. You may pass NULL as reqy_version to simply get the version string back without any checking. gcry_errnoDescriptionBoth function are to be used like there Standard-C counterparts. However gcry_errno is a function and not just a global variable. If -1 is passed to gcry_strerror, gcry_errno is implictly used. gcry_controlDescriptionThis function is used to control various aspects of Libgcrypt FIXME: Explain all commands here. gcry_set_allocation_handlerNamegcry_set_allocation_handler, gcry_set_outofcore_handler -- Use application defined malloc functionsSynopsis#include <gcrypt.h>
gcry_set_fatalerror_handlerSynopsis#include <gcrypt.h>
DescriptionAt certain places the Libgcrypt may need to call a fatal error fucntion which does terminate the process. To allow an application to do some emergency cleanup, it may register a fatal error handler with the library. This handler is assumed to terminate the application; however if it returns Libgcrypt will abort anyway. The handler is called with the opaque value registered here, an errorcode from Libgcrypt and some descriptive text string. gcry_set_gettext_handlerSynopsis#include <gcrypt.h>
gcry_set_log_handlerSynopsis#include <gcrypt.h>
DescriptionLibgcrypt has it;s own logging functions. Applications which need to use their own, should provide a log function to Libgcrypt so that it will use this function instead. Fixme: Describe how this is intended to work. gcry_mallocNamegcry_malloc, gcry_calloc, gcry_malloc_secure, gcry_calloc_secure, gcry_realloc, gcry_xmalloc, gcry_xcalloc, gcry_xmalloc_secure, gcry_xcalloc_secure, gcry_xrealloc, gcry_xstrdup, gcry_malloc, gcry_malloc -- Change the default logging function |