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


Python rsa.VerificationError方法代码示例

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


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

示例1: unpack_license_key

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import VerificationError [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

示例2: _validate_signature

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import VerificationError [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

示例3: perform_operation

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import VerificationError [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

示例4: perform_operation

# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import VerificationError [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

示例5: _validate_signature

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


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