aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pyasn1-modules/py3/pyasn1_modules/rfc5636.py
blob: f87bc4ec82f0b2452c63f896bf45f21513977369 (plain) (blame)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# This file is being contributed to pyasn1-modules software.
#
# Created by Russ Housley.
#
# Copyright (c) 2019, Vigil Security, LLC
# License: http://snmplabs.com/pyasn1/license.html
#
# Traceable Anonymous Certificate
#
# ASN.1 source from:
# https://www.rfc-editor.org/rfc/rfc5480.txt

from pyasn1.type import namedtype
from pyasn1.type import univ
from pyasn1.type import useful

from pyasn1_modules import rfc5652


# Imports from RFC 5652

ContentInfo = rfc5652.ContentInfo

EncapsulatedContentInfo = rfc5652.EncapsulatedContentInfo

id_data = rfc5652.id_data


# Object Identifiers

id_KISA = univ.ObjectIdentifier((1, 2, 410, 200004,))


id_npki = id_KISA + (10,)


id_attribute = id_npki + (1,)


id_kisa_tac = id_attribute + (1,)


id_kisa_tac_token = id_kisa_tac + (1,)


id_kisa_tac_tokenandblindbash = id_kisa_tac + (2,)


id_kisa_tac_tokenandpartially = id_kisa_tac + (3,)


# Structures for Traceable Anonymous Certificate (TAC)

class UserKey(univ.OctetString):
    pass


class Timeout(useful.GeneralizedTime):
    pass


class BlinedCertificateHash(univ.OctetString):
    pass


class PartiallySignedCertificateHash(univ.OctetString):
    pass


class Token(ContentInfo):
    pass


class TokenandBlindHash(ContentInfo):
    pass


class TokenandPartiallySignedCertificateHash(ContentInfo):
    pass


# Added to the module in RFC 5636 for the CMS Content Type Map

class TACToken(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('userKey', UserKey()),
        namedtype.NamedType('timeout', Timeout())
    )


class TACTokenandBlindHash(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('token', Token()),
        namedtype.NamedType('blinded', BlinedCertificateHash())
    )


class TACTokenandPartiallySignedCertificateHash(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('token', Token()),
        namedtype.NamedType('partially', PartiallySignedCertificateHash())
    )


# Add to the CMS Content Type Map in rfc5752.py

_cmsContentTypesMapUpdate = {
    id_kisa_tac_token: TACToken(),
    id_kisa_tac_tokenandblindbash: TACTokenandBlindHash(),
    id_kisa_tac_tokenandpartially: TACTokenandPartiallySignedCertificateHash(),
}

rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate)