diff options
| author | kenjiro <> | 2026-05-05 03:32:46 +0000 |
|---|---|---|
| committer | kenjiro <> | 2026-05-05 03:32:46 +0000 |
| commit | 9b4954e7ae164f68ca4568a0a7db9f8f686bd0f4 (patch) | |
| tree | 31e224479247ba079ef59daaa6f93444fdc4baa2 /src | |
| parent | 03aa4e2eead24982e97b0b163d537e073f748718 (diff) | |
| download | openbsd-9b4954e7ae164f68ca4568a0a7db9f8f686bd0f4.tar.gz openbsd-9b4954e7ae164f68ca4568a0a7db9f8f686bd0f4.tar.bz2 openbsd-9b4954e7ae164f68ca4568a0a7db9f8f686bd0f4.zip | |
openssl: centralize speed benchmark timer handling
The speed benchmark currently arms alarm() from print_message() and
pkey_print_message(), making the output helpers also control benchmark
lifetime. This hidden coupling makes the code harder to maintain and led to
missing alarm cleanup on Windows, as reported in #1245.
Move alarm setup and run-state initialization into speed-specific timer
helpers so benchmark timing is controlled explicitly at the start and stop
points.
ok tb joshua
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr.bin/openssl/speed.c | 259 |
1 files changed, 135 insertions, 124 deletions
diff --git a/src/usr.bin/openssl/speed.c b/src/usr.bin/openssl/speed.c index 760841d95f..142eb9bab0 100644 --- a/src/usr.bin/openssl/speed.c +++ b/src/usr.bin/openssl/speed.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: speed.c,v 1.52 2026/03/19 20:28:46 tb Exp $ */ | 1 | /* $OpenBSD: speed.c,v 1.53 2026/05/05 03:32:46 kenjiro Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -156,6 +156,8 @@ static void | |||
| 156 | pkey_print_message(const char *str, const char *str2, | 156 | pkey_print_message(const char *str, const char *str2, |
| 157 | int bits, int sec); | 157 | int bits, int sec); |
| 158 | static void print_result(int alg, int run_no, int count, double time_used); | 158 | static void print_result(int alg, int run_no, int count, double time_used); |
| 159 | static void speed_timer_start(int s); | ||
| 160 | static double speed_timer_stop(int s); | ||
| 159 | static int do_multi(int multi); | 161 | static int do_multi(int multi); |
| 160 | 162 | ||
| 161 | #define SIZE_NUM 5 | 163 | #define SIZE_NUM 5 |
| @@ -983,9 +985,6 @@ sig_done(int sig) | |||
| 983 | run = 0; | 985 | run = 0; |
| 984 | } | 986 | } |
| 985 | 987 | ||
| 986 | #define START TM_RESET | ||
| 987 | #define STOP TM_GET | ||
| 988 | |||
| 989 | static double | 988 | static double |
| 990 | time_f(int s) | 989 | time_f(int s) |
| 991 | { | 990 | { |
| @@ -995,6 +994,20 @@ time_f(int s) | |||
| 995 | return app_timer_real(s); | 994 | return app_timer_real(s); |
| 996 | } | 995 | } |
| 997 | 996 | ||
| 997 | static void | ||
| 998 | speed_timer_start(int s) | ||
| 999 | { | ||
| 1000 | run = 1; | ||
| 1001 | alarm(s); | ||
| 1002 | time_f(TM_RESET); | ||
| 1003 | } | ||
| 1004 | |||
| 1005 | static double | ||
| 1006 | speed_timer_stop(int s) | ||
| 1007 | { | ||
| 1008 | return time_f(s); | ||
| 1009 | } | ||
| 1010 | |||
| 998 | static const int KDF1_SHA1_len = 20; | 1011 | static const int KDF1_SHA1_len = 20; |
| 999 | static void * | 1012 | static void * |
| 1000 | KDF1_SHA1(const void *in, size_t inlen, void *out, size_t * outlen) | 1013 | KDF1_SHA1(const void *in, size_t inlen, void *out, size_t * outlen) |
| @@ -1617,10 +1630,10 @@ speed_main(int argc, char **argv) | |||
| 1617 | if (doit[D_MD4]) { | 1630 | if (doit[D_MD4]) { |
| 1618 | for (j = 0; j < SIZE_NUM; j++) { | 1631 | for (j = 0; j < SIZE_NUM; j++) { |
| 1619 | print_message(names[D_MD4], lengths[j]); | 1632 | print_message(names[D_MD4], lengths[j]); |
| 1620 | time_f(START); | 1633 | speed_timer_start(SECONDS); |
| 1621 | for (count = 0, run = 1; COND; count++) | 1634 | for (count = 0; COND; count++) |
| 1622 | EVP_Digest(&(buf[0]), (unsigned long) lengths[j], md, NULL, EVP_md4(), NULL); | 1635 | EVP_Digest(&(buf[0]), (unsigned long) lengths[j], md, NULL, EVP_md4(), NULL); |
| 1623 | d = time_f(STOP); | 1636 | d = speed_timer_stop(SECONDS); |
| 1624 | print_result(D_MD4, j, count, d); | 1637 | print_result(D_MD4, j, count, d); |
| 1625 | } | 1638 | } |
| 1626 | } | 1639 | } |
| @@ -1630,10 +1643,10 @@ speed_main(int argc, char **argv) | |||
| 1630 | if (doit[D_MD5]) { | 1643 | if (doit[D_MD5]) { |
| 1631 | for (j = 0; j < SIZE_NUM; j++) { | 1644 | for (j = 0; j < SIZE_NUM; j++) { |
| 1632 | print_message(names[D_MD5], lengths[j]); | 1645 | print_message(names[D_MD5], lengths[j]); |
| 1633 | time_f(START); | 1646 | speed_timer_start(SECONDS); |
| 1634 | for (count = 0, run = 1; COND; count++) | 1647 | for (count = 0; COND; count++) |
| 1635 | EVP_Digest(&(buf[0]), (unsigned long) lengths[j], md, NULL, EVP_get_digestbyname("md5"), NULL); | 1648 | EVP_Digest(&(buf[0]), (unsigned long) lengths[j], md, NULL, EVP_get_digestbyname("md5"), NULL); |
| 1636 | d = time_f(STOP); | 1649 | d = speed_timer_stop(SECONDS); |
| 1637 | print_result(D_MD5, j, count, d); | 1650 | print_result(D_MD5, j, count, d); |
| 1638 | } | 1651 | } |
| 1639 | } | 1652 | } |
| @@ -1653,8 +1666,8 @@ speed_main(int argc, char **argv) | |||
| 1653 | 1666 | ||
| 1654 | for (j = 0; j < SIZE_NUM; j++) { | 1667 | for (j = 0; j < SIZE_NUM; j++) { |
| 1655 | print_message(names[D_HMAC], lengths[j]); | 1668 | print_message(names[D_HMAC], lengths[j]); |
| 1656 | time_f(START); | 1669 | speed_timer_start(SECONDS); |
| 1657 | for (count = 0, run = 1; COND; count++) { | 1670 | for (count = 0; COND; count++) { |
| 1658 | if (!HMAC_Init_ex(hctx, NULL, 0, NULL, NULL)) { | 1671 | if (!HMAC_Init_ex(hctx, NULL, 0, NULL, NULL)) { |
| 1659 | HMAC_CTX_free(hctx); | 1672 | HMAC_CTX_free(hctx); |
| 1660 | goto end; | 1673 | goto end; |
| @@ -1668,7 +1681,7 @@ speed_main(int argc, char **argv) | |||
| 1668 | goto end; | 1681 | goto end; |
| 1669 | } | 1682 | } |
| 1670 | } | 1683 | } |
| 1671 | d = time_f(STOP); | 1684 | d = speed_timer_stop(SECONDS); |
| 1672 | print_result(D_HMAC, j, count, d); | 1685 | print_result(D_HMAC, j, count, d); |
| 1673 | } | 1686 | } |
| 1674 | HMAC_CTX_free(hctx); | 1687 | HMAC_CTX_free(hctx); |
| @@ -1678,10 +1691,10 @@ speed_main(int argc, char **argv) | |||
| 1678 | if (doit[D_SHA1]) { | 1691 | if (doit[D_SHA1]) { |
| 1679 | for (j = 0; j < SIZE_NUM; j++) { | 1692 | for (j = 0; j < SIZE_NUM; j++) { |
| 1680 | print_message(names[D_SHA1], lengths[j]); | 1693 | print_message(names[D_SHA1], lengths[j]); |
| 1681 | time_f(START); | 1694 | speed_timer_start(SECONDS); |
| 1682 | for (count = 0, run = 1; COND; count++) | 1695 | for (count = 0; COND; count++) |
| 1683 | EVP_Digest(buf, (unsigned long) lengths[j], md, NULL, EVP_sha1(), NULL); | 1696 | EVP_Digest(buf, (unsigned long) lengths[j], md, NULL, EVP_sha1(), NULL); |
| 1684 | d = time_f(STOP); | 1697 | d = speed_timer_stop(SECONDS); |
| 1685 | print_result(D_SHA1, j, count, d); | 1698 | print_result(D_SHA1, j, count, d); |
| 1686 | } | 1699 | } |
| 1687 | } | 1700 | } |
| @@ -1689,10 +1702,10 @@ speed_main(int argc, char **argv) | |||
| 1689 | if (doit[D_SHA256]) { | 1702 | if (doit[D_SHA256]) { |
| 1690 | for (j = 0; j < SIZE_NUM; j++) { | 1703 | for (j = 0; j < SIZE_NUM; j++) { |
| 1691 | print_message(names[D_SHA256], lengths[j]); | 1704 | print_message(names[D_SHA256], lengths[j]); |
| 1692 | time_f(START); | 1705 | speed_timer_start(SECONDS); |
| 1693 | for (count = 0, run = 1; COND; count++) | 1706 | for (count = 0; COND; count++) |
| 1694 | SHA256(buf, lengths[j], md); | 1707 | SHA256(buf, lengths[j], md); |
| 1695 | d = time_f(STOP); | 1708 | d = speed_timer_stop(SECONDS); |
| 1696 | print_result(D_SHA256, j, count, d); | 1709 | print_result(D_SHA256, j, count, d); |
| 1697 | } | 1710 | } |
| 1698 | } | 1711 | } |
| @@ -1702,10 +1715,10 @@ speed_main(int argc, char **argv) | |||
| 1702 | if (doit[D_SHA512]) { | 1715 | if (doit[D_SHA512]) { |
| 1703 | for (j = 0; j < SIZE_NUM; j++) { | 1716 | for (j = 0; j < SIZE_NUM; j++) { |
| 1704 | print_message(names[D_SHA512], lengths[j]); | 1717 | print_message(names[D_SHA512], lengths[j]); |
| 1705 | time_f(START); | 1718 | speed_timer_start(SECONDS); |
| 1706 | for (count = 0, run = 1; COND; count++) | 1719 | for (count = 0; COND; count++) |
| 1707 | SHA512(buf, lengths[j], md); | 1720 | SHA512(buf, lengths[j], md); |
| 1708 | d = time_f(STOP); | 1721 | d = speed_timer_stop(SECONDS); |
| 1709 | print_result(D_SHA512, j, count, d); | 1722 | print_result(D_SHA512, j, count, d); |
| 1710 | } | 1723 | } |
| 1711 | } | 1724 | } |
| @@ -1716,10 +1729,10 @@ speed_main(int argc, char **argv) | |||
| 1716 | if (doit[D_RMD160]) { | 1729 | if (doit[D_RMD160]) { |
| 1717 | for (j = 0; j < SIZE_NUM; j++) { | 1730 | for (j = 0; j < SIZE_NUM; j++) { |
| 1718 | print_message(names[D_RMD160], lengths[j]); | 1731 | print_message(names[D_RMD160], lengths[j]); |
| 1719 | time_f(START); | 1732 | speed_timer_start(SECONDS); |
| 1720 | for (count = 0, run = 1; COND; count++) | 1733 | for (count = 0; COND; count++) |
| 1721 | EVP_Digest(buf, (unsigned long) lengths[j], md, NULL, EVP_ripemd160(), NULL); | 1734 | EVP_Digest(buf, (unsigned long) lengths[j], md, NULL, EVP_ripemd160(), NULL); |
| 1722 | d = time_f(STOP); | 1735 | d = speed_timer_stop(SECONDS); |
| 1723 | print_result(D_RMD160, j, count, d); | 1736 | print_result(D_RMD160, j, count, d); |
| 1724 | } | 1737 | } |
| 1725 | } | 1738 | } |
| @@ -1728,11 +1741,11 @@ speed_main(int argc, char **argv) | |||
| 1728 | if (doit[D_RC4]) { | 1741 | if (doit[D_RC4]) { |
| 1729 | for (j = 0; j < SIZE_NUM; j++) { | 1742 | for (j = 0; j < SIZE_NUM; j++) { |
| 1730 | print_message(names[D_RC4], lengths[j]); | 1743 | print_message(names[D_RC4], lengths[j]); |
| 1731 | time_f(START); | 1744 | speed_timer_start(SECONDS); |
| 1732 | for (count = 0, run = 1; COND; count++) | 1745 | for (count = 0; COND; count++) |
| 1733 | RC4(&rc4_ks, (unsigned int) lengths[j], | 1746 | RC4(&rc4_ks, (unsigned int) lengths[j], |
| 1734 | buf, buf); | 1747 | buf, buf); |
| 1735 | d = time_f(STOP); | 1748 | d = speed_timer_stop(SECONDS); |
| 1736 | print_result(D_RC4, j, count, d); | 1749 | print_result(D_RC4, j, count, d); |
| 1737 | } | 1750 | } |
| 1738 | } | 1751 | } |
| @@ -1741,23 +1754,23 @@ speed_main(int argc, char **argv) | |||
| 1741 | if (doit[D_CBC_DES]) { | 1754 | if (doit[D_CBC_DES]) { |
| 1742 | for (j = 0; j < SIZE_NUM; j++) { | 1755 | for (j = 0; j < SIZE_NUM; j++) { |
| 1743 | print_message(names[D_CBC_DES], lengths[j]); | 1756 | print_message(names[D_CBC_DES], lengths[j]); |
| 1744 | time_f(START); | 1757 | speed_timer_start(SECONDS); |
| 1745 | for (count = 0, run = 1; COND; count++) | 1758 | for (count = 0; COND; count++) |
| 1746 | DES_ncbc_encrypt(buf, buf, lengths[j], &sch, | 1759 | DES_ncbc_encrypt(buf, buf, lengths[j], &sch, |
| 1747 | &DES_iv, DES_ENCRYPT); | 1760 | &DES_iv, DES_ENCRYPT); |
| 1748 | d = time_f(STOP); | 1761 | d = speed_timer_stop(SECONDS); |
| 1749 | print_result(D_CBC_DES, j, count, d); | 1762 | print_result(D_CBC_DES, j, count, d); |
| 1750 | } | 1763 | } |
| 1751 | } | 1764 | } |
| 1752 | if (doit[D_EDE3_DES]) { | 1765 | if (doit[D_EDE3_DES]) { |
| 1753 | for (j = 0; j < SIZE_NUM; j++) { | 1766 | for (j = 0; j < SIZE_NUM; j++) { |
| 1754 | print_message(names[D_EDE3_DES], lengths[j]); | 1767 | print_message(names[D_EDE3_DES], lengths[j]); |
| 1755 | time_f(START); | 1768 | speed_timer_start(SECONDS); |
| 1756 | for (count = 0, run = 1; COND; count++) | 1769 | for (count = 0; COND; count++) |
| 1757 | DES_ede3_cbc_encrypt(buf, buf, lengths[j], | 1770 | DES_ede3_cbc_encrypt(buf, buf, lengths[j], |
| 1758 | &sch, &sch2, &sch3, | 1771 | &sch, &sch2, &sch3, |
| 1759 | &DES_iv, DES_ENCRYPT); | 1772 | &DES_iv, DES_ENCRYPT); |
| 1760 | d = time_f(STOP); | 1773 | d = speed_timer_stop(SECONDS); |
| 1761 | print_result(D_EDE3_DES, j, count, d); | 1774 | print_result(D_EDE3_DES, j, count, d); |
| 1762 | } | 1775 | } |
| 1763 | } | 1776 | } |
| @@ -1766,72 +1779,72 @@ speed_main(int argc, char **argv) | |||
| 1766 | if (doit[D_CBC_128_AES]) { | 1779 | if (doit[D_CBC_128_AES]) { |
| 1767 | for (j = 0; j < SIZE_NUM; j++) { | 1780 | for (j = 0; j < SIZE_NUM; j++) { |
| 1768 | print_message(names[D_CBC_128_AES], lengths[j]); | 1781 | print_message(names[D_CBC_128_AES], lengths[j]); |
| 1769 | time_f(START); | 1782 | speed_timer_start(SECONDS); |
| 1770 | for (count = 0, run = 1; COND; count++) | 1783 | for (count = 0; COND; count++) |
| 1771 | AES_cbc_encrypt(buf, buf, | 1784 | AES_cbc_encrypt(buf, buf, |
| 1772 | (unsigned long) lengths[j], &aes_ks1, | 1785 | (unsigned long) lengths[j], &aes_ks1, |
| 1773 | iv, AES_ENCRYPT); | 1786 | iv, AES_ENCRYPT); |
| 1774 | d = time_f(STOP); | 1787 | d = speed_timer_stop(SECONDS); |
| 1775 | print_result(D_CBC_128_AES, j, count, d); | 1788 | print_result(D_CBC_128_AES, j, count, d); |
| 1776 | } | 1789 | } |
| 1777 | } | 1790 | } |
| 1778 | if (doit[D_CBC_192_AES]) { | 1791 | if (doit[D_CBC_192_AES]) { |
| 1779 | for (j = 0; j < SIZE_NUM; j++) { | 1792 | for (j = 0; j < SIZE_NUM; j++) { |
| 1780 | print_message(names[D_CBC_192_AES], lengths[j]); | 1793 | print_message(names[D_CBC_192_AES], lengths[j]); |
| 1781 | time_f(START); | 1794 | speed_timer_start(SECONDS); |
| 1782 | for (count = 0, run = 1; COND; count++) | 1795 | for (count = 0; COND; count++) |
| 1783 | AES_cbc_encrypt(buf, buf, | 1796 | AES_cbc_encrypt(buf, buf, |
| 1784 | (unsigned long) lengths[j], &aes_ks2, | 1797 | (unsigned long) lengths[j], &aes_ks2, |
| 1785 | iv, AES_ENCRYPT); | 1798 | iv, AES_ENCRYPT); |
| 1786 | d = time_f(STOP); | 1799 | d = speed_timer_stop(SECONDS); |
| 1787 | print_result(D_CBC_192_AES, j, count, d); | 1800 | print_result(D_CBC_192_AES, j, count, d); |
| 1788 | } | 1801 | } |
| 1789 | } | 1802 | } |
| 1790 | if (doit[D_CBC_256_AES]) { | 1803 | if (doit[D_CBC_256_AES]) { |
| 1791 | for (j = 0; j < SIZE_NUM; j++) { | 1804 | for (j = 0; j < SIZE_NUM; j++) { |
| 1792 | print_message(names[D_CBC_256_AES], lengths[j]); | 1805 | print_message(names[D_CBC_256_AES], lengths[j]); |
| 1793 | time_f(START); | 1806 | speed_timer_start(SECONDS); |
| 1794 | for (count = 0, run = 1; COND; count++) | 1807 | for (count = 0; COND; count++) |
| 1795 | AES_cbc_encrypt(buf, buf, | 1808 | AES_cbc_encrypt(buf, buf, |
| 1796 | (unsigned long) lengths[j], &aes_ks3, | 1809 | (unsigned long) lengths[j], &aes_ks3, |
| 1797 | iv, AES_ENCRYPT); | 1810 | iv, AES_ENCRYPT); |
| 1798 | d = time_f(STOP); | 1811 | d = speed_timer_stop(SECONDS); |
| 1799 | print_result(D_CBC_256_AES, j, count, d); | 1812 | print_result(D_CBC_256_AES, j, count, d); |
| 1800 | } | 1813 | } |
| 1801 | } | 1814 | } |
| 1802 | if (doit[D_IGE_128_AES]) { | 1815 | if (doit[D_IGE_128_AES]) { |
| 1803 | for (j = 0; j < SIZE_NUM; j++) { | 1816 | for (j = 0; j < SIZE_NUM; j++) { |
| 1804 | print_message(names[D_IGE_128_AES], lengths[j]); | 1817 | print_message(names[D_IGE_128_AES], lengths[j]); |
| 1805 | time_f(START); | 1818 | speed_timer_start(SECONDS); |
| 1806 | for (count = 0, run = 1; COND; count++) | 1819 | for (count = 0; COND; count++) |
| 1807 | AES_ige_encrypt(buf, buf2, | 1820 | AES_ige_encrypt(buf, buf2, |
| 1808 | (unsigned long) lengths[j], &aes_ks1, | 1821 | (unsigned long) lengths[j], &aes_ks1, |
| 1809 | iv, AES_ENCRYPT); | 1822 | iv, AES_ENCRYPT); |
| 1810 | d = time_f(STOP); | 1823 | d = speed_timer_stop(SECONDS); |
| 1811 | print_result(D_IGE_128_AES, j, count, d); | 1824 | print_result(D_IGE_128_AES, j, count, d); |
| 1812 | } | 1825 | } |
| 1813 | } | 1826 | } |
| 1814 | if (doit[D_IGE_192_AES]) { | 1827 | if (doit[D_IGE_192_AES]) { |
| 1815 | for (j = 0; j < SIZE_NUM; j++) { | 1828 | for (j = 0; j < SIZE_NUM; j++) { |
| 1816 | print_message(names[D_IGE_192_AES], lengths[j]); | 1829 | print_message(names[D_IGE_192_AES], lengths[j]); |
| 1817 | time_f(START); | 1830 | speed_timer_start(SECONDS); |
| 1818 | for (count = 0, run = 1; COND; count++) | 1831 | for (count = 0; COND; count++) |
| 1819 | AES_ige_encrypt(buf, buf2, | 1832 | AES_ige_encrypt(buf, buf2, |
| 1820 | (unsigned long) lengths[j], &aes_ks2, | 1833 | (unsigned long) lengths[j], &aes_ks2, |
| 1821 | iv, AES_ENCRYPT); | 1834 | iv, AES_ENCRYPT); |
| 1822 | d = time_f(STOP); | 1835 | d = speed_timer_stop(SECONDS); |
| 1823 | print_result(D_IGE_192_AES, j, count, d); | 1836 | print_result(D_IGE_192_AES, j, count, d); |
| 1824 | } | 1837 | } |
| 1825 | } | 1838 | } |
| 1826 | if (doit[D_IGE_256_AES]) { | 1839 | if (doit[D_IGE_256_AES]) { |
| 1827 | for (j = 0; j < SIZE_NUM; j++) { | 1840 | for (j = 0; j < SIZE_NUM; j++) { |
| 1828 | print_message(names[D_IGE_256_AES], lengths[j]); | 1841 | print_message(names[D_IGE_256_AES], lengths[j]); |
| 1829 | time_f(START); | 1842 | speed_timer_start(SECONDS); |
| 1830 | for (count = 0, run = 1; COND; count++) | 1843 | for (count = 0; COND; count++) |
| 1831 | AES_ige_encrypt(buf, buf2, | 1844 | AES_ige_encrypt(buf, buf2, |
| 1832 | (unsigned long) lengths[j], &aes_ks3, | 1845 | (unsigned long) lengths[j], &aes_ks3, |
| 1833 | iv, AES_ENCRYPT); | 1846 | iv, AES_ENCRYPT); |
| 1834 | d = time_f(STOP); | 1847 | d = speed_timer_stop(SECONDS); |
| 1835 | print_result(D_IGE_256_AES, j, count, d); | 1848 | print_result(D_IGE_256_AES, j, count, d); |
| 1836 | } | 1849 | } |
| 1837 | } | 1850 | } |
| @@ -1841,10 +1854,10 @@ speed_main(int argc, char **argv) | |||
| 1841 | 1854 | ||
| 1842 | for (j = 0; j < SIZE_NUM; j++) { | 1855 | for (j = 0; j < SIZE_NUM; j++) { |
| 1843 | print_message(names[D_GHASH], lengths[j]); | 1856 | print_message(names[D_GHASH], lengths[j]); |
| 1844 | time_f(START); | 1857 | speed_timer_start(SECONDS); |
| 1845 | for (count = 0, run = 1; COND; count++) | 1858 | for (count = 0; COND; count++) |
| 1846 | CRYPTO_gcm128_aad(ctx, buf, lengths[j]); | 1859 | CRYPTO_gcm128_aad(ctx, buf, lengths[j]); |
| 1847 | d = time_f(STOP); | 1860 | d = speed_timer_stop(SECONDS); |
| 1848 | print_result(D_GHASH, j, count, d); | 1861 | print_result(D_GHASH, j, count, d); |
| 1849 | } | 1862 | } |
| 1850 | CRYPTO_gcm128_release(ctx); | 1863 | CRYPTO_gcm128_release(ctx); |
| @@ -1867,11 +1880,11 @@ speed_main(int argc, char **argv) | |||
| 1867 | 1880 | ||
| 1868 | for (j = 0; j < SIZE_NUM; j++) { | 1881 | for (j = 0; j < SIZE_NUM; j++) { |
| 1869 | print_message(names[D_AES_128_GCM], lengths[j]); | 1882 | print_message(names[D_AES_128_GCM], lengths[j]); |
| 1870 | time_f(START); | 1883 | speed_timer_start(SECONDS); |
| 1871 | for (count = 0, run = 1; COND; count++) | 1884 | for (count = 0; COND; count++) |
| 1872 | EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, | 1885 | EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, |
| 1873 | nonce_len, buf, lengths[j], NULL, 0); | 1886 | nonce_len, buf, lengths[j], NULL, 0); |
| 1874 | d = time_f(STOP); | 1887 | d = speed_timer_stop(SECONDS); |
| 1875 | print_result(D_AES_128_GCM,j,count,d); | 1888 | print_result(D_AES_128_GCM,j,count,d); |
| 1876 | } | 1889 | } |
| 1877 | EVP_AEAD_CTX_free(ctx); | 1890 | EVP_AEAD_CTX_free(ctx); |
| @@ -1895,11 +1908,11 @@ speed_main(int argc, char **argv) | |||
| 1895 | 1908 | ||
| 1896 | for (j = 0; j < SIZE_NUM; j++) { | 1909 | for (j = 0; j < SIZE_NUM; j++) { |
| 1897 | print_message(names[D_AES_256_GCM], lengths[j]); | 1910 | print_message(names[D_AES_256_GCM], lengths[j]); |
| 1898 | time_f(START); | 1911 | speed_timer_start(SECONDS); |
| 1899 | for (count = 0, run = 1; COND; count++) | 1912 | for (count = 0; COND; count++) |
| 1900 | EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, | 1913 | EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, |
| 1901 | nonce_len, buf, lengths[j], NULL, 0); | 1914 | nonce_len, buf, lengths[j], NULL, 0); |
| 1902 | d = time_f(STOP); | 1915 | d = speed_timer_stop(SECONDS); |
| 1903 | print_result(D_AES_256_GCM, j, count, d); | 1916 | print_result(D_AES_256_GCM, j, count, d); |
| 1904 | } | 1917 | } |
| 1905 | EVP_AEAD_CTX_free(ctx); | 1918 | EVP_AEAD_CTX_free(ctx); |
| @@ -1924,11 +1937,11 @@ speed_main(int argc, char **argv) | |||
| 1924 | 1937 | ||
| 1925 | for (j = 0; j < SIZE_NUM; j++) { | 1938 | for (j = 0; j < SIZE_NUM; j++) { |
| 1926 | print_message(names[D_CHACHA20_POLY1305], lengths[j]); | 1939 | print_message(names[D_CHACHA20_POLY1305], lengths[j]); |
| 1927 | time_f(START); | 1940 | speed_timer_start(SECONDS); |
| 1928 | for (count = 0, run = 1; COND; count++) | 1941 | for (count = 0; COND; count++) |
| 1929 | EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, | 1942 | EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, |
| 1930 | nonce_len, buf, lengths[j], NULL, 0); | 1943 | nonce_len, buf, lengths[j], NULL, 0); |
| 1931 | d = time_f(STOP); | 1944 | d = speed_timer_stop(SECONDS); |
| 1932 | print_result(D_CHACHA20_POLY1305, j, count, d); | 1945 | print_result(D_CHACHA20_POLY1305, j, count, d); |
| 1933 | } | 1946 | } |
| 1934 | EVP_AEAD_CTX_free(ctx); | 1947 | EVP_AEAD_CTX_free(ctx); |
| @@ -1938,36 +1951,36 @@ speed_main(int argc, char **argv) | |||
| 1938 | if (doit[D_CBC_128_CML]) { | 1951 | if (doit[D_CBC_128_CML]) { |
| 1939 | for (j = 0; j < SIZE_NUM; j++) { | 1952 | for (j = 0; j < SIZE_NUM; j++) { |
| 1940 | print_message(names[D_CBC_128_CML], lengths[j]); | 1953 | print_message(names[D_CBC_128_CML], lengths[j]); |
| 1941 | time_f(START); | 1954 | speed_timer_start(SECONDS); |
| 1942 | for (count = 0, run = 1; COND; count++) | 1955 | for (count = 0; COND; count++) |
| 1943 | Camellia_cbc_encrypt(buf, buf, | 1956 | Camellia_cbc_encrypt(buf, buf, |
| 1944 | (unsigned long) lengths[j], &camellia_ks1, | 1957 | (unsigned long) lengths[j], &camellia_ks1, |
| 1945 | iv, CAMELLIA_ENCRYPT); | 1958 | iv, CAMELLIA_ENCRYPT); |
| 1946 | d = time_f(STOP); | 1959 | d = speed_timer_stop(SECONDS); |
| 1947 | print_result(D_CBC_128_CML, j, count, d); | 1960 | print_result(D_CBC_128_CML, j, count, d); |
| 1948 | } | 1961 | } |
| 1949 | } | 1962 | } |
| 1950 | if (doit[D_CBC_192_CML]) { | 1963 | if (doit[D_CBC_192_CML]) { |
| 1951 | for (j = 0; j < SIZE_NUM; j++) { | 1964 | for (j = 0; j < SIZE_NUM; j++) { |
| 1952 | print_message(names[D_CBC_192_CML], lengths[j]); | 1965 | print_message(names[D_CBC_192_CML], lengths[j]); |
| 1953 | time_f(START); | 1966 | speed_timer_start(SECONDS); |
| 1954 | for (count = 0, run = 1; COND; count++) | 1967 | for (count = 0; COND; count++) |
| 1955 | Camellia_cbc_encrypt(buf, buf, | 1968 | Camellia_cbc_encrypt(buf, buf, |
| 1956 | (unsigned long) lengths[j], &camellia_ks2, | 1969 | (unsigned long) lengths[j], &camellia_ks2, |
| 1957 | iv, CAMELLIA_ENCRYPT); | 1970 | iv, CAMELLIA_ENCRYPT); |
| 1958 | d = time_f(STOP); | 1971 | d = speed_timer_stop(SECONDS); |
| 1959 | print_result(D_CBC_192_CML, j, count, d); | 1972 | print_result(D_CBC_192_CML, j, count, d); |
| 1960 | } | 1973 | } |
| 1961 | } | 1974 | } |
| 1962 | if (doit[D_CBC_256_CML]) { | 1975 | if (doit[D_CBC_256_CML]) { |
| 1963 | for (j = 0; j < SIZE_NUM; j++) { | 1976 | for (j = 0; j < SIZE_NUM; j++) { |
| 1964 | print_message(names[D_CBC_256_CML], lengths[j]); | 1977 | print_message(names[D_CBC_256_CML], lengths[j]); |
| 1965 | time_f(START); | 1978 | speed_timer_start(SECONDS); |
| 1966 | for (count = 0, run = 1; COND; count++) | 1979 | for (count = 0; COND; count++) |
| 1967 | Camellia_cbc_encrypt(buf, buf, | 1980 | Camellia_cbc_encrypt(buf, buf, |
| 1968 | (unsigned long) lengths[j], &camellia_ks3, | 1981 | (unsigned long) lengths[j], &camellia_ks3, |
| 1969 | iv, CAMELLIA_ENCRYPT); | 1982 | iv, CAMELLIA_ENCRYPT); |
| 1970 | d = time_f(STOP); | 1983 | d = speed_timer_stop(SECONDS); |
| 1971 | print_result(D_CBC_256_CML, j, count, d); | 1984 | print_result(D_CBC_256_CML, j, count, d); |
| 1972 | } | 1985 | } |
| 1973 | } | 1986 | } |
| @@ -1976,12 +1989,12 @@ speed_main(int argc, char **argv) | |||
| 1976 | if (doit[D_CBC_IDEA]) { | 1989 | if (doit[D_CBC_IDEA]) { |
| 1977 | for (j = 0; j < SIZE_NUM; j++) { | 1990 | for (j = 0; j < SIZE_NUM; j++) { |
| 1978 | print_message(names[D_CBC_IDEA], lengths[j]); | 1991 | print_message(names[D_CBC_IDEA], lengths[j]); |
| 1979 | time_f(START); | 1992 | speed_timer_start(SECONDS); |
| 1980 | for (count = 0, run = 1; COND; count++) | 1993 | for (count = 0; COND; count++) |
| 1981 | idea_cbc_encrypt(buf, buf, | 1994 | idea_cbc_encrypt(buf, buf, |
| 1982 | (unsigned long) lengths[j], &idea_ks, | 1995 | (unsigned long) lengths[j], &idea_ks, |
| 1983 | iv, IDEA_ENCRYPT); | 1996 | iv, IDEA_ENCRYPT); |
| 1984 | d = time_f(STOP); | 1997 | d = speed_timer_stop(SECONDS); |
| 1985 | print_result(D_CBC_IDEA, j, count, d); | 1998 | print_result(D_CBC_IDEA, j, count, d); |
| 1986 | } | 1999 | } |
| 1987 | } | 2000 | } |
| @@ -1990,12 +2003,12 @@ speed_main(int argc, char **argv) | |||
| 1990 | if (doit[D_CBC_RC2]) { | 2003 | if (doit[D_CBC_RC2]) { |
| 1991 | for (j = 0; j < SIZE_NUM; j++) { | 2004 | for (j = 0; j < SIZE_NUM; j++) { |
| 1992 | print_message(names[D_CBC_RC2], lengths[j]); | 2005 | print_message(names[D_CBC_RC2], lengths[j]); |
| 1993 | time_f(START); | 2006 | speed_timer_start(SECONDS); |
| 1994 | for (count = 0, run = 1; COND; count++) | 2007 | for (count = 0; COND; count++) |
| 1995 | RC2_cbc_encrypt(buf, buf, | 2008 | RC2_cbc_encrypt(buf, buf, |
| 1996 | (unsigned long) lengths[j], &rc2_ks, | 2009 | (unsigned long) lengths[j], &rc2_ks, |
| 1997 | iv, RC2_ENCRYPT); | 2010 | iv, RC2_ENCRYPT); |
| 1998 | d = time_f(STOP); | 2011 | d = speed_timer_stop(SECONDS); |
| 1999 | print_result(D_CBC_RC2, j, count, d); | 2012 | print_result(D_CBC_RC2, j, count, d); |
| 2000 | } | 2013 | } |
| 2001 | } | 2014 | } |
| @@ -2004,12 +2017,12 @@ speed_main(int argc, char **argv) | |||
| 2004 | if (doit[D_CBC_BF]) { | 2017 | if (doit[D_CBC_BF]) { |
| 2005 | for (j = 0; j < SIZE_NUM; j++) { | 2018 | for (j = 0; j < SIZE_NUM; j++) { |
| 2006 | print_message(names[D_CBC_BF], lengths[j]); | 2019 | print_message(names[D_CBC_BF], lengths[j]); |
| 2007 | time_f(START); | 2020 | speed_timer_start(SECONDS); |
| 2008 | for (count = 0, run = 1; COND; count++) | 2021 | for (count = 0; COND; count++) |
| 2009 | BF_cbc_encrypt(buf, buf, | 2022 | BF_cbc_encrypt(buf, buf, |
| 2010 | (unsigned long) lengths[j], &bf_ks, | 2023 | (unsigned long) lengths[j], &bf_ks, |
| 2011 | iv, BF_ENCRYPT); | 2024 | iv, BF_ENCRYPT); |
| 2012 | d = time_f(STOP); | 2025 | d = speed_timer_stop(SECONDS); |
| 2013 | print_result(D_CBC_BF, j, count, d); | 2026 | print_result(D_CBC_BF, j, count, d); |
| 2014 | } | 2027 | } |
| 2015 | } | 2028 | } |
| @@ -2018,12 +2031,12 @@ speed_main(int argc, char **argv) | |||
| 2018 | if (doit[D_CBC_CAST]) { | 2031 | if (doit[D_CBC_CAST]) { |
| 2019 | for (j = 0; j < SIZE_NUM; j++) { | 2032 | for (j = 0; j < SIZE_NUM; j++) { |
| 2020 | print_message(names[D_CBC_CAST], lengths[j]); | 2033 | print_message(names[D_CBC_CAST], lengths[j]); |
| 2021 | time_f(START); | 2034 | speed_timer_start(SECONDS); |
| 2022 | for (count = 0, run = 1; COND; count++) | 2035 | for (count = 0; COND; count++) |
| 2023 | CAST_cbc_encrypt(buf, buf, | 2036 | CAST_cbc_encrypt(buf, buf, |
| 2024 | (unsigned long) lengths[j], &cast_ks, | 2037 | (unsigned long) lengths[j], &cast_ks, |
| 2025 | iv, CAST_ENCRYPT); | 2038 | iv, CAST_ENCRYPT); |
| 2026 | d = time_f(STOP); | 2039 | d = speed_timer_stop(SECONDS); |
| 2027 | print_result(D_CBC_CAST, j, count, d); | 2040 | print_result(D_CBC_CAST, j, count, d); |
| 2028 | } | 2041 | } |
| 2029 | } | 2042 | } |
| @@ -2055,29 +2068,29 @@ speed_main(int argc, char **argv) | |||
| 2055 | EVP_EncryptInit_ex(ctx, evp_cipher, NULL, key16, iv); | 2068 | EVP_EncryptInit_ex(ctx, evp_cipher, NULL, key16, iv); |
| 2056 | EVP_CIPHER_CTX_set_padding(ctx, 0); | 2069 | EVP_CIPHER_CTX_set_padding(ctx, 0); |
| 2057 | 2070 | ||
| 2058 | time_f(START); | 2071 | speed_timer_start(SECONDS); |
| 2059 | if (decrypt) | 2072 | if (decrypt) |
| 2060 | for (count = 0, run = 1; COND; count++) | 2073 | for (count = 0; COND; count++) |
| 2061 | EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[j]); | 2074 | EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[j]); |
| 2062 | else | 2075 | else |
| 2063 | for (count = 0, run = 1; COND; count++) | 2076 | for (count = 0; COND; count++) |
| 2064 | EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[j]); | 2077 | EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[j]); |
| 2065 | if (decrypt) | 2078 | if (decrypt) |
| 2066 | EVP_DecryptFinal_ex(ctx, buf, &outl); | 2079 | EVP_DecryptFinal_ex(ctx, buf, &outl); |
| 2067 | else | 2080 | else |
| 2068 | EVP_EncryptFinal_ex(ctx, buf, &outl); | 2081 | EVP_EncryptFinal_ex(ctx, buf, &outl); |
| 2069 | d = time_f(STOP); | 2082 | d = speed_timer_stop(SECONDS); |
| 2070 | EVP_CIPHER_CTX_free(ctx); | 2083 | EVP_CIPHER_CTX_free(ctx); |
| 2071 | } | 2084 | } |
| 2072 | if (evp_md) { | 2085 | if (evp_md) { |
| 2073 | names[D_EVP] = OBJ_nid2ln(EVP_MD_type(evp_md)); | 2086 | names[D_EVP] = OBJ_nid2ln(EVP_MD_type(evp_md)); |
| 2074 | print_message(names[D_EVP], lengths[j]); | 2087 | print_message(names[D_EVP], lengths[j]); |
| 2075 | 2088 | ||
| 2076 | time_f(START); | 2089 | speed_timer_start(SECONDS); |
| 2077 | for (count = 0, run = 1; COND; count++) | 2090 | for (count = 0; COND; count++) |
| 2078 | EVP_Digest(buf, lengths[j], &(md[0]), NULL, evp_md, NULL); | 2091 | EVP_Digest(buf, lengths[j], &(md[0]), NULL, evp_md, NULL); |
| 2079 | 2092 | ||
| 2080 | d = time_f(STOP); | 2093 | d = speed_timer_stop(SECONDS); |
| 2081 | } | 2094 | } |
| 2082 | print_result(D_EVP, j, count, d); | 2095 | print_result(D_EVP, j, count, d); |
| 2083 | } | 2096 | } |
| @@ -2097,8 +2110,8 @@ speed_main(int argc, char **argv) | |||
| 2097 | rsa_bits[j], | 2110 | rsa_bits[j], |
| 2098 | RSA_SECONDS); | 2111 | RSA_SECONDS); |
| 2099 | /* RSA_blinding_on(rsa_key[j],NULL); */ | 2112 | /* RSA_blinding_on(rsa_key[j],NULL); */ |
| 2100 | time_f(START); | 2113 | speed_timer_start(RSA_SECONDS); |
| 2101 | for (count = 0, run = 1; COND; count++) { | 2114 | for (count = 0; COND; count++) { |
| 2102 | ret = RSA_sign(NID_md5_sha1, buf, 36, buf2, | 2115 | ret = RSA_sign(NID_md5_sha1, buf, 36, buf2, |
| 2103 | &rsa_num, rsa_key[j]); | 2116 | &rsa_num, rsa_key[j]); |
| 2104 | if (ret == 0) { | 2117 | if (ret == 0) { |
| @@ -2109,7 +2122,7 @@ speed_main(int argc, char **argv) | |||
| 2109 | break; | 2122 | break; |
| 2110 | } | 2123 | } |
| 2111 | } | 2124 | } |
| 2112 | d = time_f(STOP); | 2125 | d = speed_timer_stop(RSA_SECONDS); |
| 2113 | BIO_printf(bio_err, mr ? "+R1:%ld:%d:%.2f\n" | 2126 | BIO_printf(bio_err, mr ? "+R1:%ld:%d:%.2f\n" |
| 2114 | : "%ld %d bit private RSA in %.2fs\n", | 2127 | : "%ld %d bit private RSA in %.2fs\n", |
| 2115 | count, rsa_bits[j], d); | 2128 | count, rsa_bits[j], d); |
| @@ -2126,8 +2139,8 @@ speed_main(int argc, char **argv) | |||
| 2126 | pkey_print_message("public", "rsa", | 2139 | pkey_print_message("public", "rsa", |
| 2127 | rsa_bits[j], | 2140 | rsa_bits[j], |
| 2128 | RSA_SECONDS); | 2141 | RSA_SECONDS); |
| 2129 | time_f(START); | 2142 | speed_timer_start(RSA_SECONDS); |
| 2130 | for (count = 0, run = 1; COND; count++) { | 2143 | for (count = 0; COND; count++) { |
| 2131 | ret = RSA_verify(NID_md5_sha1, buf, 36, buf2, | 2144 | ret = RSA_verify(NID_md5_sha1, buf, 36, buf2, |
| 2132 | rsa_num, rsa_key[j]); | 2145 | rsa_num, rsa_key[j]); |
| 2133 | if (ret <= 0) { | 2146 | if (ret <= 0) { |
| @@ -2138,7 +2151,7 @@ speed_main(int argc, char **argv) | |||
| 2138 | break; | 2151 | break; |
| 2139 | } | 2152 | } |
| 2140 | } | 2153 | } |
| 2141 | d = time_f(STOP); | 2154 | d = speed_timer_stop(RSA_SECONDS); |
| 2142 | BIO_printf(bio_err, mr ? "+R2:%ld:%d:%.2f\n" | 2155 | BIO_printf(bio_err, mr ? "+R2:%ld:%d:%.2f\n" |
| 2143 | : "%ld %d bit public RSA in %.2fs\n", | 2156 | : "%ld %d bit public RSA in %.2fs\n", |
| 2144 | count, rsa_bits[j], d); | 2157 | count, rsa_bits[j], d); |
| @@ -2171,8 +2184,8 @@ speed_main(int argc, char **argv) | |||
| 2171 | pkey_print_message("sign", "dsa", | 2184 | pkey_print_message("sign", "dsa", |
| 2172 | dsa_bits[j], | 2185 | dsa_bits[j], |
| 2173 | DSA_SECONDS); | 2186 | DSA_SECONDS); |
| 2174 | time_f(START); | 2187 | speed_timer_start(DSA_SECONDS); |
| 2175 | for (count = 0, run = 1; COND; count++) { | 2188 | for (count = 0; COND; count++) { |
| 2176 | ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2, | 2189 | ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2, |
| 2177 | &kk, dsa_key[j]); | 2190 | &kk, dsa_key[j]); |
| 2178 | if (ret == 0) { | 2191 | if (ret == 0) { |
| @@ -2183,7 +2196,7 @@ speed_main(int argc, char **argv) | |||
| 2183 | break; | 2196 | break; |
| 2184 | } | 2197 | } |
| 2185 | } | 2198 | } |
| 2186 | d = time_f(STOP); | 2199 | d = speed_timer_stop(DSA_SECONDS); |
| 2187 | BIO_printf(bio_err, mr ? "+R3:%ld:%d:%.2f\n" | 2200 | BIO_printf(bio_err, mr ? "+R3:%ld:%d:%.2f\n" |
| 2188 | : "%ld %d bit DSA signs in %.2fs\n", | 2201 | : "%ld %d bit DSA signs in %.2fs\n", |
| 2189 | count, dsa_bits[j], d); | 2202 | count, dsa_bits[j], d); |
| @@ -2201,8 +2214,8 @@ speed_main(int argc, char **argv) | |||
| 2201 | pkey_print_message("verify", "dsa", | 2214 | pkey_print_message("verify", "dsa", |
| 2202 | dsa_bits[j], | 2215 | dsa_bits[j], |
| 2203 | DSA_SECONDS); | 2216 | DSA_SECONDS); |
| 2204 | time_f(START); | 2217 | speed_timer_start(DSA_SECONDS); |
| 2205 | for (count = 0, run = 1; COND; count++) { | 2218 | for (count = 0; COND; count++) { |
| 2206 | ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2, | 2219 | ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2, |
| 2207 | kk, dsa_key[j]); | 2220 | kk, dsa_key[j]); |
| 2208 | if (ret <= 0) { | 2221 | if (ret <= 0) { |
| @@ -2213,7 +2226,7 @@ speed_main(int argc, char **argv) | |||
| 2213 | break; | 2226 | break; |
| 2214 | } | 2227 | } |
| 2215 | } | 2228 | } |
| 2216 | d = time_f(STOP); | 2229 | d = speed_timer_stop(DSA_SECONDS); |
| 2217 | BIO_printf(bio_err, mr ? "+R4:%ld:%d:%.2f\n" | 2230 | BIO_printf(bio_err, mr ? "+R4:%ld:%d:%.2f\n" |
| 2218 | : "%ld %d bit DSA verify in %.2fs\n", | 2231 | : "%ld %d bit DSA verify in %.2fs\n", |
| 2219 | count, dsa_bits[j], d); | 2232 | count, dsa_bits[j], d); |
| @@ -2253,8 +2266,8 @@ speed_main(int argc, char **argv) | |||
| 2253 | test_curves_bits[j], | 2266 | test_curves_bits[j], |
| 2254 | ECDSA_SECONDS); | 2267 | ECDSA_SECONDS); |
| 2255 | 2268 | ||
| 2256 | time_f(START); | 2269 | speed_timer_start(ECDSA_SECONDS); |
| 2257 | for (count = 0, run = 1; COND; count++) { | 2270 | for (count = 0; COND; count++) { |
| 2258 | ret = ECDSA_sign(0, buf, 20, | 2271 | ret = ECDSA_sign(0, buf, 20, |
| 2259 | ecdsasig, &ecdsasiglen, | 2272 | ecdsasig, &ecdsasiglen, |
| 2260 | ecdsa[j]); | 2273 | ecdsa[j]); |
| @@ -2265,7 +2278,7 @@ speed_main(int argc, char **argv) | |||
| 2265 | break; | 2278 | break; |
| 2266 | } | 2279 | } |
| 2267 | } | 2280 | } |
| 2268 | d = time_f(STOP); | 2281 | d = speed_timer_stop(ECDSA_SECONDS); |
| 2269 | 2282 | ||
| 2270 | BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" : | 2283 | BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" : |
| 2271 | "%ld %d bit ECDSA signs in %.2fs \n", | 2284 | "%ld %d bit ECDSA signs in %.2fs \n", |
| @@ -2285,8 +2298,8 @@ speed_main(int argc, char **argv) | |||
| 2285 | pkey_print_message("verify", "ecdsa", | 2298 | pkey_print_message("verify", "ecdsa", |
| 2286 | test_curves_bits[j], | 2299 | test_curves_bits[j], |
| 2287 | ECDSA_SECONDS); | 2300 | ECDSA_SECONDS); |
| 2288 | time_f(START); | 2301 | speed_timer_start(ECDSA_SECONDS); |
| 2289 | for (count = 0, run = 1; COND; count++) { | 2302 | for (count = 0; COND; count++) { |
| 2290 | ret = ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]); | 2303 | ret = ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]); |
| 2291 | if (ret != 1) { | 2304 | if (ret != 1) { |
| 2292 | BIO_printf(bio_err, "ECDSA verify failure\n"); | 2305 | BIO_printf(bio_err, "ECDSA verify failure\n"); |
| @@ -2295,7 +2308,7 @@ speed_main(int argc, char **argv) | |||
| 2295 | break; | 2308 | break; |
| 2296 | } | 2309 | } |
| 2297 | } | 2310 | } |
| 2298 | d = time_f(STOP); | 2311 | d = speed_timer_stop(ECDSA_SECONDS); |
| 2299 | BIO_printf(bio_err, mr ? "+R6:%ld:%d:%.2f\n" | 2312 | BIO_printf(bio_err, mr ? "+R6:%ld:%d:%.2f\n" |
| 2300 | : "%ld %d bit ECDSA verify in %.2fs\n", | 2313 | : "%ld %d bit ECDSA verify in %.2fs\n", |
| 2301 | count, test_curves_bits[j], d); | 2314 | count, test_curves_bits[j], d); |
| @@ -2371,14 +2384,14 @@ speed_main(int argc, char **argv) | |||
| 2371 | pkey_print_message("", "ecdh", | 2384 | pkey_print_message("", "ecdh", |
| 2372 | test_curves_bits[j], | 2385 | test_curves_bits[j], |
| 2373 | ECDH_SECONDS); | 2386 | ECDH_SECONDS); |
| 2374 | time_f(START); | 2387 | speed_timer_start(ECDH_SECONDS); |
| 2375 | for (count = 0, run = 1; COND; count++) { | 2388 | for (count = 0; COND; count++) { |
| 2376 | ECDH_compute_key(secret_a, | 2389 | ECDH_compute_key(secret_a, |
| 2377 | outlen, | 2390 | outlen, |
| 2378 | EC_KEY_get0_public_key(ecdh_b[j]), | 2391 | EC_KEY_get0_public_key(ecdh_b[j]), |
| 2379 | ecdh_a[j], kdf); | 2392 | ecdh_a[j], kdf); |
| 2380 | } | 2393 | } |
| 2381 | d = time_f(STOP); | 2394 | d = speed_timer_stop(ECDH_SECONDS); |
| 2382 | BIO_printf(bio_err, mr | 2395 | BIO_printf(bio_err, mr |
| 2383 | ? "+R7:%ld:%d:%.2f\n" | 2396 | ? "+R7:%ld:%d:%.2f\n" |
| 2384 | : "%ld %d-bit ECDH ops in %.2fs\n", | 2397 | : "%ld %d-bit ECDH ops in %.2fs\n", |
| @@ -2412,8 +2425,8 @@ speed_main(int argc, char **argv) | |||
| 2412 | continue; | 2425 | continue; |
| 2413 | 2426 | ||
| 2414 | pkey_print_message("keygen", "mlkem", bits, MLKEM_SECONDS); | 2427 | pkey_print_message("keygen", "mlkem", bits, MLKEM_SECONDS); |
| 2415 | time_f(START); | 2428 | speed_timer_start(MLKEM_SECONDS); |
| 2416 | for (count = 0, run = 1; COND; count++) { | 2429 | for (count = 0; COND; count++) { |
| 2417 | /* | 2430 | /* |
| 2418 | * MLKEM_generate_key requires an uninitialized key | 2431 | * MLKEM_generate_key requires an uninitialized key |
| 2419 | * object, so allocate and free on every iteration. | 2432 | * object, so allocate and free on every iteration. |
| @@ -2431,7 +2444,7 @@ speed_main(int argc, char **argv) | |||
| 2431 | free(encoded_pub); | 2444 | free(encoded_pub); |
| 2432 | encoded_pub = NULL; | 2445 | encoded_pub = NULL; |
| 2433 | } | 2446 | } |
| 2434 | d = time_f(STOP); | 2447 | d = speed_timer_stop(MLKEM_SECONDS); |
| 2435 | if (run) | 2448 | if (run) |
| 2436 | goto mlkem_err; | 2449 | goto mlkem_err; |
| 2437 | BIO_printf(bio_err, mr ? "+R8:%ld:%d:%.2f\n" | 2450 | BIO_printf(bio_err, mr ? "+R8:%ld:%d:%.2f\n" |
| @@ -2450,8 +2463,8 @@ speed_main(int argc, char **argv) | |||
| 2450 | encoded_pub = NULL; | 2463 | encoded_pub = NULL; |
| 2451 | 2464 | ||
| 2452 | pkey_print_message("encap", "mlkem", bits, MLKEM_SECONDS); | 2465 | pkey_print_message("encap", "mlkem", bits, MLKEM_SECONDS); |
| 2453 | time_f(START); | 2466 | speed_timer_start(MLKEM_SECONDS); |
| 2454 | for (count = 0, run = 1; COND; count++) { | 2467 | for (count = 0; COND; count++) { |
| 2455 | if (!MLKEM_encap(pub, &ct, &ct_len, &ss, | 2468 | if (!MLKEM_encap(pub, &ct, &ct_len, &ss, |
| 2456 | &ss_len)) | 2469 | &ss_len)) |
| 2457 | break; | 2470 | break; |
| @@ -2460,7 +2473,7 @@ speed_main(int argc, char **argv) | |||
| 2460 | free(ss); | 2473 | free(ss); |
| 2461 | ss = NULL; | 2474 | ss = NULL; |
| 2462 | } | 2475 | } |
| 2463 | d = time_f(STOP); | 2476 | d = speed_timer_stop(MLKEM_SECONDS); |
| 2464 | if (run) | 2477 | if (run) |
| 2465 | goto mlkem_err; | 2478 | goto mlkem_err; |
| 2466 | BIO_printf(bio_err, mr ? "+R9:%ld:%d:%.2f\n" | 2479 | BIO_printf(bio_err, mr ? "+R9:%ld:%d:%.2f\n" |
| @@ -2474,14 +2487,14 @@ speed_main(int argc, char **argv) | |||
| 2474 | ss = NULL; | 2487 | ss = NULL; |
| 2475 | 2488 | ||
| 2476 | pkey_print_message("decap", "mlkem", bits, MLKEM_SECONDS); | 2489 | pkey_print_message("decap", "mlkem", bits, MLKEM_SECONDS); |
| 2477 | time_f(START); | 2490 | speed_timer_start(MLKEM_SECONDS); |
| 2478 | for (count = 0, run = 1; COND; count++) { | 2491 | for (count = 0; COND; count++) { |
| 2479 | if (!MLKEM_decap(priv, ct, ct_len, &ss, &ss_len)) | 2492 | if (!MLKEM_decap(priv, ct, ct_len, &ss, &ss_len)) |
| 2480 | break; | 2493 | break; |
| 2481 | free(ss); | 2494 | free(ss); |
| 2482 | ss = NULL; | 2495 | ss = NULL; |
| 2483 | } | 2496 | } |
| 2484 | d = time_f(STOP); | 2497 | d = speed_timer_stop(MLKEM_SECONDS); |
| 2485 | if (run) | 2498 | if (run) |
| 2486 | goto mlkem_err; | 2499 | goto mlkem_err; |
| 2487 | BIO_printf(bio_err, mr ? "+R10:%ld:%d:%.2f\n" | 2500 | BIO_printf(bio_err, mr ? "+R10:%ld:%d:%.2f\n" |
| @@ -2679,7 +2692,6 @@ print_message(const char *s, int length) | |||
| 2679 | BIO_printf(bio_err, mr ? "+DT:%s:%d:%d\n" | 2692 | BIO_printf(bio_err, mr ? "+DT:%s:%d:%d\n" |
| 2680 | : "Doing %s for %ds on %d size blocks: ", s, SECONDS, length); | 2693 | : "Doing %s for %ds on %d size blocks: ", s, SECONDS, length); |
| 2681 | (void) BIO_flush(bio_err); | 2694 | (void) BIO_flush(bio_err); |
| 2682 | alarm(SECONDS); | ||
| 2683 | } | 2695 | } |
| 2684 | 2696 | ||
| 2685 | static void | 2697 | static void |
| @@ -2689,7 +2701,6 @@ pkey_print_message(const char *str, const char *str2, | |||
| 2689 | BIO_printf(bio_err, mr ? "+DTP:%d:%s:%s:%d\n" | 2701 | BIO_printf(bio_err, mr ? "+DTP:%d:%s:%s:%d\n" |
| 2690 | : "Doing %d bit %s %s for %ds: ", bits, str, str2, tm); | 2702 | : "Doing %d bit %s %s for %ds: ", bits, str, str2, tm); |
| 2691 | (void) BIO_flush(bio_err); | 2703 | (void) BIO_flush(bio_err); |
| 2692 | alarm(tm); | ||
| 2693 | } | 2704 | } |
| 2694 | 2705 | ||
| 2695 | static void | 2706 | static void |
