xmlsig 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +0 -0
- data/ext/xmlsig/BioWrap.h +98 -0
- data/ext/xmlsig/DSig.cpp +109 -0
- data/ext/xmlsig/DSig.h +81 -0
- data/ext/xmlsig/DSigCtx.h +72 -0
- data/ext/xmlsig/Exceptions.cpp +151 -0
- data/ext/xmlsig/Exceptions.h +214 -0
- data/ext/xmlsig/Key.cpp +582 -0
- data/ext/xmlsig/Key.h +338 -0
- data/ext/xmlsig/KeyInfoCtx.h +67 -0
- data/ext/xmlsig/KeyStore.cpp +180 -0
- data/ext/xmlsig/KeyStore.h +157 -0
- data/ext/xmlsig/KeysMngrWrap.h +62 -0
- data/ext/xmlsig/NodeSet.h +60 -0
- data/ext/xmlsig/Signer.cpp +691 -0
- data/ext/xmlsig/Signer.h +373 -0
- data/ext/xmlsig/TrustVerifier.cpp +145 -0
- data/ext/xmlsig/TrustVerifier.h +174 -0
- data/ext/xmlsig/Verifier.cpp +677 -0
- data/ext/xmlsig/Verifier.h +313 -0
- data/ext/xmlsig/X509Certificate.cpp +362 -0
- data/ext/xmlsig/X509Certificate.h +146 -0
- data/ext/xmlsig/XPath.cpp +173 -0
- data/ext/xmlsig/XPath.h +156 -0
- data/ext/xmlsig/XPathCtx.h +68 -0
- data/ext/xmlsig/XmlCharBuf.h +60 -0
- data/ext/xmlsig/XmlDoc.cpp +278 -0
- data/ext/xmlsig/XmlDoc.h +157 -0
- data/ext/xmlsig/XmlElement.cpp +151 -0
- data/ext/xmlsig/XmlElement.h +134 -0
- data/ext/xmlsig/countptr.h +260 -0
- data/ext/xmlsig/extconf.rb +58 -0
- data/ext/xmlsig/runtests.rb +23 -0
- data/ext/xmlsig/swig/countptr.i +27 -0
- data/ext/xmlsig/swig/exceptions.i +79 -0
- data/ext/xmlsig/swig/ruby.i +17 -0
- data/ext/xmlsig/swig/xmlsig.i +405 -0
- data/ext/xmlsig/t/tc_cert.rb +34 -0
- data/ext/xmlsig/t/tc_interface.rb +158 -0
- data/ext/xmlsig/t/tc_signer.rb +501 -0
- data/ext/xmlsig/t/tc_tsik.rb +490 -0
- data/ext/xmlsig/t/tc_verifier.rb +151 -0
- data/ext/xmlsig/t/tsik_interop/sign.rb +48 -0
- data/ext/xmlsig/t/tsik_interop/verify.rb +31 -0
- data/ext/xmlsig/t/tsik_interop/verify_own.rb +46 -0
- data/ext/xmlsig/xmlsig.cpp +13363 -0
- data/lib/xmlsig.rb +1 -0
- metadata +113 -0
@@ -0,0 +1,260 @@
|
|
1
|
+
/*
|
2
|
+
* (C) Copyright 2006 VeriSign, Inc.
|
3
|
+
* Developed by Sxip Identity
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
#ifndef COUNTPTR_H
|
18
|
+
#define COUNTPTR_H
|
19
|
+
|
20
|
+
#include <assert.h>
|
21
|
+
#ifdef DEBUGALLOC
|
22
|
+
#include <stdio.h>
|
23
|
+
#endif
|
24
|
+
|
25
|
+
/// @cond NO_INTERFACE
|
26
|
+
/**
|
27
|
+
* Reference counted pointer class.
|
28
|
+
*/
|
29
|
+
template <class T>
|
30
|
+
class CountPtrTo
|
31
|
+
{
|
32
|
+
public:
|
33
|
+
/**
|
34
|
+
* Create an empty (null) pointer.
|
35
|
+
*/
|
36
|
+
CountPtrTo ();
|
37
|
+
/**
|
38
|
+
* Create a reference counted pointer to the given raw pointer.
|
39
|
+
* Useful for the following idiom:
|
40
|
+
* \code
|
41
|
+
* CountPtrTo<T> pointer (new T);
|
42
|
+
* \endcode
|
43
|
+
* @param t Raw pointer
|
44
|
+
*/
|
45
|
+
CountPtrTo (T* t);
|
46
|
+
/**
|
47
|
+
* Copy constructor, increments reference count.
|
48
|
+
* @param cpt A counted pointer to "copy"
|
49
|
+
*/
|
50
|
+
CountPtrTo (const CountPtrTo<T>& cpt);
|
51
|
+
/**
|
52
|
+
* Decrement reference count and delete contained pointer if
|
53
|
+
* references are exhausted.
|
54
|
+
*/
|
55
|
+
~CountPtrTo ();
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Assignment operator, increments reference count.
|
59
|
+
* @param cpt A counted pointer to "copy"
|
60
|
+
*/
|
61
|
+
const CountPtrTo<T>& operator= (const CountPtrTo<T>& cpt);
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Member reference operator, asserts on null pointer.
|
65
|
+
*/
|
66
|
+
T* operator-> ();
|
67
|
+
/**
|
68
|
+
* Member reference operator, asserts on null pointer.
|
69
|
+
*/
|
70
|
+
const T* operator-> () const;
|
71
|
+
/**
|
72
|
+
* Dereference operator, asserts on null pointer.
|
73
|
+
*/
|
74
|
+
T& operator* ();
|
75
|
+
/**
|
76
|
+
* Dereference operator, asserts on null pointer.
|
77
|
+
*/
|
78
|
+
const T& operator* () const;
|
79
|
+
/**
|
80
|
+
* Cast to a void pointer, good for null checks.
|
81
|
+
* Does not assert on null.
|
82
|
+
*/
|
83
|
+
operator const void* () const;
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Equality operator, true if the counted pointers refer to the
|
87
|
+
* same raw pointer.
|
88
|
+
*/
|
89
|
+
int operator== (const CountPtrTo<T>&) const;
|
90
|
+
/**
|
91
|
+
* Inequality operator, true if the counted pointers do NOT refer
|
92
|
+
* to the same raw pointer.
|
93
|
+
*/
|
94
|
+
int operator!= (const CountPtrTo<T>&) const;
|
95
|
+
|
96
|
+
protected:
|
97
|
+
class CountPtr
|
98
|
+
{
|
99
|
+
public:
|
100
|
+
unsigned count;
|
101
|
+
T* pval;
|
102
|
+
|
103
|
+
CountPtr (T* pT)
|
104
|
+
: count (1), pval (pT)
|
105
|
+
{
|
106
|
+
assert(pval);
|
107
|
+
#ifdef DEBUGALLOC
|
108
|
+
|
109
|
+
printf("AddRef(%lx, %lx, %d)\n",
|
110
|
+
(unsigned long)this,
|
111
|
+
(unsigned long)pval,
|
112
|
+
count);
|
113
|
+
#endif // DEBUGALLOC
|
114
|
+
}
|
115
|
+
|
116
|
+
~CountPtr ()
|
117
|
+
{
|
118
|
+
delete pval;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
* ptr;
|
122
|
+
|
123
|
+
void AddRef (CountPtr*);
|
124
|
+
void DelRef ();
|
125
|
+
};
|
126
|
+
|
127
|
+
|
128
|
+
template <class T>
|
129
|
+
inline CountPtrTo<T>::CountPtrTo ()
|
130
|
+
: ptr (0)
|
131
|
+
{}
|
132
|
+
|
133
|
+
|
134
|
+
template <class T>
|
135
|
+
CountPtrTo<T>::CountPtrTo (T* pT)
|
136
|
+
: ptr (0)
|
137
|
+
{
|
138
|
+
if (pT)
|
139
|
+
{
|
140
|
+
ptr = new CountPtr(pT);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
|
145
|
+
template <class T>
|
146
|
+
inline CountPtrTo<T>::CountPtrTo (const CountPtrTo<T>& rCP)
|
147
|
+
: ptr (0)
|
148
|
+
{
|
149
|
+
AddRef(rCP.ptr);
|
150
|
+
}
|
151
|
+
|
152
|
+
|
153
|
+
template <class T>
|
154
|
+
inline CountPtrTo<T>::~CountPtrTo ()
|
155
|
+
{
|
156
|
+
DelRef();
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
template <class T>
|
161
|
+
const CountPtrTo<T>& CountPtrTo<T>::operator= (const CountPtrTo<T>& rCP)
|
162
|
+
{
|
163
|
+
if (this != &rCP)
|
164
|
+
{
|
165
|
+
DelRef();
|
166
|
+
AddRef(rCP.ptr);
|
167
|
+
}
|
168
|
+
return *this;
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
template <class T>
|
173
|
+
inline T* CountPtrTo<T>::operator-> ()
|
174
|
+
{
|
175
|
+
assert(ptr);
|
176
|
+
return ptr->pval;
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
template <class T>
|
181
|
+
inline const T* CountPtrTo<T>::operator-> () const
|
182
|
+
{
|
183
|
+
assert(ptr);
|
184
|
+
return ptr->pval;
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
template <class T>
|
189
|
+
inline T& CountPtrTo<T>::operator* ()
|
190
|
+
{
|
191
|
+
assert(ptr);
|
192
|
+
return *(ptr->pval);
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
template <class T>
|
197
|
+
inline const T& CountPtrTo<T>::operator* () const
|
198
|
+
{
|
199
|
+
assert(ptr);
|
200
|
+
return *(ptr->pval);
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
template <class T>
|
205
|
+
inline CountPtrTo<T>::operator const void* () const
|
206
|
+
{
|
207
|
+
return ptr ? this : 0;
|
208
|
+
}
|
209
|
+
|
210
|
+
|
211
|
+
template <class T>
|
212
|
+
inline int CountPtrTo<T>::operator== (const CountPtrTo<T>& rCP) const
|
213
|
+
{
|
214
|
+
return ptr == rCP.ptr;
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
template <class T>
|
219
|
+
inline int CountPtrTo<T>::operator!= (const CountPtrTo<T>& rCP) const
|
220
|
+
{
|
221
|
+
return ptr != rCP.ptr;
|
222
|
+
}
|
223
|
+
|
224
|
+
|
225
|
+
template <class T>
|
226
|
+
void CountPtrTo<T>::AddRef (CountPtr* pSt)
|
227
|
+
{
|
228
|
+
//DelRef();
|
229
|
+
ptr = pSt;
|
230
|
+
#ifdef DEBUGALLOC
|
231
|
+
printf("AddRef(%lx, %lx, %d)\n",
|
232
|
+
(unsigned long)ptr,
|
233
|
+
(unsigned long)(ptr ? ptr->pval : 0),
|
234
|
+
ptr ? ptr->count + 1 : 0);
|
235
|
+
#endif // DEBUGALLOC
|
236
|
+
if (ptr)
|
237
|
+
{
|
238
|
+
ptr->count++;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
|
243
|
+
template <class T>
|
244
|
+
void CountPtrTo<T>::DelRef ()
|
245
|
+
{
|
246
|
+
#ifdef DEBUGALLOC
|
247
|
+
printf("DelRef(%lx, %lx, %d)\n",
|
248
|
+
(unsigned long)ptr,
|
249
|
+
(unsigned long)(ptr ? ptr->pval : 0),
|
250
|
+
ptr ? ptr->count - 1 : 0);
|
251
|
+
#endif // DEBUGALLOC
|
252
|
+
|
253
|
+
if (ptr && (--ptr->count == 0))
|
254
|
+
{
|
255
|
+
delete ptr;
|
256
|
+
}
|
257
|
+
}
|
258
|
+
/// @endcond
|
259
|
+
|
260
|
+
#endif // COUNTPTR_H
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# (C) Copyright 2006 VeriSign, Inc.
|
4
|
+
# Developed by Sxip Identity
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
require 'fileutils'
|
19
|
+
require 'mkmf'
|
20
|
+
|
21
|
+
if /mswin32|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM
|
22
|
+
basedir = "../libext/win32-deps"
|
23
|
+
if !test(?d, basedir + "/include")
|
24
|
+
basedir = "../"
|
25
|
+
end
|
26
|
+
incdir = basedir + "/include"
|
27
|
+
libdir = basedir + "/lib"
|
28
|
+
lib_list = [ "libxmlsec.lib", "libxslt.lib", "libxml2.lib", "zlib.lib", "libxmlsec-openssl.lib", "libeay32.lib", "ssleay32.lib" ]
|
29
|
+
|
30
|
+
$CFLAGS << " /EHsc /DWIN32 /D_STATIC_CPPLIB=1 /D__XMLSEC_FUNCTION__=__FUNCTION__ /DXMLSEC_NO_XKMS=1 /DXMLSEC_CRYPTO=\\\"openssl\\\" /DXMLSEC_OPENSSL_097=1 /DXMLSEC_CRYPTO_OPENSSL=1 /DNDEBUG /I#{incdir}"
|
31
|
+
$LIBS << " msvcprt.lib " + (lib_list.collect { |x| libdir + "/" + x }).join(" ")
|
32
|
+
else
|
33
|
+
$CFLAGS << " $(shell xmlsec1-config --crypto=openssl --cflags) -DUNIX_SOCKETS -DNDEBUG"
|
34
|
+
$LIBS << " -lstdc++"
|
35
|
+
CONFIG['LDSHARED'] << " $(shell xmlsec1-config --crypto=openssl --libs)"
|
36
|
+
# fix to force C++ linker
|
37
|
+
CONFIG['LDSHARED'].sub!(/^g?cc/, "g++")
|
38
|
+
end
|
39
|
+
|
40
|
+
create_makefile('xmlsig')
|
41
|
+
|
42
|
+
open("Makefile", "a") { |mf|
|
43
|
+
mf.puts <<EOM
|
44
|
+
|
45
|
+
EXTNAME=xmlsig
|
46
|
+
EXTWRAPPER=$(EXTNAME).cpp
|
47
|
+
|
48
|
+
SWIG=swig
|
49
|
+
|
50
|
+
$(EXTWRAPPER):
|
51
|
+
$(SWIG) -c++ -ruby -o $(EXTWRAPPER) #{File.dirname mf.path}/swig/xmlsig.i
|
52
|
+
|
53
|
+
wrapper: $(EXTWRAPPER)
|
54
|
+
|
55
|
+
$(EXTNAME): wrapper
|
56
|
+
|
57
|
+
EOM
|
58
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# (C) Copyright 2006 VeriSign, Inc.
|
4
|
+
# Developed by Sxip Identity
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
require 'test/unit'
|
19
|
+
require 't/tc_signer'
|
20
|
+
require 't/tc_verifier'
|
21
|
+
require 't/tc_cert'
|
22
|
+
require 't/tc_interface'
|
23
|
+
require 't/tc_tsik'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/*
|
2
|
+
* (C) Copyright 2006 VeriSign, Inc.
|
3
|
+
* Developed by Sxip Identity
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
template <class T>
|
18
|
+
class CountPtrTo
|
19
|
+
{
|
20
|
+
public:
|
21
|
+
// CountPtrTo (); // redefine in %extend
|
22
|
+
CountPtrTo (T*);
|
23
|
+
CountPtrTo (const CountPtrTo<T>&);
|
24
|
+
~CountPtrTo ();
|
25
|
+
|
26
|
+
T* operator-> ();
|
27
|
+
};
|
@@ -0,0 +1,79 @@
|
|
1
|
+
/*
|
2
|
+
* (C) Copyright 2006 VeriSign, Inc.
|
3
|
+
* Developed by Sxip Identity
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
%include "exception.i"
|
18
|
+
%{
|
19
|
+
#include "Exceptions.h"
|
20
|
+
%}
|
21
|
+
|
22
|
+
//%include "src/Exceptions.h"
|
23
|
+
|
24
|
+
class DsigException
|
25
|
+
{
|
26
|
+
public:
|
27
|
+
DsigException ();
|
28
|
+
const char* what() const;
|
29
|
+
};
|
30
|
+
|
31
|
+
#if defined(SWIGPYTHON)
|
32
|
+
%extend DsigException {
|
33
|
+
char* __str__ ()
|
34
|
+
{
|
35
|
+
return (char*)self->what();
|
36
|
+
}
|
37
|
+
}
|
38
|
+
#endif
|
39
|
+
|
40
|
+
// Generic exceptions (with Swig analogs, see typemaps below)
|
41
|
+
class IOError: public DsigException {};
|
42
|
+
class MemoryError: public DsigException {};
|
43
|
+
class ValueError: public DsigException {};
|
44
|
+
|
45
|
+
// Exception classes specific to DSIG
|
46
|
+
class XMLError: public DsigException {};
|
47
|
+
class KeyError: public DsigException {};
|
48
|
+
class DocError: public DsigException {};
|
49
|
+
class XPathError: public DsigException {};
|
50
|
+
class TrustVerificationError: public DsigException {};
|
51
|
+
class LibError: public DsigException
|
52
|
+
{
|
53
|
+
public:
|
54
|
+
static void clearErrorLogs ();
|
55
|
+
};
|
56
|
+
|
57
|
+
// Fallthrough exception handler
|
58
|
+
%exception {
|
59
|
+
try
|
60
|
+
{
|
61
|
+
$action
|
62
|
+
}
|
63
|
+
catch (DsigException& e)
|
64
|
+
{
|
65
|
+
SWIG_exception(SWIG_RuntimeError, e.what());
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
%typemap(throws) IOError %{
|
70
|
+
SWIG_exception(SWIG_IOError, $1.what());
|
71
|
+
%}
|
72
|
+
|
73
|
+
%typemap(throws) MemoryError %{
|
74
|
+
SWIG_exception(SWIG_MemoryError, $1.what());
|
75
|
+
%}
|
76
|
+
|
77
|
+
%typemap(throws) ValueError %{
|
78
|
+
SWIG_exception(SWIG_ValueError, $1.what());
|
79
|
+
%}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/*
|
2
|
+
* (C) Copyright 2006 VeriSign, Inc.
|
3
|
+
* Developed by Sxip Identity
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
%trackobjects;
|