Main Page | Modules | File List | File Members

GSCryptoDefines.h

Go to the documentation of this file.
00001 //****************************************************************************
00002 //*   Author:  Guillaume Plante  gsdevelopers@ubisoft.com
00003 //*   Date:    2002-06-10 10:11:16
00010 //****************************************************************************
00011 
00012 #ifndef __GSCRYPTODEFINES_H__
00013 #define __GSCRYPTODEFINES_H__
00014 
00021 enum GSCRYPTO_HASH_ALGO {
00022     E_MD5,
00023     E_SHA1
00024 };
00025 
00026 #define MD5_DIGESTSIZE  16      
00027 #define SHA1_DIGESTSIZE 20      
00028 
00029 #define MD5_HEXASIZE    (2 * MD5_DIGESTSIZE)    
00030 #define SHA1_HEXASIZE   (2 * SHA1_DIGESTSIZE)   
00031 
00032 
00039 enum GSCRYPTO_CIPHER_ALGO {
00040     E_BLOWFISH,
00041     E_GSXOR
00042 };
00043 
00050 enum GSCRYPTO_PKC_ALGO {
00051     E_RSA
00052 };
00053 
00060 enum GSCRYPTO_PRNG_ALGO {
00061     E_MGF1
00062 };
00063 
00064 #define MGF1_HASHMULTIPLES              500    
00065 
00066 
00068 
00069 
00070 /* RSA key lengths.
00071  */
00072 #define MIN_RSA_MODULUS_BITS 508        
00073 #define MAX_RSA_MODULUS_BITS 1024       
00074 #define MAX_RSA_MODULUS_LEN ((MAX_RSA_MODULUS_BITS + 7) / 8) 
00075 #define MAX_RSA_PRIME_BITS ((MAX_RSA_MODULUS_BITS + 1) / 2) 
00076 #define MAX_RSA_PRIME_LEN ((MAX_RSA_PRIME_BITS + 7) / 8) 
00077 
00078 /* Maximum lengths of encoded and encrypted content, as a function of
00079    content length len. Also, inverse functions.
00080  */
00081 #define ENCODED_CONTENT_LEN(len) (4*(len)/3 + 3)
00082 #define ENCRYPTED_CONTENT_LEN(len) ENCODED_CONTENT_LEN ((len)+8)
00083 #define DECODED_CONTENT_LEN(len) (3*(len)/4 + 1)
00084 #define DECRYPTED_CONTENT_LEN(len) DECODED_CONTENT_LEN ((len)-1)
00085 
00086 
00087 
00088 /* Random structure.
00089  */
00090 typedef struct {
00091   GSuint  bytesNeeded;
00092   GSubyte state[16];
00093   GSuint  outputAvailable;
00094   GSubyte output[16];
00095 } RANDOM_STRUCT;
00096 
00097 /* RSA public and private key.
00098  */
00099 typedef struct {
00100   GSuint bits;                           /* length in bits of modulus */
00101   GSubyte modulus[MAX_RSA_MODULUS_LEN];                    /* modulus */
00102   GSubyte exponent[MAX_RSA_MODULUS_LEN];           /* public exponent */
00103 } RSA_PUBLIC_KEY;
00104 
00105 typedef struct {
00106   GSuint bits;                           /* length in bits of modulus */
00107   GSubyte modulus[MAX_RSA_MODULUS_LEN];                    /* modulus */
00108   GSubyte publicExponent[MAX_RSA_MODULUS_LEN];     /* public exponent */
00109   GSubyte exponent[MAX_RSA_MODULUS_LEN];          /* private exponent */
00110   GSubyte prime[2][MAX_RSA_PRIME_LEN];               /* prime factors */
00111   GSubyte primeExponent[2][MAX_RSA_PRIME_LEN];   /* exponents for CRT */
00112   GSubyte coefficient[MAX_RSA_PRIME_LEN];          /* CRT coefficient */
00113 } RSA_PRIVATE_KEY;
00114 
00115 /* RSA prototype key.
00116  */
00117 typedef struct {
00118   GSuint bits;                           /* length in bits of modulus */
00119   GSint useFormat4;                        /* public exponent (1 = F4, 0 = 3) */
00120 } RSA_PROTO_KEY;
00121 
00123 
00124 #endif // __GSCRYPTODEFINES_H__

Ubi.com GameService SDK - ©UbiSoft Entertainment 2002
GameService development team