3 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. The Blender
9 * Foundation also sells licenses for use in proprietary software under
10 * the Blender License. See http://www.blender.org/BL/ for information
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23 * All rights reserved.
25 * The Original Code is: all of this file.
27 * Contributor(s): none yet.
29 * ***** END GPL/BL DUAL LICENSE BLOCK *****
36 * Copyright (C) 2001 NaN Technologies B.V.
37 * Blender Key loader library internal stuff
40 #include "openssl/rand.h"
41 #include "openssl/rsa.h"
42 #include "openssl/ripemd.h"
43 #include "openssl/rc4.h"
44 #include "openssl/err.h"
47 #include "mt19937int.h" /* Mersenne Twister (under artistic license) */
49 #define MAXASCIIBLOCK 1000
50 #define MAXBYTEDATABLOCK 1000
58 /* keyloader and keymaker internal prototypes */
60 byte ReadHexByteFp(FILE *fh, int *newlinetracker);
61 byte ReadHexByteCp(char **from);
63 int HexToIntFp(FILE *fh, int *newlinetracker);
64 int HexToIntCp(char **from);
65 int Hex5ToInt(byte a, byte b, byte c, byte d, byte e);
66 int Hex5ToIntFp(FILE *fh, int *newlinetracker);
67 int Hex5ToIntCp(char **from);
68 void pub_priv_test(char *HexPriv, char *HexPub);
69 int main(int argc, char **argv);
71 /* keyloader only internal prototypes */
72 char *scan_ascii(FILE *fh, UserStruct *User);
73 char *ReadHexCryptedData(FILE *fh, int *newlinetracker);
74 char *ReadHexCryptedKey(FILE *fh, int *newlinetracker);
75 void LoadRSApubKey(RSA *Pub);
76 byte *RSADecryptKey(char *HexCryptedKey);
77 char *DeCryptDatablock(byte *CryptKey, int keylen, char *HexCryptedData);
78 char *get_from_datablock(char **DataPtr, char *TypeString);
79 int Check_All_Byte_Calculus_Data(char *KeyBytePtr);
81 /* keymaker only internal prototypes */
83 char *Create_Ascii_Part(int argc, char **argv);
84 void Create_User_RSA_Keys(unsigned int keylength,
85 char **rsaPrivString, char **rsaPubString);
86 char *Create_Byte_Calculus_Data(void);
87 byte *CreateCryptKey(unsigned int size);
88 char *CryptDatablock(byte *CryptKey, int keylen, char *KeyDataString);
89 char *RSACryptKey(RSA *rsa, byte *CryptKey, int KeyLen);
90 void add_to_datablock(char **DataString, char *HexString, char *TypeString);
91 void LoadRSAprivKey(RSA *Priv);