XRootD
XrdCryptosslMsgDigest Class Reference

#include <XrdCryptosslMsgDigest.hh>

+ Inheritance diagram for XrdCryptosslMsgDigest:
+ Collaboration diagram for XrdCryptosslMsgDigest:

Public Member Functions

 XrdCryptosslMsgDigest (const char *dgst)
 
virtual ~XrdCryptosslMsgDigest ()
 
int Final ()
 
bool IsValid ()
 
int Reset (const char *dgst=0)
 
int Update (const char *b, int l)
 
- Public Member Functions inherited from XrdCryptoMsgDigest
 XrdCryptoMsgDigest ()
 
virtual ~XrdCryptoMsgDigest ()
 
bool operator== (const XrdCryptoMsgDigest md)
 
- Public Member Functions inherited from XrdCryptoBasic
 XrdCryptoBasic (const char *t=0, int l=0, const char *b=0)
 
virtual ~XrdCryptoBasic ()
 
virtual XrdSutBucketAsBucket ()
 
char * AsHexString ()
 
virtual char * Buffer () const
 
virtual int FromHex (const char *hex)
 
virtual int Length () const
 
virtual int SetBuffer (int l, const char *b)
 
virtual int SetLength (int l)
 
virtual int SetType (const char *t)
 
virtual char * Type () const
 
virtual void UseBuffer (int l, const char *b)
 

Static Public Member Functions

static bool IsSupported (const char *dgst)
 

Detailed Description

Definition at line 46 of file XrdCryptosslMsgDigest.hh.

Constructor & Destructor Documentation

◆ XrdCryptosslMsgDigest()

XrdCryptosslMsgDigest::XrdCryptosslMsgDigest ( const char *  dgst)

Definition at line 40 of file XrdCryptosslMsgDigest.cc.

41  : XrdCryptoMsgDigest(), valid(0), mdctx(0)
42 {
43  // Constructor.
44  // Init the message digest calculation
45 
46  SetType(0);
47  Init(dgst);
48 }
virtual int SetType(const char *t)

References XrdCryptoBasic::SetType().

+ Here is the call graph for this function:

◆ ~XrdCryptosslMsgDigest()

XrdCryptosslMsgDigest::~XrdCryptosslMsgDigest ( )
virtual

Definition at line 51 of file XrdCryptosslMsgDigest.cc.

52 {
53  // Destructor.
54 
55  if (valid) {
56  unsigned char mdval[EVP_MAX_MD_SIZE];
57  EVP_DigestFinal_ex(mdctx, mdval, 0);
58  EVP_MD_CTX_destroy(mdctx);
59  }
60 }

Member Function Documentation

◆ Final()

int XrdCryptosslMsgDigest::Final ( )
virtual

Reimplemented from XrdCryptoMsgDigest.

Definition at line 137 of file XrdCryptosslMsgDigest.cc.

138 {
139  // Finalize message digest calculation.
140  // Finalize the operation
141  // Returns -1 if unsuccessful (digest not initialized), 0 otherwise.
142  EPNAME("MsgDigest::Final");
143 
144  // MD outputs in these variables
145  unsigned char mdval[EVP_MAX_MD_SIZE] = {0};
146  unsigned int mdlen = 0;
147 
148  if (Type()) {
149  // Finalize what we have
150  if (EVP_DigestFinal_ex(mdctx, mdval, &mdlen) == 1) {
151  // Save result
152  SetBuffer(mdlen,(const char *)mdval);
153  // Notify, if requested
154  DEBUG("result length is "<<mdlen <<
155  " bytes (hex: " << AsHexString() <<")");
156  return 0;
157  } else {
158  PRINT("ERROR: problems finalizing digest");
159  }
160  }
161  return -1;
162 }
#define DEBUG(x)
Definition: XrdBwmTrace.hh:54
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
#define PRINT(y)
virtual int SetBuffer(int l, const char *b)
virtual char * Type() const
char * AsHexString()

References XrdCryptoBasic::AsHexString(), DEBUG, EPNAME, PRINT, XrdCryptoBasic::SetBuffer(), and XrdCryptoBasic::Type().

+ Here is the call graph for this function:

◆ IsSupported()

bool XrdCryptosslMsgDigest::IsSupported ( const char *  dgst)
static

Definition at line 63 of file XrdCryptosslMsgDigest.cc.

64 {
65  // Check if the specified MD is supported
66 
67  return (EVP_get_digestbyname(dgst) != 0);
68 }

Referenced by XrdCryptosslFactory::SupportedMsgDigest().

+ Here is the caller graph for this function:

◆ IsValid()

bool XrdCryptosslMsgDigest::IsValid ( )
inlinevirtual

Reimplemented from XrdCryptoMsgDigest.

Definition at line 59 of file XrdCryptosslMsgDigest.hh.

59 { return valid; }

◆ Reset()

int XrdCryptosslMsgDigest::Reset ( const char *  dgst = 0)
virtual

Reimplemented from XrdCryptoMsgDigest.

Definition at line 106 of file XrdCryptosslMsgDigest.cc.

107 {
108  // Re-Init the message digest calculation
109  if (valid) {
110  unsigned char mdval[EVP_MAX_MD_SIZE];
111  EVP_DigestFinal_ex(mdctx, mdval, 0);
112  SetBuffer(0,0);
113  EVP_MD_CTX_destroy(mdctx);
114  }
115  valid = 0;
116  Init(dgst);
117  if (!valid) return -1;
118 
119  return 0;
120 }

References XrdCryptoBasic::SetBuffer().

+ Here is the call graph for this function:

◆ Update()

int XrdCryptosslMsgDigest::Update ( const char *  b,
int  l 
)
virtual

Reimplemented from XrdCryptoMsgDigest.

Definition at line 123 of file XrdCryptosslMsgDigest.cc.

124 {
125  // Update message digest with the MD of l bytes at b.
126  // Create the internal buffer if needed (first call)
127  // Returns -1 if unsuccessful (digest not initialized), 0 otherwise.
128 
129  if (Type()) {
130  EVP_DigestUpdate(mdctx, (char *)b, l);
131  return 0;
132  }
133  return -1;
134 }

References XrdCryptoBasic::Type().

+ Here is the call graph for this function:

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