/usr/share/doc/libbobcat3/man/decryptbuf.3.html is in libbobcat-dev 3.23.01-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | <html><head>
<title>FBB::DecryptBuf</title>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr>
<h1>FBB::DecryptBuf</h1>
<h2>libbobcat-dev_3.23.01-x.tar.gz</h2>
<h2>2005-2014</h2>
<html><head>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr>
<h1></h1>
<html><head>
<title>FBB::DecryptBuf(3bobcat)</title>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr>
<h1>FBB::DecryptBuf(3bobcat)</h1>
<h2>libbobcat-dev_3.23.01-x.tar.gz Decrypt information</h2>
<h2>2005-2014</h2>
<p>
<h2>NAME</h2>FBB::DecryptBuf - Decrypts information using various methods into a std::ostream
<p>
<h2>SYNOPSIS</h2>
<strong>#include <bobcat/decryptbuf></strong><br>
Linking option: <em> -lbobcat</em>
<p>
<h2>DESCRIPTION</h2>
<strong>FBB::DecryptBuf</strong> objects are <strong>std::streambuf</strong> objects that can be used
to initialize <em>std::ostream</em> objects with.
<p>
All information inserted into such a <em>std::ostream</em> is decrypted and
written into a <em>std::ostream</em> that is given as argument to <em>DecryptBuf</em>'s
constructor.
<p>
All encryption methods defined by the OpenSSL library that can be selected
by name may be used in combination with <em>DecryptBuf</em> objects. Most likely
the information will have been encrypted using an <em>EncryptBuf</em> object,
selecting a particular encryption method. The encryption method used when
encrypting information should also be specified when constructing a
<em>DecryptBuf</em> object. Likewise, the constructor expects a <em>key</em> and
<em>initialization vector</em>. The key and initialization vector that was passed
to the <em>EncryptBuf</em> object must be passed to <em>DecryptBuf</em>'s constructor as
well.
<p>
Block ciphers use one of the following four encryption modes:
<ul>
<li> <strong>CBC (Cipher Block Chaining)</strong>:<br>
The first block is XOR-ed by the initialization vector and then
encrypted using the specified method. Subsequent blocks are XOR-ed by the
encrypted version of the preceding block. Due to the initialization vector
dictionary attacks are infeasible, as long as the initialization vector is
truly random.
<li> <strong>ECB (Electronic Code Book)</strong>:<br>
Each block is encrypted by itself, using the specified encryption
method. Although an <em>initialization vector</em> may be specified, it is not
used. This method is susceptible to dictionary attacks and should therefore be
avoided, unless you know what you're doing.
<li> <strong>CFB (Cipher Feednack)</strong>:<br>
This method allows a block cipher to be used as a stream cipher. It
uses an initialization vector, which should be unique and random for each new
stream of data that is encrypted using the method. Encryption can only start
after the first data block has been received.
<li> <strong>OFB (Output Feednack)</strong>:<br>
This is an alternative way to use a block cipher as a stream
cipher. It is somewhat more susceptible to traditional data manipulation
attacks, which can usually be thwarted when a message authentication code is
added to the information as well. Like CFB it uses an initialization vector,
which should again be unique and random for each new stream of data that is
encrypted.
</ul>
<p>
The following table presents an overview of methods that are currently
available. Methods for which the block size is specified as N.A. are stream
ciphers; other methods are block ciphers:
<table>
<td colspan=5><hr></td>
<tr>
<td> method</td><td> keysize</td><td> blocksize</td><td> mode</td><td> identifier</td>
</tr>
<tr>
<td> </td><td> (bytes)</td><td> (bytes)</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> AES</td><td> 16</td><td> 8</td><td> CBC</td><td> "aes-128-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "aes-128-ecb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "aes-128-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "aes-128-ofb"</td>
</tr>
<tr>
<td> </td><td> 24</td><td> 24</td><td> CBC</td><td> "aes-192-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "aes-192-ecb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "aes-192-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "aes-192-ofb"</td>
</tr>
<tr>
<td> </td><td> 32</td><td> 32</td><td> CBC</td><td> "aes-256-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "aes-256-ecb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "aes-256-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "aes-256-ofb"</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> BLOWFISH</td><td> 16</td><td> 8</td><td> CBC</td><td> "bf-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "bf-ecb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "bf-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "bf-ofb"</td>
</tr>
<tr>
<td> max key length is 56 bytes, 16 generally used</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> CAMELLIA</td><td> 16</td><td> 16</td><td> CBC</td><td> "camellia-128-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "camellia-128-ecb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "camellia-128-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "camellia-128-ofb"</td>
</tr>
<tr>
<td> </td><td> 24</td><td> </td><td> CBC</td><td> "camellia-192-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "camellia-192-ecb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "camellia-192-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "camellia-192-ofb"</td>
</tr>
<tr>
<td> </td><td> 32</td><td> </td><td> CBC</td><td> "camellia-256-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "camellia-256-ecb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "camellia-256-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "camellia-256-ofb"</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> CAST</td><td> 16</td><td> 8</td><td> CBC</td><td> "cast-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "cast-ecb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "cast-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "cast-ofb"</td>
</tr>
<tr>
<td> min key length is 5 bytes, max is shown</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> DES</td><td> 8</td><td> 8</td><td> CBC</td><td> "des-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "des-ebc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "des-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "des-ofb"</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> DESX</td><td> 8</td><td> 8</td><td> CBC</td><td> "desx-cbc"</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> 3DES</td><td> 16</td><td> 8</td><td> CBC</td><td> "des-ede-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "des-ede"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "des-ede-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "des-ede-ofb"</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> 3DES</td><td> 24</td><td> 8</td><td> CBC</td><td> "des-ede3-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "des-ede3"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "des-ede3-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "des-ede3-ofb"</td>
</tr>
<tr>
<td> Key bytes 9-16 define the 2nd key, bytes 17-24</td>
</tr>
<tr>
<td> define the 3rd key</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> RC2</td><td> 16</td><td> 8</td><td> CBC</td><td> "rc2-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "rc2-ecb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "rc2-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "rc2-ofb"</td>
</tr>
<tr>
<td> Key length variable, max. 128 bytes, default length is shown</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> RC2-40</td><td> 5</td><td> 8</td><td> </td><td> "rc2-40-cbc"</td>
</tr>
<tr>
<td> obsolete: avoid</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> RC2-64</td><td> 8</td><td> 8</td><td> </td><td> "rc2-64-cbc"</td>
</tr>
<tr>
<td> obsolete: avoid</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> RC4</td><td> 16</td><td> N.A.</td><td> </td><td> "rc4"</td>
</tr>
<tr>
<td> Key length is variable, max. 256 bytes. default length is shown</td>
</tr>
<tr>
<td> Encrypt again to decrypt. Don't use <em>DecryptBuf</em></td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> RC4-40</td><td> 5</td><td> N.A.</td><td> </td><td> "rc4-40"</td>
</tr>
<tr>
<td> obsolete: avoid</td>
</tr>
<td colspan=5><hr></td>
<tr>
<td> RC5</td><td> 16</td><td> 8</td><td> CBC</td><td> "rc5-cbc"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> EBC</td><td> "rc5-ecb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> CFB</td><td> "rc5-cfb"</td>
</tr>
<tr>
<td> </td><td> </td><td> </td><td> OFB</td><td> "rc5-ofb"</td>
</tr>
<tr>
<td> Key length variable, max. 256 bytes, rounds 8, 12 or 16,</td>
</tr>
<tr>
<td> default # rounds is 12</td>
</tr>
<td colspan=5><hr></td>
</table>
<p>
The RC4 stream cipher is subject to a well-known attack
(cf. <a href="http://www.wisdom.weizmann.ac.il/~itsik/RC4/Papers/Mantin1.zip">http://www.wisdom.weizmann.ac.il/~itsik/RC4/Papers/Mantin1.zip</a>)
unless the initial 256 bytes produced by the cipher are discarded.
<p>
<h2>NAMESPACE</h2>
<strong>FBB</strong><br>
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace <strong>FBB</strong>.
<p>
<h2>INHERITS FROM</h2>
<strong>std::streambuf</strong>
<p>
<h2>CONSTRUCTOR/DESTRUCTOR</h2>
<ul>
<li> <strong>DecryptBuf(std::ostream &outStream, char const *type,
std::string const &key, std::string const &iv,
size_t bufsize = 1024)</strong>:<br>
This constructor initializes the <em>DecryptBuf</em> object preparing it
for the message decrypt algorithm specified with <em>type</em>. The decryption
algorithms that can be used are listed in the table found in the
<strong>EncryptBuf</strong>(3bobcat) manual page. As an example: to use the AES method on
192 bit keys and blocks in CBC mode specify <em>"aes-192-cbc"</em>. The <em>key</em>
parameter refers to the key to be used, the <em>iv</em> parameter refers to the
initialization vector to use. The <em>iv</em>'s length cannot be zero. When using
ECB modes no initialization vector is used. In those cases any non-empty
initialization vector may be provided.
<p>
The constructor throws an <em>FBB::Exception</em> exception if an unknown
encryption method was specified.
<p>
The constructor's first parameter refers to the <em>std::ostream</em> to
receive the decrypted information.
<p>
The <em>bufsize</em> argument specifies the size in bytes of the internal
buffer used by <em>DecryptBuf</em> to store incoming characters temporarily. The
provided default argument should be OK in all normal cases.
<li> <strong>~DecryptBuf()</strong>:<br>
The destructor calls the <em>done()</em> member (see below), prevending any
exception that function might throw from leaving the destructor. In this case
only a non thread-safe way to determine whether the decryption was
successfully completed is available through the static member function
<em>lastOK()</em> (see below).
</ul>
There is no copy constructor, nor move constructor (as <em>std::streambuf</em>
doesn't support either).
<p>
<h2>MEMBER FUNCTIONS</h2>
<p>
All members of <strong>std::streambuf</strong> are available, as <strong>FBB::DecryptBuf</strong>
inherits from this class. Some of the <strong>std::streambuf</strong>'s member are
overridden or are hidden by <em>DecryptBuf</em>. In normal situations these
inherited members will not be used by programs using <em>DecryptBuf</em> objects.
<p>
<ul>
<li> <strong>void done()</strong>:<br>
This member can be called to indicate that all information to be
decrypted has been received. It throws an <em>FBB::Exception</em> exception if
decryption fails (resulting from providing the <em>DecryptBuf</em> object with
incorrect (usually improperly padded) input). If not explicitly called it is
called by <em>DecryptBuf</em>'s destructor, preventing its exception from leaving
the destructor.
<li> <strong>void setIv(std::string const &iv)</strong>:<br>
This member can be used to specify the initialization vector to use
after construction time but before any data has been decrypted. When called
after decryption has started or when specifying an empty intialization vector
an <em>FBB::Exception</em> exception will be thrown. When using ECB modes no
initialization vector is used. In those cases any non-empty initialization
vector may be provided.
<li> <strong>bool setRounds(size_t nRounds)</strong>:<br>
This member can only be used with the RC5 decryption method to set the
number of rounds of the algorithm to 8, 12 or 16. When the number of rounds
were updated successfully the member returns <em>true</em>. It returns <em>false</em> in
other cases (e.g., called for other decryption methods than RC5 or the
requested number of rounds differ from 8, 12 or 16).
</ul>
<p>
<h2>STATIC MEMBER</h2>
<ul>
<li> <strong>bool lastOK()</strong>:<br>
This member is a non thread-safe way to determine whether the
decryption has succeeded when the <em>DecryptBuf</em> object's <em>done</em> member has
not been called and the object has been destroyed. In that case the object's
destructor will call <em>done</em> to complete the decryption. The member
<em>lastOK</em> returns <em>true</em> if the <em>DecryptBuf</em> object destroyed last
could complete its decryption successfully and returns <em>false</em> otherwise.
</ul>
<p>
<h2>PROTECTED MEMBER</h2>
<ul>
<li> <strong>EVP_CIPHER_CTX *cipherCtx()</strong>:<br>
Classes derived from <em>DecryptBuf</em> may use this member to gain direct
access to the <em>EVP_CIPHER_CTX</em> pointer used by the <em>DecryptBuf</em>
object. This pointer is a pointer to an opaque structure used by many OpenSSL
functions to set or query parameters of an decryption method.
</ul>
<p>
<h2>EXAMPLE</h2>
<pre>
#include <iostream>
#include <fstream>
#include <bobcat/errno>
#include <bobcat/decryptbuf>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
try
{
if (argc == 1)
throw Errno("1st arg: method, 2nd arg: key, 3rd arg: file to "
"decrypt (to stdout), 4th arg: iv");
cerr << "Key: `" << argv[2] << "'\n"
"IV: `" << argv[4] << "'\n";
DecryptBuf decryptbuf(cout, argv[1], argv[2], argv[4]);
ostream out(&decryptbuf);
ifstream in(argv[3]);
out << in.rdbuf();
// decryptbuf.done(); // optionally
}
catch(Errno const &err)
{
cout << err.why() << endl;
return 1;
}
</pre>
<p>
<h2>FILES</h2>
<em>bobcat/decryptbuf</em> - defines the class interface
<p>
<h2>SEE ALSO</h2>
<strong>bobcat</strong>(7), <strong>encryptbuf</strong>(3bobcat), <strong>std::streambuf</strong>
<p>
<h2>BUGS</h2>
None reported
<p>
<h2>DISTRIBUTION FILES</h2>
<ul>
<li> <em>bobcat_3.23.01-x.dsc</em>: detached signature;
<li> <em>bobcat_3.23.01-x.tar.gz</em>: source archive;
<li> <em>bobcat_3.23.01-x_i386.changes</em>: change log;
<li> <em>libbobcat1_3.23.01-x_*.deb</em>: debian package holding the
libraries;
<li> <em>libbobcat1-dev_3.23.01-x_*.deb</em>: debian package holding the
libraries, headers and manual pages;
<li> <em>http://sourceforge.net/projects/bobcat</em>: public archive location;
</ul>
<p>
<h2>BOBCAT</h2>
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.
<p>
<h2>COPYRIGHT</h2>
This is free software, distributed under the terms of the
GNU General Public License (GPL).
<p>
<h2>AUTHOR</h2>
Frank B. Brokken (<strong>f.b.brokken@rug.nl</strong>).
<p>
|