1# This file is being contributed to pyasn1-modules software.
2#
3# Created by Russ Housley.
4# Modified by Russ Housley to add maps for use with opentypes.
5#
6# Copyright (c) 2019, Vigil Security, LLC
7# License: http://snmplabs.com/pyasn1/license.html
8#
9# Use of the Advanced Encryption Standard (AES) Encryption
10#   Algorithm in the Cryptographic Message Syntax (CMS)
11#
12# ASN.1 source from:
13# https://www.rfc-editor.org/rfc/rfc3565.txt
14
15
16from pyasn1.type import constraint
17from pyasn1.type import univ
18
19from pyasn1_modules import rfc5280
20
21
22class AlgorithmIdentifier(rfc5280.AlgorithmIdentifier):
23    pass
24
25
26class AES_IV(univ.OctetString):
27    pass
28
29AES_IV.subtypeSpec = constraint.ValueSizeConstraint(16, 16)
30
31
32id_aes128_CBC = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.2')
33
34id_aes192_CBC = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.22')
35
36id_aes256_CBC = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.42')
37
38
39id_aes128_wrap = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.5')
40
41id_aes192_wrap = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.25')
42
43id_aes256_wrap = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.45')
44
45
46# Update the Algorithm Identifier map
47
48_algorithmIdentifierMapUpdate = {
49    id_aes128_CBC: AES_IV(),
50    id_aes192_CBC: AES_IV(),
51    id_aes256_CBC: AES_IV(),
52    id_aes128_wrap: univ.Null(),
53    id_aes192_wrap: univ.Null(),
54    id_aes256_wrap: univ.Null(),
55}
56
57rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)
58