ol sec_port_ucs4_utf8_conversion_function ( PRBool toUnicode, unsigned char *inBuf, unsigned int inBufLen, unsigned char *outBuf, unsigned int maxOutBufLen, unsigned int *outBufLen ); extern PRBool sec_port_ucs2_utf8_conversion_function ( PRBool toUnicode, unsigned char *inBuf, unsigned int inBufLen, unsigned char *outBuf, unsigned int maxOutBufLen, unsigned int *outBufLen ); /* One-way conversion from ISO-8859-1 to UTF-8 */ extern PRBool sec_port_iso88591_utf8_conversion_function ( const unsigned char *inBuf, unsigned int inBufLen, unsigned char *outBuf, unsigned int maxOutBufLen, unsigned int *outBufLen ); extern int NSS_PutEnv(const char * envVarName, const char * envValue); SEC_END_PROTOS #endif /* _SECPORT_H_ */ /* DO NOT EDIT THIS FILE. It has been auto-edited by fixincludes from: "/usr/include/libdevmapper.h" This had to be done to correct non-standard usages in the original, manufacturer supplied header file. */ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. * * This file is part of the device-mapper userspace tools. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU Lesser General Public License v.2.1. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef LIB_DEVICE_MAPPER_H #define LIB_DEVICE_MAPPER_H #include #include #include #ifdef __linux__ # include #endif #include #include #include #include /***************************************************************** * The first section of this file provides direct access to the * individual device-mapper ioctls. ****************************************************************/ /* * Since it is quite laborious to build the ioctl * arguments for the device-mapper people are * encouraged to use this library. * * You will need to build a struct dm_task for * each ioctl command you want to execute. */ typedef void (*dm_log_fn) (int level, const char *file, int line, const char *f, ...) __attribute__ ((format(printf, 4, 5))); /* * The library user may wish to register their own * logging function, by default errors go to stderr. * Use dm_log_init(NULL) to restore the default log fn. */ void dm_log_init(dm_log_fn fn); void dm_log_init_verbose(int level); enum { DM_DEVICE_CREATE, DM_DEVICE_RELOAD, DM_DEVICE_REMOVE, DM_DEVICE_REMOVE_ALL, DM_DEVICE_SUSPEND, DM_DEVICE_RESUME, DM_DEVICE_INFO, DM_DEVICE_DEPS, DM_DEVICE_RENAME, DM_DEVICE_VERSION, DM_DEVICE_STATUS, DM_DEVICE_TABLE, DM_DEVICE_WAITEVENT, DM_DEVICE_LIST, DM_DEVICE_CLEAR, DM_DEVICE_MKNODES, DM_DEVICE_LIST_VERSIONS, DM_DEVICE_TARGET_MSG, DM_DEVICE_SET_GEOMETRY }; struct dm_task; struct dm_task *dm_task_create(int type); void dm_task_destroy(struct dm_task *dmt); int dm_task_set_name(struct dm_task *dmt, const char *name); int dm_task_set_uuid(struct dm_task *dmt, const char *uuid); /* * Retrieve attributes after an info. */ struct dm_info { int exists; int suspended; int live_table; int inactive_table; int32_t open_count; uint32_t event_nr; uint32_t major; uint32_t minor; /* minor device number */ int read_only; /* 0:read-write; 1:read-only */ int32_t target_count; }; struct dm_deps { uint32_t count; uint32_t filler; uint64_t device[0]; }; struct dm_names { uint64_t dev; uint32_t next; /* Offset to next struct from start of this struct */ char name[0]; }; struct dm_versions { uint32_t next; /* Offset to next struct from start of this struct */ uint32_t version[3]; char name[0]; }; int dm_get_library_version(char *version, size_t size); int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size); int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi); const char *dm_task_get_name(const struct dm_task *dmt); const char *dm_task_get_uuid(const struct dm_task *dmt); struct dm_deps *dm_task_get_deps(struct dm_task *dmt); struct dm_names *dm_task_get_names(struct dm_task *dmt); struct dm_versions *dm_task_get_versions(struct dm_task *dmt); int dm_task_set_ro(struct dm_task *dmt); int dm_task_set_newname(struct dm_task *dmt, const char *newname); int dm_task_set_minor(struct dm_task *dmt, int minor); int dm_task_set_major(struct dm_task *dmt, int major); int dm_task_set_uid(struct dm_task *dmt, uid_t uid); int dm_task_set_gid(struct dm_task *dmt, gid_t gid); int dm_task_set_mode(struct dm_task *dmt, mode_t mode); int dm_task_set_event_nr(struct dm_task *dmt, uint32_t event_nr); int dm_task_set_geometry(struct dm_task *dmt, const char *cylinders, const char *heads, const char *sectors, const char *start); int dm_task_set_message(struct dm_task *dmt, const char *message); int dm_task_set_sector(struct dm_task *dmt, uint64_t sector); int dm_task_no_flush(struct dm_task *dmt); int dm_task_no_open_count(struct dm_task *dmt); int dm_task_skip_lockfs(struct dm_task *dmt); int dm_task_suppress_identical_reload(struct dm_task *dmt); /* * Control read_ahead. */ #define DM_READ_AHEAD_AUTO UINT32_MAX /* Use kernel default readahead */ #define DM_READ_AHEAD_NONE 0 /* Disable readahead */ #define DM_READ_AHEAD_MINIMUM_FLAG 0x1 /* Value supplied is minimum */ /* * Read ahead is set with DM_DEVICE_CREATE with a table or DM_DEVICE_RESUME. */ int dm_task_set_read_ahead(struct dm_task *dmt, uint32_t read_ahead, uint32_t read_ahead_flags); uint32_t dm_task_get_read_ahead(const struct dm_task *dmt, uint32_t *read_ahead); /* * Use these to prepare for a create or reload. */ int dm_task_add_target(struct dm_task *dmt, uint64_t start, uint64_t size, const char *ttype, const char *params); /* * Format major/minor numbers correctly for input to driver */ int dm_format_dev(char *buf, int bufsize, uint32_t dev_major, uint32_t dev_minor); /* Use this to retrive target information returned from a STATUS call */ void *dm_get_next_target(struct dm_task *dmt, void *next, uint64_t *start, uint64_t *length, char **target_type, char **params); /* * Call this to actually run the ioctl. */ int dm_task_run(struct dm_task *dmt); /* * Call this to make or remove the device nodes associated with previously * issued commands. */ void dm_task_update_nodes(void); /* * Configure the device-mapper directory */ int dm_set_dev_dir(const char *dir); const char *dm_dir(void); /* * Determine whether a major number belongs to device-mapper or not. */ int dm_is_dm_major(uint32_t major); /* * Release library resources */ void dm_lib_release(void); void dm_lib_exit(void) __attribute((destructor)); /* * Use NULL for all devices. */ int dm_mknodes(const char *name); int dm_driver_version(char *version, size_t size); /****************************************************** * Functions to build and manipulate trees of devices * ******************************************************/ struct dm_tree; struct dm_tree_node; /* * Initialise an empty dependency tree. * * The tree consists of a root node together with one node for each mapped * device which has child nodes for each device referenced in its table. * * Every node in the tree has one or more children and one or more parents. * * The root node is the parent/child of every node that doesn't have other * parents/children. */ struct dm_tree *dm_tree_create(void); void dm_tree_free(struct dm_tree *tree); /* * Add nodes to the tree for a given device and all the devices it uses. */ int dm_tree_add_dev(struct dm_tree *tree, uint32_t major, uint32_t minor); /* * Add a new node to the tree if it doesn't already exist. */ struct dm_tree_node *dm_tree_add_new_dev(struct dm_tree *tree, const char *name, const char *uuid, uint32_t major, uint32_t minor, int read_only, int clear_inactive, void *context); /* * Search for a node in the tree. * Set major and minor to 0 or uuid to NULL to get the root node. */ struct dm_tree_node *dm_tree_find_node(struct dm_tree *tree, uint32_t major, uint32_t minor); struct dm_tree_node *dm_tree_find_node_by_uuid(struct dm_tree *tree, const char *uuid); /* * Use this to walk through all children of a given node. * Set handle to NULL in first call. * Returns NULL after the last child. * Set inverted to use inverted tree. */ struct dm_tree_node *dm_tree_next_child(void **handle, struct dm_tree_node *parent, uint32_t inverted); /* * Get properties of a node. */ const char *dm_tree_node_get_name(struct dm_tree_node *node); const char *dm_tree_node_get_uuid(struct dm_tree_node *node); const struct dm_info *dm_tree_node_get_info(struct dm_tree_node *node); void *dm_tree_node_get_context(struct dm_tree_node *node); /* * Returns the number of children of the given node (excluding the root node). * Set inverted for the number of parents. */ int dm_tree_node_num_children(struct dm_tree_node *node, uint32_t inverted); /* * Deactivate a device plus all dependencies. * Ignores devices that don't have a uuid starting with uuid_prefix. */ int dm_tree_deactivate_children(struct dm_tree_node *dnode, const char *uuid_prefix, size_t uuid_prefix_len); /* * Preload/create a device plus all dependencies. * Ignores devices that don't have a uuid starting with uuid_prefix. */ int dm_tree_preload_children(struct dm_tree_node *dnode, const char *uuid_prefix, size_t uuid_prefix_len); /* * Resume a device plus all dependencies. * Ignores devices that don't have a uuid starting with uuid_prefix. */ int dm_tree_activate_children(struct dm_tree_node *dnode, const char *uuid_prefix, size_t uuid_prefix_len); /* * Suspend a device plus all dependencies. * Ignores devices that don't have a uuid starting with uuid_prefix. */ int dm_tree_suspend_children(struct dm_tree_node *dnode, const char *uuid_prefix, size_t uuid_prefix_len); /* * Skip the filesystem sync when suspending. * Does nothing with other functions. * Use this when no snapshots are involved. */ void dm_tree_skip_lockfs(struct dm_tree_node *dnode); /* * Set the 'noflush' flag when suspending devices. * If the kernel supports it, instead of erroring outstanding I/O that * cannot be completed, the I/O is queued and resubmitted when the * device is resumed. This affects multipath devices when all paths * have failed and queue_if_no_path is set, and mirror devices when * block_on_error is set and the mirror log has failed. */ void dm_tree_use_no_flush_suspend(struct dm_tree_node *dnode); /* * Is the uuid prefix present in the tree? * Only returns 0 if every node was checked successfully. * Returns 1 if the tree walk has to be aborted. */ int dm_tree_children_use_uuid(struct dm_tree_node *dnode, const char *uuid_prefix, size_t uuid_prefix_len); /* * Construct tables for new nodes before activating them. */ int dm_tree_node_add_snapshot_origin_target(struct dm_tree_node *dnode, uint64_t size, const char *origin_uuid); int dm_tree_node_add_snapshot_target(struct dm_tree_node *node, uint64_t size, const char *origin_uuid, const char *cow_uuid, int persistent, uint32_t chunk_size); int dm_tree_node_add_error_target(struct dm_tree_node *node, uint64_t size); int dm_tree_node_add_zero_target(struct dm_tree_node *node, uint64_t size); int dm_tree_node_add_linear_target(struct dm_tree_node *node, uint64_t size); int dm_tree_node_add_striped_target(struct dm_tree_node *node, uint64_t size, uint32_t stripe_size); int dm_tree_node_add_mirror_target(struct dm_tree_node *node, uint64_t size); /* Mirror log flags */ #define DM_NOSYNC 0x00000001 /* Known already in sync */ #define DM_FORCESYNC 0x00000002 /* Force resync */ #define DM_BLOCK_ON_ERROR 0x00000004 /* On error, suspend I/O */ #define DM_CORELOG 0x00000008 /* In-memory log */ int dm_tree_node_add_mirror_target_log(struct dm_tree_node *node, uint32_t region_size, unsigned clustered, const char *log_uuid, unsigned area_count, uint32_t flags); int dm_tree_node_add_target_area(struct dm_tree_node *node, const char *dev_name, const char *dlid, uint64_t offset); /* * Set readahead (in sectors) after loading the node. */ void dm_tree_node_set_read_ahead(struct dm_tree_node *dnode, uint32_t read_ahead, uint32_t read_ahead_flags); /***************************************************************************** * Library functions *****************************************************************************/ /****ÁÁÁÁÁÁÁÁÁÁÁÁÁ*************** * Memory management *******************/ void *dm_malloc_aux(size_t s, const char *file, int line); void *dm_malloc_aux_debug(size_t s, const char *file, int line); char *dm_strdup_aux(const char *str, const char *file, int line); void dm_free_aux(void *p); void *dm_realloc_aux(void *p, unsigned int s, const char *file, int line); int dm_dump_memory_debug(void); void dm_bounds_check_debug(void); #ifdef DEBUG_MEM # define dm_malloc(s) dm_malloc_aux_debug((s), __FILE__, __LINE__) # define dm_strdup(s) dm_strdup_aux((s), __FILE__, __LINE__) # define dm_free(p) dm_free_aux(p) # define dm_realloc(p, s) dm_realloc_aux(p, s, __FILE__, __LINE__) # define dm_dump_memory() dm_dump_memory_debug() # define dm_bounds_check() dm_bounds_check_debug() #else # define dm_malloc(s) dm_malloc_aux((s), __FILE__, __LINE__) # define dm_strdup(s) strdup(s) # define dm_free(p) free(p) # define dm_realloc(p, s) realloc(p, s) # define dm_dump_memory() {} # define dm_bounds_check() {} #endif /* * The pool allocator is useful when you are going to allocate * lots of memory, use the memory for a bit, and then free the * memory in one go. A surprising amount of code has this usage * profile. * * You should think of the pool as an infinite, contiguous chunk * of memory. The front of this chunk of memory contains * allocated objects, the second half is free. dm_pool_alloc grabs * the next 'size' bytes from the free half, in effect moving it * into the allocated half. This operation is very efficient. * * dm_pool_free frees the allocated object *and* all objects * allocated after it. It is important to note this semantic * difference from malloc/free. This is also extremely * efficient, since a single dm_pool_free can dispose of a large * complex object. * * dm_pool_destroy frees all allocated memory. * * eg, If you are building a binary tree in your program, and * know that you are only ever going to insert into your tree, * and not delete (eg, maintaining a symbol table for a * compiler). You can create yourself a pool, allocate the nodes * from it, and when the tree becomes redundant call dm_pool_destroy * (no nasty iterating through the tree to free nodes). * * eg, On the other hand if you wanted to repeatedly insert and * remove objects into the tree, you would be better off * allocating the nodes from a free list; you cannot free a * single arbitrary node with pool. */ struct dm_pool; /* constructor and destructor */ struct dm_pool *dm_pool_create(const char *name, size_t chunk_hint); void dm_pool_destroy(struct dm_pool *p); /* simple allocation/free routines */ void *dm_pool_alloc(struct dm_pool *p, size_t s); void *dm_pool_alloc_aligned(struct dm_pool *p, size_t s, unsigned alignment); void dm_pool_empty(struct dm_pool *p); void dm_pool_free(struct dm_pool *p, void *ptr); /* * Object building routines: * * These allow you to 'grow' an object, useful for * building strings, or filling in dynamic * arrays. * * It's probably best explained with an example: * * char *build_string(struct dm_pool *mem) * { * int i; * char buffer[16]; * * if (!dm_pool_begin_object(mem, 128)) * return NULL; * * for (i = 0; i < 50; i++) { * snprintf(buffer, sizeof(buffer), "%d, ", i); * if (!dm_pool_grow_object(mem, buffer, 0)) * goto bad; * } * * // add null * if (!dm_pool_grow_object(mem, "\0", 1)) * goto bad; * * return dm_pool_end_object(mem); * * bad: * * dm_pool_abandon_object(mem); * return NULL; *} * * So start an object by calling dm_pool_begin_object * with a guess at the final object size - if in * doubt make the guess too small. * * Then append chunks of data to your object with * dm_pool_grow_object. Finally get your object with * a call to dm_pool_end_object. * * Setting delta to 0 means it will use strlen(extra). */ int dm_pool_begin_object(struct dm_pool *p, size_t hint); int dm_pool_grow_object(struct dm_pool *p, const void *extra, size_t delta); void *dm_pool_end_object(struct dm_pool *p); void dm_pool_abandon_object(struct dm_pool *p); /* utilities */ char *dm_pool_strdup(struct dm_pool *p, const char *str); char *dm_pool_strndup(struct dm_pool *p, const char *str, size_t n); void *dm_pool_zalloc(struct dm_pool *p, size_t s); /****************** * bitset functions ******************/ typedef uint32_t *dm_bitset_t; dm_bitset_t dm_bitset_create(struct dm_pool *mem, unsigned num_bits); void dm_bitset_destroy(dm_bitset_t bs); void dm_bit_union(dm_bitset_t out, dm_bitset_t in1, dm_bitset_t in2); int dm_bit_get_first(dm_bitset_t bs); int dm_bit_get_next(dm_bitset_t bs, int last_bit); #define DM_BITS_PER_INT (sizeof(int) * CHAR_BIT) #define dm_bit(bs, i) \ (bs[(i / DM_BITS_PER_INT) + 1] & (0x1 << (i & (DM_BITS_PER_INT - 1)))) #define dm_bit_set(bs, i) \ (bs[(i / DM_BITS_PER_INT) + 1] |= (0x1 << (i & (DM_BITS_PER_INT - 1)))) #define dm_bit_clear(bs, i) \ (bs[(i / DM_BITS_PER_INT) + 1] &= ~(0x1 << (i & (DM_BITS_PER_INT - 1)))) #define dm_bit_set_all(bs) \ memset(bs + 1, -1, ((*bs / DM_BITS_PER_INT) + 1) * sizeof(int)) #define dm_bit_clear_all(bs) \ memset(bs + 1, 0, ((*bs / DM_BITS_PER_INT) + 1) * sizeof(int)) #define dm_bit_copy(bs1, bs2) \ memcpy(bs1 + 1, bs2 + 1, ((*bs1 / DM_BITS_PER_INT) + 1) * sizeof(int)) /* Returns number of set bits */ static inline unsigned hweight32(uint32_t i) { unsigned r = (i & 0x55555555) + ((i >> 1) & 0x55555555); r = (r & 0x33333333) + ((r >> 2) & 0x33333333); r = (r & 0x0F0F0F0F) + ((r >> 4) & 0x0F0F0F0F); r = (r & 0x00FF00FF) + ((r >> 8) & 0x00FF00FF); return (r & 0x0000FFFF) + ((r >> 16) & 0x0000FFFF); } /**************** * hash functions ****************/ struct dm_hash_table; struct dm_hash_node; typedef void (*dm_hash_iterate_fn) (void *data); struct dm_hash_table *dm_hash_create(unsigned size_hint); void dm_hash_destroy(struct dm_hash_table *t); void dm_hash_wipe(struct dm_hash_table *t); void *dm_hash_lookup(struct dm_hash_table *t, const char *key); int dm_hash_insert(struct dm_hash_table *t, const char *key, void *data); void dm_hash_remove(struct dm_hash_table *t, const char *key); void *dm_hash_lookup_binary(struct dm_hash_table *t, const char *key, uint32_t len); int dm_hash_insert_binary(struct dm_hash_table *t, const char *key, uint32_t len, void *data); void dm_hash_remove_binary(struct dm_hash_table *t, const char *key, uint32_t len); unsigned dm_hash_get_num_entries(struct dm_hash_table *t); void dm_hash_iter(struct dm_hash_table *t, dm_hash_iterate_fn f); char *dm_hash_get_key(struct dm_hash_table *t, struct dm_hash_node *n); void *dm_hash_get_data(struct dm_hash_table *t, struct dm_hash_node *n); struct dm_hash_node *dm_hash_get_first(struct dm_hash_table *t); struct dm_hash_node *dm_hash_get_next(struct dm_hash_table *t, struct dm_hash_node *n); #define dm_hash_iterate(v, h) \ for (v = dm_hash_get_first(h); v; \ v = dm_hash_get_next(h, v)) /********* * selinux *********/ int dm_set_selinux_context(const char *path, mode_t mode); /********************* * string manipulation *********************/ /* * Break up the name of a mapped device into its constituent * Volume Group, Logical Volume and Layer (if present). */ int dm_split_lvm_name(struct dm_pool *mem, const char *dmname, char **vgname, char **lvname, char **layer); /* * Destructively split buffer into NULL-separated words in argv. * Returns number of words. */ int dm_split_words(char *buffer, unsigned max, unsigned ignore_comments, /* Not implemented */ char **argv); /* * Returns -1 if buffer too small */ int dm_snprintf(char *buf, size_t bufsize, const char *format, ...); /* * Returns pointer to the last component of the path. */ char *dm_basename(const char *path); /************************** * file/stream manipulation **************************/ /* * Create a directory (with parent directories if necessary). * Returns 1 on success, 0 on failure. */ int dm_create_dir(const char *dir); /* * Close a stream, with nicer error checking than fclose's. * Derived from gnulib's close-stream.c. * * Close "stream". Return 0 if successful, and EOF (setting errno) * otherwise. Upon failure, set errno to 0 if the error number * cannot be determined. Useful mainly for writable streams. */ int dm_fclose(FILE *stream); /* * Returns size of a buffer which is allocated with dm_malloc. * Pointer to the buffer is stored in *buf. * Returns -1 on failure leaving buf undefined. */ int dm_asprintf(char **buf, const char *format, ...); /********************* * regular expressions *********************/ struct dm_regex; /* * Initialise an array of num patterns for matching. * Uses memory from mem. */ struct dm_regex *dm_regex_create(struct dm_pool *mem, const char **patterns, unsigned num_patterns); /* * Match string s against the patterns. * Returns the index of the highest pattern in the array that matches, * or -1 if none match. */ int dm_regex_match(struct dm_regex *regex, const char *s); /********************* * reporting functions *********************/ struct dm_report_object_type { uint32_t id; /* Powers of 2 */ const char *desc; const char *prefix; /* field id string prefix (optional) */ void *(*data_fn)(void *object); /* callback from report_object() */ }; struct dm_report_field; /* * dm_report_field_type flags */ #define DM_REPORT_FIELD_MASK 0x000000FF #define DM_REPORT_FIELD_ALIGN_MASK 0x0000000F #define DM_REPORT_FIELD_ALIGN_LEFT 0x00000001 #define DM_REPORT_FIELD_ALIGN_RIGHT 0x00000002 #define DM_REPORT_FIELD_TYPE_MASK 0x000000F0 #define DM_REPORT_FIELD_TYPE_STRING 0x00000010 #define DM_REPORT_FIELD_TYPE_NUMBER 0x00000020 struct dm_report; struct dm_report_field_type { uint32_t type; /* object type id */ uint32_t flags; /* DM_REPORT_FIELD_* */ uint32_t offset; /* byte offset in the object */ int32_t width; /* default width */ const char id[32]; /* string used to specify the field */ const char heading[32]; /* string printed in header */ int (*report_fn)(struct dm_report *rh, struct dm_pool *mem, struct dm_report_field *field, const void *data, void *private); const char *desc; /* description of the field */ }; /* * dm_report_init output_flags */ #define DM_REPORT_OUTPUT_MASK 0x000000FF #define DM_REPORT_OUTPUT_ALIGNED 0x00000001 #define DM_REPORT_OUTPUT_BUFFERED 0x00000002 #define DM_REPORT_OUTPUT_HEADINGS 0x00000004 #define DM_REPORT_OUTPUT_FIELD_NAME_PREFIX 0x00000008 #define DM_REPORT_OUTPUT_FIELD_UNQUOTED 0x00000010 #define DM_REPORT_OUTPUT_COLUMNS_AS_ROWS 0x00000020 struct dm_report *dm_report_init(uint32_t *report_types, const struct dm_report_object_type *types, const struct dm_report_field_type *fields, const char *output_fields, const char *output_separator, uint32_t output_flags, const char *sort_keys, void *private); int dm_report_object(struct dm_report *rh, void *object); int dm_report_output(struct dm_report *rh); void dm_report_free(struct dm_report *rh); /* * Prefix added to each field name with DM_REPORT_OUTPUT_FIELD_NAME_PREFIX */ int dm_report_set_output_field_name_prefix(struct dm_report *rh, const char *report_prefix); /* * Report functions are provided for simple data types. * They take care of allocating copies of the data. */ int dm_report_field_string(struct dm_report *rh, struct dm_report_field *field, const char **data); int dm_report_field_int32(struct dm_report *rh, struct dm_report_field *field, const int32_t *data); int dm_report_field_uint32(struct dm_report *rh, struct dm_report_field *field, const uint32_t *data); int dm_report_field_int(struct dm_report *rh, struct dm_report_field *field, const int *data); int dm_report_field_uint64(struct dm_report *rh, struct dm_report_field *field, const uint64_t *data); /* * For custom fields, allocate the data in 'mem' and use * dm_report_field_set_value(). * 'sortvalue' may be NULL if it matches 'value' */ void dm_report_field_set_value(struct dm_report_field *field, const void *value, const void *sortvalue); #endif /* LIB_DEVICE_MAPPER_H */ @% .<% ..A%èa.out.h/* DO NOT EDIT THIS FILE. It has been auto-edited by fixincludes from: "/usr/include/linux/a.out.h" This had to be done to correct non-standard usages in the original, manufacturer supplied header file. */ #ifndef __A_OUT_GNU_H__ #define __A_OUT_GNU_H__ #define __GNU_EXEC_MACROS__ #ifndef __STRUCT_EXEC_OVERRIDE__ #include #endif /* __STRUCT_EXEC_OVERRIDE__ */ #ifndef __ASSEMBLY__ /* these go in the N_MACHTYPE field */ enum machine_type { #if defined (M_OLDSUN2) M__OLDSUN2 = M_OLDSUN2, #else M_OLDSUN2 = 0, #endif #if defined (M_68010) M__68010 = M_68010, #else M_68010 = 1, #endif #if defined (M_68020) M__68020 = M_68020, #else M_68020 = 2, #endif #if defined (M_SPARC) M__SPARC = M_SPARC, #else M_SPARC = 3, #endif /* skip a bunch so we don't run into any of sun's numbers */ M_386 = 100, M_MIPS1 = 151, /* MIPS R3000/R3000 binary */ M_MIPS2 = 152 /* MIPS R6000/R4000 binary */ }; #if !defined (N_MAGIC) #define N_MAGIC(exec) ((exec).a_info & 0xffff) #endif #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff)) #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff) #define N_SET_INFO(exec, magic, type, flags) \ ((exec).a_info = ((magic) & 0xffff) \ | (((int)(type) & 0xff) << 16) \ | (((flags) & 0xff) << 24)) #define N_SET_MAGIC(exec, magic) \ ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff))) #define N_SET_MACHTYPE(exec, machtype) \ ((exec).a_info = \ ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16)) #define N_SET_FLAGS(exec, flags) \ ((exec).a_info = \ ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24)) /* Code indicating object file or impure executable. */ #define OMAGIC 0407 /* Code indicating pure executable. */ #define NMAGIC 0410 /* Code indicating demand-paged executable. */ #define ZMAGIC 0413 /* This indicates a demand-paged executable with the header in the text. The first page is unmapped to help trap NULL pointer references */ #define QMAGIC 0314 /* Code indicating core file. */ #define CMAGIC 0421 #if !defined (N_BADMAG) #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \ && N_MAGIC(x) != NMAGIC \ && N_MAGIC(x) != ZMAGIC \ && N_MAGIC(x) != QMAGIC) #endif #define _N_HDROFF(x) (1024 - sizeof (struct exec)) #if !defined (N_TXTOFF) #define N_TXTOFF(x) \ (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \ (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec))) #endif #if !defined (N_DATOFF) #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text) #endif #if !defined (N_TRELOFF) #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data) #endif #if !defined (N_DRELOFF) #define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x)) #endif #if !defined (N_SYMOFF) #define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x)) #endif #if !defined (N_STROFF) #define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x)) #endif /* Address of text segment in memory after it is loaded. */ #if !defined (N_TXTADDR) #define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0) #endif /* Address of data segment in memory after it is loaded. Note that it is up to you to define SEGMENT_SIZE on machines not listed here. */ #if defined(vax) || defined(hp300) || defined(pyr) #define SEGMENT_SIZE page_size #endif #ifdef sony #define SEGMENT_SIZE 0x2000 #endif /* Sony. */ #ifdef is68k #define SEGMENT_SIZE 0x20000 #endif #if defined(m68k) && defined(PORTAR) #define PAGE_SIZE 0x400 #define SEGMENT_SIZE PAGE_SIZE #endif #ifdef __linux__ #include #if defined(__i386__) || defined(__mc68000__) #define SEGMENT_SIZE 1024 #else #ifndef SEGMENT_SIZE #define SEGMENT_SIZE getpagesize() #endif #endif #endif #define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE) #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text) #ifndef N_DATADDR #define N_DATADDR(x) \ (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \ : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x)))) #endif /* Address of bss segment in memory after it is loaded. */ #if !defined (N_BSSADDR) #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data) #endif #if !defined (N_NLIST_DECLARED) struct nlist { union { char *n_name; struct nlist *n_next; long n_strx; } n_un; unsigned char n_type; char n_other; short n_desc; unsigned long n_value; }; #endif /* no N_NLIST_DECLARED. */ #if !defined (N_UNDF) #define N_UNDF 0 #endif #if !defined (N_ABS) #define N_ABS 2 #endif #if !defined (N_TEXT) #define N_TEXT 4 #endif #if !defined (N_DATA) #define N_DATA 6 #endif #if !defined (N_BSS) #define N_BSS 8 #endif #if !defined (N_FN) #define N_FN 15 #endif #if !defined (N_EXT) #define N_EXT 1 #endif #if !defined (N_TYPE) #define N_TYPE 036 #endif #if !defined (N_STAB) #define N_STAB 0340 #endif /* The following type indicates the definition of a symbol as being an indirect reference to another symbol. The other symbol appears as an undefined reference, immediately following this symbol. Indirection is asymmetrical. The other symbol's value will be used to satisfy requests for the indirect symbol, but not vice versa. If the other symbol does not have a definition, libraries will be searched to find a definition. */ #define N_INDR 0xa /* The following symbols refer to set elements. All the N_SET[ATDB] symbols with the same name form one set. Space is allocated for the set in the text section, and each set element's value is stored into one word of the space. The first word of the space is the length of the set (number of elements). The address of the set is made into an N_SETV symbol whose name is the same as the name of the set. This symbol acts like a N_DATA global symbol in that it can satisfy undefined external references. */ /* These appear as input to LD, in a .o file. */ #define N_SETA 0x14 /* Absolute set element symbol */ #define N_SETT 0x16 /* Text set element symbol */ #define N_SETD 0x18 /* Data set element symbol */ #define N_SETB 0x1A /* Bss set element symbol */ /* This is output from LD. */ #define N_SETV 0x1C /* Pointer to set vector in data area. */ #if !defined (N_RELOCATION_INFO_DECLARED) /* This structure describes a single relocation to be performed. The text-relocation section of the file is a vector of these structures, all of which apply to the text section. Likewise, the data-relocation section applies to the data section. */ struct relocation_info { /* Address (within segment) to be relocated. */ int r_address; /* The meaning of r_symbolnum depends on r_extern. */ unsigned int r_symbolnum:24; /* Nonzero means value is a pc-relative offset and it should be relocated for changes in its own address as well as for changes in the symbol or section specified. */ unsigned int r_pcrel:1; /* Length (as exponent of 2) of the field to be relocated. Thus, a value of 2 indicates 1<<2 bytes. */ unsigned int r_length:2; /* 1 => relocate with value of symbol. r_symbolnum is the index of the symbol in file's the symbol table. 0 => relocate with the address of a segment. r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS (the N_EXT bit may be set also, but signifies nothing). */ unsigned int r_extern:1; /* Four bits that aren't used, but when writing an object file it is desirable to clear them. */ #ifdef NS32K unsigned r_bsr:1; unsigned r_disp:1; unsigned r_pad:2; #else unsigned int r_pad:4; #endif }; #endif /* no N_RELOCATION_INFO_DECLARED. */ #endif /*__ASSEMBLY__ */ #endif /* __A_OUT_GNU_H__ */ /* This administrivia gets added to the beginning of limits.h if the system has its own version of limits.h. */ /* We use _GCC_LIMITS_H_ because we want this not to match any macros that the system's limits.h uses for its own purposes. */ #ifndef _GCC_LIMITS_H_ /* Terminated in limity.h. */ #define _GCC_LIMITS_H_ #ifndef _LIBC_LIMITS_H_ /* Use "..." so that we find syslimits.h only in this same directory. */ #include "syslimits.h" #endif #ifndef _LIMITS_H___ #define _LIMITS_H___ /* Number of bits in a `char'. */ #undef CHAR_BIT #define CHAR_BIT __CHAR_BIT__ /* Maximum length of a multibyte character. */ #ifndef MB_LEN_MAX #define MB_LEN_MAX 1 #endif /* Minimum and maximum values a `signed char' can hold. */ #undef SCHAR_MIN #define SCHAR_MIN (-SCHAR_MAX - 1) #undef SCHAR_MAX #define SCHAR_MAX __SCHAR_MAX__ /* Maximum value an `unsigned char' can hold. (Minimum is 0). */ #undef UCHAR_MAX #if __SCHAR_MAX__ == __INT_MAX__ # define UCHAR_MAX (SCHAR_MAX * 2U + 1U) #else # define UCHAR_MAX (SCHAR_MAX * 2 + 1) #endif /* Minimum and maximum values a `char' can hold. */ #ifdef __CHAR_UNSIGNED__ # undef CHAR_MIN # if __SCHAR_MAX__ == __INT_MAX__ # define CHAR_MIN 0U # else # define CHAR_MIN 0 # endif # undef CHAR_MAX # define CHAR_MAX UCHAR_MAX #else # undef CHAR_MIN # define CHAR_MIN SCHAR_MIN # undef CHAR_MAX # define CHAR_MAX SCHAR_MAX #endif /* Minimum and maximum values a `signed short int' can hold. */ #undef SHRT_MIN #define SHRT_MIN (-SHRT_MAX - 1) #undef SHRT_MAX #define SHRT_MAX __SHRT_MAX__ /* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ #undef USHRT_MAX #if __SHRT_MAX__ == __INT_MAX__ # define USHRT_MAX (SHRT_MAX * 2U + 1U) #else # define USHRT_MAX (SHRT_MAX * 2 + 1) #endif /* Minimum and maximum values a `signed int' can hold. */ #undef INT_MIN #define INT_MIN (-INT_MAX - 1) #undef INT_MAX #define INT_MAX __INT_MAX__ /* Maximum value an `unsigned int' can hold. (Minimum is 0). */ #undef UINT_MAX #define UINT_MAX (INT_MAX * 2U + 1U) /* Minimum and maximum values a `signed long int' can hold. (Same as `int'). */ #undef LONG_MIN #define LONG_MIN (-LONG_MAX - 1L) #undef LONG_MAX #define LONG_MAX __LONG_MAX__ /* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ #undef ULONG_MAX #define ULONG_MAX (LONG_MAX * 2UL + 1UL) #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* Minimum and maximum values a `signed long long int' can hold. */ # undef LLONG_MIN # define LLONG_MIN (-LLONG_MAX - 1LL) # undef LLONG_MAX # define LLONG_MAX __LONG_LONG_MAX__ /* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ # undef ULLONG_MAX # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) #endif #if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__) /* Minimum and maximum values a `signed long long int' can hold. */ # undef LONG_LONG_MIN # define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL) # undef LONG_LONG_MAX # define LONG_LONG_MAX __LONG_LONG_MAX__ /* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ # undef ULONG_LONG_MAX # define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL) #endif #endif /* _LIMITS_H___ */ /* This administrivia gets added to the end of limits.h if the system has its own version of limits.h. */ #else /* not _GCC_LIMITS_H_ */ #ifdef _GCC_NEXT_LIMITS_H #include_next /* recurse down to the real one */ #endif #endif /* not _GCC_LIMITS_H_ */ C% .<% ..D%èbn.h/* DO NOT EDIT THIS FILE. It has been auto-edited by fixincludes from: "/usr/include/openssl/bn.h" This had to be done to correct non-standard usages in the original, manufacturer supplied header file. */ /* crypto/bn/bn.h */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the Eric Young open source * license provided above. * * The binary polynomial arithmetic software is originally written by * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. * */ #ifndef HEADER_BN_H #define HEADER_BN_H #include #ifndef OPENSSL_NO_FP_API #include /* FILE */ #endif #include #ifdef __cplusplus extern "C" { #endif /* These preprocessor symbols control various aspects of the bignum headers and * library code. They're not defined by any "normal" configuration, as they are * intended for development and testing purposes. NB: defining all three can be * useful for debugging application code as well as openssl itself. * * BN_DEBUG - turn on various debugging alterations to the bignum code * BN_DEBUG_RAND - uses random poisoning of unused words to trip up * mismanagement of bignum internals. You must also define BN_DEBUG. */ /* #define BN_DEBUG */ /* #define BN_DEBUG_RAND */ #define BN_MUL_COMBA #define BN_SQR_COMBA #define BN_RECURSION /* This next option uses the C libraries (2 word)/(1 word) function. * If it is not defined, I use my C version (which is slower). * The reason for this flag is that when the particular C compiler * library routine is used, and the library is linked with a different * compiler, the library is missing. This mostly happens when the * library is built with gcc and then linked using normal cc. This would * be a common occurrence because gcc normally produces code that is * 2 times faster than system compilers for the big number stuff. * For machines with only one compiler (or shared libraries), this should * be on. Again this in only really a problem on machines * using "long long's", are 32bit, and are not using my assembler code. */ #if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \ defined(OPENSSL_SYS_WIN32) || defined(__linux__) # ifndef BN_DIV2W # define BN_DIV2W # endif #endif /* assuming long is 64bit - this is the DEC Alpha * unsigned long long is only 64 bits :-(, don't define * BN_LLONG for the DEC Alpha */ #ifdef SIXTY_FOUR_BIT_LONG #define BN_ULLONG unsigned long long #define BN_ULONG unsigned long #define BN_LONG long #define BN_BITS 128 #define BN_BYTES 8 #define BN_BITS2 64 #define BN_BITS4 32 #define BN_MASK (0xffffffffffffffffffffffffffffffffLL) #define BN_MASK2 (0xffffffffffffffffL) #define BN_MASK2l (0xffffffffL) #define BN_MASK2h (0xffffffff00000000L) #define BN_MASK2h1 (0xffffffff80000000L) #define BN_TBIT (0x8000000000000000L) #define BN_DEC_CONV (10000000000000000000UL) #define BN_DEC_FMT1 "%lu" #define BN_DEC_FMT2 "%019lu" #define BN_DEC_NUM 19 #endif /* This is where the long long data type is 64 bits, but long is 32. * For machines where there are 64bit registers, this is the mode to use. * IRIX, on R4000 and above should use this mode, along with the relevant * assembler code :-). Do NOT define BN_LLONG. */ #ifdef SIXTY_FOUR_BIT #undef BN_LLONG #undef BN_ULLONG #define BN_ULONG unsigned long long #define BN_LONG long long #define BN_BITS 128 #define BN_BYTES 8 #define BN_BITS2 64 #define BN_BITS4 32 #define BN_MASK2 (0xffffffffffffffffLL) #define BN_MASK2l (0xffffffffL) #define BN_MASK2h (0xffffffff00000000LL) #define BN_MASK2h1 (0xffffffff80000000LL) #define BN_TBIT (0x8000000000000000LL) #define BN_DEC_CONV (10000000000000000000ULL) #define BN_DEC_FMT1 "%llu" #define BN_DEC_FMT2 "%019llu" #define BN_DEC_NUM 19 #endif #ifdef THIRTY_TWO_BIT #ifdef BN_LLONG # if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) # define BN_ULLONG unsigned __int64 # else # define BN_ULLONG unsigned long long # endif #endif #define BN_ULONG unsigned long #define BN_LONG long #define BN_BITS 64 #define BN_BYTES 4 #define BN_BITS2 32 #define BN_BITS4 16 #ifdef OPENSSL_SYS_WIN32 /* VC++ doesn't like the LL suffix */ #define BN_MASK (0xffffffffffffffffL) #else #define BN_MASK (0xffffffffffffffffLL) #endif #define BN_MASK2 (0xffffffffL) #define BN_MASK2l (0xffff) #define BN_MASK2h1 (0xffff8000L) #define BN_MASK2h (0xffff0000L) #define BN_TBIT (0x80000000L) #define BN_DEC_CONV (1000000000L) #define BN_DEC_FMT1 "%lu" #define BN_DEC_FMT2 "%09lu" #define BN_DEC_NUM 9 #endif #ifdef SIXTEEN_BIT #ifndef BN_DIV2W #define BN_DIV2W #endif #define BN_ULLONG unsigned long #define BN_ULONG unsigned short #define BN_LONG short #define BN_BITS 32 #define BN_BYTES 2 #define BN_BITS2 16 #define BN_BITS4 8 #define BN_MASK (0xffffffff) #define BN_MASK2 (0xffff) #define BN_MASK2l (0xff) #define BN_MASK2h1 (0xff80) #define BN_MASK2h (0xff00) #define BN_TBIT (0x8000) #define BN_DEC_CONV (100000) #define BN_DEC_FMT1 "%u" #define BN_DEC_FMT2 "%05u" #define BN_DEC_NUM 5 #endif #ifdef EIGHT_BIT #ifndef BN_DIV2W #define BN_DIV2W #endif #define BN_ULLONG unsigned short #define BN_ULONG unsigned char #define BN_LONG char #define BN_BITS 16 #define BN_BYTES 1 #define BN_BITS2 8 #define BN_BITS4 4 #define BN_MASK (0xffff) #define BN_MASK2 (0xff) #define BN_MASK2l (0xf) #define BN_MASK2h1 (0xf8) #define BN_MASK2h (0xf0) #define BN_TBIT (0x80) #define BN_DEC_CONV (100) #define BN_DEC_FMT1 "%u" #define BN_DEC_FMT2 "%02u" #define BN_DEC_NUM 2 #endif #define BN_DEFAULT_BITS 1280 #define BN_FLG_MALLOCED 0x01 #define BN_FLG_STATIC_DATA 0x02 #define BN_FLG_CONSTTIME 0x04 /* avoid leaking exponent information through timing, * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime, * BN_div() will call BN_div_no_branch, * BN_mod_inverse() will call BN_mod_inverse_no_branch. */ #ifndef OPENSSL_NO_DEPRECATED #define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME /* deprecated name for the flag */ /* avoid leaking exponent information through timings * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */ #endif #ifndef OPENSSL_NO_DEPRECATED #define BN_FLG_FREE 0x8000 /* used for debuging */ #endif #define BN_set_flags(b,n) ((b)->flags|=(n)) #define BN_get_flags(b,n) ((b)->flags&(n)) /* get a clone of a BIGNUM with changed flags, for *temporary* use only * (the two BIGNUMs cannot not be used in parallel!) */ #define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \ (dest)->top=(b)->top, \ (dest)->dmax=(b)->dmax, \ (dest)->neg=(b)->neg, \ (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \ | ((b)->flags & ~BN_FLG_MALLOCED) \ | BN_FLG_STATIC_DATA \ | (n))) /* Already declared in ossl_typ.h */ #if 0 typedef struct bignum_st BIGNUM; /* Used for temp variables (declaration hidden in bn_lcl.h) */ typedef struct bignum_ctx BN_CTX; typedef struct bn_blinding_st BN_BLINDING; typedef struct bn_mont_ctx_st BN_MONT_CTX; typedef struct bn_recp_ctx_st BN_RECP_CTX; typedef struct bn_gencb_st BN_GENCB; #endif struct bignum_st { BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ int top; /* Index of last used d +1. */ /* The next are internal book keeping for bn_expand. */ int dmax; /* Size of the d array. */ int neg; /* one if the number is negative */ int flags; }; /* Used for montgomery multiplication */ struct bn_mont_ctx_st { int ri; /* number of bits in R */ BIGNUM RR; /* used to convert to montgomery form */ BIGNUM N; /* The modulus */ BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 * (Ni is only stored for bignum algorithm) */ BN_ULONG n0; /* least significant word of Ni */ int flags; }; /* Used for reciprocal division/mod functions * It cannot be shared between threads */ struct bn_recp_ctx_st { BIGNUM N; /* the divisor */ BIGNUM Nr; /* the reciprocal */ int num_bits; int shift; int flags; }; /* Used for slow "generation" functions. */ struct bn_gencb_st { unsigned int ver; /* To handle binary (in)compatibility */ void *arg; /* callback-specific data */ union { /* if(ver==1) - handles old style callbacks */ void (*cb_1)(int, int, void *); /* if(ver==2) - new callback style */ int (*cb_2)(int, int, BN_GENCB *); } cb; }; /* Wrapper function to make using BN_GENCB easier, */ int BN_GENCB_call(BN_GENCB *cb, int a, int b); /* Macro to populate 6Á7Á8Á9Á:Á;Á<Á=Á>Á?Á@ÁAÁBÁCÁDÁEÁFÁGÁHÁIÁJÁa BN_GENCB structure with an "old"-style callback */ #define BN_GENCB_set_old(gencb, callback, cb_arg) { \ BN_GENCB *tmp_gencb = (gencb); \ tmp_gencb->ver = 1; \ tmp_gencb->arg = (cb_arg); \ tmp_gencb->cb.cb_1 = (callback); } /* Macro to populate a BN_GENCB structure with a "new"-style callback */ #define BN_GENCB_set(gencb, callback, cb_arg) { \ BN_GENCB *tmp_gencb = (gencb); \ tmp_gencb->ver = 2; \ tmp_gencb->arg = (cb_arg); \ tmp_gencb->cb.cb_2 = (callback); } #define BN_prime_checks 0 /* default: select number of iterations based on the size of the number */ /* number of Miller-Rabin iterations for an error rate of less than 2^-80 * for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook * of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996]; * original paper: Damgaard, Landrock, Pomerance: Average case error estimates * for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */ #define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \ (b) >= 850 ? 3 : \ (b) >= 650 ? 4 : \ (b) >= 550 ? 5 : \ (b) >= 450 ? 6 : \ (b) >= 400 ? 7 : \ (b) >= 350 ? 8 : \ (b) >= 300 ? 9 : \ (b) >= 250 ? 12 : \ (b) >= 200 ? 15 : \ (b) >= 150 ? 18 : \ /* b >= 100 */ 27) #define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) /* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */ #define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \ (((w) == 0) && ((a)->top == 0))) #define BN_is_zero(a) ((a)->top == 0) #define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg) #define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg)) #define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) #define BN_one(a) (BN_set_word((a),1)) #define BN_zero_ex(a) \ do { \ BIGNUM *_tmp_bn = (a); \ _tmp_bn->top = 0; \ _tmp_bn->neg = 0; \ } while(0) #ifdef OPENSSL_NO_DEPRECATED #define BN_zero(a) BN_zero_ex(a) #else #define BN_zero(a) (BN_set_word((a),0)) #endif const BIGNUM *BN_value_one(void); char * BN_options(void); BN_CTX *BN_CTX_new(void); #ifndef OPENSSL_NO_DEPRECATED void BN_CTX_init(BN_CTX *c); #endif void BN_CTX_free(BN_CTX *c); void BN_CTX_start(BN_CTX *ctx); BIGNUM *BN_CTX_get(BN_CTX *ctx); void BN_CTX_end(BN_CTX *ctx); int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom); int BN_rand_range(BIGNUM *rnd, BIGNUM *range); int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); int BN_num_bits(const BIGNUM *a); int BN_num_bits_word(BN_ULONG); BIGNUM *BN_new(void); void BN_init(BIGNUM *); void BN_clear_free(BIGNUM *a); BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); void BN_swap(BIGNUM *a, BIGNUM *b); BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret); int BN_bn2bin(const BIGNUM *a, unsigned char *to); BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret); int BN_bn2mpi(const BIGNUM *a, unsigned char *to); int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx); /** BN_set_negative sets sign of a BIGNUM * \param b pointer to the BIGNUM object * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise */ void BN_set_negative(BIGNUM *b, int n); /** BN_is_negative returns 1 if the BIGNUM is negative * \param a pointer to the BIGNUM object * \return 1 if a < 0 and 0 otherwise */ #define BN_is_negative(a) ((a)->neg != 0) int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); #define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx); int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m); BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); int BN_mul_word(BIGNUM *a, BN_ULONG w); int BN_add_word(BIGNUM *a, BN_ULONG w); int BN_sub_word(BIGNUM *a, BN_ULONG w); int BN_set_word(BIGNUM *a, BN_ULONG w); BN_ULONG BN_get_word(const BIGNUM *a); int BN_cmp(const BIGNUM *a, const BIGNUM *b); void BN_free(BIGNUM *a); int BN_is_bit_set(const BIGNUM *a, int n); int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); int BN_lshift1(BIGNUM *r, const BIGNUM *a); int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx); int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,BN_CTX *ctx); int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont); int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m, BN_CTX *ctx,BN_MONT_CTX *m_ctx); int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,BN_CTX *ctx); int BN_mask_bits(BIGNUM *a,int n); #ifndef OPENSSL_NO_FP_API int BN_print_fp(FILE *fp, const BIGNUM *a); #endif #ifdef HEADER_BIO_H int BN_print(BIO *fp, const BIGNUM *a); #else int BN_print(void *fp, const BIGNUM *a); #endif int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); int BN_rshift1(BIGNUM *r, const BIGNUM *a); void BN_clear(BIGNUM *a); BIGNUM *BN_dup(const BIGNUM *a); int BN_ucmp(const BIGNUM *a, const BIGNUM *b); int BN_set_bit(BIGNUM *a, int n); int BN_clear_bit(BIGNUM *a, int n); char * BN_bn2hex(const BIGNUM *a); char * BN_bn2dec(const BIGNUM *a); int BN_hex2bn(BIGNUM **a, const char *str); int BN_dec2bn(BIGNUM **a, const char *str); int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ BIGNUM *BN_mod_inverse(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); BIGNUM *BN_mod_sqrt(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); /* Deprecated versions */ #ifndef OPENSSL_NO_DEPRECATED BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe, const BIGNUM *add, const BIGNUM *rem, void (*callback)(int,int,void *),void *cb_arg); int BN_is_prime(const BIGNUM *p,int nchecks, void (*callback)(int,int,void *), BN_CTX *ctx,void *cb_arg); int BN_is_prime_fasttest(const BIGNUM *p,int nchecks, void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg, int do_trial_division); #endif /* !defined(OPENSSL_NO_DEPRECATED) */ /* Newer versions */ int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add, const BIGNUM *rem, BN_GENCB *cb); int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb); int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, int do_trial_division, BN_GENCB *cb); BN_MONT_CTX *BN_MONT_CTX_new(void ); void BN_MONT_CTX_init(BN_MONT_CTX *ctx); int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b, BN_MONT_CTX *mont, BN_CTX *ctx); #define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ (r),(a),&((mont)->RR),(mont),(ctx)) int BN_from_montgomery(BIGNUM *r,const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx); void BN_MONT_CTX_free(BN_MONT_CTX *mont); int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx); BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from); BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock, const BIGNUM *mod, BN_CTX *ctx); /* BN_BLINDING flags */ #define BN_BLINDING_NO_UPDATE 0x00000001 #define BN_BLINDING_NO_RECREATE 0x00000002 BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, /* const */ BIGNUM *mod); void BN_BLINDING_free(BN_BLINDING *b); int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, const BIGNUM *e, /* const */ BIGNUM *m, BN_CTX *ctx, int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), BN_MONT_CTX *m_ctx); #ifndef OPENSSL_NO_DEPRECATED void BN_set_params(int mul,int high,int low,int mont); int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */ #endif void BN_RECP_CTX_init(BN_RECP_CTX *recp); BN_RECP_CTX *BN_RECP_CTX_new(void); void BN_RECP_CTX_fr