code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def test_import_key(self):
"""Verify importKey is an alias to import_key"""
key_obj = DSA.import_key(self.der_public)
self.failIf(key_obj.has_private())
self.assertEqual(self.y, key_obj.y)
self.assertEqual(self.p, key_obj.p)
self.assertEqual(self.q, key_obj.q)
se... | Verify importKey is an alias to import_key | test_import_key | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_DSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_DSA.py | MIT |
def testImportKey1(self):
"""Verify import of RSAPrivateKey DER SEQUENCE"""
key = RSA.importKey(self.rsaKeyDER)
self.failUnless(key.has_private())
self.assertEqual(key.n, self.n)
self.assertEqual(key.e, self.e)
self.assertEqual(key.d, self.d)
self.assertEqual(key.... | Verify import of RSAPrivateKey DER SEQUENCE | testImportKey1 | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def testImportKey2(self):
"""Verify import of SubjectPublicKeyInfo DER SEQUENCE"""
key = RSA.importKey(self.rsaPublicKeyDER)
self.failIf(key.has_private())
self.assertEqual(key.n, self.n)
self.assertEqual(key.e, self.e) | Verify import of SubjectPublicKeyInfo DER SEQUENCE | testImportKey2 | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def testImportKey3unicode(self):
"""Verify import of RSAPrivateKey DER SEQUENCE, encoded with PEM as unicode"""
key = RSA.importKey(self.rsaKeyPEM)
self.assertEqual(key.has_private(),True) # assert_
self.assertEqual(key.n, self.n)
self.assertEqual(key.e, self.e)
self.asse... | Verify import of RSAPrivateKey DER SEQUENCE, encoded with PEM as unicode | testImportKey3unicode | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def testImportKey3bytes(self):
"""Verify import of RSAPrivateKey DER SEQUENCE, encoded with PEM as byte string"""
key = RSA.importKey(b(self.rsaKeyPEM))
self.assertEqual(key.has_private(),True) # assert_
self.assertEqual(key.n, self.n)
self.assertEqual(key.e, self.e)
self... | Verify import of RSAPrivateKey DER SEQUENCE, encoded with PEM as byte string | testImportKey3bytes | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def testImportKey4bytes(self):
"""Verify import of SubjectPublicKeyInfo DER SEQUENCE, encoded with PEM as byte string"""
key = RSA.importKey(b(self.rsaPublicKeyPEM))
self.assertEqual(key.has_private(),False) # failIf
self.assertEqual(key.n, self.n)
self.assertEqual(key.e, self.e) | Verify import of SubjectPublicKeyInfo DER SEQUENCE, encoded with PEM as byte string | testImportKey4bytes | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def testImportKey5(self):
"""Verifies that the imported key is still a valid RSA pair"""
key = RSA.importKey(self.rsaKeyPEM)
idem = key._encrypt(key._decrypt(89L))
self.assertEqual(idem, 89L) | Verifies that the imported key is still a valid RSA pair | testImportKey5 | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def testImportKey7(self):
"""Verify import of OpenSSH public key"""
key = RSA.importKey(self.rsaPublicKeyOpenSSH)
self.assertEqual(key.n, self.n)
self.assertEqual(key.e, self.e) | Verify import of OpenSSH public key | testImportKey7 | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def testImportKey8(self):
"""Verify import of encrypted PrivateKeyInfo DER SEQUENCE"""
for t in self.rsaKeyEncryptedPEM:
key = RSA.importKey(t[1], t[0])
self.failUnless(key.has_private())
self.assertEqual(key.n, self.n)
self.assertEqual(key.e, self.e)
... | Verify import of encrypted PrivateKeyInfo DER SEQUENCE | testImportKey8 | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def testImportKey9(self):
"""Verify import of unencrypted PrivateKeyInfo DER SEQUENCE"""
key = RSA.importKey(self.rsaKeyDER8)
self.failUnless(key.has_private())
self.assertEqual(key.n, self.n)
self.assertEqual(key.e, self.e)
self.assertEqual(key.d, self.d)
self.as... | Verify import of unencrypted PrivateKeyInfo DER SEQUENCE | testImportKey9 | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def testImportKey10(self):
"""Verify import of unencrypted PrivateKeyInfo DER SEQUENCE, encoded with PEM"""
key = RSA.importKey(self.rsaKeyPEM8)
self.failUnless(key.has_private())
self.assertEqual(key.n, self.n)
self.assertEqual(key.e, self.e)
self.assertEqual(key.d, self... | Verify import of unencrypted PrivateKeyInfo DER SEQUENCE, encoded with PEM | testImportKey10 | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def testImportKey11(self):
"""Verify import of RSAPublicKey DER SEQUENCE"""
der = asn1.DerSequence([17, 3]).encode()
key = RSA.importKey(der)
self.assertEqual(key.n, 17)
self.assertEqual(key.e, 3) | Verify import of RSAPublicKey DER SEQUENCE | testImportKey11 | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def testImportKey12(self):
"""Verify import of RSAPublicKey DER SEQUENCE, encoded with PEM"""
der = asn1.DerSequence([17, 3]).encode()
pem = der2pem(der)
key = RSA.importKey(pem)
self.assertEqual(key.n, 17)
self.assertEqual(key.e, 3) | Verify import of RSAPublicKey DER SEQUENCE, encoded with PEM | testImportKey12 | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def test_import_key(self):
"""Verify that import_key is an alias to importKey"""
key = RSA.import_key(self.rsaPublicKeyDER)
self.failIf(key.has_private())
self.assertEqual(key.n, self.n)
self.assertEqual(key.e, self.e) | Verify that import_key is an alias to importKey | test_import_key | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_import_RSA.py | MIT |
def test_generate_1arg(self):
"""RSA (default implementation) generated key (1 argument)"""
rsaObj = self.rsa.generate(1024)
self._check_private_key(rsaObj)
self._exercise_primitive(rsaObj)
pub = rsaObj.publickey()
self._check_public_key(pub)
self._exercise_public... | RSA (default implementation) generated key (1 argument) | test_generate_1arg | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_RSA.py | MIT |
def test_generate_2arg(self):
"""RSA (default implementation) generated key (2 arguments)"""
rsaObj = self.rsa.generate(1024, Random.new().read)
self._check_private_key(rsaObj)
self._exercise_primitive(rsaObj)
pub = rsaObj.publickey()
self._check_public_key(pub)
s... | RSA (default implementation) generated key (2 arguments) | test_generate_2arg | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_RSA.py | MIT |
def test_construct_5tuple(self):
"""RSA (default implementation) constructed key (5-tuple)"""
rsaObj = self.rsa.construct((self.n, self.e, self.d, self.p, self.q))
self._check_private_key(rsaObj)
self._check_encryption(rsaObj)
self._check_decryption(rsaObj) | RSA (default implementation) constructed key (5-tuple) | test_construct_5tuple | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_RSA.py | MIT |
def test_construct_6tuple(self):
"""RSA (default implementation) constructed key (6-tuple)"""
rsaObj = self.rsa.construct((self.n, self.e, self.d, self.p, self.q, self.u))
self._check_private_key(rsaObj)
self._check_encryption(rsaObj)
self._check_decryption(rsaObj) | RSA (default implementation) constructed key (6-tuple) | test_construct_6tuple | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_RSA.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/PublicKey/test_RSA.py | MIT |
def test_negative_unapproved_hashes(self):
"""Verify that unapproved hashes are rejected"""
from Cryptodome.Hash import RIPEMD160
self.description = "Unapproved hash (RIPEMD160) test"
hash_obj = RIPEMD160.new()
signer = DSS.new(self.key_priv, 'fips-186-3')
self.assertRa... | Verify that unapproved hashes are rejected | test_negative_unapproved_hashes | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/Signature/test_dss.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/Signature/test_dss.py | MIT |
def test_negative_unknown_modes_encodings(self):
"""Verify that unknown modes/encodings are rejected"""
self.description = "Unknown mode test"
self.assertRaises(ValueError, DSS.new, self.key_priv, 'fips-186-0')
self.description = "Unknown encoding test"
self.assertRaises(ValueE... | Verify that unknown modes/encodings are rejected | test_negative_unknown_modes_encodings | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/SelfTest/Signature/test_dss.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/SelfTest/Signature/test_dss.py | MIT |
def __init__(self, key, encoding, order):
"""Create a new Digital Signature Standard (DSS) object.
Do not instantiate this object directly,
use `Cryptodome.Signature.DSS.new` instead.
"""
self._key = key
self._encoding = encoding
self._order = order
sel... | Create a new Digital Signature Standard (DSS) object.
Do not instantiate this object directly,
use `Cryptodome.Signature.DSS.new` instead.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/DSS.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/DSS.py | MIT |
def sign(self, msg_hash):
"""Produce the DSS signature of a message.
:Parameters:
msg_hash : hash object
The hash that was carried out over the message.
The object belongs to the `Cryptodome.Hash` package.
Under mode *'fips-186-3'*, the hash must be a FIPS... | Produce the DSS signature of a message.
:Parameters:
msg_hash : hash object
The hash that was carried out over the message.
The object belongs to the `Cryptodome.Hash` package.
Under mode *'fips-186-3'*, the hash must be a FIPS
approved secure hash (SH... | sign | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/DSS.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/DSS.py | MIT |
def verify(self, msg_hash, signature):
"""Verify that a certain DSS signature is authentic.
This function checks if the party holding the private half of the key
really signed the message.
:Parameters:
msg_hash : hash object
The hash that was carried out over the ... | Verify that a certain DSS signature is authentic.
This function checks if the party holding the private half of the key
really signed the message.
:Parameters:
msg_hash : hash object
The hash that was carried out over the message.
This is an object belonging t... | verify | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/DSS.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/DSS.py | MIT |
def _valid_hash(self, msg_hash):
"""Verify that SHA-[23] (256|384|512) bits are used to
match the 128-bit security of P-256"""
approved = ("2.16.840.1.101.3.4.2.1",
"2.16.840.1.101.3.4.2.2",
"2.16.840.1.101.3.4.2.3",
"2.16.840.1.101.3.... | Verify that SHA-[23] (256|384|512) bits are used to
match the 128-bit security of P-256 | _valid_hash | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/DSS.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/DSS.py | MIT |
def new(key, mode, encoding='binary', randfunc=None):
"""Return a signature scheme object `DSS_SigScheme` that
can be used to perform DSS signature or verification.
:Parameters:
key : a `Cryptodome.PublicKey.DSA` or `Cryptodome.PublicKey.ECC` key object
If the key has got its private half, bo... | Return a signature scheme object `DSS_SigScheme` that
can be used to perform DSS signature or verification.
:Parameters:
key : a `Cryptodome.PublicKey.DSA` or `Cryptodome.PublicKey.ECC` key object
If the key has got its private half, both signature and
verification are possible.
... | new | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/DSS.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/DSS.py | MIT |
def sign(self, msg_hash):
"""Produce the PKCS#1 v1.5 signature of a message.
This function is named ``RSASSA-PKCS1-V1_5-SIGN``;
it is specified in section 8.2.1 of RFC3447.
:Parameters:
msg_hash : hash object
This is an object created with to the `Cryptodome.Hash`... | Produce the PKCS#1 v1.5 signature of a message.
This function is named ``RSASSA-PKCS1-V1_5-SIGN``;
it is specified in section 8.2.1 of RFC3447.
:Parameters:
msg_hash : hash object
This is an object created with to the `Cryptodome.Hash` module.
It was used used... | sign | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/pkcs1_15.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/pkcs1_15.py | MIT |
def verify(self, msg_hash, signature):
"""Verify that a certain PKCS#1 v1.5 signature is valid.
This method checks if the message really originates from someone
that holds the RSA private key.
really signed the message.
This function is named ``RSASSA-PKCS1-V1_5-VERIFY``;
... | Verify that a certain PKCS#1 v1.5 signature is valid.
This method checks if the message really originates from someone
that holds the RSA private key.
really signed the message.
This function is named ``RSASSA-PKCS1-V1_5-VERIFY``;
it is specified in section 8.2.2 of RFC3447.
... | verify | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/pkcs1_15.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/pkcs1_15.py | MIT |
def _EMSA_PKCS1_V1_5_ENCODE(msg_hash, emLen, with_hash_parameters=True):
"""
Implement the ``EMSA-PKCS1-V1_5-ENCODE`` function, as defined
in PKCS#1 v2.1 (RFC3447, 9.2).
``_EMSA-PKCS1-V1_5-ENCODE`` actually accepts the message ``M`` as input,
and hash it internally. Here, we expect that the message... |
Implement the ``EMSA-PKCS1-V1_5-ENCODE`` function, as defined
in PKCS#1 v2.1 (RFC3447, 9.2).
``_EMSA-PKCS1-V1_5-ENCODE`` actually accepts the message ``M`` as input,
and hash it internally. Here, we expect that the message has already
been hashed instead.
:Parameters:
msg_hash : hash obj... | _EMSA_PKCS1_V1_5_ENCODE | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/pkcs1_15.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/pkcs1_15.py | MIT |
def __init__(self, key, mgfunc, saltLen, randfunc):
"""Initialize this PKCS#1 PSS signature scheme object.
:Parameters:
key : an RSA key object
If a private half is given, both signature and
verification are possible.
If a public half is given, only verific... | Initialize this PKCS#1 PSS signature scheme object.
:Parameters:
key : an RSA key object
If a private half is given, both signature and
verification are possible.
If a public half is given, only verification is possible.
mgfunc : callable
A ma... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/pss.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/pss.py | MIT |
def sign(self, msg_hash):
"""Produce the PKCS#1 PSS signature of a message.
This function is named ``RSASSA-PSS-SIGN``, and is specified in
section 8.1.1 of RFC3447.
:Parameters:
msg_hash : hash object
The hash that was carried out over the message. This is an obj... | Produce the PKCS#1 PSS signature of a message.
This function is named ``RSASSA-PSS-SIGN``, and is specified in
section 8.1.1 of RFC3447.
:Parameters:
msg_hash : hash object
The hash that was carried out over the message. This is an object
belonging to the `Cry... | sign | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/pss.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/pss.py | MIT |
def verify(self, msg_hash, signature):
"""Verify that a certain PKCS#1 PSS signature is authentic.
This function checks if the party holding the private half
of the given RSA key has really signed the message.
This function is called ``RSASSA-PSS-VERIFY``, and is specified
in s... | Verify that a certain PKCS#1 PSS signature is authentic.
This function checks if the party holding the private half
of the given RSA key has really signed the message.
This function is called ``RSASSA-PSS-VERIFY``, and is specified
in section 8.1.2 of RFC3447.
:Parameters:
... | verify | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/pss.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/pss.py | MIT |
def _EMSA_PSS_ENCODE(mhash, emBits, randFunc, mgf, sLen):
"""
Implement the ``EMSA-PSS-ENCODE`` function, as defined
in PKCS#1 v2.1 (RFC3447, 9.1.1).
The original ``EMSA-PSS-ENCODE`` actually accepts the message ``M``
as input, and hash it internally. Here, we expect that the message
has alread... |
Implement the ``EMSA-PSS-ENCODE`` function, as defined
in PKCS#1 v2.1 (RFC3447, 9.1.1).
The original ``EMSA-PSS-ENCODE`` actually accepts the message ``M``
as input, and hash it internally. Here, we expect that the message
has already been hashed instead.
:Parameters:
mhash : hash objec... | _EMSA_PSS_ENCODE | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/pss.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/pss.py | MIT |
def _EMSA_PSS_VERIFY(mhash, em, emBits, mgf, sLen):
"""
Implement the ``EMSA-PSS-VERIFY`` function, as defined
in PKCS#1 v2.1 (RFC3447, 9.1.2).
``EMSA-PSS-VERIFY`` actually accepts the message ``M`` as input,
and hash it internally. Here, we expect that the message has already
been hashed inste... |
Implement the ``EMSA-PSS-VERIFY`` function, as defined
in PKCS#1 v2.1 (RFC3447, 9.1.2).
``EMSA-PSS-VERIFY`` actually accepts the message ``M`` as input,
and hash it internally. Here, we expect that the message has already
been hashed instead.
:Parameters:
mhash : hash object
The... | _EMSA_PSS_VERIFY | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/pss.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/pss.py | MIT |
def new(rsa_key, **kwargs):
"""Return a signature scheme object `PSS_SigScheme` that
can be used to perform PKCS#1 PSS signature or verification.
:Parameters:
rsa_key : RSA key object
The key to use to sign or verify the message.
This is a `Cryptodome.PublicKey.RSA` object.
Si... | Return a signature scheme object `PSS_SigScheme` that
can be used to perform PKCS#1 PSS signature or verification.
:Parameters:
rsa_key : RSA key object
The key to use to sign or verify the message.
This is a `Cryptodome.PublicKey.RSA` object.
Signing is only possible if *key* is ... | new | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Signature/pss.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Signature/pss.py | MIT |
def _convertTag(self, tag):
"""Check if *tag* is a real DER tag.
Convert it from a character to number if necessary.
"""
if not _is_number(tag):
if len(tag) == 1:
tag = bord(tag[0])
# Ensure that ... | Check if *tag* is a real DER tag.
Convert it from a character to number if necessary.
| _convertTag | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def _definite_form(length):
"""Build length octets according to BER/DER
definite form.
"""
if length > 127:
encoding = long_to_bytes(length)
return bchr(len(encoding) + 128) + encoding
return ... | Build length octets according to BER/DER
definite form.
| _definite_form | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def encode(self):
"""Return this DER element, fully encoded as a binary byte string."""
# Concatenate identifier octets, length octets,
# and contents octets
output_payload = self.payload
# In case of an EXTERNAL tag, first encode the in... | Return this DER element, fully encoded as a binary byte string. | encode | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def _decodeLen(self, s):
"""Decode DER length octets from a file."""
length = s.read_byte()
if length <= 127:
return length
payloadLength = bytes_to_long(s.read(length & 0x7F))
# According to DER (but not BER) the l... | Decode DER length octets from a file. | _decodeLen | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def decode(self, derEle):
"""Decode a complete DER element, and re-initializes this
object with it.
:Parameters:
derEle : byte string
A complete DER element.
:Raise ValueError:
In case of parsing er... | Decode a complete DER element, and re-initializes this
object with it.
:Parameters:
derEle : byte string
A complete DER element.
:Raise ValueError:
In case of parsing errors.
| decode | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def _decodeFromStream(self, s):
"""Decode a complete DER element from a file."""
idOctet = s.read_byte()
if self._tag_octet is not None:
if idOctet != self._tag_octet:
raise ValueError("Unexpected DER tag")
else... | Decode a complete DER element from a file. | _decodeFromStream | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def __init__(self, value=0, implicit=None, explicit=None):
"""Initialize the DER object as an INTEGER.
:Parameters:
value : integer
The value of the integer.
implicit : integer
The IMPLICIT tag to use for the e... | Initialize the DER object as an INTEGER.
:Parameters:
value : integer
The value of the integer.
implicit : integer
The IMPLICIT tag to use for the encoded object.
It overrides the universal tag for INTEGER ... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def encode(self):
"""Return the DER INTEGER, fully encoded as a
binary string."""
number = self.value
self.payload = b('')
while True:
self.payload = bchr(int(number & 255)) + self.payload
if 128 <= ... | Return the DER INTEGER, fully encoded as a
binary string. | encode | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def _decodeFromStream(self, s):
"""Decode a complete DER INTEGER from a file."""
# Fill up self.payload
DerObject._decodeFromStream(self, s)
# Derive self.value from self.payload
self.value = 0
bits = 1
for... | Decode a complete DER INTEGER from a file. | _decodeFromStream | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def __init__(self, startSeq=None, implicit=None):
"""Initialize the DER object as a SEQUENCE.
:Parameters:
startSeq : Python sequence
A sequence whose element are either integers or
other DER objects.
implicit ... | Initialize the DER object as a SEQUENCE.
:Parameters:
startSeq : Python sequence
A sequence whose element are either integers or
other DER objects.
implicit : integer
The IMPLICIT tag to use for the encoded... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def hasInts(self, only_non_negative=True):
"""Return the number of items in this sequence that are
integers.
:Parameters:
only_non_negative : boolean
If True, negative integers are not counted in.
"""
... | Return the number of items in this sequence that are
integers.
:Parameters:
only_non_negative : boolean
If True, negative integers are not counted in.
| hasInts | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def encode(self):
"""Return this DER SEQUENCE, fully encoded as a
binary string.
:Raises ValueError:
If some elements in the sequence are neither integers
nor byte strings.
"""
self.payload = b('')
... | Return this DER SEQUENCE, fully encoded as a
binary string.
:Raises ValueError:
If some elements in the sequence are neither integers
nor byte strings.
| encode | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def decode(self, derEle, nr_elements=None, only_ints_expected=False):
"""Decode a complete DER SEQUENCE, and re-initializes this
object with it.
:Parameters:
derEle : byte string
A complete SEQUENCE DER element.
nr_... | Decode a complete DER SEQUENCE, and re-initializes this
object with it.
:Parameters:
derEle : byte string
A complete SEQUENCE DER element.
nr_elements : None, integer or list of integers
The number of members th... | decode | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def _decodeFromStream(self, s):
"""Decode a complete DER SEQUENCE from a file."""
self._seq = []
# Fill up self.payload
DerObject._decodeFromStream(self, s)
# Add one item at a time to self.seq, by scanning self.payload
p... | Decode a complete DER SEQUENCE from a file. | _decodeFromStream | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def __init__(self, value='', implicit=None, explicit=None):
"""Initialize the DER object as an OBJECT ID.
:Parameters:
value : string
The initial Object Identifier (e.g. "1.2.0.0.6.2").
implicit : integer
The IMPLICIT tag to use for the encoded object.
... | Initialize the DER object as an OBJECT ID.
:Parameters:
value : string
The initial Object Identifier (e.g. "1.2.0.0.6.2").
implicit : integer
The IMPLICIT tag to use for the encoded object.
It overrides the universal tag for OBJECT ID (6).
expli... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def encode(self):
"""Return the DER OBJECT ID, fully encoded as a
binary string."""
comps = map(int, self.value.split("."))
if len(comps) < 2:
raise ValueError("Not a valid Object Identifier string")
self.payload = bchr(40*comps[0]+comps[1])
for v in comps[2:... | Return the DER OBJECT ID, fully encoded as a
binary string. | encode | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def _decodeFromStream(self, s):
"""Decode a complete DER OBJECT ID from a file."""
# Fill up self.payload
DerObject._decodeFromStream(self, s)
# Derive self.value from self.payload
p = BytesIO_EOF(self.payload)
comps = list(map(str, divmod(p.read_byte(), 40)))
v... | Decode a complete DER OBJECT ID from a file. | _decodeFromStream | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def __init__(self, value=b(''), implicit=None, explicit=None):
"""Initialize the DER object as a BIT STRING.
:Parameters:
value : byte string or DER object
The initial, packed bit string.
If not specified, the bit string is empty.
implicit : integer
... | Initialize the DER object as a BIT STRING.
:Parameters:
value : byte string or DER object
The initial, packed bit string.
If not specified, the bit string is empty.
implicit : integer
The IMPLICIT tag to use for the encoded object.
It override... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def encode(self):
"""Return the DER BIT STRING, fully encoded as a
binary string."""
# Add padding count byte
self.payload = b('\x00') + self.value
return DerObject.encode(self) | Return the DER BIT STRING, fully encoded as a
binary string. | encode | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def _decodeFromStream(self, s):
"""Decode a complete DER BIT STRING DER from a file."""
# Fill-up self.payload
DerObject._decodeFromStream(self, s)
if self.payload and bord(self.payload[0]) != 0:
raise ValueError("Not a valid BIT STRING")
# Fill-up self.value
... | Decode a complete DER BIT STRING DER from a file. | _decodeFromStream | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def __init__(self, startSet=None, implicit=None):
"""Initialize the DER object as a SET OF.
:Parameters:
startSet : container
The initial set of integers or DER encoded objects.
implicit : integer
The IMPLICIT tag to use for the encoded object.
It... | Initialize the DER object as a SET OF.
:Parameters:
startSet : container
The initial set of integers or DER encoded objects.
implicit : integer
The IMPLICIT tag to use for the encoded object.
It overrides the universal tag for SET OF (17).
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def add(self, elem):
"""Add an element to the set.
:Parameters:
elem : byte string or integer
An element of the same type of objects already in the set.
It can be an integer or a DER encoded object.
"""
if _is_number(elem):
eo = 0x02
... | Add an element to the set.
:Parameters:
elem : byte string or integer
An element of the same type of objects already in the set.
It can be an integer or a DER encoded object.
| add | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def _decodeFromStream(self, s):
"""Decode a complete DER SET OF from a file."""
self._seq = []
# Fill up self.payload
DerObject._decodeFromStream(self, s)
# Add one item at a time to self.seq, by scanning self.payload
p = BytesIO_EOF(self.payload)
setIdOctet = ... | Decode a complete DER SET OF from a file. | _decodeFromStream | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def encode(self):
"""Return this SET OF DER element, fully encoded as a
binary string.
"""
# Elements in the set must be ordered in lexicographic order
ordered = []
for item in self._seq:
if _is_number(item):
bys = DerInteger(item).encode()
... | Return this SET OF DER element, fully encoded as a
binary string.
| encode | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/asn1.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/asn1.py | MIT |
def new(nbits, prefix=b(""), suffix=b(""), initial_value=1, little_endian=False, allow_wraparound=False):
"""Create a stateful counter block function suitable for CTR encryption modes.
Each call to the function returns the next counter block.
Each counter block is made up by three parts::
prefix || ... | Create a stateful counter block function suitable for CTR encryption modes.
Each call to the function returns the next counter block.
Each counter block is made up by three parts::
prefix || counter value || postfix
The counter value is incremented by 1 at each call.
:Parameters:
nbits :... | new | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/Counter.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/Counter.py | MIT |
def size (N):
"""size(N:long) : int
Returns the size of the number N in bits.
"""
bits = 0
while N >> bits:
bits += 1
return bits | size(N:long) : int
Returns the size of the number N in bits.
| size | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/number.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/number.py | MIT |
def GCD(x,y):
"""GCD(x:long, y:long): long
Return the GCD of x and y.
"""
x = abs(x) ; y = abs(y)
while x > 0:
x, y = y % x, x
return y | GCD(x:long, y:long): long
Return the GCD of x and y.
| GCD | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/number.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/number.py | MIT |
def inverse(u, v):
"""inverse(u:long, v:long):long
Return the inverse of u mod v.
"""
u3, v3 = long(u), long(v)
u1, v1 = 1, 0
while v3 > 0:
q = u3 // v3
u1, v1 = v1, u1 - v1*q
u3, v3 = v3, u3 - v3*q
while u1<0:
u1 = u1 + v
return u1 | inverse(u:long, v:long):long
Return the inverse of u mod v.
| inverse | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/number.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/number.py | MIT |
def bytes_to_long(s):
"""bytes_to_long(string) : long
Convert a byte string to a long integer (big endian).
This is (essentially) the inverse of long_to_bytes().
"""
acc = 0
unpack = struct.unpack
length = len(s)
if length % 4:
extra = (4 - length % 4)
s = b('\000') * ex... | bytes_to_long(string) : long
Convert a byte string to a long integer (big endian).
This is (essentially) the inverse of long_to_bytes().
| bytes_to_long | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/number.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/number.py | MIT |
def _key2bin(s):
"Convert a key into a string of binary digits"
kl=map(lambda x: bord(x), s)
kl=map(lambda x: binary[x>>4]+binary[x&15], kl)
return ''.join(kl) | Convert a key into a string of binary digits | _key2bin | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/RFC1751.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/RFC1751.py | MIT |
def _extract(key, start, length):
"""Extract a bitstring(2.x)/bytestring(2.x) from a string of binary digits, and return its
numeric value."""
k=key[start:start+length]
return reduce(lambda x,y: x*2+ord(y)-48, k, 0) | Extract a bitstring(2.x)/bytestring(2.x) from a string of binary digits, and return its
numeric value. | _extract | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/RFC1751.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/RFC1751.py | MIT |
def key_to_english (key):
"""key_to_english(key:string(2.x)/bytes(3.x)) : string
Transform an arbitrary key into a string containing English words.
The key length must be a multiple of 8.
"""
english=''
for index in range(0, len(key), 8): # Loop over 8-byte subkeys
subkey=key[index:index... | key_to_english(key:string(2.x)/bytes(3.x)) : string
Transform an arbitrary key into a string containing English words.
The key length must be a multiple of 8.
| key_to_english | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/RFC1751.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/RFC1751.py | MIT |
def english_to_key (s):
"""english_to_key(string):string(2.x)/bytes(2.x)
Transform a string into a corresponding key.
The string must contain words separated by whitespace; the number
of words must be a multiple of 6.
"""
L=s.upper().split() ; key=b('')
for index in range(0, len(L), 6):
... | english_to_key(string):string(2.x)/bytes(2.x)
Transform a string into a corresponding key.
The string must contain words separated by whitespace; the number
of words must be a multiple of 6.
| english_to_key | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/RFC1751.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/RFC1751.py | MIT |
def strxor(term1, term2):
"""Return term1 xored with term2.
The two byte strings must have equal length."""
expect_byte_string(term1)
expect_byte_string(term2)
if len(term1) != len(term2):
raise ValueError("Only byte strings of equal length can be xored")
result = create_string_buffer(l... | Return term1 xored with term2.
The two byte strings must have equal length. | strxor | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/strxor.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/strxor.py | MIT |
def strxor_c(term, c):
"""Return term xored with a sequence of characters c."""
expect_byte_string(term)
if not 0 <= c < 256:
raise ValueError("c must be in range(256)")
result = create_string_buffer(len(term))
_raw_strxor.strxor_c(term, c, result, c_size_t(len(term)))
return get_raw_bu... | Return term xored with a sequence of characters c. | strxor_c | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/strxor.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/strxor.py | MIT |
def pycryptodome_filename(dir_comps, filename):
"""Return the complete file name for the module
dir_comps : list of string
The list of directory names in the PyCryptodome package.
The first element must be "Cryptodome".
filename : string
The filename (inclusing extension) in the ta... | Return the complete file name for the module
dir_comps : list of string
The list of directory names in the PyCryptodome package.
The first element must be "Cryptodome".
filename : string
The filename (inclusing extension) in the target directory.
| pycryptodome_filename | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/_file_system.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/_file_system.py | MIT |
def ceil_shift(n, b):
"""Return ceil(n / 2**b) without performing any floating-point or division operations.
This is done by right-shifting n by b bits and incrementing the result by 1
if any '1' bits were shifted out.
"""
if not isinstance(n, (int, long)) or not isinstance(b, (int, long)):
... | Return ceil(n / 2**b) without performing any floating-point or division operations.
This is done by right-shifting n by b bits and incrementing the result by 1
if any '1' bits were shifted out.
| ceil_shift | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/_number_new.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/_number_new.py | MIT |
def ceil_div(a, b):
"""Return ceil(a / b) without performing any floating-point operations."""
if not isinstance(a, (int, long)) or not isinstance(b, (int, long)):
raise TypeError("unsupported operand type(s): %r and %r" % (type(a).__name__, type(b).__name__))
(q, r) = divmod(a, b)
if r:
... | Return ceil(a / b) without performing any floating-point operations. | ceil_div | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/_number_new.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/_number_new.py | MIT |
def exact_log2(num):
"""Find and return an integer i >= 0 such that num == 2**i.
If no such integer exists, this function raises ValueError.
"""
if not isinstance(num, (int, long)):
raise TypeError("unsupported operand type: %r" % (type(num).__name__,))
n = long(num)
if n <= 0:
... | Find and return an integer i >= 0 such that num == 2**i.
If no such integer exists, this function raises ValueError.
| exact_log2 | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/_number_new.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/_number_new.py | MIT |
def exact_div(p, d, allow_divzero=False):
"""Find and return an integer n such that p == n * d
If no such integer exists, this function raises ValueError.
Both operands must be integers.
If the second operand is zero, this function will raise ZeroDivisionError
unless allow_divzero is true (defaul... | Find and return an integer n such that p == n * d
If no such integer exists, this function raises ValueError.
Both operands must be integers.
If the second operand is zero, this function will raise ZeroDivisionError
unless allow_divzero is true (default: False).
| exact_div | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/_number_new.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/_number_new.py | MIT |
def load_lib(name, cdecl):
"""Load a shared library and return a handle to it.
@name, either an absolute path or the name of a library
in the system search path.
@cdecl, the C function declarations.
"""
lib = ffi.dlopen(name)
ffi.cdef(cdecl)
re... | Load a shared library and return a handle to it.
@name, either an absolute path or the name of a library
in the system search path.
@cdecl, the C function declarations.
| load_lib | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/_raw_api.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/_raw_api.py | MIT |
def load_pycryptodome_raw_lib(name, cdecl):
"""Load a shared library and return a handle to it.
@name, the name of the library expressed as a PyCryptodome module,
for instance Cryptodome.Cipher._raw_cbc.
@cdecl, the C function declarations.
"""
split = name.split(".")
dir_comps, ... | Load a shared library and return a handle to it.
@name, the name of the library expressed as a PyCryptodome module,
for instance Cryptodome.Cipher._raw_cbc.
@cdecl, the C function declarations.
| load_pycryptodome_raw_lib | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/Cryptodome/Util/_raw_api.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Util/_raw_api.py | MIT |
def __init__(self, listener, locals=None, banner=None, **server_args):
"""
:keyword locals: If given, a dictionary of "builtin" values that will be available
at the top-level.
:keyword banner: If geven, a string that will be printed to each connecting user.
"""
Stream... |
:keyword locals: If given, a dictionary of "builtin" values that will be available
at the top-level.
:keyword banner: If geven, a string that will be printed to each connecting user.
| __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/backdoor.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/backdoor.py | MIT |
def handle(self, conn, address):
"""
Interact with one remote user.
.. versionchanged:: 1.1b2 Each connection gets its own
``locals`` dictionary. Previously they were shared in a
potentially unsafe manner.
"""
fobj = conn.makefile(mode="rw")
fobj ... |
Interact with one remote user.
.. versionchanged:: 1.1b2 Each connection gets its own
``locals`` dictionary. Previously they were shared in a
potentially unsafe manner.
| handle | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/backdoor.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/backdoor.py | MIT |
def start(self):
"""Start accepting the connections.
If an address was provided in the constructor, then also create a socket,
bind it and put it into the listening mode.
"""
self.init_socket()
self._stop_event.clear()
try:
self.start_accepting()
... | Start accepting the connections.
If an address was provided in the constructor, then also create a socket,
bind it and put it into the listening mode.
| start | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/baseserver.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/baseserver.py | MIT |
def close(self):
"""Close the listener socket and stop accepting."""
self._stop_event.set()
try:
self.stop_accepting()
finally:
try:
self.socket.close()
except Exception:
pass
finally:
self.__... | Close the listener socket and stop accepting. | close | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/baseserver.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/baseserver.py | MIT |
def stop(self, timeout=None):
"""
Stop accepting the connections and close the listening socket.
If the server uses a pool to spawn the requests, then
:meth:`stop` also waits for all the handlers to exit. If there
are still handlers executing after *timeout* has expired
... |
Stop accepting the connections and close the listening socket.
If the server uses a pool to spawn the requests, then
:meth:`stop` also waits for all the handlers to exit. If there
are still handlers executing after *timeout* has expired
(default 1 second, :attr:`stop_timeout`),... | stop | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/baseserver.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/baseserver.py | MIT |
def serve_forever(self, stop_timeout=None):
"""Start the server if it hasn't been already started and wait until it's stopped."""
# add test that serve_forever exists on stop()
if not self.started:
self.start()
try:
self._stop_event.wait()
finally:
... | Start the server if it hasn't been already started and wait until it's stopped. | serve_forever | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/baseserver.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/baseserver.py | MIT |
def __import__(*args, **kwargs):
"""
__import__(name, globals=None, locals=None, fromlist=(), level=0) -> object
Normally python protects imports against concurrency by doing some locking
at the C level (at least, it does that in CPython). This function just
wraps the normal __import__ functionali... |
__import__(name, globals=None, locals=None, fromlist=(), level=0) -> object
Normally python protects imports against concurrency by doing some locking
at the C level (at least, it does that in CPython). This function just
wraps the normal __import__ functionality in a recursive lock, ensuring that
... | __import__ | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/builtins.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/builtins.py | MIT |
def _python_callback(handle, revents):
"""
Returns an integer having one of three values:
- -1
An exception occurred during the callback and you must call
:func:`_python_handle_error` to deal with it. The Python watcher
object will have the exception tuple saved in ``_exc_info``.
- 0
... |
Returns an integer having one of three values:
- -1
An exception occurred during the callback and you must call
:func:`_python_handle_error` to deal with it. The Python watcher
object will have the exception tuple saved in ``_exc_info``.
- 0
Everything went according to plan. You s... | _python_callback | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/corecffi.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/corecffi.py | MIT |
def rawlink(self, callback):
"""
Register a callback to call when this object is ready.
*callback* will be called in the :class:`Hub <gevent.hub.Hub>`, so it must not use blocking gevent API.
*callback* will be passed one argument: this instance.
"""
if not callable(call... |
Register a callback to call when this object is ready.
*callback* will be called in the :class:`Hub <gevent.hub.Hub>`, so it must not use blocking gevent API.
*callback* will be passed one argument: this instance.
| rawlink | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/event.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/event.py | MIT |
def unlink(self, callback):
"""Remove the callback set by :meth:`rawlink`"""
try:
self._links.remove(callback)
except KeyError:
pass | Remove the callback set by :meth:`rawlink` | unlink | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/event.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/event.py | MIT |
def exc_info(self):
"""
The three-tuple of exception information if :meth:`set_exception` was called.
"""
if self._exc_info:
return (self._exc_info[0], self._exc_info[1], load_traceback(self._exc_info[2]))
return () |
The three-tuple of exception information if :meth:`set_exception` was called.
| exc_info | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/event.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/event.py | MIT |
def set_exception(self, exception, exc_info=None):
"""Store the exception and wake up any waiters.
All greenlets blocking on :meth:`get` or :meth:`wait` are awakened.
Subsequent calls to :meth:`wait` and :meth:`get` will not block at all.
:keyword tuple exc_info: If given, a standard t... | Store the exception and wake up any waiters.
All greenlets blocking on :meth:`get` or :meth:`wait` are awakened.
Subsequent calls to :meth:`wait` and :meth:`get` will not block at all.
:keyword tuple exc_info: If given, a standard three-tuple of type, value, :class:`traceback`
as r... | set_exception | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/event.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/event.py | MIT |
def get(self, block=True, timeout=None):
"""Return the stored value or raise the exception.
If this instance already holds a value or an exception, return or raise it immediatelly.
Otherwise, block until another greenlet calls :meth:`set` or :meth:`set_exception` or
until the optional ... | Return the stored value or raise the exception.
If this instance already holds a value or an exception, return or raise it immediatelly.
Otherwise, block until another greenlet calls :meth:`set` or :meth:`set_exception` or
until the optional timeout occurs.
When the *timeout* argument... | get | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/event.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/event.py | MIT |
def __init__(self, fobj, *args, **kwargs):
"""
:param fobj: The underlying file-like object to wrap, or an integer fileno
that will be pass to :func:`os.fdopen` along with everything in *args*.
:keyword bool lock: If True (the default) then all operations will
be performed ... |
:param fobj: The underlying file-like object to wrap, or an integer fileno
that will be pass to :func:`os.fdopen` along with everything in *args*.
:keyword bool lock: If True (the default) then all operations will
be performed one-by-one. Note that this does not guarantee that, if... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/fileobject.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/fileobject.py | MIT |
def close(self):
"""
.. versionchanged:: 1.1b1
The file object is closed using the threadpool. Note that whether or
not this action is synchronous or asynchronous is not documented.
"""
fobj = self.io
if fobj is None:
return
self.io = Non... |
.. versionchanged:: 1.1b1
The file object is closed using the threadpool. Note that whether or
not this action is synchronous or asynchronous is not documented.
| close | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/fileobject.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/fileobject.py | MIT |
def __init__(self, run=None, *args, **kwargs):
"""
Greenlet constructor.
:param args: The arguments passed to the ``run`` function.
:param kwargs: The keyword arguments passed to the ``run`` function.
:keyword run: The callable object to run. If not given, this object's
... |
Greenlet constructor.
:param args: The arguments passed to the ``run`` function.
:param kwargs: The keyword arguments passed to the ``run`` function.
:keyword run: The callable object to run. If not given, this object's
`_run` method will be invoked (typically defined by su... | __init__ | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/greenlet.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/greenlet.py | MIT |
def exc_info(self):
"""Holds the exc_info three-tuple raised by the function if the greenlet finished with an error.
Otherwise a false value."""
e = self._exc_info
if e:
return (e[0], e[1], load_traceback(e[2])) | Holds the exc_info three-tuple raised by the function if the greenlet finished with an error.
Otherwise a false value. | exc_info | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/greenlet.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/greenlet.py | MIT |
def throw(self, *args):
"""Immediatelly switch into the greenlet and raise an exception in it.
Should only be called from the HUB, otherwise the current greenlet is left unscheduled forever.
To raise an exception in a safe manner from any greenlet, use :meth:`kill`.
If a greenlet was s... | Immediatelly switch into the greenlet and raise an exception in it.
Should only be called from the HUB, otherwise the current greenlet is left unscheduled forever.
To raise an exception in a safe manner from any greenlet, use :meth:`kill`.
If a greenlet was started but never switched to yet, t... | throw | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/greenlet.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/greenlet.py | MIT |
def start(self):
"""Schedule the greenlet to run in this loop iteration"""
if self._start_event is None:
self._start_event = self.parent.loop.run_callback(self.switch) | Schedule the greenlet to run in this loop iteration | start | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/greenlet.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/greenlet.py | MIT |
def start_later(self, seconds):
"""Schedule the greenlet to run in the future loop iteration *seconds* later"""
if self._start_event is None:
self._start_event = self.parent.loop.timer(seconds)
self._start_event.start(self.switch) | Schedule the greenlet to run in the future loop iteration *seconds* later | start_later | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/greenlet.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/greenlet.py | MIT |
def spawn(cls, *args, **kwargs):
"""
Create a new :class:`Greenlet` object and schedule it to run ``function(*args, **kwargs)``.
This can be used as ``gevent.spawn`` or ``Greenlet.spawn``.
The arguments are passed to :meth:`Greenlet.__init__`.
.. versionchanged:: 1.1b1
... |
Create a new :class:`Greenlet` object and schedule it to run ``function(*args, **kwargs)``.
This can be used as ``gevent.spawn`` or ``Greenlet.spawn``.
The arguments are passed to :meth:`Greenlet.__init__`.
.. versionchanged:: 1.1b1
If a *function* is given that is not cal... | spawn | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/greenlet.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/greenlet.py | MIT |
def spawn_later(cls, seconds, *args, **kwargs):
"""
Create and return a new Greenlet object scheduled to run ``function(*args, **kwargs)``
in the future loop iteration *seconds* later. This can be used as ``Greenlet.spawn_later``
or ``gevent.spawn_later``.
The arguments are pass... |
Create and return a new Greenlet object scheduled to run ``function(*args, **kwargs)``
in the future loop iteration *seconds* later. This can be used as ``Greenlet.spawn_later``
or ``gevent.spawn_later``.
The arguments are passed to :meth:`Greenlet.__init__`.
.. versionchanged... | spawn_later | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/greenlet.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/greenlet.py | MIT |
def kill(self, exception=GreenletExit, block=True, timeout=None):
"""
Raise the ``exception`` in the greenlet.
If ``block`` is ``True`` (the default), wait until the greenlet dies or the optional timeout expires.
If block is ``False``, the current greenlet is not unscheduled.
T... |
Raise the ``exception`` in the greenlet.
If ``block`` is ``True`` (the default), wait until the greenlet dies or the optional timeout expires.
If block is ``False``, the current greenlet is not unscheduled.
The function always returns ``None`` and never raises an error.
.. no... | kill | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/greenlet.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/greenlet.py | MIT |
def get(self, block=True, timeout=None):
"""Return the result the greenlet has returned or re-raise the exception it has raised.
If block is ``False``, raise :class:`gevent.Timeout` if the greenlet is still alive.
If block is ``True``, unschedule the current greenlet until the result is availab... | Return the result the greenlet has returned or re-raise the exception it has raised.
If block is ``False``, raise :class:`gevent.Timeout` if the greenlet is still alive.
If block is ``True``, unschedule the current greenlet until the result is available
or the timeout expires. In the latter cas... | get | python | mchristopher/PokemonGo-DesktopMap | app/pylibs/osx64/gevent/greenlet.py | https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/gevent/greenlet.py | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.