D
Daniel Rudy
Hello Group,
I've looked at this backwards and forwards and I can't seem to find the
problem here. What happens is I have a multidimensional array of char
that has 3 dimensions with a declaration assignment. After a certian
point in the array, I get garbage. Not sure why. Granted this is a
little off topic because of what the code does, but I'm hoping that a
few extra pairs of eyes can see what I'm missing.
#define CRYPTO_KEYMAX 16 /* number of key sizes */
#define CRYPTO_ALG_MAX 4 /* number of algorithms */
/* converts an algorithm number into a name */
const char * crypto_name_algorithm(int algorithm, int size)
{
char cs[CRYPTO_ALG_MAX][CRYPTO_KEYMAX][16] = {
{"","","","AES-128","","AES-192","","AES-256","","AES-320","",
"AES-384","","","","AES-512"},
{"","DES-64","","DES-128","","","","","","","","","","","",""},
{"","","","3DES-128","","3DES-192","","3DES-256","","3DES-320",
"","3DES-384","","","",""},
{"","","","ARC4-128","ARC4-160","ARC4-192","ARC4-224","ARC4-256",
"ARC4-288","ARC4-320","ARC4-352","ARC4-384","ARC4-416","ARC4-448",
"ARC4-480","ARC4-512"}};
DPRINTF(("%s\n", cs[algorithm][size]))
if (strlen(cs[algorithm][size]) > 0) return(cs[algorithm][size]);
return("Unknown/Invalid");
}
in crypto.h:
/* note: not all key sizes are supported by all algorithms.
crypto_initstate will return EFUNCTERR if an invalid key
size is encountered for a specific algorithm. */
#define CRYPTO_KEY32 0
#define CRYPTO_KEY64 1
#define CRYPTO_KEY96 2
#define CRYPTO_KEY128 3
#define CRYPTO_KEY160 4
#define CRYPTO_KEY192 5
#define CRYPTO_KEY224 6
#define CRYPTO_KEY256 7
#define CRYPTO_KEY288 8
#define CRYPTO_KEY320 9
#define CRYPTO_KEY352 10
#define CRYPTO_KEY384 11
#define CRYPTO_KEY416 12
#define CRYPTO_KEY448 13
#define CRYPTO_KEY480 14
#define CRYPTO_KEY512 15
/* cipher algorithm codes */
#define CRYPTO_ALG_AES 0 /* AES: blocksize 16 bytes */
#define CRYPTO_ALG_DES 1 /* DES: blocksize 8 bytes */
#define CRYPTO_ALG_DES3 2 /* 3DES: blocksize 8 bytes */
#define CRYPTO_ALG_ARC4 3 /* ARC4: stream (variable blocksize) */
in debug.h:
#define DPRINTF(arg) printf arg;
Now here's what I get when I run the test program:
strata:/home/dr2867/c/modules 1146 $$$ ->./crypto.test
Encryption Check Program
Encrypting Data...
Original Key: asdfasdfasdf123412341234
Original Keysize: 24
Crypto Index: 3
Crypto Keysize: 11
ARC4-384 <----------- from DPRINTF in crypto_name_algorithm
Crypto Text: ˆì¿¿+(²¿¿´(+(ÓH²¿¿
Nonce: 0x00000023
Skip: 0x00000003
Key:
cb29747e91b2ff308d15551b41d3fdc22e3ec22eb390d89921ee329a2919b4b4a9bba4f27465db607721985624a8722a29a94fbe
7e46d56344a1a3d971528aca
Salt:
20d560efc13cb94f0ea38c5e7f3114a10f1d61e126acffc78a2a553f5f0746687ee60a40790eea5f850622a36a55aff7d2106d48
9126bc97e6642dc1ae17d3fb
Seed:
04c135c8b4cbf85691cdc4212790091ab2e7851f460743b98ac6947b040f622c281d3b82ce7adb3c47ec1c38b1635ff2f548cfdd
a767adec608bff56f4bb0bb9
Input Size: 67
Output Size: 67
Encrypted Data: 26 cf 28 66 78 5a 3c 85 54 03 20 0d 06 a0 29 ad ad 08 5b
db 73 46 b8 39 8a e2 15 3b c4 44 de b
5 06 24 44 39 b4 40 5c 13 53 33 18 bf 99 2d 17 f6 3f 7c 87 00 75 5c f8
82 bc 56 c6 4b 71 ba 58 ad a2 d4 a4
It only starts at the position that holds the string ARC4-384. All
previous references are ok. Any ideas?
--
Daniel Rudy
Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m
Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
I've looked at this backwards and forwards and I can't seem to find the
problem here. What happens is I have a multidimensional array of char
that has 3 dimensions with a declaration assignment. After a certian
point in the array, I get garbage. Not sure why. Granted this is a
little off topic because of what the code does, but I'm hoping that a
few extra pairs of eyes can see what I'm missing.
#define CRYPTO_KEYMAX 16 /* number of key sizes */
#define CRYPTO_ALG_MAX 4 /* number of algorithms */
/* converts an algorithm number into a name */
const char * crypto_name_algorithm(int algorithm, int size)
{
char cs[CRYPTO_ALG_MAX][CRYPTO_KEYMAX][16] = {
{"","","","AES-128","","AES-192","","AES-256","","AES-320","",
"AES-384","","","","AES-512"},
{"","DES-64","","DES-128","","","","","","","","","","","",""},
{"","","","3DES-128","","3DES-192","","3DES-256","","3DES-320",
"","3DES-384","","","",""},
{"","","","ARC4-128","ARC4-160","ARC4-192","ARC4-224","ARC4-256",
"ARC4-288","ARC4-320","ARC4-352","ARC4-384","ARC4-416","ARC4-448",
"ARC4-480","ARC4-512"}};
DPRINTF(("%s\n", cs[algorithm][size]))
if (strlen(cs[algorithm][size]) > 0) return(cs[algorithm][size]);
return("Unknown/Invalid");
}
in crypto.h:
/* note: not all key sizes are supported by all algorithms.
crypto_initstate will return EFUNCTERR if an invalid key
size is encountered for a specific algorithm. */
#define CRYPTO_KEY32 0
#define CRYPTO_KEY64 1
#define CRYPTO_KEY96 2
#define CRYPTO_KEY128 3
#define CRYPTO_KEY160 4
#define CRYPTO_KEY192 5
#define CRYPTO_KEY224 6
#define CRYPTO_KEY256 7
#define CRYPTO_KEY288 8
#define CRYPTO_KEY320 9
#define CRYPTO_KEY352 10
#define CRYPTO_KEY384 11
#define CRYPTO_KEY416 12
#define CRYPTO_KEY448 13
#define CRYPTO_KEY480 14
#define CRYPTO_KEY512 15
/* cipher algorithm codes */
#define CRYPTO_ALG_AES 0 /* AES: blocksize 16 bytes */
#define CRYPTO_ALG_DES 1 /* DES: blocksize 8 bytes */
#define CRYPTO_ALG_DES3 2 /* 3DES: blocksize 8 bytes */
#define CRYPTO_ALG_ARC4 3 /* ARC4: stream (variable blocksize) */
in debug.h:
#define DPRINTF(arg) printf arg;
Now here's what I get when I run the test program:
strata:/home/dr2867/c/modules 1146 $$$ ->./crypto.test
Encryption Check Program
Encrypting Data...
Original Key: asdfasdfasdf123412341234
Original Keysize: 24
Crypto Index: 3
Crypto Keysize: 11
ARC4-384 <----------- from DPRINTF in crypto_name_algorithm
Crypto Text: ˆì¿¿+(²¿¿´(+(ÓH²¿¿
Nonce: 0x00000023
Skip: 0x00000003
Key:
cb29747e91b2ff308d15551b41d3fdc22e3ec22eb390d89921ee329a2919b4b4a9bba4f27465db607721985624a8722a29a94fbe
7e46d56344a1a3d971528aca
Salt:
20d560efc13cb94f0ea38c5e7f3114a10f1d61e126acffc78a2a553f5f0746687ee60a40790eea5f850622a36a55aff7d2106d48
9126bc97e6642dc1ae17d3fb
Seed:
04c135c8b4cbf85691cdc4212790091ab2e7851f460743b98ac6947b040f622c281d3b82ce7adb3c47ec1c38b1635ff2f548cfdd
a767adec608bff56f4bb0bb9
Input Size: 67
Output Size: 67
Encrypted Data: 26 cf 28 66 78 5a 3c 85 54 03 20 0d 06 a0 29 ad ad 08 5b
db 73 46 b8 39 8a e2 15 3b c4 44 de b
5 06 24 44 39 b4 40 5c 13 53 33 18 bf 99 2d 17 f6 3f 7c 87 00 75 5c f8
82 bc 56 c6 4b 71 ba 58 ad a2 d4 a4
It only starts at the position that holds the string ARC4-384. All
previous references are ok. Any ideas?
--
Daniel Rudy
Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m
Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep