Exemplo n.º 1
0
    return univ.ObjectIdentifier(output)


unformatted_postal_address = univ.Integer(16)

ub_organizational_units = univ.Integer(4)

ub_organizational_unit_name_length = univ.Integer(32)


class OrganizationalUnitName(char.PrintableString):
    pass


OrganizationalUnitName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)


class OrganizationalUnitNames(univ.SequenceOf):
    pass


OrganizationalUnitNames.componentType = OrganizationalUnitName()
OrganizationalUnitNames.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_units)


class AttributeType(univ.ObjectIdentifier):
    pass


id_at = _OID(2, 5, 4)
Exemplo n.º 2
0
 def setUp(self):
     BaseTestCase.setUp(self)
     self.c1 = constraint.ValueSizeConstraint(1, 2)
Exemplo n.º 3
0
    IpAddress()).setMaxAccess('readwrite').setDescription(
        "Used to modify the managed object's Default Gateway IP \nAddress.")
panduitNetIPSetConfig = MibScalar(
    (1, 3, 6, 1, 4, 1, 19536, 2, 2, 1, 9), PanduitSetType()
).setMaxAccess('readwrite').setDescription(
    'Setting to request(2) will change Current IP Address values \nusing the Config IP Address Values.  Additionaly, reports on the \nstatus of the change.'
)
panduitNetIPSetCommit = MibScalar(
    (1, 3, 6, 1, 4, 1, 19536, 2, 2, 1, 10), PanduitSetType()
).setMaxAccess('readwrite').setDescription(
    'Setting to request(2) will make the Current IP Address values\npermanent.  This is required after changin the IP Address values\nusing panduitSetIpConfig.  If this is not done, a reboot of the\nmanaged object will cause the IP Address Values to revert to\ntheir last committed values.'
)
panduitNetSNMP = MibIdentifier((1, 3, 6, 1, 4, 1, 19536, 2, 2, 2))
panduitNetSNMPReadCommunity = MibScalar(
    (1, 3, 6, 1, 4, 1, 19536, 2, 2, 2, 1),
    DisplayString().subtype(subtypeSpec=constraint.ValueSizeConstraint(
        0, 255))).setMaxAccess('readwrite').setDescription(
            "The managed object's Read Community String.")
panduitNetSNMPWriteCommunity = MibScalar(
    (1, 3, 6, 1, 4, 1, 19536, 2, 2, 2, 2),
    DisplayString().subtype(subtypeSpec=constraint.ValueSizeConstraint(0, 255))
).setMaxAccess('readwrite').setDescription(
    "The managed object's Write Community String.  Access to this \nvalue is granted only when the write community string is specified \nin the SNMP operation."
)
panduitNetSNMPTrap = MibIdentifier((1, 3, 6, 1, 4, 1, 19536, 2, 2, 2, 3))
panduitNetSNMPTrapConfigRecvNum = MibScalar(
    (1, 3, 6, 1, 4, 1, 19536, 2, 2, 2, 3, 1), Integer32()
).setMaxAccess('readonly').setDescription(
    "The number of Trap receiver's allowed by the managed object.\nThis table does not support row creation."
)
panduitNetSNMPTrapRecvTable = MibTable(
    (1, 3, 6, 1, 4, 1, 19536, 2, 2, 2, 3, 2)
class Camellia_IV(univ.OctetString):
    subtypeSpec = constraint.ValueSizeConstraint(16, 16)
Exemplo n.º 5
0
class TimeStampTokenEvidence(univ.SequenceOf):
    componentType = TimeStampAndCRL()
    subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
Exemplo n.º 6
0
class PKIHeader(univ.Sequence):
    """
    PKIHeader ::= SEQUENCE {
    pvno                INTEGER     { cmp1999(1), cmp2000(2) },
    sender              GeneralName,
    recipient           GeneralName,
    messageTime     [0] GeneralizedTime         OPTIONAL,
    protectionAlg   [1] AlgorithmIdentifier     OPTIONAL,
    senderKID       [2] KeyIdentifier           OPTIONAL,
    recipKID        [3] KeyIdentifier           OPTIONAL,
    transactionID   [4] OCTET STRING            OPTIONAL,
    senderNonce     [5] OCTET STRING            OPTIONAL,
    recipNonce      [6] OCTET STRING            OPTIONAL,
    freeText        [7] PKIFreeText             OPTIONAL,
    generalInfo     [8] SEQUENCE SIZE (1..MAX) OF
                     InfoTypeAndValue     OPTIONAL
    }

    """
    componentType = namedtype.NamedTypes(
        namedtype.NamedType(
            'pvno',
            univ.Integer(
                namedValues=namedval.NamedValues(('cmp1999', 1), ('cmp2000',
                                                                  2)))),
        namedtype.NamedType('sender', rfc2459.GeneralName()),
        namedtype.NamedType('recipient', rfc2459.GeneralName()),
        namedtype.OptionalNamedType(
            'messageTime',
            useful.GeneralizedTime().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType(
            'protectionAlg',
            rfc2459.AlgorithmIdentifier().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatConstructed, 1))),
        namedtype.OptionalNamedType(
            'senderKID',
            rfc2459.KeyIdentifier().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 2))),
        namedtype.OptionalNamedType(
            'recipKID',
            rfc2459.KeyIdentifier().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 3))),
        namedtype.OptionalNamedType(
            'transactionID',
            univ.OctetString().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 4))),
        namedtype.OptionalNamedType(
            'senderNonce',
            univ.OctetString().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 5))),
        namedtype.OptionalNamedType(
            'recipNonce',
            univ.OctetString().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 6))),
        namedtype.OptionalNamedType(
            'freeText',
            PKIFreeText().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatConstructed, 7))),
        namedtype.OptionalNamedType(
            'generalInfo',
            univ.SequenceOf(componentType=InfoTypeAndValue().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX),
                explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple,
                                    8)))))
Exemplo n.º 7
0
                                'type', certificateAttributesMap)))


class Attributes(univ.SetOf):
    pass


Attributes.componentType = Attribute()


class RelativeDistinguishedName(univ.SetOf):
    pass


RelativeDistinguishedName.componentType = AttributeTypeAndValue()
RelativeDistinguishedName.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)


class RDNSequence(univ.SequenceOf):
    pass


RDNSequence.componentType = RelativeDistinguishedName()


class Name(univ.Choice):
    pass


Name.componentType = namedtype.NamedTypes(
    namedtype.NamedType('rdnSequence', RDNSequence()))
Exemplo n.º 8
0
class Choice(Set):
    tagSet = baseTagSet = tag.TagSet()  # untagged
    sizeSpec = constraint.ConstraintsIntersection(
        constraint.ValueSizeConstraint(1, 1))
    typeId = 5
    _currentIdx = None

    def __eq__(self, other):
        if self._componentValues:
            return self._componentValues[self._currentIdx] == other
        return NotImplemented

    def __ne__(self, other):
        if self._componentValues:
            return self._componentValues[self._currentIdx] != other
        return NotImplemented

    def __lt__(self, other):
        if self._componentValues:
            return self._componentValues[self._currentIdx] < other
        return NotImplemented

    def __le__(self, other):
        if self._componentValues:
            return self._componentValues[self._currentIdx] <= other
        return NotImplemented

    def __gt__(self, other):
        if self._componentValues:
            return self._componentValues[self._currentIdx] > other
        return NotImplemented

    def __ge__(self, other):
        if self._componentValues:
            return self._componentValues[self._currentIdx] >= other
        return NotImplemented

    if sys.version_info[0] <= 2:

        def __nonzero__(self):
            return bool(self._componentValues)
    else:

        def __bool__(self):
            return bool(self._componentValues)

    def __len__(self):
        return self._currentIdx is not None and 1 or 0

    def verifySizeSpec(self):
        if self._currentIdx is None:
            raise error.PyAsn1Error('Component not chosen')
        else:
            self._sizeSpec(' ')

    def _cloneComponentValues(self, myClone, cloneValueFlag):
        try:
            c = self.getComponent()
        except error.PyAsn1Error:
            pass
        else:
            if isinstance(c, Choice):
                tagSet = c.getEffectiveTagSet()
            else:
                tagSet = c.getTagSet()
            if isinstance(c, base.AbstractConstructedAsn1Item):
                myClone.setComponentByType(
                    tagSet, c.clone(cloneValueFlag=cloneValueFlag))
            else:
                myClone.setComponentByType(tagSet, c.clone())

    def setComponentByPosition(self, idx, value=None, verifyConstraints=True):
        l = len(self._componentValues)
        if idx >= l:
            self._componentValues = self._componentValues + (idx - l +
                                                             1) * [None]
        if self._currentIdx is not None:
            self._componentValues[self._currentIdx] = None
        if value is None:
            if self._componentValues[idx] is None:
                self._componentValues[
                    idx] = self._componentType.getTypeByPosition(idx).clone()
                self._componentValuesSet = 1
                self._currentIdx = idx
            return self
        elif not isinstance(value, base.Asn1Item):
            value = self._componentType.getTypeByPosition(idx).clone(
                value=value)
        if verifyConstraints:
            if self._componentTypeLen:
                self._verifyComponent(idx, value)
            self._verifySubtypeSpec(value, idx)
        self._componentValues[idx] = value
        self._currentIdx = idx
        self._componentValuesSet = 1
        return self

    def getMinTagSet(self):
        if self._tagSet:
            return self._tagSet
        else:
            return self._componentType.genMinTagSet()

    def getEffectiveTagSet(self):
        if self._tagSet:
            return self._tagSet
        else:
            c = self.getComponent()
            if isinstance(c, Choice):
                return c.getEffectiveTagSet()
            else:
                return c.getTagSet()

    def getTagMap(self):
        if self._tagSet:
            return Set.getTagMap(self)
        else:
            return Set.getComponentTagMap(self)

    def getComponent(self, innerFlag=0):
        if self._currentIdx is None:
            raise error.PyAsn1Error('Component not chosen')
        else:
            c = self._componentValues[self._currentIdx]
            if innerFlag and isinstance(c, Choice):
                return c.getComponent(innerFlag)
            else:
                return c

    def getName(self, innerFlag=0):
        if self._currentIdx is None:
            raise error.PyAsn1Error('Component not chosen')
        else:
            if innerFlag:
                c = self._componentValues[self._currentIdx]
                if isinstance(c, Choice):
                    return c.getName(innerFlag)
            return self._componentType.getNameByPosition(self._currentIdx)

    def setDefaultComponents(self):
        pass
Exemplo n.º 9
0
    namedtype.NamedType('parBitLockRequired', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.NamedType('parameterName', ParameterName()),
        namedtype.NamedType('parameterValue', univ.Integer().subtype(namedValues=namedval.NamedValues(
            ('yes', 0),
            ('no', 1)
        )))
    )).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),

    namedtype.NamedType('parGlobalVcId', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.NamedType('parameterName', ParameterName()),
        namedtype.NamedType('parameterValue', GvcId())
    )).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),

    namedtype.NamedType('parClcwPhysicalChannel', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.NamedType('parameterName', ParameterName()),
        namedtype.NamedType('parameterValue',  char.VisibleString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 32)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
    )).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3))),

    namedtype.NamedType('parDeliveryMode', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.NamedType('parameterName', ParameterName()),
        namedtype.NamedType('parameterValue', CltuDeliveryMode())
    )).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4))),

    namedtype.NamedType('parCltuIdentification', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.NamedType('parameterName', ParameterName()),
        namedtype.NamedType('parameterValue', CltuIdentification())
    )).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),

    namedtype.NamedType('parEventInvocationIdentification', univ.Sequence(componentType=namedtype.NamedTypes(
        namedtype.NamedType('parameterName', ParameterName()),
        namedtype.NamedType('parameterValue', CltuIdentification())
Exemplo n.º 10
0
IPAddressChoice.componentType = namedtype.NamedTypes(
    namedtype.NamedType('inherit', univ.Null()),
    namedtype.NamedType('addressesOrRanges',
                        univ.SequenceOf(componentType=IPAddressOrRange())))


class IPAddressFamily(univ.Sequence):
    pass


IPAddressFamily.componentType = namedtype.NamedTypes(
    namedtype.NamedType(
        'addressFamily',
        univ.OctetString().subtype(
            subtypeSpec=constraint.ValueSizeConstraint(2, 3))),
    namedtype.NamedType('ipAddressChoice', IPAddressChoice()))


class IPAddrBlocks(univ.SequenceOf):
    pass


IPAddrBlocks.componentType = IPAddressFamily()

# Autonomous System Identifier Delegation Extension

id_pe_autonomousSysIds = univ.ObjectIdentifier('1.3.6.1.5.5.7.1.8')


class ASId(univ.Integer):
        else:
            output.append(int(x))

    return univ.ObjectIdentifier(output)


class JWTClaimName(char.IA5String):
    pass


class JWTClaimNames(univ.SequenceOf):
    pass


JWTClaimNames.componentType = JWTClaimName()
JWTClaimNames.sizeSpec = constraint.ValueSizeConstraint(1, MAX)


class JWTClaimPermittedValues(univ.Sequence):
    pass


JWTClaimPermittedValues.componentType = namedtype.NamedTypes(
    namedtype.NamedType('claim', JWTClaimName()),
    namedtype.NamedType(
        'permitted',
        univ.SequenceOf(componentType=char.UTF8String()).subtype(
            sizeSpec=constraint.ValueSizeConstraint(1, MAX))))


class JWTClaimPermittedValuesList(univ.SequenceOf):
Exemplo n.º 12
0
class _GeneralNames(univ.SequenceOf):
    componentType = _GeneralName()
    sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(
        1, 1024)
Exemplo n.º 13
0
class IpAddress(univ.OctetString):
    tagSet = univ.OctetString.tagSet.tagImplicitly(
        tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x00))
    subtypeSpec = univ.OctetString.subtypeSpec + constraint.ValueSizeConstraint(
        4, 4)
Exemplo n.º 14
0
class OctetString(univ.OctetString):
    subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueSizeConstraint(
        0, 65535)
Exemplo n.º 15
0
class Extensions(univ.SequenceOf):
    componentType = Extension()
    sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
Exemplo n.º 16
0
class TrustAnchors(univ.SequenceOf):
    componentType = PKCReference()
    subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
Exemplo n.º 17
0
class KeySpecificInfo(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('algorithm', univ.ObjectIdentifier()),
        namedtype.NamedType('counter', univ.OctetString().subtype(
            subtypeSpec=constraint.ValueSizeConstraint(4, 4)))
    )
Exemplo n.º 18
0
class RevocationInfos(univ.SequenceOf):
    componentType = RevocationInfo()
    subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
Exemplo n.º 19
0
# Extended Key Usage Values

id_kp_eapOverLAN = univ.ObjectIdentifier('1.3.6.1.5.5.7.3.14')

id_kp_eapOverPPP = univ.ObjectIdentifier('1.3.6.1.5.5.7.3.13')


# Wireless LAN SSID Extension

id_pe_wlanSSID = univ.ObjectIdentifier('1.3.6.1.5.5.7.1.13')


class SSID(univ.OctetString):
    pass

SSID.subtypeSpec = constraint.ValueSizeConstraint(1, 32)


class SSIDList(univ.SequenceOf):
    pass

SSIDList.componentType = SSID()
SSIDList.subtypeSpec=constraint.ValueSizeConstraint(1, MAX)


# Wireless LAN SSID Attribute Certificate Attribute
# Uses same syntax as the certificate extension: SSIDList
# Correction for https://www.rfc-editor.org/errata/eid234

id_aca_wlanSSID = univ.ObjectIdentifier('1.3.6.1.5.5.7.10.7')
Exemplo n.º 20
0
class WantBack(univ.SequenceOf):
    componentType = univ.ObjectIdentifier()
    subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
Exemplo n.º 21
0
class Attribute(univ.Sequence):
    pass


Attribute.componentType = namedtype.NamedTypes(
    namedtype.NamedType('attrType', univ.ObjectIdentifier()),
    namedtype.NamedType('attrValues',
                        univ.SetOf(componentType=AttributeValue())))


class SignedAttributes(univ.SetOf):
    pass


SignedAttributes.componentType = Attribute()
SignedAttributes.sizeSpec = constraint.ValueSizeConstraint(1, MAX)


class OtherRevocationInfoFormat(univ.Sequence):
    pass


OtherRevocationInfoFormat.componentType = namedtype.NamedTypes(
    namedtype.NamedType('otherRevInfoFormat', univ.ObjectIdentifier()),
    namedtype.NamedType('otherRevInfo', univ.Any()))


class RevocationInfoChoice(univ.Choice):
    pass

Exemplo n.º 22
0
class ReplyObjects(univ.SequenceOf):
    componentType = CertReply()
    subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
Exemplo n.º 23
0
class Attributes(univ.SetOf):
    componentType = Attribute()
    subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
Exemplo n.º 24
0
class CertBundles(univ.SequenceOf):
    componentType = CertBundle()
    subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
Exemplo n.º 25
0
class syncUUID(univ.OctetString):
    subtypeSpec = constraint.ValueSizeConstraint(16, 16)
Exemplo n.º 26
0
# License: http://snmplabs.com/pyasn1/license.html
#
# ChaCha20Poly1305 algorithm fo use with the Authenticated-Enveloped-Data
# protecting content type for the Cryptographic Message Syntax (CMS)
#
# ASN.1 source from:
# https://www.rfc-editor.org/rfc/rfc8103.txt

from pyasn1.type import constraint
from pyasn1.type import univ


def _OID(*components):
    output = []
    for x in tuple(components):
        if isinstance(x, univ.ObjectIdentifier):
            output.extend(list(x))
        else:
            output.append(int(x))

    return univ.ObjectIdentifier(output)


class AEADChaCha20Poly1305Nonce(univ.OctetString):
    pass


AEADChaCha20Poly1305Nonce.subtypeSpec = constraint.ValueSizeConstraint(12, 12)

id_alg_AEADChaCha20Poly1305 = _OID(1, 2, 840, 113549, 1, 9, 16, 3, 18)
Exemplo n.º 27
0
class DnsName(OctetString):
    subtypeSpec = OctetString.subtypeSpec + constraint.ValueSizeConstraint(
        0, 255)
    pass
Exemplo n.º 28
0

# SingleAttribute is the same as Attribute in RFC 5652, except that the
# attrValues SET must have one and only one member

Attribute = rfc7191.SingleAttribute


# DirectoryString is the same as RFC 5280, except the length is limited to 255

class DirectoryString(univ.Choice):
    pass

DirectoryString.componentType = namedtype.NamedTypes(
    namedtype.NamedType('teletexString', char.TeletexString().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
    namedtype.NamedType('printableString', char.PrintableString().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
    namedtype.NamedType('universalString', char.UniversalString().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
    namedtype.NamedType('utf8String', char.UTF8String().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
    namedtype.NamedType('bmpString', char.BMPString().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, 255)))
)


# OTP Challenge Attribute

id_aa_otpChallenge = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.56')
Exemplo n.º 29
0
class VarBindList(univ.SequenceOf):
    componentType = VarBind()
    subtypeSpec = univ.SequenceOf.subtypeSpec + constraint.ValueSizeConstraint(
        0, max_bindings
    )
Exemplo n.º 30
0
class EncodingParameters(univ.OctetString):
    subtypeSpec = constraint.ValueSizeConstraint(0, MAX)