• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OPENSSL_config函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中OPENSSL_config函数的典型用法代码示例。如果您正苦于以下问题:C++ OPENSSL_config函数的具体用法?C++ OPENSSL_config怎么用?C++ OPENSSL_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了OPENSSL_config函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: xmlSecOpenSSLAppInit

/**
 * xmlSecOpenSSLAppInit:
 * @config:             the path to certs.
 *
 * General crypto engine initialization. This function is used
 * by XMLSec command line utility and called before
 * @xmlSecInit function.
 *
 * Returns: 0 on success or a negative value otherwise.
 */
int
xmlSecOpenSSLAppInit(const char* config) {
    ERR_load_crypto_strings();

#ifndef XMLSEC_OPENSSL_110
    OPENSSL_config(NULL);
#endif

    OpenSSL_add_all_algorithms();

    if((RAND_status() != 1) && (xmlSecOpenSSLAppLoadRANDFile(NULL) != 1)) {
        xmlSecError(XMLSEC_ERRORS_HERE,
                    NULL,
                    "xmlSecOpenSSLAppLoadRANDFile",
                    XMLSEC_ERRORS_R_XMLSEC_FAILED,
                    XMLSEC_ERRORS_NO_MESSAGE);
        return(-1);
    }

    if((config != NULL) && (xmlSecOpenSSLSetDefaultTrustedCertsFolder(BAD_CAST config) < 0)) {
        xmlSecError(XMLSEC_ERRORS_HERE,
                    NULL,
                    "xmlSecOpenSSLSetDefaultTrustedCertsFolder",
                    XMLSEC_ERRORS_R_XMLSEC_FAILED,
                    XMLSEC_ERRORS_NO_MESSAGE);
        return(-1);
    }

    return(0);
}
开发者ID:symma,项目名称:xmlsec,代码行数:40,代码来源:app.c


示例2: my_ssl_start

/*
  Initializes SSL and allocate global
  context SSL_context

  SYNOPSIS
    my_ssl_start
      mysql        connection handle

  RETURN VALUES
    0  success
    1  error
*/
int my_ssl_start(MYSQL *mysql)
{
    int rc= 0;
    DBUG_ENTER("my_ssl_start");
    /* lock mutex to prevent multiple initialization */
    pthread_mutex_lock(&LOCK_ssl_config);
    if (!my_ssl_initialized)
    {
        if (ssl_crypto_init())
            goto end;
        SSL_library_init();

#if SSLEAY_VERSION_NUMBER >= 0x00907000L
        OPENSSL_config(NULL);
#endif
        /* load errors */
        SSL_load_error_strings();
        /* digests and ciphers */
        OpenSSL_add_all_algorithms();

        if (!(SSL_context= SSL_CTX_new(TLSv1_client_method())))
        {
            my_SSL_error(mysql);
            rc= 1;
            goto end;
        }
        my_ssl_initialized= TRUE;
    }
end:
    pthread_mutex_unlock(&LOCK_ssl_config);
    DBUG_RETURN(rc);
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:44,代码来源:ma_secure.c


示例3: lock

void OpenSSLInitializer::initialize()
{
	Poco::FastMutex::ScopedLock lock(_mutex);
	
	if (++_rc == 1)
	{
#if OPENSSL_VERSION_NUMBER >= 0x0907000L
		OPENSSL_config(NULL);
#endif
		SSL_library_init();
		SSL_load_error_strings();
		OpenSSL_add_all_algorithms();
		
		char seed[SEEDSIZE];
		RandomInputStream rnd;
		rnd.read(seed, sizeof(seed));
		RAND_seed(seed, SEEDSIZE);
		
		int nMutexes = CRYPTO_num_locks();
		_mutexes = new Poco::FastMutex[nMutexes];
		CRYPTO_set_locking_callback(&OpenSSLInitializer::lock);
#ifndef POCO_OS_FAMILY_WINDOWS // SF# 1828231: random unhandled exceptions when linking with ssl
		CRYPTO_set_id_callback(&OpenSSLInitializer::id);
#endif
		CRYPTO_set_dynlock_create_callback(&OpenSSLInitializer::dynlockCreate);
		CRYPTO_set_dynlock_lock_callback(&OpenSSLInitializer::dynlock);
		CRYPTO_set_dynlock_destroy_callback(&OpenSSLInitializer::dynlockDestroy);
	}
}
开发者ID:Fangang,项目名称:poco,代码行数:29,代码来源:OpenSSLInitializer.cpp


示例4: signature_init

gboolean signature_init(GError **error)
{
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
	OPENSSL_config(NULL);
	OpenSSL_add_all_algorithms();
	ERR_load_crypto_strings();
#else
	int ret;

	g_return_val_if_fail(error == FALSE || *error == NULL, FALSE);

	ret = OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
	if (!ret) {
		unsigned long err;
		const gchar *data;
		int flags;

		err = ERR_get_error_line_data(NULL, NULL, &data, &flags);
		g_set_error(
				error,
				R_SIGNATURE_ERROR,
				R_SIGNATURE_ERROR_CRYPTOINIT_FAILED,
				"Failed to initalize OpenSSL crypto: %s",
				(flags & ERR_TXT_STRING) ? data : ERR_error_string(err, NULL));
		return FALSE;
	}
#endif

	return TRUE;
}
开发者ID:ukleinek,项目名称:rauc,代码行数:30,代码来源:signature.c


示例5: ma_ssl_start

/*
  Initializes SSL and allocate global
  context SSL_context

  SYNOPSIS
    my_ssl_start
      mysql        connection handle

  RETURN VALUES
    0  success
    1  error
*/
int ma_ssl_start(char *errmsg, size_t errmsg_len)
{
  int rc= 1;
  /* lock mutex to prevent multiple initialization */
  pthread_mutex_init(&LOCK_openssl_config,MY_MUTEX_INIT_FAST);
  pthread_mutex_lock(&LOCK_openssl_config);
  if (!ma_ssl_initialized)
  {
    if (ssl_thread_init())
    {
      strncpy(errmsg, "Not enough memory", errmsg_len);
      goto end;
    }
    SSL_library_init();

#if SSLEAY_VERSION_NUMBER >= 0x00907000L
    OPENSSL_config(NULL);
#endif
    /* load errors */
    SSL_load_error_strings();
    /* digests and ciphers */
    OpenSSL_add_all_algorithms();

    if (!(SSL_context= SSL_CTX_new(TLSv1_client_method())))
    {
      ma_ssl_get_error(errmsg, errmsg_len);
      goto end;
    }
    rc= 0;
    ma_ssl_initialized= TRUE;
  }
end:
  pthread_mutex_unlock(&LOCK_openssl_config);
  return rc;
}
开发者ID:leobackes,项目名称:mariadb-connector-c,代码行数:47,代码来源:openssl.c


示例6: initialize

void initialize()
{
    Mutex::ScopedLock lock(_mutex);
    
    if (++_refCount == 1)
    {
#if OPENSSL_VERSION_NUMBER >= 0x0907000L
        OPENSSL_config(NULL);
#endif
        SSL_library_init();
        SSL_load_error_strings();
        OpenSSL_add_all_algorithms();
        
        char seed[SEEDSIZE];
        Random::getSeed(seed, sizeof(seed));
        RAND_seed(seed, SEEDSIZE);
        
        int nMutexes = CRYPTO_num_locks();
        _mutexes = new Mutex[nMutexes];
        CRYPTO_set_locking_callback(&internal::lock);
// #ifndef WIN32 // SF# 1828231: random unhandled exceptions when linking with ssl
//         CRYPTO_set_id_callback(&internal::id);
// #endif
        CRYPTO_set_dynlock_create_callback(&internal::dynlockCreate);
        CRYPTO_set_dynlock_lock_callback(&internal::dynlock);
        CRYPTO_set_dynlock_destroy_callback(&internal::dynlockDestroy);
    }
}
开发者ID:delort,项目名称:libsourcey,代码行数:28,代码来源:crypto.cpp


示例7: aesdecrypt

int aesdecrypt(unsigned char* ciphertext,int len,unsigned char* key,unsigned char* decryptedtext){
	
	int decryptedtext_len;
	//LOGD("LIB encrypttext:%s:len=%d\n",plaintext, strlen((char *)plaintext));
	//LOGD("LIB key:%s\n",key);
	
	unsigned char iv[32]={0};
	//memset(iv,0x00,sizeof(iv));
	//unsigned char *iv = (unsigned char*)"01234567890123456";
	
	/* Initialise the library */
  ERR_load_crypto_strings();
  OpenSSL_add_all_algorithms();
  OPENSSL_config(NULL);

  /* Decrypt the ciphertext */
  decryptedtext_len = decrypt(ciphertext, len, key, iv,
    decryptedtext);

  /* Add a NULL terminator. We are expecting printable text */
  decryptedtext[decryptedtext_len] = '\0';

  /* Show the decrypted text */
  //printf("Decrypted text is:\n");
  //printf("%s\n", decryptedtext);
  //LOGD("Decrypted text is:\n%s\n",decryptedtext);

  /* Clean up */
  EVP_cleanup();
  ERR_free_strings();
  
  return decryptedtext_len;
}
开发者ID:cloudhi,项目名称:security,代码行数:33,代码来源:aesEncrypt.cpp


示例8: uwsgi_ssl_init

void uwsgi_ssl_init(void) {
        OPENSSL_config(NULL);
        SSL_library_init();
        SSL_load_error_strings();
        OpenSSL_add_all_algorithms();
        uwsgi.ssl_initialized = 1;
}
开发者ID:IsCoolEntertainment,项目名称:debpkg_uwsgi,代码行数:7,代码来源:ssl.c


示例9: crypto_init

void crypto_init()
{
    /* Initialise the library */
    ERR_load_crypto_strings();
    OpenSSL_add_all_algorithms();
    OPENSSL_config(NULL);
}
开发者ID:ktneale,项目名称:aes_demo_code,代码行数:7,代码来源:encrypt.c


示例10: aesencrypt

int aesencrypt(unsigned char* plaintext,unsigned char* key,unsigned char* ciphertext){
	
	int ciphertext_len;
	
	//LOGD("LIB plaintext:%s:len=%d\n",plaintext, strlen((char *)plaintext));
	//LOGD("LIB key:%s[0x%x,0x%x,0x%x,0x%x]\n",key,key[0],key[1],key[2],key[3]);
	
	unsigned char iv[32]={0};
	//unsigned char *iv = (unsigned char*)"01234567890123456";
	
	/* Initialise the library */
  ERR_load_crypto_strings();
  OpenSSL_add_all_algorithms();
  OPENSSL_config(NULL);

  /* Encrypt the plaintext */
  ciphertext_len = encrypt(plaintext, strlen((char *)plaintext), key, iv,
    ciphertext);
   
	/* Do something useful with the ciphertext here */
  //printf("Ciphertext is:\n");  
  //BIO_dump_fp(stdout, (char *)ciphertext, ciphertext_len);
  //LOGD("#### %x%x%x%x",ciphertext[0],ciphertext[1],ciphertext[2],ciphertext[3]);

  /* Clean up */
  EVP_cleanup();
  ERR_free_strings();
  
  return ciphertext_len;
}
开发者ID:cloudhi,项目名称:security,代码行数:30,代码来源:aesEncrypt.cpp


示例11: main

int main(int arc, char *argv[])
{ 
	DH *dh = DH_new();

	BN_GENCB *(*cb)(BN_GENCB *, int, int);	
	cb = &callback;

	char buf[400];
	char *bufPtr = &buf[0];

	/* Load the human readable error strings for libcrypto */
	ERR_load_crypto_strings();
	/* Load all digest and cipher algorithms */
	OpenSSL_add_all_algorithms();
	/* Load config file, and other important initialisation */
	OPENSSL_config(NULL);

	/*
		use special PRNG if possible:
			* /dev/random
			* /dev/hwrng
			* ...
	*/

	/*
 		----------------------------	PARAMATER GEN	------------------------
	*/

	printf("start generation\n");
	DH_generate_parameters_ex(dh, 256, 2, NULL);
	printf("paramters DONE\n");

	if(dh->pub_key == NULL)
		printf("pubkey init to NULL\n");

	DH_generate_key(dh);
	printf("key DONE\n");
	bufPtr = BN_bn2hex(dh->p);
	printf ("prime    : %s\n", bufPtr);
	bufPtr = BN_bn2hex(dh->g);
	printf ("generator: %s\n", bufPtr);
	bufPtr = BN_bn2hex(dh->pub_key);
	printf ("pubkey   : %s\n", bufPtr);
	bufPtr = BN_bn2hex(dh->priv_key);
	printf ("privkey  : %s\n", bufPtr);

  /* Clean up */

  /* Removes all digests and ciphers */
  EVP_cleanup();

  /* if you omit the next, a small leak may be left when you make use of the BIO (low level API) for e.g. base64 transformations */
  CRYPTO_cleanup_all_ex_data();

  /* Remove error strings */
  ERR_free_strings();

  return 0;
}
开发者ID:glocklueng,项目名称:knxSec,代码行数:59,代码来源:libcrypto.c


示例12: ERR_load_CRYPTO_strings

		// init
		bool CryptographyEngine::init( void )
		{
			/* Initialise the library */
			ERR_load_CRYPTO_strings();
			OpenSSL_add_all_algorithms();
			OPENSSL_config( NULL );

			return true;
		}
开发者ID:pswin,项目名称:pcore,代码行数:10,代码来源:cryptography_engine.cpp


示例13: message

/* INFO: Setting it up
   
         The code below sets up the program. In this example we are going to
         take a simple message("The quick brown fox jumps over the lazy dog"),
         and then encrypt it using a predefined key and IV. In this example the
         key and IV have been hard coded in - in a real situation you would
         never do this! Following encryption we will then decrypt the resulting
         ciphertext, and(hopefully!) end up with the message we first started
         with. This program expects two functions to be defined: "encrypt" and
         "decrypt". We will define those further down the page. */
int aes_main(void) {
	/* INFO: Set up the key and iv. Do I need to say to not hard code these
	         in a real application? :-) */

	/* INFO: A 256 bit key */
	unsigned char * key =
		(unsigned char *)"01234567890123456789012345678901";

	/* INFO: A 128 bit IV */
	unsigned char * iv =(unsigned char *)"01234567890123456";

	/* INFO: Message to be encrypted */
	unsigned char *plaintext =
		(unsigned char *)"The quick brown fox jumps over the lazy dog";

	/* INFO: Buffer for ciphertext. Ensure the buffer is long enough for
	         the ciphertext which may be longer than the plaintext,
	         dependant on the algorithm and mode */
	unsigned char ciphertext[128];

	/* INFO: Buffer for the decrypted text */
	unsigned char decryptedtext[128];

	int decryptedtext_len, ciphertext_len;

	/* INFO: Initialise the library */
	ERR_load_crypto_strings();
	OpenSSL_add_all_algorithms();
	/* TODO: deprecated. Ude OPENSSL_init_crypto instead of it. */
	OPENSSL_config(NULL);

	/* INFO: Encrypt the plaintext */
	ciphertext_len = encrypt(plaintext, strlen((char *)plaintext), key,
		iv, ciphertext);

	/* INFO: Do something useful with the ciphertext here */
	printf("Ciphertext is:\n");
	BIO_dump_fp(stdout,(const char *)ciphertext, ciphertext_len);

	/* INFO: Decrypt the ciphertext */
	decryptedtext_len = decrypt(ciphertext, ciphertext_len, key, iv,
		decryptedtext);

	/* INFO: Add a NULL terminator. We are expecting printable text */
	decryptedtext[decryptedtext_len] = '\0';

	/* INFO: Show the decrypted text */
	printf("Decrypted text is:\n");
	printf("%s\n", decryptedtext);

	/* INFO: Clean up */
	EVP_cleanup();
	ERR_free_strings();

	return 0;
}
开发者ID:archipelagos,项目名称:openssl,代码行数:66,代码来源:aes.c


示例14: openssl_init

static void openssl_init(void){
    static int init = 0;

    if(!init){
	OPENSSL_config(NULL);
        OpenSSL_add_all_algorithms();
        ERR_load_crypto_strings();
        init = 1;
    }
}
开发者ID:WhitePatches,项目名称:snake-os,代码行数:10,代码来源:opkg_download.c


示例15: ssh_OpenSSL_add_all_algorithms

void
ssh_OpenSSL_add_all_algorithms(void)
{
	OpenSSL_add_all_algorithms();

	/* Enable use of crypto hardware */
	ENGINE_load_builtin_engines();
	ENGINE_register_all_complete();
	OPENSSL_config(NULL);
}
开发者ID:0x0mar,项目名称:backdoored-ssh,代码行数:10,代码来源:openssl-compat.c


示例16: SSL_load_error_strings

const char *dbapi_lookup(const char *key) {
	long res = 1;
	SSL_CTX* ctx = NULL;
	BIO *web = NULL, *out = NULL;
	SSL *ssl = NULL;
	const SSL_METHOD* method;
	char *token, *tmpout, *buf;
	int hlen=0, len=0, maxlen=2048;
	(void)SSL_library_init();
	SSL_load_error_strings();
	OPENSSL_config(NULL);
	method = SSLv23_method(); if(method==NULL) return NULL;
	ctx = SSL_CTX_new(method); if(ctx==NULL) return NULL;
	SSL_CTX_set_verify_depth(ctx, 4);
	SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1|
		SSL_OP_NO_COMPRESSION);
	web = BIO_new_ssl_connect(ctx); if(web==NULL) return NULL;
	res = BIO_set_conn_hostname(web, DB_API_SERVER); if(res!=1) return NULL;
	BIO_get_ssl(web, &ssl); if(ssl==NULL) return NULL;
	res = SSL_set_cipher_list(ssl, SECURE_CIPHER_LIST); if(res!=1) return NULL;
	res = SSL_set_tlsext_host_name(ssl, DB_API_HOST); if(res!=1) return NULL;
	out = BIO_new_fp(stdout, BIO_NOCLOSE); if(NULL==out) return NULL;
	res = BIO_do_connect(web); if(res!=1) return NULL;
	res = BIO_do_handshake(web); if(res!=1) return NULL;
	len=(60+strlen(key)+strlen(DB_API_HOST)+strlen(DB_API_AUTH));
	char *request=malloc(sizeof(char)*(len+1));
	snprintf(request,len,
		"GET %s HTTP/1.1\nHost: %s\nx-api-key: %s\nConnection: close\n\n",
		key, DB_API_HOST, DB_API_AUTH);
	request[len]='\0';
	BIO_puts(web, request);
	BIO_puts(out, "\n");
	buf = malloc(sizeof(char)*maxlen);
	do {
		char buff[1536] = {};
		len=BIO_read(web, buff, sizeof(buff));
		hlen+=len;
		if(hlen<maxlen&&len>0) strncat(buf,buff,len);
	} while (len>0 || BIO_should_retry(web));
	buf[maxlen]='\0';
	tmpout = malloc(sizeof(char)*(HASH_MAXLENGTH+1));
	token = strtok(buf, "\n");
	while (token) {
		snprintf(tmpout,HASH_MAXLENGTH,"%s",token);
		token = strtok(NULL, "\n");
	}
	tmpout[strlen(tmpout)]='\0';
	free(buf);
	free(request);
	if(out) BIO_free(out);
	if(web != NULL) BIO_free_all(web);
	if(NULL != ctx) SSL_CTX_free(ctx);
	return tmpout;
}
开发者ID:CertCenter,项目名称:mod_fauth,代码行数:54,代码来源:mod_fauth.c


示例17: ma_tls_start

/*
  Initializes SSL and allocate global
  context SSL_context

  SYNOPSIS
    my_ssl_start
      mysql        connection handle

  RETURN VALUES
    0  success
    1  error
*/
int ma_tls_start(char *errmsg, size_t errmsg_len)
{
  int rc= 1;
  if (ma_tls_initialized)
    return 0;

  /* lock mutex to prevent multiple initialization */
  pthread_mutex_init(&LOCK_openssl_config,MY_MUTEX_INIT_FAST);
  pthread_mutex_lock(&LOCK_openssl_config);
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
  OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL);
#else
  if (ssl_thread_init())
  {
    strncpy(errmsg, "Not enough memory", errmsg_len);
    goto end;
  }
  SSL_library_init();

#if SSLEAY_VERSION_NUMBER >= 0x00907000L
  OPENSSL_config(NULL);
#endif
#endif
  /* load errors */
  SSL_load_error_strings();
  /* digests and ciphers */
  OpenSSL_add_all_algorithms();
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
  if (!(SSL_context= SSL_CTX_new(TLS_client_method())))
#else
  if (!(SSL_context= SSL_CTX_new(SSLv23_client_method())))
#endif
  {
    ma_tls_get_error(errmsg, errmsg_len);
    goto end;
  }
#ifdef HAVE_TLS_SESSION_CACHE
  SSL_CTX_set_session_cache_mode(SSL_context, SSL_SESS_CACHE_CLIENT);
  ma_tls_sessions= (MA_SSL_SESSION *)calloc(1, sizeof(struct st_ma_tls_session) * ma_tls_session_cache_size);
  SSL_CTX_sess_set_new_cb(SSL_context, ma_tls_session_cb);
  SSL_CTX_sess_set_remove_cb(SSL_context, ma_tls_remove_session_cb);
#endif
  disable_sigpipe();
#if OPENSSL_USE_BIOMETHOD
  memcpy(&ma_BIO_method, BIO_s_socket(), sizeof(BIO_METHOD));
  ma_BIO_method.bread= ma_bio_read;
  ma_BIO_method.bwrite= ma_bio_write;
#endif
  rc= 0;
  ma_tls_initialized= TRUE;
end:
  pthread_mutex_unlock(&LOCK_openssl_config);
  return rc;
}
开发者ID:piaoasd123,项目名称:ServerTest,代码行数:66,代码来源:openssl.c


示例18: sign_init

/**
 * @brief Initialize the signing subsystem
 *
 * @param key_filename The pathname to the private key file
 * @param bad_passphrase Pointer to flag that is set if the failure was
 *        likley due to an incorrect passphrase
 *
 * @returns True on success, false on failure.
 */
bool sign_init(char * key_filename, bool * bad_passphrase) {
    FILE * fp;

    if (bad_passphrase) {
        *bad_passphrase = false;
    }

    if (!crypto_initialized) {

        /* (From: https://wiki.openssl.org/index.php/Libcrypto_API) */
        /* Load the human readable error strings for libcrypto */
        ERR_load_crypto_strings();

        /* Load all digest and cipher algorithms */
        OpenSSL_add_all_algorithms();

        /* Load config file, and other important initialisation */
        OPENSSL_config(NULL);

        crypto_initialized = true;
    }

    /**
     * Load the RSA key object from the private key file
     * (see: http://hayageek.com/rsa-encryption-decryption-openssl-c/#private-encrypt)
     */
    fp = fopen(key_filename,"rb");
    if (fp == NULL) {
        fprintf(stderr, "ERROR: Can't open private key '%s' (err %d)\n",
                key_filename, errno);
        return false;
    }
    rsa = RSA_new();
    if (rsa == NULL) {
        fprintf(stderr, "ERROR: Can't allocate RSA for key '%s': %s\n",
               key_filename, ERR_error_string(ERR_get_error(), NULL));
            return false;
    } else {
        rsa = PEM_read_RSAPrivateKey(fp, &rsa, NULL, passphrase);
        if (rsa == NULL) {
            fprintf(stderr,
                    "ERROR: Can't read private key '%s' (%s)\n", key_filename,
                    ERR_error_string(ERR_get_error(), NULL));
            if (bad_passphrase) {
                *bad_passphrase = true;
            }
            return false;
        }
    }

    return true;
}
开发者ID:JoshKaufman,项目名称:bootrom-tools,代码行数:61,代码来源:sign.c


示例19: encryptAES

struct cipher encryptAES(char *plaintext){
	//unsigned char *key = (unsigned char *)"01234567890123456789012345678901";
	struct cipher c;
	c.length=0;
	/* A 256 bit IV */
	unsigned char *iv = (unsigned char *)"01234567890123456";
	/*
	 Buffer for ciphertext. Ensure the buffer is long enough for the
	* ciphertext which may be longer than the plaintext, dependant on the
	* algorithm and mode
	*/
	unsigned char ciphertext[170];
	//puts(plaintext);
	//char pt[1510];
	
	int decryptedtext_len=0, ciphertext_len=0;
	int numpieces=0;
	/* Initialise the library */
	ERR_load_crypto_strings();
	OpenSSL_add_all_algorithms();
	OPENSSL_config(NULL);
	//int numbytes=sizeof(plaintext);
	
	//char *data[numpieces];
	int i=0;
	int j=0;
	int len=strlen(plaintext);
	numpieces=(len/1500);
	int count=0;
	
	//puts(data);
	/* Encrypt the plaintext */
  		
	ciphertext_len = encrypt (plaintext,strlen ((char *)plaintext), key, iv,ciphertext);
	
	
	//sendMsg(sock,str2);
	//BIO_dump_fp (stdout, (const char *)ciphertext, ciphertext_len);
	
	//int c=1;
	//int d=1;//introducing delay
	//for ( c = 1 ; c <= 32767 ; c++ )
       //{}
	//sendMsg(sock,ciphertext);
	puts("The Encrypted message is");
	puts(ciphertext);
	c.length=ciphertext_len;
	strcpy(c.value,ciphertext);
		
	return c;
//	
}
开发者ID:deepanshululla,项目名称:Network-security,代码行数:52,代码来源:server_mac_then_encrypt.c


示例20: main

int main(int argc, char *argv[])
{

  /* Socket Setup */
  // default socket number
  int socketNumber = 5000;

  // Init the GPIO
  wiringPiSetup();
  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);

  testEncrypt();
  return 1;

  if (argc > 1){
    socketNumber = atoi(argv[1]);
  }

  // Set up socket first
  struct sockaddr_in serv_addr;

  signal(SIGINT, intHandler);

  listenfd = socket(AF_INET, SOCK_STREAM, 0);

  memset(&serv_addr,  '0', sizeof(serv_addr));

  serv_addr.sin_family      = AF_INET;
  serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  serv_addr.sin_port        = htons(socketNumber);

  bind(listenfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr));

  listen(listenfd, 10);
  sessionfd = accept(listenfd, (struct sockaddr*)NULL, NULL);

  /* End of Socket Setup */

  /* OpenSSL setup */
  ERR_load_crypto_strings();
  OpenSSL_add_all_algorithms();
  OPENSSL_config(NULL);

  /* End of OpenSSL setup */

  commandHandler(sessionfd);

  // Destructor for socket
  close(listenfd);
}
开发者ID:jakelongo,项目名称:sca-pi3,代码行数:51,代码来源:socketAES.c



注:本文中的OPENSSL_config函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OPENSSL_free函数代码示例发布时间:2022-05-30
下一篇:
C++ OPENSSL_clear_free函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap