本文整理汇总了C++中SSL_get_current_cipher函数的典型用法代码示例。如果您正苦于以下问题:C++ SSL_get_current_cipher函数的具体用法?C++ SSL_get_current_cipher怎么用?C++ SSL_get_current_cipher使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SSL_get_current_cipher函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_desc
static int get_desc(str* res, sip_msg_t* msg)
{
static char buf[128];
struct tcp_connection* c;
SSL* ssl;
c = get_cur_connection(msg);
if (!c) {
INFO("TLS connection not found in select_desc\n");
goto err;
}
ssl = get_ssl(c);
if (!ssl) goto err;
buf[0] = '\0';
SSL_CIPHER_description(SSL_get_current_cipher(ssl), buf, 128);
res->s = buf;
res->len = strlen(buf);
tcpconn_put(c);
return 0;
err:
if (c) tcpconn_put(c);
return -1;
}
示例2: openssl_iostream_get_security_string
static const char *
openssl_iostream_get_security_string(struct ssl_iostream *ssl_io)
{
const SSL_CIPHER *cipher;
#ifdef HAVE_SSL_COMPRESSION
const COMP_METHOD *comp;
#endif
const char *comp_str;
int bits, alg_bits;
if (!ssl_io->handshaked)
return "";
cipher = SSL_get_current_cipher(ssl_io->ssl);
bits = SSL_CIPHER_get_bits(cipher, &alg_bits);
#ifdef HAVE_SSL_COMPRESSION
comp = SSL_get_current_compression(ssl_io->ssl);
comp_str = comp == NULL ? "" :
t_strconcat(" ", SSL_COMP_get_name(comp), NULL);
#else
comp_str = "";
#endif
return t_strdup_printf("%s with cipher %s (%d/%d bits)%s",
SSL_get_version(ssl_io->ssl),
SSL_CIPHER_get_name(cipher),
bits, alg_bits, comp_str);
}
示例3: tlsops_cipher
int tlsops_cipher(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
str cipher;
static char buf[1024];
struct tcp_connection* c;
SSL* ssl;
c = get_cur_connection(msg);
if (!c) {
LM_INFO("TLS connection not found in select_cipher\n");
goto err;
}
ssl = get_ssl(c);
if (!ssl) goto err;
cipher.s = (char*)SSL_CIPHER_get_name(SSL_get_current_cipher(ssl));
cipher.len = cipher.s ? strlen(cipher.s) : 0;
if (cipher.len >= 1024) {
LM_ERR("cipher name too long\n");
goto err;
}
memcpy(buf, cipher.s, cipher.len);
res->rs.s = buf;
res->rs.len = cipher.len;
res->flags = PV_VAL_STR;
tcpconn_put(c);
return 0;
err:
if (c) tcpconn_put(c);
return pv_get_null(msg, param, res);
}
示例4: DTLS_get_data_mtu
size_t DTLS_get_data_mtu(const SSL *s)
{
size_t mac_overhead, int_overhead, blocksize, ext_overhead;
const SSL_CIPHER *ciph = SSL_get_current_cipher(s);
size_t mtu = s->d1->mtu;
if (ciph == NULL)
return 0;
if (!ssl_cipher_get_overhead(ciph, &mac_overhead, &int_overhead,
&blocksize, &ext_overhead))
return 0;
if (SSL_USE_ETM(s))
ext_overhead += mac_overhead;
else
int_overhead += mac_overhead;
/* Subtract external overhead (e.g. IV/nonce, separate MAC) */
if (ext_overhead + DTLS1_RT_HEADER_LENGTH >= mtu)
return 0;
mtu -= ext_overhead + DTLS1_RT_HEADER_LENGTH;
/* Round encrypted payload down to cipher block size (for CBC etc.)
* No check for overflow since 'mtu % blocksize' cannot exceed mtu. */
if (blocksize)
mtu -= (mtu % blocksize);
/* Subtract internal overhead (e.g. CBC padding len byte) */
if (int_overhead >= mtu)
return 0;
mtu -= int_overhead;
return mtu;
}
示例5: tlsops_desc
int tlsops_desc(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
static char buf[128];
struct tcp_connection* c;
SSL* ssl;
c = get_cur_connection(msg);
if (!c) {
LM_INFO("TLS connection not found in select_desc\n");
goto err;
}
ssl = get_ssl(c);
if (!ssl) goto err;
buf[0] = '\0';
SSL_CIPHER_description(SSL_get_current_cipher(ssl), buf, 128);
res->rs.s = buf;
res->rs.len = strlen(buf);
res->flags = PV_VAL_STR;
tcpconn_put(c);
return 0;
err:
if (c) tcpconn_put(c);
return pv_get_null(msg, param, res);
}
示例6: get_cipher
static int get_cipher(str* res, sip_msg_t* msg)
{
str cipher;
static char buf[1024];
struct tcp_connection* c;
SSL* ssl;
c = get_cur_connection(msg);
if (!c) {
INFO("TLS connection not found in select_cipher\n");
goto err;
}
ssl = get_ssl(c);
if (!ssl) goto err;
cipher.s = (char*)SSL_CIPHER_get_name(SSL_get_current_cipher(ssl));
cipher.len = cipher.s ? strlen(cipher.s) : 0;
if (cipher.len >= 1024) {
ERR("Cipher name too long\n");
goto err;
}
memcpy(buf, cipher.s, cipher.len);
res->s = buf;
res->len = cipher.len;
tcpconn_put(c);
return 0;
err:
if (c) tcpconn_put(c);
return -1;
}
示例7: get_bits
static int get_bits(str* res, int* i, sip_msg_t* msg)
{
str bits;
int b;
static char buf[1024];
struct tcp_connection* c;
SSL* ssl;
c = get_cur_connection(msg);
if (!c) {
INFO("TLS connection not found in select_bits\n");
goto err;
}
ssl = get_ssl(c);
if (!ssl) goto err;
b = SSL_CIPHER_get_bits(SSL_get_current_cipher(ssl), 0);
bits.s = int2str(b, &bits.len);
if (bits.len >= 1024) {
ERR("Bits string too long\n");
goto err;
}
memcpy(buf, bits.s, bits.len);
res->s = buf;
res->len = bits.len;
if (i) *i = b;
tcpconn_put(c);
return 0;
err:
if (c) tcpconn_put(c);
return -1;
}
示例8: ssl_socket_open
static int ssl_socket_open (CONNECTION * conn)
{
sslsockdata *data;
int maxbits;
if (raw_socket_open (conn) < 0)
return -1;
data = (sslsockdata *) safe_calloc (1, sizeof (sslsockdata));
conn->sockdata = data;
data->ctx = SSL_CTX_new (SSLv23_client_method ());
/* disable SSL protocols as needed */
if (!option(OPTTLSV1))
{
SSL_CTX_set_options(data->ctx, SSL_OP_NO_TLSv1);
}
/* TLSv1.1/1.2 support was added in OpenSSL 1.0.1, but some OS distros such
* as Fedora 17 are on OpenSSL 1.0.0.
*/
#ifdef SSL_OP_NO_TLSv1_1
if (!option(OPTTLSV1_1))
{
SSL_CTX_set_options(data->ctx, SSL_OP_NO_TLSv1_1);
}
#endif
#ifdef SSL_OP_NO_TLSv1_2
if (!option(OPTTLSV1_2))
{
SSL_CTX_set_options(data->ctx, SSL_OP_NO_TLSv1_2);
}
#endif
if (!option(OPTSSLV2))
{
SSL_CTX_set_options(data->ctx, SSL_OP_NO_SSLv2);
}
if (!option(OPTSSLV3))
{
SSL_CTX_set_options(data->ctx, SSL_OP_NO_SSLv3);
}
ssl_get_client_cert(data, conn);
data->ssl = SSL_new (data->ctx);
SSL_set_fd (data->ssl, conn->fd);
if (ssl_negotiate(conn, data))
{
mutt_socket_close (conn);
return -1;
}
data->isopen = 1;
conn->ssf = SSL_CIPHER_get_bits (SSL_get_current_cipher (data->ssl),
&maxbits);
return 0;
}
示例9: ConnSSL_GetCipherInfo
bool
ConnSSL_GetCipherInfo(CONNECTION *c, char *buf, size_t len)
{
#ifdef HAVE_LIBSSL
char *nl;
SSL *ssl = c->ssl_state.ssl;
if (!ssl)
return false;
*buf = 0;
SSL_CIPHER_description(SSL_get_current_cipher(ssl), buf, len);
nl = strchr(buf, '\n');
if (nl)
*nl = 0;
return true;
#endif
#ifdef HAVE_LIBGNUTLS
if (Conn_OPTION_ISSET(c, CONN_SSL)) {
const char *name_cipher, *name_mac, *name_proto, *name_keyexchange;
unsigned keysize;
gnutls_session_t sess = c->ssl_state.gnutls_session;
gnutls_cipher_algorithm_t cipher = gnutls_cipher_get(sess);
name_cipher = gnutls_cipher_get_name(cipher);
name_mac = gnutls_mac_get_name(gnutls_mac_get(sess));
keysize = gnutls_cipher_get_key_size(cipher) * 8;
name_proto = gnutls_protocol_get_name(gnutls_protocol_get_version(sess));
name_keyexchange = gnutls_kx_get_name(gnutls_kx_get(sess));
return snprintf(buf, len, "%s-%s%15s Kx=%s Enc=%s(%u) Mac=%s",
name_cipher, name_mac, name_proto, name_keyexchange, name_cipher, keysize, name_mac) > 0;
}
return false;
#endif
}
示例10: print_ciphersuite_data
static void print_ciphersuite_data(BIO *io, SSL *ssl, int js)
{
SSL_SESSION* session = SSL_get_session(ssl);
long protocol = SSL_version(ssl);
const char *protocol_name = get_protocol_name(protocol);
const char *eol = js ? "\\n\\\n" : "\n";
if(BIO_printf(io, "Version: 0x%lx %s%s", protocol, protocol_name, eol) <= 0)
err_exit("Write error");
if(BIO_printf(io, "Current cipher: %s%s", SSL_CIPHER_get_name(SSL_get_current_cipher(ssl)), eol) <= 0)
err_exit("Write error");
STACK_OF(SSL_CIPHER) *ciphers = session->ciphers;
SSL_CIPHER *c;
int n = sk_SSL_CIPHER_num(ciphers);
if(BIO_printf(io, "client sent %d ciphers%s", n, eol) <= 0)
err_exit("Write error");
int i;
for (i = 0; i < n; i++)
{
c = sk_SSL_CIPHER_value(ciphers, i);
if(BIO_printf(io, "client [%2d of %2d]: %s%s", i, n, SSL_CIPHER_get_name(c), eol) <= 0)
err_exit("Write error");
}
}
示例11: openssl_ssl_current_cipher
static int openssl_ssl_current_cipher(lua_State *L)
{
SSL* s = CHECK_OBJECT(1, SSL, "openssl.ssl");
const SSL_CIPHER* c = SSL_get_current_cipher(s);
if (c)
{
int bits, algbits;
char err[LUAL_BUFFERSIZE] = {0};;
lua_newtable(L);
AUXILIAR_SET(L, -1, "name", SSL_CIPHER_get_name(c), string);
AUXILIAR_SET(L, -1, "version", SSL_CIPHER_get_version(c), string);
#if OPENSSL_VERSION_NUMBER > 0x10000000L
AUXILIAR_SET(L, -1, "id", SSL_CIPHER_get_id(c), integer);
#endif
bits = SSL_CIPHER_get_bits(c, &algbits);
AUXILIAR_SET(L, -1, "bits", bits, integer);
AUXILIAR_SET(L, -1, "algbits", algbits, integer);
AUXILIAR_SET(L, -1, "description", SSL_CIPHER_description((SSL_CIPHER*)c, err, sizeof(err)), string);
return 1;
}
return 0;
}
示例12: tlso_session_strength
static int
tlso_session_strength( tls_session *sess )
{
tlso_session *s = (tlso_session *)sess;
return SSL_CIPHER_get_bits(SSL_get_current_cipher(s), NULL);
}
示例13:
const char *OpenSSLQueryCipher(STREAM *S)
{
void *ptr;
if (! S) return(NULL);
ptr=STREAMGetItem(S,"LIBUSEFUL-SSL-CTX");
if (! ptr) return(NULL);
#ifdef HAVE_LIBSSL
const SSL_CIPHER *Cipher;
char *Tempstr=NULL;
Cipher=SSL_get_current_cipher((const SSL *) ptr);
if (Cipher)
{
Tempstr=FormatStr(Tempstr,"%d bit %s",SSL_CIPHER_get_bits(Cipher,NULL), SSL_CIPHER_get_name(Cipher));
STREAMSetValue(S,"SSL-Cipher",Tempstr);
Tempstr=SetStrLen(Tempstr,1024);
Tempstr=SSL_CIPHER_description(Cipher, Tempstr, 1024);
STREAMSetValue(S,"SSL-Cipher-Details",Tempstr);
}
DestroyString(Tempstr);
return(STREAMGetValue(S,"SSL-Cipher"));
#else
return(NULL);
#endif
}
示例14: pn_ssl_get_ssf
int pn_ssl_get_ssf(pn_ssl_t *ssl0)
{
const SSL_CIPHER *c;
pni_ssl_t *ssl = get_ssl_internal(ssl0);
if (ssl && ssl->ssl && (c = SSL_get_current_cipher( ssl->ssl ))) {
return SSL_CIPHER_get_bits(c, NULL);
}
return 0;
}
示例15: set_cipher_info
static void set_cipher_info(TLS_REC *tls, SSL *ssl)
{
g_return_if_fail(tls != NULL);
g_return_if_fail(ssl != NULL);
tls_rec_set_protocol_version(tls, SSL_get_version(ssl));
tls_rec_set_cipher(tls, SSL_CIPHER_get_name(SSL_get_current_cipher(ssl)));
tls_rec_set_cipher_size(tls, SSL_get_cipher_bits(ssl, NULL));
}