27#include <openssl/ssl.h> 
   33        { 
L(
"DH"),      EVP_PKEY_DH     },
 
   34        { 
L(
"DSA"),     EVP_PKEY_DSA    },
 
   35        { 
L(
"EC"),      EVP_PKEY_EC     },
 
   36        { 
L(
"RSA"),     EVP_PKEY_RSA    }
 
 
   51        if (!cert) 
return NULL;
 
   53        pkey = X509_get_pubkey(cert);
 
   54        if (!pkey) 
return NULL;
 
   56        pkey_type = EVP_PKEY_type(EVP_PKEY_id(pkey));
 
 
   84        const SSL_CIPHER *ssl_cipher;
 
   87        ssl_cipher = SSL_get_current_cipher(ssl);
 
   90        cipher = SSL_CIPHER_get_cipher_nid(ssl_cipher);
 
   91        digest = SSL_CIPHER_get_digest_nid(ssl_cipher);
 
   92        RDEBUG2(
"OpenSSL: cipher nid %d digest nid %d", cipher, digest);
 
   93        if (cipher < 0 || digest < 0)
 
   95        c = EVP_get_cipherbynid(cipher);
 
   96        h = EVP_get_digestbynid(digest);
 
  100        RDEBUG2(
"OpenSSL: keyblock size: key_len=%d MD_size=%d IV_len=%d",
 
  101                   EVP_CIPHER_key_length(c), EVP_MD_size(h),
 
  102                   EVP_CIPHER_iv_length(c));
 
  103        return 2 * (EVP_CIPHER_key_length(c) + EVP_MD_size(h) +
 
  104                    EVP_CIPHER_iv_length(c));
 
 
  118        char const      *p = (
char const *)asn1->data, *end = p + strlen(p);
 
  120        memset(&t, 0, 
sizeof(t));
 
  122        if (asn1->type == V_ASN1_UTCTIME) {
 
  124                        fr_strerror_printf(
"ASN1 date string too short, expected 2 additional bytes, got %zu bytes",
 
  129                t.tm_year = (*(p++) - 
'0') * 10;
 
  130                t.tm_year += (*(p++) - 
'0');
 
  131                if (t.tm_year < 70) t.tm_year += 100;
 
  132        } 
else if (asn1->type == V_ASN1_GENERALIZEDTIME) {
 
  134                        fr_strerror_printf(
"ASN1 string too short, expected 4 additional bytes, got %zu bytes",
 
  139                t.tm_year = (*(p++) - 
'0') * 1000;
 
  140                t.tm_year += (*(p++) - 
'0') * 100;
 
  141                t.tm_year += (*(p++) - 
'0') * 10;
 
  142                t.tm_year += (*(p++) - 
'0');
 
  147                fr_strerror_printf(
"ASN1 string too short, expected 10 additional bytes, got %zu bytes",
 
  152        t.tm_mon = (*(p++) - 
'0') * 10;
 
  153        t.tm_mon += (*(p++) - 
'0') - 1; 
 
  154        t.tm_mday = (*(p++) - 
'0') * 10;
 
  155        t.tm_mday += (*(p++) - 
'0');
 
  157        if ((end - p) < 2) 
goto done;
 
  158        t.tm_hour = (*(p++) - 
'0') * 10;
 
  159        t.tm_hour += (*(p++) - 
'0');
 
  161        if ((end - p) < 2) 
goto done;
 
  162        t.tm_min = (*(p++) - 
'0') * 10;
 
  163        t.tm_min += (*(p++) - 
'0');
 
  165        if ((end - p) < 2) 
goto done;
 
  166        t.tm_sec = (*(p++) - 
'0') * 10;
 
  167        t.tm_sec += (*(p++) - 
'0');
 
 
  196                ERROR(
"Private key encrypted but no private_key_password configured");
 
  200        pass = talloc_get_type_abort(u, 
char);
 
  201        len = talloc_array_length(pass);        
 
  202        if (len > (
size_t)size) {
 
  203                ERROR(
"Password too long.  Maximum length is %i bytes", size - 1);
 
  206        memcpy(buf, pass, len);                 
 
 
#define L(_str)
Helper for initialising arrays of string literals.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
An element in a lexicographically sorted array of name to num mappings.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
int fr_utils_get_private_key_password(char *buf, int size, UNUSED int rwflag, void *u)
Return the static private key password we have configured.
char const * fr_tls_utils_x509_pkey_type(X509 *cert)
Returns a friendly identifier for the public key type of a certificate.
int fr_tls_utils_asn1time_to_epoch(time_t *out, ASN1_TIME const *asn1)
Convert OpenSSL's ASN1_TIME to an epoch time.
int fr_tls_utils_keyblock_size_get(request_t *request, SSL *ssl)
Returns the OpenSSL keyblock size.
static size_t pkey_types_len
static fr_table_num_sorted_t const pkey_types[]
PKEY types (friendly names)
static size_t char ** out