From e03c322a2efb12acf2d4224125532a2b298c1b19 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Tue, 29 Oct 2002 21:44:13 +0000 Subject: Fixed // comments in c files (changed them to /* */ ) --- intern/keymaker/key.c | 117 +++++++++++++++++++++-------------------- intern/keymaker/key.h | 10 ++-- intern/keymaker/key_internal.h | 10 ++-- intern/keymaker/keyloader.c | 58 ++++++++++---------- intern/keymaker/mt19937int.h | 6 +-- 5 files changed, 102 insertions(+), 99 deletions(-) (limited to 'intern/keymaker') diff --git a/intern/keymaker/key.c b/intern/keymaker/key.c index 56df96c16fd..011196f3a8c 100644 --- a/intern/keymaker/key.c +++ b/intern/keymaker/key.c @@ -29,7 +29,7 @@ * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ -// ex:ts=4 +/* ex:ts=4 */ /** * $Id$ @@ -41,7 +41,7 @@ #include #include -#include "key.h" // external interface +#include "blenkey.h" /* external interface */ #include "key_internal.h" char *Hexify(byte *in, unsigned int length) { @@ -69,7 +69,7 @@ byte *DeHexify(char *in) { *outp = (byte) hexedbyte; outp++; } - // printf("\nlen=%d, string=[%s]\n", len, Hexify(out, len/2)); + /* printf("\nlen=%d, string=[%s]\n", len, Hexify(out, len/2)); */ return (out); } @@ -77,52 +77,52 @@ int from_hex(char c) { return (c<'A') ? (c-'0') : (c-'A'+10); } -// 5 ReadHex helper functions ------------------------------------------ -// read one Hex byte (two characters) and skip newlines if necessary +/* 5 ReadHex helper functions ------------------------------------------ + read one Hex byte (two characters) and skip newlines if necessary */ byte ReadHexByteFp(FILE *fh, int *newlinetracker) { unsigned char a; unsigned char a1, a2; - // read 2 bytes hexcode of ascii data type + /* read 2 bytes hexcode of ascii data type */ fread(&a1, 1, 1, fh); fread(&a2, 1, 1, fh); a = 16 * (from_hex(a1)) + (from_hex(a2)); - //printf("Char[%d] = %02X\n", *newlinetracker, a); + /*printf("Char[%d] = %02X\n", *newlinetracker, a); */ *newlinetracker += 2; - // skip the newlines + /* skip the newlines */ if (*newlinetracker == 72) { fseek(fh, 1, SEEK_CUR); *newlinetracker = 0; - //printf("LastChar = %02X\n", a); + /*printf("LastChar = %02X\n", a); */ } return((byte) a); } byte ReadHexByteCp(char **from) { int a; - // read 2 bytes hexcode of ascii data type + /* read 2 bytes hexcode of ascii data type */ sscanf(*from, "%2x", &a); - //printf("Char = %02X\n", a); + /*printf("Char = %02X\n", a); */ *from += 2; return((byte) a); } -// Generic hex2int +/* Generic hex2int */ int HexToInt(int a) { - if (a == 0x20) // space, count as 0 ;-) + if (a == 0x20) /* space, count as 0 ;-) */ return 0; else return(a - '0'); } -// Note: this is only to be used for the header type +/* Note: this is only to be used for the header type */ int HexToIntFp(FILE *fh, int *newlinetracker) { byte a = ReadHexByteFp(fh, newlinetracker); - if (DEBUG) printf("%02X = %d\n", a, a); // note: no HexToInt here + if (DEBUG) printf("%02X = %d\n", a, a); /* note: no HexToInt here */ return(a); } int HexToIntCp(char **from) { byte a = ReadHexByteCp(from); - if (DEBUG) printf("%02X = %d\n", a, a); // note: no HexToInt here + if (DEBUG) printf("%02X = %d\n", a, a); /* note: no HexToInt here */ return(a); } -// Note: this is only to be used for the header length +/* Note: this is only to be used for the header length */ int Hex5ToInt(byte a, byte b, byte c, byte d, byte e) { return(HexToInt((int) a) * 10000 + HexToInt((int) b) * 1000 + @@ -130,7 +130,7 @@ int Hex5ToInt(byte a, byte b, byte c, byte d, byte e) { HexToInt((int) d) * 10 + HexToInt((int) e)); } -// Note: this is only to be used for the header length +/* Note: this is only to be used for the header length */ int Hex5ToIntFp(FILE *fh, int *newlinetracker) { byte a = ReadHexByteFp(fh, newlinetracker), b = ReadHexByteFp(fh, newlinetracker), @@ -151,27 +151,27 @@ int Hex5ToIntCp(char **from) { Hex5ToInt(a, b, c, d, e)); return(Hex5ToInt(a, b, c, d, e)); } -// --------------------------------------------------------------------- +/* --------------------------------------------------------------------- */ -// return the biggest +/* return the biggest */ byte checkfunc0(byte a, byte b) { if (a > b) return a; else return b; } -// return |a-b| +/* return |a-b| */ byte checkfunc1(byte a, byte b) { if (a > b) return a - b; else return b - a; } -// return the sum mod 256 +/* return the sum mod 256 */ byte checkfunc2(byte a, byte b) { return ((a + b) % 256); } -// return the multiplication mod 256 +/* return the multiplication mod 256 */ byte checkfunc3(byte a, byte b) { return ((a * b) % 256); } -// return a/b or 0 +/* return a/b or 0 */ byte checkfunc4(byte a, byte b) { if (b != 0) return (a / b); else return 0; @@ -187,8 +187,8 @@ char *scan_ascii(FILE *fh, UserStruct *User) { int lines = 0; int oldftell; - // NOTE: fscanf is notorious for its buffer overflows. This must be - // fixed some day, consider this a proof-of-concept version. + /* NOTE: fscanf is notorious for its buffer overflows. This must be + fixed some day, consider this a proof-of-concept version. */ fscanf(fh, "%1000[^\n]", string); sscanf(string, "%*s %s %s %lu %d %d %d", @@ -205,13 +205,13 @@ char *scan_ascii(FILE *fh, UserStruct *User) { User->email, User->shopid, User->reldate, User->keytype, User->keylevel); - // read /n/n - - // check if we're reading dow newlines... + /* read /n/n + check if we're reading dow newlines... + */ oldftell = ftell(fh); getc(fh); if ((ftell(fh) - oldftell) == 2) { - // yes ! + /* yes ! */ dosnewlines = 1; } getc(fh); @@ -223,25 +223,27 @@ char *scan_ascii(FILE *fh, UserStruct *User) { getc(fh); - // 4 lines read uptil now... + /* 4 lines read uptil now... */ lines = 4; while (getc(fh) != EOF) { fscanf(fh, "%1000[^\n]", string); lines++; - // if (DEBUG) printf("%s\n", string); + /* if (DEBUG) printf("%s\n", string); */ if (strcmp(string, BLENKEYSEPERATOR) == 0) { getc(fh); break; } } - // fh now points at the start of the datablock + /* fh now points at the start of the datablock */ ascii_size = ftell(fh); if (dosnewlines) { - // if we were reading on dos - // ftell will also count the ^M 's in the file; substract them + /* if we were reading on dos + ftell will also count the ^M 's in the file; + substract them + */ ascii_size -= lines; } @@ -253,7 +255,7 @@ char *scan_ascii(FILE *fh, UserStruct *User) { if (DEBUG) printf("asciiblock is %ld bytes long:\n[%s]\n", ascii_size, ascii_data); - // calculate the hash checksum + /* calculate the hash checksum */ RIPEMD160(ascii_data, ascii_size, md); free(ascii_data); mdhex = Hexify(md, RIPEMD160_DIGEST_LENGTH); @@ -269,7 +271,7 @@ char *ReadHexCryptedData(FILE *fh, int *newlinetracker) { int i; if (DataType != 1) { - // printf("Error: unexpected datatype for HexCryptedData\n"); + /* printf("Error: unexpected datatype for HexCryptedData\n"); */ free(HexCryptedData); HexCryptedData = 0; } else { @@ -288,7 +290,7 @@ char *ReadHexCryptedKey(FILE *fh, int *newlinetracker) { int i; if (DataType != 2) { - // printf("Error: unexpected datatype for HexCryptedKey\n"); + /* printf("Error: unexpected datatype for HexCryptedKey\n"); */ free(HexCryptedKey); HexCryptedKey = 0; } else { @@ -300,7 +302,7 @@ char *ReadHexCryptedKey(FILE *fh, int *newlinetracker) { return(HexCryptedKey); } -// NOTE: CHANGE THIS INTO A KEY OF OUR OWN +/* NOTE: CHANGE THIS INTO A KEY OF OUR OWN */ void LoadRSApubKey(RSA *Pub) { static unsigned char n[] = "\xD1\x12\x0C\x6A\x34\x0A\xCF\x4C\x6B\x34\xA9\x3C\xDD\x1A\x2A\x68" @@ -330,10 +332,10 @@ byte *RSADecryptKey(char *HexCryptedKey) { int CryptedKeyLen = strlen(HexCryptedKey)/2; RSA *Pub = NULL; - // Load RSA public key + /* Load RSA public key */ Pub = RSA_new(); if (Pub == NULL) { - // printf("Error in RSA_new\n"); + /* printf("Error in RSA_new\n"); */ } else { LoadRSApubKey(Pub); @@ -376,7 +378,7 @@ char *get_from_datablock(char **DataPtr, char *TypeString) { char *HexString = NULL; if (atoi(TypeString) != tstringtype) { - // printf("Unexpected type %d, expected %s\n", tstringtype, TypeString); + /* printf("Unexpected type %d, expected %s\n", tstringtype, TypeString); */ } else { HexString = malloc((tstringsize+1) * sizeof(char)); @@ -393,7 +395,7 @@ int ReadKeyFile(char *filename, UserStruct *User, FILE *rawkeyfile; char *HexAsciiHash = NULL, *HexCryptedData = NULL, *HexCryptedKey = NULL; - int newlinetracker = 0; // line position, counts from 0-71 + int newlinetracker = 0; /* line position, counts from 0-71 */ byte *CryptKey = NULL; char *KeyDataString = NULL; char *KeyDataPtr = NULL; @@ -402,29 +404,29 @@ int ReadKeyFile(char *filename, UserStruct *User, int ret_val = 1; if ((rawkeyfile = fopen(filename, "rb")) == NULL) { - // printf("error, cannot read %s\n", filename); + /* printf("error, cannot read %s\n", filename); */ } else { - // Scan and interpret the ASCII part + /* Scan and interpret the ASCII part */ HexAsciiHash = scan_ascii(rawkeyfile, User); if (DEBUG) printf("\nHexHash: %s\n", HexAsciiHash); - // Read the HexCryptedData + /* Read the HexCryptedData */ HexCryptedData = ReadHexCryptedData(rawkeyfile, &newlinetracker); if (DEBUG) printf("\nHexCryptedData: %s\n", HexCryptedData); - // Read the HexCryptedKey + /* Read the HexCryptedKey */ HexCryptedKey = ReadHexCryptedKey(rawkeyfile, &newlinetracker); if (DEBUG) printf("\nHexCryptedKey: %s\n", HexCryptedKey); - // close keyfile + /* close keyfile */ fclose(rawkeyfile); if (HexAsciiHash && HexCryptedKey && HexCryptedData) { - // Decrypt HexCryptedKey + /* Decrypt HexCryptedKey */ CryptKey = RSADecryptKey(HexCryptedKey); if (CryptKey) { - // Decrypt HexCryptedData + /* Decrypt HexCryptedData */ KeyDataString = DeCryptDatablock(CryptKey, 16, HexCryptedData); free(CryptKey); CryptKey = NULL; @@ -432,7 +434,7 @@ int ReadKeyFile(char *filename, UserStruct *User, if (KeyDataString) { if (DEBUG) printf("\nKeyDataString: %s\n", KeyDataString); - // Extract data from KeyDataString + /* Extract data from KeyDataString */ KeyDataPtr = KeyDataString; mdhex = get_from_datablock(&KeyDataPtr, "01"); *Priv = get_from_datablock(&KeyDataPtr, "02"); @@ -445,15 +447,16 @@ int ReadKeyFile(char *filename, UserStruct *User, *Python = get_from_datablock(&KeyDataPtr, "05"); - // Check ascii hash + /* Check ascii hash */ if (strcmp(mdhex, HexAsciiHash) != 0) { - // printf("Ascii part checksums do not match !\n"); - // printf("found: %s\n", mdhex); - // printf("check: %s\n", HexAsciiHash); + /* printf("Ascii part checksums do not match !\n"); + printf("found: %s\n", mdhex); + printf("check: %s\n", HexAsciiHash); + */ ret_val = 2; } else { if (DEBUG) printf("\nThe ascii part checksum matches\n"); - // everything ok ! + /* everything ok ! */ ret_val = 0; } free(mdhex); @@ -466,7 +469,7 @@ int ReadKeyFile(char *filename, UserStruct *User, } } - // cleanup + /* cleanup */ if (HexAsciiHash) { free(HexAsciiHash); diff --git a/intern/keymaker/key.h b/intern/keymaker/key.h index dd84f55f129..e504fdf62b8 100644 --- a/intern/keymaker/key.h +++ b/intern/keymaker/key.h @@ -50,9 +50,9 @@ typedef struct UserStructType { char email[100]; char shopid[100]; unsigned long reldate; - int keytype; // 1 = Individual, 2 = Corporate, 3 = Unlimited - int keylevel; // key disclosure level, starts at 1 - int keyformat; // if we change the keyformat, up BLENKEYFORMAT + int keytype; /* 1 = Individual, 2 = Corporate, 3 = Unlimited */ + int keylevel; /* key disclosure level, starts at 1 */ + int keyformat; /* if we change the keyformat, up BLENKEYFORMAT */ } UserStruct; char *Hexify(byte *in, unsigned int length); @@ -64,8 +64,8 @@ byte checkfunc2(byte a, byte b); byte checkfunc3(byte a, byte b); byte checkfunc4(byte a, byte b); -// the byte size of the checksum datablock -// #define MAXBYTEDATABLOCK 1000 +/* the byte size of the checksum datablock +#define MAXBYTEDATABLOCK 1000 */ #define BLENKEYMAGIC "0ce0ba52" #define BLENKEYSEPERATOR "---+++---" diff --git a/intern/keymaker/key_internal.h b/intern/keymaker/key_internal.h index 3fa0274c33e..103f61538fe 100644 --- a/intern/keymaker/key_internal.h +++ b/intern/keymaker/key_internal.h @@ -29,7 +29,7 @@ * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ -// ex:ts=4 +/* ex:ts=4 */ /** * $Id$ @@ -43,7 +43,7 @@ #include "openssl/rc4.h" #include "openssl/err.h" -#include "mt19937int.h" // Mersenne Twister (under artistic license) +#include "mt19937int.h" /* Mersenne Twister (under artistic license) */ #define MAXASCIIBLOCK 1000 #define MAXBYTEDATABLOCK 1000 @@ -54,7 +54,7 @@ #define DEBUG 1 #endif -// keyloader and keymaker internal prototypes +/* keyloader and keymaker internal prototypes */ int from_hex(char c); byte ReadHexByteFp(FILE *fh, int *newlinetracker); byte ReadHexByteCp(char **from); @@ -66,7 +66,7 @@ int Hex5ToIntFp(FILE *fh, int *newlinetracker); int Hex5ToIntCp(char **from); int main(int argc, char **argv); -// keyloader only internal prototypes +/* keyloader only internal prototypes */ char *scan_ascii(FILE *fh, UserStruct *User); char *ReadHexCryptedData(FILE *fh, int *newlinetracker); char *ReadHexCryptedKey(FILE *fh, int *newlinetracker); @@ -76,7 +76,7 @@ char *DeCryptDatablock(byte *CryptKey, int keylen, char *HexCryptedData); char *get_from_datablock(char **DataPtr, char *TypeString); int Check_All_Byte_Calculus_Data(char *KeyBytePtr); -// keymaker only internal prototypes +/* keymaker only internal prototypes */ void usage(void); char *Create_Ascii_Part(int argc, char **argv); void Create_User_RSA_Keys(unsigned int keylength, diff --git a/intern/keymaker/keyloader.c b/intern/keymaker/keyloader.c index e4cf61fc3b7..4da347c32ac 100644 --- a/intern/keymaker/keyloader.c +++ b/intern/keymaker/keyloader.c @@ -29,7 +29,7 @@ * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ -// ex:ts=4 +/* ex:ts=4 */ /** * $Id$ @@ -41,8 +41,8 @@ #include #include -#include "key_pyc.h" // the Python byte code -#include "key.h" // the external interface +#include "key_pyc.h" /* the Python byte code */ +#include "blenkey.h" /* the external interface */ #include "key_internal.h" #define TESTReadKeyFile 1 @@ -50,7 +50,7 @@ int Check_All_Byte_Calculus_Data(char *KeyBytePtr) { int i; - // create some unique number arrays + /* create some unique number arrays */ int NoRealRandomArray[MAXBYTEDATABLOCK]; typedef byte (*funcpoin)(byte, byte); @@ -59,20 +59,20 @@ int Check_All_Byte_Calculus_Data(char *KeyBytePtr) { byte *KeyByteData = DeHexify(KeyBytePtr); - // first create a fixed seed random number generator - sgenrand(666); // seed it fixed + /* first create a fixed seed random number generator */ + sgenrand(666); /* seed it fixed */ - // initialize arrays with unique numbers + /* initialize arrays with unique numbers */ for (i=0; i>16) % MAXBYTEDATABLOCK); int store = NoRealRandomArray[swap1]; - //printf("%lu %d %d\n", randswap, swap1, swap2); + /* printf("%lu %d %d\n", randswap, swap1, swap2); */ NoRealRandomArray[swap1] = NoRealRandomArray[swap2]; NoRealRandomArray[swap2] = store; } @@ -84,7 +84,7 @@ int Check_All_Byte_Calculus_Data(char *KeyBytePtr) { printf("\n\n"); } - // check our byte calculus functions on the random data + /* check our byte calculus functions on the random data */ for (i=0; i<(MAXBYTEDATABLOCK-3); i+=3) { if (DEBUG) { char *Pcheckfunc[] = {"max", " - ", " + ", " * ", " / "}; @@ -114,7 +114,7 @@ int Check_All_Byte_Calculus_Data(char *KeyBytePtr) { void pub_priv_test(char *HexPriv, char *HexPub) { RSA *rsa = NULL; - // static unsigned char rsa_e[] = "\x11"; + /* static unsigned char rsa_e[] = "\x11"; */ static unsigned char rsa_e[] = "\x01\x00\x01"; byte cryptKey[16]; byte *cryptedKey; @@ -185,15 +185,15 @@ int main(int argc, char **argv) { printf("\nReadKeyFile OK\n"); } - // just print the rsaPrivString and rsaPubString + /* just print the rsaPrivString and rsaPubString */ if (DEBUG) printf("\nrsaPrivString: %s\n", HexPriv); if (DEBUG) printf("\nrsaPubString: %s\n", HexPub); - // try to private encrypt-public decrypt something + /* try to private encrypt-public decrypt something */ if (DEBUG) pub_priv_test(HexPriv, HexPub); - // check all the Byte checksums - // rehexify it for our Check_All_Byte_Calculus_Data function ... + /* check all the Byte checksums + rehexify it for our Check_All_Byte_Calculus_Data function ... */ HexByte = Hexify(Byte, 1000); if (Check_All_Byte_Calculus_Data(HexByte) != 0) { printf("\nByte_Calculus_Data checksums do not match !\n"); @@ -202,7 +202,7 @@ int main(int argc, char **argv) { if (DEBUG) printf("\nThe Byte Calculus Data checksums match\n"); } - // Check the KeyPythonPtr + /* Check the KeyPythonPtr */ PythonLength = strlen(HexPython)/2; PythonData = DeHexify(HexPython); if (memcmp(PythonData, g_keycode, PythonLength) != 0) { @@ -219,7 +219,7 @@ int main(int argc, char **argv) { FILE *rawkeyfile; char *AsciiHash; char *HexCryptedData, *HexCryptedKey; - int newlinetracker = 0; // line position, counts from 0-71 + int newlinetracker = 0; /* line position, counts from 0-71 */ byte *CryptKey; char *KeyDataString; char *KeyDataPtr; @@ -237,38 +237,38 @@ int main(int argc, char **argv) { exit(1); } - // open keyfile for reading + /* open keyfile for reading */ if ((rawkeyfile = fopen(argv[1], "r")) == NULL) { printf("error, cannot read %s\n", argv[1]); exit(1); } - // Scan and interpret the ASCII part + /* Scan and interpret the ASCII part */ AsciiHash = scan_ascii(rawkeyfile, &User); if (DEBUG) printf("\nHexHash: %s\n", AsciiHash); - // Read the HexCryptedData + /* Read the HexCryptedData */ HexCryptedData = ReadHexCryptedData(rawkeyfile, &newlinetracker); if (DEBUG) printf("\nHexCryptedData: %s\n", HexCryptedData); - // Read the HexCryptedKey + /* Read the HexCryptedKey */ HexCryptedKey = ReadHexCryptedKey(rawkeyfile, &newlinetracker); if (DEBUG) printf("\nHexCryptedKey: %s\n", HexCryptedKey); - // close keyfile + /* close keyfile */ fclose(rawkeyfile); - // Decrypt HexCryptedKey + /* Decrypt HexCryptedKey */ CryptKey = RSADecryptKey(HexCryptedKey); - // Decrypt HexCryptedData + /* Decrypt HexCryptedData */ KeyDataString = DeCryptDatablock(CryptKey, 16, HexCryptedData); free(CryptKey); free(HexCryptedData); free(HexCryptedKey); if (DEBUG) printf("\nKeyDataString: %s\n", KeyDataString); - // Extract data from KeyDataString + /* Extract data from KeyDataString */ KeyDataPtr = KeyDataString; mdhex = get_from_datablock(&KeyDataPtr, "01"); @@ -278,7 +278,7 @@ int main(int argc, char **argv) { KeyPythonPtr = get_from_datablock(&KeyDataPtr, "05"); free(KeyDataString); - // Check ascii hash + /* Check ascii hash */ if (strcmp(mdhex, AsciiHash) != 0) { printf("Ascii part checksums do not match !\n"); printf("found: %s\n", mdhex); @@ -288,11 +288,11 @@ int main(int argc, char **argv) { if (DEBUG) printf("\nThe ascii part checksum matches\n"); } - // just print the rsaPrivString and rsaPubString + /* just print the rsaPrivString and rsaPubString */ if (DEBUG) printf("\nrsaPrivString: %s\n", rsaPrivString); if (DEBUG) printf("\nrsaPubString: %s\n", rsaPubString); - // check all the Byte checksums + /* check all the Byte checksums */ if (Check_All_Byte_Calculus_Data(KeyBytePtr) != 0) { printf("Byte_Calculus_Data checksums do not match !\n"); exit(1); @@ -300,7 +300,7 @@ int main(int argc, char **argv) { if (DEBUG) printf("\nThe Byte Calculus Data checksums match\n"); } - // Check the KeyPythonPtr + /* Check the KeyPythonPtr */ PythonLength = strlen(KeyPythonPtr)/2; PythonData = DeHexify(KeyPythonPtr); if (memcmp(PythonData, g_keycode, PythonLength) != 0) { diff --git a/intern/keymaker/mt19937int.h b/intern/keymaker/mt19937int.h index 49acdd7ba4c..725d2079772 100644 --- a/intern/keymaker/mt19937int.h +++ b/intern/keymaker/mt19937int.h @@ -29,7 +29,7 @@ * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ -// ex:ts=4 +/* ex:ts=4 */ /** * $Id$ @@ -37,9 +37,9 @@ * Mersenne Twister prototypes */ -// external: +/* external: */ void sgenrand(signed long seed); unsigned long genrand(void); -// internal: +/* internal: */ void lsgenrand(unsigned long *seed_array); -- cgit v1.2.3