~ubuntu-branches/ubuntu/feisty/firefox/feisty-updates

« back to all changes in this revision

Viewing changes to security/nss-fips/lib/freebl/mpi/doc/expt.txt

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack, Alexander Sack
  • Date: 2008-06-23 15:08:12 UTC
  • mfrom: (1.1.24 upstream)
  • Revision ID: james.westby@ubuntu.com-20080623150812-sxdwhn3dz9pmapvf
Tags: 2.0.0.15+0nobinonly-0ubuntu0.7.4
[ Alexander Sack ]
* New security/stability upstream release (v2.0.0.15)
  - see USN-619-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Exponentiation
 
2
 
 
3
For exponentiation, the MPI library uses a simple and fairly standard
 
4
square-and-multiply method.  The algorithm is this:
 
5
 
 
6
Input:  a, b
 
7
Output: a ** b
 
8
 
 
9
        s = 1
 
10
 
 
11
        while(b != 0)
 
12
          if(b is odd)
 
13
            s = s * a
 
14
          endif
 
15
 
 
16
          b = b / 2
 
17
 
 
18
          x = x * x
 
19
        endwhile
 
20
 
 
21
        return s
 
22
 
 
23
The modular exponentiation is done the same way, except replacing:
 
24
 
 
25
        s = s * a
 
26
 
 
27
with
 
28
        s = (s * a) mod m
 
29
 
 
30
and replacing
 
31
 
 
32
        x = x * x
 
33
 
 
34
with
 
35
 
 
36
        x = (x * x) mod m
 
37
 
 
38
Here is a sample exponentiation using the MPI library, as compared to
 
39
the same problem solved by the Unix 'bc' program on my system:
 
40
 
 
41
Computation of 2,381,283 ** 235
 
42
 
 
43
'bc' says:
 
44
 
 
45
4385CA4A804D199FBEAD95FAD0796FAD0D0B51FC9C16743C45568C789666985DB719\
 
46
4D90E393522F74C9601262C0514145A49F3B53D00983F95FDFCEA3D0043ECEF6227E\
 
47
6FB59C924C3EE74447B359B5BF12A555D46CB819809EF423F004B55C587D6F0E8A55\
 
48
4988036A42ACEF9F71459F97CEF6E574BD7373657111648626B1FF8EE15F663B2C0E\
 
49
6BBE5082D4CDE8E14F263635AE8F35DB2C280819517BE388B5573B84C5A19C871685\
 
50
FD408A6471F9D6AFAF5129A7548EAE926B40874B340285F44765BF5468CE20A13267\
 
51
CD88CE6BC786ACED36EC7EA50F67FF27622575319068A332C3C0CB23E26FB55E26F4\
 
52
5F732753A52B8E2FB4D4F42D894242613CA912A25486C3DEC9C66E5DB6182F6C1761\
 
53
CF8CD0D255BE64B93836B27D452AE38F950EB98B517D4CF50D48F0165EF0CCCE1F5C\
 
54
49BF18219FDBA0EEDD1A7E8B187B70C2BAED5EC5C6821EF27FAFB1CFF70111C52235\
 
55
5E948B93A015AA1AE152B110BB5658CB14D3E45A48BFE7F082C1182672A455A695CD\
 
56
A1855E8781E625F25B41B516E77F589FA420C3B058861EA138CF7A2C58DB3C7504FD\
 
57
D29554D78237834CC5AE710D403CC4F6973D5012B7E117A8976B14A0B5AFA889BD47\
 
58
92C461F0F96116F00A97AE9E83DC5203680CAF9A18A062566C145650AB86BE4F907F\
 
59
A9F7AB4A700B29E1E5BACCD6DCBFA513E10832815F710807EED2E279081FEC61D619\
 
60
AB270BEB3D3A1787B35A9DD41A8766CF21F3B5C693B3BAB1C2FA14A4ED202BC35743\
 
61
E5CBE2391624D4F8C9BFBBC78D69764E7C6C5B11BF005677BFAD17D9278FFC1F158F\
 
62
1B3683FF7960FA0608103792C4163DC0AF3E06287BB8624F8FE3A0FFBDF82ACECA2F\
 
63
CFFF2E1AC93F3CA264A1B
 
64
 
 
65
MPI says:
 
66
 
 
67
4385CA4A804D199FBEAD95FAD0796FAD0D0B51FC9C16743C45568C789666985DB719\
 
68
4D90E393522F74C9601262C0514145A49F3B53D00983F95FDFCEA3D0043ECEF6227E\
 
69
6FB59C924C3EE74447B359B5BF12A555D46CB819809EF423F004B55C587D6F0E8A55\
 
70
4988036A42ACEF9F71459F97CEF6E574BD7373657111648626B1FF8EE15F663B2C0E\
 
71
6BBE5082D4CDE8E14F263635AE8F35DB2C280819517BE388B5573B84C5A19C871685\
 
72
FD408A6471F9D6AFAF5129A7548EAE926B40874B340285F44765BF5468CE20A13267\
 
73
CD88CE6BC786ACED36EC7EA50F67FF27622575319068A332C3C0CB23E26FB55E26F4\
 
74
5F732753A52B8E2FB4D4F42D894242613CA912A25486C3DEC9C66E5DB6182F6C1761\
 
75
CF8CD0D255BE64B93836B27D452AE38F950EB98B517D4CF50D48F0165EF0CCCE1F5C\
 
76
49BF18219FDBA0EEDD1A7E8B187B70C2BAED5EC5C6821EF27FAFB1CFF70111C52235\
 
77
5E948B93A015AA1AE152B110BB5658CB14D3E45A48BFE7F082C1182672A455A695CD\
 
78
A1855E8781E625F25B41B516E77F589FA420C3B058861EA138CF7A2C58DB3C7504FD\
 
79
D29554D78237834CC5AE710D403CC4F6973D5012B7E117A8976B14A0B5AFA889BD47\
 
80
92C461F0F96116F00A97AE9E83DC5203680CAF9A18A062566C145650AB86BE4F907F\
 
81
A9F7AB4A700B29E1E5BACCD6DCBFA513E10832815F710807EED2E279081FEC61D619\
 
82
AB270BEB3D3A1787B35A9DD41A8766CF21F3B5C693B3BAB1C2FA14A4ED202BC35743\
 
83
E5CBE2391624D4F8C9BFBBC78D69764E7C6C5B11BF005677BFAD17D9278FFC1F158F\
 
84
1B3683FF7960FA0608103792C4163DC0AF3E06287BB8624F8FE3A0FFBDF82ACECA2F\
 
85
CFFF2E1AC93F3CA264A1B
 
86
 
 
87
Diff says:
 
88
% diff bc.txt mp.txt
 
89
%
 
90
 
 
91
------------------------------------------------------------------
 
92
***** BEGIN LICENSE BLOCK *****
 
93
Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
94
 
 
95
The contents of this file are subject to the Mozilla Public License Version 
 
96
1.1 (the "License"); you may not use this file except in compliance with 
 
97
the License. You may obtain a copy of the License at 
 
98
http://www.mozilla.org/MPL/
 
99
 
 
100
Software distributed under the License is distributed on an "AS IS" basis,
 
101
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
102
for the specific language governing rights and limitations under the
 
103
License.
 
104
 
 
105
The Original Code is the MPI Arbitrary Precision Integer Arithmetic
 
106
library.
 
107
 
 
108
The Initial Developer of the Original Code is
 
109
Michael J. Fromberger <sting@linguist.dartmouth.edu>
 
110
Portions created by the Initial Developer are Copyright (C) 1998, 2000
 
111
the Initial Developer. All Rights Reserved.
 
112
 
 
113
Contributor(s):
 
114
 
 
115
Alternatively, the contents of this file may be used under the terms of
 
116
either the GNU General Public License Version 2 or later (the "GPL"), or
 
117
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
118
in which case the provisions of the GPL or the LGPL are applicable instead
 
119
of those above. If you wish to allow use of your version of this file only
 
120
under the terms of either the GPL or the LGPL, and not to allow others to
 
121
use your version of this file under the terms of the MPL, indicate your
 
122
decision by deleting the provisions above and replace them with the notice
 
123
and other provisions required by the GPL or the LGPL. If you do not delete
 
124
the provisions above, a recipient may use your version of this file under
 
125
the terms of any one of the MPL, the GPL or the LGPL.
 
126
 
 
127
***** END LICENSE BLOCK *****
 
128
 
 
129
$Id: expt.txt,v 1.2 2005/02/02 22:28:22 gerv%gerv.net Exp $
 
130
 
 
131
 
 
132