31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

10.6 Automatic Decoder supporting Cryptography (<br />

CryptAutoDecoder )<br />

1. Definition<br />

<strong>The</strong> class CryptAutoDecoder is an extension of AutoDecoder. It can be used for decoding<br />

encrypted streams (in particular if the coder used for encoding is unknown). In order<br />

to decrypt a stream a key must be provided by the user because the key is – of course<br />

– not stored in the encrypted stream. <strong>The</strong>re are three possibilities to specify a key: as<br />

a CryptKey, as a key stream or as a key file. Sometimes it may be necessary to provide<br />

several keys to CryptAutoDecoder. E.g., if you use CoderPipe2< OMACCoder,<br />

OFBCoder > to encode a stream two keys are needed for decoding. <strong>The</strong>refore,<br />

CryptAutoDecoder maintains a list of keys for decoding.<br />

#include < <strong>LEDA</strong>/coding/crypt auto decoder.h ><br />

2. Creation<br />

CryptAutoDecoder C(streambuf ∗ src stream = 0, streambuf ∗ tgt stream = 0,<br />

bool own streams = false);<br />

creates an instance C which uses the given source and target<br />

streams. If own streams is set, then C is responsible for the destruction<br />

of the streams, otherwise the pointers src stream and tgt stream<br />

must be valid during the life-time of C.<br />

CryptAutoDecoder<br />

C(const char ∗ src file name, const char ∗ tgt file name);<br />

creates an instance C which uses file-streams for input and output.<br />

3. Operations<br />

Standard Operations<br />

void C.decode( ) decodes the source stream and writes the output to<br />

the target stream.<br />

uint32<br />

streambuf ∗<br />

C.decode memory chunk(const char ∗ in buf , uint32 in len,<br />

char ∗ out buf , uint32 out len)<br />

decodes the memory chunk starting at in buf with<br />

size in len into the buffer starting at out buf with<br />

size out len. <strong>The</strong> function returns actual length<br />

of the encoded chunk which may be smaller than<br />

out len. If the output buffer is too small for the<br />

decoded data the failure flag will be set (see below).<br />

C.get src stream( ) returns the current source stream.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!