git.stg.codes
/
stg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
96895bd
)
Fixed pointer arithmentics in crypto.lib.
author
Maxim Mamontov
<faust.madf@gmail.com>
Sat, 27 Sep 2014 22:05:07 +0000
(
01:05
+0300)
committer
Maxim Mamontov
<faust.madf@gmail.com>
Sat, 10 Jan 2015 18:51:27 +0000
(20:51 +0200)
stglibs/crypto.lib/blowfish.c
patch
|
blob
|
history
diff --git
a/stglibs/crypto.lib/blowfish.c
b/stglibs/crypto.lib/blowfish.c
index e2f275e6275b0322bab7536093245fdb263e6143..384d3a10e0d45cbb667bcdc5144c641939625121 100644
(file)
--- a/
stglibs/crypto.lib/blowfish.c
+++ b/
stglibs/crypto.lib/blowfish.c
@@
-469,50
+469,58
@@
void block2bytes(uint32_t t, char * c)
//-----------------------------------------------------------------------------
void DecryptBlock(void * d, const void * s, const BLOWFISH_CTX *ctx)
{
//-----------------------------------------------------------------------------
void DecryptBlock(void * d, const void * s, const BLOWFISH_CTX *ctx)
{
-uint32_t a = bytes2block(s);
-uint32_t b = bytes2block(s + 4);
+const char * src = s;
+char * dest = d;
+uint32_t a = bytes2block(src);
+uint32_t b = bytes2block(src + 4);
Blowfish_Decrypt(ctx, &a, &b);
Blowfish_Decrypt(ctx, &a, &b);
-block2bytes(a, d);
-block2bytes(b, d + 4);
+block2bytes(a, d
est
);
+block2bytes(b, d
est
+ 4);
}
//-----------------------------------------------------------------------------
void EncryptBlock(void * d, const void * s, const BLOWFISH_CTX *ctx)
{
}
//-----------------------------------------------------------------------------
void EncryptBlock(void * d, const void * s, const BLOWFISH_CTX *ctx)
{
-uint32_t a = bytes2block(s);
-uint32_t b = bytes2block(s + 4);
+const char * src = s;
+char * dest = d;
+uint32_t a = bytes2block(src);
+uint32_t b = bytes2block(src + 4);
Blowfish_Encrypt(ctx, &a, &b);
Blowfish_Encrypt(ctx, &a, &b);
-block2bytes(a, d);
-block2bytes(b, d + 4);
+block2bytes(a, d
est
);
+block2bytes(b, d
est
+ 4);
}
//-----------------------------------------------------------------------------
void DecryptString(void * d, const void * s, size_t length, const BLOWFISH_CTX * ctx)
{
}
//-----------------------------------------------------------------------------
void DecryptString(void * d, const void * s, size_t length, const BLOWFISH_CTX * ctx)
{
+const char * src = s;
+char * dest = d;
size_t pos = 0;
while (pos < length)
{
size_t pos = 0;
while (pos < length)
{
- DecryptBlock(d
+ pos, s
+ pos, ctx);
+ DecryptBlock(d
est + pos, src
+ pos, ctx);
pos += 8;
}
}
//-----------------------------------------------------------------------------
void EncryptString(void * d, const void * s, size_t length, const BLOWFISH_CTX * ctx)
{
pos += 8;
}
}
//-----------------------------------------------------------------------------
void EncryptString(void * d, const void * s, size_t length, const BLOWFISH_CTX * ctx)
{
+const char * src = s;
+char * dest = d;
size_t pos = 0;
while (pos < length)
{
if (pos + 8 < length)
size_t pos = 0;
while (pos < length)
{
if (pos + 8 < length)
- EncryptBlock(d
+ pos, s
+ pos, ctx);
+ EncryptBlock(d
est + pos, src
+ pos, ctx);
else
{
// Short string, use 0-padded buffer.
char buf[8];
memset(buf, 0, sizeof(buf));
else
{
// Short string, use 0-padded buffer.
char buf[8];
memset(buf, 0, sizeof(buf));
- memcpy(buf, s + pos, length - pos);
- EncryptBlock(d + pos, buf, ctx);
+ memcpy(buf, s
rc
+ pos, length - pos);
+ EncryptBlock(d
est
+ pos, buf, ctx);
}
pos += 8;
}
}
pos += 8;
}