/usr/include/sipxtapi/os/OsEncryption.h is in libsipxtapi-dev 3.3.0~test17-2.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 | //
// Copyright (C) 2004-2006 SIPfoundry Inc.
// Licensed by SIPfoundry under the LGPL license.
//
// Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// $$
///////////////////////////////////////////////////////////////////////////////
#ifndef _OsEncryption_h_
#define _OsEncryption_h_
// SYSTEM INCLUDES
#ifdef HAVE_SSL
#define OSENCRYPTION
#endif
#if defined (OSENCRYPTION)
#include <openssl/evp.h>
#include <openssl/x509.h>
#endif
// APPLICATION INCLUDES
#include "os/OsDefs.h"
#include "os/OsStatus.h"
#include "os/OsTime.h"
// DEFINES
// MACROS
// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
// CONSTANTS
#define OE_MAX_KEY_LEN 64
#define OE_MAX_RESULTS_HEADER_LEN 32
// STRUCTS
// TYPEDEFS
// FORWARD DECLARATIONS
//! Wrapper and helper around system encryption routines.
/*!
Hide encryption details like:
what alg. is chosen
initialization details of alg.
messy details allocating buffers padded to minumal key length
Create one instance per encryption/decryption operation. As such, this
class makes no provisions to be multi-threaded
FUTURE: enum encryption alg posibilities and add approp accessor methods. today
there is only one, PBE/DES via OpenSSL
*/
class OsEncryption
{
public:
//! Create one for each encryption/decryption operation
OsEncryption(void);
virtual ~OsEncryption(void);
//! Data to feed to encryption, not touched and NOT copied, so keep it around
void setDataPointer(unsigned char *pIn, int inLen);
//! How large is the untouched data buffer
int getDataLen(void);
//! Pointer to untouched data buffer
unsigned char *getDataPointer(void);
//! If you want to prepend this to the results header for file identification purposes
void setResultsHeader(const unsigned char *header, int headerLen);
//! After [en/de]crypting, here's your results
unsigned char *getResults(void);
//! After [en/de]crypting get your results here
int getResultsLen(void);
//! set secret password
void setKey(const unsigned char *key, int keyLen);
//! operate after setting approp. input. . NOTE: This will return OS_FAILED on vxworks. */
OsStatus decrypt(void);
//! operate after setting approp. input. NOTE: This will return OS_FAILED on vxworks. */
OsStatus encrypt(void);
//! free all, called in descructor
OsStatus release(void);
//! DEBUG turn on/off
static UtlBoolean sIgnoreEncryption;
protected:
//! OpenSSL state differentation direction for API calls
enum Direction
{
DECRYPT = 0,
ENCRYPT = 1
};
//! allocate OpenSSL stuff
OsStatus init(Direction direction);
//! common handling of OpenSSL's errors
UtlBoolean openSslError(void);
//! common [en/de]crypt method
OsStatus crypto(Direction direction);
private:
#if defined (OSENCRYPTION)
X509_ALGOR *mAlgorithm;
EVP_CIPHER_CTX mContext;
#endif
unsigned char *mSalt; // defeats brute force decryption via appling dictionary
int mSaltLen;
unsigned char mKey[OE_MAX_KEY_LEN]; // storage of password
int mKeyLen;
unsigned char *mData; // pointer to storage of data
int mDataLen;
unsigned char *mResults; // allocated storage of results
int mResultsLen;
unsigned char mHeader[OE_MAX_RESULTS_HEADER_LEN]; // set/expect extra data in results buffer
int mHeaderLen;
// TEST: See unittests/EncryptionTest
};
#endif // _OsEncryption_h_
|