Repository URL to install this package:
|
Version:
3.3.35 ▾
|
ó
ՍEYc @` s d Z d d l m Z m Z m Z m Z d d l Z d d l Z d d l m Z m
Z
y d d l m Z m
Z
m Z m Z m Z e j d k r e n y d d l m Z d Z Wn e e f k
rÞ e n XWn e e f k
rd
Z n Xd Z d S( uN
Function for calculating the modular inverse. Exports the following items:
- inverse_mod()
Source code is derived from
http://webpages.charter.net/curryfans/peter/downloads.html, but has been heavily
modified to fit into this projects lint settings. The original project license
is listed below:
Copyright (c) 2014 Peter Pearson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
i ( t unicode_literalst divisiont absolute_importt print_functionNi ( t int_to_bytest int_from_bytes( t buffer_from_bytest bytes_from_buffert FFIEngineErrort LibraryNotFoundErrort nullu PyPy( t libcryptoc C` st t j } t t | } t t | } t | } t j | t | t } | d k ry t j | d n t | } t j | t | t } | d k r t j | d n t j t | | | } t j
| }
t t j
|
d } t | } t j | | t | | }
t |
} t j | t j | t j | t j | | S( u×
Compute the modular inverse of a (mod p)
:param a:
An integer
:param p:
An integer
:return:
An integer
i i i ( R t
BN_CTX_newR t absR t BN_bin2bnt lenR
t BN_set_negativet BN_mod_inverset BN_num_bitst intt matht ceilt BN_bn2binR R t BN_freet BN_CTX_free( t at pt ctxt a_bytest p_bytest a_buft a_bnt p_buft p_bnt r_bnt
r_len_bitst r_lent r_buft r_bytest result( ( sD /home/tvault/.virtenv/lib/python2.7/site-packages/asn1crypto/_int.pyt inverse_mod: s.
c C` sÒ | d k s | | k r% | | } n | | } } d \ } } } } x] | d k r£ t | | | f \ } } } | | | | | | | | f \ } } } } qG W| d k s¶ t | d k rÆ | S| | Sd S( u·
Compute the modular inverse of a (mod p)
:param a:
An integer
:param p:
An integer
:return:
An integer
i i N( i i i i ( t divmodt AssertionError( R R t ct dt uct vct udt vdt q( ( sD /home/tvault/.virtenv/lib/python2.7/site-packages/asn1crypto/_int.pyR( k s
2c C` s' x t | | k r" d | } q W| S( u
Ensure a byte string representing a positive integer is a specific width
(in bytes)
:param bytes_:
The integer byte string
:param width:
The desired width as an integer
:return:
A byte string of the width specified
t ( R ( t bytes_t width( ( sD /home/tvault/.virtenv/lib/python2.7/site-packages/asn1crypto/_int.pyt
fill_width s ( t __doc__t
__future__R R R R R t platformt utilR R t _ffiR R R R R
t python_implementationt EnvironmentErrort _perf._big_num_ctypesR R( t ImportErrorR5 ( ( ( sD /home/tvault/.virtenv/lib/python2.7/site-packages/asn1crypto/_int.pyt <module> s "(
+
#