22#include <com/sun/star/lang/DisposedException.hpp>
23#include <rtl/cipher.h>
31uno::Reference< xml::crypto::XCipherContext >
BlowfishCFB8CipherContext::Create(
const uno::Sequence< sal_Int8 >& aDerivedKey,
const uno::Sequence< sal_Int8 >& aInitVector,
bool bEncrypt )
34 xResult->m_pCipher = rtl_cipher_create( rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeStream );
35 if ( !xResult->m_pCipher )
36 throw uno::RuntimeException(
"Can not create cipher!" );
38 if ( rtl_Cipher_E_None != rtl_cipher_init(
40 bEncrypt ? rtl_Cipher_DirectionEncode : rtl_Cipher_DirectionDecode,
41 reinterpret_cast< const sal_uInt8*
>( aDerivedKey.getConstArray() ),
42 aDerivedKey.getLength(),
43 reinterpret_cast< const sal_uInt8*
>( aInitVector.getConstArray() ),
44 aInitVector.getLength() ) )
46 throw uno::RuntimeException(
"Can not initialize cipher!" );
49 xResult->m_bEncrypt = bEncrypt;
67 throw lang::DisposedException();
69 uno::Sequence< sal_Int8 > aResult(
aData.getLength() );
70 rtlCipherError nError = rtl_Cipher_E_None;
75 aData.getConstArray(),
77 reinterpret_cast< sal_uInt8*
>( aResult.getArray() ),
78 aResult.getLength() );
83 aData.getConstArray(),
85 reinterpret_cast< sal_uInt8*
>( aResult.getArray() ),
86 aResult.getLength() );
89 if ( rtl_Cipher_E_None != nError )
91 throw uno::RuntimeException(
"Can not decrypt/encrypt with cipher!" );
101 throw lang::DisposedException();
106 return uno::Sequence< sal_Int8 >();
static css::uno::Reference< css::xml::crypto::XCipherContext > Create(const css::uno::Sequence< sal_Int8 > &aDerivedKey, const css::uno::Sequence< sal_Int8 > &aInitVector, bool bEncrypt)
virtual ~BlowfishCFB8CipherContext() override
BlowfishCFB8CipherContext()
virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL convertWithCipherContext(const css::uno::Sequence< ::sal_Int8 > &aData) override
virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL finalizeCipherContextAndDispose() override
constexpr OUStringLiteral aData