xsecverify.cxx (2200ed4b) xsecverify.cxx (202a5bb2)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 21 unchanged lines hidden (view full) ---

30
31#include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
32#include <com/sun/star/xml/crypto/sax/ElementMarkPriority.hpp>
33#include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
34#include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
35#include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultBroadcaster.hpp>
36#include <com/sun/star/xml/sax/SAXParseException.hpp>
37
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 21 unchanged lines hidden (view full) ---

30
31#include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
32#include <com/sun/star/xml/crypto/sax/ElementMarkPriority.hpp>
33#include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
34#include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
35#include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultBroadcaster.hpp>
36#include <com/sun/star/xml/sax/SAXParseException.hpp>
37
38// FIXME: copied from main/sal/rtl/source/strimp.c
39static sal_Bool rtl_ImplIsWhitespace( sal_Unicode c )
40{
41 /* Space or Control character? */
42 if ( (c <= 32) && c )
43 return sal_True;
44
45 /* Only in the General Punctuation area Space or Control characters are included? */
46 if ( (c < 0x2000) || (c > 0x206F) )
47 return sal_False;
48
49 if ( ((c >= 0x2000) && (c <= 0x200B)) || /* All Spaces */
50 (c == 0x2028) || /* LINE SEPARATOR */
51 (c == 0x2029) ) /* PARAGRAPH SEPARATOR */
52 return sal_True;
53
54 return sal_False;
55}
56
38namespace cssu = com::sun::star::uno;
39namespace cssl = com::sun::star::lang;
40namespace cssxc = com::sun::star::xml::crypto;
41namespace cssxs = com::sun::star::xml::sax;
42
43/* xml security framework components */
44#define SIGNATUREVERIFIER_COMPONENT "com.sun.star.xml.crypto.sax.SignatureVerifier"
45

--- 149 unchanged lines hidden (view full) ---

195{
196 InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
197 setIfEmpty(isi.signatureInfor.ouX509SerialNumber, ouX509SerialNumber);
198}
199
200void XSecController::setX509Certificate( rtl::OUString& ouX509Certificate )
201{
202 InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
57namespace cssu = com::sun::star::uno;
58namespace cssl = com::sun::star::lang;
59namespace cssxc = com::sun::star::xml::crypto;
60namespace cssxs = com::sun::star::xml::sax;
61
62/* xml security framework components */
63#define SIGNATUREVERIFIER_COMPONENT "com.sun.star.xml.crypto.sax.SignatureVerifier"
64

--- 149 unchanged lines hidden (view full) ---

214{
215 InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
216 setIfEmpty(isi.signatureInfor.ouX509SerialNumber, ouX509SerialNumber);
217}
218
219void XSecController::setX509Certificate( rtl::OUString& ouX509Certificate )
220{
221 InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
203 setIfEmpty(isi.signatureInfor.ouX509Certificate, ouX509Certificate);
222 setIfEmpty(isi.signatureInfor.ouX509Certificate, ouX509Certificate);
223 if (isi.signatureInfor.ouX509Certificate.getLength()) {
224 // We allow to re-set the same certificate only.
225 // Whitespace may change.
226 const sal_Int32 l1 = isi.signatureInfor.ouX509Certificate.getLength();
227 const sal_Int32 l2 = ouX509Certificate.getLength();
228 const sal_Unicode *s1 = isi.signatureInfor.ouX509Certificate.getStr();
229 const sal_Unicode *s2 = ouX509Certificate.getStr();
230 sal_Int32 i1 = 0, i2 = 0;
231 while ((i1 < l1) && (i2 < l2)) {
232 const sal_Unicode &c1 = s1[i1];
233 const sal_Unicode &c2 = s2[i2];
234 if (rtl_ImplIsWhitespace(c1)) {
235 ++i1;
236 continue;
237 }
238 if (rtl_ImplIsWhitespace(c2)) {
239 ++i2;
240 continue;
241 }
242 if (c1 != c2) {
243 throw cssu::RuntimeException(rtl::OUString::createFromAscii("Value already set. Tampering?"), *this);
244 }
245 ++i1;
246 ++i2;
247 }
248 // We could still have whitespace at the end of both strings
249 while ((i1 < l1) && rtl_ImplIsWhitespace(s1[l1])) {
250 ++i1;
251 }
252 while ((i2 < l2) && rtl_ImplIsWhitespace(s2[l2])) {
253 ++i2;
254 }
255 if ((i1 != l1) || (i2 != l2)) {
256 throw cssu::RuntimeException(rtl::OUString::createFromAscii("Value already set. Tampering?"), *this);
257 }
258 }
259 isi.signatureInfor.ouX509Certificate = ouX509Certificate;
204}
205
206void XSecController::setSignatureValue( rtl::OUString& ouSignatureValue )
207{
208 InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
209 isi.signatureInfor.ouSignatureValue = ouSignatureValue;
210}
211

--- 124 unchanged lines hidden ---
260}
261
262void XSecController::setSignatureValue( rtl::OUString& ouSignatureValue )
263{
264 InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
265 isi.signatureInfor.ouSignatureValue = ouSignatureValue;
266}
267

--- 124 unchanged lines hidden ---