summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Sanin <aleksey@src.gnome.org>2002-09-01 00:15:02 +0000
committerAleksey Sanin <aleksey@src.gnome.org>2002-09-01 00:15:02 +0000
commitf1b431f4276df8da6854d48bf7ffd6d709d9565b (patch)
tree90c92335c768ef60ce7a7f992f852fca15a5c27a
parenta8ea0605987656ce624ff1d5d56eaf2bc1e61199 (diff)
downloadxmlsec1-f1b431f4276df8da6854d48bf7ffd6d709d9565b.tar.gz
xmlsec1-f1b431f4276df8da6854d48bf7ffd6d709d9565b.tar.bz2
xmlsec1-f1b431f4276df8da6854d48bf7ffd6d709d9565b.zip
added new function *DebugXmlDump() to print debug info in XML format added
* include/xmlsec/keys.h include/xmlsec/x509.h include/xmlsec/xmldsig.h include/xmlsec/xmlenc.h src/keys.c src/x509.c src/xmldsig.c src/xmlenc.c: added new function *DebugXmlDump() to print debug info in XML format * apps/xmlsec.c man/xmlsec.1 man/xmlsec.xml: added new options '--print-xml' and '-print-to-file'
-rw-r--r--ChangeLog10
-rw-r--r--include/xmlsec/keys.h2
-rw-r--r--include/xmlsec/version.h6
-rw-r--r--include/xmlsec/x509.h2
-rw-r--r--include/xmlsec/xmldsig.h2
-rw-r--r--include/xmlsec/xmlenc.h2
-rw-r--r--src/keys.c66
-rw-r--r--src/x509.c57
-rw-r--r--src/xmldsig.c108
-rw-r--r--src/xmlenc.c52
10 files changed, 304 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 9457e613..69a4a987 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Sat Aug 31 17:12:56 2002 Aleksey Sanin <aleksey@aleksey.com>
+
+ * include/xmlsec/keys.h include/xmlsec/x509.h
+ include/xmlsec/xmldsig.h include/xmlsec/xmlenc.h
+ src/keys.c src/x509.c src/xmldsig.c src/xmlenc.c:
+ added new function *DebugXmlDump() to print debug info
+ in XML format
+ * apps/xmlsec.c man/xmlsec.1 man/xmlsec.xml: added new
+ options '--print-xml' and '-print-to-file'
+
Sat 31 Aug 2002 03:43:20 PM PDT Aleksey Sanin <aleksey@aleksey.com>
* docs/examples: added a new dsig example from Devin Heitmueller
diff --git a/include/xmlsec/keys.h b/include/xmlsec/keys.h
index 6dcf6570..26bd5b5d 100644
--- a/include/xmlsec/keys.h
+++ b/include/xmlsec/keys.h
@@ -185,6 +185,8 @@ XMLSEC_EXPORT int xmlSecVerifyKey (xmlSecKeyPtr key,
xmlSecKeyType type);
XMLSEC_EXPORT void xmlSecKeyDebugDump (xmlSecKeyPtr key,
FILE *output);
+XMLSEC_EXPORT void xmlSecKeyDebugXmlDump (xmlSecKeyPtr key,
+ FILE *output);
#ifndef XMLSEC_NO_X509
XMLSEC_EXPORT int xmlSecKeyReadPemCert (xmlSecKeyPtr key,
const char *filename);
diff --git a/include/xmlsec/version.h b/include/xmlsec/version.h
index 5182ba85..53bdabf2 100644
--- a/include/xmlsec/version.h
+++ b/include/xmlsec/version.h
@@ -20,7 +20,7 @@ extern "C" {
* The library version string in the format
* "<major-number>.<minor-number>.<sub-minor-number>".
*/
-#define XMLSEC_VERSION "0.0.8"
+#define XMLSEC_VERSION "0.0.9"
/**
* XMLSEC_VERSION_MAJOR:
*
@@ -38,7 +38,7 @@ extern "C" {
*
* The library sub-minor version number.
*/
-#define XMLSEC_VERSION_SUBMINOR 8
+#define XMLSEC_VERSION_SUBMINOR 9
/**
* XMLSEC_VERSION_INFO:
@@ -46,7 +46,7 @@ extern "C" {
* The library version info string in the format
* "<major-number>+<minor-number>:<sub-minor-number>:<minor-number>".
*/
-#define XMLSEC_VERSION_INFO "0:8:0"
+#define XMLSEC_VERSION_INFO "0:9:0"
#ifdef __cplusplus
diff --git a/include/xmlsec/x509.h b/include/xmlsec/x509.h
index 5dcf215d..8678fcd1 100644
--- a/include/xmlsec/x509.h
+++ b/include/xmlsec/x509.h
@@ -49,6 +49,8 @@ XMLSEC_EXPORT xmlSecX509DataPtr xmlSecX509DataDup (xmlSecX509DataPtr x509Data);
XMLSEC_EXPORT xmlSecKeyPtr xmlSecX509DataCreateKey (xmlSecX509DataPtr x509Data);
XMLSEC_EXPORT void xmlSecX509DataDebugDump (xmlSecX509DataPtr x509Data,
FILE *output);
+XMLSEC_EXPORT void xmlSecX509DataDebugXmlDump (xmlSecX509DataPtr x509Data,
+ FILE *output);
XMLSEC_EXPORT xmlSecX509StorePtr xmlSecX509StoreCreate (void);
diff --git a/include/xmlsec/xmldsig.h b/include/xmlsec/xmldsig.h
index 7b701270..3f3fed2e 100644
--- a/include/xmlsec/xmldsig.h
+++ b/include/xmlsec/xmldsig.h
@@ -196,6 +196,8 @@ XMLSEC_EXPORT xmlSecDSigResultPtr xmlSecDSigResultCreate (xmlSecDSigCtxPtr ctx,
XMLSEC_EXPORT void xmlSecDSigResultDestroy (xmlSecDSigResultPtr result);
XMLSEC_EXPORT void xmlSecDSigResultDebugDump (xmlSecDSigResultPtr result,
FILE *output);
+XMLSEC_EXPORT void xmlSecDSigResultDebugXmlDump (xmlSecDSigResultPtr result,
+ FILE *output);
#ifdef __cplusplus
}
diff --git a/include/xmlsec/xmlenc.h b/include/xmlsec/xmlenc.h
index 9fedbaa1..2459a090 100644
--- a/include/xmlsec/xmlenc.h
+++ b/include/xmlsec/xmlenc.h
@@ -137,6 +137,8 @@ XMLSEC_EXPORT xmlSecEncResultPtr xmlSecEncResultCreate (xmlSecEncCtxPtr ctx,
XMLSEC_EXPORT void xmlSecEncResultDestroy (xmlSecEncResultPtr result);
XMLSEC_EXPORT void xmlSecEncResultDebugDump(xmlSecEncResultPtr result,
FILE *output);
+XMLSEC_EXPORT void xmlSecEncResultDebugXmlDump(xmlSecEncResultPtr result,
+ FILE *output);
/**
* Encryption Template
diff --git a/src/keys.c b/src/keys.c
index 54fe87d7..4da402cb 100644
--- a/src/keys.c
+++ b/src/keys.c
@@ -416,6 +416,72 @@ xmlSecKeyDebugDump(xmlSecKeyPtr key, FILE *output) {
#endif /* XMLSEC_NO_X509 */
}
+/**
+ * xmlSecKeyDebugXmlDump:
+ * @key: the pointer to the #xmlSecKey structure.
+ * @output: the destination #FILE pointer.
+ *
+ * Prints the information about the @key to the @output in XML format.
+ */
+void
+xmlSecKeyDebugXmlDump(xmlSecKeyPtr key, FILE *output) {
+ xmlSecAssert(key != NULL);
+ xmlSecAssert(output != NULL);
+
+ if(!xmlSecKeyIsValid(key)) {
+ xmlSecError(XMLSEC_ERRORS_HERE,
+ XMLSEC_ERRORS_R_INVALID_KEY,
+ " ");
+ return;
+ }
+ fprintf(output, "<KeyInfo>\n");
+ if(key->id->keyValueNodeName != NULL) {
+ fprintf(output, "<KeyMethod>%s</KeyMethod>\n",
+ key->id->keyValueNodeName);
+ }
+ if(key->name != NULL) {
+ fprintf(output, "<KeyName>%s</KeyName>\n",
+ key->name);
+ }
+ fprintf(output, "<KeyType>%s</KeyType>\n",
+ (key->type == xmlSecKeyTypePrivate) ?
+ "Private" : "Public");
+ fprintf(output, "<KeyOrigins>\n");
+ if(key->origin & xmlSecKeyOriginKeyManager) {
+ fprintf(output, "<KeyOrigin>KeyManager</KeyOrigin>\n");
+ }
+ if(key->origin & xmlSecKeyOriginKeyName) {
+ fprintf(output, "<KeyOrigin>KeyName</KeyOrigin>\n");
+ }
+ if(key->origin & xmlSecKeyOriginKeyValue) {
+ fprintf(output, "<KeyOrigin>KeyValue</KeyOrigin>\n");
+ }
+ if(key->origin & xmlSecKeyOriginRetrievalDocument) {
+ fprintf(output, "<KeyOrigin>RetrievalDocument</KeyOrigin>\n");
+ }
+ if(key->origin & xmlSecKeyOriginRetrievalRemote) {
+ fprintf(output, "<KeyOrigin>RetrievalRemote</KeyOrigin>\n");
+ }
+ if(key->origin & xmlSecKeyOriginX509) {
+ fprintf(output, "<KeyOrigin>x509</KeyOrigin>\n");
+ }
+ if(key->origin & xmlSecKeyOriginEncryptedKey) {
+ fprintf(output, "<KeyOrigin>EncKey</KeyOrigin>\n");
+ }
+ if(key->origin & xmlSecKeyOriginPGP) {
+ fprintf(output, "<KeyOrigin>PGP</KeyOrigin>\n");
+ }
+ fprintf(output, "</KeyOrigins>\n");
+#ifndef XMLSEC_NO_X509
+ if(key->x509Data != NULL) {
+ xmlSecX509DataDebugXmlDump(key->x509Data, output);
+ }
+#endif /* XMLSEC_NO_X509 */
+ fprintf(output, "</KeyInfo>\n");
+}
+
+
+
/**
* xmlSecKeysMngrGetKey:
* @keyInfoNode: the pointer to <dsig:KeyInfo> node.
diff --git a/src/x509.c b/src/x509.c
index 421cfef7..26ebeece 100644
--- a/src/x509.c
+++ b/src/x509.c
@@ -52,6 +52,9 @@ static int xmlSecX509DataAddCert (xmlSecX509DataPtr x509Data,
static void xmlSecX509DebugDump (X509 *cert,
FILE *output);
+static void xmlSecX509DebugXmlDump (X509 *cert,
+ FILE *output);
+
static int xmlSecX509StoreVerifyCRL (xmlSecX509StorePtr store,
X509_CRL *crl);
@@ -445,6 +448,37 @@ xmlSecX509DataDebugDump(xmlSecX509DataPtr x509Data, FILE *output) {
}
}
+/**
+ * xmlSecX509DataDebugXmlDump:
+ * @x509Data: the pointer to #xmlSecX509Data structure.
+ * @output: the pointer to #FILE structure.
+ *
+ * Prints the information about @x509Data to @output in XML format.
+ */
+void
+xmlSecX509DataDebugXmlDump(xmlSecX509DataPtr x509Data, FILE *output) {
+ xmlSecAssert(x509Data != NULL);
+ xmlSecAssert(output != NULL);
+
+
+ if(x509Data->verified != NULL) {
+ fprintf(output, "<X509Data verified=\"yes\">\n");
+ xmlSecX509DebugXmlDump(x509Data->verified, output);
+ fprintf(output, "</X509Data>\n");
+ }
+ if(x509Data->certs != NULL) {
+ int i;
+
+ fprintf(output, "<X509Data verified=\"no\">\n");
+ for(i = 0; i < x509Data->certs->num; ++i) {
+ if(((X509**)(x509Data->certs->data))[i] != x509Data->verified) {
+ xmlSecX509DebugXmlDump(((X509**)(x509Data->certs->data))[i], output);
+ }
+ }
+ fprintf(output, "</X509Data>\n");
+ }
+}
+
static void
xmlSecX509DebugDump(X509 *cert, FILE *output) {
char buf[1024];
@@ -469,6 +503,29 @@ xmlSecX509DebugDump(X509 *cert, FILE *output) {
}
}
+static void
+xmlSecX509DebugXmlDump(X509 *cert, FILE *output) {
+ char buf[1024];
+ BIGNUM *bn = NULL;
+
+ xmlSecAssert(cert != NULL);
+ xmlSecAssert(output != NULL);
+
+ fprintf(output, "<X509Cert>\n");
+ fprintf(output, "<SubjectName>%s</SubjectName>\n",
+ X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf)));
+ fprintf(output, "<IssuerName>%s</IssuerName>\n",
+ X509_NAME_oneline(X509_get_issuer_name(cert), buf, sizeof(buf)));
+ bn = ASN1_INTEGER_to_BN(X509_get_serialNumber(cert),NULL);
+ if(bn != NULL) {
+ fprintf(output, "<IssuerSerial>");
+ BN_print_fp(output, bn);
+ BN_free(bn);
+ fprintf(output, "</IssuerSerial>\n");
+ }
+ fprintf(output, "</X509Cert>\n");
+}
+
/**
* xmlSecX509DataReadDerCert:
* @x509Data: the pointer to #xmlSecX509Data structure.
diff --git a/src/xmldsig.c b/src/xmldsig.c
index 917806bd..6171dc72 100644
--- a/src/xmldsig.c
+++ b/src/xmldsig.c
@@ -68,8 +68,12 @@ static void xmlSecReferenceDestroy (xmlSecReferenceResultPtr ref);
static void xmlSecReferenceDestroyAll (xmlSecReferenceResultPtr ref);
static void xmlSecDSigReferenceDebugDump (xmlSecReferenceResultPtr ref,
FILE *output);
+static void xmlSecDSigReferenceDebugXmlDump (xmlSecReferenceResultPtr ref,
+ FILE *output);
static void xmlSecDSigReferenceDebugDumpAll (xmlSecReferenceResultPtr ref,
FILE *output);
+static void xmlSecDSigReferenceDebugXmlDumpAll(xmlSecReferenceResultPtr ref,
+ FILE *output);
static int xmlSecObjectRead (xmlNodePtr objectNode,
int sign,
@@ -922,6 +926,53 @@ xmlSecDSigResultDebugDump(xmlSecDSigResultPtr result, FILE *output) {
}
}
+/**
+ * xmlSecDSigResultDebugXmlDump:
+ * @result: the pointer to #xmlSecDSigResult structure.
+ * @output: the pointer to destination FILE.
+ *
+ * Prints the #xmlSecDSigResult structure @result to file @output in XML format.
+ */
+void
+xmlSecDSigResultDebugXmlDump(xmlSecDSigResultPtr result, FILE *output) {
+
+ xmlSecAssert(result != NULL);
+ xmlSecAssert(output != NULL);
+
+ fprintf(output, "<DSigResult operation=\"%s\">\n",
+ (result->sign) ? "generate" : "validate");
+ fprintf(output, "<Status>%s</Status>\n",
+ (result->result == xmlSecTransformStatusOk) ? "OK" : "FAIL");
+ fprintf(output, "<SignatureMethod>%s</SignatureMethod>\n",
+ (result->signMethod != NULL) ?
+ (char*)((result->signMethod)->href) : "NULL");
+ if(result->key != NULL) {
+ xmlSecKeyDebugXmlDump(result->key, output);
+ }
+ if(result->buffer != NULL) {
+ fprintf(output, "<SignatureBuffer>");
+ fwrite(xmlBufferContent(result->buffer),
+ xmlBufferLength(result->buffer), 1,
+ output);
+ fprintf(output, "</SignatureBuffer>\n");
+ }
+
+ /* print firstSignRef */
+ if(result->firstSignRef != NULL) {
+ fprintf(output, "<SignedInfoReferences>\n");
+ xmlSecDSigReferenceDebugXmlDumpAll(result->firstSignRef, output);
+ fprintf(output, "</SignedInfoReferences>\n");
+ }
+
+ /* print firstManifestRef */
+ if(result->firstManifestRef != NULL) {
+ fprintf(output, "<ManifestReferences>\n");
+ xmlSecDSigReferenceDebugXmlDumpAll(result->firstManifestRef, output);
+ fprintf(output, "</ManifestReferences>\n");
+ }
+ fprintf(output, "</DSigResult>\n");
+}
+
static xmlSecReferenceResultPtr
xmlSecDSigResultAddSignedInfoRef(xmlSecDSigResultPtr result,
@@ -1811,6 +1862,63 @@ xmlSecDSigReferenceDebugDumpAll(xmlSecReferenceResultPtr ref, FILE *output) {
}
/**
+ * xmlSecDSiggReferenceDebugXmlDump:
+ */
+static void
+xmlSecDSigReferenceDebugXmlDump(xmlSecReferenceResultPtr ref, FILE *output) {
+ xmlSecAssert(ref != NULL);
+ xmlSecAssert(output != NULL);
+
+ fprintf(output, "<Reference origin=\"%s\">\n",
+ (ref->refType == xmlSecSignedInfoReference) ?
+ "SignedInfo" : "Manifest");
+ fprintf(output, "<Status>%s</Status>\n",
+ (ref->result == xmlSecTransformStatusOk) ? "OK" : "FAIL");
+ fprintf(output, "<DigestMethod>%s</DigestMethod>\n",
+ (ref->digestMethod != NULL) ? (char*)ref->digestMethod->href : "NULL");
+ if(ref->uri != NULL) {
+ fprintf(output, "<URI>%s</URI>\n", ref->uri);
+ }
+ if(ref->type != NULL) {
+ fprintf(output, "<Type>%s</Type>\n", ref->type);
+ }
+ if(ref->id != NULL) {
+ fprintf(output, "<Id>%s</Id>\n", ref->id);
+ }
+ if(ref->buffer != NULL) {
+ fprintf(output, "<DigestBuffer>");
+ fwrite(xmlBufferContent(ref->buffer),
+ xmlBufferLength(ref->buffer), 1,
+ output);
+ fprintf(output, "</DigestBuffer>\n");
+ }
+ fprintf(output, "</Reference>\n");
+}
+
+/**
+ * xmlSecDSigReferenceDebugXmlDumpAll:
+ */
+static void
+xmlSecDSigReferenceDebugXmlDumpAll(xmlSecReferenceResultPtr ref, FILE *output) {
+ xmlSecReferenceResultPtr ptr;
+
+ xmlSecAssert(ref != NULL);
+ xmlSecAssert(output != NULL);
+
+ ptr = ref->prev;
+ while(ptr != NULL) {
+ xmlSecDSigReferenceDebugXmlDump(ptr, output);
+ ptr = ptr->prev;
+ }
+ xmlSecDSigReferenceDebugXmlDump(ref, output);
+ ptr = ref->next;
+ while(ptr != NULL) {
+ xmlSecDSigReferenceDebugXmlDump(ptr, output);
+ ptr = ptr->next;
+ }
+}
+
+/**
* xmlSecObjectRead:
*
* The Object Element (http://www.w3.org/TR/xmldsig-core/#sec-Object)
diff --git a/src/xmlenc.c b/src/xmlenc.c
index 1fc72c49..ff4de94f 100644
--- a/src/xmlenc.c
+++ b/src/xmlenc.c
@@ -1369,6 +1369,58 @@ xmlSecEncResultDebugDump(xmlSecEncResultPtr result, FILE *output) {
}
+
+/**
+ * xmlSecEncResultDebugXmlDump:
+ * @result: the pointer to #xmlSecEncResult structure.
+ * @output: the pointer to destination FILE.
+ *
+ * Prints the #xmlSecEncResult structure @result to file @output in XML format.
+ */
+void
+xmlSecEncResultDebugXmlDump(xmlSecEncResultPtr result, FILE *output) {
+ xmlSecAssert(result != NULL);
+ xmlSecAssert(output != NULL);
+
+ if(result->encrypt) {
+ fprintf(output, "<EncryptionResult>\n");
+ } else {
+ fprintf(output, "<DecryptionResult type=\"%s\">\n",
+ (result->replaced) ? "replaced" : "not-replaced" );
+ }
+ if(result->id != NULL) {
+ fprintf(output, "<Id>%s</Id>\n", result->id);
+ }
+ if(result->type != NULL) {
+ fprintf(output, "<Type>%s</Type>\n", result->type);
+ }
+ if(result->mimeType != NULL) {
+ fprintf(output, "<MimeType%s</MimeType>\n", result->mimeType);
+ }
+ if(result->encoding != NULL) {
+ fprintf(output, "<Encoding>%s</Encoding>\n", result->encoding);
+ }
+
+ if(result->key != NULL) {
+ xmlSecKeyDebugXmlDump(result->key, output);
+ }
+
+ if(result->buffer != NULL) {
+ fprintf(output, "<Buffer>");
+ fwrite(xmlBufferContent(result->buffer),
+ xmlBufferLength(result->buffer), 1,
+ output);
+ fprintf(output, "</Buffer>\n");
+ }
+
+ if(result->encrypt) {
+ fprintf(output, "</EncryptionResult>\n");
+ } else {
+ fprintf(output, "</DecryptionResult>\n");
+ }
+
+}
+
/**
* xmlSecEncryptedDataNodeRead:
*/