VirtualBox

Changeset 52297 in vbox for trunk/src/VBox/Runtime/testcase


Ignore:
Timestamp:
Aug 6, 2014 2:43:28 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95409
Message:

tstRTBigNum: compare with openssl. (Conclusion, we're very slow at modexp.)

Location:
trunk/src/VBox/Runtime/testcase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/Makefile.kmk

    r52018 r52297  
    227227tstRTBigNum_TEMPLATE = VBOXR3TSTEXE
    228228tstRTBigNum_SOURCES = tstRTBigNum.cpp
     229tstRTBigNum_SDKS = VBOX_OPENSSL
    229230
    230231tstRTBitOperations_TEMPLATE = VBOXR3TSTEXE
  • trunk/src/VBox/Runtime/testcase/tstRTBigNum.cpp

    r52289 r52297  
    3434#include <iprt/time.h>
    3535#include <iprt/string.h>
     36
     37#if 1
     38# include <openssl/bn.h>
     39#endif
    3640
    3741
     
    865869    RTTESTI_CHECK_RC(rc, VINF_SUCCESS);
    866870    RTTestIValue("RTBigNumModExp", uElapsed / cRounds, RTTESTUNIT_NS_PER_CALL);
     871
     872#if 1
     873    /* Compare with OpenSSL BN. */
     874    BN_CTX *pObnCtx = BN_CTX_new();
     875    BIGNUM *pObnPubKeyExp = BN_bin2bn(s_abPubKeyExp, sizeof(s_abPubKeyExp), NULL);
     876    BIGNUM *pObnPubKeyMod = BN_bin2bn(s_abPubKeyMod, sizeof(s_abPubKeyMod), NULL);
     877    BIGNUM *pObnSignature = BN_bin2bn(s_abSignature, sizeof(s_abSignature), NULL);
     878    BIGNUM *pObnResult = BN_new();
     879    RTTESTI_CHECK_RETV(BN_mod_exp(pObnResult, pObnSignature, pObnPubKeyExp, pObnPubKeyMod, pObnCtx) == 1);
     880    BN_CTX_free(pObnCtx);
     881
     882    rc = 1;
     883    cRounds  = 0;
     884    uStartTS = RTTimeNanoTS();
     885    while (cRounds < 4096)
     886    {
     887        pObnCtx = BN_CTX_new();
     888        rc &= BN_mod_exp(pObnResult, pObnSignature, pObnPubKeyExp, pObnPubKeyMod, pObnCtx);
     889        BN_CTX_free(pObnCtx);
     890        cRounds++;
     891    }
     892    uElapsed = RTTimeNanoTS() - uStartTS;
     893    RTTESTI_CHECK_RC(rc, 1);
     894    RTTestIValue("BN_mod_exp", uElapsed / cRounds, RTTESTUNIT_NS_PER_CALL);
     895
     896    rc = 1;
     897    cRounds  = 0;
     898    uStartTS = RTTimeNanoTS();
     899    while (cRounds < 4096)
     900    {
     901        pObnCtx = BN_CTX_new();
     902        rc &= BN_mod_exp_simple(pObnResult, pObnSignature, pObnPubKeyExp, pObnPubKeyMod, pObnCtx);
     903        BN_CTX_free(pObnCtx);
     904        cRounds++;
     905    }
     906    uElapsed = RTTimeNanoTS() - uStartTS;
     907    RTTESTI_CHECK_RC(rc, 1);
     908    RTTestIValue("BN_mod_exp_simple", uElapsed / cRounds, RTTESTUNIT_NS_PER_CALL);
     909#endif
    867910}
    868911
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette