1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
Ë
ž¬`iÜ-ãóx—dZddlmZddlmZddlmZdZdZdd„Z    d„Z
dd    l m Z ee dd
«Zdd „Zd „Zd „Zy)zHFunctions to create and test prime numbers.
 
:undocumented: __package__
é)ÚRandom)ÚInteger)Ú
iter_rangeéNcóž—t|t«s t|«}|dvrtS|j«rtStd«}t|dz
«}|€t j «j}t|«}d}|j«r|dz}|dz }|j«rŒt|«D]Ž}d}|||fvr5tjd|dz
|¬«}d|cxkr    |dz
ksJ‚J‚|||fvrŒ5t|||«}    |    ||fvrŒTtd|«D]%}
t|    d|«}    |    |k(rŒw|    |k(sŒtccStcStS)a:Perform a Miller-Rabin primality test on an integer.
 
    The test is specified in Section C.3.1 of `FIPS PUB 186-4`__.
 
    :Parameters:
      candidate : integer
        The number to test for primality.
      iterations : integer
        The maximum number of iterations to perform before
        declaring a candidate a probable prime.
      randfunc : callable
        An RNG function where bases are taken from.
 
    :Returns:
      ``Primality.COMPOSITE`` or ``Primality.PROBABLY_PRIME``.
 
    .. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
    ©rééérrr    )Ú min_inclusiveÚ max_inclusiveÚrandfunc) Ú
isinstancerÚPROBABLY_PRIMEÚis_evenÚ    COMPOSITErÚnewÚreadrÚ random_rangeÚpow) Ú    candidateÚ
iterationsrÚoneÚ    minus_oneÚmÚaÚiÚbaseÚzÚjs            õhH:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\Crypto/Math/Primality.pyÚmiller_rabin_testr"-s~€ô( i¤Ô )ܘIÓ&ˆ    àLÑ ÜÐà×ÑÔÜÐä
!‹*€Cܘ     A™ Ó&€IàÐÜ—:‘:“<×$Ñ$ˆô        Ó€AØ    €AØ
)‰)Œ+Ø    ˆa‰ˆØ    ˆQ‰ˆð )‰)+ô˜
Ó #òˆðˆØs˜IÐ&Ñ&Ü×'Ñ'°aØ"+¨a¡-Ø%ô'ˆDð˜Ô-     ¨A¡ Ò-Ð .Ñ-Ð .Ð-ð    s˜IÐ&Ò&ô a˜Ó #ˆØ iÐ Ñ  Ø ô˜A˜qÓ!ò    ˆAܐAq˜)Ó$ˆAؐIŠ~ÙØC‹xÜ Ô ð     ôÒ ð/ô4 Ðócó—t|t«s t|«}|dvrtS|j«s|j    «rt
Sd„}|«D]4}||| fvrŒ tj ||«}|dk(rt
cS|dk(sŒ4n|dz}|j«dz
}td«}td«}td«}td«}    t|dz
dd«D]}
|j|«||z}||z}|    j|«|    |z}    |    z}    |    j||«|    j«r|    |z }    |    dz}    |    |z}    |j|
«rx|j|«||    z }|j«r||z }|dz}||z}|j|    «|j||«|j«r||z }|dz}||z}Œô|j|«|j|    «Œ|dk(rtSt
S)a_Perform a Lucas primality test on an integer.
 
    The test is specified in Section C.3.3 of `FIPS PUB 186-4`__.
 
    :Parameters:
      candidate : integer
        The number to test for primality.
 
    :Returns:
      ``Primality.COMPOSITE`` or ``Primality.PROBABLY_PRIME``.
 
    .. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
    rc3ó@K—d}    |–—|dkDr|dz }n|dz}| }Œ­w)Nr rr    ©)Úvalues r!Ú    alternatezlucas_test.<locals>.alternates8èø€ØˆØØŠKؐqŠyؘ‘
‘à˜‘
ØFˆEð ùs‚réÿÿÿÿr) rrrrÚis_perfect_squarerÚ jacobi_symbolÚ size_in_bitsrÚsetÚmultiply_accumulateÚis_oddÚget_bit) rr(ÚDÚjsÚKÚrÚU_iÚV_iÚU_tempÚV_temprs            r!Ú
lucas_testr9ws€ô i¤Ô )ܘIÓ&ˆ    ðLÑ ÜÐØ×ÑÔ˜i×9Ñ9Ô;ÜÐòñ‹[òˆØ ˜˜Q˜B˜Ñ Ø Ü × "Ñ " 1 iÓ 0ˆØ Š7ÜÒ Ø ‹8Ù ðð    A‰ €Aà    ‰Ó˜1Ñ€Aô !‹*€CÜ
!‹*€CÜ Q‹Z€FÜ Q‹Z€Fä ˜˜A™˜r 2Ó &ó!ˆð    
‰
3ŒØ#‰ ˆØ)шà
‰
3ŒØ#‰ ˆØ!‰ ˆØ×"Ñ" 3¨Ô,Ø =‰=Œ?Ø iÑ ˆFؐ1‰ ˆØ)Ñˆà 9‰9QŒ<à G‰GFŒOØ 6‰MˆC؏z‰zŒ|ؐyÑ Ø A‰IˆCØ 9Ñ ˆCà G‰GFŒOØ × #Ñ # F¨AÔ .؏z‰zŒ|ؐyÑ Ø A‰IˆCØ 9Ñ ‰Cà G‰GFŒOØ G‰GFŽOðC!ðF ˆa‚xÜÐÜ Ðr#)Ú
sieve_baseédcóþ‡—|€tj«j}t|t«s t    |«}t |«t vrtS    t|jt «d}|j«Š    ttˆfd„|««dd}t!|||¬«tk(rtSt#|«tk(rtStS#t$r    tcYSwxYw#t$rd}YŒ[wxYw)aðTest if a number is prime.
 
    A number is qualified as prime if it passes a certain
    number of Miller-Rabin tests (dependent on the size
    of the number, but such that probability of a false
    positive is less than 10^-30) and a single Lucas test.
 
    For instance, a 1024-bit candidate will need to pass
    4 Miller-Rabin tests.
 
    :Parameters:
      candidate : integer
        The number to test for primality.
      randfunc : callable
        The routine to draw random bytes from to select Miller-Rabin bases.
    :Returns:
      ``PROBABLE_PRIME`` if the number if prime with very high probability.
      ``COMPOSITE`` if the number is a composite.
      For efficiency reasons, ``COMPOSITE`` is also returned for small primes.
    )
)éÜé)ié)i†é)ié
)ilé)iäé)izr )i°é)i¤r
)itr    có•—‰|dkS)Nrr&)ÚxÚbit_sizes €r!ú<lambda>z%test_probable_prime.<locals>.<lambda> sø€¨h¸¸1¹©o€r#rr©r)rrrrrÚintÚ _sieve_baserÚmapÚfail_if_divisible_byÚ
ValueErrorrr,ÚlistÚfilterÚ
IndexErrorr"r9)rrÚ    mr_rangesÚ mr_iterationsrGs    @r!Útest_probable_primerTÞsø€ð,ÐÜ—:‘:“<×$Ñ$ˆä i¤Ô )ܘIÓ&ˆ    ô ˆ9ƒ~œÑ$ÜÐðÜ ˆI× *Ñ *¬KÔ8ð'€Ið×%Ñ%Ó'€HðÜœVÓ$=Ø$-ó/ó0Ø01ñ3Ø34ñ6ˆ ô
˜ MØ"*ô,Ü/8ò9äÐܐ)Ó¤    Ò)ÜÐÜ Ðøô- òÜÒðûô òØŠ ðús$ÁCÂC.ÃC+Ã*C+Ã. C<Ã;C<c óº—|jdd«}|jdd«}|jdd„«}|rtd|j«z«‚|€ td«‚|dkr td    «‚|€tj«j
}t }|t k(r9tj||¬
«d z}||«sŒ,t||«}|t k(rŒ9S) axGenerate a random probable prime.
 
    The prime will not have any specific properties
    (e.g. it will not be a *strong* prime).
 
    Random numbers are evaluated for primality until one
    passes all tests, consisting of a certain number of
    Miller-Rabin tests with random bases followed by
    a single Lucas test.
 
    The number of Miller-Rabin iterations is chosen such that
    the probability that the output number is a non-prime is
    less than 1E-30 (roughly 2^{-100}).
 
    This approach is compliant to `FIPS PUB 186-4`__.
 
    :Keywords:
      exact_bits : integer
        The desired size in bits of the probable prime.
        It must be at least 160.
      randfunc : callable
        An RNG function where candidate primes are taken from.
      prime_filter : callable
        A function that takes an Integer as parameter and returns
        True if the number can be passed to further primality tests,
        False if it should be immediately discarded.
 
    :Return:
        A probable prime in the range 2^exact_bits > p > 2^(exact_bits-1).
 
    .. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
    Ú
exact_bitsNrÚ prime_filtercó—y)NTr&)rFs r!rHz)generate_probable_prime.<locals>.<lambda><sr#úUnknown parameters: zMissing exact_bits parameteré zPrime number is not big enough.©rVrr)
ÚpoprNÚkeysrrrrrÚrandomrT)ÚkwargsrVrrWÚresultrs      r!Úgenerate_probable_primeras݀ðD—‘˜L¨$Ó/€J؏z‰z˜* dÓ+€HØ—:‘:˜n©nÓ=€LÙ ÜÐ/°&·+±+³-Ñ?Ó@Ð@àÐÜÐ7Ó8Ð8ؐCÒÜÐ:Ó;Ð;àÐÜ—:‘:“<×$Ñ$ˆä €FØ
”IÒ
Ü—N‘N¨jØ,4ô6Ø89ñ:ˆ    á˜IÔ&Ø Ü$ Y°Ó9ˆð ”IÓ
ð Ðr#c ón—|jdd«}|jdd«}|rtd|j«z«‚|€tj«j
}t }|t k(rCt|dz
|¬«}|dzdz}|j«|k7rŒ5t||¬«}|t k(rŒCS)    a›Generate a random, probable safe prime.
 
    Note this operation is much slower than generating a simple prime.
 
    :Keywords:
      exact_bits : integer
        The desired size in bits of the probable safe prime.
      randfunc : callable
        An RNG function where candidate primes are taken from.
 
    :Return:
        A probable safe prime in the range
        2^exact_bits > p > 2^(exact_bits-1).
    rVNrrYrr[r    rI)
r\rNr]rrrrrar,rT)r_rVrr`Úqrs      r!Úgenerate_probable_safe_primerdRs±€ð —‘˜L¨$Ó/€J؏z‰z˜* dÓ+€HÙ ÜÐ/°&·+±+³-Ñ?Ó@Ð@àÐÜ—:‘:“<×$Ñ$ˆä €FØ
”IÒ
Ü #¨z¸A©~ÈÔ QˆØ˜‘E˜A‘Iˆ    Ø × !Ñ !Ó # zÒ 1Ø Ü$ Y¸ÔBˆð ”IÓ
ð Ðr#)N)Ú__doc__ÚCryptorÚCrypto.Math.NumbersrÚCrypto.Util.py3compatrrrr"r9ÚCrypto.Util.numberr:Ú_sieve_base_larger-rKrTrardr&r#r!ú<module>rksWðñ>õ
Ý'å,à €    Ø€óGòT^õB?ñÐ# D SÐ)Ó*€ ó7òt7ótr#