Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cX509Csr Class Reference

#include <cX509Csr.h>

Inheritance diagram for GrayLib::cX509Csr:
GrayLib::cX509Common Gray::cRefBase IUnknown

Public Member Functions

 cX509Csr () noexcept
 
 ~cX509Csr ()
 
virtual void SetEmptyX () override
 
virtual HRESULT GetDescription (StrBuilder &s, const char *prefix) const override
 
virtual HRESULT ReadFromDer1 (const BYTE *buf, size_t buflen) override
 
virtual HRESULT ReadFromDER (const BYTE *buf, size_t buflen) override
 
virtual HRESULT ReadFromUnk (const BYTE *buf, size_t buflen) override
 
HRESULT WriteToDER (BYTE *pBuffer, size_t size, const cASNSets &extensions, IRandomNoise *pRandom)
 
HRESULT WriteToPEM (char *pOut, StrLen_t size, const cASNSets &extensions, IRandomNoise *pRandom)
 
 UNITTEST_FRIEND (cX509Csr)
 
- Public Member Functions inherited from GrayLib::cX509Common
 cX509Common () noexcept
 
virtual ~cX509Common ()
 
bool isEmptyX () const noexcept
 
HRESULT ReadSigAlg (cASNReader &r1, cASNBuf &sig_params)
 
HRESULT GetSigAlgStr (StrBuilder &s) const
 
HRESULT ReadFromFile (const FILECHAR_t *pszFilePath)
 
 UNITTEST_FRIEND (cX509Common)
 
- Public Member Functions inherited from Gray::cRefBase
 cRefBase (int iRefCount=0) noexcept
 
virtual ~cRefBase ()
 
int get_RefCount () const noexcept
 
HASHCODE_t get_HashCode () const noexcept
 
 STDMETHOD_ (HASHCODE_t, get_HashCodeX)() const noexcept
 
virtual void onFinalRelease ()
 
bool isValidObj () const noexcept
 
 STDMETHOD_ (ULONG, AddRef)(void) override
 
 STDMETHOD_ (ULONG, Release)(void) override
 
STDMETHOD() QueryInterface (const IID &riid, void __RPC_FAR *__RPC_FAR *ppvObject) override
 
void IncRefCount ()
 
void DecRefCount ()
 
bool isStaticConstruct () const noexcept
 
void StaticConstruct ()
 
void StaticDestruct ()
 
bool isDestructing () noexcept
 
void SetDestructing ()
 

Static Public Member Functions

static HRESULT GRAYCALL WriteExt_KeyUsage (OUT cASNSets &sets, BYTE key_usage)
 
static HRESULT GRAYCALL WriteExt_NSCertType (OUT cASNSets &sets, BYTE ns_cert_type)
 
- Static Public Member Functions inherited from GrayLib::cX509Common
static HRESULT ReturnError (HRESULT hRes) noexcept
 
static X509_Verify_t X509_VerifySet (X509_Verify_t f1, X509_Verify_t f2) noexcept
 
static StrLen_t GRAYCALL GetSerialStr (StrBuilder &s, const cASNBuf &serial)
 

Public Attributes

cASNSets m_subject
 The parsed m_subject_raw (named information object). More...
 
cKeyWrap m_SubjectPublicKey
 Container for the public key context. More...
 
- Public Attributes inherited from GrayLib::cX509Common
cHeapBlock m_raw
 The raw certificate data (ReadFromDer1). cASNBuf pointers can point into this. More...
 
cASNBuf m_RawSigned
 The raw certificate body (in m_raw)(ReadFromDer1). The part that is To Be Signed. Precedes m_nVersion. More...
 
int m_nVersion
 1,2,3. 0 = unused. X509_CRT_VERSION_TYPE or CRL version More...
 
cASNBuf m_SignOID1
 Signature algorithm OID, e.g. "sha1RSA" for ReadSigAlg() More...
 
cKeySigAlg m_SigAlg
 How to sign with m_SignOID1. More...
 
cASNBuf m_SignBuffer
 
cNewPtr< cKeyRSASignOptionsm_pRSASignOptions
 Signature options to be passed to VerifySignatureExt(), e.g. for RSASSA-PSS SSL_Key_RSASSA_PSS. More...
 

Static Public Attributes

static const char * k_pszPEM = "CERTIFICATE REQUEST"
 "CERTIFICATE REQUEST" More...
 
- Static Public Attributes inherited from GrayLib::cX509Common
static const int k_MAX_INTERMEDIATE_CA = 8
 

Detailed Description

"Certificate Signing Request" (CSR) structure. Structures and functions for X.509 Certificate Signing Requests (CSR) CSR version (1=v1).

Constructor & Destructor Documentation

◆ cX509Csr()

GrayLib::cX509Csr::cX509Csr ( )
inlinenoexcept

◆ ~cX509Csr()

GrayLib::cX509Csr::~cX509Csr ( )
inline

Member Function Documentation

◆ GetDescription()

HRESULT GrayLib::cX509Csr::GetDescription ( StrBuilder s,
const char *  prefix 
) const
overridevirtual

Implements GrayLib::cX509Common.

◆ ReadFromDER()

virtual HRESULT GrayLib::cX509Csr::ReadFromDER ( const BYTE *  buf,
size_t  buflen 
)
inlineoverridevirtual

Implements GrayLib::cX509Common.

◆ ReadFromDer1()

HRESULT GrayLib::cX509Csr::ReadFromDer1 ( const BYTE *  buf,
size_t  buflen 
)
overridevirtual

Load a Certificate Signing Request (CSR) in DER format

  • pBuffer = buffer holding the CRL data
  • nSizeBuffer = size of the buffer
    Returns
    0 if successful, or a specific X509 error code

Implements GrayLib::cX509Common.

◆ ReadFromUnk()

HRESULT GrayLib::cX509Csr::ReadFromUnk ( const BYTE *  buf,
size_t  buflen 
)
overridevirtual

Load a Certificate Signing Request (CSR), DER or PEM format Check for valid input

  • pBuffer = buffer holding the CRL data
  • nSizeBuffer = size of the buffer
    Returns
    0 if successful, or a specific X509 or PEM error code

Implements GrayLib::cX509Common.

◆ SetEmptyX()

void GrayLib::cX509Csr::SetEmptyX ( )
overridevirtual

Reimplemented from GrayLib::cX509Common.

◆ UNITTEST_FRIEND()

GrayLib::cX509Csr::UNITTEST_FRIEND ( cX509Csr  )

◆ WriteExt_KeyUsage()

HRESULT GRAYCALL GrayLib::cX509Csr::WriteExt_KeyUsage ( OUT cASNSets sets,
BYTE  key_usage 
)
static

Set the Key Usage Extension flags (e.g. X509_KeyUsage_DIGITAL_SIGNATURE | X509_KeyUsage_KEY_CERT_SIGN)

  • key_usage key usage flags to set
    Returns
    0 if successful, or E_OUTOFMEMORY

◆ WriteExt_NSCertType()

HRESULT GRAYCALL GrayLib::cX509Csr::WriteExt_NSCertType ( OUT cASNSets sets,
BYTE  ns_cert_type 
)
static

Set the Netscape Cert Type flags (e.g. X509_NSCERT_SSL_CLIENT | X509_NSCERT_EMAIL)

  • ns_cert_type Netscape Cert Type flags to set
    Returns
    0 if successful, or E_OUTOFMEMORY

◆ WriteToDER()

HRESULT GrayLib::cX509Csr::WriteToDER ( BYTE *  pBuffer,
size_t  size,
const cASNSets extensions,
IRandomNoise pRandom 
)

Write a CSR (Certificate Signing Request) to a DER structure

Note
data is written at the end of the buffer! Use the return value to determine where you should start using the buffer
  • pBuffer = buffer to write to
  • size = size of the buffer
  • pRandom = RNG function (for signature, see note)
Returns
length of data written if successful, or a specific error code
Note
pRandom may be NULL if RSA is used for signature and the signature is made offline (otherwise pRandom is desirable for countermeasures against timing attacks). ECDSA signatures always require a non-NULL pRandom.

◆ WriteToPEM()

HRESULT GrayLib::cX509Csr::WriteToPEM ( char *  pOut,
StrLen_t  size,
const cASNSets extensions,
IRandomNoise pRandom 
)

Write a CSR (Certificate Signing Request) to a PEM string

  • pOut = buffer to write to
  • size = size of the buffer
  • pRandom RNG function (for signature, see note)
    Returns
    length if successful, or <0 = a specific error code
    Note
    pRandom may be nullptr if RSA is used for signature and the signature is made offline (otherwise pRandom is desirable for counter measures against timing attacks). ECDSA signatures always require a non-NULL pRandom.

Member Data Documentation

◆ k_pszPEM

const char * GrayLib::cX509Csr::k_pszPEM = "CERTIFICATE REQUEST"
static

"CERTIFICATE REQUEST"

◆ m_subject

cASNSets GrayLib::cX509Csr::m_subject

The parsed m_subject_raw (named information object).

◆ m_SubjectPublicKey

cKeyWrap GrayLib::cX509Csr::m_SubjectPublicKey

Container for the public key context.


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