1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _CIPHERCONTEXT_HXX 29 #define _CIPHERCONTEXT_HXX 30 31 #include <com/sun/star/xml/crypto/XCipherContext.hpp> 32 33 #include <cppuhelper/implbase1.hxx> 34 #include <osl/mutex.hxx> 35 #include <pk11pub.h> 36 37 class OCipherContext : public cppu::WeakImplHelper1< ::com::sun::star::xml::crypto::XCipherContext > 38 { 39 private: 40 ::osl::Mutex m_aMutex; 41 42 PK11SlotInfo* m_pSlot; 43 PK11SymKey* m_pSymKey; 44 SECItem* m_pSecParam; 45 PK11Context* m_pContext; 46 47 sal_Int32 m_nBlockSize; 48 ::com::sun::star::uno::Sequence< sal_Int8 > m_aLastBlock; 49 50 bool m_bEncryption; 51 bool m_bPadding; 52 bool m_bW3CPadding; 53 sal_Int64 m_nConverted; 54 55 bool m_bDisposed; 56 bool m_bBroken; 57 58 void Dispose(); 59 60 OCipherContext() 61 : m_pSlot( NULL ) 62 , m_pSymKey( NULL ) 63 , m_pSecParam( NULL ) 64 , m_pContext( NULL ) 65 , m_nBlockSize( 0 ) 66 , m_bEncryption( false ) 67 , m_bPadding( false ) 68 , m_bW3CPadding( false ) 69 , m_nConverted( 0 ) 70 , m_bDisposed( false ) 71 , m_bBroken( false ) 72 {} 73 74 public: 75 76 virtual ~OCipherContext() 77 { 78 Dispose(); 79 } 80 81 static ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XCipherContext > Create( CK_MECHANISM_TYPE nNSSCipherID, const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aKey, const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aInitializationVector, bool bEncryption, bool bW3CPadding ); 82 83 // XCipherContext 84 virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL convertWithCipherContext( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::DisposedException, ::com::sun::star::uno::RuntimeException); 85 virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL finalizeCipherContextAndDispose( ) throw (::com::sun::star::lang::DisposedException, ::com::sun::star::uno::RuntimeException); 86 }; 87 88 #endif 89 90