XRootD
XrdCryptosslgsiAux.cc File Reference
#include <cstring>
#include <sys/types.h>
#include <sys/stat.h>
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
#include <openssl/x509v3.h>
#include <memory>
#include "XrdSut/XrdSutRndm.hh"
#include "XrdCrypto/XrdCryptogsiX509Chain.hh"
#include "XrdCrypto/XrdCryptosslAux.hh"
#include "XrdCrypto/XrdCryptosslRSA.hh"
#include "XrdCrypto/XrdCryptosslTrace.hh"
#include "XrdCrypto/XrdCryptosslX509.hh"
#include "XrdCrypto/XrdCryptosslX509Req.hh"
+ Include dependency graph for XrdCryptosslgsiAux.cc:

Go to the source code of this file.

Macros

#define BIO_GET_STRING(b, str)
 
#define BIO_PRINT(b, c)
 
#define KEY_USAGE_OID   "2.5.29.15"
 
#define SUBJ_ALT_NAME_OID   "2.5.29.17"
 
#define XRDGSI_CONST
 
#define XRDGSI_VOMS_ACSEQ_OID   "1.3.6.1.4.1.8005.100.100.5"
 
#define XRDGSI_VOMS_ATCAP_OID   "1.3.6.1.4.1.8005.100.100.4"
 

Typedefs

using EVP_PKEY_ptr = std::unique_ptr< EVP_PKEY, decltype(&EVP_PKEY_free)>
 
using PROXY_CERT_INFO_EXTENSION_ptr = std::unique_ptr< PROXY_CERT_INFO_EXTENSION, decltype(&PROXY_CERT_INFO_EXTENSION_free)>
 
using STACK_OF_X509_EXTENSION_ptr = std::unique_ptr< STACK_OF(X509_EXTENSION), decltype(&stackOfX509ExtensionDelete)>
 
using X509_EXTENSION_ptr = std::unique_ptr< X509_EXTENSION, decltype(&X509_EXTENSION_free)>
 
using X509_NAME_ptr = std::unique_ptr< X509_NAME, decltype(&X509_NAME_free)>
 
using X509_ptr = std::unique_ptr< X509, decltype(&X509_free)>
 
using X509_REQ_ptr = std::unique_ptr< X509_REQ, decltype(&X509_REQ_free)>
 

Functions

static RSA * EVP_PKEY_get0_RSA (EVP_PKEY *pkey)
 
static void stackOfX509ExtensionDelete (STACK_OF(X509_EXTENSION) *ske)
 
static int XrdCheckRSA (EVP_PKEY *pkey)
 
int XrdCryptosslX509Asn1PrintInfo (int tag, int xclass, int constructed, int indent)
 
int XrdCryptosslX509FillUnknownExt (XRDGSI_CONST unsigned char **pp, long length)
 
int XrdCryptosslX509FillVOMS (XRDGSI_CONST unsigned char **pp, long length, bool &getvat, XrdOucString &vat)
 

Macro Definition Documentation

◆ BIO_GET_STRING

#define BIO_GET_STRING (   b,
  str 
)
Value:
BUF_MEM *bptr; \
BIO_get_mem_ptr(b, &bptr); \
if (bptr) { \
char *s = new char[bptr->length+1]; \
memcpy(s, bptr->data, bptr->length); \
s[bptr->length] = '\0'; \
str = s; \
delete [] s; \
} else { \
PRINT("ERROR: GET_STRING: BIO internal buffer undefined!"); \
} \
if (b) BIO_free(b);

Definition at line 109 of file XrdCryptosslgsiAux.cc.

◆ BIO_PRINT

#define BIO_PRINT (   b,
 
)
Value:
BUF_MEM *bptr; \
BIO_get_mem_ptr(b, &bptr); \
if (bptr) { \
char *s = new char[bptr->length+1]; \
memcpy(s, bptr->data, bptr->length); \
s[bptr->length] = '\0'; \
PRINT(c << s); \
delete [] s; \
} else { \
PRINT("ERROR: "<<c<<" BIO internal buffer undefined!"); \
} \
if (b) BIO_free(b);

Definition at line 95 of file XrdCryptosslgsiAux.cc.

◆ KEY_USAGE_OID

#define KEY_USAGE_OID   "2.5.29.15"

Definition at line 82 of file XrdCryptosslgsiAux.cc.

◆ SUBJ_ALT_NAME_OID

#define SUBJ_ALT_NAME_OID   "2.5.29.17"

Definition at line 84 of file XrdCryptosslgsiAux.cc.

◆ XRDGSI_CONST

#define XRDGSI_CONST

Definition at line 126 of file XrdCryptosslgsiAux.cc.

◆ XRDGSI_VOMS_ACSEQ_OID

#define XRDGSI_VOMS_ACSEQ_OID   "1.3.6.1.4.1.8005.100.100.5"

Definition at line 93 of file XrdCryptosslgsiAux.cc.

◆ XRDGSI_VOMS_ATCAP_OID

#define XRDGSI_VOMS_ATCAP_OID   "1.3.6.1.4.1.8005.100.100.4"

Definition at line 92 of file XrdCryptosslgsiAux.cc.

Typedef Documentation

◆ EVP_PKEY_ptr

using EVP_PKEY_ptr = std::unique_ptr<EVP_PKEY, decltype(&EVP_PKEY_free)>

Definition at line 67 of file XrdCryptosslgsiAux.cc.

◆ PROXY_CERT_INFO_EXTENSION_ptr

using PROXY_CERT_INFO_EXTENSION_ptr = std::unique_ptr<PROXY_CERT_INFO_EXTENSION, decltype(&PROXY_CERT_INFO_EXTENSION_free)>

Definition at line 72 of file XrdCryptosslgsiAux.cc.

◆ STACK_OF_X509_EXTENSION_ptr

using STACK_OF_X509_EXTENSION_ptr = std::unique_ptr<STACK_OF(X509_EXTENSION), decltype(&stackOfX509ExtensionDelete)>

Definition at line 73 of file XrdCryptosslgsiAux.cc.

◆ X509_EXTENSION_ptr

using X509_EXTENSION_ptr = std::unique_ptr<X509_EXTENSION, decltype(&X509_EXTENSION_free)>

Definition at line 71 of file XrdCryptosslgsiAux.cc.

◆ X509_NAME_ptr

using X509_NAME_ptr = std::unique_ptr<X509_NAME, decltype(&X509_NAME_free)>

Definition at line 69 of file XrdCryptosslgsiAux.cc.

◆ X509_ptr

using X509_ptr = std::unique_ptr<X509, decltype(&X509_free)>

Definition at line 68 of file XrdCryptosslgsiAux.cc.

◆ X509_REQ_ptr

using X509_REQ_ptr = std::unique_ptr<X509_REQ, decltype(&X509_REQ_free)>

Definition at line 70 of file XrdCryptosslgsiAux.cc.

Function Documentation

◆ EVP_PKEY_get0_RSA()

static RSA* EVP_PKEY_get0_RSA ( EVP_PKEY *  pkey)
static

Definition at line 130 of file XrdCryptosslgsiAux.cc.

131 {
132  if (pkey->type != EVP_PKEY_RSA) {
133  return NULL;
134  }
135  return pkey->pkey.rsa;
136 }

Referenced by XrdCheckRSA().

+ Here is the caller graph for this function:

◆ stackOfX509ExtensionDelete()

static void stackOfX509ExtensionDelete ( STACK_OF(X509_EXTENSION) *  ske)
static

Definition at line 60 of file XrdCryptosslgsiAux.cc.

60  {
61 #if OPENSSL_VERSION_NUMBER >= 0x10000000L
62  sk_X509_EXTENSION_pop_free(ske, X509_EXTENSION_free);
63 #else /* OPENSSL */
64  sk_pop_free(ske, X509_EXTENSION_free);
65 #endif /* OPENSSL */
66 }

◆ XrdCheckRSA()

static int XrdCheckRSA ( EVP_PKEY *  pkey)
static

Definition at line 139 of file XrdCryptosslgsiAux.cc.

139  {
140  int rc;
141 #if OPENSSL_VERSION_NUMBER < 0x10101000L
142  RSA *rsa = EVP_PKEY_get0_RSA(pkey);
143  if (rsa)
144  rc = RSA_check_key(rsa);
145  else
146  rc = -2;
147 #else
148  EVP_PKEY_CTX *ckctx = EVP_PKEY_CTX_new(pkey, 0);
149  rc = EVP_PKEY_check(ckctx);
150  EVP_PKEY_CTX_free(ckctx);
151 #endif
152  return rc;
153 }
static RSA * EVP_PKEY_get0_RSA(EVP_PKEY *pkey)

References EVP_PKEY_get0_RSA().

+ Here is the call graph for this function:

◆ XrdCryptosslX509Asn1PrintInfo()

int XrdCryptosslX509Asn1PrintInfo ( int  tag,
int  xclass,
int  constructed,
int  indent 
)

◆ XrdCryptosslX509FillUnknownExt()

int XrdCryptosslX509FillUnknownExt ( XRDGSI_CONST unsigned char **  pp,
long  length 
)

◆ XrdCryptosslX509FillVOMS()

int XrdCryptosslX509FillVOMS ( XRDGSI_CONST unsigned char **  pp,
long  length,
bool &  getvat,
XrdOucString vat 
)