summaryrefslogtreecommitdiff
path: root/lib/libssl/ssl_ciph.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2018-03-17 14:40:46 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2018-03-17 14:40:46 +0000
commit997bec46612fbf334a2325b3e2eef81ac18f1371 (patch)
tree6082296c6e5e08eeb11fadaffca0f1886222c248 /lib/libssl/ssl_ciph.c
parent8c6cbd4ee3f8405bb168df89d8a5995b126971cd (diff)
Provide SSL_CIPHER_get_auth_nid(), SSL_CIPHER_get_cipher_nid(),
SSL_CIPHER_get_digest_nid(), SSL_CIPHER_get_kx_nid() and SSL_CIPHER_is_aead().
Diffstat (limited to 'lib/libssl/ssl_ciph.c')
-rw-r--r--lib/libssl/ssl_ciph.c100
1 files changed, 99 insertions, 1 deletions
diff --git a/lib/libssl/ssl_ciph.c b/lib/libssl/ssl_ciph.c
index f30ffeaf2c6..271d77f38b4 100644
--- a/lib/libssl/ssl_ciph.c
+++ b/lib/libssl/ssl_ciph.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_ciph.c,v 1.97 2017/08/28 16:37:04 jsing Exp $ */
+/* $OpenBSD: ssl_ciph.c,v 1.98 2018/03/17 14:40:45 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -1720,6 +1720,104 @@ SSL_CIPHER_get_value(const SSL_CIPHER *c)
return ssl3_cipher_get_value(c);
}
+int
+SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c)
+{
+ switch (c->algorithm_enc) {
+ case SSL_eNULL:
+ return NID_undef;
+ case SSL_3DES:
+ return NID_des_ede3_cbc;
+ case SSL_AES128:
+ return NID_aes_128_cbc;
+ case SSL_AES128GCM:
+ return NID_aes_128_gcm;
+ case SSL_AES256:
+ return NID_aes_256_cbc;
+ case SSL_AES256GCM:
+ return NID_aes_256_gcm;
+ case SSL_CAMELLIA128:
+ return NID_camellia_128_cbc;
+ case SSL_CAMELLIA256:
+ return NID_camellia_256_cbc;
+ case SSL_CHACHA20POLY1305:
+ return NID_chacha20_poly1305;
+ case SSL_DES:
+ return NID_des_cbc;
+ case SSL_RC4:
+ return NID_rc4;
+ case SSL_eGOST2814789CNT:
+ return NID_gost89_cnt;
+ default:
+ return NID_undef;
+ }
+}
+
+int
+SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c)
+{
+ switch (c->algorithm_mac) {
+ case SSL_AEAD:
+ return NID_undef;
+ case SSL_GOST89MAC:
+ return NID_id_Gost28147_89_MAC;
+ case SSL_GOST94:
+ return NID_id_GostR3411_94;
+ case SSL_MD5:
+ return NID_md5;
+ case SSL_SHA1:
+ return NID_sha1;
+ case SSL_SHA256:
+ return NID_sha256;
+ case SSL_SHA384:
+ return NID_sha384;
+ case SSL_STREEBOG256:
+ return NID_id_tc26_gost3411_2012_256;
+ default:
+ return NID_undef;
+ }
+}
+
+int
+SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c)
+{
+ switch (c->algorithm_mkey) {
+ case SSL_kDHE:
+ return NID_kx_dhe;
+ case SSL_kECDHE:
+ return NID_kx_ecdhe;
+ case SSL_kGOST:
+ return NID_kx_gost;
+ case SSL_kRSA:
+ return NID_kx_rsa;
+ default:
+ return NID_undef;
+ }
+}
+
+int
+SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c)
+{
+ switch (c->algorithm_auth) {
+ case SSL_aNULL:
+ return NID_auth_null;
+ case SSL_aECDSA:
+ return NID_auth_ecdsa;
+ case SSL_aGOST01:
+ return NID_auth_gost01;
+ case SSL_aRSA:
+ return NID_auth_rsa;
+ default:
+ return NID_undef;
+ }
+}
+
+int
+SSL_CIPHER_is_aead(const SSL_CIPHER *c)
+{
+ return (c->algorithm_mac & SSL_AEAD) == SSL_AEAD;
+}
+
void *
SSL_COMP_get_compression_methods(void)
{