コード例 #1
0
    def from_compact(cls, compact):
        """Compact deserialization.

        :param bytes compact:

        """
        try:
            protected, payload, signature = compact.split(b'.')
        except ValueError:
            raise errors.DeserializationError(
                'Compact JWS serialization should comprise of exactly'
                ' 3 dot-separated components')

        sig = cls.signature_cls(
            protected=b64.b64decode(protected).decode('utf-8'),
            signature=b64.b64decode(signature))
        return cls(payload=b64.b64decode(payload), signatures=(sig, ))
コード例 #2
0
ファイル: jws.py プロジェクト: jsongo/certbot
    def from_compact(cls, compact):
        """Compact deserialization.

        :param bytes compact:

        """
        try:
            protected, payload, signature = compact.split(b'.')
        except ValueError:
            raise errors.DeserializationError(
                'Compact JWS serialization should comprise of exactly'
                ' 3 dot-separated components')

        sig = cls.signature_cls(
            protected=b64.b64decode(protected).decode('utf-8'),
            signature=b64.b64decode(signature))
        return cls(payload=b64.b64decode(payload), signatures=(sig,))
コード例 #3
0
def decode_b64jose(data, size=None, minimum=False):
    """Decode JOSE Base-64 field.

    :param int size: Required length (after decoding).
    :param bool minimum: If ``True``, then `size` will be treated as
        minimum required length, as opposed to exact equality.

    """
    try:
        decoded = b64.b64decode(data)
    except TypeError as error:
        raise errors.DeserializationError(error)

    if size is not None and ((not minimum and len(decoded) != size) or (minimum and len(decoded) < size)):
        raise errors.DeserializationError()

    return decoded
コード例 #4
0
ファイル: json_util.py プロジェクト: tundish/letsencrypt
def decode_b64jose(data, size=None, minimum=False):
    """Decode JOSE Base-64 field.

    :param int size: Required length (after decoding).
    :param bool minimum: If ``True``, then `size` will be treated as
        minimum required length, as opposed to exact equality.

    """
    try:
        decoded = b64.b64decode(data)
    except TypeError as error:
        raise errors.DeserializationError(error)

    if size is not None and ((not minimum and len(decoded) != size) or
                             (minimum and len(decoded) < size)):
        raise errors.DeserializationError()

    return decoded
コード例 #5
0
ファイル: json_util.py プロジェクト: v1p/letsencrypt
def decode_b64jose(data, size=None, minimum=False):
    """Decode JOSE Base-64 field.

    :param unicode data:
    :param int size: Required length (after decoding).
    :param bool minimum: If ``True``, then `size` will be treated as
        minimum required length, as opposed to exact equality.

    :rtype: bytes

    """
    error_cls = TypeError if six.PY2 else binascii.Error
    try:
        decoded = b64.b64decode(data.encode())
    except error_cls as error:
        raise errors.DeserializationError(error)

    if size is not None and ((not minimum and len(decoded) != size) or (minimum and len(decoded) < size)):
        raise errors.DeserializationError("Expected at least or exactly {0} bytes".format(size))

    return decoded
コード例 #6
0
def decode_b64jose(data, size=None, minimum=False):
    """Decode JOSE Base-64 field.

    :param unicode data:
    :param int size: Required length (after decoding).
    :param bool minimum: If ``True``, then `size` will be treated as
        minimum required length, as opposed to exact equality.

    :rtype: bytes

    """
    error_cls = TypeError if six.PY2 else binascii.Error
    try:
        decoded = b64.b64decode(data.encode())
    except error_cls as error:
        raise errors.DeserializationError(error)

    if size is not None and ((not minimum and len(decoded) != size) or
                             (minimum and len(decoded) < size)):
        raise errors.DeserializationError()

    return decoded
コード例 #7
0
ファイル: b64_test.py プロジェクト: 1resu/letsencrypt
 def _call(cls, data):
     from acme.jose.b64 import b64decode
     return b64decode(data)
コード例 #8
0
 def _call(cls, data):
     from acme.jose.b64 import b64decode
     return b64decode(data)