OLD | NEW |
(Empty) | |
| 1 # |
| 2 # PKCS#8 syntax |
| 3 # |
| 4 # ASN.1 source from: |
| 5 # http://tools.ietf.org/html/rfc5208 |
| 6 # |
| 7 # Sample captures could be obtained with "openssl pkcs8 -topk8" command |
| 8 # |
| 9 from pyasn1.type import tag, namedtype, namedval, univ, constraint |
| 10 from pyasn1_modules.rfc2459 import * |
| 11 from pyasn1_modules import rfc2251 |
| 12 |
| 13 class KeyEncryptionAlgorithms(AlgorithmIdentifier): pass |
| 14 |
| 15 class PrivateKeyAlgorithms(AlgorithmIdentifier): pass |
| 16 |
| 17 class EncryptedData(univ.OctetString): pass |
| 18 |
| 19 class EncryptedPrivateKeyInfo(univ.Sequence): |
| 20 componentType = namedtype.NamedTypes( |
| 21 namedtype.NamedType('encryptionAlgorithm', AlgorithmIdentifier()), |
| 22 namedtype.NamedType('encryptedData', EncryptedData()) |
| 23 ) |
| 24 |
| 25 class PrivateKey(univ.OctetString): pass |
| 26 |
| 27 class Attributes(univ.SetOf): |
| 28 componentType = rfc2251.Attribute() |
| 29 |
| 30 class Version(univ.Integer): |
| 31 namedValues = namedval.NamedValues(('v1', 0), ('v2', 1)) |
| 32 |
| 33 class PrivateKeyInfo(univ.Sequence): |
| 34 componentType = namedtype.NamedTypes( |
| 35 namedtype.NamedType('version', Version()), |
| 36 namedtype.NamedType('privateKeyAlgorithm', AlgorithmIdentifier()), |
| 37 namedtype.NamedType('privateKey', PrivateKey()), |
| 38 namedtype.OptionalNamedType('attributes', Attributes().subtype(implicitT
ag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))) |
| 39 ) |
OLD | NEW |