Loading...
Searching...
No Matches
XrdCryptosslRSA Class Reference

`#include <XrdCryptosslRSA.hh>`

Inheritance diagram for XrdCryptosslRSA:
Collaboration diagram for XrdCryptosslRSA:

## Public Member Functions

| XrdCryptosslRSA (const char *pub, int lpub=0)
| XrdCryptosslRSA (const XrdCryptosslRSA &r)
| XrdCryptosslRSA (EVP_PKEY *key, bool check=1)
| XrdCryptosslRSA (int bits=XrdCryptoMinRSABits, int exp=XrdCryptoDefRSAExp)
virtual | ~XrdCryptosslRSA ()
int | DecryptPrivate (const char *in, int lin, char *out, int lout)
int | DecryptPublic (const char *in, int lin, char *out, int lout)
void | Dump ()
int | EncryptPrivate (const char *in, int lin, char *out, int lout)
int | EncryptPublic (const char *in, int lin, char *out, int lout)
int | ExportPrivate (char *out, int lout)
int | ExportPublic (char *out, int lout)
int | GetOutlen (int lin)
int | GetPrilen ()
int | GetPublen ()
int | ImportPrivate (const char *in, int lin)
int | ImportPublic (const char *in, int lin)
XrdCryptoRSAdata | Opaque ()
Public Member Functions inherited from XrdCryptoRSA
| XrdCryptoRSA ()
virtual | ~XrdCryptoRSA ()
int | DecryptPrivate (XrdSutBucket &buck)
int | DecryptPublic (XrdSutBucket &buck)
int | EncryptPrivate (XrdSutBucket &buck)
int | EncryptPublic (XrdSutBucket &buck)
int | ExportPrivate (XrdOucString &exp)
int | ExportPublic (XrdOucString &exp)
bool | IsValid ()
const char * | Status (ERSAStatus t=kInvalid) const

## Additional Inherited Members

Public Types inherited from XrdCryptoRSA
enum | ERSAStatus { kInvalid = 0 , kPublic = 1 , kComplete = 2 }
Public Attributes inherited from XrdCryptoRSA
ERSAStatus | status

## Detailed Description

Definition at line 46 of file XrdCryptosslRSA.hh.

## Constructor & Destructor Documentation

## XrdCryptosslRSA() [1/4]

XrdCryptosslRSA::XrdCryptosslRSA | ( | int | bits = XrdCryptoMinRSABits,
|  | int | exp = XrdCryptoDefRSAExp )

Definition at line 87 of file XrdCryptosslRSA.cc.

{
// Constructor
// Generate a RSA asymmetric key pair
// Length will be 'bits' bits (min 2048, default 2048), public
// exponent `pubex` (default 65537).
EPNAME("RSA::XrdCryptosslRSA");
publen = -1;
prilen = -1;
// Minimum is XrdCryptoMinRSABits
bits = (bits >= XrdCryptoMinRSABits) ? bits : XrdCryptoDefRSABits;
// If pubex is not odd, use default
if (!(exp & 1))
exp = XrdCryptoDefRSAExp; // 65537 (0x10001)
DEBUG("bits: "<<bits<<", exp: "<<exp);
// Try Key Generation
BIGNUM *e = BN_new();
if (!e) {
DEBUG("cannot allocate new exponent");
return;
}
BN_set_word(e, exp);
EVP_PKEY_CTX *pkctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, 0);
EVP_PKEY_keygen_init(pkctx);
EVP_PKEY_CTX_set_rsa_keygen_bits(pkctx, bits);
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
EVP_PKEY_CTX_set1_rsa_keygen_pubexp(pkctx, e);
BN_free(e);
#else
EVP_PKEY_CTX_set_rsa_keygen_pubexp(pkctx, e);
#endif
EVP_PKEY_keygen(pkctx, &fEVP);
EVP_PKEY_CTX_free(pkctx);
// Update status flag
if (fEVP) {
if (XrdCheckRSA(fEVP) == 1) {
status = kComplete;
DEBUG("basic length: "<<EVP_PKEY_size(fEVP)<<" bytes");
} else {
DEBUG("WARNING: generated key is invalid");
// Generated an invalid key: cleanup
EVP_PKEY_free(fEVP);
fEVP = 0;
}
}
}
DEBUG
#define DEBUG(x)
Definition XrdBwmTrace.hh:54
EPNAME
#define EPNAME(x)
Definition XrdBwmTrace.hh:56
XrdCryptoMinRSABits
#define XrdCryptoMinRSABits
Definition XrdCryptoAux.hh:52
XrdCryptoDefRSAExp
#define XrdCryptoDefRSAExp
Definition XrdCryptoAux.hh:54
XrdCryptoDefRSABits
#define XrdCryptoDefRSABits
Definition XrdCryptoAux.hh:53
XrdCheckRSA
static int XrdCheckRSA(EVP_PKEY *pkey)
Definition XrdCryptosslgsiAux.cc:139
XrdCryptoRSA::status
ERSAStatus status
Definition XrdCryptoRSA.hh:58
XrdCryptoRSA::kComplete
@ kComplete
Definition XrdCryptoRSA.hh:57

References DEBUG, EPNAME, XrdCryptoRSA::kComplete, XrdCryptoRSA::status, XrdCheckRSA(), XrdCryptoDefRSABits, XrdCryptoDefRSAExp, and XrdCryptoMinRSABits.

Referenced by XrdCryptosslRSA().

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

## XrdCryptosslRSA() [2/4]

XrdCryptosslRSA::XrdCryptosslRSA | ( | const char * | pub,
|  | int | lpub = 0 )

Definition at line 143 of file XrdCryptosslRSA.cc.

{
// Constructor
// Allocate a RSA key pair and fill the public part importing
// from string representation (pub) to internal representation.
// If lpub>0 use the first lpub bytes; otherwise use strlen(pub)
// bytes.
fEVP = 0;
publen = -1;
prilen = -1;
// Import key
ImportPublic(pub,lpub);
}
XrdCryptosslRSA::ImportPublic
int ImportPublic(const char *in, int lin)
Definition XrdCryptosslRSA.cc:274

References ImportPublic().

Here is the call graph for this function:

## XrdCryptosslRSA() [3/4]

XrdCryptosslRSA::XrdCryptosslRSA | ( | EVP_PKEY * | key,
|  | bool | check = 1 )

Definition at line 160 of file XrdCryptosslRSA.cc.

{
// Constructor to import existing key
EPNAME("RSA::XrdCryptosslRSA_key");
fEVP = 0;
publen = -1;
prilen = -1;
// Create container, first
if (!key) {
DEBUG("no input key");
return;
}
if (check) {
// Check consistency
if (XrdCheckRSA(key) == 1) {
fEVP = key;
// Update status
status = kComplete;
} else {
DEBUG("key contains inconsistent information");
}
} else {
// Accept in any case (for incomplete keys)
fEVP = key;
// Update status
status = kPublic;
}
}
XrdCryptoRSA::kPublic
@ kPublic
Definition XrdCryptoRSA.hh:57

References DEBUG, EPNAME, XrdCryptoRSA::kComplete, XrdCryptoRSA::kPublic, XrdCryptoRSA::status, and XrdCheckRSA().

Here is the call graph for this function:

## XrdCryptosslRSA() [4/4]

XrdCryptosslRSA::XrdCryptosslRSA | ( | const XrdCryptosslRSA & | r | ) |

Definition at line 194 of file XrdCryptosslRSA.cc.

: XrdCryptoRSA()
{
// Copy Constructor
EPNAME("RSA::XrdCryptosslRSA_copy");
fEVP = 0;
publen = -1;
prilen = -1;
if (!r.fEVP) {
DEBUG("input key is empty");
return;
}
// If the given key is set, copy it via a bio
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
BIGNUM *d = BN_new();
bool publiconly =
(EVP_PKEY_get_bn_param(r.fEVP, OSSL_PKEY_PARAM_RSA_D, &d) != 1);
BN_free(d);
#else
const BIGNUM *d = 0;
RSA_get0_key(EVP_PKEY_get0_RSA(r.fEVP), 0, 0, &d);
bool publiconly = (d == 0);
#endif
//
// Bio for exporting the pub key
BIO *bcpy = BIO_new(BIO_s_mem());
if (bcpy) {
bool ok;
if (publiconly) {
// Write kref public key to BIO
ok = (PEM_write_bio_PUBKEY(bcpy, r.fEVP) != 0);
} else {
// Write kref private key to BIO
ok = (PEM_write_bio_PrivateKey(bcpy,r.fEVP,0,0,0,0,0) != 0);
}
if (ok) {
if (publiconly) {
// Read public key from BIO
if ((fEVP = PEM_read_bio_PUBKEY(bcpy, 0, 0, 0))) {
status = kPublic;
}
} else {
if ((fEVP = PEM_read_bio_PrivateKey(bcpy,0,0,0))) {
// Check consistency only if original was not marked complete
if (r.status == kComplete || XrdCheckRSA(fEVP) == 1) {
// Update status
status = kComplete;
}
}
}
}
// Cleanup bio
BIO_free(bcpy);
}
}
RSA_get0_key
static void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
Definition XrdCryptosslRSA.cc:58
EVP_PKEY_get0_RSA
static RSA * EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
Definition XrdCryptosslgsiAux.cc:130
XrdCryptoRSA::XrdCryptoRSA
XrdCryptoRSA()
Definition XrdCryptoRSA.hh:53

References XrdCryptoRSA::XrdCryptoRSA(), XrdCryptosslRSA(), DEBUG, EPNAME, EVP_PKEY_get0_RSA(), XrdCryptoRSA::kComplete, XrdCryptoRSA::kPublic, RSA_get0_key(), XrdCryptoRSA::status, and XrdCheckRSA().

Here is the call graph for this function:

## ~XrdCryptosslRSA()

XrdCryptosslRSA::~XrdCryptosslRSA | ( |  | ) |

virtual

Definition at line 253 of file XrdCryptosslRSA.cc.

{
// Destructor
// Destroy the RSA asymmetric key pair
if (fEVP)
EVP_PKEY_free(fEVP);
fEVP = 0;
}

## Member Function Documentation

## DecryptPrivate()

int XrdCryptosslRSA::DecryptPrivate | ( | const char * | in,
|  | int | lin,
|  | char * | out,
|  | int | lout )

virtual

Reimplemented from XrdCryptoRSA.

Definition at line 607 of file XrdCryptosslRSA.cc.

{
// Decrypt lin bytes at 'in' using the internal private key
// The output buffer 'out' is allocated by the caller for max lout bytes.
// The number of meaningful bytes in out is returned in case of success
// (never larger that loutmax); -1 in case of error.
EPNAME("RSA::DecryptPrivate");
// Make sure we got something to decrypt
if (!in || lin <= 0) {
DEBUG("input buffer undefined");
return -1;
}
// Make sure we got a buffer where to write
if (!out || loutmax <= 0) {
DEBUG("output buffer undefined");
return -1;
}
size_t lout = 0;
size_t len = lin;
size_t lcmax = EVP_PKEY_size(fEVP);
int kk = 0;
int ke = 0;
//
// Private decoding ...
EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(fEVP, 0);
EVP_PKEY_decrypt_init(ctx);
EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_OAEP_PADDING);
while (len > 0 && ke <= int(loutmax - lout)) {
lout = loutmax - ke;
if (EVP_PKEY_decrypt(ctx, (unsigned char *)&out[ke], &lout,
(unsigned char *)&in[kk], lcmax) <= 0) {
EVP_PKEY_CTX_free(ctx);
char serr[120];
ERR_error_string(ERR_get_error(), serr);
DEBUG("error: " <<serr);
return -1;
}
kk += lcmax;
len -= lcmax;
ke += lout;
}
EVP_PKEY_CTX_free(ctx);
if (len > 0 && ke > int(loutmax - lout))
PRINT("buffer truncated");
lout = ke;
return lout;
}
PRINT
#define PRINT(y)
Definition XrdCryptosslTrace.hh:39

References DEBUG, EPNAME, and PRINT.

## DecryptPublic()

int XrdCryptosslRSA::DecryptPublic | ( | const char * | in,
|  | int | lin,
|  | char * | out,
|  | int | lout )

virtual

Reimplemented from XrdCryptoRSA.

Definition at line 661 of file XrdCryptosslRSA.cc.

{
// Decrypt lin bytes at 'in' using the internal public key
// The output buffer 'out' is allocated by the caller for max lout bytes.
// The number of meaningful bytes in out is returned in case of success
// (never larger that loutmax); -1 in case of error.
EPNAME("RSA::DecryptPublic");
// Make sure we got something to decrypt
if (!in || lin <= 0) {
DEBUG("input buffer undefined");
return -1;
}
// Make sure we got a buffer where to write
if (!out || loutmax <= 0) {
DEBUG("output buffer undefined");
return -1;
}
size_t lout = 0;
size_t len = lin;
size_t lcmax = EVP_PKEY_size(fEVP);
int kk = 0;
int ke = 0;
//
// Private decoding ...
EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(fEVP, 0);
EVP_PKEY_verify_recover_init(ctx);
EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING);
while (len > 0 && ke <= int(loutmax - lout)) {
lout = loutmax - ke;
if (EVP_PKEY_verify_recover(ctx, (unsigned char *)&out[ke], &lout,
(unsigned char *)&in[kk], lcmax) <= 0) {
EVP_PKEY_CTX_free(ctx);
char serr[120];
ERR_error_string(ERR_get_error(), serr);
PRINT("error: " <<serr);
return -1;
}
kk += lcmax;
len -= lcmax;
ke += lout;
}
EVP_PKEY_CTX_free(ctx);
if (len > 0 && ke > int(loutmax - lout))
PRINT("buffer truncated");
lout = ke;
return lout;
}

References DEBUG, EPNAME, and PRINT.

## Dump()

void XrdCryptosslRSA::Dump | ( |  | ) |

virtual

Reimplemented from XrdCryptoRSA.

Definition at line 349 of file XrdCryptosslRSA.cc.

{
// Dump some info about the key
EPNAME("RSA::Dump");
DEBUG("---------------------------------------");
DEBUG("address: "<<this);
if (IsValid()) {
char *btmp = new char[GetPublen()+1];
if (btmp) {
ExportPublic(btmp,GetPublen()+1);
DEBUG("export pub key:"<<std::endl<<btmp);
delete[] btmp;
} else {
DEBUG("cannot allocate memory for public key");
}
} else {
DEBUG("key is invalid");
}
DEBUG("---------------------------------------");
}
XrdCryptoRSA::IsValid
bool IsValid()
Definition XrdCryptoRSA.hh:69
XrdCryptosslRSA::GetPublen
int GetPublen()
Definition XrdCryptosslRSA.cc:372
XrdCryptosslRSA::ExportPublic
int ExportPublic(char *out, int lout)
Definition XrdCryptosslRSA.cc:389

References DEBUG, EPNAME, ExportPublic(), GetPublen(), and XrdCryptoRSA::IsValid().

Here is the call graph for this function:

## EncryptPrivate()

int XrdCryptosslRSA::EncryptPrivate | ( | const char * | in,
|  | int | lin,
|  | char * | out,
|  | int | lout )

virtual

Reimplemented from XrdCryptoRSA.

Definition at line 497 of file XrdCryptosslRSA.cc.

{
// Encrypt lin bytes at 'in' using the internal private key.
// The output buffer 'out' is allocated by the caller for max lout bytes.
// The number of meaningful bytes in out is returned in case of success
// (never larger that loutmax); -1 in case of error.
EPNAME("RSA::EncryptPrivate");
// Make sure we got something to encrypt
if (!in || lin <= 0) {
DEBUG("input buffer undefined");
return -1;
}
// Make sure we got a buffer where to write
if (!out || loutmax <= 0) {
DEBUG("output buffer undefined");
return -1;
}
//
// Private encoding ...
size_t lcmax = EVP_PKEY_size(fEVP) - 11; // Magic number (= 2*sha1_outlen + 2)
size_t lout = 0;
size_t len = lin;
int kk = 0;
int ke = 0;
EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(fEVP, 0);
EVP_PKEY_sign_init(ctx);
EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING);
while (len > 0 && ke <= int(loutmax - lout)) {
size_t lc = (len > lcmax) ? lcmax : len;
lout = loutmax - ke;
if (EVP_PKEY_sign(ctx, (unsigned char *)&out[ke], &lout,
(unsigned char *)&in[kk], lc) <= 0) {
EVP_PKEY_CTX_free(ctx);
char serr[120];
ERR_error_string(ERR_get_error(), serr);
DEBUG("error: " <<serr);
return -1;
}
kk += lc;
ke += lout;
len -= lc;
}
EVP_PKEY_CTX_free(ctx);
if (len > 0 && ke > int(loutmax - lout))
DEBUG("buffer truncated");
lout = ke;
return lout;
}

References DEBUG, and EPNAME.

## EncryptPublic()

int XrdCryptosslRSA::EncryptPublic | ( | const char * | in,
|  | int | lin,
|  | char * | out,
|  | int | lout )

virtual

Reimplemented from XrdCryptoRSA.

Definition at line 552 of file XrdCryptosslRSA.cc.

{
// Encrypt lin bytes at 'in' using the internal public key.
// The output buffer 'out' is allocated by the caller for max lout bytes.
// The number of meaningful bytes in out is returned in case of success
// (never larger that loutmax); -1 in case of error.
EPNAME("RSA::EncryptPublic");
// Make sure we got something to encrypt
if (!in || lin <= 0) {
DEBUG("input buffer undefined");
return -1;
}
// Make sure we got a buffer where to write
if (!out || loutmax <= 0) {
DEBUG("output buffer undefined");
return -1;
}
//
// Public encoding ...
size_t lcmax = EVP_PKEY_size(fEVP) - 42; // Magic number (= 2*sha1_outlen + 2)
size_t lout = 0;
size_t len = lin;
int kk = 0;
int ke = 0;
EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(fEVP, 0);
EVP_PKEY_encrypt_init(ctx);
EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_OAEP_PADDING);
while (len > 0 && ke <= int(loutmax - lout)) {
size_t lc = (len > lcmax) ? lcmax : len;
lout = loutmax - ke;
if (EVP_PKEY_encrypt(ctx, (unsigned char *)&out[ke], &lout,
(unsigned char *)&in[kk], lc) <= 0) {
EVP_PKEY_CTX_free(ctx);
char serr[120];
ERR_error_string(ERR_get_error(), serr);
DEBUG("error: " <<serr);
return -1;
}
kk += lc;
ke += lout;
len -= lc;
}
EVP_PKEY_CTX_free(ctx);
if (len > 0 && ke > int(loutmax - lout))
DEBUG("buffer truncated");
lout = ke;
return lout;
}

References DEBUG, and EPNAME.

## ExportPrivate()

int XrdCryptosslRSA::ExportPrivate | ( | char * | out,
|  | int | lout )

virtual

Reimplemented from XrdCryptoRSA.

Definition at line 452 of file XrdCryptosslRSA.cc.

{
// Export the private key into buffer out. The length of the buffer should be
// at least GetPrilen()+1 bytes. The buffer out must be passed-by and it
// responsability-of the caller.
// Return 0 in case of success, -1 in case of failure
EPNAME("RSA::ExportPrivate");
// Make sure we have a valid key
if (!IsValid()) {
DEBUG("key not valid");
return -1;
}
// Check output buffer
if (!out) {
DEBUG("output buffer undefined!");
return -1;
}
// Bio for exporting the pub key
BIO *bkey = BIO_new(BIO_s_mem());
// Write public key to BIO
PEM_write_bio_PrivateKey(bkey,fEVP,0,0,0,0,0);
// data length
char *cbio = 0;
int lbio = (int) BIO_get_mem_data(bkey, &cbio);
if (lbio <= 0 || !cbio) {
DEBUG("problems attaching to BIO content");
return -1;
}
// Read key from BIO to buf
memcpy(out, cbio, lbio);
// Null terminate
out[lbio] = 0;
DEBUG("("<<lbio<<" bytes) "<< std::endl <<out);
BIO_free(bkey);
return 0;
}

References DEBUG, EPNAME, and XrdCryptoRSA::IsValid().

Here is the call graph for this function:

## ExportPublic()

int XrdCryptosslRSA::ExportPublic | ( | char * | out,
|  | int | lout )

virtual

Reimplemented from XrdCryptoRSA.

Definition at line 389 of file XrdCryptosslRSA.cc.

{
// Export the public key into buffer out. The length of the buffer should be
// at least GetPublen()+1 bytes. The buffer out must be passed-by and it
// responsability-of the caller.
// Return 0 in case of success, -1 in case of failure
EPNAME("RSA::ExportPublic");
// Make sure we have a valid key
if (!IsValid()) {
DEBUG("key not valid");
return -1;
}
// Check output buffer
if (!out) {
DEBUG("output buffer undefined!");
return -1;
}
// Bio for exporting the pub key
BIO *bkey = BIO_new(BIO_s_mem());
// Write public key to BIO
PEM_write_bio_PUBKEY(bkey,fEVP);
// data length
char *cbio = 0;
int lbio = (int) BIO_get_mem_data(bkey, &cbio);
if (lbio <= 0 || !cbio) {
DEBUG("problems attaching to BIO content");
return -1;
}
// Read key from BIO to buf
memcpy(out, cbio, lbio);
// Null terminate
out[lbio] = 0;
DEBUG("("<<lbio<<" bytes) "<< std::endl <<out);
BIO_free(bkey);
return 0;
}

References DEBUG, EPNAME, and XrdCryptoRSA::IsValid().

Referenced by Dump().

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

## GetOutlen()

int XrdCryptosslRSA::GetOutlen | ( | int | lin | ) |

virtual

Reimplemented from XrdCryptoRSA.

Definition at line 264 of file XrdCryptosslRSA.cc.

{
// Get minimal length of output buffer
int lcmax = EVP_PKEY_size(fEVP) - 42;
return ((lin / lcmax) + 1) * EVP_PKEY_size(fEVP);
}

## GetPrilen()

int XrdCryptosslRSA::GetPrilen | ( |  | ) |

virtual

Reimplemented from XrdCryptoRSA.

Definition at line 434 of file XrdCryptosslRSA.cc.

{
// Minimum length of export format of private key
if (prilen < 0) {
// Bio for exporting the private key
BIO *bkey = BIO_new(BIO_s_mem());
// Write public key to BIO
PEM_write_bio_PrivateKey(bkey,fEVP,0,0,0,0,0);
// data length
char *cbio = 0;
prilen = (int) BIO_get_mem_data(bkey, &cbio);
BIO_free(bkey);
}
return prilen;
}

## GetPublen()

int XrdCryptosslRSA::GetPublen | ( |  | ) |

virtual

Reimplemented from XrdCryptoRSA.

Definition at line 372 of file XrdCryptosslRSA.cc.

{
// Minimum length of export format of public key
if (publen < 0) {
// Bio for exporting the pub key
BIO *bkey = BIO_new(BIO_s_mem());
// Write public key to BIO
PEM_write_bio_PUBKEY(bkey,fEVP);
// data length
char *cbio = 0;
publen = (int) BIO_get_mem_data(bkey, &cbio);
BIO_free(bkey);
}
return publen;
}

Referenced by Dump().

Here is the caller graph for this function:

## ImportPrivate()

int XrdCryptosslRSA::ImportPrivate | ( | const char * | in,
|  | int | lin )

virtual

Reimplemented from XrdCryptoRSA.

Definition at line 314 of file XrdCryptosslRSA.cc.

{
// Import a private key
// Fill the private part importing from string representation (pub) to
// internal representation.
// If lpub>0 use the first lpub bytes; otherwise use strlen(pub)
// bytes.
// Return 0 in case of success, -1 in case of failure
if (!fEVP)
return -1;
int rc = -1;
prilen = -1;
// Bio for exporting the pub key
BIO *bpri = BIO_new(BIO_s_mem());
// Check length
lpri = (lpri <= 0) ? strlen(pri) : lpri;
// Write key from private export to BIO
BIO_write(bpri,(void *)pri,lpri);
// Read private key from BIO
if (PEM_read_bio_PrivateKey(bpri, &fEVP, 0, 0)) {
// Update status
status = kComplete;
rc = 0;
}
BIO_free(bpri);
return rc;
}

References XrdCryptoRSA::kComplete, and XrdCryptoRSA::status.

## ImportPublic()

int XrdCryptosslRSA::ImportPublic | ( | const char * | in,
|  | int | lin )

virtual

Reimplemented from XrdCryptoRSA.

Definition at line 274 of file XrdCryptosslRSA.cc.

{
// Import a public key
// Allocate a RSA key pair and fill the public part importing
// from string representation (pub) to internal representation.
// If lpub>0 use the first lpub bytes; otherwise use strlen(pub)
// bytes.
// Return 0 in case of success, -1 in case of failure
int rc = -1;
if (fEVP)
EVP_PKEY_free(fEVP);
fEVP = 0;
publen = -1;
prilen = -1;
// Temporary key
EVP_PKEY *keytmp = 0;
// Bio for exporting the pub key
BIO *bpub = BIO_new(BIO_s_mem());
// Check length
lpub = (lpub <= 0) ? strlen(pub) : lpub;
// Write key from pubexport to BIO
BIO_write(bpub,(void *)pub,lpub);
// Read pub key from BIO
if ((keytmp = PEM_read_bio_PUBKEY(bpub, 0, 0, 0))) {
fEVP = keytmp;
// Update status
status = kPublic;
rc = 0;
}
BIO_free(bpub);
return rc;
}

References XrdCryptoRSA::kPublic, and XrdCryptoRSA::status.

Referenced by XrdCryptosslRSA().

Here is the caller graph for this function:

## Opaque()

XrdCryptoRSAdata XrdCryptosslRSA::Opaque | ( |  | ) |

inline virtual

Reimplemented from XrdCryptoRSA.

Definition at line 61 of file XrdCryptosslRSA.hh.

{ return fEVP; }

The documentation for this class was generated from the following files:

- XrdCryptosslRSA.hh
- XrdCryptosslRSA.cc