RMS SDK for C++  0.2.1
A client library for using Microsoft RMS from Linux.
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
rmscore::modernapi::CustomProtectedStream Class Reference

Used to access files that use a custom protection format. More...

#include <CustomProtectedStream.h>

Inheritance diagram for rmscore::modernapi::CustomProtectedStream:
rmscrypto::api::IStream

Public Member Functions

virtual std::shared_future< int64_t > ReadAsync (uint8_t *pbBuffer, int64_t cbBuffer, int64_t cbOffset, std::launch launchType) override
 Requests contents of the stream to be read asynchronously into pbBuffer, and returns a std::shared_future to track status of the asynchronous operation. Call .get() or .wait() on this shared_future to synchronously await its completion. More...
 
virtual std::shared_future< int64_t > WriteAsync (const uint8_t *cpbBuffer, int64_t cbBuffer, int64_t cbOffset, std::launch launchType) override
 Requests that data from *cpbBuffer be written asynchronously to stream, and returns a std::shared_future to track status of the asynchronous operation. Call .get() or .wait() on this shared_future to synchronously await its completion. More...
 
virtual std::future< bool > FlushAsync (std::launch launchType) override
 Requests that pending data be flushed asynchronously to stream, and returns a std::shared_future to track status of the asynchronous operation. Call .get() or .wait() on this shared_future to synchronously await its completion. More...
 
virtual int64_t Read (uint8_t *pbBuffer, int64_t cbBuffer) override
 Reads data from the backing stream. More...
 
virtual int64_t Write (const uint8_t *cpbBuffer, int64_t cbBuffer) override
 Writes data to the backing stream. More...
 
virtual bool Flush () override
 Flushes the data to the backing stream. More...
 
virtual rmscrypto::api::SharedStream Clone () override
 Creates a copy of the CustomProtectedStream. More...
 
virtual void Seek (uint64_t u64Position) override
 Sets the current position to the specified offset in the stream. More...
 
virtual bool CanRead () const override
 Gets a value that indicates whether the file can be read from. More...
 
virtual bool CanWrite () const override
 Gets a value that indicates whether the file can be written to. More...
 
virtual uint64_t Position () override
 Gets the current file seek offset. More...
 
virtual uint64_t Size () override
 Gets the size of the protected data in bytes. More...
 
virtual void Size (uint64_t u64Value) override
 Sets the size of the protected data in bytes. More...
 
- Public Member Functions inherited from rmscrypto::api::IStream
virtual std::vector< uint8_t > Read (uint64_t u64size)
 

Static Public Member Functions

static std::shared_ptr< CustomProtectedStreamCreate (std::shared_ptr< UserPolicy > policy, rmscrypto::api::SharedStream stream, uint64_t contentStartPosition, uint64_t contentSize)
 Creates a CustomProtectedStream object based on the specified protection policy and a backing stream. More...
 
static uint64_t GetEncryptedContentLength (std::shared_ptr< UserPolicy >policy, uint64_t contentLength)
 Calculates the length of the encrypted content from the length of the plaintext content. More...
 

Protected Member Functions

 CustomProtectedStream (std::shared_ptr< IStream >pImpl)
 
std::shared_ptr< IStreamGetImpl ()
 

Detailed Description

Used to access files that use a custom protection format.

Important - RMS applications that use CustomProtectedStream may be incompatible with SharePoint, Exchange, and other RMS applications. For most applications, it is recommended that you use ProtectedFileStream instead.

Member Function Documentation

bool rmscore::modernapi::CustomProtectedStream::CanRead ( ) const
overridevirtual

Gets a value that indicates whether the file can be read from.

Returns
True if the file can be read from; otherwise false.

Implements rmscrypto::api::IStream.

bool rmscore::modernapi::CustomProtectedStream::CanWrite ( ) const
overridevirtual

Gets a value that indicates whether the file can be written to.

Returns
True if the file can be written to; otherwise false.

Implements rmscrypto::api::IStream.

SharedStream rmscore::modernapi::CustomProtectedStream::Clone ( )
overridevirtual

Creates a copy of the CustomProtectedStream.

Returns
A CustomProtectedStream object that represents the new stream. The initial seek position of the stream is 0. The seek position and lifetime of the new stream are independent of the position and lifetime of the original stream.

Implements rmscrypto::api::IStream.

shared_ptr< CustomProtectedStream > rmscore::modernapi::CustomProtectedStream::Create ( std::shared_ptr< UserPolicy policy,
rmscrypto::api::SharedStream  stream,
uint64_t  contentStartPosition,
uint64_t  contentSize 
)
static

Creates a CustomProtectedStream object based on the specified protection policy and a backing stream.

The CustomProtectedStream can be used for both encrypting and decrypting content. If the backing stream already contains encrypted content, you can use the stream Read* methods to decrypt and read it. You can also use stream Write* methods to encrypt and write content to the backing stream.

Warning - To avoid data loss and/or corruption, the Flush* methods must be called if you modify the created stream before the stream goes out of scope or is manually disposed.

Warning - This method must be called on a UI thread. Calling it on a worker thread may result in an unexpected behavior.

Remarks
You must specify a range (contentStartPosition, contentSize) where the encrypted content is located in the backing stream. If there is no existing content in the backing stream (e.g. a new file), specify contentSize as 0. If the existing content ends at the end of the stream, you can specify ulong.MaxValue for contentSize. The contentSize parameter is needed only for those cases where there is non-encrypted app-specific content after the encrypted content; in this case the method needs to know where the encrypted content ends when performing decryption. The contentSize parameter is specified in terms of the encrypted content. For example, it should include the size of the CBC padding. If the range defined by the parameters contentStartPosition and contentSize is not empty (i.e. contentSize != 0), it must address an entire segment of encrypted content; that is, it must start from block 0 and must have a final block (for CBC) or be 16-byte aligned (for ECB).
Parameters
policyThe user policy to apply to protect the content.
streamThe backing stream.
contentStartPositionThe start position of encrypted content within the stream.
contentSizeThe size of the encrypted content within the stream.
Returns
A CustomProtectedStream object that can be used to write content to the encrypted portion of the backing stream.
bool rmscore::modernapi::CustomProtectedStream::Flush ( )
overridevirtual

Flushes the data to the backing stream.

Returns
The result of the flush operation. True if data was successfully flushed; otherwise False.

Implements rmscrypto::api::IStream.

future< bool > rmscore::modernapi::CustomProtectedStream::FlushAsync ( std::launch  launchType)
overridevirtual

Requests that pending data be flushed asynchronously to stream, and returns a std::shared_future to track status of the asynchronous operation. Call .get() or .wait() on this shared_future to synchronously await its completion.

Parameters
launchTypeCan be std::launch::async and/or std::launch::deferred. If deferred, flush will take place "lazily" - i.e. only when get() or wait() is called.
Returns
(Future of) the result of the flush operation. True if data was successfully flushed; otherwise False.

Implements rmscrypto::api::IStream.

uint64_t rmscore::modernapi::CustomProtectedStream::GetEncryptedContentLength ( std::shared_ptr< UserPolicy policy,
uint64_t  contentLength 
)
static

Calculates the length of the encrypted content from the length of the plaintext content.

Parameters
policyPointer to userPolicy object.
contentLenghtLength of the plaintext content.
Returns
The encrypted content length.
uint64_t rmscore::modernapi::CustomProtectedStream::Position ( )
overridevirtual

Gets the current file seek offset.

Returns
The current file seek offset.

Implements rmscrypto::api::IStream.

int64_t rmscore::modernapi::CustomProtectedStream::Read ( uint8_t *  pbBuffer,
int64_t  cbBuffer 
)
overridevirtual

Reads data from the backing stream.

Parameters
pbBufferThe buffer into which the read operation puts the bytes that are read.
cbBufferThe number of bytes available in the buffer.
Returns
Number of bytes actually read.

Implements rmscrypto::api::IStream.

shared_future< int64_t > rmscore::modernapi::CustomProtectedStream::ReadAsync ( uint8_t *  pbBuffer,
int64_t  cbBuffer,
int64_t  cbOffset,
std::launch  launchType 
)
overridevirtual

Requests contents of the stream to be read asynchronously into pbBuffer, and returns a std::shared_future to track status of the asynchronous operation. Call .get() or .wait() on this shared_future to synchronously await its completion.

Parameters
pbBufferThe buffer into which the (asynchronous) read operation should place read bytes.
cbBufferCount of bytes in this buffer.
cbOffsetOffset into the buffer where bytes should begin being written.
launchTypeCan be std::launch::async and/or std::launch::deferred. If deferred, read will take place "lazily" - i.e. only when get() or wait() is called.
Returns
(Future of) count of bytes read.

Implements rmscrypto::api::IStream.

void rmscore::modernapi::CustomProtectedStream::Seek ( uint64_t  u64Position)
overridevirtual

Sets the current position to the specified offset in the stream.

Parameters
u64PositionThe offset in the stream to move to.

Implements rmscrypto::api::IStream.

uint64_t rmscore::modernapi::CustomProtectedStream::Size ( )
overridevirtual

Gets the size of the protected data in bytes.

Returns
Size of the protected data in bytes.

Implements rmscrypto::api::IStream.

void rmscore::modernapi::CustomProtectedStream::Size ( uint64_t  u64Value)
overridevirtual

Sets the size of the protected data in bytes.

Parameters
u64ValueSize of the protected data in bytes.

Implements rmscrypto::api::IStream.

int64_t rmscore::modernapi::CustomProtectedStream::Write ( const uint8_t *  cpbBuffer,
int64_t  cbBuffer 
)
overridevirtual

Writes data to the backing stream.

Parameters
cpbBufferThe buffer from which the write operation reads data to be written.
cbBufferThe size of the buffer.
Returns
Number of bytes written.

Implements rmscrypto::api::IStream.

shared_future< int64_t > rmscore::modernapi::CustomProtectedStream::WriteAsync ( const uint8_t *  cpbBuffer,
int64_t  cbBuffer,
int64_t  cbOffset,
std::launch  launchType 
)
overridevirtual

Requests that data from *cpbBuffer be written asynchronously to stream, and returns a std::shared_future to track status of the asynchronous operation. Call .get() or .wait() on this shared_future to synchronously await its completion.

Parameters
cpbBufferPointer to the buffer from which the write operation will read contents to be written.
cbBufferCount of bytes in cpbBuffer.
cbOffsetOffset into cpbBuffer where operation will begin reading from for write.
launchTypeCan be std::launch::async and/or std::launch::deferred. If deferred, write will take place "lazily" - i.e. only when get() or wait() is called.
Returns
(Future of) count of bytes written.

Implements rmscrypto::api::IStream.


The documentation for this class was generated from the following files: