当前位置: 首页>>代码示例>>Python>>正文


Python rsa.verify方法代码示例

本文整理汇总了Python中rsa.verify方法的典型用法代码示例。如果您正苦于以下问题:Python rsa.verify方法的具体用法?Python rsa.verify怎么用?Python rsa.verify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rsa的用法示例。


在下文中一共展示了rsa.verify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: verify

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def verify(self, purchase_token: str, product_sku: str, is_subscription: bool = False) -> dict:
        service = build("androidpublisher", "v3", http=self.http)

        if is_subscription:
            result = self.check_purchase_subscription(purchase_token, product_sku, service)
            cancel_reason = int(result.get("cancelReason", 0))

            if cancel_reason != 0:
                raise GoogleError("Subscription is canceled", result)

            ms_timestamp = result.get("expiryTimeMillis", 0)

            if self._ms_timestamp_expired(ms_timestamp):
                raise GoogleError("Subscription expired", result)
        else:
            result = self.check_purchase_product(purchase_token, product_sku, service)
            purchase_state = int(result.get("purchaseState", 1))

            if purchase_state != 0:
                raise GoogleError("Purchase cancelled", result)

        return result 
开发者ID:dotpot,项目名称:InAppPy,代码行数:24,代码来源:googleplay.py

示例2: verify_ali_data

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def verify_ali_data(valueDict):
    logger.info('verifying data from ali')
    sign = valueDict['sign']
    # remove sign and sign_type
    del valueDict['sign']
    if 'sign_type' in valueDict:
        del valueDict['sign_type']
    # contact string need to verify
    temp = []
    for key in sorted(valueDict):
        if not valueDict[key]:
            continue
        temp.append('{}={}'.format(key, valueDict[key]))
    tempStr = '&'.join(temp)
    logger.info('string to verify:{}'.format(tempStr))
    return verify(tempStr, sign, settings.ALIPAY['ali_public_key_pem']) 
开发者ID:panweifeng,项目名称:openunipay,代码行数:18,代码来源:security.py

示例3: verify

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def verify(self, message, signature, hash_method=None):
        """

        :param message:
        :param signature:
        :param hash_method:
        :return:
        """
        try:
            compare_hash_method = hash_method or self.hash_method
            hash_m = rsa.verify(message.encode(), signature, self.public_key)
            if hash_m == compare_hash_method:
                return True
            else:
                return False
        except:
            return False 
开发者ID:seecode-audit,项目名称:seecode-scanner,代码行数:19,代码来源:rsaencrypt.py

示例4: valid_token

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def valid_token():
    resp = requests.get(url = "http://zlclclc.cn/get_token")
    s = eval(resp.json()["signature"])
    signature = base64.decodestring(s)

    crypto = resp.json()["token_message"]
    message = crypto[2:-6]+'\n'

    with open('/home/mmmsc/listen-now/project/Helper/pubkey.pem','r') as f:
        pubkey = rsa.PublicKey.load_pkcs1(f.read().encode())        
    
    v = rsa.verify(message.encode(), signature, pubkey)     
    
    try:
        rsa.verify(message.encode(), signature, pubkey)
        sign_valid = 1
    except:

        sign_valid = 0
    #token = crypto[:110]+'\n'+crypto[112:115]
    token_message = crypto[2:110]+r'\n'+crypto[112:115]      
    parameter = {"sign_valid":sign_valid,"token":token_message}
    valid_key = requests.post(url = "http://zlclclc.cn/exist_token",data = json.dumps(parameter))
    return token_message
#print(valid_token()) 
开发者ID:listen-now,项目名称:listen-now,代码行数:27,代码来源:valid_token.py

示例5: checkSign

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def checkSign(self, mess, result, pubkey=None):
        """
        验证签名:传入解密后明文、签名、公钥,验证成功返回哈希方法,失败则报错
        :param mess: str
        :param result: bytes
        :param pubkey: 
        :return: str
        """
        if None == pubkey:
            pubkey = self.privkey
        try:
            result = rsa.verify(mess, result, pubkey)
            return result
        except:
            return False 
开发者ID:inlike,项目名称:R-A-M-D-D3-S-M-H,代码行数:17,代码来源:RSA-AES-MD5-DES-DES3-MD5-SHA-HMAC.py

示例6: verifySRCTokenUtxoPayload

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def verifySRCTokenUtxoPayload(self, payload, signature):
		try:
			return rsa.verify(payload, signature.decode('hex'), addr_to_pubkey(self.addr))
		except:
			return False 
开发者ID:sixstars,项目名称:starctf2018,代码行数:7,代码来源:serve.py

示例7: verify_utxo_signature

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def verify_utxo_signature(address, utxo_id, signature):
	try:
		return rsa.verify(utxo_id, signature.decode('hex'), addr_to_pubkey(address))
	except:
		return False 
开发者ID:sixstars,项目名称:starctf2018,代码行数:7,代码来源:serve.py

示例8: unpack_license_key

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def unpack_license_key(key_str, pubkey_args):
    """
    Decode a string of license key data produced by `pack_license_key`. In other
    words, this function is the inverse of `pack_...` above:

        data == unpack_license_key(pack_license_key(data, ...), ...)

    If the given string is not a valid key, `InvalidKey` is raised.

    The parameter `pubkey_args` is a dictionary containing values for the RSA
    fields "n" and "e". It can be generated with fbs's command `init_licensing`.
    """
    try:
        result = json.loads(key_str)
    except ValueError:
        raise InvalidKey() from None
    try:
        signature = result.pop('key')
    except KeyError:
        raise InvalidKey() from None
    try:
        signature_bytes = b64decode(signature.encode('ascii'))
    except ValueError:
        raise InvalidKey() from None
    try:
        rsa.verify(_dumpb(result), signature_bytes, PublicKey(**pubkey_args))
    except VerificationError:
        raise InvalidKey() from None
    return result 
开发者ID:mherrmann,项目名称:fbs,代码行数:31,代码来源:licensing.py

示例9: _validate_signature

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def _validate_signature(self, receipt: str, signature: str) -> bool:
        try:
            sig = base64.standard_b64decode(signature)
            return rsa.verify(receipt.encode(), sig, self.public_key)
        except (rsa.VerificationError, TypeError, ValueError, BaseException):
            return False 
开发者ID:dotpot,项目名称:InAppPy,代码行数:8,代码来源:googleplay.py

示例10: verify_with_result

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def verify_with_result(
        self, purchase_token: str, product_sku: str, is_subscription: bool = False
    ) -> GoogleVerificationResult:
        """Verifies by returning verification result instead of raising an error,
        basically it's and better alternative to verify method."""
        service = build("androidpublisher", "v3", http=self.http)
        verification_result = GoogleVerificationResult({}, False, False)

        if is_subscription:
            result = self.check_purchase_subscription(purchase_token, product_sku, service)
            verification_result.raw_response = result

            cancel_reason = int(result.get("cancelReason", 0))
            if cancel_reason != 0:
                verification_result.is_canceled = True

            ms_timestamp = result.get("expiryTimeMillis", 0)
            if self._ms_timestamp_expired(ms_timestamp):
                verification_result.is_expired = True
        else:
            result = self.check_purchase_product(purchase_token, product_sku, service)
            verification_result.raw_response = result

            purchase_state = int(result.get("purchaseState", 1))
            if purchase_state != 0:
                verification_result.is_canceled = True

        return verification_result 
开发者ID:dotpot,项目名称:InAppPy,代码行数:30,代码来源:googleplay.py

示例11: perform_operation

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def perform_operation(self, indata, pub_key, cli_args):
        """Verifies files."""

        signature_file = cli_args[1]

        with open(signature_file, 'rb') as sigfile:
            signature = sigfile.read()

        try:
            rsa.verify(indata, signature, pub_key)
        except rsa.VerificationError:
            raise SystemExit('Verification failed.')

        print('Verification OK', file=sys.stderr) 
开发者ID:Deltares,项目名称:aqua-monitor,代码行数:16,代码来源:cli.py

示例12: perform_operation

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def perform_operation(self, indata, pub_key, cli_args):
        '''Decrypts files.'''

        signature_file = cli_args[1]
        
        with open(signature_file, 'rb') as sigfile:
            signature = sigfile.read()

        try:
            rsa.verify(indata, signature, pub_key)
        except rsa.VerificationError:
            raise SystemExit('Verification failed.')

        print('Verification OK', file=sys.stderr) 
开发者ID:deadblue,项目名称:baidupan_shell,代码行数:16,代码来源:cli.py

示例13: validate

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def validate(self, bucket, key, public_key, digest_data, inflated_digest):
        """Validates a digest file.

        Throws a DigestError when the digest is invalid.

        :param bucket: Bucket of the digest file
        :param key: Key of the digest file
        :param public_key: Public key bytes.
        :param digest_data: Dict of digest data returned when JSON
            decoding a manifest.
        :param inflated_digest: Inflated digest file contents as bytes.
        """
        try:
            decoded_key = base64.b64decode(public_key)
            public_key = rsa.PublicKey.load_pkcs1(decoded_key, format='DER')
            to_sign = self._create_string_to_sign(digest_data, inflated_digest)
            signature_bytes = binascii.unhexlify(digest_data['_signature'])
            rsa.verify(to_sign, signature_bytes, public_key)
        except PyAsn1Error:
            raise DigestError(
                ('Digest file\ts3://%s/%s\tINVALID: Unable to load PKCS #1 key'
                 ' with fingerprint %s')
                % (bucket, key, digest_data['digestPublicKeyFingerprint']))
        except rsa.pkcs1.VerificationError:
            # Note from the Python-RSA docs: Never display the stack trace of
            # a rsa.pkcs1.VerificationError exception. It shows where in the
            # code the exception occurred, and thus leaks information about
            # the key.
            raise DigestSignatureError(bucket, key) 
开发者ID:gkrizek,项目名称:bash-lambda-layer,代码行数:31,代码来源:validation.py

示例14: setup_services

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def setup_services(self, parsed_globals):
        self._source_region = parsed_globals.region
        # Use the the same region as the region of the CLI to get locations.
        self.s3_client_provider = S3ClientProvider(
            self._session, self._source_region)
        client_args = {'region_name': parsed_globals.region,
                       'verify': parsed_globals.verify_ssl}
        if parsed_globals.endpoint_url is not None:
            client_args['endpoint_url'] = parsed_globals.endpoint_url
        self.cloudtrail_client = self._session.create_client(
            'cloudtrail', **client_args) 
开发者ID:gkrizek,项目名称:bash-lambda-layer,代码行数:13,代码来源:validation.py

示例15: to_verify_with_public_key

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import verify [as 别名]
def to_verify_with_public_key(cls, message, signature, public_path=None, public_key=None):
        # 公钥验签
        public_key_obj = cls.load_public_key(public_path, public_key)
        message = cls.check_message(message)
        result = rsa.verify(message, signature, public_key_obj)
        return result 
开发者ID:ss1917,项目名称:ops_sdk,代码行数:8,代码来源:__init__.py


注:本文中的rsa.verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。