The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Functions | Variables
utils.c File Reference

TLS utility functions. More...

#include "utils.h"
#include <openssl/ssl.h>
+ Include dependency graph for utils.c:

Go to the source code of this file.

Functions

int fr_tls_utils_asn1time_to_epoch (time_t *out, ASN1_TIME const *asn1)
 Convert OpenSSL's ASN1_TIME to an epoch time. More...
 
int fr_tls_utils_keyblock_size_get (request_t *request, SSL *ssl)
 Returns the OpenSSL keyblock size. More...
 
char const * fr_tls_utils_x509_pkey_type (X509 *cert)
 Returns a friendly identifier for the public key type of a certificate. More...
 
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. More...
 

Variables

static fr_table_num_sorted_t const pkey_types []
 PKEY types (friendly names) More...
 
static size_t pkey_types_len = NUM_ELEMENTS(pkey_types)
 

Detailed Description

TLS utility functions.

Id
2b3eebd4e0bbeb0f2a97b9b4e9976accc6d9dd64

Definition in file utils.c.

Function Documentation

◆ fr_tls_utils_asn1time_to_epoch()

int fr_tls_utils_asn1time_to_epoch ( time_t *  out,
ASN1_TIME const *  asn1 
)

Convert OpenSSL's ASN1_TIME to an epoch time.

Parameters
[out]outWhere to write the time_t.
[in]asn1The ASN1_TIME to convert.
Returns
  • 0 success.
  • -1 on failure.

Definition at line 115 of file utils.c.

◆ fr_tls_utils_keyblock_size_get()

int fr_tls_utils_keyblock_size_get ( request_t request,
SSL *  ssl 
)

Returns the OpenSSL keyblock size.

These programs are licensed under the BSD license (the one with advertisement clause removed).

this function shamelessly stolen from from hostap:src/crypto/tls_openssl.c:openssl_get_keyblock_size()

Parameters
[in]requestThe current request.
[in]sslThe current SSL session.
Returns
  • -1 problem with the session.
  • >=0 length of the block.

Definition at line 80 of file utils.c.

+ Here is the caller graph for this function:

◆ fr_tls_utils_x509_pkey_type()

char const* fr_tls_utils_x509_pkey_type ( X509 *  cert)

Returns a friendly identifier for the public key type of a certificate.

Parameters
[in]certThe X509 cert to return the type of.
Returns
the type string.

Definition at line 45 of file utils.c.

◆ fr_utils_get_private_key_password()

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.

Note
This is used as a callback to OpenSSL's PEM_read_PrivateKey function.
Parameters
[out]bufWhere to write the password to.
[in]sizeThe length of buf.
[in]rwflag
  • 0 if password used for decryption.
  • 1 if password used for encryption.
[in]uThe static password.
Returns
  • 0 on error.
  • >0 on success (the length of the password).

Definition at line 190 of file utils.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ pkey_types

fr_table_num_sorted_t const pkey_types[]
static
Initial value:
= {
{ L("DH"), EVP_PKEY_DH },
{ L("DSA"), EVP_PKEY_DSA },
{ L("EC"), EVP_PKEY_EC },
{ L("RSA"), EVP_PKEY_RSA }
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition: build.h:207

PKEY types (friendly names)

Definition at line 32 of file utils.c.

◆ pkey_types_len

size_t pkey_types_len = NUM_ELEMENTS(pkey_types)
static

Definition at line 38 of file utils.c.