mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-03 06:12:43 -06:00
Bazaar/Protect : using new Cypher package instead of StreamCypher
Added Initialization Vectors handling in encryption git-svn-id: svn://ultimatepp.org/upp/trunk@2739 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
34b1a0f02e
commit
f2da9caeda
6 changed files with 29 additions and 20 deletions
|
|
@ -31,7 +31,8 @@ int CryptBuf(byte *buf, byte *bufEnd, String const &key)
|
|||
while( (bStart = ProtectSearchBuf(bStart, bufEnd, (const byte *)PROTECT_START_MARKER, strlen(PROTECT_START_MARKER))) != NULL)
|
||||
{
|
||||
// overwrite start pattern, just to fool a bit
|
||||
// symple pattern search
|
||||
// simple pattern search and use it as the encrypt init vector
|
||||
byte *nonce = bStart;
|
||||
for(unsigned i = 0; i < strlen(PROTECT_START_MARKER); i++)
|
||||
*bStart++ = (byte)(Random() & 0xff);
|
||||
|
||||
|
|
@ -49,8 +50,8 @@ int CryptBuf(byte *buf, byte *bufEnd, String const &key)
|
|||
*bEnd++ = (byte)(Random() & 0xff);
|
||||
|
||||
// crypt buffer
|
||||
Snow2 snow2(key);
|
||||
snow2.Encode(bStart, bStart, size);
|
||||
Snow2 snow2((byte const *)~key, key.GetCount(), nonce, strlen(PROTECT_START_MARKER));
|
||||
snow2(bStart, size);
|
||||
patches++;
|
||||
}
|
||||
|
||||
|
|
@ -88,8 +89,8 @@ int ObfuscateBuf(byte *buf, byte *bufEnd)
|
|||
*bEnd++ = (byte)(Random() & 0xff);
|
||||
|
||||
// obfuscate buffer
|
||||
Snow2 snow2(key);
|
||||
snow2.Encode(bStart, bStart, size);
|
||||
Snow2 snow2(key, "12345678");
|
||||
snow2(bStart, size);
|
||||
patches++;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue