-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschemas.py
91 lines (80 loc) · 3.06 KB
/
schemas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from pyderasn import Sequence, OctetString, Any, IA5String, ObjectIdentifier, tag_ctxc, tag_ctxp, BitString, Integer
from pygost.asn1schemas.x509 import Certificate
class KeyAlgorithmParameters(Sequence):
schema = (
("curve", ObjectIdentifier()),
("digest", ObjectIdentifier())
)
class KeyAlgorithm(Sequence):
schema = (
("dh", ObjectIdentifier()),
("parameters", KeyAlgorithmParameters())
)
class PrivateKey(Sequence):
schema = (
("version", Integer(0)),
("params", KeyAlgorithm()),
("key", OctetString())
)
class GostKeyContainerContentAttributes(BitString):
schema = (
("kccaSoftPassword", 0),
("kccaReservePrimary", 1),
("kccaPrimaryKeyAbsent", 2),
("kccaFKCShared", 3)
)
class GostPrivateKeyAttributes(BitString):
schema = (
("pkaExportable", 0),
("pkaUserProtect", 1),
("pkaExchange", 2),
("pkaEphemeral", 3),
("pkaNonCachable", 4),
("pkaDhAllowed", 5)
)
class GostPrivateKeyParameters(Sequence):
schema = (
("attributes", GostPrivateKeyAttributes()),
("privateKeyAlgorithm", KeyAlgorithm(impl=tag_ctxc(0)))
)
class CertificateLink(Sequence):
schema = (
("path", IA5String()),
("hmac", OctetString()),
)
class GostKeyContainerContent(Sequence):
schema = (
("containerAlgoritmIdentifier", ObjectIdentifier(optional=True, expl=tag_ctxc(0))),
("containerName", IA5String(optional=True)),
("attributes", GostKeyContainerContentAttributes()),
("primaryPrivateKeyParameters", GostPrivateKeyParameters()),
("hmacPassword", OctetString(optional=True, impl=tag_ctxp(2))),
("secondaryEncryptedPrivateKey", Any(optional=True, expl=tag_ctxc(3))),
("secondaryPrivateKeyParameters", GostPrivateKeyParameters(optional=True, impl=tag_ctxc(4))),
("primaryCertificate", Certificate(optional=True, expl=tag_ctxp(5))),
("secondaryCertificate", Certificate(optional=True, expl=tag_ctxp(6))),
("encryptionContainerName", IA5String(optional=True, impl=tag_ctxp(7))),
("primaryCertificateLink", CertificateLink(optional=True, impl=tag_ctxc(8))),
("secondaryCertificateLink", CertificateLink(optional=True, impl=tag_ctxc(9))),
("primaryFP", OctetString(impl=tag_ctxp(10))),
("secondaryFP", OctetString(optional=True, impl=tag_ctxp(11))),
("passwordPolicy", ObjectIdentifier(optional=True)),
("containerSecurityLevel", Integer(optional=True)),
("extensions", Any(optional=True, expl=tag_ctxc(12))),
("secondaryEncryptionContainerName", IA5String(optional=True, impl=tag_ctxp(13)))
)
class GostKeyContainer(Sequence):
schema = (
("keyContainerContent", GostKeyContainerContent()),
("hmacKeyContainerContent", OctetString())
)
class GostKeyMask(Sequence):
schema = (
("mask", OctetString()),
("salt", OctetString()),
("hmac", OctetString())
)
class GostKeyPrimary(Sequence):
schema = (
("value", OctetString()),
)