This file is indexed.

/usr/include/Poco/Crypto/Cipher.h is in libpoco-dev 1.3.6p1-1ubuntu3.

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
//
// Cipher.h
//
// $Id: //poco/1.3/Crypto/include/Poco/Crypto/Cipher.h#3 $
//
// Library: Crypto
// Package: Cipher
// Module:  Cipher
//
// Definition of the Cipher class.
//
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
// 
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//


#ifndef Crypto_Cipher_INCLUDED
#define Crypto_Cipher_INCLUDED


#include "Poco/Crypto/Crypto.h"
#include "Poco/RefCountedObject.h"
#include "Poco/AutoPtr.h"
#include <istream>
#include <ostream>
#include <vector>


namespace Poco {
namespace Crypto {


class CryptoTransform;


class Crypto_API Cipher: public Poco::RefCountedObject
	/// Represents the abstract base class from which all implementations of
	/// symmetric/assymetric encryption algorithms must inherit.  Use the CipherFactory
	/// class to obtain an instance of this class:
	///
	///     CipherFactory& factory = CipherFactory::defaultFactory();
	///     // Creates a 256-bit AES cipher
	///     Cipher* pCipher = factory.createCipher(CipherKey("aes-256"));
	///     Cipher* pRSACipher = factory.createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL));
	///
	/// Check the different Key constructors on how to initialize/create
	/// a key. The above example auto-generates random keys.
	///
	/// Note that you won't be able to decrypt data encrypted with a random key
	/// once the Cipher is destroyed unless you persist the generated key and IV.
	/// An example usage for random keys is to encrypt data saved in a temporary
	/// file.
	///
	/// Once your key is set up, you can use the Cipher object to encrypt or
	/// decrypt strings or, in conjunction with a CryptoInputStream or a
	/// CryptoOutputStream, to encrypt streams of data.
	///
	/// Since encrypted strings will contain arbitary binary data that will cause
	/// problems in applications that are not binary-safe (eg., when sending
	/// encrypted data in e-mails), the encryptString() and decryptString() can
	/// encode (or decode, respectively) encrypted data using a "transport encoding".
	/// Supported encodings are Base64 and BinHex.
	///
	/// The following example encrypts and decrypts a string utilizing Base64
	/// encoding:
	///
	///     std::string plainText = "This is my secret information";
	///     std::string encrypted = pCipher->encryptString(plainText, Cipher::ENC_BASE64);
	///     std::string decrypted = pCipher->decryptString(encrypted, Cipher::ENC_BASE64);
	///
	/// In order to encrypt a stream of data (eg. to encrypt files), you can use
	/// a CryptoStream:
	///
	///     // Create an output stream that will encrypt all data going through it
	///     // and write pass it to the underlying file stream.
	///     Poco::FileOutputStream sink("encrypted.dat");
	///     CryptoOutputStream encryptor(sink, pCipher->createEncryptor());
	///     
	///     Poco::FileInputStream source("source.txt");
	///     Poco::StreamCopier::copyStream(source, encryptor);
	///     
	///     // Always close output streams to flush all internal buffers
	///     encryptor.close();
	///     sink.close();
{
public:
	typedef Poco::AutoPtr<Cipher> Ptr;
	typedef std::vector<unsigned char> ByteVec;

	enum Encoding
		/// Transport encoding to use for encryptString() and decryptString().
	{
		ENC_NONE,		/// Plain binary output
		ENC_BASE64,		/// Base64-encoded output
		ENC_BINHEX		/// BinHex-encoded output
	};

	virtual ~Cipher();
		/// Destroys the Cipher.

	virtual const std::string& name() const = 0;
		/// Returns the name of the Cipher.

	virtual CryptoTransform* createEncryptor() = 0;
		/// Creates an encrytor object to be used with a CryptoStream.

	virtual CryptoTransform* createDecryptor() = 0;
		/// Creates a decryptor object to be used with a CryptoStream.

	virtual std::string encryptString(const std::string& str, Encoding encoding = ENC_NONE);
		/// Directly encrypt a string and encode it using the given encoding.

	virtual std::string decryptString(const std::string& str, Encoding encoding = ENC_NONE);
		/// Directly decrypt a string that is encoded with the given encoding.

	virtual void encrypt(std::istream& source, std::ostream& sink, Encoding encoding = ENC_NONE);
		/// Directly encrypts an input stream and encodes it using the given encoding.

	virtual void decrypt(std::istream& source, std::ostream& sink, Encoding encoding = ENC_NONE);
		/// Directly decrypt an input stream that is encoded with the given encoding.

protected:
	Cipher();
		/// Creates a new Cipher object.

private:
	Cipher(const Cipher&);
	Cipher& operator = (const Cipher&);
};


} } // namespace Poco::Crypto


#endif // Crypto_Cipher_INCLUDED