diff options
author | cc1.yim <cc1.yim@samsung.com> | 2013-04-16 15:04:55 +0900 |
---|---|---|
committer | cc1.yim <cc1.yim@samsung.com> | 2013-04-16 17:00:01 +0900 |
commit | 2328f0391732c6e30c9b0b70d230634e5eaf3b9d (patch) | |
tree | 93491f01a7c9903fb188fc095f83eb4aace2e153 | |
parent | 2b219596088b9d49a921d13fcd80e60d13ad77d7 (diff) | |
download | xmlsec1-2328f0391732c6e30c9b0b70d230634e5eaf3b9d.tar.gz xmlsec1-2328f0391732c6e30c9b0b70d230634e5eaf3b9d.tar.bz2 xmlsec1-2328f0391732c6e30c9b0b70d230634e5eaf3b9d.zip |
Add no hash api
Change-Id: I4b2a0f3ff0bfd0759c1209a2ff231ab42359e21a
Signed-off-by: cc1.yim <cc1.yim@samsung.com>
-rw-r--r-- | include/xmlsec/errors.h | 1 | ||||
-rw-r--r-- | include/xmlsec/xmldsig.h | 11 | ||||
-rw-r--r-- | src/errors.c | 57 | ||||
-rw-r--r-- | src/openssl/signatures.c | 19 | ||||
-rw-r--r-- | src/xmldsig.c | 334 |
5 files changed, 387 insertions, 35 deletions
diff --git a/include/xmlsec/errors.h b/include/xmlsec/errors.h index 42c6306c..a7a9fd36 100644 --- a/include/xmlsec/errors.h +++ b/include/xmlsec/errors.h @@ -403,6 +403,7 @@ XMLSEC_EXPORT void xmlSecErrorsDefaultCallbackEnableOutput XMLSEC_EXPORT int xmlSecErrorsGetCode (xmlSecSize pos); XMLSEC_EXPORT const char* xmlSecErrorsGetMsg (xmlSecSize pos); +XMLSEC_EXPORT void xmlSecPrintLogMsg(const char* msg); /* __FUNCTION__ is defined for MSC compiler < MS VS .NET 2003 */ diff --git a/include/xmlsec/xmldsig.h b/include/xmlsec/xmldsig.h index b2620784..6bcf014d 100644 --- a/include/xmlsec/xmldsig.h +++ b/include/xmlsec/xmldsig.h @@ -240,6 +240,11 @@ struct _xmlSecDSigReferenceCtx { void* reserved0; void* reserved1; }; +typedef struct HashUriList_struct +{ + struct HashUriList_struct * pNext; + char* uri; +}HashUriList; XMLSEC_EXPORT xmlSecDSigReferenceCtxPtr xmlSecDSigReferenceCtxCreate(xmlSecDSigCtxPtr dsigCtx, xmlSecDSigReferenceOrigin origin); @@ -257,6 +262,12 @@ XMLSEC_EXPORT void xmlSecDSigReferenceCtxDebugDump (xmlSecDSigReferenceCtxPtr d XMLSEC_EXPORT void xmlSecDSigReferenceCtxDebugXmlDump(xmlSecDSigReferenceCtxPtr dsigRefCtx, FILE* output); + + +XMLSEC_EXPORT void xmlSecDSigSetNoHash(int hash); +XMLSEC_EXPORT void xmlSecDSigSetPartialHash(HashUriList* uriList); +void freePartialHash(HashUriList* uriList); + /************************************************************************** * * xmlSecDSigReferenceCtxListKlass diff --git a/src/errors.c b/src/errors.c index 54e34e6c..06259e6f 100644 --- a/src/errors.c +++ b/src/errors.c @@ -224,12 +224,38 @@ xmlSecError(const char* file, int line, const char* func, const char* errorObject, const char* errorSubject, int reason, const char* msg, ...) { - if(xmlSecErrorsClbk != NULL) { - xmlChar error_msg[XMLSEC_ERRORS_BUFFER_SIZE]; + if(xmlSecErrorsClbk != NULL) + { + if( xmlSecErrorsClbk != xmlSecErrorsDefaultCallback ) + { + const char* error_msg = NULL; + xmlSecSize i; + + if(reason != XMLSEC_ERRORS_MAX_NUMBER) + { + for(i = 0; (i < XMLSEC_ERRORS_MAX_NUMBER) && (xmlSecErrorsGetMsg(i) != NULL); ++i) + { + if(xmlSecErrorsGetCode(i) == reason) { + error_msg = xmlSecErrorsGetMsg(i); + break; + } + } + + if(error_msg != NULL) + msg = error_msg; + } + + if(reason == XMLSEC_ERRORS_MAX_NUMBER) + reason = 0; + + xmlSecErrorsClbk(file, line, func, errorObject, errorSubject, reason, msg); +} + + + /* if(msg != NULL) { va_list va; - va_start(va, msg); xmlSecStrVPrintf(error_msg, sizeof(error_msg), BAD_CAST msg, va); error_msg[sizeof(error_msg) - 1] = '\0'; @@ -237,6 +263,29 @@ xmlSecError(const char* file, int line, const char* func, } else { error_msg[0] = '\0'; } - xmlSecErrorsClbk(file, line, func, errorObject, errorSubject, reason, (char*)error_msg); + xmlSecErrorsClbk(file, line, func, errorObject, errorSubject, reason, (char*)error_msg);*/ } } + +void +xmlSecPrintLogMsg(const char* msg) +{ + + // LOGD("[LOG][%s:L%d]: %s \n", __func__,__LINE__, msg); +// fprintf(stderr, FMT, ##ARG); + // fprintf(stderr, " ## xmlSecPrintLogMsg: %s\n",msg); +//fprintf(RouterData(theEnv)->FastSaveFilePtr,"%s",str); + + //LOGD("[LOG][%s:L%d]: %s \n", __func__,__LINE__, msg); + + + + //LOGD("[LOG][%s:L%d] Enter \n", __func__,__LINE__); + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + NULL, + XMLSEC_ERRORS_MAX_NUMBER, + msg); + +} diff --git a/src/openssl/signatures.c b/src/openssl/signatures.c index 2a16983a..4519dc39 100644 --- a/src/openssl/signatures.c +++ b/src/openssl/signatures.c @@ -323,7 +323,10 @@ xmlSecOpenSSLEvpSignatureVerify(xmlSecTransformPtr transform, xmlSecTransformCtxPtr transformCtx) { xmlSecOpenSSLEvpSignatureCtxPtr ctx; int ret; - + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecOpenSSLEvpSignatureVerify :: OpenSSL start ??? >>"); xmlSecAssert2(xmlSecOpenSSLEvpSignatureCheckId(transform), -1); xmlSecAssert2(transform->operation == xmlSecTransformOperationVerify, -1); xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecOpenSSLEvpSignatureSize), -1); @@ -341,6 +344,11 @@ xmlSecOpenSSLEvpSignatureVerify(xmlSecTransformPtr transform, "EVP_VerifyFinal", XMLSEC_ERRORS_R_CRYPTO_FAILED, XMLSEC_ERRORS_NO_MESSAGE); + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecOpenSSLEvpSignatureVerify :: OpenSSL CRYPTO_FAILED ??? >>"); + return(-1); } else if(ret != 1) { xmlSecError(XMLSEC_ERRORS_HERE, @@ -349,10 +357,19 @@ xmlSecOpenSSLEvpSignatureVerify(xmlSecTransformPtr transform, XMLSEC_ERRORS_R_DATA_NOT_MATCH, "signature do not match"); transform->status = xmlSecTransformStatusFail; + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecOpenSSLEvpSignatureVerify :: OpenSSL DATA_NOT_MATCH ??? >>"); return(0); } transform->status = xmlSecTransformStatusOk; + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecOpenSSLEvpSignatureVerify :: OpenSSL end OK ??? >>"); + return(0); } diff --git a/src/xmldsig.c b/src/xmldsig.c index cbd825e5..535d0e63 100644 --- a/src/xmldsig.c +++ b/src/xmldsig.c @@ -49,6 +49,10 @@ static int xmlSecDSigCtxProcessManifestNode (xmlSecDSigCtxPtr dsigCtx, /* The ID attribute in XMLDSig is 'Id' */ static const xmlChar* xmlSecDSigIds[] = { xmlSecAttrId, NULL }; +static int gNoHash = 0; +static int gPartial = 0; +static HashUriList* gpList = NULL; +static char logChar[100] = "\0"; /** * xmlSecDSigCtxCreate: @@ -287,6 +291,10 @@ int xmlSecDSigCtxSign(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr tmpl) { int ret; + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxSign start >>"); + xmlSecAssert2(dsigCtx != NULL, -1); xmlSecAssert2(dsigCtx->result == NULL, -1); xmlSecAssert2(tmpl != NULL, -1); @@ -350,7 +358,11 @@ xmlSecDSigCtxSign(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr tmpl) { int xmlSecDSigCtxVerify(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { int ret; - + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxVerify start >>"); + xmlSecAssert2(dsigCtx != NULL, -1); xmlSecAssert2(node != NULL, -1); xmlSecAssert2(node->doc != NULL, -1); @@ -368,6 +380,12 @@ xmlSecDSigCtxVerify(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { "xmlSecDSigCtxSigantureProcessNode", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessSignatureNode false >>"); + + return(-1); } xmlSecAssert2(dsigCtx->signMethod != NULL, -1); @@ -387,6 +405,11 @@ xmlSecDSigCtxVerify(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { "xmlSecTransformVerifyNodeContent", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecTransformVerifyNodeContent false >>"); + return(-1); } @@ -456,6 +479,10 @@ xmlSecDSigCtxProcessSignatureNode(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { xmlNodePtr keyInfoNode = NULL; xmlNodePtr cur; int ret; + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessSignatureNode : start >>>>>>>"); xmlSecAssert2(dsigCtx != NULL, -1); xmlSecAssert2((dsigCtx->operation == xmlSecTransformOperationSign) || (dsigCtx->operation == xmlSecTransformOperationVerify), -1); @@ -629,6 +656,10 @@ xmlSecDSigCtxProcessSignatureNode(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { XMLSEC_ERRORS_NO_MESSAGE); return(-1); } + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessSignatureNode : end >>>>>>>"); return(0); } @@ -671,7 +702,11 @@ xmlSecDSigCtxProcessSignedInfoNode(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { xmlSecDSigReferenceCtxPtr dsigRefCtx; xmlNodePtr cur; int ret; - + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessSignedInfoNode start >>"); + xmlSecAssert2(dsigCtx != NULL, -1); xmlSecAssert2(dsigCtx->status == xmlSecDSigStatusUnknown, -1); xmlSecAssert2(dsigCtx->signMethod == NULL, -1); @@ -798,16 +833,41 @@ xmlSecDSigCtxProcessSignedInfoNode(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { return(-1); } - /* process */ - ret = xmlSecDSigReferenceCtxProcessNode(dsigRefCtx, cur); - if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecDSigReferenceCtxProcessNode", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - "node=%s", - xmlSecErrorsSafeString(xmlSecNodeGetName(cur))); - return(-1); + if( gNoHash == 1) + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessSignedInfoNode : NoHash :: skip start >>>>>>"); + + /* process */ + ret = xmlSecDSigReferenceCtxProcessNode(dsigRefCtx, cur); + if(ret < 0) { + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + "xmlSecDSigReferenceCtxProcessNode", + XMLSEC_ERRORS_R_XMLSEC_FAILED, + "node=%s", + xmlSecErrorsSafeString(xmlSecNodeGetName(cur))); + + if( gNoHash == 1) + { + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigReferenceCtxProcessNode : ignore false >>>>>>"); + + //return(-1); + } + else + return(-1); + } + + + if( gNoHash == 1) + { + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessSignedInfoNode : NoHash :: skip end >>>>>>"); + + dsigRefCtx->status = xmlSecDSigStatusSucceeded; } /* bail out if next Reference processing failed */ @@ -815,18 +875,21 @@ xmlSecDSigCtxProcessSignedInfoNode(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { dsigCtx->status = xmlSecDSigStatusInvalid; return(0); } + cur = xmlSecGetNextElementNode(cur->next); } + /* check that we have at least one Reference */ if(xmlSecPtrListGetSize(&(dsigCtx->signedInfoReferences)) == 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - NULL, - XMLSEC_ERRORS_R_DSIG_NO_REFERENCES, - XMLSEC_ERRORS_NO_MESSAGE); - return(-1); - } + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + NULL, + XMLSEC_ERRORS_R_DSIG_NO_REFERENCES, + XMLSEC_ERRORS_NO_MESSAGE); + return(-1); + } + /* if there is something left than it's an error */ if(cur != NULL) { @@ -837,12 +900,21 @@ xmlSecDSigCtxProcessSignedInfoNode(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { XMLSEC_ERRORS_NO_MESSAGE); return(-1); } + + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessSignedInfoNode end >>"); + return(0); } static int xmlSecDSigCtxProcessKeyInfoNode(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { int ret; + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessKeyInfoNode start >>"); xmlSecAssert2(dsigCtx != NULL, -1); xmlSecAssert2(dsigCtx->signMethod != NULL, -1); @@ -901,6 +973,9 @@ xmlSecDSigCtxProcessKeyInfoNode(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { } } + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessKeyInfoNode end >>"); return(0); } @@ -936,6 +1011,11 @@ static int xmlSecDSigCtxProcessObjectNode(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { xmlNodePtr cur; int ret; + + /*xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessObjectNode start >>"); + */ xmlSecAssert2(dsigCtx != NULL, -1); xmlSecAssert2(dsigCtx->status == xmlSecDSigStatusUnknown, -1); @@ -957,6 +1037,10 @@ xmlSecDSigCtxProcessObjectNode(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { } cur = xmlSecGetNextElementNode(cur->next); } + + /*xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessObjectNode end >>");*/ return(0); } @@ -995,6 +1079,9 @@ xmlSecDSigCtxProcessManifestNode(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { xmlSecDSigReferenceCtxPtr dsigRefCtx; xmlNodePtr cur; int ret; + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessManifestNode start >>"); xmlSecAssert2(dsigCtx != NULL, -1); xmlSecAssert2(dsigCtx->status == xmlSecDSigStatusUnknown, -1); @@ -1052,6 +1139,9 @@ xmlSecDSigCtxProcessManifestNode(xmlSecDSigCtxPtr dsigCtx, xmlNodePtr node) { XMLSEC_ERRORS_NO_MESSAGE); return(-1); } + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigCtxProcessManifestNode end >>"); return(0); } @@ -1250,7 +1340,11 @@ xmlSecDSigReferenceCtxPtr xmlSecDSigReferenceCtxCreate(xmlSecDSigCtxPtr dsigCtx, xmlSecDSigReferenceOrigin origin) { xmlSecDSigReferenceCtxPtr dsigRefCtx; int ret; - + + /*xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigReferenceCtxCreate start >>"); + */ xmlSecAssert2(dsigCtx != NULL, NULL); dsigRefCtx = (xmlSecDSigReferenceCtxPtr) xmlMalloc(sizeof(xmlSecDSigReferenceCtx)); @@ -1274,6 +1368,11 @@ xmlSecDSigReferenceCtxCreate(xmlSecDSigCtxPtr dsigCtx, xmlSecDSigReferenceOrigin xmlSecDSigReferenceCtxDestroy(dsigRefCtx); return(NULL); } + + /*xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigReferenceCtxCreate end >>");*/ + return(dsigRefCtx); } @@ -1285,6 +1384,11 @@ xmlSecDSigReferenceCtxCreate(xmlSecDSigCtxPtr dsigCtx, xmlSecDSigReferenceOrigin */ void xmlSecDSigReferenceCtxDestroy(xmlSecDSigReferenceCtxPtr dsigRefCtx) { + + /*xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigReferenceCtxDestroy start >>"); */ + xmlSecAssert(dsigRefCtx != NULL); xmlSecDSigReferenceCtxFinalize(dsigRefCtx); @@ -1307,6 +1411,10 @@ int xmlSecDSigReferenceCtxInitialize(xmlSecDSigReferenceCtxPtr dsigRefCtx, xmlSecDSigCtxPtr dsigCtx, xmlSecDSigReferenceOrigin origin) { int ret; + + /*xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigReferenceCtxInitialize start >>"); */ xmlSecAssert2(dsigCtx != NULL, -1); xmlSecAssert2(dsigRefCtx != NULL, -1); @@ -1357,6 +1465,11 @@ xmlSecDSigReferenceCtxInitialize(xmlSecDSigReferenceCtxPtr dsigRefCtx, xmlSecDSi */ void xmlSecDSigReferenceCtxFinalize(xmlSecDSigReferenceCtxPtr dsigRefCtx) { + + /*xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigReferenceCtxFinalize start >>"); */ + xmlSecAssert(dsigRefCtx != NULL); xmlSecTransformCtxFinalize(&(dsigRefCtx->transformCtx)); @@ -1418,6 +1531,9 @@ xmlSecDSigReferenceCtxProcessNode(xmlSecDSigReferenceCtxPtr dsigRefCtx, xmlNodeP xmlNodePtr cur; int ret; + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigReferenceCtxProcessNode : start >>>>>>>"); xmlSecAssert2(dsigRefCtx != NULL, -1); xmlSecAssert2(dsigRefCtx->dsigCtx != NULL, -1); xmlSecAssert2(dsigRefCtx->digestMethod == NULL, -1); @@ -1426,8 +1542,16 @@ xmlSecDSigReferenceCtxProcessNode(xmlSecDSigReferenceCtxPtr dsigRefCtx, xmlNodeP xmlSecAssert2(node != NULL, -1); xmlSecAssert2(node->doc != NULL, -1); + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + " : skip start >>>>>"); + + + transformCtx = &(dsigRefCtx->transformCtx); + if( gNoHash != 1) + { /* read attributes first */ dsigRefCtx->uri = xmlGetProp(node, xmlSecAttrURI); dsigRefCtx->id = xmlGetProp(node, xmlSecAttrId); @@ -1548,6 +1672,15 @@ xmlSecDSigReferenceCtxProcessNode(xmlSecDSigReferenceCtxPtr dsigRefCtx, xmlNodeP return(-1); } +#if 0 + }// if( gNoHash == 1) + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + " : skip end >>>>>"); +#endif + + /* if we need to write result to xml node then we need base64 encode result */ if(dsigRefCtx->dsigCtx->operation == xmlSecTransformOperationSign) { xmlSecTransformPtr base64Encode; @@ -1560,7 +1693,12 @@ xmlSecDSigReferenceCtxProcessNode(xmlSecDSigReferenceCtxPtr dsigRefCtx, xmlNodeP "xmlSecTransformCtxCreateAndAppend", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecTransformCtxCreateAndAppend false >>>>>"); return(-1); + } base64Encode->operation = xmlSecTransformOperationEncode; } @@ -1573,11 +1711,30 @@ xmlSecDSigReferenceCtxProcessNode(xmlSecDSigReferenceCtxPtr dsigRefCtx, xmlNodeP "xmlSecTransformCtxExecute", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + " TransformCtxExecute false return ?? >>>>>"); + return(-1); } dsigRefCtx->result = transformCtx->result; + + +#if 0 + }// if( gNoHash == 1) + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + " : skip end >>>>>"); +#endif if(dsigRefCtx->dsigCtx->operation == xmlSecTransformOperationSign) { + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + " : skip start 2 >>>>>"); + if((dsigRefCtx->result == NULL) || (xmlSecBufferGetData(dsigRefCtx->result) == NULL)) { xmlSecError(XMLSEC_ERRORS_HERE, NULL, @@ -1591,19 +1748,33 @@ xmlSecDSigReferenceCtxProcessNode(xmlSecDSigReferenceCtxPtr dsigRefCtx, xmlNodeP xmlNodeSetContentLen(digestValueNode, xmlSecBufferGetData(dsigRefCtx->result), xmlSecBufferGetSize(dsigRefCtx->result)); - + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + " : skip end 2 >>>>>"); + /* set success status and we are done */ dsigRefCtx->status = xmlSecDSigStatusSucceeded; } else { - /* verify SignatureValue node content */ - ret = xmlSecTransformVerifyNodeContent(dsigRefCtx->digestMethod, - digestValueNode, transformCtx); - if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecTransformVerifyNodeContent", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - XMLSEC_ERRORS_NO_MESSAGE); + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecTransformVerifyNodeContent :: signature start ??? >>"); + + + /* verify SignatureValue node content */ + ret = xmlSecTransformVerifyNodeContent(dsigRefCtx->digestMethod, + digestValueNode, transformCtx); + if(ret < 0) { + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + "xmlSecTransformVerifyNodeContent", + XMLSEC_ERRORS_R_XMLSEC_FAILED, + XMLSEC_ERRORS_NO_MESSAGE); + + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + " TransformVerifyNodeContent :: signature false ??? >>"); return(-1); } @@ -1613,8 +1784,27 @@ xmlSecDSigReferenceCtxProcessNode(xmlSecDSigReferenceCtxPtr dsigRefCtx, xmlNodeP } else { dsigRefCtx->status = xmlSecDSigStatusInvalid; } + + + +#if 1 + }// if( gNoHash == 1) + if(dsigRefCtx->digestMethod->status == xmlSecTransformStatusOk) { + dsigRefCtx->status = xmlSecDSigStatusSucceeded; + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + " :: TransformStatusOk , SigStatusSucceeded >>>>"); + + } + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + " : skip end >>>>>"); +#endif + } +partialHash: return(0); } @@ -1765,6 +1955,90 @@ xmlSecDSigReferenceCtxDebugXmlDump(xmlSecDSigReferenceCtxPtr dsigRefCtx, FILE* o } +void xmlSecDSigSetNoHash(int hash) +{ + gNoHash = hash; + + if( gNoHash == 1 ) + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigSetNoHash >> start"); + else + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigSetNoHash : 0 ( default)"); +} + +void _copyMemory(HashUriList* src, HashUriList* dest) +{ + dest= (HashUriList*)malloc(sizeof(HashUriList)); // gpList + + HashUriList* pDestTmp = dest; + HashUriList* pSrcTmp = src; + int len = 0; + int cnt = 0; + + while(pSrcTmp) + { + len = strlen(pSrcTmp->uri); + pDestTmp->uri = (char*)malloc(len+1); + memcpy(pDestTmp->uri, pSrcTmp->uri, len); + pDestTmp->uri[len] = '\0'; + ++cnt; + + strcpy(logChar, pDestTmp->uri); + + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + (const char*)logChar); + + pSrcTmp = pSrcTmp->pNext; + + if(pSrcTmp != NULL) + { + pDestTmp->pNext = (HashUriList*)malloc(sizeof(HashUriList)); + pDestTmp = pDestTmp->pNext; + } + } + +} + +void xmlSecDSigSetPartialHash(HashUriList* uriList) +{ + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigSetPartialHash >> start"); + + gPartial = 1; + + if(uriList != NULL) + { + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "xmlSecDSigSetPartialHash >> uriList != NULL >>>>"); + + gpList = uriList; + } + +} + +void freePartialHash(HashUriList* uriList) +{ + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, NULL, XMLSEC_ERRORS_MAX_NUMBER, + "freePartialHash >> start"); + + HashUriList* pTmp = uriList; + while(pTmp != NULL) + { + free(pTmp->uri); + pTmp = pTmp->pNext; + } + //free(pTmp); + //pTmp = NULL; +} + + /************************************************************************** * * xmlSecDSigReferenceCtxListKlass |