summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormcgreer%netscape.com <devnull@localhost>2000-05-23 20:01:31 +0000
committermcgreer%netscape.com <devnull@localhost>2000-05-23 20:01:31 +0000
commita7b4c7baeab1484eb16c3e570922cffc38fccbfb (patch)
treea41d6a39e4b9810b70503fc7dacceeaa717badd9
parentc87b7f9cf23d36dcd77d22475e54a20ecb7f8590 (diff)
downloadnss-hg-a7b4c7baeab1484eb16c3e570922cffc38fccbfb.tar.gz
break a long rsa message into key-sized blocks for testing.
-rw-r--r--security/nss/cmd/bltest/blapitest.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/security/nss/cmd/bltest/blapitest.c b/security/nss/cmd/bltest/blapitest.c
index a9b51db2a..6e9342855 100644
--- a/security/nss/cmd/bltest/blapitest.c
+++ b/security/nss/cmd/bltest/blapitest.c
@@ -387,6 +387,14 @@ typedef struct
((float)(time1))/info->repetitions); \
}
+SECStatus
+fillitem(SECItem *item, int numbytes, char *filename)
+{
+ if (item->len == 0)
+ return get_and_write_random_bytes(item, numbytes, filename);
+ return SECSuccess;
+}
+
/************************
** DES
************************/
@@ -426,14 +434,6 @@ des_common(DESContext *descx, blapitestInfo *info)
return rv;
}
-SECStatus
-fillitem(SECItem *item, int numbytes, char *filename)
-{
- if (item->len == 0)
- return get_and_write_random_bytes(item, numbytes, filename);
- return SECSuccess;
-}
-
/* DES codebook mode */
static SECStatus
des_ecb_test(blapitestInfo *info)
@@ -475,13 +475,16 @@ des_cbc_test(blapitestInfo *info)
* So, once the performance test is done, reset the context
* and perform a single iteration to obtain the correct result.
*/
+ int tmp = info->repetitions;
rv = des_common(descx, info);
DES_DestroyContext(descx, PR_TRUE);
descx = DES_CreateContext(info->key.data, info->iv.data, NSS_DES_CBC,
info->encrypt);
info->performance = PR_FALSE;
+ info->repetitions = 1;
rv = des_common(descx, info);
info->performance = PR_TRUE;
+ info->repetitions = tmp;
} else {
rv = des_common(descx, info);
}
@@ -531,13 +534,16 @@ des_ede_cbc_test(blapitestInfo *info)
* So, once the performance test is done, reset the context
* and perform a single iteration to obtain the correct result.
*/
+ int tmp = info->repetitions;
rv = des_common(descx, info);
DES_DestroyContext(descx, PR_TRUE);
descx = DES_CreateContext(info->key.data, info->iv.data,
NSS_DES_EDE3_CBC, info->encrypt);
info->performance = PR_FALSE;
+ info->repetitions = 1;
rv = des_common(descx, info);
info->performance = PR_TRUE;
+ info->repetitions = tmp;
} else {
rv = des_common(descx, info);
}
@@ -826,9 +832,10 @@ rsa_test(blapitestInfo *info)
SECItem expitem;
SECStatus rv;
PRIntervalTime time1, time2;
- int i, numiter;
+ int i, j, numiter;
numiter = info->repetitions;
fillitem(&info->in, info->bufsize, "tmp.pt");
+ info->in.data[0] = 0x00;
if (info->key.len > 0) {
key = rsakey_from_filedata(&info->key);
} else {
@@ -849,14 +856,22 @@ rsa_test(blapitestInfo *info)
SECITEM_CopyItem(key->arena, &pubkey.publicExponent,
&key->publicExponent);
TIMESTART();
- for (i=0; i<numiter; i++)
- rv = RSA_PublicKeyOp(&pubkey, info->out.data, info->in.data);
+ for (i=0; i<numiter; i++) {
+ for (j=0; j<info->in.len; j+=pubkey.modulus.len) {
+ rv = RSA_PublicKeyOp(&pubkey, &info->out.data[j],
+ &info->in.data[j]);
+ }
+ }
TIMEFINISH("RSA ENCRYPT", info->in.len);
CHECKERROR(rv, __LINE__);
} else {
TIMESTART();
- for (i=info->repetitions; i>0; i--)
- rv = RSA_PrivateKeyOp(key, info->out.data, info->in.data);
+ for (i=info->repetitions; i>0; i--) {
+ for (j=0; j<info->in.len; j+=key->modulus.len) {
+ rv = RSA_PrivateKeyOp(key, &info->out.data[j],
+ &info->in.data[j]);
+ }
+ }
TIMEFINISH("RSA DECRYPT", info->in.len);
CHECKERROR(rv, __LINE__);
}