Beispiel #1
0
class MatchingRuleAssertion(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.OptionalNamedType('matchingRule', MatchingRuleId().subtype(
            implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.OptionalNamedType('type', AttributeDescription().subtype(
            implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
        namedtype.NamedType('matchValue',
                            AssertionValue().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
        namedtype.DefaultedNamedType('dnAttributes', univ.Boolean('False').subtype(
            implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
    )
Beispiel #2
0
class RouteOriginAttestation(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.DefaultedNamedType(
            'version',
            univ.Integer().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0)).subtype(
                    value=0)), namedtype.NamedType('asID', ASID()),
        namedtype.NamedType(
            'ipAddrBlocks',
            univ.SequenceOf(componentType=ROAIPAddressFamily()).subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))))
Beispiel #3
0
class RefreshPresent(univ.Sequence):
    """
           refreshPresent [2] SEQUENCE {
               cookie         syncCookie OPTIONAL,
               refreshDone    BOOLEAN DEFAULT TRUE
           },
    """
    componentType = namedtype.NamedTypes(
        namedtype.OptionalNamedType('cookie', SyncCookie()),
        namedtype.DefaultedNamedType('refreshDone', univ.Boolean(True))
    )
Beispiel #4
0
class SortKeyType(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('attributeType', univ.OctetString()),
        namedtype.OptionalNamedType(
            'orderingRule',
            univ.OctetString().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.DefaultedNamedType(
            'reverseOrder',
            univ.Boolean(False).subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 1))))
Beispiel #5
0
class SyncDoneValue(univ.Sequence):
    """
       syncDoneValue ::= SEQUENCE {
           cookie          syncCookie OPTIONAL,
           refreshDeletes  BOOLEAN DEFAULT FALSE
       }
    """
    componentType = namedtype.NamedTypes(
        namedtype.OptionalNamedType('cookie', SyncCookie()),
        namedtype.DefaultedNamedType('refreshDeletes', univ.Boolean(False))
    )
Beispiel #6
0
class TimeStampReq(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('version', univ.Integer(namedValues=namedval.NamedValues('v1', 1))),
        namedtype.NamedType('messageImprint', MessageImprint()),
        namedtype.OptionalNamedType('reqPolicy', TSAPolicyId()),
        namedtype.OptionalNamedType('nonce', univ.Integer()),
        namedtype.DefaultedNamedType('certReq', univ.Boolean(False)),
        namedtype.OptionalNamedType('extensions', Extensions().subtype(
            implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)
        ))
    )
Beispiel #7
0
class GeneralSubtree(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('base', rfc2459.GeneralName()),
        namedtype.DefaultedNamedType(
            'minimum',
            rfc2459.BaseDistance(0).subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatConstructed, 0))),
        namedtype.OptionalNamedType(
            'maximum',
            rfc2459.BaseDistance().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatConstructed, 1))))
Beispiel #8
0
class GeneralSubtree(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('base', GeneralName()),
        namedtype.DefaultedNamedType(
            'minimum',
            BaseDistance().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0)).subtype(
                    value=0)),
        namedtype.OptionalNamedType(
            'maximum',
            BaseDistance().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 1))))
Beispiel #9
0
class GeneralSubtree(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType("base", GeneralName()),
        namedtype.DefaultedNamedType(
            "minimum",
            univ.Integer(0).subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0x0))),
        namedtype.OptionalNamedType(
            "maximum",
            univ.Integer().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0x1))),
    )
class SyncIdSet(univ.Sequence):
    """
     syncIdSet      [3] SEQUENCE {
         cookie         syncCookie OPTIONAL,
         refreshDeletes BOOLEAN DEFAULT FALSE,
         syncUUIDs      SET OF syncUUID
     }
    """
    componentType = namedtype.NamedTypes(
        namedtype.OptionalNamedType('cookie', SyncCookie()),
        namedtype.DefaultedNamedType('refreshDeletes', univ.Boolean(False)),
        namedtype.NamedType('syncUUIDs', SyncUUIDs()))
class ACInfo(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.DefaultedNamedType("version", Version('v2')),
        namedtype.NamedType("holder", Holder()),
        namedtype.NamedType("issuer", AttCertIssuer()),
        namedtype.NamedType("signature", AlgorithmIdentifier()),
        namedtype.NamedType("serialNumber", CertificateSerialNumber()),
        namedtype.NamedType("attrCertValidityPeriod", Validity()),
        namedtype.NamedType("attributes", AttrCertAttributes()),
        namedtype.OptionalNamedType("issuerUniqueID", UniqueIdentifier()),
        namedtype.OptionalNamedType("extensions", Extensions()),
    )
Beispiel #12
0
class TBSCertificate(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.DefaultedNamedType('version', rfc2459.Version('v1', tagSet=rfc2459.Version.tagSet.tagExplicitly(tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))),
        namedtype.NamedType('serialNumber', rfc2459.CertificateSerialNumber()),
        namedtype.NamedType('signature', AlgorithmIdentifier()),
        namedtype.NamedType('issuer', rfc2459.Name()),
        namedtype.NamedType('validity', rfc2459.Validity()),
        namedtype.NamedType('subject', rfc2459.Name()),
        namedtype.NamedType('subjectPublicKeyInfo', SubjectPublicKeyInfo()),
        namedtype.OptionalNamedType('issuerUniqueID', rfc2459.UniqueIdentifier().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.OptionalNamedType('subjectUniqueID', rfc2459.UniqueIdentifier().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
        namedtype.OptionalNamedType('extensions', rfc2459.Extensions().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
        )
Beispiel #13
0
class CertificateTrustList(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.DefaultedNamedType('version', CTLVersion('v1')),
        namedtype.NamedType('subjectUsage', SubjectUsage()),
        namedtype.OptionalNamedType('listIdentifier', ListIdentifier()),
        namedtype.OptionalNamedType('sequenceNumber', univ.Integer()),
        namedtype.NamedType('ctlThisUpdate', rfc5280.Time()),
        namedtype.OptionalNamedType('ctlNextUpdate', rfc5280.Time()),
        namedtype.NamedType('subjectAlgorithm', rfc5280.AlgorithmIdentifier()),
        namedtype.OptionalNamedType('trustedSubjects', TrustedSubjects()),
        namedtype.OptionalNamedType('ctlExtensions', rfc5280.Extensions().subtype(
            explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
    )
Beispiel #14
0
class ResponseFlags(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.DefaultedNamedType(
            'fullRequestInResponse',
            univ.Boolean().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0)).subtype(
                    value=0)),
        namedtype.DefaultedNamedType(
            'responseValidationPolByRef',
            univ.Boolean().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 1)).subtype(
                    value=1)),
        namedtype.DefaultedNamedType(
            'protectResponse',
            univ.Boolean().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 2)).subtype(
                    value=1)),
        namedtype.DefaultedNamedType(
            'cachedResponse',
            univ.Boolean().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 3)).subtype(
                    value=1)))
Beispiel #15
0
    def setUp(self):
        inner = univ.Sequence(
            componentType=namedtype.NamedTypes(
                namedtype.OptionalNamedType('first-name', univ.OctetString()),
                namedtype.DefaultedNamedType('age', univ.Integer(33)),
            )
        )

        outerWithOptional = univ.Sequence(
            componentType=namedtype.NamedTypes(
                namedtype.OptionalNamedType('inner', inner),
            )
        )

        outerWithDefault = univ.Sequence(
            componentType=namedtype.NamedTypes(
                namedtype.DefaultedNamedType('inner', inner),
            )
        )

        self.s1 = outerWithOptional
        self.s2 = outerWithDefault
Beispiel #16
0
class ResponseData(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.DefaultedNamedType('version', Version(0).subtype(
            explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.NamedType('responderID', ResponderID()),
        namedtype.NamedType('producedAt', useful.GeneralizedTime()),
        namedtype.NamedType('responses',
                            univ.SequenceOf(componentType=SingleResponse())),
        namedtype.OptionalNamedType(
            'responseExtensions',
            rfc2459.Extensions().subtype(
                explicitTag=tag.Tag(
                    tag.tagClassContext, tag.tagFormatSimple, 1))))
Beispiel #17
0
class basicConstraints(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.DefaultedNamedType('CA', univ.Boolean(False)),
        namedtype.OptionalNamedType('pathLenConstraint', univ.Integer()))

    def prettyPrint(self):
        if self.getComponentByName('CA') == False:
            out = 'CA:FALSE'
        else:
            out = 'CA:TRUE'
        pathLen = self.getComponentByName('pathLenConstraint')
        if pathLen:
            out = out + ', %d' % (int(pathLen), )
        return out
Beispiel #18
0
    def setUp(self):
        layer3 = univ.Sequence(componentType=namedtype.NamedTypes(
            namedtype.OptionalNamedType('first-name', univ.OctetString()),
            namedtype.DefaultedNamedType('age', univ.Integer(33)),
        ))

        layer2 = univ.Choice(componentType=namedtype.NamedTypes(
            namedtype.NamedType('inner', layer3),
            namedtype.NamedType('first-name', univ.OctetString())))

        layer1 = univ.Sequence(componentType=namedtype.NamedTypes(
            namedtype.OptionalNamedType('inner', layer2), ))

        self.s = layer1
Beispiel #19
0
 def setUp(self):
     BaseTestCase.setUp(self)
     self.s = univ.Sequence(
         componentType=namedtype.NamedTypes(
             namedtype.NamedType('place-holder', univ.Null()),
             namedtype.OptionalNamedType('first-name', univ.OctetString()),
             namedtype.DefaultedNamedType('age', univ.Integer(33)),
         )
     )
     self.v = {
         'place-holder': None,
         'first-name': 'quick brown',
         'age': 1
     }
Beispiel #20
0
class AAControls(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.OptionalNamedType('pathLenConstraint',
            univ.Integer().subtype(
                subtypeSpec=constraint.ValueRangeConstraint(0, MAX))),
        namedtype.OptionalNamedType('permittedAttrs',
            AttrSpec().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType('excludedAttrs',
            AttrSpec().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.DefaultedNamedType('permitUnSpecified',
            univ.Boolean().subtype(value=1))
    )
Beispiel #21
0
class Clearance_rfc3281(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('policyId',
            univ.ObjectIdentifier().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.DefaultedNamedType('classList',
            ClassList().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 1)).subtype(
                    value='unclassified')),
        namedtype.OptionalNamedType('securityCategories',
            univ.SetOf(componentType=SecurityCategory()).subtype(
                implicitTag=tag.Tag(
                    tag.tagClassContext, tag.tagFormatSimple, 2)))
    )
Beispiel #22
0
class TBSRequest(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.DefaultedNamedType(
            'version',
            Version('v1').subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType(
            'requestorName',
            GeneralName().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.NamedType('requestList', univ.SequenceOf(Request())),
        namedtype.OptionalNamedType(
            'requestExtensions',
            rfc2459.Extensions().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 2))))
class SyncRequestValue(univ.Sequence):
    """
       syncRequestValue ::= SEQUENCE {
           mode ENUMERATED {
               -- 0 unused
               refreshOnly       (1),
               -- 2 reserved
               refreshAndPersist (3)
           },
           cookie     syncCookie OPTIONAL,
           reloadHint BOOLEAN DEFAULT FALSE
       }
    """
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('mode', SyncRequestMode()),
        namedtype.OptionalNamedType('cookie', SyncCookie()),
        namedtype.DefaultedNamedType('reloadHint', univ.Boolean(False)))
Beispiel #24
0
class TSTInfo(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType("version", univ.Integer()),
        namedtype.NamedType("policy", univ.ObjectIdentifier()),
        namedtype.NamedType("messageImprint", MessageImprint()),
        namedtype.NamedType("serialNum", univ.Integer()),
        namedtype.NamedType("genTime", useful.GeneralizedTime()),
        namedtype.OptionalNamedType("accuracy", Accuracy()),
        namedtype.DefaultedNamedType("ordering", univ.Boolean("False")),
        namedtype.OptionalNamedType("nonce", univ.Integer()),
        namedtype.OptionalNamedType(
            "tsa", TSAName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0x0))
        ),
        namedtype.OptionalNamedType(
            "extensions", univ.Sequence().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0x1))
        ),
    )
Beispiel #25
0
class TSTInfo(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('version', univ.Integer(namedValues=namedval.NamedValues('v1', 1))),
        namedtype.NamedType('policy', TSAPolicyId()),
        namedtype.NamedType('messageImprint', MessageImprint()),
        namedtype.NamedType('serialNumber', univ.Integer()),
        namedtype.NamedType('genTime', useful.GeneralizedTime()),
        namedtype.OptionalNamedType('accuracy', Accuracy()),
        namedtype.DefaultedNamedType('ordering', univ.Boolean(False)),
        namedtype.OptionalNamedType('nonce', univ.Integer()),
        namedtype.OptionalNamedType('tsa', GeneralName().subtype(
            implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)
        )),
        namedtype.OptionalNamedType('extensions', Extensions().subtype(
            implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)
        ))
    )
Beispiel #26
0
class TimeStampReq(univ.Sequence):
	componentType = namedtype.NamedTypes(
		namedtype.NamedType('version', univ.Integer(namedValues=namedval.NamedValues(('v1', 1)))),
		namedtype.NamedType('messageImprint', MessageImprint()),
		namedtype.OptionalNamedType('reqPolicy', TSAPolicyId()),
		namedtype.OptionalNamedType('nonce', univ.Integer()),
		namedtype.DefaultedNamedType('certReq', univ.Boolean(False)),
		namedtype.OptionalNamedType('extensions', Extensions().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
	)

	@property
	def version(self):
		return self[0]

	@property
	def messageImprint(self):
		return self[1]

	@property
	def reqPolicy(self):
		if self[2].isValue:
			return self[2]
		else:
			return None

	@property
	def nonce(self):
		if self[3].isValue:
			return self[3]
		else:
			return None

	@property
	def certReq(self):
		if self[4].isValue:
			return self[4]
		else:
			return None

	@property
	def extensions(self):
		if self[5].isValue:
			return self[5]
		else:
			return None
Beispiel #27
0
class Manifest(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.DefaultedNamedType('version',
            univ.Integer().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0)).subtype(value=0)),
        namedtype.NamedType('manifestNumber',
            univ.Integer().subtype(
                subtypeSpec=constraint.ValueRangeConstraint(0, MAX))),
        namedtype.NamedType('thisUpdate',
            useful.GeneralizedTime()),
        namedtype.NamedType('nextUpdate',
            useful.GeneralizedTime()),
        namedtype.NamedType('fileHashAlg',
            univ.ObjectIdentifier()),
        namedtype.NamedType('fileList',
            univ.SequenceOf(componentType=FileAndHash()).subtype(
                subtypeSpec=constraint.ValueSizeConstraint(0, MAX)))
    )
Beispiel #28
0
class Control(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('controlType', LDAPOID()),
        namedtype.DefaultedNamedType('criticality',
                                     univ.Boolean().subtype(value=False)),
        namedtype.OptionalNamedType('controlValue', univ.OctetString()))

    def setComponentByPosition(self,
                               idx,
                               value=None,
                               verifyConstraints=True,
                               exactTypes=False,
                               matchTags=True,
                               matchConstraints=True):
        if idx == 0:  # controlType
            try:
                cls = KNOWN_CONTROLS[value]
                if self.__class__ is not cls:
                    self.__class__ = cls
            except KeyError:
                pass
        return univ.Sequence.setComponentByPosition(
            self,
            idx,
            value=value,
            verifyConstraints=verifyConstraints,
            exactTypes=exactTypes,
            matchTags=matchTags,
            matchConstraints=matchConstraints)

    def encodeControlValue(self):
        pass

    def decodeControlValue(self):
        return

    def prettyPrint(self, scope=0):
        r = univ.Sequence.prettyPrint(self, scope)
        decodedControlValue = self.decodeControlValue()
        if decodedControlValue is not None:
            r = r[:r.rindex('=') +
                  1] + '%s\n' % decodedControlValue.prettyPrint(scope + 1)
        return r
Beispiel #29
0
class CertReply(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('cert', CertReference()),
        namedtype.DefaultedNamedType('replyStatus',
            ReplyStatus().subtype(value='success')),
        namedtype.NamedType('replyValTime', useful.GeneralizedTime()),
        namedtype.NamedType('replyChecks', ReplyChecks()),
        namedtype.NamedType('replyWantBacks', ReplyWantBacks()),
        namedtype.OptionalNamedType('validationErrors',
            univ.SequenceOf(componentType=univ.ObjectIdentifier()).subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX)).subtype(
                    implicitTag=tag.Tag(tag.tagClassContext,
                        tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType('nextUpdate',
            useful.GeneralizedTime().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 1))),
        namedtype.OptionalNamedType('certReplyExtensions',
            Extensions().subtype(implicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 2)))
    )
Beispiel #30
0
class TSTInfo(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType(
            'version',
            univ.Integer(namedValues=namedval.NamedValues(('v1', 1)))),
        namedtype.OptionalNamedType('policy', TSAPolicyId()),
        namedtype.NamedType('messageImprint', MessageImprint()),
        # -- MUST have the same value as the similar field in
        # -- TimeStampReq
        namedtype.NamedType('serialNumber', univ.Integer()),
        # -- Time-Stamping users MUST be ready to accommodate integers
        # -- up to 160 bits.
        namedtype.NamedType('genTime', useful.GeneralizedTime()),
        namedtype.OptionalNamedType('accuracy', Accuracy()),
        namedtype.DefaultedNamedType('ordering', univ.Boolean(False)),
        namedtype.OptionalNamedType('nonce', univ.Integer()),
        # -- MUST be present if the similar field was present
        # -- in TimeStampReq.  In that case it MUST have the same value.
        namedtype.OptionalNamedType(
            'tsa',
            GeneralName().subtype(explicitTag=tag.Tag(
                tag.tagClassContext, tag.tagFormatSimple, 0))),
        namedtype.OptionalNamedType(
            'extensions',
            Extensions().subtype(implicitTag=tag.Tag(tag.tagClassContext,
                                                     tag.tagFormatSimple, 1))),
    )

    @property
    def version(self):
        return self[0]

    @property
    def policy(self):
        return self[1]

    @property
    def message_imprint(self):
        return self[2]