}
int
-rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile)
+rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile, const char *cipher_list)
{
int ret;
gnutls_datum_t *d_cert, *d_key;
else
rb_lib_log("rb_setup_ssl_server: Unable to setup DH parameters");
}
+
+ /* XXX integrate gnutls_priority_init() */
return 1;
}
{
int result;
- result = rb_listen(F->fd, backlog, defer_accept);
+ result = rb_listen(F, backlog, defer_accept);
F->type = RB_FD_SOCKET | RB_FD_LISTEN | RB_FD_SSL;
return result;
{
#if GNUTLS_VERSION_MAJOR < 3
gcry_fast_random_poll();
+#else
+ gnutls_rnd_refresh();
#endif
return 1;
}
return 1;
}
-int
-rb_get_pseudo_random(void *buf, size_t length)
-{
-#if GNUTLS_VERSION_MAJOR < 3
- gcry_randomize(buf, length, GCRY_WEAK_RANDOM);
-#else
- gnutls_rnd(GNUTLS_RND_RANDOM, buf, length);
-#endif
- return 1;
-}
-
const char *
rb_get_ssl_strerror(rb_fde_t *F)
{
}
int
-rb_get_ssl_certfp(rb_fde_t *F, uint8_t certfp[RB_SSL_CERTFP_LEN])
+rb_get_ssl_certfp(rb_fde_t *F, uint8_t certfp[RB_SSL_CERTFP_LEN], int method)
{
gnutls_x509_crt_t cert;
+ gnutls_digest_algorithm_t algo;
unsigned int cert_list_size;
const gnutls_datum_t *cert_list;
uint8_t digest[RB_SSL_CERTFP_LEN * 2];
size_t digest_size;
+ int len;
if (gnutls_certificate_type_get(SSL_P(F)) != GNUTLS_CRT_X509)
return 0;
return 0;
}
- if (gnutls_x509_crt_get_fingerprint(cert, GNUTLS_DIG_SHA1, digest, &digest_size) < 0)
+ switch(method)
+ {
+ case RB_SSL_CERTFP_METH_SHA1:
+ algo = GNUTLS_DIG_SHA1;
+ len = RB_SSL_CERTFP_LEN_SHA1;
+ break;
+ case RB_SSL_CERTFP_METH_SHA256:
+ algo = GNUTLS_DIG_SHA256;
+ len = RB_SSL_CERTFP_LEN_SHA256;
+ break;
+ case RB_SSL_CERTFP_METH_SHA512:
+ algo = GNUTLS_DIG_SHA512;
+ len = RB_SSL_CERTFP_LEN_SHA512;
+ break;
+ default:
+ return 0;
+ }
+
+ if (gnutls_x509_crt_get_fingerprint(cert, algo, digest, &digest_size) < 0)
{
gnutls_x509_crt_deinit(cert);
return 0;
}
- memcpy(certfp, digest, RB_SSL_CERTFP_LEN);
+ memcpy(certfp, digest, len);
gnutls_x509_crt_deinit(cert);
- return 1;
+ return len;
}
int
LIBGNUTLS_VERSION, gnutls_check_version(NULL));
}
+const char *
+rb_ssl_get_cipher(rb_fde_t *F)
+{
+ static char buf[1024];
+
+ rb_snprintf(buf, sizeof(buf), "%s-%s-%s-%s",
+ gnutls_protocol_get_name(gnutls_protocol_get_version(SSL_P(F))),
+ gnutls_kx_get_name(gnutls_kx_get(SSL_P(F))),
+ gnutls_cipher_get_name(gnutls_cipher_get(SSL_P(F))),
+ gnutls_mac_get_name(gnutls_mac_get(SSL_P(F))));
+
+ return buf;
+}
#endif /* HAVE_GNUTLS */