Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "pyasn1 in functional component" in Python

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'pyasn1' in functional components in Python. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

Copyright (c) 2016, Maarten Everts
All rights reserved.

This source code has been ported from https://github.com/privacybydesign/gabi
The authors of this file are not -in any way- affiliated with the original authors or organizations.
"""
from cryptography.hazmat.primitives.asymmetric.rsa import _modinv

from pyasn1.codec.ber.encoder import encode
from pyasn1.type import univ

from ...primitives.attestation import sha256_as_int
from ...primitives.value import FP2Value


class Record(univ.SequenceOf):
    componentType = univ.Integer()


def custom_asn1_marshal(values):
    return encode(values, asn1Spec=Record())


def hashCommit(values, issig):
    tmp = [True] if issig else []
    tmp = tmp + [len(values)] + values
    r = custom_asn1_marshal(tmp)
    if issig:
        indx = r.find(b'\x02\x01\x01')
        r = r[:indx] + b'\x01\x01\xFF' + r[indx + 3:]
    return sha256_as_int(r)
g.setComponentByName(
        'gocbRef',
        'DENNY_11F_13_100CFG/LLN0$GO$Dset_SubnetCtrl'
    )
    g.setComponentByName('timeAllowedtoLive', 2000)
    g.setComponentByName('datSet', 'DENNY_11F_13_100CFG/LLN0$G_NetCtrl')
    g.setComponentByName('goID', '11F_13_100Dset_SubnetCtrl')
    g.setComponentByName('t', b'\x5a\xaa\xe0\xa4\x6f\xf3\x5e\x92')
    g.setComponentByName('stNum', 96)
    g.setComponentByName('sqNum', 16192)
    g.setComponentByName('test', False)
    g.setComponentByName('confRev', 2)
    g.setComponentByName('ndsCom', False)
    g.setComponentByName('numDatSetEntries', 5)
    all_data = AllData().subtype(
        implicitTag=tag.Tag(
            tag.tagClassContext,
            tag.tagFormatConstructed,
            11
        )
    )
    inner1 = univ.SequenceOf(componentType=Data()).subtype(
        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)
    )
    inner1.setComponentByPosition(0, Data().setComponentByName("boolean", False))
    inner1.setComponentByPosition(1, Data().setComponentByName("bit-string", "'0000000000000'B"))
    inner1.setComponentByPosition(2, Data().setComponentByName('utc-time', b'\x5a\xaa\xe0\xa4\x6f\xf3\x5e\x92'))
    data1 = Data()
    data1.setComponentByName('structure', inner1)
    inner2 = univ.SequenceOf(componentType=Data()).subtype(
        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)
    )
def testIter(self):
        n, t = self.e
        assert n == 'age' or t == univ.Integer(), 'unpack fails'
def testSchemaWithOptionalComponents(self):

        class Sequence(univ.Sequence):
            componentType = namedtype.NamedTypes(
                namedtype.OptionalNamedType('name', univ.OctetString())
            )

        s = Sequence()

        assert s.isValue

        s[0] = 'test'

        assert s.isValue

        s.clear()

        assert s.isValue

        s.reset()
def setUp(self):
        BaseTestCase.setUp(self)
        self.o = univ.OctetString('Quick brown fox')
def testEdge9(self):
        # 10001000|10000100|10000111|0000010
        assert encoder.encode(
            univ.ObjectIdentifier((2, 16843570))
        ) == ints2octs((6, 4, 0x88, 0x84, 0x87, 0x02))
def setUp(self):
        BaseTestCase.setUp(self)

        self.o = univ.Integer().subtype(
            value=1, explicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0xdeadbeaf)
        )
def testLegacyInitializer(self):
        n = univ.SequenceOf(
            componentType=univ.OctetString()
        )
        o = univ.SequenceOf(
            univ.OctetString()  # this is the old way
        )

        assert n.isSameTypeWith(o) and o.isSameTypeWith(n)

        n[0] = 'fox'
        o[0] = 'fox'

        assert n == o
def testIndefModeChunked(self):
        s = univ.SequenceOf()
        s.setComponentByPosition(0, univ.OctetString('quick brown'))
        assert encoder.encode(
            s, defMode=False, maxChunkSize=4
        ) == ints2octs((48, 128, 36, 128, 4, 4, 113, 117, 105, 99, 4, 4, 107, 32, 98, 114, 4, 3, 111, 119, 110, 0, 0, 0, 0))
def testDontDecodeOpenTypesChoiceOne(self):
        s, r = decoder.decode(
            ints2octs((48, 6, 2, 1, 1, 2, 1, 12)), asn1Spec=self.s
        )
        assert not r
        assert s[0] == 1
        assert s[1] == ints2octs((2, 1, 12))

Is your System Free of Underlying Vulnerabilities?
Find Out Now