OLD | NEW |
(Empty) | |
| 1 # -*- coding: ascii -*- |
| 2 # |
| 3 # pct_warnings.py : PyCrypto warnings file |
| 4 # |
| 5 # Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net> |
| 6 # |
| 7 # =================================================================== |
| 8 # The contents of this file are dedicated to the public domain. To |
| 9 # the extent that dedication to the public domain is not available, |
| 10 # everyone is granted a worldwide, perpetual, royalty-free, |
| 11 # non-exclusive license to exercise all rights associated with the |
| 12 # contents of this file for any purpose whatsoever. |
| 13 # No rights are reserved. |
| 14 # |
| 15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 16 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 19 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 20 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 21 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 # SOFTWARE. |
| 23 # =================================================================== |
| 24 |
| 25 # |
| 26 # Base classes. All our warnings inherit from one of these in order to allow |
| 27 # the user to specifically filter them. |
| 28 # |
| 29 |
| 30 class CryptoWarning(Warning): |
| 31 """Base class for PyCrypto warnings""" |
| 32 |
| 33 class CryptoDeprecationWarning(DeprecationWarning, CryptoWarning): |
| 34 """Base PyCrypto DeprecationWarning class""" |
| 35 |
| 36 class CryptoRuntimeWarning(RuntimeWarning, CryptoWarning): |
| 37 """Base PyCrypto RuntimeWarning class""" |
| 38 |
| 39 # |
| 40 # Warnings that we might actually use |
| 41 # |
| 42 |
| 43 class RandomPool_DeprecationWarning(CryptoDeprecationWarning): |
| 44 """Issued when Crypto.Util.randpool.RandomPool is instantiated.""" |
| 45 |
| 46 class ClockRewindWarning(CryptoRuntimeWarning): |
| 47 """Warning for when the system clock moves backwards.""" |
| 48 |
| 49 class GetRandomNumber_DeprecationWarning(CryptoDeprecationWarning): |
| 50 """Issued when Crypto.Util.number.getRandomNumber is invoked.""" |
| 51 |
| 52 class PowmInsecureWarning(CryptoRuntimeWarning): |
| 53 """Warning for when _fastmath is built without mpz_powm_sec""" |
| 54 |
| 55 # By default, we want this warning to be shown every time we compensate for |
| 56 # clock rewinding. |
| 57 import warnings as _warnings |
| 58 _warnings.filterwarnings('always', category=ClockRewindWarning, append=1) |
| 59 |
| 60 # vim:set ts=4 sw=4 sts=4 expandtab: |
OLD | NEW |