本文整理汇总了C++中OpenSSL_add_all_ciphers函数的典型用法代码示例。如果您正苦于以下问题:C++ OpenSSL_add_all_ciphers函数的具体用法?C++ OpenSSL_add_all_ciphers怎么用?C++ OpenSSL_add_all_ciphers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OpenSSL_add_all_ciphers函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: AES256
/**
* @ingroup TestOpenssl
* @brief AES256 암호화 테스트
*/
void AES256( )
{
const char * pszKey = "12345678901234567890123456789012";
const char * pszIv = "1234567890123456";
const char * pszInput = "ABCD";
char szOutput[255];
int iOutputLen, iLen;
OpenSSL_add_all_ciphers();
const EVP_CIPHER * psttCipher = EVP_get_cipherbyname( "aes256" );
EVP_CIPHER_CTX sttCtx;
memset( szOutput, 0, sizeof(szOutput) );
EVP_CIPHER_CTX_init( &sttCtx );
EVP_EncryptInit( &sttCtx, psttCipher, (const unsigned char *)pszKey, (const unsigned char *)pszIv );
EVP_EncryptUpdate( &sttCtx, (uint8_t *)szOutput, &iOutputLen, (uint8_t *)pszInput, strlen(pszInput) );
EVP_EncryptFinal( &sttCtx, (uint8_t *)szOutput + iOutputLen, &iLen );
EVP_CIPHER_CTX_cleanup( &sttCtx );
iOutputLen += iLen;
for( int i = 0; i < iOutputLen; ++i )
{
printf( "%02X", (uint8_t)szOutput[i] );
}
printf( "\n" );
EVP_cleanup();
}
开发者ID:YeeYoungHan,项目名称:cppsipstack,代码行数:37,代码来源:AES256.cpp
示例2: pthread_mutex_lock
void SSLSupport::init(void)
{
pthread_mutex_lock(&s_initLock);
if (s_initCounter) {
//already inited, exit
pthread_mutex_unlock(&s_initLock);
return;
}
++s_initCounter;
SSL_load_error_strings(); /* readable error messages */
SSL_library_init(); /* initialize library */
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
ERR_load_crypto_strings();
s_nLocks = CRYPTO_num_locks();
s_mutexArray = (pthread_mutex_t*) OPENSSL_malloc(s_nLocks * sizeof(pthread_mutex_t));
for (int i = 0; i < s_nLocks; i++)
{
pthread_mutex_init(&s_mutexArray[i], NULL);
}
CRYPTO_set_id_callback(getThreadID);
CRYPTO_set_locking_callback(lock);
pthread_mutex_unlock(&s_initLock);
}
开发者ID:dkirker,项目名称:BrowserServer,代码行数:29,代码来源:SSLSupport.cpp
示例3: CRYPTO_mem_ctrl
void RSAZCryptor::init()
{
m_trace_level = 0;
m_encoding = true;
bio_err = NULL;
priv_mem = NULL;
pub_mem = NULL;
privkey = NULL;
pubkey = NULL;
priv_rsa = NULL;
pub_rsa = NULL;
priv_size = 0;
pub_size = 0;
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
bio_err=BIO_new_fp(stderr, BIO_NOCLOSE);
#if defined(_WIN32) || defined(__linux__)
OpenSSL_add_all_ciphers();
#else
SSL_library_init();
#endif
ERR_load_crypto_strings ();
seed_prng();
m_keycache = new ZKeyCache();
m_filesToBeZIP = NULL;
}
开发者ID:elahehrashedi,项目名称:HPCC-Platform,代码行数:33,代码来源:zcrypt.cpp
示例4: isns_create_dsa_context
/*
* Create a DSA security context
*/
isns_security_t *
isns_create_dsa_context(void)
{
isns_security_t *ctx;
#if OPENSSL_VERSION_NUMBER < 0x10100000L
if (!isns_openssl_init) {
ERR_load_crypto_strings();
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
isns_openssl_init = 1;
}
#endif
ctx = isns_calloc(1, sizeof(*ctx));
ctx->is_name = "DSA";
ctx->is_type = ISNS_AUTH_TYPE_SHA1_DSA;
ctx->is_replay_window = isns_config.ic_auth.replay_window;
ctx->is_timestamp_jitter = isns_config.ic_auth.timestamp_jitter;
ctx->is_verify = isns_dsasig_verify;
ctx->is_sign = isns_dsasig_sign;
ctx->is_load_private = isns_dsasig_load_private_pem;
ctx->is_load_public = isns_dsasig_load_public_pem;
isns_debug_auth("Created DSA authentication context\n");
return ctx;
}
开发者ID:open-iscsi,项目名称:open-isns,代码行数:33,代码来源:pki.c
示例5: rsa_priv_decrypt
int rsa_priv_decrypt(char ** str_out, char *str_in, size_t str_in_sz, char *key_file, char * keypass)
{
RSA * priv_key = NULL;
FILE * priv_key_file;
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
ERR_load_crypto_strings();
priv_key_file = fopen(key_file, "rb");
priv_key = PEM_read_RSAPrivateKey(priv_key_file, NULL, NULL, keypass);
fclose(priv_key_file);
if (!priv_key) {
std::cerr << ERR_error_string(ERR_get_error(), NULL) << std::endl;
return -1;
}
int key_size = RSA_size(priv_key);
unsigned char *ustr_out = (unsigned char *)malloc(key_size);
int len = RSA_private_decrypt(str_in_sz, (unsigned char *)&str_in[0], ustr_out, priv_key, RSA_PKCS1_PADDING);
if (len == -1) {
std::cerr << "RSA_private_decrypt error (rsa_priv_decrypt)." << std::endl;
std::cerr << ERR_error_string(ERR_get_error(), NULL) << std::endl;
return -1;
}
*str_out = (char *)ustr_out;
return len;
}
开发者ID:GameAP,项目名称:GDaemon2,代码行数:32,代码来源:gcrypt.cpp
示例6: main
int main(int argc, char **argv)
{
int i;
char *names[] = {
"sms4-ecb",
"sms4-cbc",
"sms4-cfb",
"sms4-ofb",
"sms4-ctr",
};
const EVP_CIPHER *cipher;
OpenSSL_add_all_ciphers();
printf("%s new ciphers:\n\n", OPENSSL_VERSION_TEXT);
for (i = 0; i < sizeof(names)/sizeof(names[i]); i++) {
if (!(cipher = EVP_get_cipherbyname(names[i]))) {
fprintf(stderr, "cipher \"%s\" is not supported\n", names[i]);
continue;
}
printf(" cipher nid : %d\n", EVP_CIPHER_nid(cipher));
printf(" cipher name : %s\n", EVP_CIPHER_name(cipher));
printf(" block size : %d\n", EVP_CIPHER_block_size(cipher));
printf(" key length : %d\n", EVP_CIPHER_key_length(cipher));
printf(" iv length : %d\n", EVP_CIPHER_iv_length(cipher));
printf(" flags : 0x%016lx\n", EVP_CIPHER_flags(cipher));
printf("\n");
}
return 0;
}
开发者ID:kenchowcn,项目名称:GmSSL,代码行数:33,代码来源:listciphers.c
示例7: load_rsa_key
static RSA *
load_rsa_key(const char *privkey)
{
RSA *rsa = NULL;
char *defprivkey;
/*
* If privkey not set, default to ~/.ssh/id_rsa.
*/
if (privkey == NULL)
defprivkey = xbps_xasprintf("%s/.ssh/id_rsa", getenv("HOME"));
else
defprivkey = strdup(privkey);
ERR_load_crypto_strings();
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
if ((rsa = load_rsa_privkey(defprivkey)) == NULL) {
fprintf(stderr, "%s: failed to read the RSA privkey\n", _XBPS_RINDEX);
exit(EXIT_FAILURE);
}
return rsa;
}
开发者ID:uggedal,项目名称:xbps,代码行数:26,代码来源:sign.c
示例8: rsa_verify_cert
int
rsa_verify_cert(const char *path, unsigned char *key, int keylen,
unsigned char *sig, int siglen, int fd)
{
int ret;
bool need_close = false;
struct rsa_verify_cbdata cbdata;
if (fd == -1) {
if ((fd = open(path, O_RDONLY)) == -1) {
pkg_emit_errno("fopen", path);
return (EPKG_FATAL);
}
need_close = true;
}
(void)lseek(fd, 0, SEEK_SET);
cbdata.key = key;
cbdata.keylen = keylen;
cbdata.sig = sig;
cbdata.siglen = siglen;
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
ret = pkg_emit_sandbox_call(rsa_verify_cert_cb, fd, &cbdata);
if (need_close)
close(fd);
return (ret);
}
开发者ID:HardenedBSD,项目名称:pkg,代码行数:32,代码来源:rsa.c
示例9: libssh2_publickey_is_privatekey
LIBSSH2_API int libssh2_publickey_is_privatekey(const char *keypath, const char *passphrase)
{
int st;
BIO* bp;
EVP_PKEY* pk;
bp = BIO_new_file(keypath, "r");
if (bp == NULL) {
return -1;
}
if (!EVP_get_cipherbyname("des")) {
/* If this cipher isn't loaded it's a pretty good indication that none
* are. I have *NO DOUBT* that there's a better way to deal with this
* ($#&%#$(%$#( Someone buy me an OpenSSL manual and I'll read up on
* it.
*/
OpenSSL_add_all_ciphers();
}
BIO_reset(bp);
pk = PEM_read_bio_PrivateKey(bp, NULL, NULL, (void*)passphrase);
BIO_free(bp);
if (pk == NULL) {
/* _libssh2_error(session, */
/* LIBSSH2_ERROR_FILE, */
/* "Wrong passphrase or invalid/unrecognized " */
/* "private key file format"); */
return -1;
}
return 1;
}
开发者ID:caidongyun,项目名称:nullfxp,代码行数:32,代码来源:ssh_info.c
示例10: OPENSSL_add_all_algorithms_noconf
void
OPENSSL_add_all_algorithms_noconf(void)
{
OPENSSL_cpuid_setup();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:7,代码来源:c_all.c
示例11: env_init
ENVELOP_API int env_init(IN const char * cert,IN const char * key)
{
//初始化Openssl
do {
CRYPTO_malloc_init();
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
ERR_load_PEM_strings();//TaoNote ,如果不调这个函数,则在读读取PEM时会异常
ERR_load_crypto_strings();
} while(0);
//检查证书文件是否可用
if(cert != NULL)
{
if(g_pub_key != NULL)
EVP_PKEY_free(g_pub_key);
g_pub_key = read_pub_key(cert);
if(!g_pub_key)
return ERR_ENV_CERT_INVALID;
g_pub_key_size = EVP_PKEY_size(g_pub_key);
}
//检查私钥文件是否可用
if(g_prv_key != NULL)
EVP_PKEY_free(g_prv_key);
g_prv_key = read_private_key(key);
if (!g_prv_key)
return ERR_ENV_KEY_INVALID;
return 0;
}
开发者ID:SomebodyLuo,项目名称:exm_onvif,代码行数:35,代码来源:gt_env.c
示例12: openssl_init
void openssl_init()
{
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
ERR_load_crypto_strings();
}
开发者ID:viktorTarasov,项目名称:has,代码行数:7,代码来源:test_pkcs10.c
示例13: pkg_repo_verify
int
pkg_repo_verify(const char *path, unsigned char *sig, unsigned int sig_len)
{
char sha256[SHA256_DIGEST_LENGTH *2 +1];
char errbuf[1024];
RSA *rsa = NULL;
sha256_file(path, sha256);
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
rsa = load_rsa_public_key(pkg_config("PUBKEY"));
if (rsa == NULL)
return(EPKG_FATAL);
if (RSA_verify(NID_sha1, sha256, sizeof(sha256), sig, sig_len, rsa) == 0) {
pkg_emit_error("%s: %s", pkg_config("PUBKEY"),
ERR_error_string(ERR_get_error(), errbuf));
return (EPKG_FATAL);
}
RSA_free(rsa);
ERR_free_strings();
return (EPKG_OK);
}
开发者ID:dnaeon,项目名称:pkgng,代码行数:28,代码来源:pkg_repo.c
示例14: SSL_library_init
apisock *api_connect_ssl(){
apisock *ret;
SSL *ssl;
int sock;
sock=connect_socket(API_HOST, API_PORT_SSL);
if (sock==-1)
return NULL;
if (!globalctx){
SSL_library_init();
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
SSL_load_error_strings();
globalctx=SSL_CTX_new(SSLv23_method());
if (!globalctx)
return NULL;
}
ssl=SSL_new(globalctx);
if (!ssl){
close(sock);
return NULL;
}
SSL_set_fd(ssl, sock);
if (SSL_connect(ssl)!=1){
SSL_free(ssl);
close(sock);
return NULL;
}
ret=(apisock *)malloc(sizeof(apisock));
ret->sock=sock;
ret->ssl=ssl;
return ret;
}
开发者ID:andemi02,项目名称:pfs,代码行数:32,代码来源:binapi.c
示例15: mailstream_ssl_init
static inline void mailstream_ssl_init(void)
{
#ifdef USE_SSL
MUTEX_LOCK(&ssl_lock);
#ifndef USE_GNUTLS
if (!openssl_init_done) {
#if defined (HAVE_PTHREAD_H) && !defined (WIN32) && defined (USE_SSL) && defined (LIBETPAN_REENTRANT)
mailstream_openssl_reentrant_setup();
#endif
SSL_load_error_strings();
SSL_library_init();
OpenSSL_add_all_digests();
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
openssl_init_done = 1;
}
#else
if (!gnutls_init_not_required)
gnutls_global_init();
#endif
MUTEX_UNLOCK(&ssl_lock);
#endif
}
开发者ID:SEA2GH,项目名称:libetpan,代码行数:25,代码来源:mailstream_ssl.c
示例16: _winpr_openssl_initialize
static BOOL CALLBACK _winpr_openssl_initialize(PINIT_ONCE once, PVOID param, PVOID* context)
{
DWORD flags = param ? *(PDWORD)param : WINPR_SSL_INIT_DEFAULT;
if (flags & WINPR_SSL_INIT_ALREADY_INITIALIZED)
{
return TRUE;
}
#ifdef WINPR_OPENSSL_LOCKING_REQUIRED
if (flags & WINPR_SSL_INIT_ENABLE_LOCKING)
{
if (!_winpr_openssl_initialize_locking())
{
return FALSE;
}
}
#endif
/* SSL_load_error_strings() is void */
#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
SSL_load_error_strings();
/* SSL_library_init() always returns "1" */
SSL_library_init();
OpenSSL_add_all_digests();
OpenSSL_add_all_ciphers();
#else
if (OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS |
OPENSSL_INIT_LOAD_CRYPTO_STRINGS |
OPENSSL_INIT_ADD_ALL_CIPHERS |
OPENSSL_INIT_ADD_ALL_DIGESTS |
OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL) != 1)
return FALSE;
#endif
g_winpr_openssl_initialized_by_winpr = TRUE;
if (flags & WINPR_SSL_INIT_ENABLE_FIPS)
{
#if (OPENSSL_VERSION_NUMBER < 0x10001000L)
WLog_ERR(TAG, "Openssl fips mode ENable not available on openssl versions less than 1.0.1!");
#else
WLog_DBG(TAG, "Ensuring openssl fips mode is ENabled");
if (FIPS_mode() != 1)
{
if (FIPS_mode_set(1))
WLog_INFO(TAG, "Openssl fips mode ENabled!");
else
WLog_ERR(TAG, "Openssl fips mode ENable failed!");
}
#endif
}
return TRUE;
}
开发者ID:99455125,项目名称:FreeRDP,代码行数:59,代码来源:ssl.c
示例17: OpenSSL_add_all_algorithms
CHTTPCrypt::CHTTPCrypt()
{
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
retrievePreKey();
}
开发者ID:GoGoogle,项目名称:WindowsAgent,代码行数:8,代码来源:HTTPCrypt.cpp
示例18: R_init_openssl
void R_init_openssl(DllInfo *info) {
OpenSSL_add_all_digests();
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
ERR_load_crypto_strings();
SSL_load_error_strings();
SSL_library_init();
}
开发者ID:rOpenSec,项目名称:openssl,代码行数:8,代码来源:onload.c
示例19: OPENSSL_add_all_algorithms_noconf
void OPENSSL_add_all_algorithms_noconf(void)
{
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
#ifdef __OpenBSD__
ENGINE_setup_openbsd();
#endif
}
开发者ID:xyzy,项目名称:mips-openssl_0.9.7,代码行数:8,代码来源:c_all.c
示例20: main
int main(void)
{
CRYPTO_set_mem_debug(1);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
ERR_load_crypto_strings();
/* Load up the software EVP_CIPHER and EVP_MD definitions */
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
if (!test_EVP_DigestSignInit()) {
fprintf(stderr, "EVP_DigestSignInit failed\n");
return 1;
}
if (!test_EVP_DigestVerifyInit()) {
fprintf(stderr, "EVP_DigestVerifyInit failed\n");
return 1;
}
if (!test_d2i_AutoPrivateKey(kExampleRSAKeyDER, sizeof(kExampleRSAKeyDER),
EVP_PKEY_RSA)) {
fprintf(stderr, "d2i_AutoPrivateKey(kExampleRSAKeyDER) failed\n");
return 1;
}
if (!test_d2i_AutoPrivateKey
(kExampleRSAKeyPKCS8, sizeof(kExampleRSAKeyPKCS8), EVP_PKEY_RSA)) {
fprintf(stderr, "d2i_AutoPrivateKey(kExampleRSAKeyPKCS8) failed\n");
return 1;
}
#ifndef OPENSSL_NO_EC
if (!test_d2i_AutoPrivateKey(kExampleECKeyDER, sizeof(kExampleECKeyDER),
EVP_PKEY_EC)) {
fprintf(stderr, "d2i_AutoPrivateKey(kExampleECKeyDER) failed\n");
return 1;
}
if (!test_EVP_PKCS82PKEY()) {
fprintf(stderr, "test_EVP_PKCS82PKEY failed\n");
return 1;
}
#endif
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
ERR_remove_thread_state(NULL);
ERR_free_strings();
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
if (CRYPTO_mem_leaks_fp(stderr) <= 0)
return 1;
#endif
printf("PASS\n");
return 0;
}
开发者ID:Voxer,项目名称:openssl,代码行数:57,代码来源:evp_extra_test.c
注:本文中的OpenSSL_add_all_ciphers函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论