Mixes for Privacy and Anonymity in the Internet
Macros | Functions | Variables
CAUtil.cpp File Reference

Macros

#define XML_ENCODE_KEY_TEMPLATE   "<EncryptedKey><EncryptionMethod Algorithm=\"RSA\"/><CipherData><CipherValue>%s</CipherValue></CipherData></EncryptedKey>"
 

Functions

UINT32 strtrim (UINT8 *s)
 Removes leading and ending whitespaces (chars<=32) from a zero terminated string. More...
 
UINT32 toLower (UINT8 *a_string)
 
UINT8bytes2hex (const void *bytes, UINT32 len)
 Converts the byte array to a hex string. More...
 
SINT32 memtrim (UINT8 *dest, const UINT8 *src, UINT32 size)
 Removes leading and ending whitespaces (chars<=32) from a byte array. More...
 
char * strins (const char *src, UINT32 pos, const char *ins)
 Inserts a String ins in a String src starting after pos chars. More...
 
char * strins (const char *src, const char *pos, const char *ins)
 Inserts a String ins in a String src starting at the char pos points to. More...
 
void logMemoryUsage ()
 Log information about the current memory (heap) usage. More...
 
SINT32 getcurrentTime (timespec &t)
 Gets the current Systemtime in milli seconds. More...
 
SINT32 getcurrentTimeMillis (UINT64 &u64Time)
 Gets the current Systemtime in milli seconds. More...
 
SINT32 getcurrentTimeMicros (UINT64 &u64Time)
 Gets the current Systemtime in micros seconds. More...
 
SINT32 initRandom ()
 
SINT32 compDate (struct tm *date1, struct tm *date2)
 
SINT32 getRandom (UINT32 *val)
 Gets 32 random bits. More...
 
SINT32 getRandom (UINT16 *val)
 Gets 16 random bits. More...
 
SINT32 getRandom (UINT64 *val)
 
SINT32 getRandom (UINT8 *buff, UINT32 len)
 Gets some random bytes. More...
 
SINT32 msSleep (UINT32 ms)
 Sleeps ms milliseconds. More...
 
SINT32 sSleep (UINT32 sec)
 Sleeps sec Seconds. More...
 
UINT32 getMemoryUsage ()
 
SINT32 getDOMChildByName (const DOMNode *pNode, const char *const name, DOMElement *&child, bool deep)
 
SINT32 getDOMChildByName (const DOMNode *pNode, const XMLCh *const name, DOMNode *&a_child, bool deep)
 
SINT32 getDOMChildByName (const DOMNode *pNode, const char *const name, DOMNode *&a_child, bool deep)
 
SINT32 getSignatureElements (DOMNode *parent, DOMNode **signatureNodes, UINT32 *length)
 
SINT32 integrateDOMNode (const DOMNode *srcNode, DOMNode *dstNode, bool recursive, bool replace)
 integrates the source node in the destination Node. More...
 
bool equals (const XMLCh *const e1, const char *const e2)
 
void initDOMParser ()
 
XERCES_CPP_NAMESPACE::DOMDocument * parseDOMDocument (const UINT8 *const buff, UINT32 len)
 Parses a buffer containing an XML document and returns this document. More...
 
XERCES_CPP_NAMESPACE::DOMDocument * parseDOMDocument (const UINT8 *const pathOrURL)
 parses a file via path or URL More...
 
void releaseDOMParser ()
 
SINT32 getNodeName (const DOMNode *const pElem, UINT8 *value, UINT32 *valuelen)
 
SINT32 getDOMElementValue (const DOMNode *const pElem, UINT8 *value, UINT32 *valuelen)
 Returns the content of the text node(s) under elem as null-terminated C String. More...
 
SINT32 getDOMElementAttribute (const DOMNode *const elem, const char *attrName, UINT8 *value, UINT32 *len)
 
SINT32 getDOMElementAttribute (const DOMNode *const elem, const char *attrName, SINT32 *value)
 
DOMElement * createDOMElement (XERCES_CPP_NAMESPACE::DOMDocument *pOwnerDoc, const char *const name)
 Creates a new DOMElement with the given name which belongs to the DOMDocument owernDoc. More...
 
DOMText * createDOMText (XERCES_CPP_NAMESPACE::DOMDocument *pOwnerDoc, const char *const text)
 Creates a new DOMText with the given value which belongs to the DOMDocument owernDoc. More...
 
SINT32 setDOMElementAttribute (DOMNode *pElem, const char *attrName, const char *value)
 
SINT32 setDOMElementAttribute (DOMNode *pElem, const char *attrName, const UINT8 *value)
 
SINT32 setCurrentTimeMilliesAsDOMAttribute (DOMNode *pElem)
 
UINT8getTermsAndConditionsTemplateRefId (DOMNode *tcTemplateRoot)
 
SINT32 getDOMElementValue (const DOMElement *pElem, UINT32 &value, UINT32 defaultValue)
 Gets the value from an DOM-Element as UINT32. More...
 
SINT32 getDOMElementValue (const DOMElement *const pElem, UINT32 *value)
 
SINT32 setDOMElementValue (DOMElement *pElem, SINT32 value)
 
SINT32 setDOMElementValue (DOMElement *pElem, double floatValue)
 
SINT32 setDOMElementValue (DOMElement *pElem, const UINT64 text)
 Sets the decimal text representation of a 64bit integer as node value TODO: implement this for non-64bit platforms. More...
 
SINT32 setDOMElementAttribute (DOMNode *pElem, const char *attrName, UINT64 value)
 
SINT32 setDOMElementAttribute (DOMNode *pElem, const char *attrName, SINT64 value)
 
SINT32 setDOMElementAttribute (DOMNode *pElem, const char *attrName, SINT32 value)
 
SINT32 setDOMElementAttribute (DOMNode *pElem, const char *attrName, bool value)
 
SINT32 setDOMElementValue (DOMElement *pElem, bool value)
 
SINT32 getDOMElementValue (const DOMElement *const pElem, SINT32 *value)
 
SINT32 getDOMElementValue (const DOMElement *const pElem, double *value)
 
SINT32 getDOMElementValue (const DOMNode *const pElem, UINT64 &value)
 
SINT32 getDOMElementValue (const DOMElement *const pElem, SINT64 &value)
 
SINT32 encryptXMLElement (DOMNode *node, CAASymCipher *pRSA)
 The resulting encrypted xml struct is as follows: More...
 
UINT8encryptXMLElement (UINT8 *inbuff, UINT32 inlen, UINT32 &outlen, CAASymCipher *pRSA)
 Encrypts an XML-Element by wrapping it with: More...
 
SINT32 decryptXMLElement (DOMNode *node, CAASymCipher *pRSA)
 Replaces a DOM element with a deencrypted version of this element. More...
 
UINT8readFile (const UINT8 *const name, UINT32 *size)
 ONLY_LOCAL_PROXY or first. More...
 
SINT32 saveFile (const UINT8 *const name, const UINT8 *const buff, UINT32 buffSize)
 
SINT32 parseUINT16 (const UINT8 *str, UINT16 &value)
 Parses a timestamp in JDBC timestamp escape format (as it comes from the BI) and outputs the value in milliseconds since the epoch. More...
 
SINT32 parseU64 (const UINT8 *str, UINT64 &value)
 Parses a 64bit unsigned integer. More...
 
SINT32 parseS64 (const UINT8 *str, SINT64 &value)
 Parses a 64bit signed integer. More...
 
SINT32 readPasswd (UINT8 *buff, UINT32 len)
 Read a passwd (i.e. More...
 
XERCES_CPP_NAMESPACE::DOMDocument * createDOMDocument ()
 Parses a timestamp in JDBC timestamp escape format (as it comes from the BI) and outputs the value in seconds since the epoch. More...
 
SINT32 setDOMElementValue (DOMElement *pElem, UINT32 value)
 
SINT32 setDOMElementValue (DOMElement *pElem, const UINT8 *value)
 
SINT32 setDOMElementAttribute (DOMNode *pElem, const char *attrName, UINT32 value)
 
SINT32 getDOMElementAttribute (const DOMNode *const elem, const char *attrName, UINT32 &value)
 
SINT32 decodeXMLEncryptedKey (UINT8 *key, UINT32 *keylen, const UINT8 *const xml, UINT32 xmllen, CAASymCipher *pRSA)
 
SINT32 decodeXMLEncryptedKey (UINT8 *key, UINT32 *keylen, const DOMNode *root, CAASymCipher *pRSA)
 
void __encryptKey (UINT8 *key, UINT32 keylen, UINT8 *outBuff, UINT32 *outLen, CAASymCipher *pRSA)
 
SINT32 encodeXMLEncryptedKey (UINT8 *key, UINT32 keylen, UINT8 *xml, UINT32 *xmllen, CAASymCipher *pRSA)
 
SINT32 encodeXMLEncryptedKey (UINT8 *key, UINT32 keylen, DOMElement *&elemRootEncodedKey, XERCES_CPP_NAMESPACE::DOMDocument *docOwner, CAASymCipher *pRSA)
 
DOMNodeList * getElementsByTagName (DOMElement *pElem, const char *const name)
 
SINT32 getLastDOMChildByName (const DOMNode *pNode, const char *const name, DOMElement *&a_child)
 
SINT32 getLastDOMChildByName (const DOMNode *pNode, const char *const name, DOMNode *&a_child)
 
SINT32 getLastDOMChildByName (const DOMNode *pNode, const XMLCh *const name, DOMNode *&a_child)
 
SINT32 getDOMElementAttribute (const DOMNode *const elem, const char *attrName, bool &value)
 
SINT32 getDOMElementAttribute (const DOMNode *const elem, const char *attrName, SINT64 &value)
 
SINT32 getDOMElementAttribute (const DOMNode *const elem, const char *attrName, UINT64 &value)
 
SINT32 getDOMElementValue (const DOMElement *const pElem, UINT16 *value)
 
void formatBytesPerSecond (UINT8 *buff, UINT32 buffsize, UINT64 bytespersecond)
 

Variables

XercesDOMParser * theDOMParser =NULL
 
CAMutextheParseDOMDocumentLock = NULL
 

Macro Definition Documentation

◆ XML_ENCODE_KEY_TEMPLATE

#define XML_ENCODE_KEY_TEMPLATE   "<EncryptedKey><EncryptionMethod Algorithm=\"RSA\"/><CipherData><CipherValue>%s</CipherValue></CipherData></EncryptedKey>"

Function Documentation

◆ __encryptKey()

void __encryptKey ( UINT8 key,
UINT32  keylen,
UINT8 outBuff,
UINT32 outLen,
CAASymCipher pRSA 
)

◆ bytes2hex()

UINT8* bytes2hex ( const void *  bytes,
UINT32  len 
)

Converts the byte array to a hex string.

the caller is responsible for deleting the string

References len.

Referenced by CAChain::getPrintableChainId(), and CAThread::start().

◆ compDate()

SINT32 compDate ( struct tm *  date1,
struct tm *  date2 
)

◆ createDOMDocument()

XERCES_CPP_NAMESPACE::DOMDocument* createDOMDocument ( )

Parses a timestamp in JDBC timestamp escape format (as it comes from the BI) and outputs the value in seconds since the epoch.

Creates an empty DOM DOcument.

Parameters
strTimestampthe string containing the timestamp
secondsan integer variable that gets the seconds value.
Todo:
think about timezone handling

Converts a timestamp (in seconds) to the String JDBC timestamp escape format (YYYY-MM-DD HH:MM:SS)

Parameters
secondsinteger value containing the timestamp in seconds since the epoch
strTimestampa string buffer that gets the result
lenthe buffer length
Todo:
think about timezone handling

Referenced by CACmdLnOptions::CACmdLnOptions(), CACmdLnOptions::createMixOnCDConfiguration(), CAFirstMix::doUserLogin_internal(), CAASymCipher::getPublicKeyAsXML(), CAAccountingInstance::handleAccountCertificate_internal(), CAFirstMix::handleTermsAndConditionsLogin(), CAFirstMix::init(), CAMix::initMixCascadeInfo(), CAReplayCtrlChannelMsgProc::initTimestampsMessageTemplate(), CAAccountingInstance::makeCCRequest(), CAAccountingInstance::makeInitialCCRequest(), CAAccountingInstance::prepareCCRequest(), CAReplayCtrlChannelMsgProc::proccessGetTimestamp(), CAReplayCtrlChannelMsgProc::proccessGotTimestamp(), CALastMix::processKeyExchange(), CAMiddleMix::processKeyExchange(), CAAccountingInstance::sendAILoginConfirmation(), CAReplayCtrlChannelMsgProc::sendGetTimestamp(), CAAbstractXMLSignable::setSignature(), CACmdLnOptions::setTermsAndConditionsList(), CAAccountingBIInterface::settleAll(), TermsAndConditions::TermsAndConditions(), and CAAbstractXMLEncodable::toXmlDocument().

◆ createDOMElement()

DOMElement* createDOMElement ( XERCES_CPP_NAMESPACE::DOMDocument *  pOwnerDoc,
const char *const  name 
)

◆ createDOMText()

DOMText * createDOMText ( XERCES_CPP_NAMESPACE::DOMDocument *  pOwnerDoc,
const char *const  text 
)

Creates a new DOMText with the given value which belongs to the DOMDocument owernDoc.

Referenced by CAASymCipher::addKeyPart().

◆ decodeXMLEncryptedKey() [1/2]

SINT32 decodeXMLEncryptedKey ( UINT8 key,
UINT32 keylen,
const DOMNode *  root,
CAASymCipher pRSA 
)

◆ decodeXMLEncryptedKey() [2/2]

SINT32 decodeXMLEncryptedKey ( UINT8 key,
UINT32 keylen,
const UINT8 *const  xml,
UINT32  xmllen,
CAASymCipher pRSA 
)

◆ decryptXMLElement()

SINT32 decryptXMLElement ( DOMNode *  node,
CAASymCipher pRSA 
)

◆ encodeXMLEncryptedKey() [1/2]

SINT32 encodeXMLEncryptedKey ( UINT8 key,
UINT32  keylen,
DOMElement *&  elemRootEncodedKey,
XERCES_CPP_NAMESPACE::DOMDocument *  docOwner,
CAASymCipher pRSA 
)

◆ encodeXMLEncryptedKey() [2/2]

SINT32 encodeXMLEncryptedKey ( UINT8 key,
UINT32  keylen,
UINT8 xml,
UINT32 xmllen,
CAASymCipher pRSA 
)

◆ encryptXMLElement() [1/2]

SINT32 encryptXMLElement ( DOMNode *  node,
CAASymCipher pRSA 
)

The resulting encrypted xml struct is as follows:

Replaces a DOM element with an encrypted version of this element.

  * <EncryptedData Type='http://www.w3.org/2001/04/xmlenc#Element'>
  *   <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
  *   <ds:KeyInfo xmlns:ds='http://www.w3.org/2000/09/xmldsig#'>
  *     <EncryptedKey>
  *       <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/>
  *       <CipherData>
  *         <CipherValue>...</CipherValue>
  *       </CipherData>
  *     </EncryptedKey>
  *   </ds:KeyInfo>
  *   <CipherData>
  *     <CipherValue>...</CipherValue>
  *   </CipherData>
  * </EncryptedData>
  *

References createDOMElement(), DOM_Output::dumpToMem(), E_SUCCESS, CABase64::encode(), CASymCipher::encryptCBCwithPKCS7(), CAASymCipher::encryptOAEP(), getRandom(), setDOMElementValue(), CASymCipher::setIV(), and CASymCipher::setKey().

Referenced by CALocalProxy::processKeyExchange().

◆ encryptXMLElement() [2/2]

UINT8* encryptXMLElement ( UINT8 inbuff,
UINT32  inlen,
UINT32 outlen,
CAASymCipher pRSA 
)

Encrypts an XML-Element by wrapping it with:

ONLY_LOCAL_PROXY or first.

 * \<EncryptedData Type='http://www.w3.org/2001/04/xmlenc#Element'>
 *    \<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
 *   \<ds:KeyInfo xmlns:ds='http://www.w3.org/2000/09/xmldsig#'>
 *      \<EncryptedKey>
 *        \<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/>
 *        \<CipherData\>
 *          \<CipherValue>...\</CipherValue>
 *        \</CipherData>
 *      \</EncryptedKey>
 *    \</ds:KeyInfo>
 *    \<CipherData>
 *      \<CipherValue>...\</CipherValue>
 *    \</CipherData>
 *  \</EncryptedData>
 *
Returns
a buffer with the encyrpted element (the caller is responsible for freeing it), or NULL

References CABase64::encode(), CASymCipher::encryptCBCwithPKCS7(), CAASymCipher::encryptOAEP(), getRandom(), CASymCipher::setIV(), and CASymCipher::setKey().

◆ equals()

bool equals ( const XMLCh *const  e1,
const char *const  e2 
)

◆ formatBytesPerSecond()

void formatBytesPerSecond ( UINT8 buff,
UINT32  buffsize,
UINT64  bytespersecond 
)

◆ getcurrentTime()

SINT32 getcurrentTime ( timespec &  t)

Gets the current Systemtime in milli seconds.

Parameters
bnTime- Big Number, in which the current time is placed
Return values
E_UNSPECIFIED,ifbnTime was NULL
E_UNKNOWN,ifan error occurs
E_SUCCESS,otherwise

References E_SUCCESS.

Referenced by CAChain::addChannel(), CAChain::forceImmediateResponsesInternal(), CAAccountingInstance::handleAccountCertificate_internal(), initRandom(), CAChain::processDownstream(), and CAConditionVariable::wait().

◆ getcurrentTimeMicros()

SINT32 getcurrentTimeMicros ( UINT64 u64Time)

Gets the current Systemtime in micros seconds.

Depending on the operating system, the time may not be so accurat.

Parameters
u64Time- 64 bit Integer, in which the current time is placed
Return values
E_UNKNOWN,ifan error occurs
E_SUCCESS,otherwise

References E_SUCCESS, and E_UNKNOWN.

Referenced by CAChain::CAChain(), CAFirstMixA::loop(), CALastMixA::loop(), CAFirstMixB::loop(), CALastMixB::loop(), CADatabase::measurePerformance(), CAReplayDatabase::measurePerformance(), CAFirstMixA::sendToUsers(), and CAChain::~CAChain().

◆ getcurrentTimeMillis()

SINT32 getcurrentTimeMillis ( UINT64 u64Time)

◆ getDOMChildByName() [1/3]

SINT32 getDOMChildByName ( const DOMNode *  pNode,
const char *const  name,
DOMElement *&  child,
bool  deep 
)

Referenced by CACmdLnOptions::addVisibleAddresses(), CAMix::checkCompatibility(), decodeXMLEncryptedKey(), decryptXMLElement(), CAFirstMix::doUserLogin_internal(), CAInfoService::getCascadeHeloXMLAsString(), getDOMChildByName(), CAListenerInterface::getInstance(), CACmdLnOptions::getMixXml(), CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), CAFirstMix::handleKeyInfoExtensions(), CAFirstMix::handleTermsAndConditionsExtension(), CAFirstMix::handleTermsAndConditionsLogin(), CAMix::initMixCascadeInfo(), CAAccountingInstance::makeCCRequest(), CAAccountingInstance::makeInitialCCRequest(), CACmdLnOptions::parseInfoServices(), CASignature::parseSignKeyXML(), CAAccountingInstance::prepareCCRequest(), CAReplayCtrlChannelMsgProc::proccessGetTimestamp(), CALastMix::processKeyExchange(), CAMiddleMix::processKeyExchange(), CALocalProxy::processKeyExchange(), CACmdLnOptions::processXmlConfiguration(), CAReplayControlChannel::processXMLMessage(), CAReplayCtrlChannelMsgProc::propagateCurrentReplayTimestamp(), CACmdLnOptions::setAccessControlCredential(), CACmdLnOptions::setAccountingDatabase(), CACmdLnOptions::setAccountingHardLimit(), CACmdLnOptions::setAccountingOptions(), CACmdLnOptions::setAccountingSoftLimit(), CACmdLnOptions::setCascadeNameFromOptions(), CACmdLnOptions::setCertificateOptions(), CACmdLnOptions::setDaemonMode(), CACmdLnOptions::setDynamicMix(), CACmdLnOptions::setGeneralOptions(), CACmdLnOptions::setInfoServices(), CACmdLnOptions::setKeepAliveTraffic(), CACmdLnOptions::setListenerInterfaces(), CACmdLnOptions::setLoggingOptions(), CACmdLnOptions::setMaxUsers(), CACmdLnOptions::setMinCascadeLength(), CACmdLnOptions::setMixCertificateVerification(), CACmdLnOptions::setMixDescription(), CACmdLnOptions::setMixID(), CACmdLnOptions::setMixName(), CACmdLnOptions::setMixType(), CACmdLnOptions::setNetworkOptions(), CACmdLnOptions::setNextMix(), CACmdLnOptions::setNextMixCertificate(), CACmdLnOptions::setNrOfFileDescriptors(), CACmdLnOptions::setOwnCertificate(), CACmdLnOptions::setOwnOperatorCertificate(), CACmdLnOptions::setPaymentInstance(), CACmdLnOptions::setPaymentReminder(), CACmdLnOptions::setPrepaidInterval(), CACmdLnOptions::setPrevMix(), CACmdLnOptions::setPrevMixCertificate(), CACmdLnOptions::setPriceCertificate(), CACmdLnOptions::setRessourceOptions(), CACmdLnOptions::setServerMonitoring(), CACmdLnOptions::setSettleInterval(), CACmdLnOptions::setSymChannelCipherAlgorithm(), CACmdLnOptions::setTargetInterfaces(), CACmdLnOptions::setTermsAndConditions(), CACmdLnOptions::setTermsAndConditionsList(), CACmdLnOptions::setTermsAndConditionsTemplates(), CACmdLnOptions::setTrustedRootCertificates(), CACmdLnOptions::setUserID(), CAXMLErrorMessage::setValues(), CASignature::setVerifyKey(), CAMultiSignature::signXML(), CACertStore::verifyMixCert(), CAMultiSignature::verifyXML(), and CASignature::verifyXML().

◆ getDOMChildByName() [2/3]

SINT32 getDOMChildByName ( const DOMNode *  pNode,
const char *const  name,
DOMNode *&  a_child,
bool  deep 
)

References E_UNKNOWN, and getDOMChildByName().

◆ getDOMChildByName() [3/3]

SINT32 getDOMChildByName ( const DOMNode *  pNode,
const XMLCh *const  name,
DOMNode *&  a_child,
bool  deep 
)

◆ getDOMElementAttribute() [1/6]

SINT32 getDOMElementAttribute ( const DOMNode *const  elem,
const char *  attrName,
bool &  value 
)

◆ getDOMElementAttribute() [2/6]

SINT32 getDOMElementAttribute ( const DOMNode *const  elem,
const char *  attrName,
SINT32 value 
)

◆ getDOMElementAttribute() [3/6]

SINT32 getDOMElementAttribute ( const DOMNode *const  elem,
const char *  attrName,
SINT64 value 
)

◆ getDOMElementAttribute() [4/6]

SINT32 getDOMElementAttribute ( const DOMNode *const  elem,
const char *  attrName,
UINT32 value 
)

◆ getDOMElementAttribute() [5/6]

SINT32 getDOMElementAttribute ( const DOMNode *const  elem,
const char *  attrName,
UINT64 value 
)

◆ getDOMElementAttribute() [6/6]

SINT32 getDOMElementAttribute ( const DOMNode *const  elem,
const char *  attrName,
UINT8 value,
UINT32 len 
)

◆ getDOMElementValue() [1/8]

SINT32 getDOMElementValue ( const DOMElement *const  pElem,
double *  value 
)

◆ getDOMElementValue() [2/8]

SINT32 getDOMElementValue ( const DOMElement *const  pElem,
SINT32 value 
)

◆ getDOMElementValue() [3/8]

SINT32 getDOMElementValue ( const DOMElement *const  pElem,
SINT64 value 
)

◆ getDOMElementValue() [4/8]

SINT32 getDOMElementValue ( const DOMElement *const  pElem,
UINT16 value 
)

◆ getDOMElementValue() [5/8]

SINT32 getDOMElementValue ( const DOMElement *const  pElem,
UINT32 value 
)

◆ getDOMElementValue() [6/8]

SINT32 getDOMElementValue ( const DOMElement *const  pElem,
UINT32 value,
UINT32  defaultValue 
)

Gets the value from an DOM-Element as UINT32.

If an error occurs, the default value is returned.

References E_SUCCESS, and getDOMElementValue().

◆ getDOMElementValue() [7/8]

SINT32 getDOMElementValue ( const DOMNode *const  pElem,
UINT64 value 
)

◆ getDOMElementValue() [8/8]

SINT32 getDOMElementValue ( const DOMNode *const  pElem,
UINT8 value,
UINT32 valuelen 
)

Returns the content of the text node(s) under elem as null-terminated C String.

If there is no text node len is set to 0.

TODO: Why is elem a DOM_Node and not a DOM_Element here?

Parameters
elemthe element which has a text node under it
valuea buffer that gets the text value
valuelenon call contains the buffer size, on return contains the number of bytes copied
Return values
E_SPACEif the buffer is too small
E_UNKNOWNif the element is NULL
E_SUCCESSotherwise

References ASSERT, E_SPACE, E_SUCCESS, and E_UNKNOWN.

Referenced by CACmdLnOptions::addVisibleAddresses(), CACertificate::decode(), decodeXMLEncryptedKey(), decryptXMLElement(), CAFirstMix::doUserLogin_internal(), getDOMElementValue(), CAListenerInterface::getInstance(), CAASymCipher::getKeyPart(), CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), CACmdLnOptions::parseInfoServices(), CALastMix::processKeyExchange(), CAMiddleMix::processKeyExchange(), CALocalProxy::processKeyExchange(), CACmdLnOptions::processXmlConfiguration(), CAReplayControlChannel::processXMLMessage(), CACmdLnOptions::setAccessControlCredential(), CACmdLnOptions::setAccountingDatabase(), CACmdLnOptions::setAccountingHardLimit(), CACmdLnOptions::setAccountingSoftLimit(), CACmdLnOptions::setCascadeNameFromOptions(), CACmdLnOptions::setDaemonMode(), CACmdLnOptions::setDynamicMix(), CACmdLnOptions::setInfoServices(), CACmdLnOptions::setKeepAliveTraffic(), CACmdLnOptions::setLoggingOptions(), CACmdLnOptions::setMaxUsers(), CACmdLnOptions::setMixCertificateVerification(), CACmdLnOptions::setMixID(), CACmdLnOptions::setMixName(), CACmdLnOptions::setMixType(), CACmdLnOptions::setNrOfFileDescriptors(), CACmdLnOptions::setPaymentReminder(), CACmdLnOptions::setPrepaidInterval(), CACmdLnOptions::setRessourceOptions(), CACmdLnOptions::setServerMonitoring(), CACmdLnOptions::setSettleInterval(), CASignature::setSignKey(), CACmdLnOptions::setTargetInterfaces(), CACmdLnOptions::setTermsAndConditionsTemplates(), CACmdLnOptions::setUserID(), CAXMLErrorMessage::setValues(), CASignature::setVerifyKey(), CAMultiSignature::verifyXML(), and CASignature::verifyXML().

◆ getElementsByTagName()

DOMNodeList* getElementsByTagName ( DOMElement *  pElem,
const char *const  name 
)

◆ getLastDOMChildByName() [1/3]

SINT32 getLastDOMChildByName ( const DOMNode *  pNode,
const char *const  name,
DOMElement *&  a_child 
)

◆ getLastDOMChildByName() [2/3]

SINT32 getLastDOMChildByName ( const DOMNode *  pNode,
const char *const  name,
DOMNode *&  a_child 
)

◆ getLastDOMChildByName() [3/3]

SINT32 getLastDOMChildByName ( const DOMNode *  pNode,
const XMLCh *const  name,
DOMNode *&  a_child 
)

References E_SUCCESS, E_UNKNOWN, and equals().

◆ getMemoryUsage()

UINT32 getMemoryUsage ( )

◆ getNodeName()

SINT32 getNodeName ( const DOMNode *const  pElem,
UINT8 value,
UINT32 valuelen 
)

References ASSERT, E_SPACE, E_SUCCESS, and E_UNKNOWN.

Referenced by CAMix::checkCompatibility().

◆ getRandom() [1/4]

SINT32 getRandom ( UINT16 val)

Gets 16 random bits.

Parameters
val- on return the bits are random
Return values
E_UNKNOWN,ifan error occured
E_SUCCESS,ifsuccessful

References ASSERT, E_SUCCESS, and E_UNKNOWN.

◆ getRandom() [2/4]

SINT32 getRandom ( UINT32 val)

◆ getRandom() [3/4]

SINT32 getRandom ( UINT64 val)

References ASSERT, E_SUCCESS, and E_UNKNOWN.

◆ getRandom() [4/4]

SINT32 getRandom ( UINT8 buff,
UINT32  len 
)

Gets some random bytes.

Parameters
buff- buff which is filled with randomness
len- number of bytes requested
Return values
E_UNKNOWN,ifan error occured
E_SUCCESS,ifsuccessful

References ASSERT, E_SUCCESS, E_UNKNOWN, and len.

◆ getSignatureElements()

SINT32 getSignatureElements ( DOMNode *  parent,
DOMNode **  signatureNodes,
UINT32 length 
)

◆ getTermsAndConditionsTemplateRefId()

UINT8* getTermsAndConditionsTemplateRefId ( DOMNode *  tcTemplateRoot)

◆ initDOMParser()

void initDOMParser ( )

◆ initRandom()

SINT32 initRandom ( )

◆ integrateDOMNode()

SINT32 integrateDOMNode ( const DOMNode *  srcNode,
DOMNode *  dstNode,
bool  recursive,
bool  replace 
)

integrates the source node in the destination Node.

TODO 1. test for XERCES >= 3.0.1

  1. specification
Todo:
: check!

References E_SUCCESS, E_UNKNOWN, equals(), INTEGRATE_NOT_ALLOWED_POSITIONS, and CAMsg::printMsg().

Referenced by CACmdLnOptions::setTermsAndConditionsList().

◆ logMemoryUsage()

void logMemoryUsage ( )

Log information about the current memory (heap) usage.

References CAMsg::printMsg().

◆ memtrim()

SINT32 memtrim ( UINT8 dest,
const UINT8 src,
UINT32  size 
)

Removes leading and ending whitespaces (chars<=32) from a byte array.

Parameters
srcinput byte array
destoutput byte array
sizesize of the input byte array
Return values
E_UNSPECIFIED,ifdest was NULL
Returns
size of output otherwise
Todo:
replace UINT32 size with SINT32 size

References E_UNSPECIFIED.

◆ msSleep()

SINT32 msSleep ( UINT32  ms)

◆ parseDOMDocument() [1/2]

XERCES_CPP_NAMESPACE::DOMDocument* parseDOMDocument ( const UINT8 *const  buff,
UINT32  len 
)

◆ parseDOMDocument() [2/2]

XERCES_CPP_NAMESPACE::DOMDocument* parseDOMDocument ( const UINT8 *const  pathOrURL)

parses a file via path or URL

References CAMutex::lock(), theDOMParser, theParseDOMDocumentLock, and CAMutex::unlock().

◆ parseS64()

SINT32 parseS64 ( const UINT8 str,
SINT64 value 
)

Parses a 64bit signed integer.

Note: If the value is out of range or not parseable an erro is returned.

Todo:
code if we do not have native UINT64

References E_SUCCESS, E_UNKNOWN, and len.

Referenced by getDOMElementAttribute(), and getDOMElementValue().

◆ parseU64()

SINT32 parseU64 ( const UINT8 str,
UINT64 value 
)

Parses a 64bit unsigned integer.

Note: If the value is out of range or not parseable an error is returned.

Todo:
code if we do not have native UINT64

References E_SUCCESS, E_UNKNOWN, and len.

Referenced by getDOMElementAttribute(), and getDOMElementValue().

◆ parseUINT16()

SINT32 parseUINT16 ( const UINT8 str,
UINT16 value 
)

Parses a timestamp in JDBC timestamp escape format (as it comes from the BI) and outputs the value in milliseconds since the epoch.

Parameters
strTimestampthe string containing the timestamp
valuean integer variable that gets the milliseconds value. Converts a timestamp (in seconds) to the String JDBC timestamp escape format (YYYY-MM-DD HH:MM:SS)
secondsinteger value containing the timestamp in seconds since the epoch
strTimestampa string buffer that gets the result
lenthe buffer length
Todo:
think about timezone handling

Parses a 16bit unsigned integer

References E_SUCCESS.

◆ readFile()

UINT8* readFile ( const UINT8 *const  name,
UINT32 size 
)

ONLY_LOCAL_PROXY or first.

References filesize32(), and O_BINARY.

Referenced by CALastMix::init(), and CAMiddleMix::init().

◆ readPasswd()

SINT32 readPasswd ( UINT8 buff,
UINT32  len 
)

Read a passwd (i.e.

without echoing the chars typed in)

References E_SUCCESS, flags, and len.

Referenced by CACmdLnOptions::setOwnCertificate().

◆ releaseDOMParser()

void releaseDOMParser ( )

◆ saveFile()

SINT32 saveFile ( const UINT8 *const  name,
const UINT8 *const  buff,
UINT32  buffSize 
)

◆ setCurrentTimeMilliesAsDOMAttribute()

SINT32 setCurrentTimeMilliesAsDOMAttribute ( DOMNode *  pElem)

◆ setDOMElementAttribute() [1/7]

SINT32 setDOMElementAttribute ( DOMNode *  pElem,
const char *  attrName,
bool  value 
)

◆ setDOMElementAttribute() [2/7]

SINT32 setDOMElementAttribute ( DOMNode *  pElem,
const char *  attrName,
const char *  value 
)

◆ setDOMElementAttribute() [3/7]

SINT32 setDOMElementAttribute ( DOMNode *  pElem,
const char *  attrName,
const UINT8 value 
)

References E_SUCCESS, and E_UNKNOWN.

◆ setDOMElementAttribute() [4/7]

SINT32 setDOMElementAttribute ( DOMNode *  pElem,
const char *  attrName,
SINT32  value 
)

◆ setDOMElementAttribute() [5/7]

SINT32 setDOMElementAttribute ( DOMNode *  pElem,
const char *  attrName,
SINT64  value 
)

◆ setDOMElementAttribute() [6/7]

SINT32 setDOMElementAttribute ( DOMNode *  pElem,
const char *  attrName,
UINT32  value 
)

◆ setDOMElementAttribute() [7/7]

SINT32 setDOMElementAttribute ( DOMNode *  pElem,
const char *  attrName,
UINT64  value 
)

◆ setDOMElementValue() [1/6]

SINT32 setDOMElementValue ( DOMElement *  pElem,
bool  value 
)

◆ setDOMElementValue() [2/6]

SINT32 setDOMElementValue ( DOMElement *  pElem,
const UINT64  text 
)

Sets the decimal text representation of a 64bit integer as node value TODO: implement this for non-64bit platforms.

Returns the content of the text node under elem as 64bit unsigned integer.

References E_SUCCESS, print64(), and setDOMElementValue().

◆ setDOMElementValue() [3/6]

SINT32 setDOMElementValue ( DOMElement *  pElem,
const UINT8 value 
)

References E_SUCCESS.

◆ setDOMElementValue() [4/6]

SINT32 setDOMElementValue ( DOMElement *  pElem,
double  floatValue 
)

References E_SUCCESS, and setDOMElementValue().

◆ setDOMElementValue() [5/6]

SINT32 setDOMElementValue ( DOMElement *  pElem,
SINT32  value 
)

◆ setDOMElementValue() [6/6]

SINT32 setDOMElementValue ( DOMElement *  pElem,
UINT32  value 
)

References E_SUCCESS, and setDOMElementValue().

◆ sSleep()

SINT32 sSleep ( UINT32  sec)

◆ strins() [1/2]

char* strins ( const char *  src,
const char *  pos,
const char *  ins 
)

Inserts a String ins in a String src starting at the char pos points to.

Returns a newly allocated String which must be freed using delete.

References strins().

◆ strins() [2/2]

char* strins ( const char *  src,
UINT32  pos,
const char *  ins 
)

Inserts a String ins in a String src starting after pos chars.

Returns a newly allocated String which must be freed using delete.

Referenced by strins().

◆ strtrim()

UINT32 strtrim ( UINT8 s)

Removes leading and ending whitespaces (chars<=32) from a zero terminated string.

Parameters
sinput string (null terminated)
Returns
new size of string
Return values
0means, that either s was NULL or that the new string has a zero length (that means, that the old string only contains whitespaces)

Referenced by CAListenerInterface::getInstance(), CAChain::getPrintableChainId(), CAMultiSignature::getSKI(), CAAccountingInstance::prepareCCRequest(), CACmdLnOptions::setAccountingDatabase(), CACmdLnOptions::setLoggingOptions(), CACmdLnOptions::setMixID(), and CACmdLnOptions::setTargetInterfaces().

◆ toLower()

UINT32 toLower ( UINT8 a_string)

References E_SUCCESS.

Referenced by CACmdLnOptions::setLoggingOptions().

Variable Documentation

◆ theDOMParser

XercesDOMParser* theDOMParser =NULL

◆ theParseDOMDocumentLock

CAMutex* theParseDOMDocumentLock = NULL