## Function

cdk_error_t cdk_armor_filter_use (cdk_stream_t inp )

### Arguments

cdk_stream_t inp
  the stream to check

### Description

Check if the stream contains armored data.

## Function

cdk_error_t cdk_file_armor (cdk_ctx_t hd , const char * file , const char * output )

### Arguments

cdk_ctx_t hd
  Handle
const char * file
  Name of the file to protect.
const char * output
  Output filename.

### Description

Protect a file with ASCII armor.

## Function

cdk_error_t cdk_file_dearmor (const char * file , const char * output )

### Arguments

const char * file
  Name of the file to unprotect.
const char * output
  Output filename.

### Description

Remove ASCII armor from a file.

## Function

cdk_error_t cdk_stream_encrypt (cdk_ctx_t hd , cdk_strlist_t remusr , cdk_stream_t inp , cdk_stream_t out )

### Arguments

cdk_ctx_t hd
  Handle
cdk_strlist_t remusr
  List of recipients
cdk_stream_t inp
  Input stream handle
cdk_stream_t out
  Output stream handle

### Description

If remusr is NULL, then symmetric encryption is used. Via the handle the caller can set or unset multiple options.

## Function

cdk_error_t cdk_file_encrypt (cdk_ctx_t hd , cdk_strlist_t remusr , const char * file , const char * output )

### Arguments

cdk_ctx_t hd
  Handle
cdk_strlist_t remusr
  List of recipient
const char * file
  Input file
const char * output
  Output file

## Function

cdk_error_t cdk_file_decrypt (cdk_ctx_t hd , const char * file , const char * output )

### Arguments

cdk_ctx_t hd
  Handle.
const char * file
  Name of the file to decrypt.
const char * output
  Output filename.

### Description

When the operation was successfull, hd can contain information about the signature (when present) and more.

## Function

cdk_error_t cdk_data_transform (cdk_ctx_t hd , enum cdk_crypto_mode_t mode , cdk_strlist_t locusr , cdk_strlist_t remusr , const void * inbuf , size_t insize , byte ** outbuf , size_t * outsize , int modval )

### Arguments

cdk_ctx_t hd
  session handle
enum cdk_crypto_mode_t mode
  crypto mode
cdk_strlist_t locusr
  local user list (sign mode only)
cdk_strlist_t remusr
  remote users 'recipients'
const void * inbuf
  input buffer with data
size_t insize
  length of data in bytes
byte ** outbuf
  pointer to the output data (will be allocated)
size_t * outsize
  size of the new data in bytes
int modval
  value for the modus (for example sign mode)

### Description

This function transforms data into the given openpgp mode. It works exactly like the cdk_file_xxx functions with the exception that it can be used with memory and not with streams or files.

## Function

cdk_kbnode_t cdk_kbnode_new (cdk_packet_t pkt )

### Arguments

cdk_packet_t pkt
  the packet to add

### Description

Allocate a new key node and add the packet.

## Function

void cdk_kbnode_release (cdk_kbnode_t node )

### Arguments

cdk_kbnode_t node

### Description

Release the memory of the node.

## Function

void cdk_kbnode_delete (cdk_kbnode_t node )

### Arguments

cdk_kbnode_t node
  the ke keynode.

### Description

Delete @node.

## Function

void cdk_kbnode_insert (cdk_kbnode_t root , cdk_kbnode_t node , int pkttype )

### Arguments

cdk_kbnode_t root
  the root key node
cdk_kbnode_t node
  the node to add
int pkttype
  packet type

### Description

Insert @node into the list after @root but before a packet which is not of type @pkttype (only if @pkttype != 0).

## Function

cdk_kbnode_t cdk_kbnode_find_prev (cdk_kbnode_t root , cdk_kbnode_t node , int pkttype )

### Arguments

cdk_kbnode_t root
  the root key node
cdk_kbnode_t node
  the key node
int pkttype
  packet type

### Description

Find the previous node (if @pkttype = 0) or the previous node with pkttype @pkttype in the list starting with @root of @node.

## Function

cdk_kbnode_t cdk_kbnode_find_next (cdk_kbnode_t node , int pkttype )

### Arguments

cdk_kbnode_t node
  the key node
int pkttype
  packet type

### Description

Ditto, but find the next packet. The behaviour is trivial if @pkttype is 0 but if it is specified, the next node with a packet of this type is returned. The function has some knowledge about

### the valid ordering of packets

e.g. if the next signature packet is requested, the function will not return one if it encounters a user-id.

## Function

cdk_kbnode_t cdk_kbnode_find (cdk_kbnode_t node , int pkttype )

### Arguments

cdk_kbnode_t node
  the key node
int pkttype
  packet type

### Description

Try to find the next node with the packettype @pkttype.

## Function

cdk_packet_t cdk_kbnode_find_packet (cdk_kbnode_t node , int pkttype )

### Arguments

cdk_kbnode_t node
  the key node
int pkttype
  packet type

### Description

Same as cdk_kbnode_find but it returns the packet instead of the node.

## Function

cdk_packet_t cdk_kbnode_get_packet (cdk_kbnode_t node )

### Arguments

cdk_kbnode_t node
  the key node

### Description

Return the packet which is stored inside the node in @node.

## Function

cdk_error_t cdk_kbnode_read_from_mem (cdk_kbnode_t * ret_node , const byte * buf , size_t buflen )

### Arguments

cdk_kbnode_t * ret_node
  the new key node
const byte * buf
  the buffer which stores the key sequence
size_t buflen
  the length of the buffer

### Description

Try to read a key node from the memory buffer @buf.

## Function

cdk_error_t cdk_kbnode_write_to_mem (cdk_kbnode_t node , byte * buf , size_t * r_nbytes )

### Arguments

cdk_kbnode_t node
  the key node
byte * buf
  the buffer to store the node data
size_t * r_nbytes
  the new length of the buffer.

### Description

Try to write the contents of the key node to the buffer @buf and return the length of it in @r_nbytes. If buf is zero, only the length of the node is calculated and returned in @r_nbytes.

## Function

void * cdk_kbnode_get_attr (cdk_kbnode_t node , int pkttype , int attr )

### Arguments

cdk_kbnode_t node
  the key node
int pkttype
  the packet type which the attribute should be retrieved from
int attr
  the attribute to retrive

### Description

Extract a single attribute from the specified packet type. If no packet type is given, it is assumed that the public key is meant. If the attr was found, it is returned as a pointer which can be cast to a proper type.

## Function

cdk_error_t cdk_kbnode_hash (cdk_kbnode_t node , cdk_md_hd_t md , int is_v4 , int pkttype , int flags )

### Arguments

cdk_kbnode_t node
  the key node
cdk_md_hd_t md
int is_v4
  OpenPGP signature (yes=1, no=0)
int pkttype
  packet type to hash (if zero use the packet type from the node)
int flags
  flags which depend on the operation

### Description

Hash the key node contents. Two modes are supported. If the packet type is used (!= 0) then the function searches the first node with this type. Otherwise the node is seen as a single node and the type is extracted from it.

## Function

cdk_error_t cdk_keydb_idx_rebuild (cdk_keydb_hd_t hd )

### Arguments

cdk_keydb_hd_t hd
  key database handle

### Description

Rebuild the key index files for the given key database.

## Function

cdk_error_t cdk_keydb_new (cdk_keydb_hd_t * r_hd , int type , void * data , size_t count )

### Arguments

cdk_keydb_hd_t * r_hd
  handle to store the new keydb object
int type
  type of the keyring
void * data
  data which depends on the keyring type
size_t count
  length of the data

### Description

Create a new keydb object

## Function

void cdk_keydb_free (cdk_keydb_hd_t hd )

### Arguments

cdk_keydb_hd_t hd
  the keydb object

### Description

Free the keydb object.

## Function

cdk_error_t cdk_keydb_open (cdk_keydb_hd_t hd , cdk_stream_t * ret_kr )

### Arguments

cdk_keydb_hd_t hd
  keydb object
cdk_stream_t * ret_kr
  the STREAM object which contains the data of the keyring

### Description

Open a STREAM with the contents of the keyring from @hd

## Function

cdk_error_t cdk_keydb_search_start (cdk_keydb_hd_t db , int type , void * desc )

### Arguments

cdk_keydb_hd_t db
  key database handle
int type
  specifies the search type
void * desc
  description which depends on the type

### Description

Create a new keydb search object.

## Function

cdk_error_t cdk_keydb_search (cdk_keydb_hd_t hd , cdk_kbnode_t * ret_key )

### Arguments

cdk_keydb_hd_t hd
  the keydb object
cdk_kbnode_t * ret_key
  kbnode object to store the key

### Description

Search for a key in the given keyring. The search mode is handled via @ks. If the key was found, @ret_key contains the key data.

## Function

cdk_error_t cdk_listkey_start (cdk_listkey_t * r_ctx , cdk_keydb_hd_t db , const char * patt , cdk_strlist_t fpatt )

### Arguments

cdk_listkey_t * r_ctx
  pointer to store the new context
cdk_keydb_hd_t db
  the key database handle
const char * patt
  string pattern
cdk_strlist_t fpatt
  recipients from a stringlist to show

### Description

Prepare a key listing with the given parameters. Two modes are supported. The first mode uses string pattern to determine if the key should be returned or not. The other mode uses a string list to request the key which should be listed.

## Function

void cdk_listkey_close (cdk_listkey_t ctx )

### Arguments

cdk_listkey_t ctx
  the list key context

### Description

Free the list key context.

## Function

cdk_error_t cdk_listkey_next (cdk_listkey_t ctx , cdk_kbnode_t * ret_key )

### Arguments

cdk_listkey_t ctx
  list key context
cdk_kbnode_t * ret_key

### Description

Retrieve the next key from the pattern of the key list context.

## Function

cdk_error_t cdk_keygen_set_prefs (cdk_keygen_ctx_t hd , enum cdk_pref_type_t type , const byte * array , size_t n )

### Arguments

cdk_keygen_ctx_t hd
  the preference type
enum cdk_pref_type_t type
const byte * array
  one-octet array with algorithm numers
size_t n

## Function

void cdk_keygen_set_name (cdk_keygen_ctx_t hd , const char * name )

### Arguments

cdk_keygen_ctx_t hd
  the keygen object
const char * name
  name

### Description

The name will be encoded in UTF8 to avoid problems.

## Function

cdk_error_t cdk_keygen_set_algo_info (cdk_keygen_ctx_t hd , int type , enum cdk_pk_algo_t algo , int bits )

### Arguments

cdk_keygen_ctx_t hd
  the keygen object.
int type
  key type (primary=0, subkey=1)
enum cdk_pk_algo_t algo
  algorithm compliant with rfc2440
int bits
  lengt of the key in bits

## Function

void cdk_keygen_set_mdc_feature (cdk_keygen_ctx_t hd , int val )

### Arguments

cdk_keygen_ctx_t hd
  keygen object
int val
  boolean( yes=1, no=0)

### Description

if you want a RFC2440 compliant key, you've to disable this feature until the rfc2440-bis8 becomes the next standard.

## Function

void cdk_keygen_set_expire_date (cdk_keygen_ctx_t hd , int type , long timestamp )

### Arguments

cdk_keygen_ctx_t hd
  keygen object
int type
  key type( 0=primary, 1=seconardy)
long timestamp
  the date the key should expire

## Function

cdk_error_t cdk_keygen_start (cdk_keygen_ctx_t hd )

### Arguments

cdk_keygen_ctx_t hd
  the keygen object

## Function

cdk_error_t cdk_keygen_save (cdk_keygen_ctx_t hd , const char * pubf , const char * secf )

### Arguments

cdk_keygen_ctx_t hd
  the keygen object
const char * pubf
const char * secf

## Function

void cdk_keygen_free (cdk_keygen_ctx_t hd )

### Arguments

cdk_keygen_ctx_t hd
  the keygen object

## Function

cdk_error_t cdk_keygen_new (cdk_keygen_ctx_t * r_hd )

### Arguments

cdk_keygen_ctx_t * r_hd
  the new object

## Function

int cdk_pklist_select_algo (cdk_keylist_t pkl , int preftype )

### Arguments

cdk_keylist_t pkl
  the keylist
int preftype
  preference type

### Description

Select a symmetric cipher algorithm from a list of public keys. This algorithm is present in all key preferences.

## Function

void cdk_pklist_release (cdk_keylist_t pkl )

### Arguments

cdk_keylist_t pkl
  the keylist

### Description

Free the memory of the key list.

## Function

cdk_error_t cdk_pklist_build (cdk_keylist_t * ret_pkl , cdk_keydb_hd_t hd , cdk_strlist_t remusr , int use )

### Arguments

cdk_keylist_t * ret_pkl
  the new keylist
cdk_keydb_hd_t hd
  the session handle
cdk_strlist_t remusr
  the string list of the recipients
int use
  public key usage

### Description

Create a public key list based on the recipient names in @remusr.

## Function

cdk_error_t cdk_pklist_encrypt (cdk_keylist_t pk_list , cdk_dek_t dek , cdk_stream_t outp )

### Arguments

cdk_keylist_t pk_list
cdk_dek_t dek
  the data encryption key
cdk_stream_t outp
  the stream to write in the data

### Description

Encrypt the session key with each key of the list and wrap it into a PUBKEY_ENC packet and write it to @outp.

## Function

void cdk_sklist_release (cdk_keylist_t sk_list )

### Arguments

cdk_keylist_t sk_list

### Description

Free the memory of the secret keylist.

## Function

cdk_error_t cdk_sklist_write_onepass (cdk_keylist_t skl , cdk_stream_t outp , int sigclass , int mdalgo )

### Arguments

cdk_keylist_t skl
  secret keylist
cdk_stream_t outp
  the stream to write in the data
int sigclass
  the class of the sig to create
int mdalgo
  the message digest algorithm

### Description

Write a one-pass signature for each key in the list into @outp.

## Function

cdk_error_t cdk_sklist_write (cdk_keylist_t skl , cdk_stream_t outp , cdk_md_hd_t hash , int sigclass , int sigver )

### Arguments

cdk_keylist_t skl
  secret keylist
cdk_stream_t outp
  the stream to write in the data
cdk_md_hd_t hash
  opaque handle for the message digest operations
int sigclass
  the class of the sig
int sigver
  version of the sig

### Description

Complete the sig based on @hash and write all signatures to @outp.

## Function

cdk_error_t cdk_keyserver_recv_key (const char * host , int port , const byte * keyid , int kid_type , cdk_kbnode_t * ret_key )

### Arguments

const char * host
  URL or hostname of the keyserver
int port
  The port to use for the connection
const byte * keyid
  KeyID of the key to retrieve
int kid_type
  KeyID type (long, short, fingerprint)
cdk_kbnode_t * ret_key

### Description

Receive a key from a keyserver.

## Function

const char * cdk_strerror (int ec )

### Arguments

int ec
  the error number

### Description

Return an error text for the given id.

## Function

void cdk_set_malloc_hooks (void * (*new_alloc_func )

### Arguments

void * (*new_alloc_func

### Description

Set private memory hooks for the lib.

## Function

int cdk_malloc_hook_initialized ( void )

### Arguments

void

### Description

Return if the malloc hooks are already initialized.

## Function

void cdk_set_log_handler (cdk_log_fnc_t logfnc , void * opaque )

### Arguments

cdk_log_fnc_t logfnc
  the function pointer
void * opaque
  a private values for the function

### Description

set a private handler for logging.

## Function

void cdk_set_log_level (int lvl )

### Arguments

int lvl
  the level

### Description

set the verbosity level.

## Function

int cdk_handle_control (cdk_ctx_t hd , int action , int cmd , ... )

### Arguments

cdk_ctx_t hd
  session handle
int action
  flag which indicates whether put or get is requested
int cmd
  command id
...

### Description

Perform various control operations for the current session.

## Function

int cdk_handle_new (cdk_ctx_t * r_ctx )

### Arguments

cdk_ctx_t * r_ctx
  context to store the handle

### Description

create a new session handle.

## Function

void cdk_handle_set_keydb (cdk_ctx_t hd , cdk_keydb_hd_t db )

### Arguments

cdk_ctx_t hd
  session handle
cdk_keydb_hd_t db
  the database handle

### Description

set the key database handle. the function automatically detects whether this is a public or secret keyring and the right handle is set.

## Function

cdk_keydb_hd_t cdk_handle_get_keydb (cdk_ctx_t hd , int type )

### Arguments

cdk_ctx_t hd
  session handle
int type
  type of the keyring

### Description

Return the keydb handle from the session handle.

## Function

void cdk_handle_set_callback (cdk_ctx_t hd , void (*cb )

### Arguments

cdk_ctx_t hd
  the handle
void (*cb

### Description

set the callback for filter operations.

## Function

void cdk_handle_set_passphrase_cb (cdk_ctx_t hd , char * (*cb )

### Arguments

cdk_ctx_t hd
  session handle
char * (*cb

### Description

set the passphrase callback.

## Function

void cdk_handle_free (cdk_ctx_t hd )

### Arguments

cdk_ctx_t hd
  the handle

### Description

free the main handle.

## Function

const char * cdk_check_version (const char * req_version )

### Arguments

const char * req_version
  The requested version

### Description

Check that the the version of the library is at minimum the requested one and return the version string; return NULL if the condition is not satisfied. If a NULL is passed to this function, no check is done, but the version string is simply returned.

## Function

void cdk_subpkt_free (cdk_subpkt_t ctx )

### Arguments

cdk_subpkt_t ctx
  the sub packet node to free

### Description

Release the context.

## Function

cdk_subpkt_t cdk_subpkt_find (cdk_subpkt_t ctx , int type )

### Arguments

cdk_subpkt_t ctx
  the sub packet node
int type
  the packet type to find

### Description

Find the given packet type in the node. If no packet with this type was found, return null otherwise pointer to the node.

## Function

cdk_subpkt_t cdk_subpkt_new (size_t size )

### Arguments

size_t size
  the size of the new context

### Description

Create a new sub packet node with the size of @size.

## Function

const byte * cdk_subpkt_get_data (cdk_subpkt_t ctx , int * r_type , size_t * r_nbytes )

### Arguments

cdk_subpkt_t ctx
  the sub packet node
int * r_type
  pointer store the packet type
size_t * r_nbytes
  pointer to store the packet size

### Description

Extract the data from the given sub packet. The type is returned in @r_type and the size in @r_nbytes.

## Function

cdk_error_t cdk_subpkt_add (cdk_subpkt_t root , cdk_subpkt_t node )

### Arguments

cdk_subpkt_t root
  the root node
cdk_subpkt_t node
  the node to add

### Description

Add the node in @node to the root node @root.

## Function

void cdk_subpkt_init (cdk_subpkt_t node , int type , const void * buf , size_t buflen )

### Arguments

cdk_subpkt_t node
  the sub packet node
int type
  type of the packet which data should be initialized
const void * buf
  the buffer with the actual data
size_t buflen
  the size of the data

### Description

Set the packet data of the given root and set the type of it.

## Function

cdk_error_t cdk_pk_encrypt (cdk_pkt_pubkey_t pk , cdk_pkt_pubkey_enc_t pke , cdk_sesskey_t esk )

### Arguments

cdk_pkt_pubkey_t pk
  the public key
cdk_pkt_pubkey_enc_t pke
  the public key encrypted packet
cdk_sesskey_t esk
  the actual session key

### Description

Encrypt the session key in @esk and write its encrypted content into the @pke struct.

## Function

cdk_error_t cdk_pk_decrypt (cdk_pkt_seckey_t sk , cdk_pkt_pubkey_enc_t pke , cdk_sesskey_t * r_sk )

### Arguments

cdk_pkt_seckey_t sk
  the secret key
cdk_pkt_pubkey_enc_t pke
  public key encrypted packet
cdk_sesskey_t * r_sk
  the object to store the plain session key

### Description

Decrypt the encrypted session key from @pke into @r_sk.

## Function

cdk_error_t cdk_pk_sign (cdk_pkt_seckey_t sk , cdk_pkt_signature_t sig , const byte * md )

### Arguments

cdk_pkt_seckey_t sk
  secret key
cdk_pkt_signature_t sig
  signature
const byte * md
  the message digest

### Description

Sign the message digest from @md and write the result into @sig.

## Function

cdk_error_t cdk_pk_verify (cdk_pkt_pubkey_t pk , cdk_pkt_signature_t sig , const byte * md )

### Arguments

cdk_pkt_pubkey_t pk
  the public key
cdk_pkt_signature_t sig
  signature
const byte * md
  the message digest

### Description

Verify the signature in @sig and compare it with the message digest in @md.

## Function

cdk_error_t cdk_pk_from_secret_key (cdk_pkt_seckey_t sk , cdk_pkt_pubkey_t* ret_pk )

### Arguments

cdk_pkt_seckey_t sk
  the secret key
cdk_pkt_pubkey_t* ret_pk
  the new public key

### Description

Create a new public key from a secret key.

## Function

cdk_error_t cdk_pkt_read (cdk_stream_t inp , cdk_packet_t pkt )

### Arguments

cdk_stream_t inp
  the input stream
cdk_packet_t pkt
  allocated packet handle to store the packet

### Description

Parse the next packet on the @inp stream and return its contents in @pkt.

## Function

cdk_error_t cdk_pk_check_sigs (cdk_kbnode_t knode , cdk_keydb_hd_t hd , int * r_status )

### Arguments

cdk_kbnode_t knode
  the key node
cdk_keydb_hd_t hd
  the session handle
int * r_status
  variable to store the status of the key

### Description

Check all signatures. When no key is available for checking, the sigstat is marked as 'NOKEY'. The @r_status contains the key flags which are or-ed or zero when there are no flags.

## Function

cdk_error_t cdk_stream_sign (cdk_ctx_t hd , cdk_stream_t inp , cdk_stream_t out , cdk_strlist_t locusr , cdk_strlist_t remusr , int encryptflag , int sigmode )

### Arguments

cdk_ctx_t hd
  session handle
cdk_stream_t inp
  input stream
cdk_stream_t out
  output stream
cdk_strlist_t locusr
  local user list for signing
cdk_strlist_t remusr
int encryptflag
  shall the output be encrypted? (1/0)
int sigmode
  signature mode

### Description

Sign the data from the STREAM @inp.

## Function

cdk_error_t cdk_file_sign (cdk_ctx_t hd , cdk_strlist_t locusr , cdk_strlist_t remusr , const char * file , const char * output , int sigmode , int encryptflag )

### Arguments

cdk_ctx_t hd
cdk_strlist_t locusr
  List of userid which should be used for signing
cdk_strlist_t remusr
  If encrypt is valid, the list of recipients
const char * file
  Name of the input file
const char * output
  Name of the output file
int sigmode
  Signature mode
int encryptflag

### Description

Sign a file.

## Function

cdk_error_t cdk_stream_open (const char * file , cdk_stream_t * ret_s )

### Arguments

const char * file
  The file to open
cdk_stream_t * ret_s
  The new STREAM object

## Function

cdk_error_t cdk_stream_new (const char * file , cdk_stream_t * ret_s )

### Arguments

const char * file
  The name of the new file
cdk_stream_t * ret_s
  The new STREAM object

## Function

cdk_error_t cdk_stream_create (const char * file , cdk_stream_t * ret_s )

### Arguments

const char * file
  the filename
cdk_stream_t * ret_s
  the object

### Description

The difference to cdk_stream_new is, that no filtering can be used with this kind of stream and everything is written directly to the stream.

## Function

cdk_error_t cdk_stream_close (cdk_stream_t s )

### Arguments

cdk_stream_t s
  The STREAM object.

### Description

This function work different for read or write streams. When the stream is for reading, the filtering is already done and we can simply close the file and all buffers. But for the case it's a write stream, we need to apply all registered filters now. The file is closed in the filter function and not here.

## Function

int cdk_stream_eof (cdk_stream_t s )

### Arguments

cdk_stream_t s
  The STREAM object.

### Description

This function will only work with read streams.

## Function

unsigned cdk_stream_get_length (cdk_stream_t s )

### Arguments

cdk_stream_t s
  The STREAM object.

### Description

This file only works for read stream because it's likely that the write stream is not flushed or even no data was inserted.

## Function

cdk_error_t cdk_stream_filter_disable (cdk_stream_t s , int type )

### Arguments

cdk_stream_t s
  The STREAM object
int type
  The numberic filter ID.

## Function

int cdk_stream_read (cdk_stream_t s , void * buf , size_t count )

### Arguments

cdk_stream_t s
  The STREAM object.
void * buf
  The buffer to insert the readed bytes.
size_t count
  Request so much bytes.

### Description

When this function is called the first time, it can take a while because all filters need to be processed. Please remember that you need to add the filters in reserved order.

## Function

int cdk_stream_write (cdk_stream_t s , const void * buf , size_t count )

### Arguments

cdk_stream_t s
  The STREAM object
const void * buf
  The buffer with the values to write.
size_t count
  The size of the buffer.

### Description

In this function we simply write the bytes to the stream. We can't use the filters here because it would mean they have to support partial flushing.

## Function

cdk_error_t cdk_stream_mmap (cdk_stream_t s , byte ** ret_buf , size_t * ret_count )

### Arguments

cdk_stream_t s
  the stream
byte ** ret_buf
  the buffer to store the content
size_t * ret_count
  length of the buffer

### Description

Map the data of the given stream into a memory section. @ret_count contains the length of the buffer.

## Function

int cdk_stream_peek (cdk_stream_t inp , byte * s , size_t count )

### Arguments

cdk_stream_t inp
  the input stream handle
byte * s
  buffer
size_t count
  number of bytes to peek

### Description

The function acts like cdk_stream_read with the difference that the file pointer is moved to the old position after the bytes were read.

## Function

cdk_error_t cdk_file_verify (cdk_ctx_t hd , const char * file , const char * output )

### Arguments

cdk_ctx_t hd
  the session handle
const char * file
  the input file
const char * output
  the output file

### Description

Verify a signature.

## Function

unsigned long cdk_sig_get_ulong_attr (cdk_ctx_t hd , int idx , int what )

### Arguments

cdk_ctx_t hd
  session handle
int idx
  index of the signature
int what
  attribute id

### Description

Extract the requested attribute of the signature. The returned value is always an integer (max. 32-bit).

## Function

const void * cdk_sig_get_data_attr (cdk_ctx_t hd , int idx , int what )

### Arguments

cdk_ctx_t hd
  session handle
int idx
  index of the signature
int what
  attribute id.

### Description

Extract the requested attribute of the signature. The returned value is always a constant object to the data.

## Function

cdk_error_t cdk_pkt_write (cdk_stream_t out , cdk_packet_t pkt )

### Arguments

cdk_stream_t out
  the output stream handle
cdk_packet_t pkt
  the packet itself

### Description

Write the contents of @pkt into the @out stream.