|
Mixe for Privacy and Anonymity in the Internet
|
#include "CAASymCipher.hpp"Go to the source code of this file.
Defines | |
| #define | UNIVERSAL_ATTRIBUTE_LAST_UPDATE "lastUpdate" |
| #define | UNIVERSAL_NODE_LAST_UPDATE "LastUpdate" |
| #define | STR_VALUE_TRUE "true" |
| #define | STR_VALUE_FALSE "false" |
| #define | TMP_BUFF_SIZE 255 |
| #define | TMP_LOCALE_SIZE 3 |
| #define | TMP_DATE_SIZE 9 |
| #define | TEMPLATE_REFID_MAXLEN ((TMP_BUFF_SIZE) + (TMP_LOCALE_SIZE) + (TMP_DATE_SIZE) + 2) |
| #define | INTEGRATE_NOT_ALLOWED_POSITIONS |
Functions | |
| UINT32 | strtrim (UINT8 *) |
| Removes leading and ending whitespaces (chars<=32) from a zero terminated string. | |
| UINT32 | toLower (UINT8 *a_string) |
| SINT32 | memtrim (UINT8 *out, const UINT8 *in, UINT32 len) |
| Removes leading and ending whitespaces (chars<=32) from a byte array. | |
| UINT8 * | bytes2hex (const void *bytes, UINT32 len) |
| Converts the byte array to a hex string. | |
| char * | strins (const char *src, UINT32 pos, const char *ins) |
| Inserts a String ins in a String src starting after pos chars. | |
| 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. | |
| SINT32 | getcurrentTime (timespec &t) |
| Gets the current Systemtime in milli seconds. | |
| SINT32 | getcurrentTimeMillis (UINT64 &u64Time) |
| Gets the current Systemtime in milli seconds. | |
| SINT32 | getcurrentTimeMicros (UINT64 &u64Time) |
| Gets the current Systemtime in micros seconds. | |
| SINT32 | compDate (struct tm *date1, struct tm *date2) |
| SINT32 | initRandom () |
| SINT32 | getRandom (UINT8 *buff, UINT32 len) |
| Gets some random bytes. | |
| SINT32 | getRandom (UINT32 *val) |
| Gets 32 random bits. | |
| SINT32 | getRandom (UINT64 *val) |
| SINT32 | msSleep (UINT32 ms) |
| Sleeps ms milliseconds. | |
| SINT32 | sSleep (UINT32 sec) |
| Sleeps sec Seconds. | |
| UINT32 | getMemoryUsage () |
| SINT64 | filesize64 (int handle) |
| SINT32 | filesize32 (int handle) |
| XERCES_CPP_NAMESPACE::DOMDocument * | parseDOMDocument (const UINT8 *const buff, UINT32 len) |
| Parses a buffer containing an XML document and returns this document. | |
| XERCES_CPP_NAMESPACE::DOMDocument * | parseDOMDocument (const UINT8 *const pathOrURL) |
| parses a file via path or URL | |
| void | initDOMParser () |
| void | releaseDOMParser () |
| SINT32 | getDOMChildByName (const DOMNode *pNode, const XMLCh *const name, DOMNode *&child, bool deep=false) |
| SINT32 | getDOMChildByName (const DOMNode *pNode, const char *const name, DOMNode *&child, bool deep=false) |
| SINT32 | getDOMChildByName (const DOMNode *pNode, const char *const name, DOMElement *&child, bool deep=false) |
| SINT32 | getSignatureElements (DOMNode *parent, DOMNode **signatureNodes, UINT32 *length) |
| SINT32 | getDOMElementValue (const DOMNode *const pElem, UINT8 *value, UINT32 *len) |
| Returns the content of the text node(s) under elem as null-terminated C String. | |
| SINT32 | setDOMElementAttribute (DOMNode *pElem, const char *attrName, const UINT8 *value) |
| bool | equals (const XMLCh *const e1, const char *const e2) |
| SINT32 | getDOMElementAttribute (const DOMNode *const pElem, 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. | |
| 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. | |
| XERCES_CPP_NAMESPACE::DOMDocument * | createDOMDocument () |
| Creates an empty DOM DOcument. | |
| SINT32 | setDOMElementValue (DOMElement *pElem, UINT32 value) |
| SINT32 | setDOMElementValue (DOMElement *pElem, SINT32 value) |
| SINT32 | setDOMElementValue (DOMElement *pElem, const UINT64 text) |
| Returns the content of the text node under elem as 64bit unsigned integer. | |
| SINT32 | setDOMElementValue (DOMElement *pElem, const SINT64 text) |
| SINT32 | getNodeName (const DOMNode *const pElem, UINT8 *value, UINT32 *valuelen) |
| SINT32 | getDOMElementValue (const DOMNode *const pElem, UINT64 &value) |
| SINT32 | getDOMElementValue (const DOMElement *const pElem, SINT64 &value) |
| SINT32 | getDOMElementValue (const DOMElement *const pElem, UINT32 *value) |
| SINT32 | getDOMElementValue (const DOMElement *const pElem, SINT32 *value) |
| SINT32 | getDOMElementValue (const DOMElement *const pElem, UINT32 &value, UINT32 defaultValue) |
| Gets the value from an DOM-Element as UINT32. | |
| SINT32 | getDOMElementValue (const DOMElement *const pElem, UINT16 *value) |
| SINT32 | setDOMElementValue (DOMElement *pElem, const UINT8 *value) |
| SINT32 | getDOMElementValue (const DOMElement *const pElem, double *value) |
| SINT32 | setDOMElementAttribute (DOMNode *pElem, const char *attrName, bool value) |
| SINT32 | setDOMElementAttribute (DOMNode *pElem, const char *attrName, SINT32 value) |
| SINT32 | setDOMElementAttribute (DOMNode *pElem, const char *attrName, UINT32 value) |
| SINT32 | setDOMElementAttribute (DOMNode *pElem, const char *attrName, UINT64 value) |
| SINT32 | setDOMElementAttribute (DOMNode *pElem, const char *attrName, SINT64 value) |
| SINT32 | setDOMElementValue (DOMElement *pElem, double floatValue) |
| SINT32 | setDOMElementValue (DOMElement *pElem, bool value) |
| SINT32 | getDOMElementAttribute (const DOMNode *const pElem, const char *attrName, SINT64 &value) |
| SINT32 | getDOMElementAttribute (const DOMNode *const pElem, const char *attrName, UINT32 &value) |
| SINT32 | getDOMElementAttribute (const DOMNode *const pElem, const char *attrName, bool &value) |
| SINT32 | getDOMElementAttribute (const DOMNode *const pElem, const char *attrName, UINT8 *value, UINT32 *len) |
| DOMNodeList * | getElementsByTagName (DOMElement *pElem, const char *const name) |
| SINT32 | getLastDOMChildByName (const DOMNode *pNode, const XMLCh *const name, DOMNode *&a_child) |
| SINT32 | getLastDOMChildByName (const DOMNode *pNode, const char *const name, DOMNode *&a_child) |
| SINT32 | getLastDOMChildByName (const DOMNode *pNode, const char *const name, DOMElement *&a_child) |
| SINT32 | setCurrentTimeMilliesAsDOMAttribute (DOMNode *pElem) |
| UINT8 * | getTermsAndConditionsTemplateRefId (DOMNode *tcTemplateRoot) |
| 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) |
| SINT32 | decodeXMLEncryptedKey (UINT8 *key, UINT32 *keylen, const UINT8 *const xml, UINT32 xmllen, CAASymCipher *pRSA) |
| SINT32 | decodeXMLEncryptedKey (UINT8 *key, UINT32 *keylen, const DOMNode *pRoot, CAASymCipher *pRSA) |
| SINT32 | integrateDOMNode (const DOMNode *srcNode, DOMNode *dstNode, bool recursive, bool replace) |
| integrates the source node in the destination Node. | |
| SINT32 | encryptXMLElement (DOMNode *pElem, CAASymCipher *pRSA) |
| Replaces a DOM element with an encrypted version of this element. | |
| SINT32 | decryptXMLElement (DOMNode *pelem, CAASymCipher *pRSA) |
| Replaces a DOM element with a deencrypted version of this element. | |
| UINT8 * | encryptXMLElement (UINT8 *inbuff, UINT32 inlen, UINT32 &outlen, CAASymCipher *pRSA) |
| Encrypts an XML-Element by wrapping it with: | |
| void | set64 (UINT64 &op1, UINT32 op2) |
| void | set64 (UINT64 &dst, UINT64 src) |
| Sets the value of dst to the value of src. | |
| void | set64 (SINT64 &dst, SINT64 src) |
| Sets the value of dst to the value of src. | |
| void | setZero64 (UINT64 &op1) |
| void | setZero64 (SINT64 &op1) |
| void | add64 (UINT64 &op1, UINT32 op2) |
| void | inc64 (UINT64 &op1) |
| UINT32 | diff64 (const UINT64 &bigop, const UINT64 &smallop) |
| UINT32 | div64 (UINT64 &op1, UINT32 op2) |
| bool | isGreater64 (UINT64 &op1, UINT64 &op2) |
| bool | isGreater64 (SINT64 op1, SINT64 op2) |
| bool | isLesser64 (UINT64 &smallOp1, UINT64 &bigOp2) |
| bool | isEqual64 (UINT64 &op1, UINT64 &op2) |
| bool | isZero64 (UINT64 &op1) |
| bool | isZero64 (SINT64 &op1) |
| void | print64 (UINT8 *buff, UINT64 num) |
| UINT8 * | readFile (const UINT8 *const name, UINT32 *size) |
| SINT32 | saveFile (const UINT8 *const name, const UINT8 *const buff, UINT32 buffSize) |
| SINT32 | parseU64 (const UINT8 *str, UINT64 &value) |
| Parses a timestamp in JDBC timestamp escape format (as it comes from the BI) and outputs the value in milliseconds since the epoch. | |
| SINT32 | parseS64 (const UINT8 *str, SINT64 &value) |
| Parses a 64bit signed integer. | |
| SINT32 | readPasswd (UINT8 *buff, UINT32 len) |
| Read a passwd (i.e. | |
| void | logMemoryUsage () |
| Log information about the current memory (heap) usage. | |
| DSA * | DSA_clone (DSA *dsa) |
| Clones an OpenSSL DSA structure. | |
| RSA * | RSA_clone (RSA *rsa) |
| Clones an OpenSSL RSA structure. | |
| #define INTEGRATE_NOT_ALLOWED_POSITIONS |
(DOMNode::TREE_POSITION_ANCESTOR | DOMNode::TREE_POSITION_DESCENDANT | \
DOMNode::TREE_POSITION_EQUIVALENT | DOMNode::TREE_POSITION_SAME_NODE )
Definition at line 48 of file CAUtil.hpp.
Referenced by integrateDOMNode().
| #define STR_VALUE_FALSE "false" |
Definition at line 36 of file CAUtil.hpp.
Referenced by getDOMElementAttribute(), setDOMElementAttribute(), and setDOMElementValue().
| #define STR_VALUE_TRUE "true" |
Definition at line 35 of file CAUtil.hpp.
Referenced by getDOMElementAttribute(), setDOMElementAttribute(), and setDOMElementValue().
| #define TEMPLATE_REFID_MAXLEN ((TMP_BUFF_SIZE) + (TMP_LOCALE_SIZE) + (TMP_DATE_SIZE) + 2) |
Definition at line 42 of file CAUtil.hpp.
Referenced by CAMix::appendTermsAndConditionsExtension(), CAFirstMix::getTermsAndConditionsTemplate(), and CACmdLnOptions::setTermsAndConditionsTemplates().
| #define TMP_BUFF_SIZE 255 |
Definition at line 38 of file CAUtil.hpp.
Referenced by CACmdLnOptions::addVisibleAddresses(), CAMix::appendTermsAndConditionsExtension(), CAInfoService::getOperatorTnCsAsStrings(), CACmdLnOptions::getTermsAndConditions(), getTermsAndConditionsTemplateRefId(), CAFirstMix::handleTermsAndConditionsExtension(), CAFirstMix::handleTermsAndConditionsLogin(), CACmdLnOptions::parse(), CACmdLnOptions::setAccountingDatabase(), CACmdLnOptions::setCascadeNameFromOptions(), CACmdLnOptions::setDaemonMode(), CACmdLnOptions::setDynamicMix(), CACmdLnOptions::setInfoServices(), CACmdLnOptions::setLoggingOptions(), CACmdLnOptions::setMixCertificateVerification(), CACmdLnOptions::setMixID(), CACmdLnOptions::setMixName(), CACmdLnOptions::setMixType(), CACmdLnOptions::setOwnCertificate(), CACmdLnOptions::setServerMonitoring(), CACmdLnOptions::setTargetInterfaces(), CACmdLnOptions::setTermsAndConditionsList(), CACmdLnOptions::setTermsAndConditionsTemplates(), CACmdLnOptions::setUserID(), and CAMix::termsAndConditionsInfoNode().
| #define TMP_DATE_SIZE 9 |
Definition at line 40 of file CAUtil.hpp.
Referenced by getTermsAndConditionsTemplateRefId(), and CACmdLnOptions::setTermsAndConditionsList().
| #define TMP_LOCALE_SIZE 3 |
Definition at line 39 of file CAUtil.hpp.
Referenced by TermsAndConditions::addTranslation(), getTermsAndConditionsTemplateRefId(), CAFirstMix::handleTermsAndConditionsExtension(), CAFirstMix::handleTermsAndConditionsLogin(), and CACmdLnOptions::setTermsAndConditionsList().
| #define UNIVERSAL_ATTRIBUTE_LAST_UPDATE "lastUpdate" |
Definition at line 32 of file CAUtil.hpp.
Referenced by setCurrentTimeMilliesAsDOMAttribute().
| #define UNIVERSAL_NODE_LAST_UPDATE "LastUpdate" |
Definition at line 33 of file CAUtil.hpp.
Referenced by CACmdLnOptions::getMixXml().
Definition at line 293 of file CAUtil.hpp.
References __UINT64__t_::high, and __UINT64__t_::low.
Referenced by CALastMixA::loop(), CALastMixB::loop(), CAHttpClient::parseHTTPHeader(), CAMuxSocket::receive(), CASocket::receiveFullyT(), and CASocket::receiveLine().
Converts the byte array to a hex string.
the caller is responsible for deleting the string
Definition at line 90 of file CAUtil.cpp.
References len.
Referenced by CAChain::getPrintableChainId(), and CAThread::start().
{
if(bytes==NULL||len==0)
return NULL;
UINT8* buff=new UINT8[len*3+1];
UINT32 aktInd=0;
for(UINT32 i=0;i<len;i++)
{
UINT8 b1=((UINT8*)bytes)[i];
UINT8 b=(b1>>4);
if(b>9)
b+=55;
else
b+=48;
buff[aktInd++]=b;
b=(b1&0x0F);
if(b>9)
b+=55;
else
b+=48;
buff[aktInd++]=b;
buff[aktInd++]=32;
}
buff[len*3]=0;
return buff;
}
Definition at line 321 of file CAUtil.cpp.
{
//year
if(date1->tm_year != date2->tm_year)
{
return (date1->tm_year < date2->tm_year) ? -1 : 1;
}
if(date1->tm_mon != date2->tm_mon)
{
return (date1->tm_mon < date2->tm_mon) ? -1 : 1;
}
if(date1->tm_mday != date2->tm_mday)
{
return (date1->tm_mday < date2->tm_mday) ? -1 : 1;
}
return 0;
}
| XERCES_CPP_NAMESPACE::DOMDocument* createDOMDocument | ( | ) |
Creates an empty DOM DOcument.
Definition at line 881 of file CAUtil.cpp.
Referenced by CACmdLnOptions::CACmdLnOptions(), CACmdLnOptions::createMixOnCDConfiguration(), CAFirstMix::doUserLogin_internal(), CAXMLCostConfirmation::getInstance(), CAXMLPriceCert::getInstance(), 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().
{
DOMImplementation* pImpl=DOMImplementation::getImplementation();
return pImpl->createDocument();
}
| 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.
Definition at line 779 of file CAUtil.cpp.
Referenced by CAASymCipher::addKeyPart(), CAMix::appendCompatibilityInfo(), CAMix::appendTermsAndConditionsExtension(), CACmdLnOptions::buildDefaultConfig(), CAFirstMix::doUserLogin_internal(), CACertStore::encode(), CACertificate::encode(), encodeXMLEncryptedKey(), encryptXMLElement(), CAInfoService::getCascadeHeloXMLAsString(), CACmdLnOptions::getMixXml(), CAASymCipher::getPublicKeyAsDOMElement(), 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::setTargetInterfaces(), CAAccountingBIInterface::settleAll(), CAMultiSignature::signXML(), CAMix::termsAndConditionsInfoNode(), CAListenerInterface::toDOMElement(), CAXMLPriceCert::toXmlElement(), CAXMLBI::toXmlElement(), and CAXMLErrorMessage::toXmlElement().
{
XMLCh* n=XMLString::transcode(name);
DOMElement* ret=pOwnerDoc->createElement(n);
XMLString::release(&n);
return ret;
}
| 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.
Definition at line 787 of file CAUtil.cpp.
Referenced by CAASymCipher::addKeyPart().
{
XMLCh* t=XMLString::transcode(text);
DOMText* ret= pOwnerDoc->createTextNode(t);
XMLString::release(&t);
return ret;
}
| SINT32 decodeXMLEncryptedKey | ( | UINT8 * | key, |
| UINT32 * | keylen, | ||
| const UINT8 *const | xml, | ||
| UINT32 | xmllen, | ||
| CAASymCipher * | pRSA | ||
| ) |
Definition at line 1233 of file CAUtil.cpp.
References decodeXMLEncryptedKey(), E_UNKNOWN, and parseDOMDocument().
Referenced by decodeXMLEncryptedKey(), CAMiddleMix::processKeyExchange(), and CALastMix::processKeyExchange().
{
XERCES_CPP_NAMESPACE::DOMDocument* pDoc=parseDOMDocument(xml,xmllen);
if(pDoc == NULL)
{
return E_UNKNOWN;
}
DOMElement* root=pDoc->getDocumentElement();
if(root == NULL)
{
return E_UNKNOWN;
}
SINT32 ret=decodeXMLEncryptedKey(key,keylen,root,pRSA);
if (pDoc != NULL)
{
pDoc->release();
pDoc = NULL;
}
return ret;
}
| SINT32 decodeXMLEncryptedKey | ( | UINT8 * | key, |
| UINT32 * | keylen, | ||
| const DOMNode * | pRoot, | ||
| CAASymCipher * | pRSA | ||
| ) |
Definition at line 1254 of file CAUtil.cpp.
References CABase64::decode(), CAASymCipher::decrypt(), E_SUCCESS, E_UNKNOWN, getDOMChildByName(), and getDOMElementValue().
{
DOMNode* elemCipherValue=NULL;
if(getDOMChildByName(root,"CipherValue",elemCipherValue,true)!=E_SUCCESS)
return E_UNKNOWN;
UINT8 buff[2048];
UINT32 bufflen=2048;
if(getDOMElementValue(elemCipherValue,buff,&bufflen)!=E_SUCCESS)
return E_UNKNOWN;
CABase64::decode(buff,bufflen,buff,&bufflen);
pRSA->decrypt(buff,buff);
for(SINT32 i=127;i>=0;i--)
{
if(buff[i]!=0)
{
if(i>32)
*keylen=64;
else if(i>16)
*keylen=32;
else
*keylen=16;
}
}
memcpy(key,buff+128-(*keylen),(*keylen));
return E_SUCCESS;
}
| SINT32 decryptXMLElement | ( | DOMNode * | pelem, |
| CAASymCipher * | pRSA | ||
| ) |
Replaces a DOM element with a deencrypted version of this element.
Definition at line 1437 of file CAUtil.cpp.
References CABase64::decode(), CASymCipher::decrypt1CBCwithPKCS7(), CAASymCipher::decryptOAEP(), E_SUCCESS, E_UNKNOWN, equals(), getDOMChildByName(), getDOMElementValue(), len, parseDOMDocument(), CASymCipher::setIVs(), and CASymCipher::setKey().
Referenced by CAFirstMix::doUserLogin_internal().
{
XERCES_CPP_NAMESPACE::DOMDocument* doc=node->getOwnerDocument();
if(! equals(node->getNodeName(),"EncryptedData"))
return E_UNKNOWN;
DOMNode* elemKeyInfo=NULL;
getDOMChildByName(node,"ds:KeyInfo",elemKeyInfo,false);
DOMNode* elemEncKey=NULL;
getDOMChildByName(elemKeyInfo,"EncryptedKey",elemEncKey,false);
DOMNode* elemCipherValue=NULL;
getDOMChildByName(elemEncKey,"CipherValue",elemCipherValue,true);
UINT8* cipherValue=new UINT8[1000];
UINT32 len=1000;
if(getDOMElementValue(elemCipherValue,cipherValue,&len)!=E_SUCCESS)
{
delete[] cipherValue;
cipherValue = NULL;
return E_UNKNOWN;
}
CABase64::decode(cipherValue,len,cipherValue,&len);
if( pRSA->decryptOAEP(cipherValue,cipherValue,&len)!=E_SUCCESS||
len!=32)
{
delete[] cipherValue;
cipherValue = NULL;
return E_UNKNOWN;
}
CASymCipher *pSymCipher=new CASymCipher();
pSymCipher->setKey(cipherValue,false);
pSymCipher->setIVs(cipherValue+16);
DOMNode* elemCipherData=NULL;
getDOMChildByName(node,"CipherData",elemCipherData,false);
getDOMChildByName(elemCipherData,"CipherValue",elemCipherValue,false);
len=1000;
if(getDOMElementValue(elemCipherValue,cipherValue,&len)!=E_SUCCESS)
{
delete pSymCipher;
pSymCipher = NULL;
delete[] cipherValue;
cipherValue = NULL;
return E_UNKNOWN;
}
if(CABase64::decode(cipherValue,len,cipherValue,&len)!=E_SUCCESS)
{
delete pSymCipher;
pSymCipher = NULL;
delete[] cipherValue;
cipherValue = NULL;
return E_UNKNOWN;
}
SINT32 ret=pSymCipher->decrypt1CBCwithPKCS7(cipherValue,cipherValue,&len);
delete pSymCipher;
pSymCipher = NULL;
if(ret!=E_SUCCESS)
{
delete[] cipherValue;
cipherValue = NULL;
return E_UNKNOWN;
}
//now the need to parse the plaintext...
XERCES_CPP_NAMESPACE::DOMDocument* docPlain=parseDOMDocument(cipherValue,len);
delete[] cipherValue;
cipherValue = NULL;
DOMNode* elemPlainRoot=NULL;
if(docPlain==NULL)
return E_UNKNOWN;
if((elemPlainRoot=docPlain->getDocumentElement())==NULL)
{
if (docPlain != NULL)
{
docPlain->release();
docPlain = NULL;
}
return E_UNKNOWN;
}
elemPlainRoot=doc->importNode(elemPlainRoot,true);
DOMNode* parent=node->getParentNode();
if(parent->getNodeType()==DOMNode::DOCUMENT_NODE)
{
DOMNode* n=parent->removeChild(node);
if (n != NULL)
{
n->release();
n = NULL;
}
parent->appendChild(elemPlainRoot);
}
else
{
DOMNode* n=parent->replaceChild(elemPlainRoot,node);
if (n != NULL)
{
n->release();
n = NULL;
}
}
if (docPlain != NULL)
{
docPlain->release();
docPlain = NULL;
}
return E_SUCCESS;
}
Definition at line 316 of file CAUtil.hpp.
Referenced by fm_loopReadFromMix(), CAInfoService::getStatusXMLAsString(), lm_loopReadFromMix(), CAFirstMixB::loop(), CAFirstMixA::loop(), CADatabase::measurePerformance(), CAReplayDatabase::measurePerformance(), CAHttpClient::parseHTTPHeader(), CAMuxSocket::receive(), CASocket::receiveFullyT(), CASocket::receiveLine(), CAASymCipher::testSpeed(), CASymCipher::testSpeed(), and CAChain::~CAChain().
Definition at line 325 of file CAUtil.hpp.
Referenced by CAInfoService::getStatusXMLAsString().
| DSA* DSA_clone | ( | DSA * | dsa | ) | [inline] |
Clones an OpenSSL DSA structure.
Definition at line 482 of file CAUtil.hpp.
Referenced by CASignature::clone(), CASignature::setSignKey(), and CASignature::setVerifyKey().
{
if(dsa==NULL)
return NULL;
DSA* tmpDSA=DSA_new();
tmpDSA->g=BN_dup(dsa->g);
tmpDSA->p=BN_dup(dsa->p);
tmpDSA->q=BN_dup(dsa->q);
tmpDSA->pub_key=BN_dup(dsa->pub_key);
if(dsa->priv_key!=NULL)
tmpDSA->priv_key=BN_dup(dsa->priv_key);
return tmpDSA;
}
| SINT32 encodeXMLEncryptedKey | ( | UINT8 * | key, |
| UINT32 | keylen, | ||
| UINT8 * | xml, | ||
| UINT32 * | xmllen, | ||
| CAASymCipher * | pRSA | ||
| ) |
Definition at line 1201 of file CAUtil.cpp.
References __encryptKey(), E_SUCCESS, len, and XML_ENCODE_KEY_TEMPLATE.
Referenced by CAMiddleMix::processKeyExchange(), and CAFirstMix::processKeyExchange().
{
#define XML_ENCODE_KEY_TEMPLATE "<EncryptedKey><EncryptionMethod Algorithm=\"RSA\"/><CipherData><CipherValue>%s</CipherValue></CipherData></EncryptedKey>"
UINT8 tmpBuff[1024];
UINT32 len=1024;
__encryptKey(key,keylen,tmpBuff,&len,pRSA);
sprintf((char*)xml,XML_ENCODE_KEY_TEMPLATE,tmpBuff);
*xmllen=strlen((char*)xml);
return E_SUCCESS;
}
| SINT32 encodeXMLEncryptedKey | ( | UINT8 * | key, |
| UINT32 | keylen, | ||
| DOMElement *& | elemRootEncodedKey, | ||
| XERCES_CPP_NAMESPACE::DOMDocument * | docOwner, | ||
| CAASymCipher * | pRSA | ||
| ) |
Definition at line 1212 of file CAUtil.cpp.
References __encryptKey(), createDOMElement(), E_SUCCESS, setDOMElementAttribute(), and setDOMElementValue().
{
elemRootEncodedKey=createDOMElement(docOwner,"EncryptedKey");
DOMElement* elem1=createDOMElement(docOwner,"EncryptionMethod");
setDOMElementAttribute(elem1,"Algorithm",(UINT8*)"RSA");
elemRootEncodedKey->appendChild(elem1);
DOMElement* elem2=createDOMElement(docOwner,"CipherData");
elem1->appendChild(elem2);
elem1=createDOMElement(docOwner,"CipherValue");
elem2->appendChild(elem1);
UINT8 tmpBuff[1024];
UINT32 tmpLen=1024;
__encryptKey(key,keylen,tmpBuff,&tmpLen,pRSA);
setDOMElementValue(elem1,tmpBuff);
return E_SUCCESS;
}
| SINT32 encryptXMLElement | ( | DOMNode * | node, |
| CAASymCipher * | pRSA | ||
| ) |
Replaces a DOM element with an encrypted version of this element.
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> *
Definition at line 1299 of file CAUtil.cpp.
References createDOMElement(), DOM_Output::dumpToMem(), E_SUCCESS, CABase64::encode(), CASymCipher::encrypt1CBCwithPKCS7(), CAASymCipher::encryptOAEP(), getRandom(), setDOMElementValue(), CASymCipher::setIVs(), and CASymCipher::setKey().
Referenced by CALocalProxy::processKeyExchange().
{
XERCES_CPP_NAMESPACE::DOMDocument* doc=NULL;
DOMNode* parent=NULL;
if(node->getNodeType()==DOMNode::DOCUMENT_NODE)
{
doc=(XERCES_CPP_NAMESPACE::DOMDocument*)node;
parent=doc;
node=doc->getDocumentElement();
}
else
{
doc=node->getOwnerDocument();
parent=node->getParentNode();
}
DOMElement* elemRoot=createDOMElement(doc,"EncryptedData");
DOMElement* elemKeyInfo=createDOMElement(doc,"ds:KeyInfo");
elemRoot->appendChild(elemKeyInfo);
DOMElement* elemEncKey=createDOMElement(doc,"EncryptedKey");
elemKeyInfo->appendChild(elemEncKey);
DOMElement* elemCipherData=createDOMElement(doc,"CipherData");
elemEncKey->appendChild(elemCipherData);
DOMElement* elemCipherValue=createDOMElement(doc,"CipherValue");
elemCipherData->appendChild(elemCipherValue);
UINT8 key[32];
getRandom(key,32);
UINT8* pBuff=new UINT8[1000];
UINT32 bufflen=255;
pRSA->encryptOAEP(key,32,pBuff,&bufflen);
UINT8* pOutBuff=new UINT8[1000];
UINT32 outbufflen=255;
CABase64::encode(pBuff,bufflen,pOutBuff,&outbufflen);
pOutBuff[outbufflen]=0;
setDOMElementValue(elemCipherValue,pOutBuff);
delete[] pOutBuff;
pOutBuff = NULL;
delete[] pBuff;
pBuff = NULL;
CASymCipher *pSymCipher=new CASymCipher();
pSymCipher->setKey(key,true);
pSymCipher->setIVs(key+16);
elemCipherData=createDOMElement(doc,"CipherData");
elemRoot->appendChild(elemCipherData);
elemCipherValue=createDOMElement(doc,"CipherValue");
elemCipherData->appendChild(elemCipherValue);
UINT8* b=DOM_Output::dumpToMem(node,&bufflen);
outbufflen=bufflen+1000;
pOutBuff=new UINT8[outbufflen];
pSymCipher->encrypt1CBCwithPKCS7(b,bufflen,pOutBuff,&outbufflen);
delete[] b;
b = NULL;
bufflen=outbufflen*3/2+1000;
pBuff=new UINT8[bufflen];
CABase64::encode(pOutBuff,outbufflen,pBuff,&bufflen);
pBuff[bufflen]=0;
setDOMElementValue(elemCipherValue,pBuff);
delete[] pOutBuff;
pOutBuff = NULL;
delete[] pBuff;
pBuff = NULL;
if(parent->getNodeType()==DOMNode::DOCUMENT_NODE)
{
DOMNode* n=parent->removeChild(node);
if (n != NULL)
{
n->release();
n = NULL;
}
parent->appendChild(elemRoot);
}
else
{
DOMNode* n=parent->replaceChild(elemRoot,node);
if (n != NULL)
{
n->release();
n = NULL;
}
}
return E_SUCCESS;
}
| UINT8* encryptXMLElement | ( | UINT8 * | inbuff, |
| UINT32 | inlen, | ||
| UINT32 & | outlen, | ||
| CAASymCipher * | pRSA | ||
| ) |
Encrypts an XML-Element by wrapping it with:
* \<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> *
Definition at line 1401 of file CAUtil.cpp.
References CABase64::encode(), CASymCipher::encrypt1CBCwithPKCS7(), CAASymCipher::encryptOAEP(), getRandom(), CASymCipher::setIVs(), and CASymCipher::setKey().
{
const char* XML_ENC_TEMPLATE="<EncryptedData><ds:KeyInfo><EncryptedKey><CipherData><CipherValue>%s</CipherValue></CipherData></EncryptedKey></ds:KeyInfo><CipherData><CipherValue>%s</CipherValue></CipherData></EncryptedData>";
UINT8 key[32];
getRandom(key,32);
UINT8 buff[1000];
UINT32 bufflen=255;
pRSA->encryptOAEP(key,32,buff,&bufflen);
UINT8 keyoutbuff[1000];
UINT32 keyoutbufflen=255;
CABase64::encode(buff,bufflen,keyoutbuff,&keyoutbufflen);
keyoutbuff[keyoutbufflen]=0;
CASymCipher* pSymCipher=new CASymCipher();
pSymCipher->setKey(key,true);
pSymCipher->setIVs(key+16);
UINT32 msgoutbufflen=inlen+1000;
UINT8* msgoutbuff=new UINT8[msgoutbufflen];
pSymCipher->encrypt1CBCwithPKCS7(inbuff,inlen,msgoutbuff,&msgoutbufflen);
delete pSymCipher;
pSymCipher = NULL;
UINT32 encmsgoutbufflen=msgoutbufflen*3/2+1000;
UINT8* encmsgoutbuff=new UINT8[encmsgoutbufflen];
CABase64::encode(msgoutbuff,msgoutbufflen,encmsgoutbuff,&encmsgoutbufflen);
delete[] msgoutbuff;
msgoutbuff = NULL;
encmsgoutbuff[encmsgoutbufflen]=0;
msgoutbufflen=encmsgoutbufflen+1000;
msgoutbuff=new UINT8[msgoutbufflen];
sprintf((char*)msgoutbuff,XML_ENC_TEMPLATE,keyoutbuff,encmsgoutbuff);
outlen=strlen((char*)msgoutbuff);
delete[] encmsgoutbuff;
encmsgoutbuff = NULL;
return msgoutbuff;
}
| bool equals | ( | const XMLCh *const | e1, |
| const char *const | e2 | ||
| ) |
Definition at line 617 of file CAUtil.cpp.
References equals().
Referenced by CACmdLnOptions::addVisibleAddresses(), CACertificate::decode(), decryptXMLElement(), CAFirstMix::doUserLogin_internal(), equals(), getDOMChildByName(), getLastDOMChildByName(), getSignatureElements(), CAFirstMix::handleTermsAndConditionsLogin(), CAMix::initMixCascadeInfo(), integrateDOMNode(), CASignature::parseSignKeyXML(), CALocalProxy::processKeyExchange(), CAMiddleMix::processKeyExchange(), CAFirstMix::processKeyExchange(), CAReplayControlChannel::processXMLMessage(), CAASymCipher::setPublicKeyAsDOMNode(), CASignature::setSignKey(), CAXMLCostConfirmation::setValues(), CAXMLBI::setValues(), CAXMLPriceCert::setValues(), and CASignature::setVerifyKey().
{
XMLCh* e3=XMLString::transcode(e2);
bool ret=XMLString::equals(e1,e3);
XMLString::release(&e3);
return ret;
}
| SINT32 filesize32 | ( | int | handle | ) | [inline] |
Definition at line 100 of file CAUtil.hpp.
References E_UNKNOWN.
Referenced by readFile(), and CACmdLnOptions::readXmlConfiguration().
{
#ifdef _WIN32
return _filelength(handle);
#else
struct stat info;
if(fstat(handle, &info) != 0)
return E_UNKNOWN;
return info.st_size;
#endif
}
| SINT64 filesize64 | ( | int | handle | ) | [inline] |
| SINT32 getcurrentTime | ( | timespec & | t | ) |
Gets the current Systemtime in milli seconds.
| bnTime | - Big Number, in which the current time is placed |
| E_UNSPECIFIED,if | bnTime was NULL |
| E_UNKNOWN,if | an error occurs |
| E_SUCCESS,otherwise |
Definition at line 225 of file CAUtil.cpp.
References E_SUCCESS.
Referenced by CAChain::addChannel(), CAChain::forceImmediateResponsesInternal(), CAAccountingInstance::handleAccountCertificate_internal(), initRandom(), CAChain::processDownstream(), and CAConditionVariable::wait().
{
#ifdef _WIN32
timeb timebuffer;
ftime(&timebuffer);
/* Hack what should be solved better...*/
t.tv_sec=timebuffer.time;
t.tv_nsec=timebuffer.millitm*1000000;
/* end of hack..*/
return E_SUCCESS;
#else //we dont use ftime due to a bug in glibc2.0
//we use gettimeofday() in order to get the millis...
struct timeval tv;
gettimeofday(&tv,NULL); //getting millis...
t.tv_sec=tv.tv_sec;
t.tv_nsec=tv.tv_usec*1000;
return E_SUCCESS;
#endif
}
| SINT32 getcurrentTimeMicros | ( | UINT64 & | u64Time | ) |
Gets the current Systemtime in micros seconds.
Depending on the operating system, the time may not be so accurat.
| u64Time | - 64 bit Integer, in which the current time is placed |
| E_UNKNOWN,if | an error occurs |
| E_SUCCESS,otherwise |
Definition at line 278 of file CAUtil.cpp.
References E_SUCCESS, and E_UNKNOWN.
Referenced by CAChain::CAChain(), fm_loopReadFromMix(), fm_loopSendToMix(), lm_loopReadFromMix(), lm_loopSendToMix(), CALastMixA::loop(), CAFirstMixB::loop(), CAFirstMixA::loop(), CALastMixB::loop(), CADatabase::measurePerformance(), CAReplayDatabase::measurePerformance(), mm_loopSendToMixAfter(), mm_loopSendToMixBefore(), CAFirstMixA::sendToUsers(), and CAChain::~CAChain().
{
#ifdef _WIN32
timeb timebuffer;
ftime(&timebuffer);
/* Hack what should be solved better...*/
u64Time=((UINT64)timebuffer.time)*1000000+((UINT64)timebuffer.millitm)*1000;
/* end of hack..*/
return E_SUCCESS;
#else //we dont use ftime due to a bug in glibc2.0
//we use gettimeofday() in order to get the millis...
struct timeval tv;
gettimeofday(&tv,NULL); //getting millis...
#ifdef HAVE_NATIVE_UINT64
u64Time=((UINT64)tv.tv_sec)*1000000+((UINT64)tv.tv_usec);
return E_SUCCESS;
#else
return E_UNKNOWN;
#endif
#endif
}
| SINT32 getcurrentTimeMillis | ( | UINT64 & | u64Time | ) |
Gets the current Systemtime in milli seconds.
| u64Time | - 64 bit Integer, in which the current time is placed |
| E_UNKNOWN,if | an error occurs |
| E_SUCCESS,otherwise |
Definition at line 250 of file CAUtil.cpp.
References E_SUCCESS, and E_UNKNOWN.
Referenced by CAFirstMixChannelList::add(), CATempIPBlockList::checkIP(), CATempIPBlockList::cleanupThreadMainLoop(), CAFirstMixA::closeConnection(), fm_loopReadFromMix(), CAInfoService::getCascadeHeloXMLAsString(), CACmdLnOptions::getMixXml(), CAInfoService::getStatusXMLAsString(), CAAccountingInstance::handleCostConfirmation_internal(), CATempIPBlockList::insertIP(), lm_loopReadFromMix(), CALastMixA::loop(), CAFirstMixB::loop(), CAHttpClient::parseHTTPHeader(), CAMuxSocket::receive(), CASocket::receiveFullyT(), CASocket::receiveLine(), CAInfoService::sendCascadeHelo(), CASocket::sendFullyTimeOut(), CAInfoService::sendMixHelo(), CAInfoService::sendStatus(), setCurrentTimeMilliesAsDOMAttribute(), CAMix::start(), CAASymCipher::testSpeed(), and CASymCipher::testSpeed().
{
#ifdef _WIN32
timeb timebuffer;
ftime(&timebuffer);
/* Hack what should be solved better...*/
u64Time=((UINT64)timebuffer.time)*1000+((UINT64)timebuffer.millitm);
/* end of hack..*/
return E_SUCCESS;
#else //we dont use ftime due to a bug in glibc2.0
//we use gettimeofday() in order to get the millis...
struct timeval tv;
gettimeofday(&tv,NULL); //getting millis...
#ifdef HAVE_NATIVE_UINT64
u64Time=((UINT64)tv.tv_sec)*1000+((UINT64)tv.tv_usec)/1000;
return E_SUCCESS;
#else
return E_UNKNOWN;
#endif
#endif
}
| SINT32 getDOMChildByName | ( | const DOMNode * | pNode, |
| const XMLCh *const | name, | ||
| DOMNode *& | child, | ||
| bool | deep = false |
||
| ) |
Definition at line 434 of file CAUtil.cpp.
References E_SUCCESS, E_UNKNOWN, equals(), and getDOMChildByName().
{
a_child=NULL;
if(pNode==NULL)
return E_UNKNOWN;
DOMNode *pChild=pNode->getFirstChild();
while(pChild!=NULL)
{
if(XMLString::equals(pChild->getNodeName(),name))
{
a_child=pChild;
return E_SUCCESS;
}
if(deep)
{
if(getDOMChildByName(pChild,name,a_child,deep)==E_SUCCESS)
return E_SUCCESS;
}
pChild=pChild->getNextSibling();
}
return E_UNKNOWN;
}
| SINT32 getDOMChildByName | ( | const DOMNode * | pNode, |
| const char *const | name, | ||
| DOMNode *& | child, | ||
| bool | deep = false |
||
| ) |
Definition at line 457 of file CAUtil.cpp.
References E_UNKNOWN, and getDOMChildByName().
{
a_child=NULL;
if(pNode==NULL)
return E_UNKNOWN;
XMLCh* tmpName=XMLString::transcode((const char * const)name);
SINT32 ret=getDOMChildByName(pNode,tmpName,a_child,deep);
XMLString::release(&tmpName);
return ret;
}
| SINT32 getDOMChildByName | ( | const DOMNode * | pNode, |
| const char *const | name, | ||
| DOMElement *& | child, | ||
| bool | deep = false |
||
| ) |
Definition at line 430 of file CAUtil.cpp.
References getDOMChildByName().
Referenced by CACmdLnOptions::addVisibleAddresses(), CAMix::appendTermsAndConditionsExtension(), 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::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::setTargetInterfaces(), CACmdLnOptions::setTermsAndConditions(), CACmdLnOptions::setTermsAndConditionsList(), CACmdLnOptions::setTermsAndConditionsTemplates(), CACmdLnOptions::setTrustedRootCertificates(), CACmdLnOptions::setUserID(), CAXMLCostConfirmation::setValues(), CAXMLBI::setValues(), CAXMLErrorMessage::setValues(), CAXMLPriceCert::setValues(), CASignature::setVerifyKey(), CAMultiSignature::signXML(), CACertStore::verifyMixCert(), CAMultiSignature::verifyXML(), and CASignature::verifyXML().
{
return getDOMChildByName(pNode,name,(DOMNode*&)child,deep);
}
| SINT32 getDOMElementAttribute | ( | const DOMNode *const | pElem, |
| const char * | attrName, | ||
| SINT32 * | value | ||
| ) |
Definition at line 769 of file CAUtil.cpp.
References E_SUCCESS, E_UNKNOWN, getDOMElementAttribute(), and len.
{
UINT8 val[50];
UINT32 len=50;
if(getDOMElementAttribute(elem,attrName,val,&len)!=E_SUCCESS)
return E_UNKNOWN;
*value=atol((char*)val);
return E_SUCCESS;
}
| SINT32 getDOMElementAttribute | ( | const DOMNode *const | pElem, |
| const char * | attrName, | ||
| SINT64 & | value | ||
| ) |
Definition at line 993 of file CAUtil.cpp.
References E_SUCCESS, E_UNKNOWN, getDOMElementAttribute(), len, and parseS64().
{
UINT8 val[50];
UINT32 len=50;
if(getDOMElementAttribute(elem,attrName,val,&len)!=E_SUCCESS)
{
return E_UNKNOWN;
}
if(parseS64(val,value)!=E_SUCCESS)
{
return E_UNKNOWN;
}
return E_SUCCESS;
}
| SINT32 getDOMElementAttribute | ( | const DOMNode *const | pElem, |
| const char * | attrName, | ||
| UINT32 & | value | ||
| ) |
Definition at line 1023 of file CAUtil.cpp.
References E_SUCCESS, E_UNKNOWN, getDOMElementAttribute(), and len.
{
UINT8 val[50];
UINT32 len=50;
if(getDOMElementAttribute(elem,attrName,val,&len)!=E_SUCCESS)
return E_UNKNOWN;
long l=atol((char*)val);
if(l<0)
return E_UNKNOWN;
value=(UINT32)l;
return E_SUCCESS;
}
| SINT32 getDOMElementAttribute | ( | const DOMNode *const | pElem, |
| const char * | attrName, | ||
| bool & | value | ||
| ) |
Definition at line 1036 of file CAUtil.cpp.
References E_SUCCESS, E_UNKNOWN, E_UNSPECIFIED, getDOMElementAttribute(), len, STR_VALUE_FALSE, and STR_VALUE_TRUE.
{
UINT8 val[50];
UINT32 len=50;
if(getDOMElementAttribute(elem,attrName,val,&len) != E_SUCCESS)
{
return E_UNKNOWN;
}
SINT32 ret = E_UNSPECIFIED;
if(strncasecmp((char*)val, STR_VALUE_TRUE, strlen(STR_VALUE_TRUE)) == 0)
{
value = true;
ret = E_SUCCESS;
}
else if(strncasecmp((char*)val, STR_VALUE_FALSE, strlen(STR_VALUE_FALSE)) == 0)
{
value = false;
ret = E_SUCCESS;
}
return ret;
}
| SINT32 getDOMElementAttribute | ( | const DOMNode *const | pElem, |
| const char * | attrName, | ||
| UINT8 * | value, | ||
| UINT32 * | len | ||
| ) |
Definition at line 749 of file CAUtil.cpp.
References E_SPACE, E_SUCCESS, and E_UNKNOWN.
Referenced by CAMix::checkCompatibility(), getDOMElementAttribute(), CAListenerInterface::getInstance(), CAInfoService::getOperatorTnCsAsStrings(), getTermsAndConditionsTemplateRefId(), CAFirstMix::handleTermsAndConditionsExtension(), CAFirstMix::handleTermsAndConditionsLogin(), CAFirstMix::initMixParameters(), CALocalProxy::processKeyExchange(), CAMiddleMix::processKeyExchange(), CAFirstMix::processKeyExchange(), CACmdLnOptions::processXmlConfiguration(), CAReplayControlChannel::processXMLMessage(), CACmdLnOptions::setLoggingOptions(), CACmdLnOptions::setMixName(), CACmdLnOptions::setPaymentReminder(), CACmdLnOptions::setTermsAndConditionsList(), CAAccountingBIInterface::settleAll(), CAXMLCostConfirmation::setValues(), CAXMLBI::setValues(), CAXMLErrorMessage::setValues(), CASignature::setVerifyKey(), CAMix::termsAndConditionsInfoNode(), and CAMultiSignature::verifyXML().
{
if(elem==NULL||attrName==NULL||value==NULL||len==NULL||elem->getNodeType()!=DOMNode::ELEMENT_NODE)
return E_UNKNOWN;
XMLCh* name=XMLString::transcode(attrName);
const XMLCh* tmpCh=((DOMElement*)elem)->getAttribute(name);
XMLString::release(&name);
char* tmpStr=XMLString::transcode(tmpCh);
UINT32 l=strlen(tmpStr);
if(l>=*len)
{
XMLString::release(&tmpStr);
return E_SPACE;
}
*len=l;
memcpy(value,tmpStr,l+1);
XMLString::release(&tmpStr);
return E_SUCCESS;
}
| 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.
| DOM_Node | the element which has a text node under it |
| value | a buffer that gets the text value |
| len | on call contains the buffer size, on return contains the number of bytes copied |
If there is no text node len is set to 0.
TODO: Why is elem a DOM_Node and not a DOM_Element here?
| elem | the element which has a text node under it |
| value | a buffer that gets the text value |
| valuelen | on call contains the buffer size, on return contains the number of bytes copied |
| E_SPACE | if the buffer is too small |
| E_UNKNOWN | if the element is NULL |
| E_SUCCESS | otherwise |
Definition at line 715 of file CAUtil.cpp.
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(), CALocalProxy::processKeyExchange(), CAMiddleMix::processKeyExchange(), CALastMix::processKeyExchange(), CAFirstMix::processKeyExchange(), CACmdLnOptions::processXmlConfiguration(), CAReplayControlChannel::processXMLMessage(), 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(), CAXMLCostConfirmation::setValues(), CAXMLBI::setValues(), CAXMLErrorMessage::setValues(), CAXMLPriceCert::setValues(), CASignature::setVerifyKey(), CAMultiSignature::verifyXML(), and CASignature::verifyXML().
{
ASSERT(value!=NULL,"Value is null");
ASSERT(valuelen!=NULL,"ValueLen is null");
ASSERT(pElem!=NULL,"Element is NULL");
if(pElem==NULL)
return E_UNKNOWN;
DOMNode* pText=pElem->getFirstChild();
UINT32 spaceLeft=*valuelen;
*valuelen=0;
while(pText!=NULL)
{
if(pText->getNodeType()==DOMNode::TEXT_NODE)
{
const XMLCh* str=pText->getNodeValue();
char* tmpStr=XMLString::transcode(str);
UINT32 tmpStrLen=strlen(tmpStr);
if(tmpStrLen>=spaceLeft)
{
*valuelen=tmpStrLen+1;
XMLString::release(&tmpStr);
return E_SPACE;
}
memcpy(value+(*valuelen),tmpStr,tmpStrLen);
*valuelen+=tmpStrLen;
spaceLeft-=tmpStrLen;
XMLString::release(&tmpStr);
}
pText=pText->getNextSibling();
}
value[*valuelen]=0;
return E_SUCCESS;
}
| SINT32 getDOMElementValue | ( | const DOMNode *const | pElem, |
| UINT64 & | value | ||
| ) |
Definition at line 1145 of file CAUtil.cpp.
References ASSERT, E_SUCCESS, E_UNKNOWN, getDOMElementValue(), and parseU64().
{
ASSERT(pElem!=NULL, "Element is NULL");
UINT8 buf[256];
UINT32 bufLen = 256;
if(getDOMElementValue(pElem,buf,&bufLen)!=E_SUCCESS)
{
return E_UNKNOWN;
}
if(parseU64(buf, value)!=E_SUCCESS)
{
return E_UNKNOWN;
}
return E_SUCCESS;
}
| SINT32 getDOMElementValue | ( | const DOMElement *const | pElem, |
| SINT64 & | value | ||
| ) |
Definition at line 1162 of file CAUtil.cpp.
References ASSERT, E_SUCCESS, E_UNKNOWN, getDOMElementValue(), and parseS64().
{
ASSERT(pElem!=NULL, "Element is NULL");
UINT8 buf[256];
UINT32 bufLen = 256;
if(getDOMElementValue(pElem,buf,&bufLen)!=E_SUCCESS)
{
return E_UNKNOWN;
}
if(parseS64(buf, value)!=E_SUCCESS)
{
return E_UNKNOWN;
}
return E_SUCCESS;
}
| SINT32 getDOMElementValue | ( | const DOMElement *const | pElem, |
| UINT32 * | value | ||
| ) |
Definition at line 1093 of file CAUtil.cpp.
References ASSERT, E_SUCCESS, E_UNKNOWN, and getDOMElementValue().
{
ASSERT(value!=NULL,"Value is null");
ASSERT(pElem!=NULL,"Element is NULL");
UINT8 buff[255];
UINT32 buffLen=255;
if(getDOMElementValue(pElem,buff,&buffLen)!=E_SUCCESS)
return E_UNKNOWN;
*value=atol((char*)buff);
return E_SUCCESS;
}
| SINT32 getDOMElementValue | ( | const DOMElement *const | pElem, |
| SINT32 * | value | ||
| ) |
Definition at line 1106 of file CAUtil.cpp.
References ASSERT, E_SUCCESS, E_UNKNOWN, and getDOMElementValue().
{
ASSERT(value!=NULL,"Value is null");
ASSERT(pElem!=NULL,"Element is NULL");
UINT8 buff[255];
UINT32 buffLen=255;
if(getDOMElementValue(pElem,buff,&buffLen)!=E_SUCCESS)
return E_UNKNOWN;
*value=atol((char*)buff);
return E_SUCCESS;
}
| 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.
Definition at line 1133 of file CAUtil.cpp.
References E_SUCCESS, and getDOMElementValue().
{
UINT32 v;
if(getDOMElementValue(pElem,&v)!=E_SUCCESS)
{
value=defaultValue;
}
else
value=v;
return E_SUCCESS;
}
| SINT32 getDOMElementValue | ( | const DOMElement *const | pElem, |
| UINT16 * | value | ||
| ) |
Definition at line 1179 of file CAUtil.cpp.
References E_SUCCESS, E_UNKNOWN, and getDOMElementValue().
{
UINT32 tmp;
if(getDOMElementValue(pElem,&tmp)!=E_SUCCESS)
return E_UNKNOWN;
if(tmp>0xFFFF)
return E_UNKNOWN;
*value=(UINT16)tmp;
return E_SUCCESS;
}
| SINT32 getDOMElementValue | ( | const DOMElement *const | pElem, |
| double * | value | ||
| ) |
Definition at line 1119 of file CAUtil.cpp.
References ASSERT, E_SUCCESS, E_UNKNOWN, and getDOMElementValue().
{
ASSERT(value!=NULL,"Value is null");
ASSERT(pElem!=NULL,"Element is NULL");
UINT8 buff[255];
UINT32 buffLen=255;
if(getDOMElementValue(pElem,buff,&buffLen)!=E_SUCCESS)
return E_UNKNOWN;
*value=atof((char*)buff);
return E_SUCCESS;
}
| DOMNodeList* getElementsByTagName | ( | DOMElement * | pElem, |
| const char *const | name | ||
| ) |
Definition at line 868 of file CAUtil.cpp.
Referenced by CACmdLnOptions::appendMixInfo_internal(), CAMix::appendTermsAndConditionsExtension(), CACertStore::decode(), CAListenerInterface::getInstance(), CAInfoService::getOperatorTnCsAsStrings(), CAFirstMix::handleTermsAndConditionsExtension(), CAFirstMix::handleTermsAndConditionsLogin(), CAFirstMix::initMixParameters(), CACmdLnOptions::parseInfoServices(), CAAccountingInstance::prepareCCRequest(), CACmdLnOptions::processXmlConfiguration(), CACmdLnOptions::setOwnCertificate(), CACmdLnOptions::setOwnOperatorCertificate(), CACmdLnOptions::setTargetInterfaces(), CACmdLnOptions::setTermsAndConditionsList(), CACmdLnOptions::setTermsAndConditionsTemplates(), CAAccountingBIInterface::settleAll(), CACmdLnOptions::setTrustedRootCertificates(), CAXMLCostConfirmation::setValues(), and CAMix::termsAndConditionsInfoNode().
{
XMLCh* tmpCh=XMLString::transcode(name);
DOMNodeList* ret=pElem->getElementsByTagName(tmpCh);
XMLString::release(&tmpCh);
return ret;
}
| SINT32 getLastDOMChildByName | ( | const DOMNode * | pNode, |
| const XMLCh *const | name, | ||
| DOMNode *& | a_child | ||
| ) |
Definition at line 1069 of file CAUtil.cpp.
References E_SUCCESS, E_UNKNOWN, and equals().
{
a_child=NULL;
if(pNode==NULL)
{
return E_UNKNOWN;
}
DOMNode* pChild;
pChild=pNode->getLastChild();
while(pChild!=NULL)
{
if(XMLString::equals(pChild->getNodeName(),name))
{
a_child = pChild; // found a child
return E_SUCCESS;
}
pChild=pChild->getPreviousSibling();
}
return E_UNKNOWN;
}
| SINT32 getLastDOMChildByName | ( | const DOMNode * | pNode, |
| const char *const | name, | ||
| DOMNode *& | a_child | ||
| ) |
Definition at line 1058 of file CAUtil.cpp.
References E_UNKNOWN, and getLastDOMChildByName().
{
a_child=NULL;
if(pNode==NULL)
return E_UNKNOWN;
XMLCh* tmpName=XMLString::transcode((const char * const)name);
SINT32 ret=getLastDOMChildByName(pNode,tmpName,a_child);
XMLString::release(&tmpName);
return ret;
}
| SINT32 getLastDOMChildByName | ( | const DOMNode * | pNode, |
| const char *const | name, | ||
| DOMElement *& | a_child | ||
| ) |
Definition at line 876 of file CAUtil.cpp.
References getLastDOMChildByName().
Referenced by getLastDOMChildByName(), and CAMix::initMixCascadeInfo().
{
return getLastDOMChildByName(pNode,name,(DOMNode*&)a_child);
}
| UINT32 getMemoryUsage | ( | ) |
Definition at line 415 of file CAUtil.cpp.
Referenced by CAFirstMix::clean(), and CAFirstMixB::loop().
{
#ifndef _WIN32
struct rusage usage_self;
if(getrusage(RUSAGE_SELF,&usage_self)==-1)
return 0;
struct rusage usage_children;
if(getrusage(RUSAGE_CHILDREN,&usage_children)==-1)
return 0;
return usage_self.ru_idrss+usage_children.ru_idrss;
#else
return 0;
#endif
}
| SINT32 getNodeName | ( | const DOMNode *const | pElem, |
| UINT8 * | value, | ||
| UINT32 * | valuelen | ||
| ) |
Definition at line 676 of file CAUtil.cpp.
References ASSERT, E_SPACE, E_SUCCESS, and E_UNKNOWN.
Referenced by CAMix::checkCompatibility().
{
ASSERT(value!=NULL,"Value is null");
ASSERT(valuelen!=NULL,"ValueLen is null");
ASSERT(pElem!=NULL,"Element is NULL");
if(pElem==NULL)
return E_UNKNOWN;
UINT32 spaceLeft=*valuelen;
*valuelen=0;
const XMLCh* str=pElem->getNodeName();
char* tmpStr=XMLString::transcode(str);
UINT32 tmpStrLen=strlen(tmpStr);
if(tmpStrLen>=spaceLeft)
{
*valuelen=tmpStrLen+1;
XMLString::release(&tmpStr);
return E_SPACE;
}
memcpy(value+(*valuelen),tmpStr,tmpStrLen);
*valuelen+=tmpStrLen;
XMLString::release(&tmpStr);
value[*valuelen] = 0;
return E_SUCCESS;
}
Gets some random bytes.
| buff | - buff which is filled with randomness |
| len | - number of bytes requested |
| E_UNKNOWN,if | an error occured |
| E_SUCCESS,if | successful |
Definition at line 368 of file CAUtil.cpp.
Gets 32 random bits.
| val | - on return the bits are random |
| E_UNKNOWN,if | an error occured |
| E_SUCCESS,if | successful |
Definition at line 344 of file CAUtil.cpp.
References ASSERT, E_SUCCESS, and E_UNKNOWN.
Referenced by CASocketList::add(), CAMiddleMixChannelList::add(), CAFirstMixChannelList::add(), CAFirstMixChannelList::addChannel(), CAIPList::CAIPList(), CAPool::CAPool(), CAFirstMixA::closeConnection(), CAChainTable::createEntry(), encryptXMLElement(), CADatabase::fill(), CAReplayDatabase::fill(), fm_loopReadFromMix(), fm_loopSendToMix(), CAAccountingInstance::handleAccountCertificate_internal(), lm_loopReadFromMix(), lm_loopSendToMix(), CALastMixA::loop(), CAFirstMixB::loop(), CAFirstMixA::loop(), CALastMixB::loop(), CALocalProxy::loop(), CADatabase::measurePerformance(), CAReplayDatabase::measurePerformance(), mm_loopReadFromMixAfter(), mm_loopReadFromMixBefore(), mm_loopSendToMixAfter(), mm_loopSendToMixBefore(), CAFirstMixA::notifyAllUserChannels(), CAMsg::openEncryptedLog(), CAPool::pool(), CAChain::processDownstream(), CALocalProxy::processKeyExchange(), CAMiddleMix::processKeyExchange(), CALastMix::processKeyExchange(), CAFirstMix::processKeyExchange(), CAReplayDatabase::test(), CAMiddleMixChannelList::test(), CAQueue::test(), CALastMixChannelList::test(), CAASymCipher::testSpeed(), and CASymCipher::testSpeed().
| SINT32 getSignatureElements | ( | DOMNode * | parent, |
| DOMNode ** | signatureNodes, | ||
| UINT32 * | length | ||
| ) |
Definition at line 468 of file CAUtil.cpp.
References E_SUCCESS, E_UNKNOWN, and equals().
Referenced by CACertStore::verifyMixCert(), and CAMultiSignature::verifyXML().
{
if(parent == NULL)
{
return E_UNKNOWN;
}
DOMNode* child = parent->getFirstChild();
UINT32 count = 0;
while(child != NULL)
{
if(XMLString::equals(child->getNodeName(), XMLString::transcode("Signature")))
{
if(count < *length)
{
signatureNodes[count] = child;
count++;
}
else
{
return E_UNKNOWN;
}
}
child = child->getNextSibling();
}
*length = count;
return E_SUCCESS;
}
| UINT8* getTermsAndConditionsTemplateRefId | ( | DOMNode * | tcTemplateRoot | ) |
Definition at line 824 of file CAUtil.cpp.
References E_SUCCESS, getDOMElementAttribute(), TMP_BUFF_SIZE, TMP_DATE_SIZE, and TMP_LOCALE_SIZE.
Referenced by CAMix::appendTermsAndConditionsExtension(), CAFirstMix::getTermsAndConditionsTemplate(), and CACmdLnOptions::setTermsAndConditionsTemplates().
{
UINT32 tmpTypeLen = TMP_BUFF_SIZE;
UINT8 tmpType[TMP_BUFF_SIZE];
UINT32 tmpLocaleLen = TMP_LOCALE_SIZE;
UINT8 tmpLocale[TMP_LOCALE_SIZE];
UINT32 tmpDateLen = TMP_DATE_SIZE;
UINT8 tmpDate[TMP_DATE_SIZE];
memset(tmpDate, 0, TMP_DATE_SIZE);
memset(tmpLocale, 0, TMP_LOCALE_SIZE);
memset(tmpType, 0, TMP_BUFF_SIZE);
//TODO replace magic strings
if(getDOMElementAttribute(tcTemplateRoot, "type", tmpType, &tmpTypeLen) != E_SUCCESS)
{
return NULL;
}
else if(getDOMElementAttribute(tcTemplateRoot, "locale", tmpLocale, &tmpLocaleLen) != E_SUCCESS)
{
return NULL;
}
else if(getDOMElementAttribute(tcTemplateRoot, "date", tmpDate, &tmpDateLen) != E_SUCCESS)
{
return NULL;
}
if( (tmpTypeLen == 0) ||
(tmpLocaleLen == 0) ||
(tmpDateLen) == 0)
{
return NULL;
}
//reserve 2 more chars for the both underlines between the fields ...
size_t templateRefIdLen = tmpTypeLen+tmpLocaleLen+tmpDateLen+2;
//... and 1 more for zero termination.
char *templateRefId = new char[templateRefIdLen+1];
memset(templateRefId, 0, templateRefIdLen+1);
snprintf(templateRefId, templateRefIdLen+1, "%s_%s_%s", (char *) tmpType, (char *) tmpLocale, (char *) tmpDate);
return (UINT8 *) templateRefId;
}
Definition at line 305 of file CAUtil.hpp.
References __UINT64__t_::high, and __UINT64__t_::low.
Referenced by CAFirstMix::incMixedPackets().
| void initDOMParser | ( | ) |
Definition at line 628 of file CAUtil.cpp.
Referenced by CALibProxytest::init().
{
theParseDOMDocumentLock = new CAMutex();
theDOMParser = new XercesDOMParser();
}
| SINT32 initRandom | ( | ) |
Definition at line 300 of file CAUtil.cpp.
References E_SUCCESS, and getcurrentTime().
Referenced by CALibProxytest::init(), CADatabase::measurePerformance(), and CAReplayDatabase::measurePerformance().
{
#if _WIN32
RAND_screen();
#else
#ifndef __linux
unsigned char randbuff[255];
getcurrentTime(*((timespec*)randbuff));
RAND_seed(randbuff,sizeof(randbuff));
#endif
#endif
return E_SUCCESS;
}
| 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 2. specification
Definition at line 504 of file CAUtil.cpp.
References E_SUCCESS, E_UNKNOWN, equals(), INTEGRATE_NOT_ALLOWED_POSITIONS, integrateDOMNode(), and CAMsg::printMsg().
Referenced by integrateDOMNode(), and CACmdLnOptions::setTermsAndConditionsList().
{
if( (srcNode->getNodeType() != DOMNode::ELEMENT_NODE) ||
(dstNode->getNodeType() != DOMNode::ELEMENT_NODE) )
{
return E_UNKNOWN;
}
DOMNodeList *srcList = srcNode->getChildNodes();
XERCES_CPP_NAMESPACE::DOMDocument *srcOwnerDoc = srcNode->getOwnerDocument();
XERCES_CPP_NAMESPACE::DOMDocument *dstOwnerDoc = dstNode->getOwnerDocument();
short int pos =
#if _XERCES_VERSION >= 30001
srcNode->compareDocumentPosition(dstNode);
#else
srcNode->compareTreePosition(dstNode);
#endif
if( (pos & INTEGRATE_NOT_ALLOWED_POSITIONS) )
{
CAMsg::printMsg(LOG_ERR,"integrate impossible due to illegal tree positions, (pos: 0x%x)\n", pos);
return E_UNKNOWN;
}
if(srcList->getLength() == 0)
{
return E_SUCCESS;
}
DOMElement *srcElem = (DOMElement *) srcNode;
DOMElement *dstElem = (DOMElement *) dstNode;
DOMNode *currSrcChild = NULL;
XMLCh** nodeNames=new XMLCh*[srcList->getLength()];
memset(nodeNames,0,sizeof(XMLCh*)*srcList->getLength());
UINT32 nodeNamesIndex = 0;
XMLCh *currSrcChildName = NULL;
DOMNodeList *currSrcChildren = NULL;
DOMNodeList *currDstChildren = NULL;
bool nodeAlreadyFinished = false;
for(XMLSize_t i = 0; i < srcList->getLength(); i++)
{
currSrcChild = srcList->item(i);
if( currSrcChild->getNodeType() == DOMNode::ELEMENT_NODE )
{
nodeAlreadyFinished = false;
currSrcChildName = (XMLCh *) ((DOMElement *) currSrcChild)->getTagName();
/*UINT8 *tn = (UINT8 *) XMLString::transcode(currSrcChildName);
CAMsg::printMsg(LOG_DEBUG,"handle %s\n", tn);
XMLString::release(&tn);*/
for(UINT32 i = 0; i < nodeNamesIndex; i++ )
{
if(XMLString::equals(currSrcChildName, nodeNames[i]))
{
nodeAlreadyFinished = true;
break;
}
}
if(nodeAlreadyFinished)
{
continue;
}
currDstChildren = dstElem->getElementsByTagName(currSrcChildName);
currSrcChildren = srcElem->getElementsByTagName(currSrcChildName);
for(XMLSize_t j = 0;
j < currSrcChildren->getLength(); j++ )
{
if(j >= currDstChildren->getLength())
{
if( (dstOwnerDoc != NULL) && (srcOwnerDoc != dstOwnerDoc) )
{
dstNode->appendChild(dstOwnerDoc->importNode(currSrcChildren->item(j), true));
}
else
{
dstNode->appendChild(currSrcChildren->item(j)->cloneNode(true));
}
}
else if(replace)
{
if( (dstOwnerDoc != NULL) && (srcOwnerDoc != dstOwnerDoc) )
{
dstElem->replaceChild(
dstOwnerDoc->importNode(currSrcChildren->item(j),true),
currDstChildren->item(j));
}
else
{
dstElem->replaceChild(
dstOwnerDoc->cloneNode(currSrcChildren->item(j)),
currDstChildren->item(j));
}
continue;
}
else if(recursive)
{
if(currSrcChildren->item(j)->hasChildNodes() )
{
integrateDOMNode(currSrcChildren->item(j), currDstChildren->item(j), true, false);
}
}
nodeNames[nodeNamesIndex++] = currSrcChildName;
}
}
}
delete[] nodeNames;
return E_SUCCESS;
}
Definition at line 373 of file CAUtil.hpp.
References __UINT64__t_::high, and __UINT64__t_::low.
Referenced by CAMuxSocket::receive().
| bool isGreater64 | ( | UINT64 & | op1, |
| UINT64 & | op2 | ||
| ) | [inline] |
Definition at line 334 of file CAUtil.hpp.
References __UINT64__t_::high, and __UINT64__t_::low.
Referenced by CALastMixA::loop(), CAMsg::printMsg(), and CAMuxSocket::receive().
| bool isGreater64 | ( | SINT64 | op1, |
| SINT64 | op2 | ||
| ) | [inline] |
Definition at line 347 of file CAUtil.hpp.
References __SINT64__t_::high, and __SINT64__t_::low.
| bool isLesser64 | ( | UINT64 & | smallOp1, |
| UINT64 & | bigOp2 | ||
| ) | [inline] |
Definition at line 360 of file CAUtil.hpp.
References __UINT64__t_::high, and __UINT64__t_::low.
Referenced by CAHttpClient::parseHTTPHeader(), CASocket::receiveFullyT(), and CASocket::receiveLine().
Definition at line 382 of file CAUtil.hpp.
References __UINT64__t_::high, and __UINT64__t_::low.
Referenced by fm_loopSendToMix(), lm_loopSendToMix(), CAFirstMixB::loop(), mm_loopSendToMixAfter(), mm_loopSendToMixBefore(), CAMsg::printMsg(), and CAFirstMixA::sendToUsers().
Definition at line 391 of file CAUtil.hpp.
References __SINT64__t_::high, and __SINT64__t_::low.
| void logMemoryUsage | ( | ) |
Log information about the current memory (heap) usage.
Definition at line 176 of file CAUtil.cpp.
References CAMsg::printMsg().
Referenced by fm_loopLog(), and lm_loopLog().
{
#ifdef HAVE_SBRK
CAMsg::printMsg(LOG_DEBUG,"Memory consumption reported by sbrk(): %u\n",(long)((char*)sbrk(0)-internal_sbrk_start));
#endif
#ifdef HAVE_MALLINFO
struct mallinfo malli=mallinfo();
//memset(&malli,0,sizeo(malli));
CAMsg::printMsg(LOG_DEBUG,"Memory consumption reported by mallinfo():\n");
CAMsg::printMsg(LOG_DEBUG,"\t Total size of memory allocated with sbrk() by malloc() [bytes]: %i\n",malli.arena);
CAMsg::printMsg(LOG_DEBUG,"\t Number of chunks not in use: %i\n",malli.ordblks);
CAMsg::printMsg(LOG_DEBUG,"\t Total number of chunks allocated with mmap(): %i\n",malli.hblks);
CAMsg::printMsg(LOG_DEBUG,"\t Total size of memory allocated with mmap() [byte]: %i\n",malli.hblkhd);
CAMsg::printMsg(LOG_DEBUG,"\t Total size of memory occupied by chunks handed out by malloc(): %i\n",malli.uordblks);
CAMsg::printMsg(LOG_DEBUG,"\t Total size of memory occupied by free (not in use) chunks: %i\n",malli.fordblks);
CAMsg::printMsg(LOG_DEBUG,"\t Size of the top-most releasable chunk that normally borders the end of the heap: %i\n",malli.keepcost);
#endif
}
Removes leading and ending whitespaces (chars<=32) from a byte array.
| src | input byte array |
| dest | output byte array |
| size | size of the input byte array |
| E_UNSPECIFIED,if | dest was NULL |
Definition at line 126 of file CAUtil.cpp.
References E_UNSPECIFIED.
{
if(src==NULL||size==0)
return 0;
if(dest==NULL)
return E_UNSPECIFIED;
UINT32 start=0;
UINT32 end=size-1;
while(start<=end&&src[start]<=32)
start++;
if(start>end) //empty string....
return 0;
while(end>start&&src[end]<=32)
end--;
size=(end+1)-start;
memmove(dest,src+start,size);
return (SINT32)size;
}
Sleeps ms milliseconds.
Definition at line 378 of file CAUtil.cpp.
References E_SUCCESS.
Referenced by fm_loopAcceptUsers(), fm_loopReadFromMix(), fml_loopDelayBuckets(), lm_loopReadFromMix(), CALastMixA::loop(), CAFirstMixB::loop(), CAFirstMixA::loop(), CALastMixB::loop(), main(), mm_loopReadFromMixAfter(), mm_loopReadFromMixBefore(), my_terminate(), CAHttpClient::parseHTTPHeader(), producer(), CAClientSocket::receiveFully(), and CASocket::sendTimeOut().
{//Do not us usleep for this --> because it doesnt seam to work on irix, multithreaded
#ifdef _WIN32
Sleep(ms);
#else
struct timespec req;
struct timespec rem;
req.tv_sec=ms/1000;
req.tv_nsec=(ms%1000)*1000000;
while(nanosleep(&req,&rem)==-1)
{
req.tv_sec=rem.tv_sec;
req.tv_nsec=rem.tv_nsec;
}
#endif
return E_SUCCESS;
}
| XERCES_CPP_NAMESPACE::DOMDocument* parseDOMDocument | ( | const UINT8 *const | buff, |
| UINT32 | len | ||
| ) |
Parses a buffer containing an XML document and returns this document.
Definition at line 634 of file CAUtil.cpp.
References CAMutex::lock(), and CAMutex::unlock().
Referenced by CAXMLErrorMessage::CAXMLErrorMessage(), CACertificate::decode(), decodeXMLEncryptedKey(), decryptXMLElement(), CAFirstMix::doUserLogin_internal(), CAXMLCostConfirmation::getInstance(), CAXMLPriceCert::getInstance(), CAInfoService::getPaymentInstance(), CASignature::parseSignKeyXML(), CASyncControlChannel::proccessMessageComplete(), CALocalProxy::processKeyExchange(), CAMiddleMix::processKeyExchange(), CALastMix::processKeyExchange(), CAFirstMix::processKeyExchange(), CACmdLnOptions::readXmlConfiguration(), CAASymCipher::setPublicKeyAsXML(), CACmdLnOptions::setTermsAndConditionsTemplates(), CAAccountingBIInterface::settleAll(), CAMultiSignature::signXML(), and CAMultiSignature::verifyXML().
{
theParseDOMDocumentLock->lock();
MemBufInputSource in(buff,len,"tmpBuff");
theDOMParser->parse(in);
XERCES_CPP_NAMESPACE::DOMDocument* ret=NULL;
if(theDOMParser->getErrorCount()==0)
ret=theDOMParser->adoptDocument();
theParseDOMDocumentLock->unlock();
return ret;
}
| XERCES_CPP_NAMESPACE::DOMDocument* parseDOMDocument | ( | const UINT8 *const | pathOrURL | ) |
parses a file via path or URL
Definition at line 649 of file CAUtil.cpp.
References CAMutex::lock(), and CAMutex::unlock().
{
theParseDOMDocumentLock->lock();
theDOMParser->parse((const char *const) pathOrURL);
XERCES_CPP_NAMESPACE::DOMDocument* ret=NULL;
if(theDOMParser->getErrorCount()==0)
{
ret=theDOMParser->adoptDocument();
}
theParseDOMDocumentLock->unlock();
return ret;
}
Parses a 64bit signed integer.
Note: If the value is out of range or not parseable an erro is returned.
Definition at line 1617 of file CAUtil.cpp.
References E_SUCCESS, E_UNKNOWN, and len.
Referenced by getDOMElementAttribute(), and getDOMElementValue().
{
#ifdef HAVE_ATOLL
value = atoll((const char *) str);
return E_SUCCESS;
#else
#ifdef HAVE_NATIVE_UINT64
if (str == NULL)
{
return E_UNKNOWN;
}
UINT32 len=strlen((char*)str);
if (len < 1)
{
return E_UNKNOWN;
}
SINT64 s64 = 0;
for (UINT32 i = 0; i < len; i++)
{
UINT8 c=str[i];
if (c >= '0' && c <= '9')
{
s64 *= 10;
s64 += c - '0';
}
else if (i != 0 || str[i] != '+'||str[i]!='-')
{
return E_UNKNOWN;
}
}
if(str[0]=='-')
value=-s64;
else
value = s64;
return E_SUCCESS;
#else
#warning parseS64() is not implemented for platforms without native INT64 support!!!
return E_UNKNOWN;
#endif
#endif
}
Parses a timestamp in JDBC timestamp escape format (as it comes from the BI) and outputs the value in milliseconds since the epoch.
| strTimestamp | the string containing the timestamp |
| value | an 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) |
| seconds | integer value containing the timestamp in seconds since the epoch |
| strTimestamp | a string buffer that gets the result |
| len | the buffer length |
Parses a 64bit unsigned integer
Parses a timestamp in JDBC timestamp escape format (as it comes from the BI) and outputs the value in milliseconds since the epoch.
Note: If the value is out of range or not parseable an erro is returned.
Definition at line 1573 of file CAUtil.cpp.
References E_SUCCESS, E_UNKNOWN, and len.
Referenced by getDOMElementAttribute(), and getDOMElementValue().
{
#ifdef HAVE_STRTOULL
value = strtoull((const char *) str, NULL, 0);
return E_SUCCESS;
#else
#ifdef HAVE_NATIVE_UINT64
if (str == NULL)
{
return E_UNKNOWN;
}
UINT32 len=strlen((char*)str);
if (len < 1)
{
return E_UNKNOWN;
}
UINT64 u64 = 0;
for (UINT32 i = 0; i < len; i++)
{
UINT8 c=str[i];
if (c >= '0' && c <= '9')
{
u64 *= 10;
u64 += c - '0';
}
else if (i != 0 || str[i] != '+')
{
return E_UNKNOWN;
}
}
value = u64;
return E_SUCCESS;
#else
#warning parseU64() is not implemented for platforms without native UINT64 support!!!
return E_UNKNOWN;
#endif
#endif
}
Definition at line 400 of file CAUtil.hpp.
Referenced by CAAccountingDBInterface::__deleteCC(), CAAccountingDBInterface::__getAccountStatus(), CAAccountingDBInterface::__getCostConfirmation(), CAAccountingDBInterface::__getPrepaidAmount(), CAAccountingInstance::__handleSettleResult(), CAAccountingDBInterface::__markAsSettled(), CAAccountingDBInterface::__storeAccountStatus(), CAAccountingDBInterface::__storeCostConfirmation(), CAAccountingDBInterface::__storePrepaidAmount(), CAAccountingInstance::cleanupTableEntry(), CAInfoService::getCascadeHeloXMLAsString(), CACmdLnOptions::getMixXml(), CAInfoService::getStatusXMLAsString(), CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleCostConfirmation_internal(), CAAccountingInstance::handleJapPacket_internal(), lm_loopLog(), CAAccountingInstance::returnKickout(), setCurrentTimeMilliesAsDOMAttribute(), setDOMElementAttribute(), setDOMElementValue(), and CAAccountingInstance::settlementTransaction().
{
#ifdef HAVE_NATIVE_UINT64
if(num==0)
{
buff[0]='0';
buff[1]=0;
return;
}
UINT64 mask=10000000000000000000ULL;
UINT digit;
UINT32 index=0;
bool bprintZero=false;
if(num>=mask)
{
buff[index++]='1';
num-=mask;
bprintZero=true;
}
while(mask>1)
{
mask/=10;
digit=(UINT)(num/mask);
if(digit>0||bprintZero)
{
buff[index++]=(UINT8)(digit+'0');
num%=mask;
bprintZero=true;
}
}
buff[index]=0;
#else //no native UINT_64
sprintf((char*)buff,"(%lu:%lu)",op.high,op.low);
#endif
}
Definition at line 1543 of file CAUtil.cpp.
References filesize32().
Referenced by CAMiddleMix::init(), CALastMix::init(), and CAFirstMix::processKeyExchange().
{
int handle=open((char*)name,O_BINARY|O_RDONLY);
if(handle<0)
return NULL;
*size=filesize32(handle);
UINT8* buff=new UINT8[*size];
read(handle,buff,*size);
close(handle);
return buff;
}
| SINT32 readPasswd | ( | UINT8 * | buff, |
| UINT32 | len | ||
| ) |
Read a passwd (i.e.
without echoing the chars typed in)
Definition at line 1660 of file CAUtil.cpp.
References E_SUCCESS, and flags.
Referenced by CACmdLnOptions::setOwnCertificate().
{
if(len==0)
return E_SUCCESS;
#ifndef _WIN32
termios tmpTermios;
UINT32 flags;
bool bRestore=true;
if(tcgetattr(STDIN_FILENO,&tmpTermios)!=0)
{
bRestore=false;
}
flags=tmpTermios.c_lflag;
tmpTermios.c_lflag&=~(ECHO);
if(bRestore)
tcsetattr(STDIN_FILENO,TCSAFLUSH,&tmpTermios);
#endif
UINT32 i=0;
for(i=0;i<len-1;i++)
{
#ifdef _WIN32
int c=::getch();
#else
int c=getchar();
#endif
if(c<=0||c=='\r'||c=='\n')
break;
buff[i]=(UINT8)c;
}
buff[i]=0;
#ifndef _WIN32
tmpTermios.c_lflag=flags;
if(bRestore)
tcsetattr(STDIN_FILENO,TCSAFLUSH,&tmpTermios);
#endif
return E_SUCCESS;
}
| void releaseDOMParser | ( | ) |
Definition at line 663 of file CAUtil.cpp.
References CAMutex::lock(), theDOMParser, theParseDOMDocumentLock, and CAMutex::unlock().
Referenced by CALibProxytest::cleanup().
{
if( theParseDOMDocumentLock!=NULL)
{
theParseDOMDocumentLock->lock();
delete theDOMParser;
theDOMParser=NULL;
theParseDOMDocumentLock->unlock();
delete theParseDOMDocumentLock;
theParseDOMDocumentLock=NULL;
}
}
| RSA* RSA_clone | ( | RSA * | rsa | ) | [inline] |
Clones an OpenSSL RSA structure.
Definition at line 499 of file CAUtil.hpp.
Referenced by CASignature::clone(), CASignature::setSignKey(), and CASignature::setVerifyKey().
{
if(rsa == NULL)
{
return NULL;
}
RSA* tmpRSA = RSA_new();
tmpRSA->n = BN_dup(rsa->n);
tmpRSA->e = BN_dup(rsa->e);
if(rsa->d != NULL)
{ //we have a private key
tmpRSA->d = BN_dup(rsa->d);
if(tmpRSA->p != NULL)
{
tmpRSA->p = BN_dup(rsa->p);
}
if(tmpRSA->q != NULL)
{
tmpRSA->q = BN_dup(rsa->q);
}
}
if(tmpRSA->dmp1 != NULL)
{
tmpRSA->dmp1 = BN_dup(rsa->dmp1);
}
if(tmpRSA->dmq1 != NULL)
{
tmpRSA->dmq1 = BN_dup(rsa->dmq1);
}
if(tmpRSA->iqmp != NULL)
{
tmpRSA->iqmp = BN_dup(rsa->iqmp);
}
return tmpRSA;
}
Definition at line 1555 of file CAUtil.cpp.
References E_SUCCESS, and E_UNKNOWN.
Referenced by CAMiddleMix::init(), CALastMix::init(), and CAFirstMix::processKeyExchange().
Definition at line 239 of file CAUtil.hpp.
References __UINT64__t_::high, and __UINT64__t_::low.
Referenced by CAFirstMix::getMixedPackets(), CAInfoService::getStatusXMLAsString(), CALastMixA::loop(), CAFirstMixB::loop(), CAFirstMixA::loop(), CALastMixB::loop(), CAHttpClient::parseHTTPHeader(), CASocket::receiveFullyT(), CASocket::receiveLine(), CAMsg::setMaxLogFileSize(), and CAInfoService::start().
Sets the value of dst to the value of src.
Definition at line 251 of file CAUtil.hpp.
References __UINT64__t_::high, and __UINT64__t_::low.
Sets the value of dst to the value of src.
Definition at line 263 of file CAUtil.hpp.
References __SINT64__t_::high, and __SINT64__t_::low.
| SINT32 setCurrentTimeMilliesAsDOMAttribute | ( | DOMNode * | pElem | ) |
Definition at line 807 of file CAUtil.cpp.
References E_SUCCESS, E_UNKNOWN, getcurrentTimeMillis(), print64(), setDOMElementAttribute(), and UNIVERSAL_ATTRIBUTE_LAST_UPDATE.
Referenced by CAInfoService::getOperatorTnCsAsStrings().
{
if( pElem == NULL || pElem->getNodeType() != DOMNode::ELEMENT_NODE )
{
return E_UNKNOWN;
}
UINT64 currentMillis;
getcurrentTimeMillis(currentMillis);
UINT8 tmpStrCurrentMillis[50];
print64(tmpStrCurrentMillis,currentMillis);
setDOMElementAttribute
(pElem,UNIVERSAL_ATTRIBUTE_LAST_UPDATE, tmpStrCurrentMillis );
return E_SUCCESS;
}
| SINT32 setDOMElementAttribute | ( | DOMNode * | pElem, |
| const char * | attrName, | ||
| const UINT8 * | value | ||
| ) |
Definition at line 795 of file CAUtil.cpp.
References E_SUCCESS, and E_UNKNOWN.
Referenced by CACmdLnOptions::addMixIdToMixInfo(), CAMix::appendCompatibilityInfo(), CAMix::appendTermsAndConditionsExtension(), CACmdLnOptions::buildDefaultConfig(), CAFirstMix::doUserLogin_internal(), encodeXMLEncryptedKey(), CAInfoService::getCascadeHeloXMLAsString(), CAInfoService::getMixHeloXMLAsString(), CAInfoService::getOperatorTnCsAsStrings(), CACmdLnOptions::getTermsAndConditions(), CAAccountingInstance::handleAccountCertificate_internal(), CALastMix::initMixCascadeInfo(), CAMix::initMixCascadeInfo(), CAReplayCtrlChannelMsgProc::initTimestampsMessageTemplate(), CAAccountingInstance::makeInitialCCRequest(), CAAccountingInstance::prepareCCRequest(), CAReplayCtrlChannelMsgProc::proccessGetTimestamp(), CAReplayCtrlChannelMsgProc::proccessGotTimestamp(), CAMiddleMix::processKeyExchange(), CALastMix::processKeyExchange(), CAFirstMix::processKeyExchange(), CAAccountingInstance::sendAILoginConfirmation(), CAReplayCtrlChannelMsgProc::sendGetTimestamp(), setCurrentTimeMilliesAsDOMAttribute(), setDOMElementAttribute(), CACmdLnOptions::setMixName(), CACmdLnOptions::setTargetInterfaces(), CAMultiSignature::signXML(), CAMix::termsAndConditionsInfoNode(), CAXMLPriceCert::toXmlElement(), CAXMLBI::toXmlElement(), and CAXMLErrorMessage::toXmlElement().
{
if(pElem==NULL||pElem->getNodeType()!=DOMNode::ELEMENT_NODE||attrName==NULL||value==NULL)
return E_UNKNOWN;
XMLCh* name=XMLString::transcode(attrName);
XMLCh* val=XMLString::transcode((const char*)value);
((DOMElement*)pElem)->setAttribute(name,val);
XMLString::release(&name);
XMLString::release(&val);
return E_SUCCESS;
}
| SINT32 setDOMElementAttribute | ( | DOMNode * | pElem, |
| const char * | attrName, | ||
| bool | value | ||
| ) |
Definition at line 982 of file CAUtil.cpp.
References setDOMElementAttribute(), STR_VALUE_FALSE, and STR_VALUE_TRUE.
{
return setDOMElementAttribute(pElem, attrName,
((UINT8*) (value ? STR_VALUE_TRUE : STR_VALUE_FALSE)));
}
| SINT32 setDOMElementAttribute | ( | DOMNode * | pElem, |
| const char * | attrName, | ||
| SINT32 | value | ||
| ) |
Definition at line 968 of file CAUtil.cpp.
References setDOMElementAttribute().
{
UINT8 tmp[10];
sprintf((char*)tmp, "%i", value);
return setDOMElementAttribute(pElem, attrName, tmp);
}
| SINT32 setDOMElementAttribute | ( | DOMNode * | pElem, |
| const char * | attrName, | ||
| UINT32 | value | ||
| ) |
Definition at line 975 of file CAUtil.cpp.
References setDOMElementAttribute().
{
UINT8 tmp[10];
sprintf((char*)tmp, "%u", value);
return setDOMElementAttribute(pElem, attrName, tmp);
}
| SINT32 setDOMElementAttribute | ( | DOMNode * | pElem, |
| const char * | attrName, | ||
| UINT64 | value | ||
| ) |
Definition at line 953 of file CAUtil.cpp.
References print64(), and setDOMElementAttribute().
{
UINT8 tmp[50];
print64(tmp, value);
return setDOMElementAttribute(pElem, attrName, tmp);
}
| SINT32 setDOMElementAttribute | ( | DOMNode * | pElem, |
| const char * | attrName, | ||
| SINT64 | value | ||
| ) |
Definition at line 960 of file CAUtil.cpp.
References setDOMElementAttribute().
{
UINT8 tmp[50];
memset(tmp, 0, 50);
snprintf((char *) tmp, 50, "%lld", value);
return setDOMElementAttribute(pElem, attrName, tmp);
}
| SINT32 setDOMElementValue | ( | DOMElement * | pElem, |
| UINT32 | value | ||
| ) |
Definition at line 887 of file CAUtil.cpp.
References E_SUCCESS, and setDOMElementValue().
Referenced by CACmdLnOptions::buildDefaultConfig(), CAFirstMix::doUserLogin_internal(), CACertificate::encode(), encodeXMLEncryptedKey(), encryptXMLElement(), CAInfoService::getCascadeHeloXMLAsString(), CACmdLnOptions::getMixXml(), CASignature::getSignKey(), CAAccountingInstance::handleAccountCertificate_internal(), CAMix::initMixCascadeInfo(), CAReplayCtrlChannelMsgProc::initTimestampsMessageTemplate(), CAAccountingInstance::makeCCRequest(), CAAccountingInstance::makeInitialCCRequest(), CAAccountingInstance::prepareCCRequest(), CAReplayCtrlChannelMsgProc::proccessGetTimestamp(), CAReplayCtrlChannelMsgProc::proccessGotTimestamp(), CAMiddleMix::processKeyExchange(), CALastMix::processKeyExchange(), CAFirstMix::processKeyExchange(), CACmdLnOptions::processXmlConfiguration(), CAReplayCtrlChannelMsgProc::propagateCurrentReplayTimestamp(), CAAccountingInstance::sendAILoginConfirmation(), setDOMElementValue(), CACmdLnOptions::setMixName(), CACmdLnOptions::setPrepaidInterval(), CACmdLnOptions::setTargetInterfaces(), CAMultiSignature::signXML(), CAListenerInterface::toDOMElement(), CAXMLPriceCert::toXmlElement(), CAXMLBI::toXmlElement(), and CAXMLErrorMessage::toXmlElement().
{
UINT8 tmp[11];
memset(tmp, 0, 11);
snprintf((char*)tmp, 10, "%u", value);
setDOMElementValue(pElem,tmp);
return E_SUCCESS;
}
| SINT32 setDOMElementValue | ( | DOMElement * | pElem, |
| SINT32 | value | ||
| ) |
Definition at line 896 of file CAUtil.cpp.
References E_SUCCESS, and setDOMElementValue().
{
//One more char for the sign of negative numbers
UINT8 tmp[12];
memset(tmp, 0, 12);
snprintf((char*)tmp, 11, "%d", value);
setDOMElementValue(pElem,tmp);
return E_SUCCESS;
}
| SINT32 setDOMElementValue | ( | DOMElement * | pElem, |
| const UINT64 | text | ||
| ) |
Returns the content of the text node under elem as 64bit unsigned integer.
Sets the decimal text representation of a 64bit integer as node value TODO: implement this for non-64bit platforms
Definition at line 919 of file CAUtil.cpp.
References E_SUCCESS, print64(), and setDOMElementValue().
{
UINT8 tmp[32];
memset(tmp, 0, 32);
print64(tmp,text);
setDOMElementValue(pElem,tmp);
return E_SUCCESS;
}
| SINT32 setDOMElementValue | ( | DOMElement * | pElem, |
| const SINT64 | text | ||
| ) |
| SINT32 setDOMElementValue | ( | DOMElement * | pElem, |
| const UINT8 * | value | ||
| ) |
Definition at line 929 of file CAUtil.cpp.
References E_SUCCESS.
{
XMLCh* val=XMLString::transcode((const char *)value);
DOMText* pText=pElem->getOwnerDocument()->createTextNode(val);
XMLString::release(&val);
//Remove all "old" text Elements...
DOMNode* pChild=pElem->getFirstChild();
while(pChild!=NULL)
{
if(pChild->getNodeType()==DOMNode::TEXT_NODE)
{
DOMNode* n=pElem->removeChild(pChild);
if (n != NULL)
{
n->release();
n = NULL;
}
}
pChild=pChild->getNextSibling();
}
pElem->appendChild(pText);
return E_SUCCESS;
}
| SINT32 setDOMElementValue | ( | DOMElement * | pElem, |
| double | floatValue | ||
| ) |
Definition at line 906 of file CAUtil.cpp.
References E_SUCCESS, and setDOMElementValue().
{
char tmp[400];
snprintf(tmp,400, "%.2f", floatValue);
setDOMElementValue(pElem,(UINT8 *)tmp);
return E_SUCCESS;
}
| SINT32 setDOMElementValue | ( | DOMElement * | pElem, |
| bool | value | ||
| ) |
Definition at line 988 of file CAUtil.cpp.
References setDOMElementValue(), STR_VALUE_FALSE, and STR_VALUE_TRUE.
{
return setDOMElementValue(pElem,((UINT8*) (value ? STR_VALUE_TRUE : STR_VALUE_FALSE)));
}
Definition at line 273 of file CAUtil.hpp.
References __UINT64__t_::high, and __UINT64__t_::low.
Referenced by CACmdLnOptions::CACmdLnOptions(), CAMsg::CAMsg(), CAPool::CAPool(), CAFirstMixA::closeConnection(), fm_loopReadFromMix(), fm_loopSendToMix(), lm_loopReadFromMix(), lm_loopSendToMix(), CALastMixA::loop(), CAFirstMixB::loop(), CAFirstMixA::loop(), and CALastMixB::loop().
Definition at line 283 of file CAUtil.hpp.
References __SINT64__t_::high, and __SINT64__t_::low.
Sleeps sec Seconds.
Definition at line 397 of file CAUtil.cpp.
References E_SUCCESS.
Referenced by CATempIPBlockList::cleanupThreadMainLoop(), CASocket::connect(), CAMiddleMix::connectToNextMix(), CAFirstMix::connectToNextMix(), db_loopMaintenance(), fm_loopAcceptUsers(), fm_loopLog(), CAInfoService::InfoLoop(), iplist_loopDoLogCountries(), lm_loopLog(), CALocalProxy::loop(), replaydb_loopMaintenance(), rp_loopPropagateTimestamp(), signal_segv(), CALocalProxy::start(), and CAMix::start().
{
#ifdef _WIN32
Sleep(sec*1000);
#else
struct timespec req;
struct timespec rem;
req.tv_sec=sec;
req.tv_nsec=0;
while(nanosleep(&req,&rem)==-1)
{
req.tv_sec=rem.tv_sec;
req.tv_nsec=rem.tv_nsec;
}
#endif
return E_SUCCESS;
}
Inserts a String ins in a String src starting after pos chars.
Returns a newly allocated String which must be freed using delete.
Definition at line 148 of file CAUtil.cpp.
Referenced by strins().
{
if(src==NULL||ins==NULL)
return NULL;
UINT32 srcLen=strlen(src);
if(pos>srcLen)
return NULL;
UINT32 insLen=strlen(ins);
char* newString=new char[srcLen+insLen+1];
if(newString==NULL)
return NULL;
memcpy(newString,src,pos);
memcpy(newString+pos,ins,insLen);
memcpy(newString+pos+insLen,src+pos,srcLen-pos+1); //copy includes the \0
return newString;
}
| 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.
Definition at line 168 of file CAUtil.cpp.
References strins().
{
if(pos==NULL||pos<src)
return NULL;
return strins(src,pos-src,ins);
}
Removes leading and ending whitespaces (chars<=32) from a zero terminated string.
| s | input string (null terminated) |
| 0 | means, that either s was NULL or that the new string has a zero length (that means, that the old string only contains whitespaces) |
Definition at line 51 of file CAUtil.cpp.
Referenced by CAListenerInterface::getInstance(), CAChain::getPrintableChainId(), CAMultiSignature::getSKI(), CAAccountingInstance::prepareCCRequest(), CACmdLnOptions::setAccountingDatabase(), CACmdLnOptions::setLoggingOptions(), CACmdLnOptions::setMixID(), and CACmdLnOptions::setTargetInterfaces().
{
if(s==NULL)
return 0;
UINT32 end=strlen((char*)s);
if(end==0)
return 0;
end--;
UINT32 start=0;
UINT32 size;
while(start<=end&&s[start]<=32)
start++;
if(start>end) //empty string....
return 0;
while(end>start&&s[end]<=32)
end--;
size=(end+1)-start;
memmove(s,s+start,size);
s[size]=0;
return size;
}
Definition at line 73 of file CAUtil.cpp.
References E_SUCCESS.
Referenced by CACmdLnOptions::setLoggingOptions().
{
int differ = 'A'-'a';
char ch;
int ii = strlen((char*)a_string);
for (int i=0; i <ii;i++)
{
strncpy(&ch,(char*)a_string+i,1);
if (ch>='A' && ch<='Z')
{
ch = ch-differ;
memcpy(a_string+i,&ch,1);
}
}
return E_SUCCESS;
}
1.7.6.1