-
Notifications
You must be signed in to change notification settings - Fork 346
Add google.auth.crypt #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| @@ -0,0 +1,65 @@ | |||
| # Copyright 2015 Google Inc. | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/crypt.py
Outdated
| for start in six.moves.xrange(0, num_bits, 8): | ||
| curr_bits = bit_list[start:start + 8] | ||
| char_val = sum(val * digit | ||
| for val, digit in zip(_POW2, curr_bits)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| message = _helpers.to_bytes(message, encoding='utf-8') | ||
| try: | ||
| return rsa.pkcs1.verify(message, signature, self._pubkey) | ||
| except (ValueError, rsa.pkcs1.VerificationError): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/crypt.py
Outdated
| ValueError: If the public_key can't be parsed. | ||
| """ | ||
| public_key = _helpers.to_bytes(public_key) | ||
| is_x509_cert = b'-----BEGIN CERTIFICATE-----' in public_key |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/crypt.py
Outdated
| Returns: | ||
| bool: True if the signature is valid, otherwise False. | ||
| """ | ||
| if isinstance(certs, six.binary_type): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
|
|
||
| def test_to_bytes_with_nonstring_type(): | ||
| with pytest.raises(ValueError): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| from google.auth import crypt | ||
|
|
||
|
|
||
| DATA_DIR = os.path.join(os.path.dirname(__file__), 'data') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
tests/test_crypt.py
Outdated
|
|
||
| # List of certs | ||
| assert crypt.verify_signature( | ||
| to_sign, signature, [OTHER_CERT_BYTES, PUBLIC_CERT_BYTES]) is True |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
tests/test_crypt.py
Outdated
| to_sign, signature, OTHER_CERT_BYTES) is False | ||
|
|
||
|
|
||
| class TestVerifier: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| sphinx | ||
| commands = sphinx-apidoc --output-dir docs/reference --separate --module-first google | ||
| commands = | ||
| rm -r docs/reference |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
tests/test_crypt.py
Outdated
|
|
||
| # To generate privatekey.pem, privatekey.pub, and public_cert.pem: | ||
| # $ openssl req -new -newkey rsa:1024 -x509 -nodes -out public_cert.pem \ | ||
| # -keyout privatekey.pem |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Really great that you added the commands to generate the key files! |
|
@dhermes any outstanding comments? |
|
LGTM |

No description provided.