本文整理匯總了C++中ENGINE_load_builtin_engines函數的典型用法代碼示例。如果您正苦於以下問題:C++ ENGINE_load_builtin_engines函數的具體用法?C++ ENGINE_load_builtin_engines怎麽用?C++ ENGINE_load_builtin_engines使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ENGINE_load_builtin_engines函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: init_openssl
static void init_openssl(void)
{
atexit(fini_openssl);
OpenSSL_add_all_algorithms();
ENGINE_load_builtin_engines();
ENGINE_register_all_complete();
}
示例2: ENGINE_load_builtin_engines
//ignore
unsigned char *HMACRSA(const EVP_MD *evp_md, const void *key, int key_len,const unsigned char *d, size_t n, unsigned char *md,unsigned int *md_len)
{
HMAC_CTX c;
static unsigned char m[EVP_MAX_MD_SIZE];
//TODO: get/set rsa engine struct
const char *engine_id = "rsa";
ENGINE_load_builtin_engines();
ENGINE *e = ENGINE_by_id(engine_id);//ENGINE_;
if(!e)
fprintf(stderr,"Engine not available\n");
ENGINE_init(e);
if (md == NULL)
md = m;
HMAC_CTX_init(&c);
if (!HMAC_Init_ex(&c, key, key_len, evp_md, NULL))
goto err;
if (!HMAC_Update(&c, d, n))
goto err;
if (!HMAC_Final(&c, md, md_len))
goto err;
HMAC_CTX_cleanup(&c);
ENGINE_free(e);
return md;
err:
HMAC_CTX_cleanup(&c);
ENGINE_free(e);
return NULL;
}
示例3: main
int main(int argc, char **argv)
{
int i;
testdata *test = test_cases;
CRYPTO_malloc_debug_init();
CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
OpenSSL_add_all_digests();
# ifndef OPENSSL_NO_ENGINE
ENGINE_load_builtin_engines();
ENGINE_register_all_digests();
# endif
printf("PKCS5_PBKDF2_HMAC() tests ");
for (i = 0; test->pass != NULL; i++, test++) {
test_p5_pbkdf2(i, "sha1", test, sha1_results[i]);
test_p5_pbkdf2(i, "sha256", test, sha256_results[i]);
test_p5_pbkdf2(i, "sha512", test, sha512_results[i]);
printf(".");
}
printf(" done\n");
# ifndef OPENSSL_NO_ENGINE
ENGINE_cleanup();
# endif
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
ERR_remove_thread_state(NULL);
ERR_free_strings();
CRYPTO_mem_leaks_fp(stderr);
return 0;
}
示例4: tor_init
void
tor_init (void)
{
if (initialized) {
return;
}
ERR_load_crypto_strings();
OpenSSL_add_all_algorithms();
// enable proper threading
locks.length = CRYPTO_num_locks();
locks.item = malloc(locks.length * sizeof(uv_mutex_t));
for (size_t i = 0; i < locks.length; i++) {
uv_mutex_init(&locks.item[i]);
}
CRYPTO_set_locking_callback(_locking_callback);
CRYPTO_set_id_callback(uv_thread_self);
CRYPTO_set_dynlock_create_callback(_dynlock_create_callback);
CRYPTO_set_dynlock_lock_callback(_dynlock_lock_callback);
CRYPTO_set_dynlock_destroy_callback(_dynlock_destroy_callback);
ENGINE_load_builtin_engines();
ENGINE_register_all_complete();
initialized = true;
}
示例5: init_aesni
/* Use AES-NI if available. This is not supported with low-level calls,
we have to use EVP) */
static void init_aesni(void)
{
ENGINE *e;
const char *engine_id = "aesni";
ENGINE_load_builtin_engines();
e = ENGINE_by_id(engine_id);
if (!e) {
//fprintf(stderr, "AES-NI engine not available\n");
return;
}
if (!ENGINE_init(e)) {
fprintf(stderr, "AES-NI engine could not init\n");
ENGINE_free(e);
return;
}
if (!ENGINE_set_default(e, ENGINE_METHOD_ALL & ~ENGINE_METHOD_RAND)) {
/* This should only happen when 'e' can't initialise, but the
* previous statement suggests it did. */
fprintf(stderr, "AES-NI engine initialized but then failed\n");
abort();
}
ENGINE_finish(e);
ENGINE_free(e);
}
示例6: openssl_init
void openssl_init(bool threaded)
{
// initialize the SSL library
SSL_load_error_strings();
SSL_library_init();
unsigned int randSeed = 0;
RAND_bytes( (unsigned char*)&randSeed, sizeof(randSeed) );
srand( randSeed );
#ifndef OPENSSL_NO_ENGINE
/* Load all bundled ENGINEs into memory and make them visible */
ENGINE_load_builtin_engines();
/* Register all of them for every algorithm they collectively implement */
ENGINE_register_all_complete();
#endif // NO_ENGINE
if(threaded)
{
// provide locking functions to OpenSSL since we'll be running with
// threads accessing openssl in parallel.
CRYPTO_set_id_callback( threads_thread_id );
CRYPTO_set_locking_callback( threads_locking_callback );
}
}
示例7: ssl_init
int ssl_init(void) { /* init SSL before parsing configuration file */
SSL_load_error_strings();
SSL_library_init();
index_cli=SSL_get_ex_new_index(0, "cli index",
NULL, NULL, NULL);
index_opt=SSL_CTX_get_ex_new_index(0, "opt index",
NULL, NULL, NULL);
index_redirect=SSL_SESSION_get_ex_new_index(0, "redirect index",
NULL, NULL, NULL);
index_addr=SSL_SESSION_get_ex_new_index(0, "addr index",
NULL, NULL, cb_free);
if(index_cli<0 || index_opt<0 || index_redirect<0 || index_addr<0) {
s_log(LOG_ERR, "Application specific data initialization failed");
return 1;
}
#ifndef OPENSSL_NO_ENGINE
ENGINE_load_builtin_engines();
#endif
#ifndef OPENSSL_NO_DH
dh_params=get_dh2048();
if(!dh_params) {
s_log(LOG_ERR, "Failed to get default DH parameters");
return 1;
}
#endif /* OPENSSL_NO_DH */
return 0;
}
示例8: apps_startup
static int apps_startup()
{
#ifdef SIGPIPE
signal(SIGPIPE, SIG_IGN);
#endif
CRYPTO_malloc_init();
ERR_load_crypto_strings();
ERR_load_SSL_strings();
OPENSSL_load_builtin_modules();
#ifndef OPENSSL_NO_ENGINE
ENGINE_load_builtin_engines();
#endif
if (!app_load_modules(NULL)) {
ERR_print_errors(bio_err);
BIO_printf(bio_err, "Error loading default configuration\n");
return 0;
}
OpenSSL_add_all_algorithms();
OpenSSL_add_ssl_algorithms();
setup_ui_method();
/*SSL_library_init();*/
return 1;
}
示例9: QBox_MakeUpToken
char* QBox_MakeUpToken(const QBox_AuthPolicy* auth)
{
char* uptoken;
char* policy_str;
char* encoded_digest;
char* encoded_policy_str;
char digest[EVP_MAX_MD_SIZE + 1];
unsigned int dgtlen = sizeof(digest);
HMAC_CTX ctx;
ENGINE_load_builtin_engines();
ENGINE_register_all_complete();
policy_str = QBox_AuthPolicy_json(auth);
encoded_policy_str = QBox_String_Encode(policy_str);
free(policy_str);
bzero(digest, sizeof(digest));
HMAC_CTX_init(&ctx);
HMAC_Init_ex(&ctx, QBOX_SECRET_KEY, strlen(QBOX_SECRET_KEY), EVP_sha1(), NULL);
HMAC_Update(&ctx, encoded_policy_str, strlen(encoded_policy_str));
HMAC_Final(&ctx, digest, &dgtlen);
HMAC_CTX_cleanup(&ctx);
encoded_digest = QBox_Memory_Encode(digest, dgtlen);
uptoken = QBox_String_Concat(QBOX_ACCESS_KEY, ":", encoded_digest, ":", encoded_policy_str, NULL);
free(encoded_policy_str);
free(encoded_digest);
return uptoken;
}
示例10: ossl_engine_s_load
static VALUE
ossl_engine_s_load(int argc, VALUE *argv, VALUE klass)
{
#if !defined(HAVE_ENGINE_LOAD_BUILTIN_ENGINES)
return Qnil;
#else
VALUE name;
rb_scan_args(argc, argv, "01", &name);
if(NIL_P(name)){
ENGINE_load_builtin_engines();
return Qtrue;
}
StringValue(name);
#ifndef OPENSSL_NO_STATIC_ENGINE
OSSL_ENGINE_LOAD_IF_MATCH(dynamic);
OSSL_ENGINE_LOAD_IF_MATCH(cswift);
OSSL_ENGINE_LOAD_IF_MATCH(chil);
OSSL_ENGINE_LOAD_IF_MATCH(atalla);
OSSL_ENGINE_LOAD_IF_MATCH(nuron);
OSSL_ENGINE_LOAD_IF_MATCH(ubsec);
OSSL_ENGINE_LOAD_IF_MATCH(aep);
OSSL_ENGINE_LOAD_IF_MATCH(sureware);
OSSL_ENGINE_LOAD_IF_MATCH(4758cca);
#endif
#ifdef HAVE_ENGINE_LOAD_OPENBSD_DEV_CRYPTO
OSSL_ENGINE_LOAD_IF_MATCH(openbsd_dev_crypto);
#endif
OSSL_ENGINE_LOAD_IF_MATCH(openssl);
rb_warning("no such builtin loader for `%s'", RSTRING_PTR(name));
return Qnil;
#endif /* HAVE_ENGINE_LOAD_BUILTIN_ENGINES */
}
示例11: malloc
void BTCTrader::signRequest ( QString* header, QNetworkRequest* newRequest )
{
nonce += 1;
*header = ( header->length() == 0 ) ? "nonce=" + QString::number( nonce ) : "nonce=" + QString::number( nonce ) + "&" + *header;
QByteArray key = QByteArray::fromBase64( restSign.toStdString().c_str() );
unsigned char* result;
unsigned int result_len = 512;
HMAC_CTX ctx;
result = (unsigned char*) malloc(sizeof(unsigned char) * result_len);
ENGINE_load_builtin_engines();
ENGINE_register_all_complete();
HMAC_CTX_init(&ctx);
HMAC_Init_ex(&ctx, key.constData(), key.length(), EVP_sha512(), NULL);
HMAC_Update(&ctx, (unsigned char*)header->toAscii().constData(), header->length());
HMAC_Final(&ctx, result, &result_len);
HMAC_CTX_cleanup(&ctx);
newRequest->setRawHeader( "Rest-Key", restKey.toStdString().c_str() );
newRequest->setRawHeader( "Rest-Sign", QByteArray::fromRawData( (char*)result, result_len ).toBase64() );
newRequest->setRawHeader( "content-type","application/x-www-form-urlencoded" );
free ( result );
}
示例12: main
int main(int argc, char **argv) {
OpenSSL_add_all_algorithms();
int len = 128 * MB;
if (argc > 1) {
len = atoi(argv[1]) * MB;
}
unsigned char *buf = (unsigned char *) malloc(TOTAL_LEN);
if (!buf) {
fprintf(stderr, "Error Allocating Memory");
}
ENGINE_load_builtin_engines();
#ifdef OPENCL_ENGINE
ENGINE *e = ENGINE_by_id("dynamic");
if (!ENGINE_ctrl_cmd_string(e, "SO_PATH", OPENCL_ENGINE, 0) ||
!ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0)) {
fprintf(stderr, "Failed to load OpenCL engine!\n");
return -1;
}
ENGINE_set_default(e, ENGINE_METHOD_ALL);
#endif
run(argv[0], buf, len);
free(buf);
return 0;
}
示例13: setup_engine
static ENGINE *
setup_engine (const char *engine)
{
ENGINE *e = NULL;
ENGINE_load_builtin_engines ();
if (engine)
{
if (strcmp (engine, "auto") == 0)
{
msg (M_INFO, "Initializing OpenSSL auto engine support");
ENGINE_register_all_complete ();
return NULL;
}
if ((e = ENGINE_by_id (engine)) == NULL
&& (e = try_load_engine (engine)) == NULL)
{
msg (M_FATAL, "OpenSSL error: cannot load engine '%s'", engine);
}
if (!ENGINE_set_default (e, ENGINE_METHOD_ALL))
{
msg (M_FATAL, "OpenSSL error: ENGINE_set_default failed on engine '%s'",
engine);
}
msg (M_INFO, "Initializing OpenSSL support for engine '%s'",
ENGINE_get_id (e));
}
return e;
}
示例14: openssl_config_int
int openssl_config_int(const OPENSSL_INIT_SETTINGS *settings)
{
int ret;
const char *filename;
const char *appname;
unsigned long flags;
if (openssl_configured)
return 1;
filename = settings ? settings->filename : NULL;
appname = settings ? settings->appname : NULL;
flags = settings ? settings->flags : DEFAULT_CONF_MFLAGS;
#ifdef OPENSSL_INIT_DEBUG
fprintf(stderr, "OPENSSL_INIT: openssl_config_int(%s, %s, %lu)\n",
filename, appname, flags);
#endif
OPENSSL_load_builtin_modules();
#ifndef OPENSSL_NO_ENGINE
/* Need to load ENGINEs */
ENGINE_load_builtin_engines();
#endif
ERR_clear_error();
#ifndef OPENSSL_SYS_UEFI
ret = CONF_modules_load_file(filename, appname, flags);
#endif
openssl_configured = 1;
return ret;
}
示例15: OPENSSL_config
void OPENSSL_config(const char *config_name)
{
if (openssl_configured)
return;
OPENSSL_load_builtin_modules();
#ifndef OPENSSL_NO_ENGINE
/* Need to load ENGINEs */
ENGINE_load_builtin_engines();
#endif
/* Add others here? */
ERR_clear_error();
if (CONF_modules_load_file(NULL, config_name,
CONF_MFLAGS_DEFAULT_SECTION|CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0)
{
BIO *bio_err;
ERR_load_crypto_strings();
if ((bio_err=BIO_new_fp(stderr, BIO_NOCLOSE)) != NULL)
{
BIO_printf(bio_err,"Auto configuration failed\n");
ERR_print_errors(bio_err);
BIO_free(bio_err);
}
fprintf(stderr, "OpenSSL could not auto-configure.\n");
exit(1);
}
return;
}