codekingpro/portable-devtools
114k
1# Copyright 2017 Google LLC2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14 15"""RSA cryptography signer and verifier."""16 17 18try:19 # Prefer cryptograph-based RSA implementation.20 from google.auth.crypt import _cryptography_rsa21 22 RSASigner = _cryptography_rsa.RSASigner23 RSAVerifier = _cryptography_rsa.RSAVerifier24except ImportError: # pragma: NO COVER25 # Fallback to pure-python RSA implementation if cryptography is26 # unavailable.27 from google.auth.crypt import _python_rsa28 29 RSASigner = _python_rsa.RSASigner # type: ignore30 RSAVerifier = _python_rsa.RSAVerifier # type: ignore31 