codekingpro/portable-devtools
114k
1#2# This file is part of pyasn1-modules software.3#4# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>5# License: http://snmplabs.com/pyasn1/license.html6#7# PKCS#8 syntax8#9# ASN.1 source from:10# http://tools.ietf.org/html/rfc520811#12# Sample captures could be obtained with "openssl pkcs8 -topk8" command13#14from pyasn1_modules import rfc225115from pyasn1_modules.rfc2459 import *16 17 18class KeyEncryptionAlgorithms(AlgorithmIdentifier):19 pass20 21 22class PrivateKeyAlgorithms(AlgorithmIdentifier):23 pass24 25 26class EncryptedData(univ.OctetString):27 pass28 29 30class EncryptedPrivateKeyInfo(univ.Sequence):31 componentType = namedtype.NamedTypes(32 namedtype.NamedType('encryptionAlgorithm', AlgorithmIdentifier()),33 namedtype.NamedType('encryptedData', EncryptedData())34 )35 36 37class PrivateKey(univ.OctetString):38 pass39 40 41class Attributes(univ.SetOf):42 componentType = rfc2251.Attribute()43 44 45class Version(univ.Integer):46 namedValues = namedval.NamedValues(('v1', 0), ('v2', 1))47 48 49class PrivateKeyInfo(univ.Sequence):50 componentType = namedtype.NamedTypes(51 namedtype.NamedType('version', Version()),52 namedtype.NamedType('privateKeyAlgorithm', AlgorithmIdentifier()),53 namedtype.NamedType('privateKey', PrivateKey()),54 namedtype.OptionalNamedType('attributes', Attributes().subtype(55 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))56 )57 