$sse2=0;
for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
+&external_label("OPENSSL_ia32cap_P") if ($sse2);
+
&bn_mul_add_words("bn_mul_add_words");
&bn_mul_words("bn_mul_words");
&bn_sqr_words("bn_sqr_words");
{
local($name)=@_;
- &function_begin($name,"");
+ &function_begin($name,$sse2?"EXTRN\t_OPENSSL_ia32cap_P:DWORD":"");
&comment("");
$Low="eax";
&jz(&label("maw_finish"));
if ($sse2) {
- &picmeup("eax","OPENSSL_ia32cap");
+ &picmeup("eax","OPENSSL_ia32cap_P");
&bt(&DWP(0,"eax"),26);
&jnc(&label("maw_loop"));
#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
-unsigned long OPENSSL_ia32cap=0;
-unsigned long *OPENSSL_ia32cap_loc() { return &OPENSSL_ia32cap; }
+unsigned long OPENSSL_ia32cap_P=0;
+unsigned long *OPENSSL_ia32cap_loc(void) { return &OPENSSL_ia32cap_P; }
#if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
#define OPENSSL_CPUID_SETUP
-void OPENSSL_cpuid_setup()
+void OPENSSL_cpuid_setup(void)
{ static int trigger=0;
- unsigned long OPENSSL_ia32_cpuid();
+ unsigned long OPENSSL_ia32_cpuid(void);
char *env;
if (trigger) return;
trigger=1;
if ((env=getenv("OPENSSL_ia32cap")))
- OPENSSL_ia32cap = strtoul(env,NULL,0)|(1<<10);
+ OPENSSL_ia32cap_P = strtoul(env,NULL,0)|(1<<10);
else
- OPENSSL_ia32cap = OPENSSL_ia32_cpuid()|(1<<10);
+ OPENSSL_ia32cap_P = OPENSSL_ia32_cpuid()|(1<<10);
/*
* |(1<<10) sets a reserved bit to signal that variable
* was initialized already... This is to avoid interference
#endif
#if !defined(OPENSSL_CPUID_SETUP)
-void OPENSSL_cpuid_setup() {}
+void OPENSSL_cpuid_setup(void) {}
#endif
#if (defined(_WIN32) || defined(__CYGWIN__)) && defined(_DLL)
#define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1)
#define HEX_SIZE(type) (sizeof(type)*2)
+void OPENSSL_cpuid_setup(void);
+extern unsigned long OPENSSL_ia32cap_P;
+
#ifdef __cplusplus
}
#endif
/* Reason codes. */
#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100
+unsigned long *OPENSSL_ia32cap_loc(void);
+#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
+
#ifdef __cplusplus
}
#endif
* only on IA-32, but we reserve the option for all
* platforms...
*/
- void OPENSSL_cpuid_setup();
OPENSSL_cpuid_setup();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
#include <openssl/sha.h>
#include <openssl/opensslv.h>
+#include "cryptlib.h"
+
const char *SHA512_version="SHA-512" OPENSSL_VERSION_PTEXT;
#if defined(_M_IX86) || defined(_M_AMD64) || defined(__i386) || defined(__x86_64)
#if defined(OPENSSL_IA32_SSE2) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
#define GO_FOR_SSE2(ctx,in,num) do { \
- extern int OPENSSL_ia32cap; \
- void sha512_block_sse2(void *,const void *,size_t); \
- if (!(OPENSSL_ia32cap & (1<<26))) break; \
+ void sha512_block_sse2(void *,const void *,size_t); \
+ if (!(OPENSSL_ia32cap_P & (1<<26))) break; \
sha512_block_sse2(ctx->h,in,num); return; \
} while (0)
#endif
#include <openssl/sha.h>
#include <openssl/evp.h>
+#include <openssl/crypto.h>
unsigned char app_c1[SHA512_DIGEST_LENGTH] = {
0xdd,0xaf,0x35,0xa1,0x93,0x61,0x7a,0xba,
EVP_MD_CTX evp;
#ifdef OPENSSL_IA32_SSE2
- { extern int OPENSSL_ia32cap;
- char *env;
+ /* Alternative to this is to call OpenSSL_add_all_algorithms...
+ * The below code is retained exclusively for debugging purposes. */
+ { char *env;
if ((env=getenv("OPENSSL_ia32cap")))
- OPENSSL_ia32cap = strtol (env,NULL,0);
+ OPENSSL_ia32cap = strtoul (env,NULL,0);
}
#endif
&mov ("edx","ecx");
&function_end("OPENSSL_ia32_cpuid");
-&external_label("OPENSSL_ia32cap");
+&external_label("OPENSSL_ia32cap_P");
-&function_begin_B("OPENSSL_rdtsc");
+&function_begin_B("OPENSSL_rdtsc","EXTRN\t_OPENSSL_ia32cap_P:DWORD");
&xor ("eax","eax");
&xor ("edx","edx");
- &picmeup("ecx","OPENSSL_ia32cap");
+ &picmeup("ecx","OPENSSL_ia32cap_P");
&bt (&DWP(0,"ecx"),4);
&jnc (&label("notsc"));
&rdtsc ();
&ret ();
&function_end_B("OPENSSL_rdtsc");
-&initseg("OPENSSL_cpuid_setup") if ($main'elf);
+&initseg("OPENSSL_cpuid_setup");
&asm_finish();
=head1 SYNOPSIS
- extern unsigned long OPENSSL_ia32cap;
- unsigned long *OPENSSL_ia32cap_loc();
+ unsigned long *OPENSSL_ia32cap_loc(void);
+ #define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
=head1 DESCRIPTION
-OPENSSL_ia32cap is a variable containing IA-32 processor capabilities
-bit vector as it appears in EDX register after executing CPUID
-instruction with EAX=1 input value (see Intel Application Note
-#241618). Naturally it's defined/meaningful on IA-32 platforms only.
-The variable is normally set up automatically upon toolkit
-initialization and can be manipulated afterwards to modify crypto
-library behaviour. For the moment of this writing only two bits are
-significant, namely bit #26 denoting SSE2 support, and bit #4 denoting
-presence of Time-Stamp Counter. Resetting bit #26 at run-time for
-example disables high-performance SSE2 code present in the crypto
+Value returned by OPENSSL_ia32cap_loc() is address of a variable
+containing IA-32 processor capabilities bit vector as it appears in EDX
+register after executing CPUID instruction with EAX=1 input value (see
+Intel Application Note #241618). Naturally it's meaningful on IA-32
+platforms only. The variable is normally set up automatically upon
+toolkit initialization, but can be manipulated afterwards to modify
+crypto library behaviour. For the moment of this writing only two bits
+are significant, namely bit #26 denoting SSE2 support, and bit #4
+denoting presence of Time-Stamp Counter. Clearing bit #26 at run-time
+for example disables high-performance SSE2 code present in the crypto
library. You might have to do this if target OpenSSL application is
executed on SSE2 capable CPU, but under control of OS which does not
-support SSE2 extentions. Even though you can programmatically
-manipulate the value, you most likely will find it more appropriate to
-set up an environment variable with the same name prior starting target
+support SSE2 extentions. Even though you can manipulate the value
+programmatically, you most likely will find it more appropriate to set
+up an environment variable with the same name prior starting target
application, e.g. 'env OPENSSL_ia32cap=0x10 apps/openssl', to achieve
same effect without modifying the application source code.
Alternatively you can reconfigure the toolkit with no-sse2 option and