| RSA BSAFE Crypto-C |
Cryptographic Components for C |
| Search |
00001 /* $Id: bsfplatf.h,v 1.10 2004/12/01 07:06:56 sparki Exp $ */ 00002 /* 00003 * Copyright (C) 1998-2004 RSA Security Inc. All rights reserved. 00004 * 00005 * This work contains proprietary information of RSA Security. 00006 * Distribution is limited to authorized licensees of RSA 00007 * Security. Any unauthorized reproduction, distribution or 00008 * modification of this work is strictly prohibited. 00009 */ 00010 00016 #ifndef _BSAFE_PLATFORM_H_ 00017 #define _BSAFE_PLATFORM_H_ 1 00018 00019 /* The include file bsfmacro.h contains all the alternatives for macro 00020 definitions. */ 00021 #include "bsfmacro.h" 00022 00023 /* 00024 If RSA_BSAFE_EXPORT is defined generate an export version of 00025 BSAFE. 00026 */ 00027 #ifdef RSA_BSAFE_EXPORT 00028 #define RSA_BSAFE_DESTINATION RSA_EXPORT_VERSION 00029 #else 00030 #define RSA_BSAFE_DESTINATION RSA_DOMESTIC_VERSION 00031 #endif 00032 00033 #if RSA_PLATFORM == RSA_I386_486 00034 #define RSA_PLATFORM_SPECIFIC 00035 #include "bsplti32.h" 00036 #endif 00037 00038 #if (RSA_PLATFORM == RSA_LINUX || RSA_PLATFORM == RSA_INTEL_IA32_SOLARIS9) 00039 #define RSA_PLATFORM_SPECIFIC 00040 #include "bslinux.h" 00041 #endif 00042 00043 #if RSA_PLATFORM == RSA_LINUX_ARM 00044 #define RSA_PLATFORM_SPECIFIC 00045 #include "bslinuxarm.h" 00046 #endif 00047 00048 #if RSA_PLATFORM == RSA_INTEL_SCO50_32_BIT 00049 #define RSA_PLATFORM_SPECIFIC 00050 #include "bssco.h" 00051 #endif 00052 00053 00054 00055 #if RSA_PLATFORM == RSA_IRIX65 00056 #define RSA_PLATFORM_SPECIFIC 00057 #include "bsirix65.h" 00058 #endif 00059 00060 00061 #if RSA_PLATFORM == RSA_WINTEL_IA64 00062 #define RSA_PLATFORM_SPECIFIC 00063 #include "bspia64.h" 00064 #endif 00065 00066 #if (RSA_PLATFORM == RSA_HP_PA1 || RSA_PLATFORM == RSA_HP_PA2) 00067 #define RSA_PLATFORM_SPECIFIC 00068 #include "bshp1020.h" 00069 #endif 00070 00071 #if (RSA_PLATFORM == RSA_HP_64) 00072 #define RSA_PLATFORM_SPECIFIC 00073 #include "bshp64.h" 00074 #endif 00075 00076 #if RSA_PLATFORM == RSA_LINUX_IA64 00077 #define RSA_PLATFORM_SPECIFIC 00078 #include "bslinuxia64.h" 00079 #endif 00080 00081 #if (RSA_PLATFORM == RSA_HP_IA64) 00082 #define RSA_PLATFORM_SPECIFIC 00083 #include "bshpia64.h" 00084 #endif 00085 00086 #if (RSA_PLATFORM == RSA_HP_IA64_32) 00087 #define RSA_PLATFORM_SPECIFIC 00088 #include "bshpia64_32.h" 00089 #endif 00090 00091 #if (RSA_PLATFORM == RSA_MAC_68K_CODE_WARRIOR) 00092 #define RSA_PLATFORM_SPECIFIC 00093 #include "bsmac68k.h" 00094 #endif 00095 00096 #if (RSA_PLATFORM == RSA_MAC_PPC_CODE_WARRIOR) 00097 #define RSA_PLATFORM_SPECIFIC 00098 #include "bsmacppc.h" 00099 #endif 00100 00101 #if RSA_PLATFORM == RSA_SPARC_SUN_SOLARISV8 00102 #define RSA_PLATFORM_SPECIFIC 00103 #include "bsparcv8.h" 00104 #endif 00105 00106 #if RSA_PLATFORM == RSA_SPARC_SUN_SOLARISV9 00107 #define RSA_PLATFORM_SPECIFIC 00108 #include "bsparcv9.h" 00109 #endif 00110 00111 #if RSA_PLATFORM == RSA_IBM_AIX32 00112 #define RSA_PLATFORM_SPECIFIC 00113 #include "bsaix32.h" 00114 #endif 00115 00116 #if RSA_PLATFORM == RSA_IBM_AIX64 00117 #define RSA_PLATFORM_SPECIFIC 00118 #include "bsaix64.h" 00119 #endif 00120 00121 #if RSA_PLATFORM == RSA_AMD_WIN64 00122 #define RSA_PLATFORM_SPECIFIC 00123 #include "bsamdwin64.h" 00124 #endif 00125 00126 #if RSA_PLATFORM == RSA_AMD_LINUX64 00127 #define RSA_PLATFORM_SPECIFIC 00128 #include "bsamdlinux64.h" 00129 #endif 00130 00131 00132 #ifndef RSA_PLATFORM_SPECIFIC 00133 00134 #ifdef __cplusplus 00135 extern "C" { 00136 #endif 00137 00138 /* Is this BSAFE to use full, domestic strength key sizes or export 00139 strength? */ 00140 #define RSA_BSAFE_DESTINATION RSA_DOMESTIC_VERSION 00141 00142 /* The default calling convention is C, the macro RSA_CALLING_CONV should be 00143 "nothing". 00144 If the application is using the PASCAL calling convention then 00145 RSA_CALLING_CONV should be defined approrpriately so that the 00146 application can call the public API accordingly. 00147 For example, the PASCAL calling convention on Windows 95 is 00148 00149 #define RSA_CALLING_CONV ??? 00150 00151 */ 00152 #define RSA_CALLING_CONV 00153 /* temporary, when all files have converted, take this next line out. */ 00154 #define CALL_CONV 00155 00156 /* RSA_GLOBAL_FUNCTION_POINTERS should be set to RSA_ENABLED if and only if 00157 the compiler can intitialize global or static function pointers. 00158 If not (such as with MAC code resource), function pointers can be 00159 set only at run time through an initializing routine. If that is the 00160 case, set RSA_GLOBAL_FUNCTION_POINTERS to RSA_DISABLED. 00161 */ 00162 #define RSA_GLOBAL_FUNCTION_POINTERS RSA_ENABLED 00163 00164 /* Set RSA_INTERMEDIATE_STATE to RSA_DISABLED if you do NOT want to include 00165 the code that finds intermediate states for cloning/serialization 00166 purposes. For instance, an object that has been initialized for RC4 00167 can be "serialized". Call B_GetAlgorithmState. This returns a byte 00168 array that is the RC4 state. With this byte array, B_SetAlgorithmState 00169 will build an object that is in the same state as the original. 00170 If this flag is "enabled", code size increases. If a customer wants to 00171 delete this feature to keep code size down, disable the flag. 00172 */ 00173 #define RSA_INTERMEDIATE_STATE RSA_ENABLED 00174 00175 /* Set RSA_ENDIAN to RSA_LITTLE_ENDIAN for little endian machines (Intel, 00176 for instance). Set it to RSA_BIG_ENDIAN for big endian machines (Mac and 00177 most UNIX, for example). 00178 */ 00179 #define RSA_ENDIAN RSA_BIG_ENDIAN 00180 00181 /* Set RSA_FETCH_UINT4 to RSA_FETCH_ALIGNED_ONLY if the CPU can fetch UINT4 00182 values only from byte-aligned addresses. Set it to RSA_FETCH_UNALIGNED 00183 if it is possible to fetch from unaligned addresses. Unaligned fetches 00184 enables speedups in the handling of 4 and 8 byte quantities (e.g., in 00185 CBC). Old Sun SPARC chips, for instance, cannot do this. 00186 */ 00187 #define RSA_FETCH_UINT4 RSA_FETCH_ALIGNED_ONLY 00188 00189 /* RSA_REGISTER_SIZE defines the bit size of a register, or word. For instance, 00190 a Pentium's register is 32 bits, so set the value to RSA_32_BIT_REGISTER. 00191 On the other hand, an Alpha's register is 64 bits, so set the value to 00192 RSA_64_BIT_REGISTER. 00193 */ 00194 #define RSA_REGISTER_SIZE RSA_32_BIT_REGISTER 00195 00196 /* If the platform accepts prototyping in the function definition, set 00197 RSA_PROTOTYPES to RSA_ENABLED. If not, set the value to RSA_DISABLED. 00198 */ 00199 #define RSA_PROTOTYPES RSA_ENABLED 00200 00201 /* PROTO_LIST is defined depending on how RSA_PROTOTYPES is defined. If 00202 enabled, then PROTO_LIST returns the list, otherwise it returns an 00203 empty list. 00204 */ 00205 #if RSA_PROTOTYPES == RSA_ENABLED 00206 #define PROTO_LIST(list) list 00207 #endif 00208 #if RSA_PROTOTYPES == RSA_DISABLED 00209 #define PROTO_LIST(list) () 00210 #endif 00211 00212 /* On the outside chance that some strange platform exists that does not 00213 use 8-bit bytes, define BITS_PER_BYTE. 00214 */ 00215 #define RSA_BITS_PER_BYTE 8 00216 00217 /* We will create a type (through typedef) that is a time type. It will be 00218 some sort of int (seconds since 1970). Right now, almost all time 00219 int's are 32 bits. In the future, some platforms may use a 64 bit 00220 value. An RSA_TIME_T will be a UINT4, unless someone wants to change 00221 to something else. If so, redefine RSA_TIME_TYPE and add the typedef 00222 (which is in aglobal.h). 00223 */ 00224 #define RSA_TIME_TYPE RSA_32_BIT_TIME 00225 00226 /* The following are all the optimizations we have made so far. An optimization 00227 may exist on a certain platform or it may not. If the optimization exists, 00228 set the macro to the platform macro. If not leave it as C code. 00229 For instance, on Alpha NT, there is a CMP multiply optimization, but 00230 no MD5 transform optimization. Hence, set 00231 RSA_CMP_MULT_WORDS_OPT to RSA_ALPHA_DEC_NT_MSVC40 00232 but leave 00233 RSA_MD5_TRANSFORM_OPT at RSA_C_CODE 00234 */ 00235 #define RSA_CMP_WORD_SIZE RSA_C_CODE 00236 #define RSA_CMP_MULT_WORDS_OPT RSA_C_CODE 00237 #define RSA_CMP_VECTOR_MULT_OPT RSA_C_CODE 00238 #define RSA_CMP_ADD_IN_TRACE_OPT RSA_C_CODE 00239 #define RSA_CMP_MONT_PRODUCT_OPT RSA_C_CODE 00240 #define RSA_CMP_MONT_SQUARE_OPT RSA_C_CODE 00241 #define RSA_CMP_MULTIPLY_OPT RSA_C_CODE 00242 #define RSA_CMP_PA2_0_TEST RSA_C_CODE 00243 #define RSA_CMP_PLATFORM RSA_C_CODE 00244 00245 #define RSA_DES_ENCRYPT_OPT RSA_C_CODE 00246 #define RSA_DES_INIT_ENCRYPT_OPT RSA_C_CODE 00247 #define RSA_DES_INIT_DECRYPT_OPT RSA_C_CODE 00248 #define RSA_DES_PLATFORM RSA_C_CODE 00249 00250 #define RSA_RC2_ENCRYPT_OPT RSA_C_CODE 00251 #define RSA_RC2_DECRYPT_OPT RSA_C_CODE 00252 #define RSA_RC2_INIT_OPT RSA_C_CODE 00253 00254 #define RSA_RC4_UPDATE_OPT RSA_C_CODE 00255 00256 /* 00257 RC5 - 32 00258 */ 00259 #define RSA_RC5_INIT_OPT RSA_C_CODE 00260 /* May set = RSA_DISABLED to revert to Pre-V5.1 C-language procedure 00261 = RSA_ENABLED to invoke faster V5.1 C-language procedures */ 00262 #define RSA_RC5_12_ROUND_INIT_OPTS RSA_ENABLED 00263 #define RSA_RC5_16_ROUND_INIT_OPTS RSA_ENABLED 00264 00265 /* May set = RSA_DISABLED to revert to Pre-V5.1 C-language procedure 00266 = RSA_ENABLED to invoke faster V5.1 C-language procedures */ 00267 #define RSA_RC5_ENCRYPT_OPT RSA_C_CODE 00268 #define RSA_RC5_12_ROUND_ENCRYPT_OPT RSA_ENABLED 00269 #define RSA_RC5_16_ROUND_ENCRYPT_OPT RSA_ENABLED 00270 00271 /* 00272 RC5 - 64 00273 */ 00274 #define RSA_RC5_64_ENCRYPT_OPT RSA_C_CODE 00275 #define RSA_RC5_64_DECRYPT_OPT RSA_C_CODE 00276 #define RSA_RC5_64_INIT_OPT RSA_C_CODE 00277 00278 /* 00279 AES 00280 */ 00281 #define RSA_AES_INIT_OPT RSA_C_CODE 00282 #define RSA_AES_ENCRYPT_OPT RSA_C_CODE 00283 #define RSA_AES_DECRYPT_OPT RSA_C_CODE 00284 #define RSA_AES_PLATFORM RSA_C_CODE 00285 00286 #define RSA_MD5_TRANSFORM_OPT RSA_C_CODE 00287 00288 #define RSA_MAC_UPDATE_OPT RSA_C_CODE 00289 00290 #define RSA_SHA1_UPDATE_OPT RSA_C_CODE 00291 00292 #define RSA_CMP_EC_EVEN_OPT RSA_C_CODE 00293 00294 /* __rotl is not available on this compiler for in-line rotate speed-ups */ 00295 #define ROTL_COMPILER_INTRINSIC RSA_DISABLED 00296 /* __rotr is not available on this compiler for in-line rotate speed-ups */ 00297 #define ROTR_COMPILER_INTRINSIC RSA_DISABLED 00298 00299 /* The following are included to smooth the transition. Take them out 00300 when all files are converted to the new style. 00301 */ 00302 #define BITS_PER_BYTE RSA_BITS_PER_BYTE 00303 #define RSA_PRIME_BITS(modulusBits) (((modulusBits) + 1) / 2) 00304 #define RSA_PRIME_LEN(modulusBits) \ 00305 ((RSA_PRIME_BITS (modulusBits) + RSA_BITS_PER_BYTE - 1) \ 00306 / RSA_BITS_PER_BYTE) 00307 #define BITS_TO_LEN(modulusBits) \ 00308 (((modulusBits) + RSA_BITS_PER_BYTE - 1) / RSA_BITS_PER_BYTE) 00309 00310 #define GLOBAL_FUNCTION_POINTERS 1 00311 00312 #ifdef __cplusplus 00313 } 00314 00315 #ifndef INTELx86 00316 #define INTELx86 0 00317 #endif 00318 00319 00320 #ifndef RSA_MODEXP_RCOM_OPT 00321 #define RSA_MODEXP_RCOM_OPT RSA_DISABLED 00322 #endif 00323 00324 #ifndef RSA_CHAIN_TO_RCOM_MODEXP 00325 #define RSA_CHAIN_TO_RCOM_MODEXP RSA_DISABLED 00326 #endif 00327 00328 #endif /* #ifndef RSA_PLATFORM_SPECIFIC */ 00329 00330 /* Proscribe permissable encryption sizes for entire toolkit 00331 */ 00332 #define MAX_RSA_MODULUS_BITS 4096 00333 #define MIN_RSA_MODULUS_BITS 256 00334 #define MIN_STRONG_RSA_MODULUS_BITS 432 00335 #define A_MIN_DIGEST_LEN 16 00336 #define A_MAX_DIGEST_LEN 32 00337 00338 #ifndef F2M_SELECT_MULTIPLY 00339 #define F2M_SELECT_MULTIPLY F2M_SelectMulOverF2 00340 #endif 00341 00342 #endif /* RSA_PLATFORM == RSA_C_CODE */ 00343 #endif /* _BSAFE_PLATFORM_H_ */