How to use the pyasn1.compat.octets.ints2octs function in pyasn1

To help you get started, we’ve selected a few pyasn1 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github etingof / pyasn1 / tests / codec / ber / test_decoder.py View on Github external
def testLeading0x80Case4(self):
        try:
            decoder.decode(
                ints2octs((6, 2, 0x80, 0x7F))
            )
        except error.PyAsn1Error:
            pass
        else:
            assert 0, 'Leading 0x80 tolerated'
github etingof / pyasn1 / tests / codec / cer / test_encoder.py View on Github external
def testOptionalWithDefault(self):
        s = self.__initOptionalWithDefault()
        assert encoder.encode(s) == ints2octs((48, 128, 48, 128, 2, 1, 123, 0, 0, 0, 0))
github etingof / pyasn1 / tests / codec / ber / test_encoder.py View on Github external
def testOne(self):
        assert encoder.encode(
            (1, 3, 6, 0, 0xffffe), asn1Spec=univ.ObjectIdentifier()
        ) == ints2octs((6, 6, 43, 6, 0, 191, 255, 126))
github etingof / pyasn1 / tests / codec / der / test_encoder.py View on Github external
def testDefModeOptionalWithOptional(self):
        s = self.__initOptionalWithOptional()
        assert encoder.encode(s) == ints2octs((48, 8, 48, 6, 4, 4, 116, 101, 115, 116))
github etingof / pyasn1 / tests / codec / cer / test_encoder.py View on Github external
def testDefMode2(self):
        s = univ.SetOf()
        s.append(univ.OctetString('ab'))
        s.append(univ.OctetString('a'))
        assert encoder.encode(s) == ints2octs((49, 128, 4, 1, 97, 4, 2, 97, 98, 0, 0))
github etingof / pyasn1 / tests / codec / ber / test_encoder.py View on Github external
def testEncoder(self):
        assert encoder.encode(self.o) == ints2octs((127, 141, 245, 182, 253, 47, 3, 2, 1, 1))
github jay0lee / GAM / src / pyasn1 / type / univ.py View on Github external
bitNo -= 1
            else:
                bitNo = 7
                r.append(byte)
                byte = 0
            if v in ('0', '1'):
                v = int(v)
            else:
                raise error.PyAsn1Error(
                    'Non-binary OCTET STRING initializer %s' % (v,)
                )
            byte |= v << bitNo

        r.append(byte)

        return octets.ints2octs(r)
github mozilla-services / socorro / webapp-django / vendor-local / lib / python / pyasn1 / type / univ.py View on Github external
def fromHexString(self, value):            
        r = p = ()
        for v in value:
            if p:
                r = r + (int(p+v, 16),)
                p = ()
            else:
                p = v
        if p:
            r = r + (int(p+'0', 16),)
        return octets.ints2octs(r)
github trakt / Plex-Trakt-Scrobbler / Trakttv.bundle / Contents / Libraries / Shared / pyasn1 / type / univ.py View on Github external
def asOctets(self, padding=True):
        """Get BIT STRING as a sequence of octets.

        Parameters
        ----------
        padding: :class:`bool`
            Allow left-padding if BIT STRING length is not a multiples of eight.

        Raises
        ------
        : :py:class:`pyasn1.error.PyAsn1Error`
            If BIT STRING length is not multiples of eight and no padding is allowed.
        """
        return octets.ints2octs(self.asNumbers(padding))
github tp4a / teleport / server / www / packages / packages-windows / x86 / pyasn1 / codec / ber / encoder.py View on Github external
from pyasn1.type import char
from pyasn1.type import tag
from pyasn1.type import univ
from pyasn1.type import useful

__all__ = ['encode']

LOG = debug.registerLoggee(__name__, flags=debug.DEBUG_ENCODER)


class AbstractItemEncoder(object):
    supportIndefLenMode = True

    # An outcome of otherwise legit call `encodeFun(eoo.endOfOctets)`
    eooIntegerSubstrate = (0, 0)
    eooOctetsSubstrate = ints2octs(eooIntegerSubstrate)

    # noinspection PyMethodMayBeStatic
    def encodeTag(self, singleTag, isConstructed):
        tagClass, tagFormat, tagId = singleTag
        encodedTag = tagClass | tagFormat
        if isConstructed:
            encodedTag |= tag.tagFormatConstructed

        if tagId < 31:
            return encodedTag | tagId,

        else:
            substrate = tagId & 0x7f,

            tagId >>= 7