Skip Navigation Links | |
Exit Print View | |
man pages section 3: Extended Library Functions, Volume 1 Oracle Solaris 11.1 Information Library |
Extended Library Functions, Volume 1
CIRCLEQ_HEAD_INITIALIZER(3EXT)
cpc_walk_generic_events_all(3CPC)
cpc_walk_generic_events_pic(3CPC)
ct_dev_status_get_aset(3CONTRACT)
ct_dev_status_get_dev_state(3CONTRACT)
ct_dev_status_get_minor(3CONTRACT)
ct_dev_status_get_noneg(3CONTRACT)
ct_dev_tmpl_clear_noneg(3CONTRACT)
ct_dev_tmpl_get_aset(3CONTRACT)
ct_dev_tmpl_get_minor(3CONTRACT)
ct_dev_tmpl_get_noneg(3CONTRACT)
ct_dev_tmpl_set_aset(3CONTRACT)
ct_dev_tmpl_set_minor(3CONTRACT)
ct_dev_tmpl_set_noneg(3CONTRACT)
ct_event_read_critical(3CONTRACT)
ct_pr_event_get_exitstatus(3CONTRACT)
ct_pr_event_get_gcorefile(3CONTRACT)
ct_pr_event_get_pcorefile(3CONTRACT)
ct_pr_event_get_pid(3CONTRACT)
ct_pr_event_get_ppid(3CONTRACT)
ct_pr_event_get_sender(3CONTRACT)
ct_pr_event_get_senderct(3CONTRACT)
ct_pr_event_get_signal(3CONTRACT)
ct_pr_event_get_zcorefile(3CONTRACT)
ct_pr_status_get_contracts(3CONTRACT)
ct_pr_status_get_fatal(3CONTRACT)
ct_pr_status_get_members(3CONTRACT)
ct_pr_status_get_param(3CONTRACT)
ct_pr_status_get_svc_aux(3CONTRACT)
ct_pr_status_get_svc_creator(3CONTRACT)
ct_pr_status_get_svc_ctid(3CONTRACT)
ct_pr_status_get_svc_fmri(3CONTRACT)
ct_pr_tmpl_get_fatal(3CONTRACT)
ct_pr_tmpl_get_param(3CONTRACT)
ct_pr_tmpl_get_svc_aux(3CONTRACT)
ct_pr_tmpl_get_svc_fmri(3CONTRACT)
ct_pr_tmpl_get_transfer(3CONTRACT)
ct_pr_tmpl_set_fatal(3CONTRACT)
ct_pr_tmpl_set_param(3CONTRACT)
ct_pr_tmpl_set_svc_aux(3CONTRACT)
ct_pr_tmpl_set_svc_fmri(3CONTRACT)
ct_pr_tmpl_set_transfer(3CONTRACT)
ct_status_get_cookie(3CONTRACT)
ct_status_get_critical(3CONTRACT)
ct_status_get_holder(3CONTRACT)
ct_status_get_informative(3CONTRACT)
ct_status_get_nevents(3CONTRACT)
ct_status_get_nevid(3CONTRACT)
ct_status_get_ntime(3CONTRACT)
ct_status_get_qtime(3CONTRACT)
ct_status_get_state(3CONTRACT)
ct_status_get_zoneid(3CONTRACT)
ct_tmpl_get_critical(3CONTRACT)
ct_tmpl_get_informative(3CONTRACT)
ct_tmpl_set_critical(3CONTRACT)
ct_tmpl_set_informative(3CONTRACT)
dat_evd_clear_unwaitable(3DAT)
dat_get_consumer_context(3DAT)
dat_registry_add_provider(3DAT)
dat_registry_list_providers(3DAT)
dat_registry_remove_provider(3DAT)
dat_set_consumer_context(3DAT)
devid_deviceid_to_nmlist(3DEVID)
di_link_next_by_lnode(3DEVINFO)
di_link_next_by_node(3DEVINFO)
di_lnode_private_get(3DEVINFO)
di_lnode_private_set(3DEVINFO)
di_minor_private_get(3DEVINFO)
di_minor_private_set(3DEVINFO)
di_path_client_devfs_path(3DEVINFO)
di_path_client_next_path(3DEVINFO)
di_path_phci_next_path(3DEVINFO)
di_path_prop_lookup_bytes(3DEVINFO)
di_path_prop_lookup_int64s(3DEVINFO)
di_path_prop_lookup_ints(3DEVINFO)
di_path_prop_lookup_strings(3DEVINFO)
di_path_prop_strings(3DEVINFO)
di_prom_prop_lookup_bytes(3DEVINFO)
di_prom_prop_lookup_ints(3DEVINFO)
di_prom_prop_lookup_strings(3DEVINFO)
di_prop_lookup_bytes(3DEVINFO)
di_prop_lookup_int64(3DEVINFO)
di_prop_lookup_strings(3DEVINFO)
ea_match_object_catalog(3EXACCT)
- SHA2 digest functions
cc [ flag ... ] file ... -lmd [ library ... ] #include <sha2.h> void SHA2Init(uint64_t mech, SHA2_CTX *context);
void SHA2Update(SHA2_CTX *context, unsigned char *input, unsigned int inlen);
void SHA2Final(unsigned char *output, SHA2_CTX *context);
void SHA224Init(SHA224_CTX *context);
void SHA224Update(SHA224_CTX *context, unsigned char *input, unsigned int inlen);
void SHA224Final(unsigned char *output, SHA224_CTX *context);
void SHA256Init(SHA256_CTX *context);
void SHA256Update(SHA256_CTX *context, unsigned char *input, unsigned int inlen);
void SHA256Final(unsigned char *output, SHA256_CTX *context);
void SHA384Init(SHA384_CTX *context);
void SHA384Update(SHA384_CTX *context, unsigned char *input, unsigned int inlen);
void SHA384Final(unsigned char *output, SHA384_CTX *context);
void SHA512Init(SHA512_CTX *context);
void SHA512Update(SHA512_CTX *context, unsigned char *input, unsigned int inlen);
void SHA512Final(unsigned char *output, SHA512_CTX *context);
The SHA2Init(), SHA2Update(), SHA2Final() functions implement the SHA224, SHA256, SHA384 and SHA512 message-digest algorithms. The algorithms take as input a message of arbitrary length and produces a 200-bit “fingerprint” or “message digest” as output. The SHA2 message-digest algorithms are intended for digital signature applications in which large files are “compressed” in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA.
The SHA2Init(), SHA2Update(), and SHA2Final() functions allow an SHA2 digest to be computed over multiple message blocks. Between blocks, the state of the SHA2 computation is held in an SHA2 context structure allocated by the caller. A complete digest computation consists of calls to SHA2 functions in the following order: one call to SHA2Init(), one or more calls to SHA2Update(), and one call to SHA2Final().
The SHA2Init() function initializes the SHA2 context structure pointed to by context. The mech argument is one of SHA224, SHA256, SHA512, and SHA384.
The SHA2Update() function computes a partial SHA2 digest on the inlen-byte message block pointed to by input, and updates the SHA2 context structure pointed to by context accordingly.
The SHA2Final() function generates the final SHA2Final digest, using the SHA2 context structure pointed to by context. The SHA2 digest is written to output. After a call to SHA2Final(), the state of the context structure is undefined. It must be reinitialized with SHA2Init() before it can be used again.
Alternative APIs exist as named above. The Update() and Final() sets of functions operate exactly as the previously described SHA2Update() and SHA2Final() functions. The SHA224Init(), SHA256Init(), SHA384Init(), and SHA512Init() functions do not take the mech argument as it is implicit in the function names.
These functions do not return a value.
Example 1 Authenticate a message found in multiple buffers
The following is a sample function that authenticates a message found in multiple buffers. The calling function provides an authentication buffer to contain the result of the SHA2 digest.
#include <sys/types.h> #include <sys/uio.h> #include <sha2.h> int AuthenticateMsg(unsigned char *auth_buffer, struct iovec *messageIov, unsigned int num_buffers) { SHA2_CTX sha2_context; unsigned int i; SHA2Init(SHA384, &sha2_context); for(i=0; i<num_buffers; i++) { SHA2Update(&sha2_context, messageIov->iov_base, messageIov->iov_len); messageIov += sizeof(struct iovec); } SHA2Final(auth_buffer, &sha2_context); return 0; }
Example 2 Authenticate a message found in multiple buffers
The following is a sample function that authenticates a message found in multiple buffers. The calling function provides an authentication buffer that will contain the result of the SHA384 digest, using alternative interfaces.
int AuthenticateMsg(unsigned char *auth_buffer, struct iovec *messageIov, unsigned int num_buffers) { SHA384_CTX ctx; unsigned int i; SHA384Init(&ctx); for(i=0, i<num_buffers; i++ { SHA384Update(&ctx, messageIov->iov_base, messageIov->iov_len); messageIov += sizeof(struct iovec); } SHA384Final(auth_buffer, &ctx); return 0; }
See attributes(5) for descriptions of the following attributes:
|
FIPS 180–2