-.\" $OpenBSD: openssl.1,v 1.144 2023/05/05 18:01:27 tb Exp $
+.\" $OpenBSD: openssl.1,v 1.145 2023/05/20 12:03:02 tb Exp $
.\" ====================================================================
.\" Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
.\"
.\" copied and put under another distribution licence
.\" [including the GNU Public Licence.]
.\"
-.Dd $Mdocdate: May 5 2023 $
+.Dd $Mdocdate: May 20 2023 $
.Dt OPENSSL 1
.Os
.Sh NAME
.Op Fl evp Ar algorithm
.Op Fl mr
.Op Fl multi Ar number
+.Op Fl unaligned Ar number
.Ek
.El
.Pp
Run
.Ar number
benchmarks in parallel.
+.It Fl unaligned Ar number
+Use allocated buffers with an offset of
+.Ar number
+bytes from the alignment provided by
+.Xr malloc 3 .
+.Ar number
+should be between 0 and 16.
.El
.Tg spkac
.Sh SPKAC
-/* $OpenBSD: speed.c,v 1.32 2023/05/20 11:44:15 tb Exp $ */
+/* $OpenBSD: speed.c,v 1.33 2023/05/20 12:03:02 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
#define ECDSA_SECONDS 10
#define ECDH_SECONDS 10
+#define MAX_UNALIGN 16
+
#include <math.h>
#include <signal.h>
#include <stdio.h>
int
speed_main(int argc, char **argv)
{
+ unsigned char *real_buf = NULL, *real_buf2 = NULL;
unsigned char *buf = NULL, *buf2 = NULL;
+ size_t unaligned = 0;
int mret = 1;
long count = 0, save_count = 0;
int i, j, k;
for (i = 0; i < RSA_NUM; i++)
rsa_key[i] = NULL;
- if ((buf = malloc(BUFSIZE)) == NULL) {
+ if ((buf = real_buf = malloc(BUFSIZE + MAX_UNALIGN)) == NULL) {
BIO_printf(bio_err, "out of memory\n");
goto end;
}
- if ((buf2 = malloc(BUFSIZE)) == NULL) {
+ if ((buf2 = real_buf2 = malloc(BUFSIZE + MAX_UNALIGN)) == NULL) {
BIO_printf(bio_err, "out of memory\n");
goto end;
}
}
j--; /* Otherwise, -multi gets confused with an
* algorithm. */
+ } else if (argc > 0 && strcmp(*argv, "-unaligned") == 0) {
+ argc--;
+ argv++;
+ if (argc == 0) {
+ BIO_printf(bio_err, "no alignment offset given\n");
+ goto end;
+ }
+ unaligned = strtonum(argv[0], 0, MAX_UNALIGN, &errstr);
+ if (errstr) {
+ BIO_printf(bio_err, "bad alignment offset: %s",
+ errstr);
+ goto end;
+ }
+ buf = real_buf + unaligned;
+ buf2 = real_buf2 + unaligned;
+ j--; /* Otherwise, -unaligned gets confused with an
+ * algorithm. */
} else if (argc > 0 && strcmp(*argv, "-mr") == 0) {
mr = 1;
j--; /* Otherwise, -mr gets confused with an
BIO_printf(bio_err, "-decrypt time decryption instead of encryption (only EVP).\n");
BIO_printf(bio_err, "-mr produce machine readable output.\n");
BIO_printf(bio_err, "-multi n run n benchmarks in parallel.\n");
+ BIO_printf(bio_err, "-unaligned n use buffers with offset n from proper alignment.\n");
goto end;
}
argc--;
end:
ERR_print_errors(bio_err);
- free(buf);
- free(buf2);
+ free(real_buf);
+ free(real_buf2);
for (i = 0; i < RSA_NUM; i++)
if (rsa_key[i] != NULL)
RSA_free(rsa_key[i]);