summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMikhail Voytenko <mav@openoffice.org>2011-03-23 18:59:23 +0100
committerMikhail Voytenko <mav@openoffice.org>2011-03-23 18:59:23 +0100
commit0cdc1272fdfbf181b6f297185e0a02dddb912a1a (patch)
treeeba8032d6c0e9d131861196d6689219d60821543 /xmlsecurity
parent1decd7beffc8333d441b4327649685464e129d26 (diff)
mav60: #164341# fix problems with the new implementation
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/xmlsec/nss/digestcontext.cxx19
-rw-r--r--xmlsecurity/source/xmlsec/nss/digestcontext.hxx7
-rw-r--r--xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx13
3 files changed, 29 insertions, 10 deletions
diff --git a/xmlsecurity/source/xmlsec/nss/digestcontext.cxx b/xmlsecurity/source/xmlsec/nss/digestcontext.cxx
index 17b700f1fd63..4b3a0d094bd9 100644
--- a/xmlsecurity/source/xmlsec/nss/digestcontext.cxx
+++ b/xmlsecurity/source/xmlsec/nss/digestcontext.cxx
@@ -52,12 +52,21 @@ void SAL_CALL ODigestContext::updateDigest( const uno::Sequence< ::sal_Int8 >& a
if ( m_bDisposed )
throw lang::DisposedException();
- if ( PK11_DigestOp( m_pContext, reinterpret_cast< const unsigned char* >( aData.getConstArray() ), aData.getLength() ) != SECSuccess )
+ if ( !m_b1KData || m_nDigested < 1024 )
{
- PK11_DestroyContext( m_pContext, PR_TRUE );
- m_pContext = NULL;
- m_bBroken = true;
- throw uno::RuntimeException();
+ uno::Sequence< sal_Int8 > aToDigest = aData;
+ if ( m_b1KData && m_nDigested + aData.getLength() > 1024 )
+ aToDigest.realloc( 1024 - m_nDigested );
+
+ if ( PK11_DigestOp( m_pContext, reinterpret_cast< const unsigned char* >( aToDigest.getConstArray() ), aToDigest.getLength() ) != SECSuccess )
+ {
+ PK11_DestroyContext( m_pContext, PR_TRUE );
+ m_pContext = NULL;
+ m_bBroken = true;
+ throw uno::RuntimeException();
+ }
+
+ m_nDigested += aToDigest.getLength();
}
}
diff --git a/xmlsecurity/source/xmlsec/nss/digestcontext.hxx b/xmlsecurity/source/xmlsec/nss/digestcontext.hxx
index 88b2063a84dc..8f9ef475a485 100644
--- a/xmlsecurity/source/xmlsec/nss/digestcontext.hxx
+++ b/xmlsecurity/source/xmlsec/nss/digestcontext.hxx
@@ -40,13 +40,18 @@ private:
PK11Context* m_pContext;
sal_Int32 m_nDigestLength;
+ bool m_b1KData;
+ sal_Int32 m_nDigested;
+
bool m_bDisposed;
bool m_bBroken;
public:
- ODigestContext( PK11Context* pContext, sal_Int32 nDigestLength )
+ ODigestContext( PK11Context* pContext, sal_Int32 nDigestLength, bool b1KData )
: m_pContext( pContext )
, m_nDigestLength( nDigestLength )
+ , m_b1KData( b1KData )
+ , m_nDigested( 0 )
, m_bDisposed( false )
, m_bBroken( false )
{}
diff --git a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
index 81fe6857bf75..2cccd079f8e5 100644
--- a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
@@ -455,15 +455,20 @@ css::uno::Reference< css::xml::crypto::XDigestContext > SAL_CALL SEInitializer_N
{
SECOidTag nNSSDigestID = SEC_OID_UNKNOWN;
sal_Int32 nDigestLength = 0;
- if ( nDigestID == css::xml::crypto::DigestID::SHA256 )
+ bool b1KData = false;
+ if ( nDigestID == css::xml::crypto::DigestID::SHA256
+ || nDigestID == css::xml::crypto::DigestID::SHA256_1K )
{
nNSSDigestID = SEC_OID_SHA256;
nDigestLength = 32;
+ b1KData = ( nDigestID == css::xml::crypto::DigestID::SHA256_1K );
}
- else if ( nDigestID != css::xml::crypto::DigestID::SHA1 )
+ else if ( nDigestID == css::xml::crypto::DigestID::SHA1
+ || nDigestID == css::xml::crypto::DigestID::SHA1_1K )
{
nNSSDigestID = SEC_OID_SHA1;
- nDigestLength = 16;
+ nDigestLength = 20;
+ b1KData = ( nDigestID == css::xml::crypto::DigestID::SHA1_1K );
}
else
throw css::lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unexpected digest requested." ) ), css::uno::Reference< css::uno::XInterface >(), 1 );
@@ -476,7 +481,7 @@ css::uno::Reference< css::xml::crypto::XDigestContext > SAL_CALL SEInitializer_N
{
PK11Context* pContext = PK11_CreateDigestContext( nNSSDigestID );
if ( pContext && PK11_DigestBegin( pContext ) == SECSuccess )
- xResult = new ODigestContext( pContext, nDigestLength );
+ xResult = new ODigestContext( pContext, nDigestLength, b1KData );
}
return xResult;