Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
rfc5275.py405 linesDownload Raw Back to pyasn1_modules
1#2# This file is part of pyasn1-modules software.3#4# Created by Russ Housley with assistance from asn1ate v.0.6.0.5#6# Copyright (c) 2019, Vigil Security, LLC7# License: http://snmplabs.com/pyasn1/license.html8#9# An Internet Attribute Certificate Profile for Authorization10#11# ASN.1 source from:12# https://www.rfc-editor.org/rfc/rfc5275.txt13#14 15from pyasn1.type import constraint16from pyasn1.type import namedtype17from pyasn1.type import namedval18from pyasn1.type import opentype19from pyasn1.type import tag20from pyasn1.type import univ21from pyasn1.type import useful22 23from pyasn1_modules import rfc356524from pyasn1_modules import rfc528025from pyasn1_modules import rfc565226from pyasn1_modules import rfc575127from pyasn1_modules import rfc575528 29MAX = float('inf')30 31 32# Initialize the map for GLAQueryRequests and GLAQueryResponses33 34glaQueryRRMap = { }35 36 37# Imports from RFC 356538 39id_aes128_wrap = rfc3565.id_aes128_wrap40 41 42# Imports from RFC 528043 44AlgorithmIdentifier = rfc5280.AlgorithmIdentifier45 46Certificate = rfc5280.Certificate47 48GeneralName = rfc5280.GeneralName49 50 51# Imports from RFC 565252 53CertificateSet = rfc5652.CertificateSet54 55KEKIdentifier = rfc5652.KEKIdentifier56 57RecipientInfos = rfc5652.RecipientInfos58 59 60# Imports from RFC 575161 62SMIMECapability = rfc5751.SMIMECapability63 64 65# Imports from RFC 575566 67AttributeCertificate = rfc5755.AttributeCertificate68 69 70# The GL symmetric key distribution object identifier arc71 72id_skd = univ.ObjectIdentifier((1, 2, 840, 113549, 1, 9, 16, 8,))73 74 75# The GL Use KEK control attribute76 77id_skd_glUseKEK = id_skd + (1,)78 79 80class Certificates(univ.Sequence):81    componentType = namedtype.NamedTypes(82        namedtype.OptionalNamedType('pKC',83            Certificate().subtype(implicitTag=tag.Tag(84                tag.tagClassContext, tag.tagFormatSimple, 0))),85        namedtype.OptionalNamedType('aC',86            univ.SequenceOf(componentType=AttributeCertificate()).subtype(87                subtypeSpec=constraint.ValueSizeConstraint(1, MAX)).subtype(88                    implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),89        namedtype.OptionalNamedType('certPath',90            CertificateSet().subtype(implicitTag=tag.Tag(91                tag.tagClassContext, tag.tagFormatSimple, 2)))92    )93 94 95class GLInfo(univ.Sequence):96    componentType = namedtype.NamedTypes(97        namedtype.NamedType('glName', GeneralName()),98        namedtype.NamedType('glAddress', GeneralName())99    )100 101 102class GLOwnerInfo(univ.Sequence):103    componentType = namedtype.NamedTypes(104        namedtype.NamedType('glOwnerName', GeneralName()),105        namedtype.NamedType('glOwnerAddress', GeneralName()),106        namedtype.OptionalNamedType('certificates', Certificates())107    )108 109 110class GLAdministration(univ.Integer):111    namedValues = namedval.NamedValues(112        ('unmanaged', 0),113        ('managed', 1),114        ('closed', 2)115    )116 117 118requested_algorithm = SMIMECapability().subtype(119   implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))120requested_algorithm['capabilityID'] = id_aes128_wrap121 122 123class GLKeyAttributes(univ.Sequence):124    componentType = namedtype.NamedTypes(125        namedtype.DefaultedNamedType('rekeyControlledByGLO',126            univ.Boolean().subtype(value=0,127                implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),128        namedtype.DefaultedNamedType('recipientsNotMutuallyAware',129            univ.Boolean().subtype(value=1,130                implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),131        namedtype.DefaultedNamedType('duration',132            univ.Integer().subtype(value=0,133                implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),134        namedtype.DefaultedNamedType('generationCounter',135            univ.Integer().subtype(value=2,136                implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),137        namedtype.DefaultedNamedType('requestedAlgorithm', requested_algorithm)138    )139 140 141class GLUseKEK(univ.Sequence):142    componentType = namedtype.NamedTypes(143        namedtype.NamedType('glInfo', GLInfo()),144        namedtype.NamedType('glOwnerInfo',145            univ.SequenceOf(componentType=GLOwnerInfo()).subtype(146                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),147        namedtype.DefaultedNamedType('glAdministration',148            GLAdministration().subtype(value=1)),149        namedtype.OptionalNamedType('glKeyAttributes', GLKeyAttributes())150    )151 152 153# The Delete GL control attribute154 155id_skd_glDelete = id_skd + (2,)156 157 158class DeleteGL(GeneralName):159    pass160 161 162# The Add GL Member control attribute163 164id_skd_glAddMember = id_skd + (3,)165 166 167class GLMember(univ.Sequence):168    componentType = namedtype.NamedTypes(169        namedtype.NamedType('glMemberName', GeneralName()),170        namedtype.OptionalNamedType('glMemberAddress', GeneralName()),171        namedtype.OptionalNamedType('certificates', Certificates())172    )173 174 175class GLAddMember(univ.Sequence):176    componentType = namedtype.NamedTypes(177        namedtype.NamedType('glName', GeneralName()),178        namedtype.NamedType('glMember', GLMember())179    )180 181 182# The Delete GL Member control attribute183 184id_skd_glDeleteMember = id_skd + (4,)185 186 187class GLDeleteMember(univ.Sequence):188    componentType = namedtype.NamedTypes(189        namedtype.NamedType('glName', GeneralName()),190        namedtype.NamedType('glMemberToDelete', GeneralName())191    )192 193 194# The GL Rekey control attribute195 196id_skd_glRekey = id_skd + (5,)197 198 199class GLNewKeyAttributes(univ.Sequence):200    componentType = namedtype.NamedTypes(201        namedtype.OptionalNamedType('rekeyControlledByGLO',202            univ.Boolean().subtype(implicitTag=tag.Tag(203                tag.tagClassContext, tag.tagFormatSimple, 0))),204        namedtype.OptionalNamedType('recipientsNotMutuallyAware',205            univ.Boolean().subtype(implicitTag=tag.Tag(206                tag.tagClassContext, tag.tagFormatSimple, 1))),207        namedtype.OptionalNamedType('duration',208            univ.Integer().subtype(implicitTag=tag.Tag(209                tag.tagClassContext, tag.tagFormatSimple, 2))),210        namedtype.OptionalNamedType('generationCounter',211            univ.Integer().subtype(implicitTag=tag.Tag(212                tag.tagClassContext, tag.tagFormatSimple, 3))),213        namedtype.OptionalNamedType('requestedAlgorithm',214            AlgorithmIdentifier().subtype(implicitTag=tag.Tag(215                tag.tagClassContext, tag.tagFormatSimple, 4)))216    )217 218 219class GLRekey(univ.Sequence):220    componentType = namedtype.NamedTypes(221        namedtype.NamedType('glName', GeneralName()),222        namedtype.OptionalNamedType('glAdministration', GLAdministration()),223        namedtype.OptionalNamedType('glNewKeyAttributes', GLNewKeyAttributes()),224        namedtype.OptionalNamedType('glRekeyAllGLKeys', univ.Boolean())225    )226 227 228# The Add and Delete GL Owner control attributes229 230id_skd_glAddOwner = id_skd + (6,)231 232id_skd_glRemoveOwner = id_skd + (7,)233 234 235class GLOwnerAdministration(univ.Sequence):236    componentType = namedtype.NamedTypes(237        namedtype.NamedType('glName', GeneralName()),238        namedtype.NamedType('glOwnerInfo', GLOwnerInfo())239    )240 241 242# The GL Key Compromise control attribute243 244id_skd_glKeyCompromise = id_skd + (8,)245 246 247class GLKCompromise(GeneralName):248    pass249 250 251# The GL Key Refresh control attribute252 253id_skd_glkRefresh = id_skd + (9,)254 255 256class Date(univ.Sequence):257    componentType = namedtype.NamedTypes(258        namedtype.NamedType('start', useful.GeneralizedTime()),259        namedtype.OptionalNamedType('end', useful.GeneralizedTime())260    )261 262 263class GLKRefresh(univ.Sequence):264    componentType = namedtype.NamedTypes(265        namedtype.NamedType('glName', GeneralName()),266        namedtype.NamedType('dates',267            univ.SequenceOf(componentType=Date()).subtype(268                subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))269    )270 271 272# The GLA Query Request control attribute273 274id_skd_glaQueryRequest = id_skd + (11,)275 276 277class GLAQueryRequest(univ.Sequence):278    componentType = namedtype.NamedTypes(279        namedtype.NamedType('glaRequestType', univ.ObjectIdentifier()),280        namedtype.NamedType('glaRequestValue', univ.Any(),281            openType=opentype.OpenType('glaRequestType', glaQueryRRMap))282    )283 284 285# The GLA Query Response control attribute286 287id_skd_glaQueryResponse = id_skd + (12,)288 289 290class GLAQueryResponse(univ.Sequence):291    componentType = namedtype.NamedTypes(292        namedtype.NamedType('glaResponseType', univ.ObjectIdentifier()),293        namedtype.NamedType('glaResponseValue', univ.Any(),294            openType=opentype.OpenType('glaResponseType', glaQueryRRMap))295    )296 297 298# The GLA Request/Response (glaRR) arc for glaRequestType/glaResponseType299 300id_cmc_glaRR = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 7, 99,))301 302 303# The Algorithm Request304 305id_cmc_gla_skdAlgRequest = id_cmc_glaRR + (1,)306 307 308class SKDAlgRequest(univ.Null):309    pass310 311 312# The Algorithm Response313 314id_cmc_gla_skdAlgResponse = id_cmc_glaRR + (2,)315 316SMIMECapabilities = rfc5751.SMIMECapabilities317 318 319# The control attribute to request an updated certificate to the GLA and320# the control attribute to return an updated certificate to the GLA321 322id_skd_glProvideCert = id_skd + (13,)323 324id_skd_glManageCert = id_skd + (14,)325 326 327class GLManageCert(univ.Sequence):328    componentType = namedtype.NamedTypes(329        namedtype.NamedType('glName', GeneralName()),330        namedtype.NamedType('glMember', GLMember())331    )332 333 334# The control attribute to distribute the GL shared KEK335 336id_skd_glKey = id_skd + (15,)337 338 339class GLKey(univ.Sequence):340    componentType = namedtype.NamedTypes(341        namedtype.NamedType('glName', GeneralName()),342        namedtype.NamedType('glIdentifier', KEKIdentifier()),343        namedtype.NamedType('glkWrapped', RecipientInfos()),344        namedtype.NamedType('glkAlgorithm', AlgorithmIdentifier()),345        namedtype.NamedType('glkNotBefore', useful.GeneralizedTime()),346        namedtype.NamedType('glkNotAfter', useful.GeneralizedTime())347    )348 349 350# The CMC error types351 352id_cet_skdFailInfo = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 15, 1,))353 354 355class SKDFailInfo(univ.Integer):356    namedValues = namedval.NamedValues(357        ('unspecified', 0),358        ('closedGL', 1),359        ('unsupportedDuration', 2),360        ('noGLACertificate', 3),361        ('invalidCert', 4),362        ('unsupportedAlgorithm', 5),363        ('noGLONameMatch', 6),364        ('invalidGLName', 7),365        ('nameAlreadyInUse', 8),366        ('noSpam', 9),367        ('alreadyAMember', 11),368        ('notAMember', 12),369        ('alreadyAnOwner', 13),370        ('notAnOwner', 14)371    )372 373 374# Update the map for GLAQueryRequests and GLAQueryResponses375 376_glaQueryRRMapUpdate = {377    id_cmc_gla_skdAlgRequest: univ.Null(""),378    id_cmc_gla_skdAlgResponse: SMIMECapabilities(),379}380 381glaQueryRRMap.update(_glaQueryRRMapUpdate)382 383 384# Update the map for CMC control attributes; since CMS Attributes and385# CMC Controls both use 'attrType', one map is used for both386 387_cmcControlAttributesMapUpdate = {388    id_skd_glUseKEK: GLUseKEK(),389    id_skd_glDelete: DeleteGL(),390    id_skd_glAddMember: GLAddMember(),391    id_skd_glDeleteMember: GLDeleteMember(),392    id_skd_glRekey: GLRekey(),393    id_skd_glAddOwner: GLOwnerAdministration(),394    id_skd_glRemoveOwner: GLOwnerAdministration(),395    id_skd_glKeyCompromise: GLKCompromise(),396    id_skd_glkRefresh: GLKRefresh(),397    id_skd_glaQueryRequest: GLAQueryRequest(),398    id_skd_glaQueryResponse: GLAQueryResponse(),399    id_skd_glProvideCert: GLManageCert(),400    id_skd_glManageCert: GLManageCert(),401    id_skd_glKey: GLKey(),402}403 404rfc5652.cmsAttributesMap.update(_cmcControlAttributesMapUpdate)405 
codekingpro/portable-devtools · Team Ai