本文整理汇总了C++中crypto_init函数的典型用法代码示例。如果您正苦于以下问题:C++ crypto_init函数的具体用法?C++ crypto_init怎么用?C++ crypto_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了crypto_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
static void
init(void) {
logger_init(daemon_mode);
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
signal(SIGCHLD, SIG_IGN);
signal(SIGABRT, SIG_IGN);
#endif
if (crypto_init(password)) {
logger_log(LOG_ERR, "crypto init failed");
exit(1);
}
resolver_prepare(nameserver_num);
uv_key_create(&thread_resolver_key);
if (idle_timeout == 0) {
idle_timeout = 60;
}
}
示例2: app_startup
void
app_startup(void)
{
msg_init(FALSE);
iv_set_fatal_msg_handler(app_fatal);
iv_init();
g_thread_init(NULL);
crypto_init();
hostname_global_init();
dns_caching_global_init();
dns_caching_thread_init();
afinter_global_init();
child_manager_init();
alarm_init();
stats_init();
tzset();
log_msg_global_init();
log_tags_global_init();
log_source_global_init();
log_template_global_init();
value_pairs_global_init();
service_management_init();
scratch_buffers_allocator_init();
main_loop_thread_resource_init();
nondumpable_setlogger(nondumpable_allocator_logger);
secret_storage_init();
transport_factory_id_global_init();
}
示例3: test_crypto
void
test_crypto (enum transform which)
{
u_int8_t buf[256];
struct crypto_xf *xf;
struct keystate *ks;
enum cryptoerr err;
xf = crypto_get (which);
printf ("Testing %s: ", xf->name);
SET_KEY (buf, xf->keymax);
ks = crypto_init (xf, buf, xf->keymax, &err);
if (!ks)
{
printf ("FAILED (init %d)", err);
goto fail;
}
SET_KEY (buf, sizeof (buf));
crypto_init_iv (ks, buf, xf->blocksize);
crypto_encrypt (ks, buf, sizeof (buf));
dump_buf (buf, sizeof buf);
crypto_decrypt (ks, buf, sizeof (buf));
if (!verify_buf (buf, sizeof (buf)))
printf ("FAILED ");
else
printf ("OKAY ");
free (ks);
fail:
printf ("\n");
return;
}
示例4: cli_session
void cli_session(int sock_in, int sock_out) {
seedrandom();
crypto_init();
common_session_init(sock_in, sock_out);
chaninitialise(cli_chantypes);
/* Set up cli_ses vars */
cli_session_init();
/* Ready to go */
sessinitdone = 1;
/* Exchange identification */
session_identification();
send_msg_kexinit();
session_loop(cli_sessionloop);
/* Not reached */
}
示例5: objectcrypto_decrypt
const unsigned char * objectcrypto_decrypt(char *user, char *object, char *content, char *passphrase)
{
//the three keys
const unsigned char *K1, *K2, *K2E, *IV, *De;
//initialize
crypto_init();
//first, obtain K1 by hashing the passphrase.
K1 = crypto_MD5(passphrase);
//second, obtain K2E from the keySafe:
K2E = keyset_retrieve(user, object);
//third, use this to decrypt K2E to find K2.
IV = IVSTRING;//_setIV(K1);
K2 = crypto_decryptAES(K1, IV, K2E);
//fourth, once you have K2, you can decrypt the content
De = crypto_decryptAES(K2, IV, content);
//check if the original file was blank
if (strncmp(De, blankFile, 16) == 0)
{
De = NULL;
}
crypto_destroy();
//return this content
return De;
}
示例6: init
static void
init(void) {
#ifdef ANDROID
logger_init(0);
#else
logger_init(daemon_mode);
#endif
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
#if !defined(_WIN32)
signal(SIGPIPE, SIG_IGN);
signal(SIGCHLD, SIG_IGN);
signal(SIGABRT, SIG_IGN);
#endif
if (crypto_init(password)) {
logger_stderr("crypto init failed");
exit(1);
}
if (idle_timeout == 0) {
idle_timeout = 60;
}
#if !defined(_WIN32)
if (acl_file != NULL) {
acl = !acl_init(acl_file);
}
#endif
}
示例7: service_init
void service_init(struct service *sv, uint16_t port, const char *key, const char *capture, const char *playback, uint32_t bitrate,
void (*handler)(enum service_event event, const uint8_t uid[20], void *args), void *args)
{
sv->state = STATE_IDLE;
sv->state_handler = handler;
sv->state_args = args;
sv->epfd = epoll_create1(0); assert(sv->epfd > 0);
sv->timerfd = timerfd_create(CLOCK_MONOTONIC, 0); assert(sv->timerfd > 0);
service_pollfd(sv, sv->timerfd, (void(*)(void*))timer_handler, sv);
const int optval = 1;
const struct sockaddr_in addr = { AF_INET, htons(port) };
sv->sockfd = socket(AF_INET, SOCK_DGRAM, 0); assert(sv->sockfd > 0);
int res = setsockopt(sv->sockfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); assert(res == 0);
if(bind(sv->sockfd, (struct sockaddr*)&addr, sizeof(addr)) != 0) { ERROR("Cannot bind socket"); abort(); }
service_pollfd(sv, sv->sockfd, (void(*)(void*))socket_handler, sv);
route_init(sv->table);
sv->crypto = (struct crypto*)((void*)sv + sizeof(struct service));
crypto_init(sv->crypto, key, sv->srcid);
sv->media = (struct media*)((void*)sv + sizeof(struct service) + crypto_sizeof());
media_init(sv->media, capture, playback);
sv->packet_size = bitrate / 8 / 50;
INFO("Media: bitrate = %u, capture = %s, playback = %s", bitrate, capture, playback);
char tmp[128]; INFO("User ID is %.40s", hexify(sv->srcid, tmp, 20));
}
示例8: init
/**
* Parse the config file, and initiate the host and crypto modules.
*/
int init (void)
{
int port, max, capup, capdown;
parser_load_config(&port, &max, &capup, &capdown);
crypto_init();
return host_init_server(port, max, capup, capdown);
}
示例9: main
int main(int argc, char **argv) {
unsigned char *x;
unsigned long long xlen;
if (argv[0])
if (argv[1]) {
if (str_equal(argv[1], "-h"))
die_usage(0);
}
/* get password */
x = (unsigned char *)env_get("PASSWORD");
if (!x) { errno = 0; die_usage("$PASSWORD not set"); }
xlen = str_len((char *)x);
/* create salt */
randombytes(s, sizeof s);
/* derive key */
if (sha512hmacpbkdf2(h, sizeof h, x, xlen, s, sizeof s, ROUNDS) == -1) die_fatal("unable to derive keys", 0);
byte_zero(x, xlen);
/* create nonce */
randombytes(n, sizeof n);
uint64_pack(n, nanoseconds());
sha512(nk, (unsigned char *)MAGIC, MAGICBYTES);
crypto_block_aes256vulnerable(n, n, nk);
/* initialize */
crypto_init(&ctx, n, h, MAGIC);
randombytes(h, sizeof h);
sha512_init(&shactx);
/* write header */
if (writeall(1, MAGIC, MAGICBYTES) == -1) die_fatal("unable to write output", 0);
if (writeall(1, s, sizeof s) == -1) die_fatal("unable to write output", 0);
randombytes(s, sizeof s);
if (writeall(1, n, sizeof n) == -1) die_fatal("unable to write output", 0);
for (;;) {
inlen = readblock(in, BLOCK);
if (inlen != BLOCK) break;
if (sha512_block(&shactx, in, inlen) != 0) die_fatal("unable to compute hash", 0);
if (crypto_block(&ctx, in, inlen) != 0) die_fatal("unable to encrypt stream", 0);
if (writeall(1, in, inlen) == -1) die_fatal("unable to write output", 0);
}
if (sha512_last(&shactx, h, in, inlen) != 0) die_fatal("unable to compute hash", 0);
byte_copy(in + inlen, CHECKSUMBYTES, h);
inlen += CHECKSUMBYTES;
if (crypto_last(&ctx, in, inlen) != 0) die_fatal("unable to encrypt stream", 0);
if (writeall(1, in, inlen) == -1) die_fatal("unable to write output", 0);
if (fsyncfd(1) == -1) die_fatal("unable to write output", 0);
cleanup();
_exit(0);
}
示例10: mvWLAN_init_crypt_lib
void mvWLAN_init_crypt_lib(local_info_t *local)
{
crypto_init();
INIT_LIST_HEAD(&local->crypt_deinit_list);
init_timer(&local->crypt_deinit_timer);
local->crypt_deinit_timer.data = (unsigned long) local;
local->crypt_deinit_timer.function = crypt_deinit_handler;
}
示例11: u2fs_global_init
/**
* u2fs_global_init:
* @flags: initialization flags, ORed #u2fs_initflags.
*
* Initialize the library. This function is not guaranteed to be
* thread safe and must be invoked on application startup.
*
* Returns: On success %U2FS_OK (integer 0) is returned, and on errors
* an #u2fs_rc error code.
*/
u2fs_rc u2fs_global_init(u2fs_initflags flags)
{
if (flags & U2FS_DEBUG)
debug = 1;
crypto_init();
return U2FS_OK;
}
示例12: storage_init
void
storage_init (struct config_data_storage *config_storage)
{
void crypto_init (void);
crypto_init ();
cfg = config_storage;
storage_desc = msgregister ("storage", storage_msghandler);
}
示例13: load_module
static int load_module(void *mod)
{
crypto_init();
if (ast_opt_init_keys)
crypto_load(STDIN_FILENO, STDOUT_FILENO);
else
crypto_load(-1, -1);
return 0;
}
示例14: crypto_randomize
gboolean
crypto_randomize (void *buffer, gsize buffer_len, GError **error)
{
if (!crypto_init (error))
return FALSE;
gnutls_rnd (GNUTLS_RND_RANDOM, buffer, buffer_len);
return TRUE;
}
示例15: load_module
int load_module(void)
{
crypto_init();
if (option_initcrypto)
crypto_load(STDIN_FILENO, STDOUT_FILENO);
else
crypto_load(-1, -1);
return 0;
}