Nuked ancient uneeded things

This commit is contained in:
Drake Arconis
2012-10-04 17:56:25 -04:00
parent 0287e21c01
commit 5b8b88e05a
7 changed files with 0 additions and 1823 deletions

View File

@@ -22,13 +22,11 @@ include_directories(
)
set(llimage_SOURCE_FILES
aes.cpp
llimagebmp.cpp
llimage.cpp
llimagedxt.cpp
llimagej2c.cpp
llimagejpeg.cpp
llimagemetadatareader.cpp
llimagepng.cpp
llimagetga.cpp
llimageworker.cpp
@@ -37,13 +35,11 @@ set(llimage_SOURCE_FILES
set(llimage_HEADER_FILES
CMakeLists.txt
aes.h
llimage.h
llimagebmp.h
llimagedxt.h
llimagej2c.h
llimagejpeg.h
llimagemetadatareader.h
llimagepng.h
llimagetga.h
llimageworker.h

File diff suppressed because it is too large Load Diff

View File

@@ -1,190 +0,0 @@
//Rijndael.h
#ifndef __RIJNDAEL_H__
#define __RIJNDAEL_H__
#include <exception>
#include <string>
#include <cstring>
using namespace std;
//Rijndael (pronounced Reindaal) is a block cipher, designed by Joan Daemen and Vincent Rijmen as a candidate algorithm for the AES.
//The cipher has a variable block length and key length. The authors currently specify how to use keys with a length
//of 128, 192, or 256 bits to encrypt blocks with al length of 128, 192 or 256 bits (all nine combinations of
//key length and block length are possible). Both block length and key length can be extended very easily to
// multiples of 32 bits.
//Rijndael can be implemented very efficiently on a wide range of processors and in hardware.
//This implementation is based on the Java Implementation used with the Cryptix toolkit found at:
//http://www.esat.kuleuven.ac.be/~rijmen/rijndael/rijndael.zip
//Java code authors: Raif S. Naffah, Paulo S. L. M. Barreto
//This Implementation was tested against KAT test published by the authors of the method and the
//results were identical.
class CRijndael
{
public:
//Operation Modes
//The Electronic Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback Block (CFB) modes
//are implemented.
//In ECB mode if the same block is encrypted twice with the same key, the resulting
//ciphertext blocks are the same.
//In CBC Mode a ciphertext block is obtained by first xoring the
//plaintext block with the previous ciphertext block, and encrypting the resulting value.
//In CFB mode a ciphertext block is obtained by encrypting the previous ciphertext block
//and xoring the resulting value with the plaintext.
enum { ECB=0, CBC=1, CFB=2 };
private:
enum { DEFAULT_BLOCK_SIZE=16 };
enum { MAX_BLOCK_SIZE=32, MAX_ROUNDS=14, MAX_KC=8, MAX_BC=8 };
//Auxiliary Functions
//Multiply two elements of GF(2^m)
static int Mul(int a, int b)
{
return (a != 0 && b != 0) ? sm_alog[(sm_log[a & 0xFF] + sm_log[b & 0xFF]) % 255] : 0;
}
//Convenience method used in generating Transposition Boxes
static int Mul4(int a, char b[])
{
if(a == 0)
return 0;
a = sm_log[a & 0xFF];
int a0 = (b[0] != 0) ? sm_alog[(a + sm_log[b[0] & 0xFF]) % 255] & 0xFF : 0;
int a1 = (b[1] != 0) ? sm_alog[(a + sm_log[b[1] & 0xFF]) % 255] & 0xFF : 0;
int a2 = (b[2] != 0) ? sm_alog[(a + sm_log[b[2] & 0xFF]) % 255] & 0xFF : 0;
int a3 = (b[3] != 0) ? sm_alog[(a + sm_log[b[3] & 0xFF]) % 255] & 0xFF : 0;
return a0 << 24 | a1 << 16 | a2 << 8 | a3;
}
public:
//CONSTRUCTOR
CRijndael();
//DESTRUCTOR
virtual ~CRijndael();
//Expand a user-supplied key material into a session key.
// key - The 128/192/256-bit user-key to use.
// chain - initial chain block for CBC and CFB modes.
// keylength - 16, 24 or 32 bytes
// blockSize - The block size in bytes of this Rijndael (16, 24 or 32 bytes).
void MakeKey(char const* key, char const* chain, int keylength=DEFAULT_BLOCK_SIZE, int blockSize=DEFAULT_BLOCK_SIZE);
private:
//Auxiliary Function
void Xor(char* buff, char const* chain)
{
if(false==m_bKeyInit)
throw std::string(sm_szErrorMsg1);
for(int i=0; i<m_blockSize; i++)
*(buff++) ^= *(chain++);
}
//Convenience method to encrypt exactly one block of plaintext, assuming
//Rijndael's default block size (128-bit).
// in - The plaintext
// result - The ciphertext generated from a plaintext using the key
void DefEncryptBlock(char const* in, char* result);
//Convenience method to decrypt exactly one block of plaintext, assuming
//Rijndael's default block size (128-bit).
// in - The ciphertext.
// result - The plaintext generated from a ciphertext using the session key.
void DefDecryptBlock(char const* in, char* result);
public:
//Encrypt exactly one block of plaintext.
// in - The plaintext.
// result - The ciphertext generated from a plaintext using the key.
void EncryptBlock(char const* in, char* result);
//Decrypt exactly one block of ciphertext.
// in - The ciphertext.
// result - The plaintext generated from a ciphertext using the session key.
void DecryptBlock(char const* in, char* result);
void Encrypt(char const* in, char* result, size_t n, int iMode=ECB);
void Decrypt(char const* in, char* result, size_t n, int iMode=ECB);
//Get Key Length
int GetKeyLength()
{
if(false==m_bKeyInit)
throw std::string(sm_szErrorMsg1);
return m_keylength;
}
//Block Size
int GetBlockSize()
{
if(false==m_bKeyInit)
throw std::string(sm_szErrorMsg1);
return m_blockSize;
}
//Number of Rounds
int GetRounds()
{
if(false==m_bKeyInit)
throw std::string(sm_szErrorMsg1);
return m_iROUNDS;
}
void ResetChain()
{
memcpy(m_chain, m_chain0, m_blockSize);
}
public:
//Null chain
static char const* sm_chain0;
private:
static const int sm_alog[256];
static const int sm_log[256];
static const char sm_S[256];
static const char sm_Si[256];
static const int sm_T1[256];
static const int sm_T2[256];
static const int sm_T3[256];
static const int sm_T4[256];
static const int sm_T5[256];
static const int sm_T6[256];
static const int sm_T7[256];
static const int sm_T8[256];
static const int sm_U1[256];
static const int sm_U2[256];
static const int sm_U3[256];
static const int sm_U4[256];
static const char sm_rcon[30];
static const int sm_shifts[3][4][2];
//Error Messages
static char const* sm_szErrorMsg1;
static char const* sm_szErrorMsg2;
//Key Initialization Flag
bool m_bKeyInit;
//Encryption (m_Ke) round key
int m_Ke[MAX_ROUNDS+1][MAX_BC];
//Decryption (m_Kd) round key
int m_Kd[MAX_ROUNDS+1][MAX_BC];
//Key Length
int m_keylength;
//Block Size
int m_blockSize;
//Number of Rounds
int m_iROUNDS;
//Chain Block
char m_chain0[MAX_BLOCK_SIZE];
char m_chain[MAX_BLOCK_SIZE];
//Auxiliary private use buffers
int tk[MAX_KC];
int a[MAX_BC];
int t[MAX_BC];
};
#endif // __RIJNDAEL_H__

View File

@@ -1,213 +0,0 @@
// <edit>
#include "linden_common.h"
#include "llimagemetadatareader.h"
#include "aes.h"
//#include "llapr.h"
//#include "llerror.h"
const unsigned char EMKDU_AES_KEY[] = {0x01,0x00,0x81,0x07,0x63,0x78,0xB6,0xFE,0x6E,0x3F,0xB0,0x12,0xCC,0x65,0x66,0xC1,
0x81,0x96,0xAC,0xC1,0x3B,0x66,0x0B,0xF7};
//#define COMMENT_DEBUGG1ING
LLJ2cParser::LLJ2cParser(U8* data,int data_size)
{
if(data && data_size)
{
mData.resize(data_size);
memcpy(&(mData[0]), data, data_size);
//std::copy(data,data+data_size,mData.begin());
}
mIter = mData.begin();
}
U8 LLJ2cParser::nextChar()
{
U8 rtn = 0x00;
if(mIter != mData.end())
{
rtn = (*mIter);
mIter++;
}
return rtn;
}
std::vector<U8> LLJ2cParser::nextCharArray(int len)
{
std::vector<U8> array;
if(len > 0)
{
array.resize(len);
for(S32 i = 0; i < len; i++)
{
array[i] = nextChar();
}
}
return array;
}
std::vector<U8> LLJ2cParser::GetNextComment()
{
std::vector<U8> content;
while (mIter != mData.end())
{
U8 marker = nextChar();
if (marker == 0xff)
{
U8 marker_type = nextChar();
if (marker_type == 0x4f)
{
continue;
}
if (marker_type == 0x90)
{
//llinfos << "FOUND 0x90" << llendl;
break; //return empty vector
}
if (marker_type == 0x64)
{
//llinfos << "FOUND 0x64 COMMENT SECTION" << llendl;
S32 len = ((S32)nextChar())*256 + (S32)nextChar();
if (len > 3) content = nextCharArray(len - 2);
return content;
}
}
}
content.clear(); //return empty vector by clear anything there
return content;
}
//flow of control in this method is shit, gotta fix this... possibly return a vector or map instead of a string -HG
/*
Notes:
For anyone debugging this method, if a comment is not being decoded properly and you know encryption is being used,
the easiest thing to do is to create an LLAPRFile handle inside this method and write the contents of data to a file.
Normally the comment is going to be up near the header, just have a look at it in a hex editor.
It's generally going to be a string of 130 bytes preceeded by a null.
*/
//static
unsigned int LLImageMetaDataReader::ExtractEncodedComment(U8* data,int data_size, std::string& output)
{
LLJ2cParser parser = LLJ2cParser(data,data_size);
std::string decodedComment;
//not supported yet, but why the hell not?
unsigned int result = ENC_NONE;
while(1)
{
std::vector<U8> comment = parser.GetNextComment();
if (comment.empty()) break; //exit loop
if (comment[1] == 0x00 && comment.size() == 130)
{
bool xorComment = true;
//llinfos << "FOUND PAYLOAD" << llendl;
std::vector<U8> payload(128);
S32 i;
memcpy(&(payload[0]), &(comment[2]), 128);
//std::copy(comment.begin()+2,comment.end(),payload.begin());
//lets check xorComment Cipher first
if (payload[2] == payload[127])
{
// emkdu.dll
for (i = 4; i < 128; i += 4)
{
payload[i] ^= payload[3];
payload[i + 1] ^= payload[1];
payload[i + 2] ^= payload[0];
payload[i + 3] ^= payload[2];
}
result = ENC_EMKDU_V1;
}
else if (payload[3] == payload[127])
{
// emkdu.dll or onyxkdu.dll
for (i = 4; i < 128; i += 4)
{
payload[i] ^= payload[2];
payload[i + 1] ^= payload[0];
payload[i + 2] ^= payload[1];
payload[i + 3] ^= payload[3];
}
result = ENC_ONYXKDU;
}
else
{
xorComment = false;
}
if(!xorComment)
{
//this is terrible i know
std::vector<U8> decrypted(129);
CRijndael aes;
try
{
aes.MakeKey(reinterpret_cast<const char*>(EMKDU_AES_KEY),"", 24, 16);
} catch(std::string error)
{
llinfos << error << llendl;
}
try
{
int numBlocks = 8;
char* datain = (char*)&(payload[0]);
char* dataout = (char*)&(decrypted[0]);
char buffer[64];
memset(buffer,0,sizeof(buffer));
aes.DecryptBlock(datain,dataout); // do first block
for (int pos = 0; pos < 16; ++pos)
*dataout++ ^= buffer[pos];
datain += 16;
numBlocks--;
while (numBlocks)
{
aes.DecryptBlock(datain,dataout); // do next block
for (int pos = 0; pos < 16; ++pos)
*dataout++ ^= *(datain-16+pos);
datain += 16;
--numBlocks;
}
} catch(std::string error)
{
llinfos << error << llendl;
}
//payload.clear();
//memcpy(&(payload[0]),&(dataout[0]),dataout.size());
for (i = 0 ; i < 128; ++i)
{
if (decrypted[i] == 0) break;
}
if(i == 0) continue;
if(decodedComment.length() > 0)
decodedComment.append(", ");
//the way it's being done now, you can only specify the encryption type for the last comment.
//need to switch to a map<std::string, unsigned int> or a vector for output.
result = ENC_EMKDU_V2;
decodedComment.append(decrypted.begin(),decrypted.begin()+i);
}
else
{
for (i = 4 ; i < 128; ++i)
{
if (payload[i] == 0) break;
}
if(i < 4) continue;
if(decodedComment.length() > 0)
decodedComment.append(", ");
decodedComment.append(payload.begin()+4,payload.begin()+i);
}
//llinfos << "FOUND COMMENT: " << result << llendl;
}
}
//end of loop
output = decodedComment;
return result;
}
// </edit>

View File

@@ -1,32 +0,0 @@
// <edit>
#ifndef LL_LLIMAGEMETADATAREADER_H
#define LL_LLIMAGEMETADATAREADER_H
#include "stdtypes.h"
#include <string.h>
#include <vector>
#include <string>
//encryption types
#define ENC_NONE 0
#define ENC_ONYXKDU 1
#define ENC_EMKDU_V1 2
#define ENC_EMKDU_V2 4
class LLJ2cParser
{
public:
LLJ2cParser(U8* data,int data_size);
std::vector<U8> GetNextComment();
std::vector<U8> mData;
private:
U8 nextChar();
std::vector<U8> nextCharArray(int len);
std::vector<U8>::iterator mIter;
};
class LLImageMetaDataReader
{
public:
static unsigned int ExtractEncodedComment(U8* data,int data_size, std::string& output);
};
#endif
// </edit>

View File

@@ -2440,7 +2440,6 @@ BOOL LLLineEditor::evaluateFloat()
{
bool success = false;
std::string expr = getText();
LLStringUtil::toUpper(expr);
// user deleted the contents, nothing to evaluate -- MC
if (expr.empty())

View File

@@ -54,12 +54,10 @@
#include "lldriverparam.h"
#include "lleditingmotion.h"
#include "llemote.h"
#include "llfirstuse.h"
#include "llfloaterchat.h"
#include "llfloaterinventory.h"
#include "llheadrotmotion.h"
#include "llhudeffecttrail.h"
#include "llhudmanager.h"
#include "llinventorybridge.h"
@@ -112,7 +110,6 @@
// <edit>
#include "llfloaterexploreanimations.h"
#include "llimagemetadatareader.h"
// </edit>
#include "llavatarname.h"