summaryrefslogtreecommitdiff
path: root/package/qa
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2006-03-24 12:20:20 +0000
committerOliver Bolte <obo@openoffice.org>2006-03-24 12:20:20 +0000
commitf7f7d6cb0945814443c90917bafb32078b24089f (patch)
tree3c420437bde7e8cba3bce9c191356cf1b41e6fb2 /package/qa
parentd59c440a5ae1c42c1d3b5a497097153fbdcd322a (diff)
INTEGRATION: CWS fwk33 (1.5.42); FILE MERGED
2006/03/13 13:13:18 mav 1.5.42.1: #i61909# add new regression tests
Diffstat (limited to 'package/qa')
-rw-r--r--package/qa/storages/TestHelper.java103
1 files changed, 103 insertions, 0 deletions
diff --git a/package/qa/storages/TestHelper.java b/package/qa/storages/TestHelper.java
index f39321bf419a..2a93eb23a87d 100644
--- a/package/qa/storages/TestHelper.java
+++ b/package/qa/storages/TestHelper.java
@@ -859,6 +859,109 @@ public class TestHelper {
return xSubStream;
}
+ public boolean compareRawMethodsOnEncrStream( XStorage xStorage, String sStreamName )
+ {
+
+ XStorageRawAccess xRawStorage;
+ try
+ {
+ xRawStorage = (XStorageRawAccess) UnoRuntime.queryInterface( XStorageRawAccess.class, xStorage );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't get raw access to the storage, exception : " + e + "!" );
+ return false;
+ }
+
+ if ( xRawStorage == null )
+ {
+ Error( "Can't get raw access to the storage!" );
+ return false;
+ }
+
+ XInputStream xHeadRawStream = null;
+ try
+ {
+ xHeadRawStream = xRawStorage.getRawEncrStreamElement( sStreamName );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't open encrypted stream '" + sStreamName + "' in raw mode with header, exception : " + e + "!" );
+ }
+
+ XInputStream xPlainRawStream = null;
+ try
+ {
+ xPlainRawStream = xRawStorage.getPlainRawStreamElement( sStreamName );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't open encrypted stream '" + sStreamName + "' in raw mode with header, exception : " + e + "!" );
+ }
+
+ if ( xHeadRawStream == null || xPlainRawStream == null )
+ {
+ Error( "Can't open encrypted stream '" + sStreamName + "' in raw modes!" );
+ return false;
+ }
+
+ try
+ {
+ byte pData[][] = new byte[1][22];
+ if ( xHeadRawStream.readBytes( pData, 22 ) != 22 )
+ {
+ Error( "Can't read header of encrypted stream '" + sStreamName + "' raw representations!" );
+ return false;
+ }
+
+ if ( pData[0][0] != 0x4d || pData[0][1] != 0x47 || pData[0][2] != 0x02 || pData[0][3] != 0x05 )
+ {
+ Error( "No signature in the header of encrypted stream '" + sStreamName + "' raw representations!" );
+ return false;
+ }
+
+ int nVariableHeaderLength =
+ ( pData[0][14] + pData[0][15] * 0x100 ) // salt length
+ + ( pData[0][16] + pData[0][17] * 0x100 ) // iv length
+ + ( pData[0][18] + pData[0][19] * 0x100 ) // digest length
+ + ( pData[0][20] + pData[0][21] * 0x100 ); // mediatype length
+
+ xHeadRawStream.skipBytes( nVariableHeaderLength );
+
+ byte pRawData1[][] = new byte[1][32000];
+ byte pRawData2[][] = new byte[1][32000];
+ int nRead1 = 0;
+ int nRead2 = 0;
+
+ do
+ {
+ nRead1 = xHeadRawStream.readBytes( pRawData1, 32000 );
+ nRead2 = xPlainRawStream.readBytes( pRawData2, 32000 );
+
+ if ( nRead1 != nRead2 )
+ {
+ Error( "The encrypted stream '" + sStreamName + "' raw representations have different size!" );
+ return false;
+ }
+
+ for ( int nInd = 0; nInd < nRead1; nInd++ )
+ if ( pRawData1[0][nInd] != pRawData2[0][nInd] )
+ {
+ Error( "The encrypted stream '" + sStreamName + "' raw representations have different data!" );
+ return false;
+ }
+ }
+ while( nRead1 == 32000 );
+ }
+ catch ( Exception e )
+ {
+ Error( "Can't compare stream '" + sStreamName + "' raw representations, exception : " + e + "!" );
+ return false;
+ }
+
+ return true;
+ }
+
public boolean cantOpenStorage( XStorage xStorage, String sName )
{
// try to open an opened substorage, open call must fail