Python cryptography.hazmat.primitives.asymmetric.ec.SECP192R1 Examples
The following are 4
code examples of cryptography.hazmat.primitives.asymmetric.ec.SECP192R1().
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.hazmat.primitives.asymmetric.ec
, or try the search function
.
Example #1
Source File: test_crypto_elliptic_curve.py From aws-encryption-sdk-python with Apache License 2.0 | 5 votes |
def test_ecc_decode_compressed_point_prime_unsupported(): with pytest.raises(NotSupportedError) as excinfo: _ecc_decode_compressed_point(curve=ec.SECP192R1(), compressed_point="\x02skdgaiuhgijudflkjsdgfkjsdflgjhsd") excinfo.match(r"Curve secp192r1 is not supported at this time")
Example #2
Source File: tests_utils.py From django-ca with GNU General Public License v3.0 | 5 votes |
def test_basic(self): self.assertIsInstance(parse_key_curve(), type(ca_settings.CA_DEFAULT_ECC_CURVE)) self.assertIsInstance(parse_key_curve('SECT409R1'), ec.SECT409R1) self.assertIsInstance(parse_key_curve('SECP521R1'), ec.SECP521R1) self.assertIsInstance(parse_key_curve('SECP192R1'), ec.SECP192R1)
Example #3
Source File: utils.py From lemur with Apache License 2.0 | 4 votes |
def generate_private_key(key_type): """ Generates a new private key based on key_type. Valid key types: RSA2048, RSA4096', 'ECCPRIME192V1', 'ECCPRIME256V1', 'ECCSECP192R1', 'ECCSECP224R1', 'ECCSECP256R1', 'ECCSECP384R1', 'ECCSECP521R1', 'ECCSECP256K1', 'ECCSECT163K1', 'ECCSECT233K1', 'ECCSECT283K1', 'ECCSECT409K1', 'ECCSECT571K1', 'ECCSECT163R2', 'ECCSECT233R1', 'ECCSECT283R1', 'ECCSECT409R1', 'ECCSECT571R2' :param key_type: :return: """ _CURVE_TYPES = { "ECCPRIME192V1": ec.SECP192R1(), "ECCPRIME256V1": ec.SECP256R1(), "ECCSECP192R1": ec.SECP192R1(), "ECCSECP224R1": ec.SECP224R1(), "ECCSECP256R1": ec.SECP256R1(), "ECCSECP384R1": ec.SECP384R1(), "ECCSECP521R1": ec.SECP521R1(), "ECCSECP256K1": ec.SECP256K1(), "ECCSECT163K1": ec.SECT163K1(), "ECCSECT233K1": ec.SECT233K1(), "ECCSECT283K1": ec.SECT283K1(), "ECCSECT409K1": ec.SECT409K1(), "ECCSECT571K1": ec.SECT571K1(), "ECCSECT163R2": ec.SECT163R2(), "ECCSECT233R1": ec.SECT233R1(), "ECCSECT283R1": ec.SECT283R1(), "ECCSECT409R1": ec.SECT409R1(), "ECCSECT571R2": ec.SECT571R1(), } if key_type not in CERTIFICATE_KEY_TYPES: raise Exception( "Invalid key type: {key_type}. Supported key types: {choices}".format( key_type=key_type, choices=",".join(CERTIFICATE_KEY_TYPES) ) ) if "RSA" in key_type: key_size = int(key_type[3:]) return rsa.generate_private_key( public_exponent=65537, key_size=key_size, backend=default_backend() ) elif "ECC" in key_type: return ec.generate_private_key( curve=_CURVE_TYPES[key_type], backend=default_backend() )
Example #4
Source File: test_lib_crypto_ecc.py From synapse with Apache License 2.0 | 4 votes |
def test_lib_crypto_ecc_exchange(self): spvk1 = s_ecc.PriKey.generate() spbk1 = spvk1.public() spvk2 = s_ecc.PriKey.generate() spbk2 = spvk2.public() k1 = (spvk1.exchange(spbk2)) k2 = (spvk2.exchange(spbk1)) self.eq(k1, k2) # Curves must be the same _pkd = c_ec.generate_private_key( c_ec.SECP192R1(), # We don't use this curve default_backend() ) prkdiff = s_ecc.PriKey(_pkd) pbkdiff = prkdiff.public() self.raises(s_exc.BadEccExchange, spvk1.exchange, pbkdiff) self.raises(s_exc.BadEccExchange, prkdiff.exchange, spbk1) # Do a demonstrative ephemeral exchange epvk1 = s_ecc.PriKey.generate() epbk1 = epvk1.public() epvk2 = s_ecc.PriKey.generate() epbk2 = epvk2.public() # assume epbk2 is sent to the owner of pvk1 z1e = epvk1.exchange(epbk2) z1s = spvk1.exchange(spbk2) z1 = z1e + z1s # assume epbk1 is sent to the owner of pvk2 z2e = epvk2.exchange(epbk1) z2s = spvk2.exchange(spbk1) z2 = z2e + z2s self.eq(z1, z2) # run through kdf kdf1 = c_hkdf.HKDF(c_hashes.SHA256(), length=64, salt=None, info=b'test', backend=default_backend()) k1 = kdf1.derive(z1) k1tx, k1rx = k1[32:], k1[:32] kdf2 = c_hkdf.HKDF(c_hashes.SHA256(), length=64, salt=None, info=b'test', backend=default_backend()) k2 = kdf2.derive(z2) k2rx, k2tx = k2[32:], k2[:32] self.eq(k1tx, k2rx) self.eq(k1rx, k2tx) self.ne(k1tx, k2tx)