The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Creates dynamic expansions for encrypting/decrypting data. More...
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/tls/base.h>
#include <freeradius-devel/tls/cert.h>
#include <freeradius-devel/tls/log.h>
#include <freeradius-devel/tls/utils.h>
#include <freeradius-devel/tls/strerror.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <freeradius-devel/unlang/xlat.h>
#include <freeradius-devel/tls/openssl_user_macros.h>
#include <openssl/crypto.h>
#include <openssl/pem.h>
#include <openssl/evp.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>
Go to the source code of this file.
Data Structures | |
struct | cipher_rsa_oaep_t |
Configuration for the OAEP padding method. More... | |
struct | cipher_rsa_t |
Configuration for RSA encryption/decryption/signing. More... | |
struct | rlm_cipher_rsa_thread_inst_t |
struct | rlm_cipher_t |
Instance configuration. More... | |
union | rlm_cipher_t.__unnamed157__ |
Supported cipher types. More... | |
Enumerations | |
enum | cipher_cert_attributes_t { CIPHER_CERT_ATTR_UNKNOWN = 0 , CIPHER_CERT_ATTR_SERIAL , CIPHER_CERT_ATTR_FINGERPRINT , CIPHER_CERT_ATTR_NOT_BEFORE , CIPHER_CERT_ATTR_NOT_AFTER } |
enum | cipher_cert_verify_mode_t { CIPHER_CERT_VERIFY_INVALID = 0 , CIPHER_CERT_VERIFY_HARD , CIPHER_CERT_VERIFY_SOFT , CIPHER_CERT_VERIFY_NONE } |
Certificate validation modes. More... | |
enum | cipher_type_t { RLM_CIPHER_TYPE_INVALID = 0 , RLM_CIPHER_TYPE_RSA = 1 , RLM_CIPHER_TYPE_SYMMETRIC = 2 } |
Functions | |
static int | _evp_md_ctx_free (EVP_MD_CTX *evp_md_ctx) |
Talloc destructor for freeing an EVP_MD_CTX. More... | |
static int | _evp_pkey_ctx_free (EVP_PKEY_CTX *evp_pkey_ctx) |
Talloc destructor for freeing an EVP_PKEY_CTX. More... | |
static int | _evp_pkey_free (EVP_PKEY *pkey) |
Talloc destructor for freeing an EVP_PKEY (representing a certificate) More... | |
static int | _x509_cert_free (X509 *cert) |
Talloc destructor for freeing an X509 struct (representing a public certificate) More... | |
static xlat_action_t | cipher_certificate_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
static xlat_action_t | cipher_fingerprint_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
Return the fingerprint of the public certificate. More... | |
static int | cipher_rsa_certificate_file_load (TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
static int | cipher_rsa_certificate_file_load (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
Load an RSA public key using OpenSSL functions. More... | |
static xlat_action_t | cipher_rsa_decrypt_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
Decrypt input data. More... | |
static xlat_action_t | cipher_rsa_encrypt_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
Encrypt input data. More... | |
static int | cipher_rsa_padding_params_set (EVP_PKEY_CTX *evp_pkey_ctx, cipher_rsa_t const *rsa_inst) |
static int | cipher_rsa_padding_type_parse (UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
Checks if the specified padding type is valid. More... | |
static int | cipher_rsa_private_key_file_load (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
Load and (optionally decrypt) an RSA private key using OpenSSL functions. More... | |
static int | cipher_rsa_private_key_file_load (UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
static xlat_action_t | cipher_rsa_sign_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
Sign input data. More... | |
static int | cipher_rsa_thread_instantiate (module_thread_inst_ctx_t const *mctx) |
Pre-initialises the EVP_PKEY_CTX necessary for performing RSA encryption/decryption/sign/verify. More... | |
static xlat_action_t | cipher_rsa_verify_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
Verify input data. More... | |
static xlat_action_t | cipher_serial_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in) |
Return the serial of the public certificate. More... | |
static int | cipher_type_parse (UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
Checks if the specified cipher type is valid. More... | |
static int | digest_type_parse (UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
Calls EVP_get_digestbyname() to convert the digest type. More... | |
static int | mod_bootstrap (module_inst_ctx_t const *mctx) |
static int | mod_thread_instantiate (module_thread_inst_ctx_t const *mctx) |
Creates dynamic expansions for encrypting/decrypting data.
Definition in file rlm_cipher.c.
struct cipher_rsa_oaep_t |
Configuration for the OAEP padding method.
Definition at line 146 of file rlm_cipher.c.
Data Fields | ||
---|---|---|
char const * | label | Additional input to the hashing function. |
EVP_MD * | mgf1_digest | Masking function digest. |
EVP_MD * | oaep_digest | Padding digest type. |
struct cipher_rsa_t |
Configuration for RSA encryption/decryption/signing.
Definition at line 158 of file rlm_cipher.c.
Data Fields | ||
---|---|---|
EVP_PKEY * | certificate_file | Public (certificate) file. |
fr_unix_time_t | not_after | Certificate isn't valid after this time. |
fr_unix_time_t | not_before | Certificate isn't valid before this time. |
cipher_rsa_oaep_t * | oaep | OAEP can use a configurable message digest type. |
int | padding | Type of padding to apply to the plaintext or ciphertext before feeding it to RSA crypto functions. |
EVP_PKEY * | private_key_file | Private key file. |
char const * | private_key_password | Password to decrypt the private key. |
char const * | random_file | If set, we read 10K of data (or the complete file) and use it to seed OpenSSL's PRNG. |
EVP_MD * | sig_digest | Signature digest type. |
cipher_cert_verify_mode_t | verify_mode | How hard we try to verify the certificate. |
X509 * | x509_certificate_file | Needed for extracting certificate attributes. |
struct rlm_cipher_rsa_thread_inst_t |
Definition at line 133 of file rlm_cipher.c.
Data Fields | ||
---|---|---|
uint8_t * | digest_buff | Pre-allocated digest buffer. |
EVP_PKEY_CTX * | evp_decrypt_ctx | Pre-allocated evp_pkey_ctx. |
EVP_PKEY_CTX * | evp_encrypt_ctx | Pre-allocated evp_pkey_ctx. |
EVP_MD_CTX * | evp_md_ctx | Pre-allocated evp_md_ctx for sign and verify. |
EVP_PKEY_CTX * | evp_sign_ctx | Pre-allocated evp_pkey_ctx. |
EVP_PKEY_CTX * | evp_verify_ctx | Pre-allocated evp_pkey_ctx. |
struct rlm_cipher_t |
Instance configuration.
Definition at line 183 of file rlm_cipher.c.
Data Fields | ||
---|---|---|
union rlm_cipher_t | __unnamed__ | Supported cipher types. |
cipher_type_t | type | Type of encryption to use. |
union rlm_cipher_t.__unnamed157__ |
Supported cipher types.
Definition at line 189 of file rlm_cipher.c.
Data Fields | ||
---|---|---|
cipher_rsa_t * | rsa | Use RSA encryption (with optional padding). |
Definition at line 79 of file rlm_cipher.c.
Certificate validation modes.
Definition at line 70 of file rlm_cipher.c.
enum cipher_type_t |
Enumerator | |
---|---|
RLM_CIPHER_TYPE_INVALID | |
RLM_CIPHER_TYPE_RSA | |
RLM_CIPHER_TYPE_SYMMETRIC | Any symmetric cipher available via OpenSSL's EVP interface. |
Definition at line 60 of file rlm_cipher.c.
|
static |
Talloc destructor for freeing an EVP_MD_CTX.
[in] | evp_md_ctx | to free. |
Definition at line 988 of file rlm_cipher.c.
|
static |
Talloc destructor for freeing an EVP_PKEY_CTX.
[in] | evp_pkey_ctx | to free. |
Definition at line 976 of file rlm_cipher.c.
|
static |
Talloc destructor for freeing an EVP_PKEY (representing a certificate)
[in] | pkey | to free. |
Definition at line 338 of file rlm_cipher.c.
|
static |
Talloc destructor for freeing an X509 struct (representing a public certificate)
[in] | cert | to free. |
Definition at line 350 of file rlm_cipher.c.
|
static |
Definition at line 936 of file rlm_cipher.c.
|
static |
|
static |
Load an RSA public key using OpenSSL functions.
[in] | ctx | UNUSED. Although the EVP_PKEY struct will be allocated with talloc, we need to call the specialised free function anyway. |
[out] | out | Where to write the EVP_PKEY * representing the certificate we just loaded. |
[in] | parent | Base structure address. |
[in] | ci | Config item containing the certificate path. |
[in] | rule | this callback was attached to. |
Definition at line 430 of file rlm_cipher.c.
|
static |
Definition at line 995 of file rlm_cipher.c.
|
static |
Checks if the specified padding type is valid.
[in] | ctx | to allocate data in. |
[out] | out | Padding type. |
[in] | parent | Base structure address. |
[in] | ci | CONF_PAIR specifying the padding type.. |
[in] | rule | unused. |
Definition at line 282 of file rlm_cipher.c.
|
static |
Load and (optionally decrypt) an RSA private key using OpenSSL functions.
[in] | ctx | UNUSED. Although the EVP_PKEY struct will be allocated with talloc, we need to call the specialised free function anyway. |
[out] | out | Where to write the EVP_PKEY * representing the certificate we just loaded. |
[in] | parent | Base structure address. |
[in] | ci | Config item containing the certificate path. |
[in] | rule | this callback was attached to. |
Definition at line 371 of file rlm_cipher.c.
|
static |
|
static |
Pre-initialises the EVP_PKEY_CTX necessary for performing RSA encryption/decryption/sign/verify.
If reference counting is used for EVP_PKEY structs, should also prevent any mutex contention associated with incrementing/decrementing those references.
xlat functions MUST NOT interleave PKEY operations with yields
Definition at line 1061 of file rlm_cipher.c.
|
static |
Checks if the specified cipher type is valid.
[in] | ctx | to allocate data in. |
[out] | out | Cipher enumeration type. |
[in] | parent | Base structure address. |
[in] | ci | CONF_PAIR specifying the name of the type module. |
[in] | rule | unused. |
Definition at line 311 of file rlm_cipher.c.
|
static |
Calls EVP_get_digestbyname() to convert the digest type.
[in] | ctx | to allocate data in. |
[out] | out | EVP_MD representing the OpenSSL digest type. |
[in] | parent | Base structure address. |
[in] | ci | CONF_PAIR specifying the name of the digest. |
[in] | rule | unused. |
Definition at line 253 of file rlm_cipher.c.
|
static |
|
static |
|
static |
Public key types.
Definition at line 125 of file rlm_cipher.c.
|
static |
Definition at line 131 of file rlm_cipher.c.
|
static |
Definition at line 115 of file rlm_cipher.c.
|
static |
Definition at line 120 of file rlm_cipher.c.
|
static |
Definition at line 849 of file rlm_cipher.c.
|
static |
Definition at line 674 of file rlm_cipher.c.
|
static |
Definition at line 535 of file rlm_cipher.c.
|
static |
|
static |
Definition at line 107 of file rlm_cipher.c.
|
static |
Definition at line 596 of file rlm_cipher.c.
|
static |
Definition at line 733 of file rlm_cipher.c.
|
static |
Definition at line 109 of file rlm_cipher.c.
|
static |
Definition at line 113 of file rlm_cipher.c.
|
static |
Definition at line 236 of file rlm_cipher.c.
|
static |
|
static |
Definition at line 96 of file rlm_cipher.c.
module_rlm_t rlm_cipher |
Definition at line 1340 of file rlm_cipher.c.
|
static |
Configuration for the RSA cipher type.
Definition at line 208 of file rlm_cipher.c.
|
static |
Configuration for the RSA-PCKS1-OAEP padding scheme.
Definition at line 197 of file rlm_cipher.c.