]>
git.saurik.com Git - apple/security.git/blob - AppleCSP/open_ssl/bn/exp.c
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
22 #include <openssl/tmdiff.h>
27 #define MOD (8*8*8*8*8)
34 BIGNUM a
,b
,c
,r
,rr
,t
,l
;
35 int j
,i
,size
=SIZE
,num
=NUM
,mod
=MOD
;
40 BN_MONT_CTX_init(&mont
);
49 while (size
<= 1024*8)
55 BN_mod(&a
,&a
,&c
,&ctx
);
59 BN_MONT_CTX_set(&mont
,&c
,&ctx
);
61 md
=ms_time_diff(start
,end
);
66 /* bn_mull(&r,&a,&b,&ctx); */
67 /* BN_sqr(&r,&a,&ctx); */
68 BN_mod_exp_mont(&r
,&a
,&b
,&c
,&ctx
,&mont
);
71 d
=ms_time_diff(start
,end
)/* *50/33 */;
72 printf("%5d bit:%6.2f %6d %6.4f %4d m_set(%5.4f)\n",size
,
73 d
,num
,d
/num
,(int)((d
/num
)*mod
),md
/10.0);