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 (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 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>"

Referenced by encodeXMLEncryptedKey().

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(), filesize32(), CAASymCipher::getPublicKeyAsXML(), CAAccountingInstance::handleAccountCertificate_internal(), CAFirstMix::handleTermsAndConditionsLogin(), CAFirstMix::init(), CAMix::initMixCascadeInfo(), CAReplayCtrlChannelMsgProc::initTimestampsMessageTemplate(), CAAccountingInstance::makeCCRequest(), CAAccountingInstance::makeInitialCCRequest(), CAAccountingInstance::prepareCCRequest(), CAReplayCtrlChannelMsgProc::proccessGetTimestamp(), CAReplayCtrlChannelMsgProc::proccessGotTimestamp(), CAMiddleMix::processKeyExchange(), CALastMix::processKeyExchange(), CAFirstMix::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 
)

Creates a new DOMElement with the given name which belongs to the DOMDocument owernDoc.

Referenced by CAASymCipher::addKeyPart(), CAMix::addMixInfo(), CAMix::appendCompatibilityInfo(), CACmdLnOptions::buildDefaultConfig(), CAFirstMix::doUserLogin_internal(), CACertStore::encode(), CACertificate::encode(), encodeXMLEncryptedKey(), encryptXMLElement(), filesize32(), CAInfoService::getCascadeHeloXMLAsString(), CACmdLnOptions::getMixXml(), CAASymCipher::getPublicKeyAsDOMElement(), CAASymCipher::getPublicKeyAsXML(), CASignature::getSignKey(), CAAccountingInstance::handleAccountCertificate_internal(), CAFirstMix::handleTermsAndConditionsLogin(), CAMix::initMixCascadeInfo(), CAReplayCtrlChannelMsgProc::initTimestampsMessageTemplate(), CAAccountingInstance::makeCCRequest(), CAAccountingInstance::makeInitialCCRequest(), CAAccountingInstance::prepareCCRequest(), CAReplayCtrlChannelMsgProc::proccessGetTimestamp(), CAReplayCtrlChannelMsgProc::proccessGotTimestamp(), CAMiddleMix::processKeyExchange(), CALastMix::processKeyExchange(), CAFirstMix::processKeyExchange(), CACmdLnOptions::processXmlConfiguration(), CAAccountingInstance::sendAILoginConfirmation(), CAReplayCtrlChannelMsgProc::sendGetTimestamp(), CACmdLnOptions::setMixName(), CACmdLnOptions::setNextMix(), CACmdLnOptions::setPrepaidInterval(), CACmdLnOptions::setPrevMix(), CACmdLnOptions::setSymChannelCipherAlgorithm(), CACmdLnOptions::setTargetInterfaces(), CAAccountingBIInterface::settleAll(), CAMultiSignature::signXML(), CAListenerInterface::toDOMElement(), and CAXMLErrorMessage::toXmlElement().

◆ 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(), filesize32(), and RSA_clone().

◆ decodeXMLEncryptedKey() [1/2]

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

◆ decodeXMLEncryptedKey() [2/2]

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

◆ decryptXMLElement()

SINT32 decryptXMLElement ( DOMNode *  node,
CAASymCipher pRSA 
)

◆ encodeXMLEncryptedKey() [1/2]

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

◆ encodeXMLEncryptedKey() [2/2]

SINT32 encodeXMLEncryptedKey ( UINT8 key,
UINT32  keylen,
DOMElement *&  elemRootEncodedKey,
XERCES_CPP_NAMESPACE::DOMDocument *  docOwner,
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(), and RSA_clone().

◆ 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::checkUserConnections(), fm_loopReadFromMix(), fm_loopSendToMix(), lm_loopReadFromMix(), lm_loopSendToMix(), CAFirstMixB::loop(), CALastMixA::loop(), CAFirstMixA::loop(), CALastMixB::loop(), CADatabase::measurePerformance(), CAReplayDatabase::measurePerformance(), mm_loopSendToMixAfter(), mm_loopSendToMixBefore(), 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 
)

References getDOMChildByName().

Referenced by CAMix::addMixInfo(), 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(), CALocalProxy::processKeyExchange(), CAMiddleMix::processKeyExchange(), CALastMix::processKeyExchange(), CAFirstMix::processKeyExchange(), CACmdLnOptions::processXmlConfiguration(), CAReplayControlChannel::processXMLMessage(), CAReplayCtrlChannelMsgProc::propagateCurrentReplayTimestamp(), CACmdLnOptions::saveToFile(), 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 XMLCh *const  name,
DOMNode *&  a_child,
bool  deep 
)

References E_SUCCESS, E_UNKNOWN, equals(), and getDOMChildByName().

Referenced by filesize32().

◆ getDOMChildByName() [3/3]

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

References E_UNKNOWN, and getDOMChildByName().

◆ getDOMElementAttribute() [1/6]

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

◆ getDOMElementAttribute() [2/6]

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

References E_SUCCESS, E_UNKNOWN, getDOMElementAttribute(), and len.

Referenced by filesize32().

◆ getDOMElementAttribute() [3/6]

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

◆ getDOMElementAttribute() [4/6]

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

◆ getDOMElementAttribute() [5/6]

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

◆ getDOMElementAttribute() [6/6]

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

◆ getDOMElementValue() [1/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(), filesize32(), getDOMElementValue(), CAListenerInterface::getInstance(), CAASymCipher::getKeyPart(), CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), CACmdLnOptions::parseInfoServices(), CALocalProxy::processKeyExchange(), CAMiddleMix::processKeyExchange(), CALastMix::processKeyExchange(), CAFirstMix::processKeyExchange(), CACmdLnOptions::processXmlConfiguration(), CAReplayControlChannel::processXMLMessage(), RSA_clone(), 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::setNextMix(), CACmdLnOptions::setNrOfFileDescriptors(), CACmdLnOptions::setPaymentReminder(), CACmdLnOptions::setPrepaidInterval(), CACmdLnOptions::setRessourceOptions(), CACmdLnOptions::setServerMonitoring(), CACmdLnOptions::setSettleInterval(), CASignature::setSignKey(), CACmdLnOptions::setTargetInterfaces(), CACmdLnOptions::setTermsAndConditionsList(), CACmdLnOptions::setTermsAndConditionsTemplates(), CACmdLnOptions::setUserID(), CAXMLErrorMessage::setValues(), CASignature::setVerifyKey(), CAMultiSignature::verifyXML(), and CASignature::verifyXML().

◆ getDOMElementValue() [2/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() [3/8]

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

◆ getDOMElementValue() [4/8]

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

◆ getDOMElementValue() [5/8]

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

◆ getDOMElementValue() [6/8]

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

◆ getDOMElementValue() [7/8]

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

◆ getDOMElementValue() [8/8]

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

◆ 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 
)

◆ getRandom() [1/3]

SINT32 getRandom ( UINT32 val)

◆ getRandom() [2/3]

SINT32 getRandom ( UINT64 val)

References ASSERT, E_SUCCESS, and E_UNKNOWN.

◆ getRandom() [3/3]

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, and E_UNKNOWN.

◆ getSignatureElements()

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

◆ getTermsAndConditionsTemplateRefId()

UINT8* getTermsAndConditionsTemplateRefId ( DOMNode *  tcTemplateRoot)

◆ initDOMParser()

void initDOMParser ( )

Referenced by filesize32(), and CALibProxytest::init().

◆ 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, integrateDOMNode(), and CAMsg::printMsg().

Referenced by integrateDOMNode(), RSA_clone(), and CACmdLnOptions::setTermsAndConditionsList().

◆ logMemoryUsage()

void logMemoryUsage ( )

Log information about the current memory (heap) usage.

References CAMsg::printMsg().

Referenced by fm_loopLog(), lm_loopLog(), and print64().

◆ 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(), 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(), getDOMElementValue(), and print64().

◆ 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(), getDOMElementValue(), and print64().

◆ 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.

Referenced by print64().

◆ readFile()

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

ONLY_LOCAL_PROXY or first.

References filesize32(), and O_BINARY.

Referenced by CAMiddleMix::init(), CALastMix::init(), print64(), and CAFirstMix::processKeyExchange().

◆ readPasswd()

SINT32 readPasswd ( UINT8 buff,
UINT32  len 
)

Read a passwd (i.e.

without echoing the chars typed in)

References E_SUCCESS, and flags.

Referenced by print64(), and 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/6]

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

◆ setDOMElementAttribute() [2/6]

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

◆ setDOMElementAttribute() [3/6]

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

◆ setDOMElementAttribute() [4/6]

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

◆ setDOMElementAttribute() [5/6]

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

◆ setDOMElementAttribute() [6/6]

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

◆ setDOMElementValue() [1/6]

SINT32 setDOMElementValue ( DOMElement *  pElem,
SINT32  value 
)

◆ setDOMElementValue() [2/6]

SINT32 setDOMElementValue ( DOMElement *  pElem,
double  floatValue 
)

References E_SUCCESS, and setDOMElementValue().

◆ setDOMElementValue() [3/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() [4/6]

SINT32 setDOMElementValue ( DOMElement *  pElem,
bool  value 
)

◆ setDOMElementValue() [5/6]

SINT32 setDOMElementValue ( DOMElement *  pElem,
UINT32  value 
)

References E_SUCCESS, and setDOMElementValue().

◆ setDOMElementValue() [6/6]

SINT32 setDOMElementValue ( DOMElement *  pElem,
const UINT8 value 
)

References E_SUCCESS.

Referenced by filesize32(), and RSA_clone().

◆ sSleep()

SINT32 sSleep ( UINT32  sec)

◆ strins() [1/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().

◆ strins() [2/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().

◆ 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(), CACmdLnOptions::setNextMix(), and CACmdLnOptions::setTargetInterfaces().

◆ toLower()

UINT32 toLower ( UINT8 a_string)

References E_SUCCESS.

Referenced by CACmdLnOptions::setLoggingOptions().

Variable Documentation

◆ theDOMParser

XercesDOMParser* theDOMParser =NULL

Referenced by releaseDOMParser().

◆ theParseDOMDocumentLock

CAMutex* theParseDOMDocumentLock = NULL

Referenced by releaseDOMParser().