summaryrefslogtreecommitdiff
path: root/external/libxmlsec/xmlsec1-ooxml.patch.1
blob: 8a1dbe39ef31c2ec303baa98e14ebfabb9697654 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
From b7fb2699e3c383ae40f29369dc57afbd0d52004c Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Mon, 25 Jan 2016 09:50:03 +0100
Subject: [PATCH] OOXML Relationship Transform skeleton

---
 include/xmlsec/strings.h    |  3 ++
 include/xmlsec/transforms.h |  4 +++
 src/strings.c               |  3 ++
 src/transforms.c            | 11 ++++++
 src/xpath.c                 | 82 +++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 103 insertions(+)

diff --git a/include/xmlsec/strings.h b/include/xmlsec/strings.h
index 07afb9d..9c72d1b 100644
--- a/include/xmlsec/strings.h
+++ b/include/xmlsec/strings.h
@@ -551,6 +551,9 @@ XMLSEC_EXPORT_VAR const xmlChar xmlSecXPath2FilterUnion[];
 XMLSEC_EXPORT_VAR const xmlChar xmlSecNameXPointer[];
 XMLSEC_EXPORT_VAR const xmlChar xmlSecNodeXPointer[];
 
+XMLSEC_EXPORT_VAR const xmlChar xmlSecNameRelationship[];
+XMLSEC_EXPORT_VAR const xmlChar xmlSecHrefRelationship[];
+
 /*************************************************************************
  *
  * Xslt strings
diff --git a/include/xmlsec/transforms.h b/include/xmlsec/transforms.h
index 4008cae..b0e31e4 100644
--- a/include/xmlsec/transforms.h
+++ b/include/xmlsec/transforms.h
@@ -961,6 +961,10 @@ XMLSEC_EXPORT int		xmlSecTransformXPointerSetExpr		(xmlSecTransformPtr transform
 									 const xmlChar* expr,
 									 xmlSecNodeSetType nodeSetType,
 									 xmlNodePtr hereNode);
+
+#define xmlSecTransformRelationshipId xmlSecTransformRelationshipGetKlass()
+XMLSEC_EXPORT xmlSecTransformId xmlSecTransformRelationshipGetKlass (void);
+
 #ifndef XMLSEC_NO_XSLT
 /**
  * xmlSecTransformXsltId:
diff --git a/src/strings.c b/src/strings.c
index 9897198..546e993 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -543,6 +543,9 @@ const xmlChar xmlSecXPath2FilterUnion[]		= "union";
 const xmlChar xmlSecNameXPointer[]		= "xpointer";
 const xmlChar xmlSecNodeXPointer[]		= "XPointer";
 
+const xmlChar xmlSecNameRelationship[] = "relationship";
+const xmlChar xmlSecHrefRelationship[] = "http://schemas.openxmlformats.org/package/2006/RelationshipTransform";
+
 /*************************************************************************
  *
  * Xslt strings
diff --git a/src/transforms.c b/src/transforms.c
index 2ed3fe8..9e5ad27 100644
--- a/src/transforms.c
+++ b/src/transforms.c
@@ -271,6 +271,17 @@ xmlSecTransformIdsRegisterDefault(void) {
 	return(-1);
     }
 
+    if (xmlSecTransformIdsRegister(xmlSecTransformRelationshipId) < 0)
+    {
+	xmlSecError(XMLSEC_ERRORS_HERE,
+		    NULL,
+		    "xmlSecTransformIdsRegister",
+		    XMLSEC_ERRORS_R_XMLSEC_FAILED,
+		    "name=%s",
+		    xmlSecErrorsSafeString(xmlSecTransformKlassGetName(xmlSecTransformRelationshipId)));
+	return -1;
+    }
+
 #ifndef XMLSEC_NO_XSLT
     if(xmlSecTransformIdsRegister(xmlSecTransformXsltId) < 0) {
 	xmlSecError(XMLSEC_ERRORS_HERE,
diff --git a/src/xpath.c b/src/xpath.c
index 8b0b4f8..63b02d4 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -1144,5 +1144,87 @@ xmlSecTransformVisa3DHackExecute(xmlSecTransformPtr transform, int last,
     return(0);
 }
 
+/* OOXML Relationship Transform. */
+typedef struct _xmlSecRelationshipCtx xmlSecRelationshipCtx, *xmlSecRelationshipCtxPtr;
+struct _xmlSecRelationshipCtx
+{
+    xmlParserCtxtPtr parserCtx;
+};
+#define xmlSecRelationshipSize (sizeof(xmlSecTransform) + sizeof(xmlSecRelationshipCtx))
+#define xmlSecRelationshipGetCtx(transform) ((xmlSecRelationshipCtxPtr)(((xmlSecByte*)(transform)) + sizeof(xmlSecTransform)))
+
+static int xmlSecRelationshipInitialize (xmlSecTransformPtr transform);
+static void xmlSecRelationshipFinalize (xmlSecTransformPtr transform);
+static int xmlSecRelationshipReadNode (xmlSecTransformPtr transform, xmlNodePtr node, xmlSecTransformCtxPtr transformCtx);
+static int xmlSecRelationshipExecute (xmlSecTransformPtr transform, int last, xmlSecTransformCtxPtr transformCtx);
+
+static xmlSecTransformKlass xmlSecRelationshipKlass =
+{
+    /* klass/object sizes */
+    sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
+    xmlSecRelationshipSize, /* xmlSecSize objSize */
+    xmlSecNameRelationship, /* const xmlChar* name; */
+    xmlSecHrefRelationship, /* const xmlChar* href; */
+    xmlSecTransformUsageDSigTransform, /* xmlSecAlgorithmUsage usage; */
+    xmlSecRelationshipInitialize, /* xmlSecTransformInitializeMethod initialize; */
+    xmlSecRelationshipFinalize, /* xmlSecTransformFinalizeMethod finalize; */
+    xmlSecRelationshipReadNode, /* xmlSecTransformNodeReadMethod readNode; */
+    NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
+    NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
+    NULL, /* xmlSecTransformSetKeyMethod setKey; */
+    NULL, /* xmlSecTransformValidateMethod validate; */
+    xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
+    xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
+    xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
+    NULL, /* xmlSecTransformPushXmlMethod pushXml; */
+    NULL, /* xmlSecTransformPopXmlMethod popXml; */
+    xmlSecRelationshipExecute, /* xmlSecTransformExecuteMethod execute; */
+    NULL, /* void* reserved0; */
+    NULL, /* void* reserved1; */
+};
+
+xmlSecTransformId xmlSecTransformRelationshipGetKlass(void)
+{
+    return &xmlSecRelationshipKlass;
+}
+
+static int xmlSecRelationshipInitialize(xmlSecTransformPtr transform)
+{
+    xmlSecRelationshipCtxPtr ctx;
+
+    xmlSecAssert2(xmlSecTransformCheckId(transform, xmlSecTransformRelationshipId), -1);
+    xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecRelationshipSize), -1);
+
+    ctx = xmlSecRelationshipGetCtx(transform);
+    xmlSecAssert2(ctx != NULL, -1);
 
+    /* initialize context */
+    memset(ctx, 0, sizeof(xmlSecRelationshipCtx));
+    return 0;
+}
+
+static void xmlSecRelationshipFinalize(xmlSecTransformPtr transform)
+{
+    xmlSecRelationshipCtxPtr ctx;
+
+    xmlSecAssert(xmlSecTransformCheckId(transform, xmlSecTransformRelationshipId));
+    xmlSecAssert(xmlSecTransformCheckSize(transform, xmlSecRelationshipSize));
+
+    ctx = xmlSecRelationshipGetCtx(transform);
+    xmlSecAssert(ctx != NULL);
+
+    if (ctx->parserCtx != NULL)
+	xmlFreeParserCtxt(ctx->parserCtx);
 
+    memset(ctx, 0, sizeof(xmlSecRelationshipCtx));
+}
+
+static int xmlSecRelationshipReadNode(xmlSecTransformPtr transform, xmlNodePtr node, xmlSecTransformCtxPtr transformCtx)
+{
+    return 0;
+}
+
+static int xmlSecRelationshipExecute(xmlSecTransformPtr transform, int last, xmlSecTransformCtxPtr transformCtx)
+{
+    return 0;
+}
-- 
2.6.2