Loading...
Searching...
No Matches
XrdCryptosslCipher.cc File Reference
`#include <cstring>`
`#include <cassert>`
`#include "XrdSut/XrdSutRndm.hh"`
`#include "XrdCrypto/XrdCryptosslTrace.hh"`
`#include "XrdCrypto/XrdCryptosslCipher.hh"`
`#include <openssl/bio.h>`
`#include <openssl/pem.h>`
`#include <openssl/dh.h>`
Include dependency graph for XrdCryptosslCipher.cc:

Go to the source code of this file.

## Functions

static void | DH_get0_key (const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key)
static void | DH_get0_pqg (const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
static int | DH_set0_key (DH *dh, BIGNUM *pub_key, BIGNUM *priv_key)
static int | DH_set0_pqg (DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g)
static int | DSA_set0_key (DSA *d, BIGNUM *pub_key, BIGNUM *priv_key)
static DH * | EVP_PKEY_get0_DH (EVP_PKEY *pkey)
static EVP_PKEY * | getFixedDHParams ()
static int | XrdCheckDH (EVP_PKEY *pkey)

## Variables

static const char | dh_param_enc []

## Function Documentation

## DH_get0_key()

void DH_get0_key | ( | const DH * | dh,
|  | const BIGNUM ** | pub_key,
|  | const BIGNUM ** | priv_key )

static

Definition at line 121 of file XrdCryptosslCipher.cc.

{
if (pub_key != NULL)
*pub_key = dh->pub_key;
if (priv_key != NULL)
*priv_key = dh->priv_key;
}

Referenced by XrdCryptosslCipher::XrdCryptosslCipher(), XrdCryptosslCipher::AsBucket(), and XrdCryptosslCipher::Public().

Here is the caller graph for this function:

## DH_get0_pqg()

void DH_get0_pqg | ( | const DH * | dh,
|  | const BIGNUM ** | p,
|  | const BIGNUM ** | q,
|  | const BIGNUM ** | g )

static

Definition at line 85 of file XrdCryptosslCipher.cc.

{
if (p != NULL)
*p = dh->p;
if (q != NULL)
*q = dh->q;
if (g != NULL)
*g = dh->g;
}

Referenced by XrdCryptosslCipher::XrdCryptosslCipher(), and XrdCryptosslCipher::AsBucket().

Here is the caller graph for this function:

## DH_set0_key()

int DH_set0_key | ( | DH * | dh,
|  | BIGNUM * | pub_key,
|  | BIGNUM * | priv_key )

static

Definition at line 130 of file XrdCryptosslCipher.cc.

{
/* If the field pub_key in dh is NULL, the corresponding input
* parameters MUST be non-NULL. The priv_key field may
* be left NULL.
*/
if (dh->pub_key == NULL && pub_key == NULL)
return 0;
if (pub_key != NULL) {
BN_free(dh->pub_key);
dh->pub_key = pub_key;
}
if (priv_key != NULL) {
BN_free(dh->priv_key);
dh->priv_key = priv_key;
}
return 1;
}

Referenced by XrdCryptosslCipher::XrdCryptosslCipher(), XrdCryptosslCipher::XrdCryptosslCipher(), XrdCryptosslCipher::XrdCryptosslCipher(), and XrdCryptosslCipher::Finalize().

Here is the caller graph for this function:

## DH_set0_pqg()

int DH_set0_pqg | ( | DH * | dh,
|  | BIGNUM * | p,
|  | BIGNUM * | q,
|  | BIGNUM * | g )

static

Definition at line 96 of file XrdCryptosslCipher.cc.

{
/* If the fields p and g in d are NULL, the corresponding input
* parameters MUST be non-NULL. q may remain NULL.
*/
if ((dh->p == NULL && p == NULL) || (dh->g == NULL && g == NULL))
return 0;
if (p != NULL) {
BN_free(dh->p);
dh->p = p;
}
if (q != NULL) {
BN_free(dh->q);
dh->q = q;
}
if (g != NULL) {
BN_free(dh->g);
dh->g = g;
}
if (q != NULL) {
dh->length = BN_num_bits(q);
}
return 1;
}

Referenced by XrdCryptosslCipher::XrdCryptosslCipher(), and XrdCryptosslCipher::XrdCryptosslCipher().

Here is the caller graph for this function:

## DSA_set0_key()

int DSA_set0_key | ( | DSA * | d,
|  | BIGNUM * | pub_key,
|  | BIGNUM * | priv_key )

static

Definition at line 149 of file XrdCryptosslCipher.cc.

{
/* If the field pub_key in d is NULL, the corresponding input
* parameters MUST be non-NULL. The priv_key field may
* be left NULL.
*/
if (d->pub_key == NULL && pub_key == NULL)
return 0;
if (pub_key != NULL) {
BN_free(d->pub_key);
d->pub_key = pub_key;
}
if (priv_key != NULL) {
BN_free(d->priv_key);
d->priv_key = priv_key;
}
return 1;
}

## EVP_PKEY_get0_DH()

DH * EVP_PKEY_get0_DH | ( | EVP_PKEY * | pkey | ) |

static

Definition at line 77 of file XrdCryptosslCipher.cc.

{
if (pkey->type != EVP_PKEY_DH) {
return NULL;
}
return pkey->pkey.dh;
}

Referenced by XrdCryptosslCipher::XrdCryptosslCipher(), XrdCryptosslCipher::AsBucket(), XrdCryptosslCipher::Public(), and XrdCheckDH().

Here is the caller graph for this function:

## getFixedDHParams()

EVP_PKEY * getFixedDHParams | ( |  | ) |

static

Definition at line 169 of file XrdCryptosslCipher.cc.

{
static EVP_PKEY *dhparms = [] {
EVP_PKEY *dhParam = 0;
BIO *biop = BIO_new(BIO_s_mem());
BIO_write(biop, dh_param_enc, strlen(dh_param_enc));
PEM_read_bio_Parameters(biop, &dhParam);
BIO_free(biop);
return dhParam;
}();
assert(dhparms);
return dhparms;
}
dh_param_enc
static const char dh_param_enc[]
Definition XrdCryptosslCipher.cc:55

References dh_param_enc.

Referenced by XrdCryptosslCipher::XrdCryptosslCipher(), and XrdCheckDH().

Here is the caller graph for this function:

## XrdCheckDH()

int XrdCheckDH | ( | EVP_PKEY * | pkey | ) |

static

Definition at line 184 of file XrdCryptosslCipher.cc.

{
// If the DH parameters we received are our fixed set we know they
// are acceptable. The parameter check requires computation and more
// with openssl 3 than previously. So skip if DH params are known.
const EVP_PKEY *dhparms = getFixedDHParams();
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
const bool skipcheck = EVP_PKEY_parameters_eq(pkey, dhparms);
#else
const bool skipcheck = EVP_PKEY_cmp_parameters(pkey, dhparms);
#endif
if (skipcheck) return 1;
int rc;
#if OPENSSL_VERSION_NUMBER < 0x10101000L
DH *dh = EVP_PKEY_get0_DH(pkey);
if (dh) {
DH_check(dh, &rc);
rc = (rc == 0 ? 1 : 0);
}
else {
rc = -2;
}
#else
EVP_PKEY_CTX *ckctx = EVP_PKEY_CTX_new(pkey, 0);
rc = EVP_PKEY_param_check(ckctx);
EVP_PKEY_CTX_free(ckctx);
#endif
return rc;
}
getFixedDHParams
static EVP_PKEY * getFixedDHParams()
Definition XrdCryptosslCipher.cc:169
EVP_PKEY_get0_DH
static DH * EVP_PKEY_get0_DH(EVP_PKEY *pkey)
Definition XrdCryptosslCipher.cc:77

References EVP_PKEY_get0_DH(), and getFixedDHParams().

Referenced by XrdCryptosslCipher::XrdCryptosslCipher(), XrdCryptosslCipher::XrdCryptosslCipher(), and XrdCryptosslCipher::XrdCryptosslCipher().

Here is the call graph for this function:
Here is the caller graph for this function:

## Variable Documentation

## dh_param_enc

const char dh_param_enc[]

static

Initial value:
=
R"(
-----BEGIN DH PARAMETERS-----
MIIBiAKCAYEAzcEAf3ZCkm0FxJLgKd1YoT16Hietl7QV8VgJNc5CYKmRu/gKylxT
MVZJqtUmoh2IvFHCfbTGEmZM5LdVaZfMLQf7yXjecg0nSGklYZeQQ3P0qshFLbI9
u3z1XhEeCbEZPq84WWwXacSAAxwwRRrN5nshgAavqvyDiGNi+GqYpqGPb9JE38R3
GJ51FTPutZlvQvEycjCbjyajhpItBB+XvIjWj2GQyvi+cqB0WrPQAsxCOPrBTCZL
OjM0NfJ7PQfllw3RDQev2u1Q+Rt8QyScJQCFUj/SWoxpw2ydpWdgAkrqTmdVYrev
x5AoXE52cVIC8wfOxaaJ4cBpnJui3Y0jZcOQj0FtC0wf4WcBpHnLLBzKSOQwbxts
WE8LkskPnwwrup/HqWimFFg40bC9F5Lm3CTDCb45mtlBxi3DydIbRLFhGAjlKzV3
s9G3opHwwfgXpFf3+zg7NPV3g1//HLgWCvooOvMqaO+X7+lXczJJLMafEaarcAya
Kyo8PGKIAORrAgEF
-----END DH PARAMETERS-----
)"

Definition at line 55 of file XrdCryptosslCipher.cc.

Referenced by getFixedDHParams().