Python cryptography.__version__() Examples
The following are 9
code examples of cryptography.__version__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cryptography
, or try the search function
.
Example #1
Source File: conftest.py From service-identity with MIT License | 6 votes |
def pytest_report_header(config): if OpenSSL is not None: openssl_version = OpenSSL.SSL.SSLeay_version( OpenSSL.SSL.SSLEAY_VERSION ).decode("ascii") pyopenssl_version = OpenSSL.__version__ else: openssl_version = "n/a" pyopenssl_version = "missing" return """\ OpenSSL: {openssl} pyOpenSSL: {pyOpenSSL} cryptography: {cryptography}""".format( openssl=openssl_version, pyOpenSSL=pyopenssl_version, cryptography=cryptography.__version__, )
Example #2
Source File: __init__.py From py-ipv8 with GNU Lesser General Public License v3.0 | 6 votes |
def _should_use_new_crypto_version(): """ Checks if this python-cryptography supports the new signing and verifying methods. As of version 1.5.x cryptography has the `sign` and `verify` methods. As of version 2.x, the `signer` and `verifier` methods have been deprecated. :return: whether we should use the new signing/verifying methods :rtype: bool """ import cryptography from distutils.version import LooseVersion try: cryptography_version = LooseVersion(cryptography.__version__) return cryptography_version >= LooseVersion('1.5') except (AttributeError, UnicodeEncodeError): # Empty strings raise AttributeError # Illegal unicode characters raise UnicodeEncodeError return False
Example #3
Source File: versions.py From learn_python3_spider with MIT License | 5 votes |
def scrapy_components_versions(): lxml_version = ".".join(map(str, lxml.etree.LXML_VERSION)) libxml2_version = ".".join(map(str, lxml.etree.LIBXML_VERSION)) try: w3lib_version = w3lib.__version__ except AttributeError: w3lib_version = "<1.14.3" try: import cryptography cryptography_version = cryptography.__version__ except ImportError: cryptography_version = "unknown" return [ ("Scrapy", scrapy.__version__), ("lxml", lxml_version), ("libxml2", libxml2_version), ("cssselect", cssselect.__version__), ("parsel", parsel.__version__), ("w3lib", w3lib_version), ("Twisted", twisted.version.short()), ("Python", sys.version.replace("\n", "- ")), ("pyOpenSSL", _get_openssl_version()), ("cryptography", cryptography_version), ("Platform", platform.platform()), ]
Example #4
Source File: versions.py From learn_python3_spider with MIT License | 5 votes |
def _get_openssl_version(): try: import OpenSSL openssl = OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION)\ .decode('ascii', errors='replace') # pyOpenSSL 0.12 does not expose openssl version except AttributeError: openssl = 'Unknown OpenSSL version' return '{} ({})'.format(OpenSSL.version.__version__, openssl)
Example #5
Source File: versions.py From learn_python3_spider with MIT License | 5 votes |
def scrapy_components_versions(): lxml_version = ".".join(map(str, lxml.etree.LXML_VERSION)) libxml2_version = ".".join(map(str, lxml.etree.LIBXML_VERSION)) try: w3lib_version = w3lib.__version__ except AttributeError: w3lib_version = "<1.14.3" try: import cryptography cryptography_version = cryptography.__version__ except ImportError: cryptography_version = "unknown" return [ ("Scrapy", scrapy.__version__), ("lxml", lxml_version), ("libxml2", libxml2_version), ("cssselect", cssselect.__version__), ("parsel", parsel.__version__), ("w3lib", w3lib_version), ("Twisted", twisted.version.short()), ("Python", sys.version.replace("\n", "- ")), ("pyOpenSSL", _get_openssl_version()), ("cryptography", cryptography_version), ("Platform", platform.platform()), ]
Example #6
Source File: versions.py From learn_python3_spider with MIT License | 5 votes |
def _get_openssl_version(): try: import OpenSSL openssl = OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION)\ .decode('ascii', errors='replace') # pyOpenSSL 0.12 does not expose openssl version except AttributeError: openssl = 'Unknown OpenSSL version' return '{} ({})'.format(OpenSSL.version.__version__, openssl)
Example #7
Source File: Mastodon.py From Mastodon.py with MIT License | 5 votes |
def push_subscription_generate_keys(self): """ Generates a private key, public key and shared secret for use in webpush subscriptions. Returns two dicts: One with the private key and shared secret and another with the public key and shared secret. """ if not IMPL_HAS_CRYPTO: raise NotImplementedError('To use the crypto tools, please install the webpush feature dependencies.') push_key_pair = ec.generate_private_key(ec.SECP256R1(), default_backend()) push_key_priv = push_key_pair.private_numbers().private_value crypto_ver = cryptography.__version__ if len(crypto_ver) < 5: crypto_ver += ".0" if bigger_version(crypto_ver, "2.5.0") == crypto_ver: push_key_pub = push_key_pair.public_key().public_bytes(serialization.Encoding.X962, serialization.PublicFormat.UncompressedPoint) else: push_key_pub = push_key_pair.public_key().public_numbers().encode_point() push_shared_secret = os.urandom(16) priv_dict = { 'privkey': push_key_priv, 'auth': push_shared_secret } pub_dict = { 'pubkey': push_key_pub, 'auth': push_shared_secret } return priv_dict, pub_dict
Example #8
Source File: conftest.py From pyopenssl with Apache License 2.0 | 5 votes |
def pytest_report_header(config): import OpenSSL.SSL import cryptography return "OpenSSL: {openssl}\ncryptography: {cryptography}".format( openssl=OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION), cryptography=cryptography.__version__ )
Example #9
Source File: iasimage.py From iasimage with BSD 3-Clause "New" or "Revised" License | 4 votes |
def main(): arg_parser = argparse.ArgumentParser() arg_subparser = arg_parser.add_subparsers(help='command') cmd_createp = arg_subparser.add_parser('create', help='create ias-image', formatter_class=argparse.RawTextHelpFormatter) cmd_createp.add_argument('-o', '--output', help='output filename') cmd_createp.add_argument('-d', '--devkey', help='private key for internal signing - used during development phase (RSA signature and public key will be appended to image)') cmd_createp.add_argument('-i', '--imagetype', help='\ image type: 32bit-value decimal [197376] or hexadecimal [0x30300]\n\ [BIT 31-16: Image type]\n\ [BIT 15-10: Reserved]\n\ [BIT 9: Public Key present]\n\ [BIT 8: RSA signature present]\n\ [BIT 7-0: Compression algorithm]\n\ Image type - BIT field:\n\ [3 : Multi-file boot image]\n\ [4 : ELF Multiboot compliant boot image]\n\ [5 : SPI update package]\n\ [6 : ABL configuration image]\n\ [7 : MRC training parameter]\n\ [8 : IFWI update package]\n\ [9 : PDR update package]\n\ [10: Firmware package]\n\ [11: Pre-OS checker image]') cmd_createp.add_argument('-p', '--page-aligned', default=None, const='0', nargs='?', help='file number before which image should be page aligned') cmd_createp.add_argument('-v', '--verbose', action='count') cmd_createp.add_argument('file', nargs='+') cmd_createp.set_defaults(output='iasImage') cmd_createp.set_defaults(verbose=0) cmd_createp.set_defaults(func=cmd_create) cmd_signp = arg_subparser.add_parser('sign', help='sign ias-image') cmd_signp.add_argument('-o', '--output', help='output filename') cmd_signp.add_argument('-k', '--key', help='public key') cmd_signp.add_argument('-s', '--signature', required=True, help='RSA signature') cmd_signp.add_argument('file') cmd_signp.set_defaults(output='iasImage') cmd_signp.set_defaults(func=cmd_sign) cmd_extractp = arg_subparser.add_parser('extract', help='extract ias-image components') cmd_extractp.add_argument('file') cmd_extractp.set_defaults(func=cmd_extract) arg_parser.add_argument('-V', '--version', action='version', version='%(prog)s ' + __version__) args = arg_parser.parse_args() if not 'func' in args: arg_parser.print_usage() sys.exit(2) sys.exit(args.func(args))