#include <stdio.h>
#include <stdlib.h>
-#include <signal.h>
+
#include <string.h>
#include <math.h>
#include "apps.h"
#include OPENSSL_UNISTD
#endif
+#ifndef OPENSSL_SYS_NETWARE
+#include <signal.h>
+#endif
+
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(OPENSSL_SYS_MACOSX)
# define USE_TOD
#elif !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
# define TIMEB
#endif
+#if defined(OPENSSL_SYS_NETWARE)
+#undef TIMES
+#undef TIMEB
+#include <time.h>
+#endif
+
#ifndef _IRIX
# include <time.h>
#endif
#include <sys/timeb.h>
#endif
-#if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD) && !defined(OPENSSL_SYS_VXWORKS)
+#if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD) && !defined(OPENSSL_SYS_VXWORKS) && !defined(OPENSSL_SYS_NETWARE)
#error "It seems neither struct tms nor struct timeb is supported in this platform!"
#endif
#include <openssl/ecdh.h>
#endif
+/*
+ * The following "HZ" timing stuff should be sync'd up with the code in
+ * crypto/tmdiff.[ch]. That appears to try to do the same job, though I think
+ * this code is more up to date than libcrypto's so there may be features to
+ * migrate over first. This is used in two places further down AFAICS.
+ * The point is that nothing in openssl actually *uses* that tmdiff stuff, so
+ * either speed.c should be using it or it should go because it's obviously not
+ * useful enough. Anyone want to do a janitorial job on this?
+ */
+
/* The following if from times(3) man page. It may need to be changed */
#ifndef HZ
# if defined(_SC_CLK_TCK) \
&& (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
-# define HZ ((double)sysconf(_SC_CLK_TCK))
+# define HZ sysconf(_SC_CLK_TCK)
# else
# ifndef CLK_TCK
# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
# endif
#endif
-#if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2)
+#if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2) && !defined(OPENSSL_SYS_NETWARE)
# define HAVE_FORK 1
#endif
#define START 0
#define STOP 1
+#if defined(OPENSSL_SYS_NETWARE)
+
+ /* for NetWare the best we can do is use clock() which returns the
+ * time, in hundredths of a second, since the NLM began executing
+ */
+static double Time_F(int s)
+ {
+ double ret;
+
+ static clock_t tstart,tend;
+
+ if (s == START)
+ {
+ tstart=clock();
+ return(0);
+ }
+ else
+ {
+ tend=clock();
+ ret=(double)((double)(tend)-(double)(tstart));
+ return((ret < 0.001)?0.001:ret);
+ }
+ }
+
+#else
+
static double Time_F(int s)
{
double ret;
#ifdef USE_TOD
if(usertime)
- {
+ {
static struct rusage tstart,tend;
getrusage_used = 1;
else
{
times(&tend);
- ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
+ ret = HZ;
+ ret=(double)(tend.tms_utime-tstart.tms_utime) / ret;
return((ret < 1e-3)?1e-3:ret);
}
}
# endif
#endif
}
+#endif /* if defined(OPENSSL_SYS_NETWARE) */
+
+
+static const int KDF1_SHA1_len = 20;
+static void *KDF1_SHA1(void *in, size_t inlen, void *out, size_t outlen)
+ {
+#ifndef OPENSSL_NO_SHA
+ if (outlen != SHA_DIGEST_LENGTH)
+ return NULL;
+ return SHA1(in, inlen, out);
+#else
+ return NULL;
+#endif
+ }
+
int MAIN(int, char **);
c[D_CBC_RC5][0]=count;
c[D_CBC_BF][0]=count;
c[D_CBC_CAST][0]=count;
+ c[D_CBC_128_AES][0]=count;
+ c[D_CBC_192_AES][0]=count;
+ c[D_CBC_256_AES][0]=count;
for (i=1; i<SIZE_NUM; i++)
{
c[D_CBC_RC5][i]=c[D_CBC_RC5][i-1]*l0/l1;
c[D_CBC_BF][i]=c[D_CBC_BF][i-1]*l0/l1;
c[D_CBC_CAST][i]=c[D_CBC_CAST][i-1]*l0/l1;
+ c[D_CBC_128_AES][i]=c[D_CBC_128_AES][i-1]*l0/l1;
+ c[D_CBC_192_AES][i]=c[D_CBC_192_AES][i-1]*l0/l1;
+ c[D_CBC_256_AES][i]=c[D_CBC_256_AES][i-1]*l0/l1;
}
#ifndef OPENSSL_NO_RSA
rsa_c[R_RSA_512][0]=count/2000;
}
else
{
- secret_size_a = ECDH_compute_key(secret_a,
+ /* If field size is not more than 24 octets, then use SHA-1 hash of result;
+ * otherwise, use result (see section 4.8 of draft-ietf-tls-ecc-03.txt).
+ */
+ int field_size, outlen;
+ void *(*kdf)(void *in, size_t inlen, void *out, size_t xoutlen);
+ field_size = EC_GROUP_get_degree(ecdh_a[j]->group);
+ if (field_size <= 24 * 8)
+ {
+ outlen = KDF1_SHA1_len;
+ kdf = KDF1_SHA1;
+ }
+ else
+ {
+ outlen = (field_size+7)/8;
+ kdf = NULL;
+ }
+ secret_size_a = ECDH_compute_key(secret_a, outlen,
ecdh_b[j]->pub_key,
- ecdh_a[j]);
- secret_size_b = ECDH_compute_key(secret_b,
+ ecdh_a[j], kdf);
+ secret_size_b = ECDH_compute_key(secret_b, outlen,
ecdh_a[j]->pub_key,
- ecdh_b[j]);
+ ecdh_b[j], kdf);
if (secret_size_a != secret_size_b)
ecdh_checks = 0;
else
Time_F(START);
for (count=0,run=1; COND(ecdh_c[j][0]); count++)
{
- ECDH_compute_key(secret_a,
+ ECDH_compute_key(secret_a, outlen,
ecdh_b[j]->pub_key,
- ecdh_a[j]);
+ ecdh_a[j], kdf);
}
d=Time_F(STOP);
BIO_printf(bio_err, mr ? "+R7:%ld:%d:%.2f\n" :"%ld %d-bit ECDH ops in %.2fs\n",
#endif
#ifdef HZ
#define as_string(s) (#s)
- printf("HZ=%g", (double)HZ);
+ {
+ double dbl = HZ;
+ printf("HZ=%g", dbl);
+ }
# ifdef _SC_CLK_TCK
printf(" [sysconf value]");
# endif
static void print_result(int alg,int run_no,int count,double time_used)
{
- BIO_printf(bio_err,mr ? "+R:%ld:%s:%f\n"
- : "%ld %s's in %.2fs\n",count,names[alg],time_used);
+ BIO_printf(bio_err,mr ? "+R:%d:%s:%f\n"
+ : "%d %s's in %.2fs\n",count,names[alg],time_used);
results[alg][run_no]=((double)count)/time_used*lengths[run_no];
}